Skip to content

Commit 2e66d0f

Browse files
committed
Add an option to specify the exit code for when a bug is encountered
1 parent e919d16 commit 2e66d0f

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/sqlancer/Main.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939

4040
public final class Main {
4141

42-
private static final int THREADS_SHUTDOWN_EXIT_CODE = -1;
4342
public static final File LOG_DIRECTORY = new File("logs");
4443
public static volatile AtomicLong nrQueries = new AtomicLong();
4544
public static volatile AtomicLong nrDatabases = new AtomicLong();
@@ -305,7 +304,7 @@ public static int executeMain(String[] args) throws AssertionError {
305304
jc.parse(args);
306305
if (jc.getParsedCommand() == null) {
307306
jc.usage();
308-
return THREADS_SHUTDOWN_EXIT_CODE;
307+
return options.getErrorExitCode();
309308
}
310309

311310
if (options.printProgressInformation()) {
@@ -407,7 +406,7 @@ private void runThread(final String databaseName) {
407406
e.printStackTrace();
408407
}
409408
}
410-
return threadsShutdown == 0 ? 0 : THREADS_SHUTDOWN_EXIT_CODE;
409+
return threadsShutdown == 0 ? 0 : options.getErrorExitCode();
411410
}
412411

413412
private static void startProgressMonitor() {

src/sqlancer/MainOptions.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ public class MainOptions {
4444
@Parameter(names = "--timeout-seconds", description = "The timeout in seconds")
4545
private int timeoutSeconds = -1;
4646

47+
@Parameter(names = "--exit-code-error", description = "The exit code that should be returned when an error is encountered (or a bug is found)")
48+
private int errorExitCode = -1;
49+
4750
public int getMaxExpressionDepth() {
4851
return maxExpressionDepth;
4952
}
@@ -103,4 +106,8 @@ public int getTimeoutSeconds() {
103106
return timeoutSeconds;
104107
}
105108

109+
public int getErrorExitCode() {
110+
return errorExitCode;
111+
}
112+
106113
}

0 commit comments

Comments
 (0)