Refactored the tests to make the generic across different plats.

This commit is contained in:
David Given 2016-11-25 21:02:51 +01:00
parent bfa8e501a3
commit 5f66f06dc6
24 changed files with 63 additions and 48 deletions

View file

@ -1,49 +1,7 @@
include("plat/build.lua")
include("tests/plat/build.lua")
local qemu = "qemu-system-ppc"
local tests = {}
if os.execute("which "..qemu.." > /dev/null") ~= 0 then
print("warning: skipping tests which require ", qemu)
else
local testcases = filenamesof("./*.c", "./*.s", "./*.e", "./*.p")
for _, f in ipairs(testcases) do
local fs = replace(basename(f), "%..$", "")
local _, _, lang = fs:find("_(.)$")
if not lang then
lang = "e"
end
local bin = ackprogram {
name = fs.."_bin",
srcs = { f },
deps = { "plat/qemuppc/tests/lib+lib" },
vars = {
plat = "qemuppc",
lang = lang,
ackcflags = "-O0"
}
}
tests[#tests+1] = normalrule {
name = fs,
outleaves = { "stamp" },
ins = {
bin,
"./testdriver.sh"
},
commands = {
"%{ins[2]} "..qemu.." %{ins[1]} 5",
"touch %{outs}"
}
}
end
end
normalrule {
name = "tests",
outleaves = { "stamp" },
ins = tests,
commands = { "touch %{outs}" }
plat_testsuite {
name = "tests",
plat = "qemuppc",
method = "qemu-system-ppc"
}

57
tests/plat/build.lua Normal file
View file

@ -0,0 +1,57 @@
include("plat/build.lua")
definerule("plat_testsuite",
{
plat = { type="string" },
method = { type="string" },
},
function(e)
-- Remember this is executed from the caller's directory; local
-- target names will resolve there.
local testfiles = filenamesof(
"tests/plat/*.c",
"tests/plat/*.e",
"tests/plat/*.p"
)
local tests = {}
for _, f in ipairs(testfiles) do
local fs = replace(basename(f), "%..$", "")
local _, _, lang = fs:find("_(.)$")
if not lang then
lang = "e"
end
local bin = ackprogram {
name = fs.."_bin",
srcs = { f },
deps = { "tests/plat/lib+lib" },
vars = {
plat = e.plat,
lang = lang,
ackcflags = "-O0"
}
}
tests[#tests+1] = normalrule {
name = fs,
outleaves = { "stamp" },
ins = {
bin,
"tests/plat/testdriver.sh"
},
commands = {
"%{ins[2]} "..e.method.." %{ins[1]} 5",
"touch %{outs}"
}
}
end
return normalrule {
name = e.name,
outleaves = { "stamp" },
ins = tests,
commands = { "touch %{outs}" }
}
end
)