Skip to content

Commit a57cc41

Browse files
committed
MultiProcessAffinityTest: Print sub-process output when it fails to acquire the lock
1 parent cd1cc3f commit a57cc41

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

affinity/src/test/java/net/openhft/affinity/MultiProcessAffinityTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class MultiProcessAffinityTest {
2020
public void shouldNotAcquireLockOnCoresLockedByOtherProcesses() throws IOException, InterruptedException {
2121
Assume.assumeTrue(IS_LINUX);
2222
// run the separate affinity locker
23-
final Process last = ProcessRunner.runClass(AffinityLockerProcess.class, "last");
23+
final Process affinityLockerProcess = ProcessRunner.runClass(AffinityLockerProcess.class, "last");
2424
try {
2525
int lastCpuId = AffinityLock.PROCESSORS - 1;
2626

@@ -29,6 +29,7 @@ public void shouldNotAcquireLockOnCoresLockedByOtherProcesses() throws IOExcepti
2929
while (FileLockBasedLockChecker.getInstance().isLockFree(lastCpuId)) {
3030
Thread.sleep(100);
3131
if (System.currentTimeMillis() > endTime) {
32+
ProcessRunner.printProcessOutput("AffinityLockerProcess", affinityLockerProcess);
3233
fail("Timed out waiting for the sub-process to acquire the lock");
3334
}
3435
}
@@ -37,8 +38,8 @@ public void shouldNotAcquireLockOnCoresLockedByOtherProcesses() throws IOExcepti
3738
assertNotEquals(lastCpuId, lock.cpuId());
3839
}
3940
} finally {
40-
last.destroy();
41-
if (!last.waitFor(5, TimeUnit.SECONDS)) {
41+
affinityLockerProcess.destroy();
42+
if (!affinityLockerProcess.waitFor(5, TimeUnit.SECONDS)) {
4243
fail("Sub-process didn't terminate!");
4344
}
4445
}

0 commit comments

Comments
 (0)