Skip to content

Commit 80ede24

Browse files
Added one more test to SolverThreadLocalityTest that checks what happeneds when formulas are used outside of their context.
1 parent 0b3c2b8 commit 80ede24

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.sosy_lab.java_smt.api.IntegerFormulaManager;
2828
import org.sosy_lab.java_smt.api.InterpolatingProverEnvironment;
2929
import org.sosy_lab.java_smt.api.SolverContext;
30+
import org.sosy_lab.java_smt.api.SolverContext.ProverOptions;
3031
import org.sosy_lab.java_smt.api.SolverException;
3132
import org.sosy_lab.java_smt.solvers.opensmt.Logics;
3233

@@ -284,4 +285,55 @@ public <T> void nonlocalInterpolationTest() throws InterruptedException, Executi
284285
assert task3.get() == null;
285286
}
286287
}
288+
289+
@SuppressWarnings("resource")
290+
@Test
291+
public void wrongContextTest() throws InterruptedException, SolverException {
292+
assume()
293+
.that(solverToUse())
294+
.isNoneOf(
295+
Solvers.OPENSMT,
296+
Solvers.MATHSAT5,
297+
Solvers.SMTINTERPOL,
298+
Solvers.Z3,
299+
Solvers.PRINCESS,
300+
Solvers.BOOLECTOR);
301+
302+
// FIXME: This test tries to use a formula that was created in a different context. We expect
303+
// this test to fail for most solvers, but there should be a unique error message.
304+
// Right now we get:
305+
// OpenSMT claims the formula is satisfiable:
306+
// expected to be : unsatisfiable
307+
// but was : org.sosy_lab.java_smt.solvers.opensmt.OpenSmtTheoremProver@10d59286
308+
// which is : satisfiable
309+
// which has model:
310+
// MathSAT5 thows an IllegalStateExpression:
311+
// msat_solve returned "unknown": polarity information is meaningful only for terms of
312+
// type Bool
313+
// SMTInterpol thows an de.uni_freiburg.informatik.ultimate.logic.SMTLIBException:
314+
// Asserted terms created with incompatible theory
315+
// Z3 throws an com.microsoft.z3.Z3Exception:
316+
// invalid argument
317+
// Princess throws an java.util.NoSuchElementException:
318+
// key not found: i@15
319+
// Boolector crashes with a segfault:
320+
// boolector_assert: argument 'exp' belongs to different Boolector instance
321+
322+
HardIntegerFormulaGenerator gen = new HardIntegerFormulaGenerator(imgr, bmgr);
323+
324+
// Boolector does not support integer, so we have to use two different versions for this test.
325+
BooleanFormula formula =
326+
solverToUse() == Solvers.BOOLECTOR ? bmgr.makeFalse() : gen.generate(8);
327+
328+
try (SolverContext newContext = factory.generateContext()) {
329+
try (BasicProverEnvironment<?> prover =
330+
newContext.newProverEnvironment(ProverOptions.GENERATE_MODELS)) {
331+
// Trying to add a formula from our global context to the newly created solver context.
332+
prover.push(formula);
333+
assertThat(prover).isUnsatisfiable();
334+
}
335+
} catch (InvalidConfigurationException e) {
336+
throw new RuntimeException(e);
337+
}
338+
}
287339
}

0 commit comments

Comments
 (0)