Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CODETOOLS-7902917: jcstress: Errors during interruption tests #45

Merged
merged 1 commit into from
May 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions jcstress-core/src/main/java/org/openjdk/jcstress/ForkedMain.java
Original file line number Diff line number Diff line change
@@ -70,12 +70,14 @@ public Thread newThread(Runnable r) {
ForkedTestConfig config = link.nextJob(token);

TestResult result;
boolean forceExit = false;

try {
Class<?> aClass = Class.forName(config.generatedRunnerName);
Constructor<?> cnstr = aClass.getConstructor(ForkedTestConfig.class, ExecutorService.class);
Runner<?> o = (Runner<?>) cnstr.newInstance(config, pool);
result = o.run();
forceExit = o.forceExit();
} catch (ClassFormatError | NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
result = new TestResult(Status.API_MISMATCH);
result.addMessage(StringUtils.getStacktrace(e));
@@ -84,7 +86,15 @@ public Thread newThread(Runnable r) {
result.addMessage(StringUtils.getStacktrace(ex));
}

if (forceExit) {
result.addMessage("Have stale threads, forcing VM to exit for proper cleanup.");
}

link.doneResult(token, result);

if (forceExit) {
System.exit(0);
}
}

}
Original file line number Diff line number Diff line change
@@ -787,11 +787,11 @@ private void generateTermination(TestInfo info) {
pw.println(" run(results);");
pw.println();
pw.println(" if (results.count(Outcome.STALE) > 0) {");
pw.println(" messages.add(\"Have stale threads, forcing VM to exit for proper cleanup.\");");
pw.println(" dump(results);");
pw.println(" System.exit(0);");
pw.println(" forceExit = true;");
pw.println(" break;");
pw.println(" }");
pw.println(" }");
pw.println();
pw.println(" return dump(results);");
pw.println(" }");
pw.println();
Original file line number Diff line number Diff line change
@@ -51,6 +51,7 @@ public abstract class Runner<R> {
protected final String testName;
protected final ForkedTestConfig config;
protected final List<String> messages;
protected volatile boolean forceExit;

public Runner(ForkedTestConfig config, ExecutorService pool, String testName) {
this.pool = pool;
@@ -140,6 +141,10 @@ protected TestResult dump(Counter<R> cnt) {
return result;
}

public boolean forceExit() {
return forceExit;
}

public abstract Counter<R> sanityCheck() throws Throwable;

public abstract Collection<Future<Counter<R>>> internalRun();