aboutsummaryrefslogtreecommitdiff
path: root/tests/tcg
diff options
context:
space:
mode:
authorIlya Leoshkevich <iii@linux.ibm.com>2024-03-18 21:27:11 +0100
committerThomas Huth <thuth@redhat.com>2024-03-25 15:05:59 +0100
commitf9b29c636442e917a56a725d774ea99be3b28111 (patch)
tree549b82f1fc01226175668e54d21f023c8c28cdf8 /tests/tcg
parent272fba9779af0bb1c29cd30302fc1e31c59274d0 (diff)
downloadqemu-f9b29c636442e917a56a725d774ea99be3b28111.zip
qemu-f9b29c636442e917a56a725d774ea99be3b28111.tar.gz
qemu-f9b29c636442e917a56a725d774ea99be3b28111.tar.bz2
tests/tcg/s390x: Test TEST AND SET
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>
Diffstat (limited to 'tests/tcg')
-rw-r--r--tests/tcg/s390x/Makefile.target1
-rw-r--r--tests/tcg/s390x/ts.c35
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target
index e2aba2e..a8f86c9 100644
--- a/tests/tcg/s390x/Makefile.target
+++ b/tests/tcg/s390x/Makefile.target
@@ -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
index 0000000..441faf3
--- /dev/null
+++ b/tests/tcg/s390x/ts.c
@@ -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;
+}