36
36
import org .sosy_lab .java_smt .solvers .opensmt .Logics ;
37
37
38
38
public class SolverThreadLocalTest extends SolverBasedTest0 .ParameterizedSolverBasedTest0 {
39
+ ExecutorService executor = Executors .newFixedThreadPool (2 );
40
+
39
41
@ Test
40
42
public void allLocalTest () throws InterruptedException , SolverException {
41
43
requireIntegers ();
@@ -53,9 +55,9 @@ public void allLocalTest() throws InterruptedException, SolverException {
53
55
@ Test
54
56
public void nonlocalContext () throws ExecutionException , InterruptedException , SolverException {
55
57
requireIntegers ();
58
+
56
59
assume ().that (solverToUse ()).isNotEqualTo (Solvers .CVC5 );
57
60
58
- ExecutorService executor = Executors .newSingleThreadExecutor ();
59
61
Future <SolverContext > result =
60
62
executor .submit (
61
63
() -> {
@@ -106,9 +108,9 @@ public void nonlocalContext() throws ExecutionException, InterruptedException, S
106
108
public void nonlocalFormulaTest ()
107
109
throws InterruptedException , SolverException , ExecutionException {
108
110
requireIntegers ();
111
+
109
112
assume ().that (solverToUse ()).isNotEqualTo (Solvers .CVC5 );
110
113
111
- ExecutorService executor = Executors .newSingleThreadExecutor ();
112
114
Future <BooleanFormula > result =
113
115
executor .submit (
114
116
() -> {
@@ -134,47 +136,58 @@ public void nonlocalFormulaTest()
134
136
}
135
137
}
136
138
137
- @ SuppressWarnings ("resource" )
138
139
@ Test
139
140
public void nonlocalProverTest () throws InterruptedException , ExecutionException {
140
141
requireIntegers ();
142
+
141
143
assume ().that (solverToUse ()).isNotEqualTo (Solvers .CVC5 );
142
144
143
145
HardIntegerFormulaGenerator gen = new HardIntegerFormulaGenerator (imgr , bmgr );
144
146
BooleanFormula formula = gen .generate (8 );
145
147
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 );
169
166
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
+ }
171
185
}
172
186
173
187
@ Override
174
- protected Logics logicToUse () {
175
- return Logics .QF_LIA ;
176
- }
188
+ protected Logics logicToUse () { return Logics .QF_LIA ; }
177
189
190
+ // Make sure that the solver returned a valid interpolant for the two formulas
178
191
private void checkInterpolant (
179
192
BooleanFormula formulaA , BooleanFormula formulaB , BooleanFormula itp )
180
193
throws SolverException , InterruptedException {
@@ -213,9 +226,8 @@ public <T> void localInterpolationTest() throws InterruptedException, SolverExce
213
226
public <T > void nonlocalInterpolationTest () throws InterruptedException , ExecutionException {
214
227
requireIntegers ();
215
228
requireInterpolation ();
216
- assume ().that (solverToUse ()).isNotEqualTo (Solvers .CVC5 );
217
229
218
- ExecutorService executor = Executors . newFixedThreadPool ( 5 );
230
+ assume (). that ( solverToUse ()). isNotEqualTo ( Solvers . CVC5 );
219
231
220
232
BooleanFormula f1 = imgr .lessThan (imgr .makeVariable ("A" ), imgr .makeVariable ("B" ));
221
233
BooleanFormula f2 = imgr .lessThan (imgr .makeVariable ("B" ), imgr .makeVariable ("A" ));
@@ -237,18 +249,6 @@ public <T> void nonlocalInterpolationTest() throws InterruptedException, Executi
237
249
// (AbstractProver.java:88)
238
250
// at ..
239
251
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 ..
252
252
assertThat (prover ).isUnsatisfiable ();
253
253
254
254
} catch (SolverException | InterruptedException pE ) {
0 commit comments