Skip to content

Commit

Permalink
Check for illegal bits in SelfSuspendDisablerTest
Browse files Browse the repository at this point in the history
Fixes: eclipse-openj9/openj9#16276

Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
  • Loading branch information
babsingh committed Dec 5, 2022
1 parent 1303c08 commit ff681ae
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,27 @@ private static void sleep(long millis) {
private static void testJvmtiThreadState(Thread thread, int expectedState) {
String kindStr = thread.isVirtual()? "virtual " : "platform";
int state = getThreadState(thread);
boolean pass = true;

System.out.printf("Expected %s thread state: %06X got: %06X\n",
kindStr, expectedState, state);
if ((state & expectedState) != expectedState) {
if (expectedState == SUSPENDED) {
if ((state & expectedState) != expectedState) {
/* Fail if the required bits are not set. */
pass = false;
}
/* SUSPENDED_OPTIONAL = JVMTI_THREAD_STATE_INTERRUPTED | JVMTI_THREAD_STATE_IN_NATIVE */
int SUSPENDED_OPTIONAL = 0x200000 | 0x400000;
if ((state & ~(SUSPENDED | SUSPENDED_OPTIONAL)) != 0) {
/* Fail if any unexpected bit is set. */
pass = false;
}
} else {
if (state != expectedState) {
pass = false;
}
}
if (!pass) {
throw new RuntimeException("Test FAILED: Unexpected thread state");
}
}
Expand Down

0 comments on commit ff681ae

Please sign in to comment.