# HG changeset patch # User Tassilo Philipp # Date 1647877844 -3600 # Node ID 45ac093ca82239250d5f0f2fbc5c020c8ec4fd12 # Parent d45c582b5457156e0e3a83fd326e7cea7014feab - test/callback_suite: make it use shared random sig generator from call_suite and call_suite_aggrs diff -r d45c582b5457 -r 45ac093ca822 test/callback_suite/README.txt --- a/test/callback_suite/README.txt Mon Mar 21 16:06:16 2022 +0100 +++ b/test/callback_suite/README.txt Mon Mar 21 16:50:44 2022 +0100 @@ -58,9 +58,9 @@ Specify 'api' and 'ccprefix' accordingly: -"__stdcall" "_s" -"__fastcall" "_f" for gcc compiler - "_F" for microsoft compiler +"__stdcall" "_s" +"__fastcall" "_f" for gcc compiler + "_F" for microsoft compiler diff -r d45c582b5457 -r 45ac093ca822 test/callback_suite/config-random.lua --- a/test/callback_suite/config-random.lua Mon Mar 21 16:06:16 2022 +0100 +++ b/test/callback_suite/config-random.lua Mon Mar 21 16:50:44 2022 +0100 @@ -1,6 +1,6 @@ -- section 'main' -------------------------------------------------------------- -nsigs = 800 -- number of test cases +ncases = 800 -- number of test cases mode = "random" -- generatore mode: 'random' or 'ordered' type sequences minargs = 0 -- minimum num. of supported arguments (>= 0) maxargs = 67 -- maximum num. of supported arguments (>= minargs) @@ -8,8 +8,8 @@ -- section 'types' ------------------------------------------------------------- -argtypes = "BcCsSiIjJlLpfd" -- supported argument types -rettypes = argtypes -- supported return types (currently no void support) +types = "BcCsSiIjJlLpfd" -- supported argument types +rtypes = types -- supported return types (currently no void support) -- section 'ordered' ----------------------------------------------------------- @@ -20,12 +20,11 @@ -- section 'random' ------------------------------------------------------------ -seed = 40 -- random seed +seed = 40 -- random seed -- section 'calling convention' (useful on Windows for now) -------------------- api = "" -- calling convention ("__stdcall" or "__fastcall") - -- for gcc use "__attribute__((__stdcall__))" or "__attribute__((__fastcall__))" - -- for ms ? + -- for gcc use "__attribute__((__stdcall__))" or "__attribute__((__fastcall__))" ccprefix = "" -- signature prefix ("_s" (stdcall), "_f" (gcc fastcall) or "_F" (microsoft fastcall)) diff -r d45c582b5457 -r 45ac093ca822 test/callback_suite/config-stress1.lua --- a/test/callback_suite/config-stress1.lua Mon Mar 21 16:06:16 2022 +0100 +++ b/test/callback_suite/config-stress1.lua Mon Mar 21 16:50:44 2022 +0100 @@ -11,15 +11,15 @@ return cnt end -nsigs = nlines() -- number of test cases +ncases = nlines() -- number of test cases minargs = 0 -- minimum num. of supported arguments (>= 0) maxargs = 20 -- maximum num. of supported arguments (>= minargs) -- section 'types' (not used by 'designed') ------------------------------------ -argtypes = "BcCsSiIjJlLpfd" -- "BcCsSiIjJlLpfd" -- supported argument types -rettypes = argtypes -- supported return types (currently no void support) +types = "BcCsSiIjJlLpfd" -- "BcCsSiIjJlLpfd" -- supported argument types +rtypes = types -- supported return types (currently no void support) -- section 'ordered' ----------------------------------------------------------- diff -r d45c582b5457 -r 45ac093ca822 test/callback_suite/config.lua --- a/test/callback_suite/config.lua Mon Mar 21 16:06:16 2022 +0100 +++ b/test/callback_suite/config.lua Mon Mar 21 16:50:44 2022 +0100 @@ -1,7 +1,7 @@ -- auto-generated file from template config-random.lua (created by GNUmake) -- section 'main' -------------------------------------------------------------- -nsigs = 800 -- number of test cases +ncases = 800 -- number of test cases (note: inf loop if higher than max arg permutation) mode = "random" -- generatore mode: 'random' or 'ordered' type sequences minargs = 0 -- minimum num. of supported arguments (>= 0) maxargs = 67 -- maximum num. of supported arguments (>= minargs) @@ -9,8 +9,8 @@ -- section 'types' ------------------------------------------------------------- -argtypes = "BcCsSiIjJlLpfd" -- supported argument types -rettypes = argtypes -- supported return types (currently no void support) +types = "BcCsSiIjJlLpfd" -- supported argument types +rtypes = types -- supported return types (currently no void support) -- section 'ordered' ----------------------------------------------------------- diff -r d45c582b5457 -r 45ac093ca822 test/callback_suite/main.c --- a/test/callback_suite/main.c Mon Mar 21 16:06:16 2022 +0100 +++ b/test/callback_suite/main.c Mon Mar 21 16:50:44 2022 +0100 @@ -75,15 +75,15 @@ int number; if(argv[i][0] == '-') - { + { switch(argv[i][1]) { case 'v': - OptionVerbose = 1; - continue; + OptionVerbose = 1; + continue; case 'h': case '?': - PrintUsage(argv[0]); - return 0; + PrintUsage(argv[0]); + return 0; default: Error("invalid option: %s\n\n", argv[i], argv[0]); } } diff -r d45c582b5457 -r 45ac093ca822 test/callback_suite/make-config.lua --- a/test/callback_suite/make-config.lua Mon Mar 21 16:06:16 2022 +0100 +++ b/test/callback_suite/make-config.lua Mon Mar 21 16:50:44 2022 +0100 @@ -2,7 +2,7 @@ local defs = { MAXARGS = maxargs, - NSIGS = nsigs, + NSIGS = ncases, API = api } diff -r d45c582b5457 -r 45ac093ca822 test/callback_suite/make-invoke-table.lua --- a/test/callback_suite/make-invoke-table.lua Mon Mar 21 16:06:16 2022 +0100 +++ b/test/callback_suite/make-invoke-table.lua Mon Mar 21 16:50:44 2022 +0100 @@ -1,7 +1,7 @@ require "config" local i -for i = 1, nsigs do +for i = 1, ncases do line = "&f" .. i .. ",\n" io.write(line) end diff -r d45c582b5457 -r 45ac093ca822 test/callback_suite/make-signatures.lua --- a/test/callback_suite/make-signatures.lua Mon Mar 21 16:06:16 2022 +0100 +++ b/test/callback_suite/make-signatures.lua Mon Mar 21 16:50:44 2022 +0100 @@ -2,47 +2,37 @@ require "math" require "string" -local nargtypes = string.len(argtypes) -local nrettypes = string.len(rettypes) -local argrange = maxargs - minargs -math.randomseed(seed) -function randomSignatures(nsigs) - local i - for i = 1, nsigs do - local nargs = minargs + math.random(argrange+1) - 1 - local signature = "" - for j = 1, nargs do - local typeindex = math.random(nargtypes) - signature = signature .. string.sub(argtypes, typeindex, typeindex) - end - local rtypeindex = math.random(nrettypes) - signature = signature .. ")" .. string.sub(rettypes, rtypeindex, rtypeindex) - io.write(signature .. "\n") - end +function randomSignatures() + package.path = '../common/?.lua;' .. package.path + require"rand-sig" end + function orderedSignature(x) local signature = "" local typeindex + local nargtypes = string.len(types) while true do if x < nargtypes then break end typeindex = 1 + math.mod(x, nargtypes) - signature = signature .. string.sub(argtypes, typeindex, typeindex) + signature = signature .. string.sub(types, typeindex, typeindex) x = math.floor( x / nargtypes ) end typeindex = 1 + x - signature = signature .. ")" .. string.sub(argtypes, typeindex, typeindex) + signature = signature .. ")" .. string.sub(types, typeindex, typeindex) return signature end -function orderedSignatures(nsigs) + +function orderedSignatures() local i - for i = 1, nsigs do + for i = 1, ncases do io.write( orderedSignature(offset+i*step) .. "\n" ) end end + function designedSignatures() for line in io.lines(designfile) do io.write( line ) @@ -50,14 +40,15 @@ end end + if mode == "random" then - randomSignatures(nsigs) + randomSignatures() elseif mode == "ordered" then - orderedSignatures(nsigs) + orderedSignatures() elseif mode == "designed" then designedSignatures() else - error("'mode' must be 'random' or 'ordered'") + error("'mode' must be 'random', 'ordered' or 'designed'") end io.flush() diff -r d45c582b5457 -r 45ac093ca822 test/common/rand-sig.lua --- a/test/common/rand-sig.lua Mon Mar 21 16:06:16 2022 +0100 +++ b/test/common/rand-sig.lua Mon Mar 21 16:50:44 2022 +0100 @@ -7,6 +7,9 @@ -- types -- seed +-- optional: +-- rtypes (if not set, it'll be 'v'..types) + -- optional (when including aggregate generation): -- minaggrfields -- maxaggrfields @@ -36,7 +39,10 @@ end -rtypes = "v"..types +if rtypes == nil then + rtypes = "v"..types +end + function mkaggr(n_nest, maxdepth, o, c) local s = o @@ -45,16 +51,16 @@ repeat local t = c if nfields < maxaggrfields then - repeat + repeat local id = math.random(#types) t = types:sub(id,id) until t ~= c or nfields >= minaggrfields end s_ = mktype(t, n_nest, maxdepth, o) - if(#s_ > 0) then + if(#s_ > 0) then nfields = nfields + 1 - end + end s = s..s_ -- member (which cannot be first char) as array? Disallow multidimensional arrays @@@STRUCT allow multidim? @@ -121,6 +127,14 @@ -- reject dupes, sigs without any aggregate (as this is about aggrs after all), and empty ones (if not wanted) until (reqaggrinsig ~= true or string.match(l, aggr_op_pattern) ~= nil) and uniq_sigs[l] == nil uniq_sigs[l] = 1 - io.write(l.."\n") + + -- @@@ hack: if included from callback_suite, 'mode' is set, and has value "random"; make sig + -- be in expected format + -- @@@ all sigs should follow that dyncally format + if mode ~= nil and mode == 'random' then + io.write(l:sub(2)..')'..l:sub(1,1).."\n") + else + io.write(l.."\n") + end end