Skip to content

Commit dc5ee89

Browse files
Cleaned up SolverThreadLocalTest class
1 parent 0436959 commit dc5ee89

File tree

1 file changed

+44
-44
lines changed

1 file changed

+44
-44
lines changed

src/org/sosy_lab/java_smt/test/SolverThreadLocalTest.java

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import org.sosy_lab.java_smt.solvers.opensmt.Logics;
3737

3838
public class SolverThreadLocalTest extends SolverBasedTest0.ParameterizedSolverBasedTest0 {
39+
ExecutorService executor = Executors.newFixedThreadPool(2);
40+
3941
@Test
4042
public void allLocalTest() throws InterruptedException, SolverException {
4143
requireIntegers();
@@ -53,9 +55,9 @@ public void allLocalTest() throws InterruptedException, SolverException {
5355
@Test
5456
public void nonlocalContext() throws ExecutionException, InterruptedException, SolverException {
5557
requireIntegers();
58+
5659
assume().that(solverToUse()).isNotEqualTo(Solvers.CVC5);
5760

58-
ExecutorService executor = Executors.newSingleThreadExecutor();
5961
Future<SolverContext> result =
6062
executor.submit(
6163
() -> {
@@ -106,9 +108,9 @@ public void nonlocalContext() throws ExecutionException, InterruptedException, S
106108
public void nonlocalFormulaTest()
107109
throws InterruptedException, SolverException, ExecutionException {
108110
requireIntegers();
111+
109112
assume().that(solverToUse()).isNotEqualTo(Solvers.CVC5);
110113

111-
ExecutorService executor = Executors.newSingleThreadExecutor();
112114
Future<BooleanFormula> result =
113115
executor.submit(
114116
() -> {
@@ -134,47 +136,58 @@ public void nonlocalFormulaTest()
134136
}
135137
}
136138

137-
@SuppressWarnings("resource")
138139
@Test
139140
public void nonlocalProverTest() throws InterruptedException, ExecutionException {
140141
requireIntegers();
142+
141143
assume().that(solverToUse()).isNotEqualTo(Solvers.CVC5);
142144

143145
HardIntegerFormulaGenerator gen = new HardIntegerFormulaGenerator(imgr, bmgr);
144146
BooleanFormula formula = gen.generate(8);
145147

146-
ExecutorService executor = Executors.newSingleThreadExecutor();
147-
Future<?> task =
148-
executor.submit(
149-
() -> {
150-
try (BasicProverEnvironment<?> prover = context.newProverEnvironment()) {
151-
// FIXME: Exception for CVC5
152-
// io.github.cvc5.CVC5ApiException:
153-
// Given term is not associated with the node manager of this solver
154-
// at io.github.cvc5.Solver.assertFormula
155-
// (Native Method)
156-
// at io.github.cvc5.Solver.assertFormula
157-
// (Solver.java:1455)
158-
// at org.sosy_lab.java_smt.solvers.cvc5.CVC5AbstractProver.addConstraintImpl
159-
// (CVC5AbstractProver.java:114)
160-
// at org.sosy_lab.java_smt.basicimpl.AbstractProver.addConstraint
161-
// (AbstractProver.java:108)
162-
// at ..
163-
prover.push(formula);
164-
assertThat(prover).isUnsatisfiable();
165-
} catch (SolverException | InterruptedException pE) {
166-
throw new RuntimeException(pE);
167-
}
168-
});
148+
try (BasicProverEnvironment<?> prover = context.newProverEnvironment()) {
149+
Future<?> task =
150+
executor.submit(
151+
() -> {
152+
try {
153+
// FIXME: Exception for CVC5
154+
// io.github.cvc5.CVC5ApiException:
155+
// Given term is not associated with the node manager of this solver
156+
// at io.github.cvc5.Solver.assertFormula
157+
// (Native Method)
158+
// at io.github.cvc5.Solver.assertFormula
159+
// (Solver.java:1455)
160+
// at org.sosy_lab.java_smt.solvers.cvc5.CVC5AbstractProver.addConstraintImpl
161+
// (CVC5AbstractProver.java:114)
162+
// at org.sosy_lab.java_smt.basicimpl.AbstractProver.addConstraint
163+
// (AbstractProver.java:108)
164+
// at ..
165+
prover.push(formula);
169166

170-
assert task.get() == null;
167+
// FIXME: Exception for MathSAT (bug #339)
168+
// java.lang.StackOverflowError
169+
// at org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_solve
170+
// (Native Method)
171+
// at org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_check_sat
172+
// (Mathsat5NativeApi.java:156)
173+
// at org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5AbstractProver.isUnsat
174+
// (Mathsat5AbstractProver.java:106)
175+
// at org.sosy_lab.java_smt.test.ProverEnvironmentSubject.isUnsatisfiable
176+
// (ProverEnvironmentSubject.java:67)
177+
// at ..
178+
assertThat(prover).isUnsatisfiable();
179+
} catch (SolverException | InterruptedException pE) {
180+
throw new RuntimeException(pE);
181+
}
182+
});
183+
assert task.get() == null;
184+
}
171185
}
172186

173187
@Override
174-
protected Logics logicToUse() {
175-
return Logics.QF_LIA;
176-
}
188+
protected Logics logicToUse() { return Logics.QF_LIA; }
177189

190+
// Make sure that the solver returned a valid interpolant for the two formulas
178191
private void checkInterpolant(
179192
BooleanFormula formulaA, BooleanFormula formulaB, BooleanFormula itp)
180193
throws SolverException, InterruptedException {
@@ -213,9 +226,8 @@ public <T> void localInterpolationTest() throws InterruptedException, SolverExce
213226
public <T> void nonlocalInterpolationTest() throws InterruptedException, ExecutionException {
214227
requireIntegers();
215228
requireInterpolation();
216-
assume().that(solverToUse()).isNotEqualTo(Solvers.CVC5);
217229

218-
ExecutorService executor = Executors.newFixedThreadPool(5);
230+
assume().that(solverToUse()).isNotEqualTo(Solvers.CVC5);
219231

220232
BooleanFormula f1 = imgr.lessThan(imgr.makeVariable("A"), imgr.makeVariable("B"));
221233
BooleanFormula f2 = imgr.lessThan(imgr.makeVariable("B"), imgr.makeVariable("A"));
@@ -237,18 +249,6 @@ public <T> void nonlocalInterpolationTest() throws InterruptedException, Executi
237249
// (AbstractProver.java:88)
238250
// at ..
239251
prover.push(f2);
240-
241-
// FIXME: Exception for MathSAT (bug #339)
242-
// java.lang.StackOverflowError
243-
// at org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_solve
244-
// (Native Method)
245-
// at org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_check_sat
246-
// (Mathsat5NativeApi.java:156)
247-
// at org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5AbstractProver.isUnsat
248-
// (Mathsat5AbstractProver.java:106)
249-
// at org.sosy_lab.java_smt.test.ProverEnvironmentSubject.isUnsatisfiable
250-
// (ProverEnvironmentSubject.java:67)
251-
// at ..
252252
assertThat(prover).isUnsatisfiable();
253253

254254
} catch (SolverException | InterruptedException pE) {

0 commit comments

Comments
 (0)