diff --git a/test/functional/cmdLineTests/criu/criu_nonPortable.xml b/test/functional/cmdLineTests/criu/criu_nonPortable.xml index 88a6ef9f1d4..d6abeac0917 100644 --- a/test/functional/cmdLineTests/criu/criu_nonPortable.xml +++ b/test/functional/cmdLineTests/criu/criu_nonPortable.xml @@ -273,7 +273,7 @@ - bash $SCRIPPATH$ $TEST_RESROOT$ $JAVA_COMMAND$ "$JVM_OPTIONS$ --add-opens java.base/jdk.internal.misc=ALL-UNNAMED $STD_CMD_OPTS$" $MAINCLASS_DEADLOCK_TEST$ CheckpointDeadlock 1 false false + bash $SCRIPPATH$ $TEST_RESROOT$ $JAVA_COMMAND$ "$JVM_OPTIONS$ -Xtrace:print={j9jcl.533,j9vm.684-696,j9vm.699,j9vm.717-743} --add-opens java.base/jdk.internal.misc=ALL-UNNAMED $STD_CMD_OPTS$" $MAINCLASS_DEADLOCK_TEST$ CheckpointDeadlock 1 false false User requested Java dump using AOT load and compilation disabled post restore TEST PASSED diff --git a/test/functional/cmdLineTests/criu/src/org/openj9/criu/DeadlockTest.java b/test/functional/cmdLineTests/criu/src/org/openj9/criu/DeadlockTest.java index 13e94a23d70..da70721d58d 100644 --- a/test/functional/cmdLineTests/criu/src/org/openj9/criu/DeadlockTest.java +++ b/test/functional/cmdLineTests/criu/src/org/openj9/criu/DeadlockTest.java @@ -75,14 +75,19 @@ public static void checkpointDeadlock() { final TestResult testResult = new TestResult(true, 0); Thread t1 = new Thread(() -> { + CRIUTestUtils.showThreadCurrentTime("checkpointDeadlock.t1 started with testResult.lockStatus = " + + testResult.lockStatus.get()); synchronized (lock) { testResult.lockStatus.set(1); - try { - Thread.sleep(20000); - } catch (InterruptedException e) { - e.printStackTrace(); + CRIUTestUtils.showThreadCurrentTime("checkpointDeadlock.t1 locked with testResult.lockStatus = " + + testResult.lockStatus.get()); + // Hold the lock until the lockStatus value is changed. + while (testResult.lockStatus.get() == 1) { + Thread.yield(); } } + CRIUTestUtils.showThreadCurrentTime("checkpointDeadlock.t1 finished with testResult.lockStatus = " + + testResult.lockStatus.get()); }); t1.start(); @@ -90,7 +95,9 @@ public static void checkpointDeadlock() { CRIUSupport criuSupport = new CRIUSupport(path); criuSupport.registerPreCheckpointHook(() -> { synchronized (lock) { - System.out.println("Precheckpoint hook inside monitor"); + CRIUTestUtils.showThreadCurrentTime("Precheckpoint hook inside monitor with testResult.lockStatus = " + + testResult.lockStatus.get()); + testResult.lockStatus.set(2); testResult.testPassed = false; } }); @@ -101,7 +108,11 @@ public static void checkpointDeadlock() { try { System.out.println("Pre-checkpoint"); + CRIUTestUtils.showThreadCurrentTime("Pre-checkpoint with testResult.lockStatus = " + + testResult.lockStatus.get()); CRIUTestUtils.checkPointJVM(criuSupport, path, true); + CRIUTestUtils.showThreadCurrentTime("Post-restore with testResult.lockStatus = " + + testResult.lockStatus.get()); testResult.testPassed = false; } catch (JVMCheckpointException e) { /* @@ -122,10 +133,18 @@ public static void checkpointDeadlock() { at java.base/openj9.internal.criu.InternalCRIUSupport.lambda$registerCheckpointHookHelper$2(InternalCRIUSupport.java:697) */ if (!e.getCause().getCause().getMessage().contains("Blocking operation is not allowed in CRIU single thread mode")) { + CRIUTestUtils.showThreadCurrentTime("checkpointDeadlock test failed with testResult.lockStatus = " + + testResult.lockStatus.get()); testResult.testPassed = false; e.printStackTrace(); } } + testResult.lockStatus.set(3); + try { + t1.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } if (testResult.testPassed) { System.out.println("TEST PASSED");