From 03ab00aec5d10f4a2d048fab7f16489cf33fcc1d Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Mon, 24 Oct 2016 14:21:51 +0200 Subject: Update the tests and test infrastructure in test/regression Tests updated to work with x86 64 bits. Infrastructure added: script "Runtest", with ability to have different reference outputs depending on platform or bit size. --- test/regression/Results/initializers | 30 ----------------- test/regression/Results/initializers-32 | 30 +++++++++++++++++ test/regression/Results/initializers-64 | 30 +++++++++++++++++ test/regression/Results/packedstruct1 | 25 --------------- test/regression/Results/packedstruct1-32 | 25 +++++++++++++++ test/regression/Results/packedstruct1-64 | 25 +++++++++++++++ test/regression/Results/sizeof1 | 3 -- test/regression/Results/sizeof1-32 | 3 ++ test/regression/Results/sizeof1-64 | 3 ++ test/regression/Runtest | 55 ++++++++++++++++++++++++++++++++ test/regression/builtins-ia32.c | 2 ++ test/regression/extasm.c | 12 ++++++- test/regression/initializers2.c | 2 +- test/regression/sizeof1.c | 6 ++-- test/regression/sizeof2.c | 4 +-- 15 files changed, 190 insertions(+), 65 deletions(-) delete mode 100644 test/regression/Results/initializers create mode 100644 test/regression/Results/initializers-32 create mode 100644 test/regression/Results/initializers-64 delete mode 100644 test/regression/Results/packedstruct1 create mode 100644 test/regression/Results/packedstruct1-32 create mode 100644 test/regression/Results/packedstruct1-64 delete mode 100644 test/regression/Results/sizeof1 create mode 100644 test/regression/Results/sizeof1-32 create mode 100644 test/regression/Results/sizeof1-64 create mode 100755 test/regression/Runtest (limited to 'test/regression') diff --git a/test/regression/Results/initializers b/test/regression/Results/initializers deleted file mode 100644 index a3c92e86..00000000 --- a/test/regression/Results/initializers +++ /dev/null @@ -1,30 +0,0 @@ -x0 = 0 -x1 = 'x' -x2 = 12345 -x3 = 3.14159 -x4 = { 'a', 'b', 'c', 'd' } -x5 = { 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, } -x6 = { 4, 5 } -x7 = { 6, 'u' } -x8 = { 'v', 7 } -x9 = { { 'a', 'b', 0, 0, 0, 0, 0, 0, 0, }, 2.718 } -x10 = { { 'v', 7 }, 2.718 } -x11 = 1.3183101416 -x12 = 1.3183101550 -x13 = { 0, 1 } -x14 ok -x15 ok -x16 ok -x17[7] = { 'H', 'e', 'l', 'l', 'o', '!', 0, } -x18 = "Hello!" -x19 = { "Hello", "world!" } -x20 = { 'H', 'e', 'l', } -x21 = { 'H', 'e', 'l', 'l', 'o', '!', 0, 0, 0, 0, } -x22 ok -x23 = { hd = 8, tl = ok } -x24[6] = { '/', '*', 'B', '*', '/', 0, } -x25[4] = { "/tmp" } -x26[6] = { 'w', 'o', 'r', 'l', 'd', 0, } -x27[4] = { 'a', 'b', 'c', 0, } -x28[2] = { 'a', 'b', } -x29[10] = { 'a', 'b', 'c', 0, 0, 0, 0, 0, 0, 0, } diff --git a/test/regression/Results/initializers-32 b/test/regression/Results/initializers-32 new file mode 100644 index 00000000..a3c92e86 --- /dev/null +++ b/test/regression/Results/initializers-32 @@ -0,0 +1,30 @@ +x0 = 0 +x1 = 'x' +x2 = 12345 +x3 = 3.14159 +x4 = { 'a', 'b', 'c', 'd' } +x5 = { 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, } +x6 = { 4, 5 } +x7 = { 6, 'u' } +x8 = { 'v', 7 } +x9 = { { 'a', 'b', 0, 0, 0, 0, 0, 0, 0, }, 2.718 } +x10 = { { 'v', 7 }, 2.718 } +x11 = 1.3183101416 +x12 = 1.3183101550 +x13 = { 0, 1 } +x14 ok +x15 ok +x16 ok +x17[7] = { 'H', 'e', 'l', 'l', 'o', '!', 0, } +x18 = "Hello!" +x19 = { "Hello", "world!" } +x20 = { 'H', 'e', 'l', } +x21 = { 'H', 'e', 'l', 'l', 'o', '!', 0, 0, 0, 0, } +x22 ok +x23 = { hd = 8, tl = ok } +x24[6] = { '/', '*', 'B', '*', '/', 0, } +x25[4] = { "/tmp" } +x26[6] = { 'w', 'o', 'r', 'l', 'd', 0, } +x27[4] = { 'a', 'b', 'c', 0, } +x28[2] = { 'a', 'b', } +x29[10] = { 'a', 'b', 'c', 0, 0, 0, 0, 0, 0, 0, } diff --git a/test/regression/Results/initializers-64 b/test/regression/Results/initializers-64 new file mode 100644 index 00000000..63cc0eb7 --- /dev/null +++ b/test/regression/Results/initializers-64 @@ -0,0 +1,30 @@ +x0 = 0 +x1 = 'x' +x2 = 12345 +x3 = 3.14159 +x4 = { 'a', 'b', 'c', 'd' } +x5 = { 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, } +x6 = { 4, 5 } +x7 = { 6, 'u' } +x8 = { 'v', 7 } +x9 = { { 'a', 'b', 0, 0, 0, 0, 0, 0, 0, }, 2.718 } +x10 = { { 'v', 7 }, 2.718 } +x11 = 1.3183101416 +x12 = 1.3183101550 +x13 = { 0, 1 } +x14 ok +x15 ok +x16 ok +x17[7] = { 'H', 'e', 'l', 'l', 'o', '!', 0, } +x18 = "Hello!" +x19 = { "Hello", "world!" } +x20 = { 'H', 'e', 'l', } +x21 = { 'H', 'e', 'l', 'l', 'o', '!', 0, 0, 0, 0, } +x22 ok +x23 = { hd = 16, tl = ok } +x24[6] = { '/', '*', 'B', '*', '/', 0, } +x25[8] = { "/tmp" } +x26[6] = { 'w', 'o', 'r', 'l', 'd', 0, } +x27[4] = { 'a', 'b', 'c', 0, } +x28[2] = { 'a', 'b', } +x29[10] = { 'a', 'b', 'c', 0, 0, 0, 0, 0, 0, 0, } diff --git a/test/regression/Results/packedstruct1 b/test/regression/Results/packedstruct1 deleted file mode 100644 index e4bca769..00000000 --- a/test/regression/Results/packedstruct1 +++ /dev/null @@ -1,25 +0,0 @@ -sizeof(struct s1) = 14 -offsetof(x) = 0, offsetof(y) = 2, offsetof(z) = 6 -s1 = {x = 123, y = -456, z = 3.14159} - -sizeof(struct s2) = 16 -&s2 mod 16 = 0 -offsetof(x) = 0, offsetof(y) = 2, offsetof(z) = 6 -s2 = {x = 57, y = -456, z = 3.14159} - -sizeof(struct s3) = 31 -offsetof(s) = 29 -s3 = {x = 123, y = 45678, z = 2147483649, v = -456, w = -1234567, p is ok, t = {111,222,333}, s = {'o','k'}} - -sizeof(struct s4) = 16 -offsetof(x) = 0, offsetof(y) = 4, offsetof(z) = 8 -s4 = {x = 123, y = -456, z = 3.14159} - -sizeof(struct s5) = 14 -offsetof(x) = 0, offsetof(y) = 2, offsetof(z) = 6 -s5 = {x = 123, y = -456, z = 3.14159} - -sizeof(struct s6) = 14 -offsetof(x) = 0, offsetof(y) = 2, offsetof(z) = 6 -s62 = {x = 123, y = -456, z = 3.14159} - diff --git a/test/regression/Results/packedstruct1-32 b/test/regression/Results/packedstruct1-32 new file mode 100644 index 00000000..e4bca769 --- /dev/null +++ b/test/regression/Results/packedstruct1-32 @@ -0,0 +1,25 @@ +sizeof(struct s1) = 14 +offsetof(x) = 0, offsetof(y) = 2, offsetof(z) = 6 +s1 = {x = 123, y = -456, z = 3.14159} + +sizeof(struct s2) = 16 +&s2 mod 16 = 0 +offsetof(x) = 0, offsetof(y) = 2, offsetof(z) = 6 +s2 = {x = 57, y = -456, z = 3.14159} + +sizeof(struct s3) = 31 +offsetof(s) = 29 +s3 = {x = 123, y = 45678, z = 2147483649, v = -456, w = -1234567, p is ok, t = {111,222,333}, s = {'o','k'}} + +sizeof(struct s4) = 16 +offsetof(x) = 0, offsetof(y) = 4, offsetof(z) = 8 +s4 = {x = 123, y = -456, z = 3.14159} + +sizeof(struct s5) = 14 +offsetof(x) = 0, offsetof(y) = 2, offsetof(z) = 6 +s5 = {x = 123, y = -456, z = 3.14159} + +sizeof(struct s6) = 14 +offsetof(x) = 0, offsetof(y) = 2, offsetof(z) = 6 +s62 = {x = 123, y = -456, z = 3.14159} + diff --git a/test/regression/Results/packedstruct1-64 b/test/regression/Results/packedstruct1-64 new file mode 100644 index 00000000..c2a8bcd2 --- /dev/null +++ b/test/regression/Results/packedstruct1-64 @@ -0,0 +1,25 @@ +sizeof(struct s1) = 14 +offsetof(x) = 0, offsetof(y) = 2, offsetof(z) = 6 +s1 = {x = 123, y = -456, z = 3.14159} + +sizeof(struct s2) = 16 +&s2 mod 16 = 0 +offsetof(x) = 0, offsetof(y) = 2, offsetof(z) = 6 +s2 = {x = 57, y = -456, z = 3.14159} + +sizeof(struct s3) = 35 +offsetof(s) = 33 +s3 = {x = 123, y = 45678, z = 2147483649, v = -456, w = -1234567, p is ok, t = {111,222,333}, s = {'o','k'}} + +sizeof(struct s4) = 16 +offsetof(x) = 0, offsetof(y) = 4, offsetof(z) = 8 +s4 = {x = 123, y = -456, z = 3.14159} + +sizeof(struct s5) = 14 +offsetof(x) = 0, offsetof(y) = 2, offsetof(z) = 6 +s5 = {x = 123, y = -456, z = 3.14159} + +sizeof(struct s6) = 14 +offsetof(x) = 0, offsetof(y) = 2, offsetof(z) = 6 +s62 = {x = 123, y = -456, z = 3.14159} + diff --git a/test/regression/Results/sizeof1 b/test/regression/Results/sizeof1 deleted file mode 100644 index a952be52..00000000 --- a/test/regression/Results/sizeof1 +++ /dev/null @@ -1,3 +0,0 @@ -sizeof(struct s) = 20, sizeof(tbl) = 20 -sizeof(struct bits1) = 1, sizeof(b1) = 1 -sizeof(struct bits2) = 8, sizeof(b2) = 8 diff --git a/test/regression/Results/sizeof1-32 b/test/regression/Results/sizeof1-32 new file mode 100644 index 00000000..a952be52 --- /dev/null +++ b/test/regression/Results/sizeof1-32 @@ -0,0 +1,3 @@ +sizeof(struct s) = 20, sizeof(tbl) = 20 +sizeof(struct bits1) = 1, sizeof(b1) = 1 +sizeof(struct bits2) = 8, sizeof(b2) = 8 diff --git a/test/regression/Results/sizeof1-64 b/test/regression/Results/sizeof1-64 new file mode 100644 index 00000000..674f6dad --- /dev/null +++ b/test/regression/Results/sizeof1-64 @@ -0,0 +1,3 @@ +sizeof(struct s) = 32, sizeof(tbl) = 32 +sizeof(struct bits1) = 1, sizeof(b1) = 1 +sizeof(struct bits2) = 8, sizeof(b2) = 8 diff --git a/test/regression/Runtest b/test/regression/Runtest new file mode 100755 index 00000000..7cc6330b --- /dev/null +++ b/test/regression/Runtest @@ -0,0 +1,55 @@ +#!/bin/sh + +# The name of the test +name="$1" +shift + +# The temp file for output +out="test$$.log" +rm -f $out +trap "rm -f $out" 0 INT QUIT + +# The architecture and the model +arch=`sed -n -e 's/^ARCH=//p' ../../Makefile.config` +model=`sed -n -e 's/^MODEL=//p' ../../Makefile.config` + +# Its bit size +case "$arch,$model" in + ia32,64) bits=64;; + *) bits=32;; +esac + +# The reference output +if test -f "Results/$name-$arch-$model"; then + ref="Results/$name-$arch-$model" +elif test -f "Results/$name-$arch"; then + ref="Results/$name-$arch" +elif test -f "Results/$name-$bits"; then + ref="Results/$name-$bits" +elif test -f "Results/$name"; then + ref="Results/$name" +else + ref="" +fi + +# Administer the test +if $* > $out +then + if test -n "$ref"; then + if cmp -s "$out" "$ref"; then + echo "$name: passed" + exit 0 + else + echo "$name: WRONG OUTPUT (diff follows)" + diff -u "$ref" "$out" + exit 2 + fi + else + echo "$name: passed" + exit 0 + fi +else + echo "$name: EXECUTION FAILED (status $?)" + exit 2 +fi + diff --git a/test/regression/builtins-ia32.c b/test/regression/builtins-ia32.c index 9b7ed126..1ba213e7 100644 --- a/test/regression/builtins-ia32.c +++ b/test/regression/builtins-ia32.c @@ -8,6 +8,7 @@ int main(int argc, char ** argv) unsigned int y = 0xDEADBEEF; unsigned long long xx = 0x1234567812345678ULL; unsigned long long yy = 0x1234567800000000ULL; + unsigned long long zz = 0x123456789ABCDEF0ULL; unsigned z; double a = 3.14159; double b = 2.718; @@ -16,6 +17,7 @@ int main(int argc, char ** argv) printf("bswap(%x) = %x\n", x, __builtin_bswap(x)); printf("bswap16(%x) = %x\n", s, __builtin_bswap16(s)); + printf("bswap64(%llx) = %llx\n", zz, __builtin_bswap64(zz)); printf("clz(%x) = %d\n", x, __builtin_clz(x)); printf("clzll(%llx) = %d\n", (unsigned long long) x, __builtin_clzll(x)); printf("clzll(%llx) = %d\n", xx, __builtin_clzll(xx)); diff --git a/test/regression/extasm.c b/test/regression/extasm.c index 00a1cd57..c0534047 100644 --- a/test/regression/extasm.c +++ b/test/regression/extasm.c @@ -5,7 +5,9 @@ int clobbers(int x, int z) { int y; asm("TEST0 out:%0 in:%1" : "=r"(y) : "r"(x) : "cc" -#if defined(__i386__) +#if defined(__x86_64__) + , "rax", "rdx", "rbx" +#elif defined(__i386__) , "eax", "edx", "ebx" #elif defined(__arm__) , "r0", "r1", "r4" @@ -16,6 +18,12 @@ int clobbers(int x, int z) return y + z; } +#if defined(__x86_64__) +#define SIXTYFOUR +#else +#undef SIXTYFOUR +#endif + int main() { int x; @@ -44,10 +52,12 @@ int main() asm("FAIL1 in:%0" : : "i"(x)); #endif /* 64-bit output */ +#ifndef SIXTYFOUR asm("TEST10 out: high %R0,lo %Q0" : "=r" (z)); /* 64-bit input */ asm("TEST11 out:%0 in:%1,high %R2,lo %Q2,%3" : "=r"(x) : "r"(y), "r"(z), "r"(f)); +#endif #ifdef FAILURES asm("FAIL2 out:%0" : "=r"(z)); asm("FAIL3 in:%0" : : "r"(z)); diff --git a/test/regression/initializers2.c b/test/regression/initializers2.c index f8d5cafa..82fd9432 100644 --- a/test/regression/initializers2.c +++ b/test/regression/initializers2.c @@ -43,7 +43,7 @@ int main() a2[0], a2[1], a2[2], a2[3], a2[4]); printf("a3 = { %d, %d, %d, %d, %d } (size = %d)\n", a3[0], a3[1], a3[2], a3[3], a3[4], - sizeof(a3) / sizeof(int)); + (int)(sizeof(a3) / sizeof(int))); printf("s1 = { %d, %.2f, %s }\n", s1.a, s1.b, s1.c); diff --git a/test/regression/sizeof1.c b/test/regression/sizeof1.c index 139b1bc7..ca494622 100644 --- a/test/regression/sizeof1.c +++ b/test/regression/sizeof1.c @@ -34,10 +34,10 @@ char b2[sizeof(struct bits2)]; /* should be 8 */ int main() { printf("sizeof(struct s) = %d, sizeof(tbl) = %d\n", - sizeof(struct s), sizeof(tbl)); + (int) sizeof(struct s), (int) sizeof(tbl)); printf("sizeof(struct bits1) = %d, sizeof(b1) = %d\n", - sizeof(struct bits1), sizeof(b1)); + (int) sizeof(struct bits1), (int) sizeof(b1)); printf("sizeof(struct bits2) = %d, sizeof(b2) = %d\n", - sizeof(struct bits2), sizeof(b2)); + (int) sizeof(struct bits2), (int) sizeof(b2)); return 0; } diff --git a/test/regression/sizeof2.c b/test/regression/sizeof2.c index 66e38c02..7b2f189e 100644 --- a/test/regression/sizeof2.c +++ b/test/regression/sizeof2.c @@ -3,7 +3,7 @@ int main() { - printf("%d\n", sizeof("abcd")); - printf("%d\n", sizeof(L"abcd") / sizeof(wchar_t)); + printf("%d\n", (int) sizeof("abcd")); + printf("%d\n", (int) (sizeof(L"abcd") / sizeof(wchar_t))); return 0; } -- cgit