aboutsummaryrefslogtreecommitdiffstats
path: root/test/regression
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2016-10-24 14:21:51 +0200
committerXavier Leroy <xavier.leroy@inria.fr>2016-10-24 14:34:59 +0200
commit03ab00aec5d10f4a2d048fab7f16489cf33fcc1d (patch)
tree16d5313fb0d61585f6d82c6232228d716e9f7553 /test/regression
parent2fc1f0ce18c45d1148493d58e0c848fc70c44a4d (diff)
downloadcompcert-kvx-03ab00aec5d10f4a2d048fab7f16489cf33fcc1d.tar.gz
compcert-kvx-03ab00aec5d10f4a2d048fab7f16489cf33fcc1d.zip
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.
Diffstat (limited to 'test/regression')
-rw-r--r--test/regression/Results/initializers-32 (renamed from test/regression/Results/initializers)0
-rw-r--r--test/regression/Results/initializers-6430
-rw-r--r--test/regression/Results/packedstruct1-32 (renamed from test/regression/Results/packedstruct1)0
-rw-r--r--test/regression/Results/packedstruct1-6425
-rw-r--r--test/regression/Results/sizeof1-32 (renamed from test/regression/Results/sizeof1)0
-rw-r--r--test/regression/Results/sizeof1-643
-rwxr-xr-xtest/regression/Runtest55
-rw-r--r--test/regression/builtins-ia32.c2
-rw-r--r--test/regression/extasm.c12
-rw-r--r--test/regression/initializers2.c2
-rw-r--r--test/regression/sizeof1.c6
-rw-r--r--test/regression/sizeof2.c4
12 files changed, 132 insertions, 7 deletions
diff --git a/test/regression/Results/initializers b/test/regression/Results/initializers-32
index a3c92e86..a3c92e86 100644
--- a/test/regression/Results/initializers
+++ b/test/regression/Results/initializers-32
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-32
index e4bca769..e4bca769 100644
--- a/test/regression/Results/packedstruct1
+++ b/test/regression/Results/packedstruct1-32
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-32
index a952be52..a952be52 100644
--- a/test/regression/Results/sizeof1
+++ b/test/regression/Results/sizeof1-32
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;
}