From 55e24e1f24b932592ba3b24c8e97c3410c1a9d8b Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 6 Dec 2016 21:45:20 +0100 Subject: [PATCH 1/4] inn was assuming that bitfields were arrays of bytes, when actually they're arrays of words (which makes the LSB move on big-endian systems). --- mach/powerpc/libem/inn.s | 6 +++--- tests/plat/inn_e.e | 27 ++++++++++----------------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/mach/powerpc/libem/inn.s b/mach/powerpc/libem/inn.s index f5ae4c63e..9770ac094 100644 --- a/mach/powerpc/libem/inn.s +++ b/mach/powerpc/libem/inn.s @@ -13,10 +13,10 @@ lwz r4, 4(sp) /* r4 = bit number */ addi r5, sp, 8 /* r5 = base address of bit set */ - srawi r6, r4, 3 /* r6 = byte address into set */ - andi. r7, r4, 7 /* r7 = bit within byte */ + rlwinm r6, r4, 29, 3, 29 /* r6 = byte index of word in set */ + andi. r7, r4, 31 /* r7 = bit within word */ - lbzx r8, r5, r6 /* r8 = individual byte from set */ + lwzx r8, r5, r6 /* r8 = individual byte from set */ sraw r8, r8, r7 rlwinm r8, r8, 0, 31, 31 diff --git a/tests/plat/inn_e.e b/tests/plat/inn_e.e index 7d27abf42..a5aee02f5 100644 --- a/tests/plat/inn_e.e +++ b/tests/plat/inn_e.e @@ -7,10 +7,10 @@ /* Test non-existent bit */ .1 - rom 0I1, 0I1, 0I1, 0I1 + rom 0I4 loe .1 loc 1 /* bit number */ - inn EM_WSIZE + inn 4 zeq *1 loc __LINE__ @@ -21,9 +21,12 @@ /* Test existent bit */ .2 - rom 2I1, 0I1, 0I1, 0I1 + rom 16384 +.21 + rom 14 /* to defeat constant folding */ + loe .2 - loc 1 /* bit number */ + loe .21 /* bit number */ inn EM_WSIZE zne *2 @@ -35,10 +38,9 @@ /* Test non-existent high bit */ .3 - rom 0I1, 0I1, 0I1, 0I1 - rom 0I1, 0I1, 0I1, 0I1 + rom 0, 0 .31 - rom (EM_WSIZE*8)+1 /* to defeat constant folding */ + rom 8 /* to defeat constant folding */ lae .3 loi EM_WSIZE*2 @@ -54,16 +56,7 @@ /* Test existent high bit */ .4 -#if EM_WSIZE == 2 - rom 0I1, 0I1 - rom 2I1, 0I1 -#elif EM_WSIZE == 4 - rom 0I1, 0I1, 0I1, 0I1 - rom 2I1, 0I1, 0I1, 0I1 -#else - #error Unknown word size -#endif - + rom 0, 2 .41 rom (EM_WSIZE*8)+1 /* to defeat constant folding */ From cc3d72e884848fce02ad44277924d9eecce14ff0 Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 6 Dec 2016 22:05:14 +0100 Subject: [PATCH 2/4] Fix redirection so stray stderr output from qemu doesn't cause mysterious test failures. --- tests/plat/testdriver.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/plat/testdriver.sh b/tests/plat/testdriver.sh index 5e8e5b899..384c83b47 100755 --- a/tests/plat/testdriver.sh +++ b/tests/plat/testdriver.sh @@ -27,7 +27,7 @@ get_test_output() { qemu-system-ppc) img="-kernel $img" ;; esac - $timeoutprog -t $timeout -- $method -nographic $img 2>&1 > $result + $timeoutprog -t $timeout -- $method -nographic $img > $result 2>&1 ;; qemu-*) @@ -37,7 +37,7 @@ get_test_output() { exit 0 fi - $method $img 2>&1 > $result + $method $img > $result 2>&1 ;; *) From 67e7d226ad15464ed9133810defa474cc021627e Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 6 Dec 2016 22:06:17 +0100 Subject: [PATCH 3/4] Disable qemuppc tests; turns out qemu-system-ppc won't load more than the first 4kB of a kernel... --- build.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.lua b/build.lua index 6364e5f75..91415d689 100644 --- a/build.lua +++ b/build.lua @@ -18,7 +18,7 @@ vars.plats = { vars.plats_with_tests = { "linux386", "linuxppc", - "qemuppc", + -- "qemuppc", FIXME: disable until we figure out why qemu won't run binaries bigger than 4kB "pc86", } From 1039c0a7473ff5f6bf03ace435ca6ecc46edb060 Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 6 Dec 2016 22:07:22 +0100 Subject: [PATCH 4/4] Add a test for #22. --- tests/plat/{_dummy.c => _dummy_e.c} | 0 tests/plat/bugs/bug-22-inn_mod.mod | 26 ++++++++++++++++++++++++++ tests/plat/build.lua | 9 +++++---- 3 files changed, 31 insertions(+), 4 deletions(-) rename tests/plat/{_dummy.c => _dummy_e.c} (100%) create mode 100644 tests/plat/bugs/bug-22-inn_mod.mod diff --git a/tests/plat/_dummy.c b/tests/plat/_dummy_e.c similarity index 100% rename from tests/plat/_dummy.c rename to tests/plat/_dummy_e.c diff --git a/tests/plat/bugs/bug-22-inn_mod.mod b/tests/plat/bugs/bug-22-inn_mod.mod new file mode 100644 index 000000000..8f3a2d00a --- /dev/null +++ b/tests/plat/bugs/bug-22-inn_mod.mod @@ -0,0 +1,26 @@ +MODULE test; +FROM InOut IMPORT WriteLn, WriteString; + +TYPE charset = SET OF CHAR; + +PROCEDURE Space(c: CHAR): BOOLEAN; +BEGIN + RETURN c IN charset{' ', 11C, 12C, 15C} +END Space; + +BEGIN + IF Space('a') THEN + WriteString("@@FAIL 1"); + WriteLn; + END; + IF NOT Space(' ') THEN + WriteString("@@FAIL 2"); + WriteLn; + END; + IF NOT Space(12C) THEN + WriteString("@@FAIL 3"); + WriteLn; + END; + WriteString("@@FINISHED"); + WriteLn; +END test. \ No newline at end of file diff --git a/tests/plat/build.lua b/tests/plat/build.lua index f5885a190..d8362b3a0 100644 --- a/tests/plat/build.lua +++ b/tests/plat/build.lua @@ -11,7 +11,8 @@ definerule("plat_testsuite", local testfiles = filenamesof( "tests/plat/*.c", "tests/plat/*.e", - "tests/plat/*.p" + "tests/plat/*.p", + "tests/plat/bugs/*.mod" ) acklibrary { @@ -23,8 +24,8 @@ definerule("plat_testsuite", local tests = {} for _, f in ipairs(testfiles) do - local fs = replace(basename(f), "%..$", "") - local _, _, lang = fs:find("_(.)$") + local fs = replace(basename(f), "%.[^.]+$", "") + local _, _, lang = fs:find("_([^_]+)$") if not lang then lang = "e" end @@ -49,7 +50,7 @@ definerule("plat_testsuite", "util/build+testrunner" }, commands = { - "(%{ins[2]} "..e.method.." %{ins[1]} 5 %{ins[3]} || echo FAILED) 2>&1 > %{outs}", + "(%{ins[2]} "..e.method.." %{ins[1]} 5 %{ins[3]} || echo FAILED) > %{outs}", } } end