]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
tests/tcg/s390x: Test TEST AND SET
authorIlya Leoshkevich <iii@linux.ibm.com>
Mon, 18 Mar 2024 20:27:11 +0000 (21:27 +0100)
committerThomas Huth <thuth@redhat.com>
Mon, 25 Mar 2024 14:05:59 +0000 (15:05 +0100)
Add a small test to prevent regressions.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20240318202722.20675-2-iii@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
tests/tcg/s390x/Makefile.target
tests/tcg/s390x/ts.c [new file with mode: 0644]

index e2aba2ec274b1c66283655581dc9c23532fc19a1..a8f86c9449874d0ad0d4c34f2d1f00b59c4930bb 100644 (file)
@@ -47,6 +47,7 @@ TESTS+=add-logical-with-carry
 TESTS+=lae
 TESTS+=cvd
 TESTS+=cvb
+TESTS+=ts
 
 cdsg: CFLAGS+=-pthread
 cdsg: LDFLAGS+=-pthread
diff --git a/tests/tcg/s390x/ts.c b/tests/tcg/s390x/ts.c
new file mode 100644 (file)
index 0000000..441faf3
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Test the TEST AND SET instruction.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include <assert.h>
+#include <stdlib.h>
+
+static int ts(char *p)
+{
+    int cc;
+
+    asm("ts %[p]\n"
+        "ipm %[cc]"
+        : [cc] "=r" (cc)
+        , [p] "+Q" (*p)
+        : : "cc");
+
+    return (cc >> 28) & 3;
+}
+
+int main(void)
+{
+    char c;
+
+    c = 0x80;
+    assert(ts(&c) == 1);
+    assert(c == 0xff);
+
+    c = 0x7f;
+    assert(ts(&c) == 0);
+    assert(c == 0xff);
+
+    return EXIT_SUCCESS;
+}