Skip to content

Commit 82c6764

Browse files
committed
"Fix" unit tests by ignoring rule predicate and substitution
Adapt test-3934-smt
1 parent 0603d89 commit 82c6764

File tree

8 files changed

+13085
-60451
lines changed

8 files changed

+13085
-60451
lines changed

booster/test/rpc-integration/resources/3934-smt.kompile

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ set -eux
22

33
SCRIPT_DIR=$(dirname $0)
44
PLUGIN_DIR=${PLUGIN_DIR:-""}
5-
SECP=${SECP256K1_DIR:-/usr}
65

76

87
if [ -z "$PLUGIN_DIR" ]; then
@@ -19,7 +18,6 @@ else
1918
PLUGIN_CPP="${PLUGIN_DIR}/include/plugin-c/crypto.cpp ${PLUGIN_DIR}/include/plugin-c/plugin_util.cpp"
2019
fi
2120

22-
SECP_OPTS="-I${SECP}/include -L${SECP}/lib"
2321

2422
NAME=$(basename ${0%.tar.gz.kompile})
2523
NAMETGZ=$(basename ${0%.kompile})
@@ -42,7 +40,7 @@ esac
4240
llvm-kompile 3934-smt.llvm.kore ./dt c -- \
4341
-fPIC -std=c++17 -o interpreter \
4442
$PLUGIN_LIBS $PLUGIN_INCLUDE $PLUGIN_CPP \
45-
-lcrypto -lssl $LPROCPS ${SECP_OPTS}
43+
-lcrypto -lssl $LPROCPS -lsecp256k1
4644

4745
mv interpreter.* 3934-smt.dylib
4846

booster/test/rpc-integration/resources/3934-smt.kore

-60,439
This file was deleted.

booster/test/rpc-integration/test-3934-smt/response-003.booster-dev

+2,316
Large diffs are not rendered by default.

booster/test/rpc-integration/test-3934-smt/response-005.booster-dev

+2,236
Large diffs are not rendered by default.

booster/test/rpc-integration/test-3934-smt/response-007.booster-dev

+2,205
Large diffs are not rendered by default.

booster/test/rpc-integration/test-3934-smt/response-008.booster-dev

+6,300
Large diffs are not rendered by default.

booster/unit-tests/Test/Booster/Pattern/Rewrite.hs

+26-5
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ testConf = do
172172
, terminalLabels = []
173173
}
174174

175+
ignoreRulePredicateAndSubst :: RewriteResult Pattern -> RewriteResult Pattern
176+
ignoreRulePredicateAndSubst =
177+
\case
178+
RewriteBranch pre posts -> RewriteBranch pre (NE.map (\(lbl, uid, p, _, _) -> (lbl, uid, p, Nothing, mempty)) posts)
179+
other -> other
180+
175181
----------------------------------------
176182
errorCases
177183
, rewriteSuccess
@@ -244,7 +250,7 @@ rulePriority =
244250

245251
runWith :: Term -> IO (Either (RewriteFailed "Rewrite") (RewriteResult Pattern))
246252
runWith t =
247-
second fst <$> do
253+
second (ignoreRulePredicateAndSubst . fst) <$> do
248254
conf <- testConf
249255
runNoLoggingT $ runRewriteT conf mempty (rewriteStep [] [] $ Pattern_ t)
250256

@@ -260,7 +266,10 @@ branchesTo :: Term -> [(Text, Term)] -> IO ()
260266
t `branchesTo` ts =
261267
runWith t
262268
@?>>= Right
263-
(RewriteBranch (Pattern_ t) $ NE.fromList $ map (\(lbl, t') -> (lbl, mockUniqueId, Pattern_ t')) ts)
269+
( RewriteBranch (Pattern_ t) $
270+
NE.fromList $
271+
map (\(lbl, t') -> (lbl, mockUniqueId, Pattern_ t', Nothing, mempty)) ts
272+
)
264273

265274
failsWith :: Term -> RewriteFailed "Rewrite" -> IO ()
266275
failsWith t err =
@@ -276,7 +285,7 @@ runRewrite t = do
276285
runNoLoggingT $
277286
performRewrite conf $
278287
Pattern_ t
279-
pure (counter, fmap (.term) res)
288+
pure (counter, fmap (.term) (ignoreRulePredicateAndSubst res))
280289

281290
aborts :: RewriteFailed "Rewrite" -> Term -> IO ()
282291
aborts failure t = runRewrite t >>= (@?= (0, RewriteAborted failure t))
@@ -306,11 +315,15 @@ canRewrite =
306315
( "con1-f2"
307316
, mockUniqueId
308317
, [trm| kCell{}( kseq{}( inj{AnotherSort{}, SortKItem{}}( con4{}( \dv{SomeSort{}}("somethingElse"), \dv{SomeSort{}}("somethingElse") ) ), C:SortK{}) ) |]
318+
, Nothing
319+
, mempty
309320
)
310321
branch2 =
311322
( "con1-f1'"
312323
, mockUniqueId
313324
, [trm| kCell{}( kseq{}( inj{SomeSort{}, SortKItem{}}( f1{}( \dv{SomeSort{}}("somethingElse") ) ), C:SortK{}) ) |]
325+
, Nothing
326+
, mempty
314327
)
315328

316329
rewrites
@@ -399,11 +412,15 @@ supportsDepthControl =
399412
( "con1-f2"
400413
, mockUniqueId
401414
, [trm| kCell{}( kseq{}( inj{AnotherSort{}, SortKItem{}}( con4{}( \dv{SomeSort{}}("somethingElse"), \dv{SomeSort{}}("somethingElse") ) ), C:SortK{}) ) |]
415+
, Nothing
416+
, mempty
402417
)
403418
branch2 =
404419
( "con1-f1'"
405420
, mockUniqueId
406421
, [trm| kCell{}( kseq{}( inj{SomeSort{}, SortKItem{}}( f1{}( \dv{SomeSort{}}("somethingElse") ) ), C:SortK{}) ) |]
422+
, Nothing
423+
, mempty
407424
)
408425

409426
rewritesToDepth
@@ -419,7 +436,7 @@ supportsDepthControl =
419436
conf <- testConf
420437
(counter, _, res) <-
421438
runNoLoggingT $ performRewrite conf{mbMaxDepth = Just depth} $ Pattern_ t
422-
(counter, fmap (.term) res) @?= (n, f t')
439+
(counter, fmap (.term) (ignoreRulePredicateAndSubst res)) @?= (n, f t')
423440

424441
supportsCutPoints :: TestTree
425442
supportsCutPoints =
@@ -452,11 +469,15 @@ supportsCutPoints =
452469
( "con1-f2"
453470
, mockUniqueId
454471
, [trm| kCell{}( kseq{}( inj{AnotherSort{}, SortKItem{}}( con4{}( \dv{SomeSort{}}("somethingElse"), \dv{SomeSort{}}("somethingElse") ) ), C:SortK{}) ) |]
472+
, Nothing
473+
, mempty
455474
)
456475
branch2 =
457476
( "con1-f1'"
458477
, mockUniqueId
459478
, [trm| kCell{}( kseq{}( inj{SomeSort{}, SortKItem{}}( f1{}( \dv{SomeSort{}}("somethingElse") ) ), C:SortK{}) ) |]
479+
, Nothing
480+
, mempty
460481
)
461482

462483
rewritesToCutPoint
@@ -474,7 +495,7 @@ supportsCutPoints =
474495
runNoLoggingT $
475496
performRewrite conf{cutLabels = [lbl]} $
476497
Pattern_ t
477-
(counter, fmap (.term) res) @?= (n, f t')
498+
(counter, fmap (.term) (ignoreRulePredicateAndSubst res)) @?= (n, f t')
478499

479500
supportsTerminalRules :: TestTree
480501
supportsTerminalRules =

scripts/booster-integration-tests.sh

+1-4
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ for dir in $(ls -d test-*); do
2828
name=${dir##test-}
2929
echo "Running $name..."
3030
case "$name" in
31-
"3934-smt")
32-
continue
33-
;;
3431
"a-to-f" | "diamond")
3532
SERVER=$BOOSTER_DEV ./runDirectoryTest.sh test-$name $@
3633
SERVER=$KORE_RPC_DEV ./runDirectoryTest.sh test-$name $@
@@ -40,7 +37,7 @@ for dir in $(ls -d test-*); do
4037
SERVER=$KORE_RPC_DEV ./runDirectoryTest.sh test-$name $@
4138
SERVER=$KORE_RPC_BOOSTER ./runDirectoryTest.sh test-$name $@
4239
;;
43-
"get-model" | "collectiontest" | "implies" | "implies2" | "implies-issue-3941" | "remainder-predicates" | "use-path-condition-in-equations" | "issue3764-vacuous-branch")
40+
"get-model" | "collectiontest" | "implies" | "implies2" | "implies-issue-3941" | "remainder-predicates" | "use-path-condition-in-equations" | "issue3764-vacuous-branch" | "3934-smt")
4441
SERVER=$BOOSTER_DEV ./runDirectoryTest.sh test-$name $@
4542
SERVER=$KORE_RPC_BOOSTER ./runDirectoryTest.sh test-$name $@
4643
;;

0 commit comments

Comments
 (0)