Skip to content
Merged
Show file tree
Hide file tree
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: 5 additions & 5 deletions src/sqlancer/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

public final class Main {

private static final int THREADS_SHUTDOWN_EXIT_CODE = -1;
public static final File LOG_DIRECTORY = new File("logs");
public static volatile AtomicLong nrQueries = new AtomicLong();
public static volatile AtomicLong nrDatabases = new AtomicLong();
Expand Down Expand Up @@ -305,7 +304,7 @@ public static int executeMain(String[] args) throws AssertionError {
jc.parse(args);
if (jc.getParsedCommand() == null) {
jc.usage();
return THREADS_SHUTDOWN_EXIT_CODE;
return options.getErrorExitCode();
}

if (options.printProgressInformation()) {
Expand All @@ -332,7 +331,8 @@ private void runThread(final String databaseName) {
while (true) {
// create a new instance of the provider in case it has a global state
try {
provider = nameToProvider.get(jc.getParsedCommand()).getClass().newInstance();
provider = nameToProvider.get(jc.getParsedCommand()).getClass().getDeclaredConstructor()
.newInstance();
} catch (Exception e) {
throw new AssertionError(e);
}
Expand Down Expand Up @@ -392,7 +392,7 @@ private void runThread(final String databaseName) {
e.printStackTrace();
}
if (threadsShutdown == options.getTotalNumberTries()) {
System.exit(THREADS_SHUTDOWN_EXIT_CODE);
executor.shutdown();
}
}
}
Expand All @@ -406,7 +406,7 @@ private void runThread(final String databaseName) {
e.printStackTrace();
}
}
return threadsShutdown == 0 ? 0 : THREADS_SHUTDOWN_EXIT_CODE;
return threadsShutdown == 0 ? 0 : options.getErrorExitCode();
}

private static void startProgressMonitor() {
Expand Down
7 changes: 7 additions & 0 deletions src/sqlancer/MainOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public class MainOptions {
@Parameter(names = "--timeout-seconds", description = "The timeout in seconds")
private int timeoutSeconds = -1;

@Parameter(names = "--exit-code-error", description = "The exit code that should be returned when an error is encountered (or a bug is found)")
private int errorExitCode = -1;

public int getMaxExpressionDepth() {
return maxExpressionDepth;
}
Expand Down Expand Up @@ -103,4 +106,8 @@ public int getTimeoutSeconds() {
return timeoutSeconds;
}

public int getErrorExitCode() {
return errorExitCode;
}

}