-
Notifications
You must be signed in to change notification settings - Fork 397
Expand file tree
/
Copy pathCERTOracleBase.java
More file actions
88 lines (71 loc) · 2.3 KB
/
CERTOracleBase.java
File metadata and controls
88 lines (71 loc) · 2.3 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
package sqlancer.common.oracle;
import java.util.Arrays;
import java.util.List;
import sqlancer.Randomly;
import sqlancer.SQLGlobalState;
import sqlancer.common.query.ExpectedErrors;
public abstract class CERTOracleBase<S extends SQLGlobalState<?, ?>> implements TestOracle<S> {
protected final S state;
protected final ExpectedErrors errors;
protected List<String> queryPlan1Sequences;
protected List<String> queryPlan2Sequences;
protected enum Mutator {
JOIN, DISTINCT, WHERE, GROUPBY, HAVING, AND, OR, LIMIT;
public static Mutator getRandomExcept(Mutator... exclude) {
Mutator[] values = Arrays.stream(values()).filter(m -> !Arrays.asList(exclude).contains(m))
.toArray(Mutator[]::new);
return Randomly.fromOptions(values);
}
}
protected CERTOracleBase(S state) {
this.state = state;
this.errors = new ExpectedErrors();
}
protected boolean mutate(Mutator... exclude) {
Mutator m = Mutator.getRandomExcept(exclude);
switch (m) {
case JOIN:
return mutateJoin();
case DISTINCT:
return mutateDistinct();
case WHERE:
return mutateWhere();
case GROUPBY:
return mutateGroupBy();
case HAVING:
return mutateHaving();
case AND:
return mutateAnd();
case OR:
return mutateOr();
case LIMIT:
return mutateLimit();
default:
throw new AssertionError(m);
}
}
protected boolean mutateJoin() {
throw new UnsupportedOperationException();
}
protected boolean mutateDistinct() {
throw new UnsupportedOperationException();
}
protected boolean mutateWhere() {
throw new UnsupportedOperationException();
}
protected boolean mutateGroupBy() {
throw new UnsupportedOperationException();
}
protected boolean mutateHaving() {
throw new UnsupportedOperationException();
}
protected boolean mutateAnd() {
throw new UnsupportedOperationException();
}
protected boolean mutateOr() {
throw new UnsupportedOperationException();
}
protected boolean mutateLimit() {
throw new UnsupportedOperationException();
}
}