Skip to content

Commit 3988737

Browse files
authored
Merge pull request #1889 from goblint/dbg-regression
Remove `dbg.regression` option
2 parents db6db2d + 604e87f commit 3988737

File tree

4 files changed

+23
-34
lines changed

4 files changed

+23
-34
lines changed

docs/developer-guide/testing.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,24 @@ Regression tests can be run with various granularity:
1616

1717
* Run all (non-Apron) regression tests with: `./scripts/update_suite.rb`.
1818
* Run all Apron tests with: `dune build @runaprontest`.
19-
* Run a group of tests with: `./scripts/update_suite.rb group sanity`.
19+
* Run a group of tests (by directory, without number) with: `./scripts/update_suite.rb group sanity`.
2020

2121
Unfortunately this also runs skipped tests.
2222
This is a bug that is used as a feature in the tests with Apron, as not all CI jobs have the Apron library installed.
2323

24-
* Run a single test with: `./scripts/update_suite.rb assert`.
25-
* Run a single test with full output: `./regtest.sh 00 01`.
24+
* Run a single test (by name, without group or number) with: `./scripts/update_suite.rb assert`.
2625

27-
Additional options are also passed to Goblint.
26+
This compares Goblint output with test annotations (described below) and only outputs mismatches (i.e. test failures).
27+
It is useful for checking if the test passes (or which parts don't).
28+
Since group name is not specified, beware of same test name in multiple groups.
2829

29-
To pass additional options to Goblint with `update_suite.rb`, use the `gobopt` environment variable, e.g.:
30+
* Run a single test (by group and test number) with full output: `./regtest.sh 00 01`.
31+
32+
This _does not_ compare Goblint output with test annotations, but directly shows all Goblint output.
33+
It is useful for debugging the test.
34+
Additional command-line options are also passed to Goblint.
35+
36+
To pass additional command-line options to Goblint with `update_suite.rb`, use the `gobopt` environment variable, e.g.:
3037
```
3138
gobopt='--set ana.base.privatization write+lock' ./scripts/update_suite.rb
3239
```

regtest.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#MacOS: needs brew install grep
33
if [ $# -lt 2 ]; then
44
echo "Usage: $0 group-nr test-nr [extra options]"
5+
echo "(Does not check test annotations.)"
56
exit 1
67
fi
78
file=(tests/regression/$1*/$2*.c)
@@ -14,7 +15,7 @@ if [[ $OSTYPE == 'darwin'* ]]; then
1415
grep="ggrep"
1516
fi
1617
params="`$grep -oP "PARAM: \K.*" $file`"
17-
cmd="./goblint --enable warn.debug --enable dbg.regression --html $params ${@:3} $file" # -v
18+
cmd="./goblint --enable warn.debug --html $params ${@:3} $file" # -v
1819
echo "$cmd"
1920
eval $cmd
2021
echo "See result/index.xml"

src/analyses/assert.ml

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,24 @@ struct
1414
(* transfer functions *)
1515

1616
let assert_fn man e check refine =
17-
let expr = CilType.Exp.show e in
18-
let warn warn_fn ?annot msg = if check then
19-
if get_bool "dbg.regression" then ( (* This only prints unexpected results (with the difference) as indicated by the comment behind the assert (same as used by the regression test script). *)
20-
let loc = !M.current_loc in
21-
let line = List.at (List.of_enum @@ File.lines_of loc.file) (loc.line-1) in (* nosemgrep: batenum-of_enum *)
22-
let open Str in
23-
let expected = if string_match (regexp ".+//.*\\(FAIL\\|UNKNOWN\\).*") line 0 then Some (matched_group 1 line) else None in
24-
if expected <> annot then (
25-
let result = if annot = None && (expected = Some ("NOWARN") || (expected = Some ("UNKNOWN") && not (String.exists line "UNKNOWN!"))) then "improved" else "failed" in
26-
(* Expressions with logical connectives like a && b are calculated in temporary variables by CIL. Instead of the original expression, we then see something like tmp___0. So we replace expr in msg by the original source if this is the case. *)
27-
let assert_expr = if string_match (regexp ".*assert(\\(.+\\));.*") line 0 then matched_group 1 line else expr in
28-
let msg = if expr <> assert_expr then String.nreplace ~str:msg ~sub:expr ~by:assert_expr else msg in
29-
warn_fn (msg ^ " Expected: " ^ (expected |? "SUCCESS") ^ " -> " ^ result)
30-
)
31-
) else
32-
warn_fn msg
17+
let assert_msg severity fmt =
18+
if check then
19+
M.msg severity ~category:Assert fmt
20+
else
21+
GobPretty.igprintf () fmt
3322
in
34-
(* TODO: use format instead of %s for the following messages *)
3523
match Queries.eval_bool (Analyses.ask_of_man man) e with
3624
| `Lifted false ->
37-
warn (M.error ~category:Assert "%s") ~annot:"FAIL" ("Assertion \"" ^ expr ^ "\" will fail.");
25+
assert_msg Error "Assertion \"%a\" will fail." CilType.Exp.pretty e;
3826
if refine then raise Analyses.Deadcode else man.local
3927
| `Lifted true ->
40-
warn (M.success ~category:Assert "%s") ("Assertion \"" ^ expr ^ "\" will succeed");
28+
assert_msg Success "Assertion \"%a\" will succeed" CilType.Exp.pretty e;
4129
man.local
4230
| `Bot ->
43-
M.error ~category:Assert "%s" ("Assertion \"" ^ expr ^ "\" produces a bottom. What does that mean? (currently uninitialized arrays' content is bottom)");
31+
M.error ~category:Assert "Assertion \"%a\" produces a bottom. What does that mean? (currently uninitialized arrays' content is bottom)" CilType.Exp.pretty e;
4432
man.local
4533
| `Top ->
46-
warn (M.warn ~category:Assert "%s") ~annot:"UNKNOWN" ("Assertion \"" ^ expr ^ "\" is unknown.");
34+
assert_msg Warning "Assertion \"%a\" is unknown." CilType.Exp.pretty e;
4735
man.local
4836

4937
let special man (lval: lval option) (f:varinfo) (args:exp list) : D.t =

src/config/options.schema.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2202,13 +2202,6 @@
22022202
"type": "boolean",
22032203
"default": false
22042204
},
2205-
"regression": {
2206-
"title": "dbg.regression",
2207-
"description":
2208-
"Only output warnings for assertions that have an unexpected result (no comment, comment FAIL, comment UNKNOWN)",
2209-
"type": "boolean",
2210-
"default": false
2211-
},
22122205
"test": {
22132206
"title": "dbg.test",
22142207
"type": "object",

0 commit comments

Comments
 (0)