Skip to content

Commit

Permalink
Merge pull request #13538 from mikezhang1234567890/zlinux-mmap
Browse files Browse the repository at this point in the history
Workaround for zlinux mmap issue in pltest
  • Loading branch information
keithc-ca committed Sep 20, 2021
2 parents 4467813 + 5f793d4 commit 8d9ca8d
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions runtime/tests/port/j9mmapTest.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2019 IBM Corp. and others
* Copyright (c) 1991, 2021 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -1483,7 +1483,15 @@ j9mmap_test9(struct J9PortLibrary *portLibrary)
lastErrorNumber = j9error_last_error_number();
outputErrorMessage(PORTTEST_ERROR_ARGS, "Close of file %s after mapping failed: lastErrorNumber=%d, lastErrorMessage=%s\n", filename, lastErrorNumber, lastErrorMessage);
}


/* workaround to map remaining read only after changing prots to RW on s390x Ubuntu 20 */
#if defined(LINUX) && (defined(S390) || defined(S39064))
memcpy(updatedBuffer, mapAddr, 4);
if ((0 == updatedBuffer[0]) && (1 == updatedBuffer[1]) && (2 == updatedBuffer[2]) && (3 == updatedBuffer[3])) {
outputComment(portLibrary, "Read from mmap before write as workaround for zLinux\n");
}
#endif /* defined(LINUX) && (defined(S390) || defined(S39064)) */

/* try to write to region that was set to read only */
if (!j9sig_can_protect(signalHandlerFlags)) {
outputComment(portLibrary, "Signal handling framework not available, can't test readonly functionality without crashing, bypassing test");
Expand Down Expand Up @@ -1680,7 +1688,15 @@ j9mmap_test10(struct J9PortLibrary *portLibrary)
lastErrorNumber = j9error_last_error_number();
outputErrorMessage(PORTTEST_ERROR_ARGS, "Close of file %s after mapping failed: lastErrorNumber=%d, lastErrorMessage=%s\n", filename, lastErrorNumber, lastErrorMessage);
}


/* workaround to map remaining read only after changing prots to RW on s390x Ubuntu 20 */
#if defined(LINUX) && (defined(S390) || defined(S39064))
memcpy(updatedBuffer, mapAddr, 4);
if ((0 == updatedBuffer[0]) && (1 == updatedBuffer[1]) && (2 == updatedBuffer[2]) && (3 == updatedBuffer[3])) {
outputComment(portLibrary, "Read from mmap before write as workaround for zLinux\n");
}
#endif /* defined(LINUX) && (defined(S390) || defined(S39064)) */

/* try to write to region that was set to read only */
if (!j9sig_can_protect(signalHandlerFlags)) {
outputComment(portLibrary, "Signal handling framework not available, can't test readonly functionality without crashing, bypassing test");
Expand Down

0 comments on commit 8d9ca8d

Please sign in to comment.