Skip to content

Commit 92f2f60

Browse files
author
BaierD
committed
Add Int and BV test for context shutdown and prover reuse afterward
1 parent 2b81ac8 commit 92f2f60

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,52 @@ public void testProverInterruptWithSubsequentNewProverUsageInt()
135135
}
136136
}
137137

138+
// Test shutdown of context-wide shutdown manager. No prover should be usable afterward!
139+
@Test(timeout = TIMEOUT_MILLISECONDS)
140+
public void testContextInterruptWithSubsequentNewProverUsageBv()
141+
throws InterruptedException, SolverException {
142+
requireBitvectors();
143+
requireIsolatedProverShutdown();
144+
145+
testBasicContextTimeoutBv(() -> context.newProverEnvironment());
146+
assertThat(shutdownManager.getNotifier().shouldShutdown()).isTrue();
147+
148+
HardBitvectorFormulaGenerator gen = new HardBitvectorFormulaGenerator(bvmgr, bmgr);
149+
try (BasicProverEnvironment<?> pe = context.newProverEnvironment()) {
150+
pe.push(gen.generate(8));
151+
assertThrows(InterruptedException.class, pe::isUnsat);
152+
153+
} catch (InterruptedException expected) {
154+
// We don't really know where an exception is coming from currently.
155+
// TODO: define where and how exceptions are thrown if we build a new prover but shutdown
156+
// has been requested.
157+
assertThat(expected).isNotNull();
158+
}
159+
}
160+
161+
// Test shutdown of context-wide shutdown manager. No prover should be usable afterward!
162+
@Test(timeout = TIMEOUT_MILLISECONDS)
163+
public void testContextInterruptWithSubsequentNewProverUsageInt()
164+
throws InterruptedException, SolverException {
165+
requireIntegers();
166+
requireIsolatedProverShutdown();
167+
168+
testBasicContextTimeoutInt(() -> context.newProverEnvironment());
169+
assertThat(shutdownManager.getNotifier().shouldShutdown()).isTrue();
170+
171+
HardIntegerFormulaGenerator gen = new HardIntegerFormulaGenerator(imgr, bmgr);
172+
try (BasicProverEnvironment<?> pe = context.newProverEnvironment()) {
173+
pe.push(gen.generate(8));
174+
assertThrows(InterruptedException.class, pe::isUnsat);
175+
176+
} catch (InterruptedException expected) {
177+
// We don't really know where an exception is coming from currently.
178+
// TODO: define where and how exceptions are thrown if we build a new prover but shutdown
179+
// has been requested.
180+
assertThat(expected).isNotNull();
181+
}
182+
}
183+
138184
@Test(timeout = TIMEOUT_MILLISECONDS)
139185
public void testInterpolationProverTimeout() throws InterruptedException {
140186
requireInterpolation();

0 commit comments

Comments
 (0)