Skip to content

Commit

Permalink
tests/tcg/s390x: Test EPSW
Browse files Browse the repository at this point in the history
Add a small test to prevent regressions.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Message-Id: <20230704081506.276055-9-iii@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
  • Loading branch information
iii-i authored and huth committed Jul 10, 2023
1 parent 349372f commit f5c2ae7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/tcg/s390x/Makefile.target
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ TESTS+=rxsbg
TESTS+=ex-relative-long
TESTS+=ex-branch
TESTS+=mxdb
TESTS+=epsw

cdsg: CFLAGS+=-pthread
cdsg: LDFLAGS+=-pthread
Expand Down
23 changes: 23 additions & 0 deletions tests/tcg/s390x/epsw.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Test the EPSW instruction.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <assert.h>
#include <stdlib.h>

int main(void)
{
unsigned long r1 = 0x1234567887654321UL, r2 = 0x8765432112345678UL;

asm("cr %[r1],%[r2]\n" /* cc = 1 */
"epsw %[r1],%[r2]"
: [r1] "+r" (r1), [r2] "+r" (r2) : : "cc");

/* Do not check the R and RI bits. */
r1 &= ~0x40000008UL;
assert(r1 == 0x1234567807051001UL);
assert(r2 == 0x8765432180000000UL);

return EXIT_SUCCESS;
}

0 comments on commit f5c2ae7

Please sign in to comment.