Skip to content

Commit 07f117c

Browse files
daniel-rafflerbaierd
authored andcommitted
Added another version of the native test for #339 that fixes the bug.
1 parent ff0b515 commit 07f117c

File tree

1 file changed

+36
-5
lines changed

1 file changed

+36
-5
lines changed

src/org/sosy_lab/java_smt/solvers/mathsat5/Mathsat5NativeApiTest.java

+36-5
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ public void enumTypeTest() throws SolverException, InterruptedException {
537537

538538
private final ExecutorService executor = Executors.newSingleThreadExecutor();
539539

540-
@SuppressWarnings("unused")
540+
541541
private long createSharedEnv(long sibling) {
542542
long cfg = msat_create_config();
543543
msat_set_option_checked(cfg, "dpll.ghost_filtering", "true");
@@ -546,32 +546,63 @@ private long createSharedEnv(long sibling) {
546546
long prover = msat_create_shared_env(cfg, sibling);
547547
msat_destroy_config(cfg);
548548

549-
// FIXME: Bug #339 is caused by this line. Removing it will fix the test.
550-
long hook = msat_set_termination_callback(prover, () -> false);
551-
552549
return prover;
553550
}
554551

555552
private long makeLt(long e, long t1, long t2) {
556553
return msat_make_not(e, msat_make_leq(e, t2, t1));
557554
}
558555

556+
@SuppressWarnings("unused")
559557
@Test
560-
public void bug339Test() throws ExecutionException, InterruptedException {
558+
public void bug339BrokenTest() throws ExecutionException, InterruptedException {
561559
long integerType = msat_get_integer_type(env);
562560

563561
long varA = msat_make_variable(env, "A", integerType);
564562
long varB = msat_make_variable(env, "B", integerType);
565563

566564
long formula = msat_make_and(env, makeLt(env, varA, varB), makeLt(env, varB, varA));
565+
long prover = createSharedEnv(this.env);
566+
567+
// FIXME: Bug #339 is caused by this line. Removing it will fix the test.
568+
long hook = msat_set_termination_callback(prover, () -> false);
569+
570+
msat_assert_formula(prover, formula);
567571

572+
Future<?> task1 =
573+
executor.submit(
574+
() -> {
575+
try {
576+
assertThat(msat_check_sat(prover)).isFalse();
577+
} catch (InterruptedException | SolverException pE) {
578+
throw new RuntimeException(pE);
579+
}
580+
});
581+
582+
assert task1.get() == null;
583+
}
584+
585+
@SuppressWarnings("unused")
586+
@Test
587+
public void bug339FixedTest() throws ExecutionException, InterruptedException {
588+
long integerType = msat_get_integer_type(env);
589+
590+
long varA = msat_make_variable(env, "A", integerType);
591+
long varB = msat_make_variable(env, "B", integerType);
592+
593+
long formula = msat_make_and(env, makeLt(env, varA, varB), makeLt(env, varB, varA));
568594
long prover = createSharedEnv(this.env);
595+
569596
msat_assert_formula(prover, formula);
570597

571598
Future<?> task1 =
572599
executor.submit(
573600
() -> {
574601
try {
602+
// FIXME: Bug #339 is not triggered if we add the callback on the thread that
603+
// will do the calculation
604+
long hook = msat_set_termination_callback(prover, () -> false);
605+
575606
assertThat(msat_check_sat(prover)).isFalse();
576607
} catch (InterruptedException | SolverException pE) {
577608
throw new RuntimeException(pE);

0 commit comments

Comments
 (0)