-
Notifications
You must be signed in to change notification settings - Fork 397
Expand file tree
/
Copy pathMainOptions.java
More file actions
214 lines (156 loc) · 7.91 KB
/
MainOptions.java
File metadata and controls
214 lines (156 loc) · 7.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
package sqlancer;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import sqlancer.Randomly.StringGenerationStrategy;
@Parameters(separators = "=", commandDescription = "Options applicable to all DBMS")
public class MainOptions {
@Parameter(names = { "--help", "-h" }, description = "Lists all supported options and commands", help = true)
private boolean help; // NOPMD
@Parameter(names = {
"--num-threads" }, description = "How many threads should run concurrently to test separate databases")
private int nrConcurrentThreads = 16; // NOPMD
@Parameter(names = {
"--random-seed" }, description = "A seed value != -1 that can be set to make the query and database generation deterministic")
private long randomSeed = -1; // NOPMD
@Parameter(names = { "--num-tries" }, description = "Specifies after how many found errors to stop testing")
private int totalNumberTries = 100; // NOPMD
@Parameter(names = { "--max-num-inserts" }, description = "Specifies how many INSERT statements should be issued")
private int maxNumberInserts = 30; // NOPMD
@Parameter(names = {
"--max-expression-depth" }, description = "Specifies the maximum depth of randomly-generated expressions")
private int maxExpressionDepth = 3; // NOPMD
@Parameter(names = {
"--num-queries" }, description = "Specifies the number of queries to be issued to a database before creating a new database")
private int nrQueries = 100000; // NOPMD
@Parameter(names = {
"--num-statement-kind-retries" }, description = "Specifies the number of times a specific statement kind (e.g., INSERT) should be retried when the DBMS indicates that it failed")
private int nrStatementRetryCount = 1000; // NOPMD
@Parameter(names = "--log-each-select", description = "Logs every statement issued", arity = 1)
private boolean logEachSelect = true; // NOPMD
@Parameter(names = "--log-execution-time", description = "Logs the execution time of each statement (requires --log-each-select to be enabled)", arity = 1)
private boolean logExecutionTime = true; // NOPMD
@Parameter(names = "--username", description = "The user name used to log into the DBMS")
private String userName = "sqlancer"; // NOPMD
@Parameter(names = "--password", description = "The password used to log into the DBMS")
private String password = "sqlancer"; // NOPMD
@Parameter(names = "--print-progress-information", description = "Whether to print progress information such as the number of databases generated or queries issued", arity = 1)
private boolean printProgressInformation = true; // NOPMD
@Parameter(names = "--print-progress-summary", description = "Whether to print an execution summary when exiting SQLancer", arity = 1)
private boolean printProgressSummary; // NOPMD
@Parameter(names = "--timeout-seconds", description = "The timeout in seconds")
private int timeoutSeconds = -1; // NOPMD
@Parameter(names = "--max-generated-databases", description = "The maximum number of databases that are generated by each thread")
private int maxGeneratedDatabases = -1; // NOPMD
@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; // NOPMD
@Parameter(names = "--print-statements", description = "Print all statements to stdout, before they are sent to the DBMS (not yet implemented for all oracles)", arity = 1)
private boolean printStatements; // NOPMD
@Parameter(names = "--print-succeeding-statements", description = "Print statements that are successfully processed by the DBMS to stdout (not yet implemented for all oracles)", arity = 1)
private boolean printSucceedingStatements; // NOPMD
@Parameter(names = "--test-only-nonempty-tables", description = "Test only databases each of whose tables contain at least a single row", arity = 1)
private boolean testOnlyWithMoreThanZeroRows; // NOPMD
@Parameter(names = "--pqs-test-aggregates", description = "Partially test aggregate functions when all tables contain only a single row.", arity = 1)
private boolean testAggregateFunctions; // NOPMD
@Parameter(names = "--random-string-generation", description = "Select the random-string eneration approach")
private StringGenerationStrategy randomStringGenerationStrategy = StringGenerationStrategy.SOPHISTICATED; // NOPMD
@Parameter(names = "--string-constant-max-length", description = "Specify the maximum-length of generated string constants")
private int maxStringConstantLength = 10; // NOPMD
@Parameter(names = "--use-constant-caching", description = "Specifies whether constants should be cached and re-used with a certain probability", arity = 1)
private boolean useConstantCaching = true; // NOPMD
@Parameter(names = "--use-connection-test", description = "Test whether the DBMS is accessible before trying to connect using multiple threads", arity = 1)
private boolean useConnectionTest = true; // NOPMD
@Parameter(names = "--constant-cache-size", description = "Specifies the size of the constant cache. This option only takes effect when constant caching is enabled")
private int constantCacheSize = 100; // NOPMD
@Parameter(names = "--database-prefix", description = "The prefix used for each database created")
private String databasePrefix = "database"; // NOPMD
public int getMaxExpressionDepth() {
return maxExpressionDepth;
}
public int getTotalNumberTries() {
return totalNumberTries;
}
public int getNumberConcurrentThreads() {
return nrConcurrentThreads;
}
public boolean logEachSelect() {
return logEachSelect;
}
public boolean printAllStatements() {
if (printSucceedingStatements && printStatements) {
throw new AssertionError();
}
return printStatements;
}
public boolean printSucceedingStatements() {
if (printStatements && printSucceedingStatements) {
throw new AssertionError();
}
return printSucceedingStatements;
}
public boolean logExecutionTime() {
if (!logEachSelect) {
throw new AssertionError();
}
return logExecutionTime;
}
public int getNrQueries() {
return nrQueries;
}
public int getMaxNumberInserts() {
return maxNumberInserts;
}
public int getNrStatementRetryCount() {
return nrStatementRetryCount;
}
public String getUserName() {
return userName;
}
public String getPassword() {
return password;
}
public boolean printProgressInformation() {
return printProgressInformation;
}
public boolean printProgressSummary() {
return printProgressSummary;
}
public int getTimeoutSeconds() {
return timeoutSeconds;
}
public int getMaxGeneratedDatabases() {
return maxGeneratedDatabases;
}
public int getErrorExitCode() {
return errorExitCode;
}
public long getRandomSeed() {
return randomSeed;
}
public boolean testAggregateFunctionsPQS() {
return testAggregateFunctions;
}
public boolean testOnlyWithMoreThanZeroRows() {
return testOnlyWithMoreThanZeroRows;
}
public StringGenerationStrategy getRandomStringGenerationStrategy() {
return randomStringGenerationStrategy;
}
public int getMaxStringConstantLength() {
return maxStringConstantLength;
}
public boolean useConstantCaching() {
return useConstantCaching;
}
public int getConstantCacheSize() {
return constantCacheSize;
}
public boolean isHelp() {
return help;
}
public String getDatabasePrefix() {
return databasePrefix;
}
public boolean performConnectionTest() {
return useConnectionTest;
}
}