Skip to content

Commit

Permalink
Check interrupt handler after each test case
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Dec 20, 2023
1 parent f681f27 commit b321bf2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ protected static TestResult runTestCase(final TestRequest request) {
throw new RuntimeException("Test was interrupted");
} catch (final ExecutionException e) {
return TestResult.fromException("failed with an error", e.getCause());
} finally {
final String reason = image.interrupt.activeTest();
if (reason != null) {
printlnErr(request.testCase + ">>" + request.testSelector + " left interrupt handling in inconsistent state, reason: " + reason);
}
image.interrupt.clearState();
}
}

Expand All @@ -195,7 +201,6 @@ protected static <T, R> R runWithTimeout(final T argument, final Function<T, R>
} finally {
testWithImageIsActive = false;
}

});
try {
return future.get(timeout, TimeUnit.SECONDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,36 @@ public void resetTrigger() {
* TESTING
*/

public String activeTest() {
if (nextWakeupTick > 0) {
return "Timer";
} else if (interruptPending) {
return "Interrupt";
} else if (pendingFinalizationSignals) {
return "Finalization";
} else if (!semaphoresToSignal.isEmpty()) {
return "Semaphore";
} else {
return null;
}
}

public void clearState() {
nextWakeupTick = 0;
interruptPending = false;
pendingFinalizationSignals = false;
clearWeakPointersQueue();
semaphoresToSignal.clear();
}

public void reset() {
CompilerAsserts.neverPartOfCompilation("Resetting interrupt handler only supported for testing purposes");
isActive = true;
nextWakeupTick = 0;
if (interruptChecks != null) {
interruptChecks.cancel(true);
}
shutdown();
interruptPending = false;
pendingFinalizationSignals = false;
clearWeakPointersQueue();
semaphoresToSignal.clear();
clearState();
}

private void clearWeakPointersQueue() {
Expand Down

0 comments on commit b321bf2

Please sign in to comment.