comparison test/callback_suite/mk-cases.lua @ 509:f3d44195dbdf

callback_suite: - further, big refactoring to make the test data setup be a lot more in line with call_suite and call_suite_aggrs - added support to test void return values (was missing in prev version)
author Tassilo Philipp
date Sat, 09 Apr 2022 23:00:24 +0200
parents 5a3c07a0f376
children 95f6f43178ed
comparison
equal deleted inserted replaced
508:1aa2af848e8a 509:f3d44195dbdf
1 require "config" 1 require "config"
2 2
3 function trim(l) return l:gsub("^%s+",""):gsub("%s+$","") end 3 function trim(l) return l:gsub("^%s+",""):gsub("%s+$","") end
4 function mkcase(id,sig) 4 function mkcase(id,sig)
5 local nargs = string.len(sig) - 2 5 local nargs = string.len(sig) - 2 -- @@@ wrong, b/c ignores callconv prefixes
6 local rtype = string.sub(sig, nargs + 2, nargs + 2) 6 local rtype = string.sub(sig, -1)
7 local s = "F" .. nargs .. "(f" .. id .. "," .. rtype 7 local s = "F" .. nargs .. "(f" .. id .. "," .. rtype
8 for i = 1, nargs do 8 for i = 1, nargs do
9 local type = string.sub(sig, i, i) 9 local type = string.sub(sig, i, i)
10 s = s .. "," .. type 10 s = s .. "," .. type
11 end 11 end
50 if j > 0 then 50 if j > 0 then
51 argdef = argdef .. "," 51 argdef = argdef .. ","
52 argset = argset .. "," 52 argset = argset .. ","
53 end 53 end
54 argdef = argdef .. "M" .. j 54 argdef = argdef .. "M" .. j
55 argset = argset .. "M[" .. j .. "].M" .. j 55 argset = argset .. "K_##M" .. j .. "[" .. j .. "]"
56 end 56 end
57 end 57 end
58 line = line .. argdef .. ") void ID(void* addr) { Result.R = ((CONFIG_API R(*)(" .. argdef .. "))addr)(" .. argset .. ");}\n" 58 line = line .. argdef .. ") void ID(void* addr) { write_V_##R(" .. i .. ", ((CONFIG_API R(*)(" .. argdef .. "))addr)(" .. argset .. "));}\n"
59 io.write(line) 59 io.write(line)
60 end 60 end
61 61
62 -- cases 62 -- cases
63 local lineno = 0 63 local lineno = 0