forked from sqlancer/sqlancer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompositeTestOracle.java
More file actions
37 lines (30 loc) · 970 Bytes
/
CompositeTestOracle.java
File metadata and controls
37 lines (30 loc) · 970 Bytes
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
package sqlancer.common.oracle;
import java.util.List;
import sqlancer.GlobalState;
public class CompositeTestOracle<G extends GlobalState<?, ?, ?>> implements TestOracle<G> {
private final List<TestOracle<G>> oracles;
private final G globalState;
private int i;
private int iLast;
public CompositeTestOracle(List<TestOracle<G>> oracles, G globalState) {
this.globalState = globalState;
this.oracles = oracles;
}
@Override
public void check() throws Exception {
try {
oracles.get(i).check();
iLast = i;
boolean lastOracleIndex = i == oracles.size() - 1;
if (!lastOracleIndex) {
globalState.getManager().incrementSelectQueryCount();
}
} finally {
i = (i + 1) % oracles.size();
}
}
@Override
public String getLastQueryString() {
return oracles.get(iLast).getLastQueryString();
}
}