]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add testcases for "compare and swap".
authorFlorian Krohm <florian@eich-krohm.de>
Wed, 30 May 2012 20:46:58 +0000 (20:46 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Wed, 30 May 2012 20:46:58 +0000 (20:46 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12595

19 files changed:
configure.in
memcheck/tests/Makefile.am
memcheck/tests/s390x/Makefile.am [new file with mode: 0644]
memcheck/tests/s390x/cs.c [new file with mode: 0644]
memcheck/tests/s390x/cs.stderr.exp [new file with mode: 0644]
memcheck/tests/s390x/cs.vgtest [new file with mode: 0644]
memcheck/tests/s390x/csg.c [new file with mode: 0644]
memcheck/tests/s390x/csg.stderr.exp [new file with mode: 0644]
memcheck/tests/s390x/csg.vgtest [new file with mode: 0644]
memcheck/tests/s390x/filter_stderr [new file with mode: 0755]
none/tests/s390x/Makefile.am
none/tests/s390x/cs.c [new file with mode: 0644]
none/tests/s390x/cs.stderr.exp [new file with mode: 0644]
none/tests/s390x/cs.stdout.exp [new file with mode: 0644]
none/tests/s390x/cs.vgtest [new file with mode: 0644]
none/tests/s390x/csg.c [new file with mode: 0644]
none/tests/s390x/csg.stderr.exp [new file with mode: 0644]
none/tests/s390x/csg.stdout.exp [new file with mode: 0644]
none/tests/s390x/csg.vgtest [new file with mode: 0644]

index 5b462444ec0e8c7cea1a8796fb93c96c85199473..13c4a9577e24a8d1f14a6ce9990bed791dabc814 100644 (file)
@@ -2196,6 +2196,7 @@ AC_CONFIG_FILES([
    memcheck/tests/x86-linux/Makefile
    memcheck/tests/ppc32/Makefile
    memcheck/tests/ppc64/Makefile
+   memcheck/tests/s390x/Makefile
    cachegrind/Makefile
    cachegrind/tests/Makefile
    cachegrind/tests/x86/Makefile
index fa76b5c718721c71c1f7fc50c8d1b5ce5f9e80fd..530e1f2c8725842abcb8c4963553e3c2254480d9 100644 (file)
@@ -18,6 +18,10 @@ if VGCONF_ARCHS_INCLUDE_PPC64
 SUBDIRS += ppc64
 endif
 
+if VGCONF_ARCHS_INCLUDE_S390X
+SUBDIRS += s390x
+endif
+
 # OS-specific tests
 if VGCONF_OS_IS_LINUX
 SUBDIRS += linux
diff --git a/memcheck/tests/s390x/Makefile.am b/memcheck/tests/s390x/Makefile.am
new file mode 100644 (file)
index 0000000..4369e5c
--- /dev/null
@@ -0,0 +1,16 @@
+include $(top_srcdir)/Makefile.tool-tests.am
+
+dist_noinst_SCRIPTS = filter_stderr
+
+INSN_TESTS = cs csg
+
+check_PROGRAMS = $(INSN_TESTS) 
+
+EXTRA_DIST = \
+       $(addsuffix .stderr.exp,$(INSN_TESTS)) \
+       $(addsuffix .stdout.exp,$(INSN_TESTS)) \
+       $(addsuffix .vgtest,$(INSN_TESTS))
+
+AM_CFLAGS    += @FLAG_M64@
+AM_CXXFLAGS  += @FLAG_M64@
+AM_CCASFLAGS += @FLAG_M64@
diff --git a/memcheck/tests/s390x/cs.c b/memcheck/tests/s390x/cs.c
new file mode 100644 (file)
index 0000000..9a298ce
--- /dev/null
@@ -0,0 +1,32 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+void 
+test(int32_t op1_init, int32_t op2_init, int32_t op3_init)
+{
+   register int32_t op1 asm("8") = op1_init;
+   register int32_t op3 asm("9") = op3_init;
+   
+   int32_t op2 = op2_init;
+   int cc = 1; 
+
+   __asm__ volatile (
+           "cs      8,9,%1\n\t"
+           "ipm     %0\n\t"
+           "srl     %0,28\n\t"
+           : "=d" (cc), "+Q" (op2), "+d"(op1), "+d"(op3)
+           : 
+           : "cc");
+}
+
+int main ()
+{
+   int op1, op2, op3;
+
+   test(op1, 0x10000000, 0x12345678);   // complaint
+   test(0x10000000, op2, 0x12345678);   // complaint
+   test(0x10000000, 0x01000000, op3);   // no complaint
+
+   return 0;
+}
diff --git a/memcheck/tests/s390x/cs.stderr.exp b/memcheck/tests/s390x/cs.stderr.exp
new file mode 100644 (file)
index 0000000..e45dc99
--- /dev/null
@@ -0,0 +1,8 @@
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: test (cs.c:14)
+   by 0x........: main (cs.c:27)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: test (cs.c:14)
+   by 0x........: main (cs.c:28)
+
diff --git a/memcheck/tests/s390x/cs.vgtest b/memcheck/tests/s390x/cs.vgtest
new file mode 100644 (file)
index 0000000..323cce8
--- /dev/null
@@ -0,0 +1,2 @@
+prog: cs
+vgopts: -q
diff --git a/memcheck/tests/s390x/csg.c b/memcheck/tests/s390x/csg.c
new file mode 100644 (file)
index 0000000..7f9d8c8
--- /dev/null
@@ -0,0 +1,32 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+void 
+test(int64_t op1_init, int64_t op2_init, int64_t op3_init)
+{
+   register int64_t op1 asm("8") = op1_init;
+   register int64_t op3 asm("9") = op3_init;
+   
+   int64_t op2 = op2_init;
+   int cc = 1; 
+
+   __asm__ volatile (
+           "csg     8,9,%1\n\t"
+           "ipm     %0\n\t"
+           "srl     %0,28\n\t"
+           : "=d" (cc), "+Q" (op2), "+d"(op1), "+d"(op3)
+           : 
+           : "cc");
+}
+
+int main ()
+{
+   int64_t op1, op2, op3;
+
+   test(op1, 0x1000000000000000ull, 0x1234567887654321ull);  // complaint
+   test(0x1000000000000000ull, op2, 0x1234567887654321ull);  // complaint
+   test(0x1000000000000000ull, 0x1000000000000000ull, op3);  // no complaint
+
+   return 0;
+}
diff --git a/memcheck/tests/s390x/csg.stderr.exp b/memcheck/tests/s390x/csg.stderr.exp
new file mode 100644 (file)
index 0000000..fda2021
--- /dev/null
@@ -0,0 +1,8 @@
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: test (csg.c:14)
+   by 0x........: main (csg.c:27)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: test (csg.c:14)
+   by 0x........: main (csg.c:28)
+
diff --git a/memcheck/tests/s390x/csg.vgtest b/memcheck/tests/s390x/csg.vgtest
new file mode 100644 (file)
index 0000000..6de75c1
--- /dev/null
@@ -0,0 +1,2 @@
+prog: csg
+vgopts: -q
diff --git a/memcheck/tests/s390x/filter_stderr b/memcheck/tests/s390x/filter_stderr
new file mode 100755 (executable)
index 0000000..a778e97
--- /dev/null
@@ -0,0 +1,3 @@
+#! /bin/sh
+
+../filter_stderr "$@"
index ddb4f4ed61739732fbf3c3f9cdd69e6aa84cc3fa..b52ee13393997f2124bf91f72d28042f1d22e42a 100644 (file)
@@ -6,7 +6,8 @@ INSN_TESTS = clc clcle cvb cvd icm lpr tcxb lam_stam xc mvst add sub mul \
              and or xor insert div srst fold_And16 flogr sub_EI add_EI \
              and_EI or_EI xor_EI insert_EI mul_GE add_GE condloadstore \
              op_exception fgx stck stckf stcke stfle cksm mvcl clcl troo \
-             trto trot trtt tr tre cij cgij clij clgij crj cgrj clrj clgrj
+             trto trot trtt tr tre cij cgij clij clgij crj cgrj clrj clgrj \
+             cs csg
 
 check_PROGRAMS = $(INSN_TESTS) \
                 allexec \
diff --git a/none/tests/s390x/cs.c b/none/tests/s390x/cs.c
new file mode 100644 (file)
index 0000000..72b56c2
--- /dev/null
@@ -0,0 +1,51 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+void 
+test(int32_t op1_init, int32_t op2_init, int32_t op3_init, int expected_cc)
+{
+   register int32_t op1 asm("8") = op1_init;
+   register int32_t op3 asm("9") = op3_init;
+   
+   int32_t op2 = op2_init;
+   int cc = 1; 
+
+   printf("before op1 = %#x\n", op1);
+   printf("before op2 = %#x\n", op2);
+   printf("before op3 = %#x\n", op3);
+
+   __asm__ volatile (
+           "cs      8,9,%1\n\t"
+           "ipm     %0\n\t"
+           "srl     %0,28\n\t"
+           : "=d" (cc), "+Q" (op2), "+d"(op1), "+d"(op3)
+           : 
+           : "cc");
+
+   printf("after  op1 = %#x\n", op1);
+   printf("after  op2 = %#x\n", op2);
+   printf("after  op3 = %#x\n", op3);
+   printf("cc = %d\n", cc);
+
+   if (cc != expected_cc) {
+      printf("condition code is incorrect\n");
+   }
+   if (expected_cc == 0) {
+      if (op2 != op3) {
+         printf("operand #2 not updated\n");
+      }
+   } else {
+      if (op1 != op2) {
+         printf("operand #1 not updated\n");
+      }
+   }
+}
+
+int main ()
+{
+   test(0x10000000, 0x10000000, 0x12345678, 0);
+   test(0x10000000, 0x20000000, 0x12345678, 1);
+
+   return 0;
+}
diff --git a/none/tests/s390x/cs.stderr.exp b/none/tests/s390x/cs.stderr.exp
new file mode 100644 (file)
index 0000000..139597f
--- /dev/null
@@ -0,0 +1,2 @@
+
+
diff --git a/none/tests/s390x/cs.stdout.exp b/none/tests/s390x/cs.stdout.exp
new file mode 100644 (file)
index 0000000..803a8b3
--- /dev/null
@@ -0,0 +1,14 @@
+before op1 = 0x10000000
+before op2 = 0x10000000
+before op3 = 0x12345678
+after  op1 = 0x10000000
+after  op2 = 0x12345678
+after  op3 = 0x12345678
+cc = 0
+before op1 = 0x10000000
+before op2 = 0x20000000
+before op3 = 0x12345678
+after  op1 = 0x20000000
+after  op2 = 0x20000000
+after  op3 = 0x12345678
+cc = 1
diff --git a/none/tests/s390x/cs.vgtest b/none/tests/s390x/cs.vgtest
new file mode 100644 (file)
index 0000000..9d9bdd9
--- /dev/null
@@ -0,0 +1 @@
+prog: cs
diff --git a/none/tests/s390x/csg.c b/none/tests/s390x/csg.c
new file mode 100644 (file)
index 0000000..1a5e8ff
--- /dev/null
@@ -0,0 +1,51 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+void 
+test(int64_t op1_init, int64_t op2_init, int64_t op3_init, int expected_cc)
+{
+   register int64_t op1 asm("8") = op1_init;
+   register int64_t op3 asm("9") = op3_init;
+   
+   int64_t op2 = op2_init;
+   int cc = 1; 
+
+   printf("before op1 = %#lx\n", op1);
+   printf("before op2 = %#lx\n", op2);
+   printf("before op3 = %#lx\n", op3);
+
+   __asm__ volatile (
+           "csg     8,9,%1\n\t"
+           "ipm     %0\n\t"
+           "srl     %0,28\n\t"
+           : "=d" (cc), "+Q" (op2), "+d"(op1), "+d"(op3)
+           : 
+           : "cc");
+
+   printf("after  op1 = %#lx\n", op1);
+   printf("after  op2 = %#lx\n", op2);
+   printf("after  op3 = %#lx\n", op3);
+   printf("cc = %d\n", cc);
+
+   if (cc != expected_cc) {
+      printf("condition code is incorrect\n");
+   }
+   if (expected_cc == 0) {
+      if (op2 != op3) {
+         printf("operand #2 not updated\n");
+      }
+   } else {
+      if (op1 != op2) {
+         printf("operand #1 not updated\n");
+      }
+   }
+}
+
+int main ()
+{
+   test(0x1000000000000000ull, 0x1000000000000000ull, 0x1234567887654321ull, 0);
+   test(0x1000000000000000ull, 0x2000000000000000ull, 0x1234567887654321ull, 1);
+
+   return 0;
+}
diff --git a/none/tests/s390x/csg.stderr.exp b/none/tests/s390x/csg.stderr.exp
new file mode 100644 (file)
index 0000000..139597f
--- /dev/null
@@ -0,0 +1,2 @@
+
+
diff --git a/none/tests/s390x/csg.stdout.exp b/none/tests/s390x/csg.stdout.exp
new file mode 100644 (file)
index 0000000..1258ece
--- /dev/null
@@ -0,0 +1,14 @@
+before op1 = 0x1000000000000000
+before op2 = 0x1000000000000000
+before op3 = 0x1234567887654321
+after  op1 = 0x1000000000000000
+after  op2 = 0x1234567887654321
+after  op3 = 0x1234567887654321
+cc = 0
+before op1 = 0x1000000000000000
+before op2 = 0x2000000000000000
+before op3 = 0x1234567887654321
+after  op1 = 0x2000000000000000
+after  op2 = 0x2000000000000000
+after  op3 = 0x1234567887654321
+cc = 1
diff --git a/none/tests/s390x/csg.vgtest b/none/tests/s390x/csg.vgtest
new file mode 100644 (file)
index 0000000..c765a1b
--- /dev/null
@@ -0,0 +1 @@
+prog: csg