Skip to content

Commit

Permalink
Add test for synthetic YAML witness invariant locations (PR #758)
Browse files Browse the repository at this point in the history
  • Loading branch information
sim642 committed Feb 8, 2024
1 parent 6c9d719 commit 990cf0c
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 6 deletions.
6 changes: 1 addition & 5 deletions tests/regression/56-witness/dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
(env
(_
(binaries ../../util/yamlWitnessStrip.exe)))

(cram
(deps (glob_files *.c) %{bin:yamlWitnessStrip}))
(deps (glob_files *.c)))
9 changes: 8 additions & 1 deletion tests/regression/dune
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
(env
(_
(binaries ../util/yamlWitnessStrip.exe)))

(cram
(applies_to :whole_subtree)
(deps %{bin:goblint} (package goblint))) ; need entire package for includes/
(deps
%{bin:goblint}
(package goblint) ; need entire package for includes/
%{bin:yamlWitnessStrip}))
22 changes: 22 additions & 0 deletions tests/regression/pr-758.t/pr-758.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Code from https://github.com/goblint/cil/pull/98

int main() {
// for loop
int x = 42;
for (x = 0; x < 10; x++) { // there shouldn't be invariants x <= 9, x <= 10 and 0 <= x before this line
// ...
}

// expression with side effect
int i, k;
i = k = 0; // there shouldn't be invariant k == 0 before this line

// compound initializers
struct kala {
int kaal;
int hind;
};

struct kala a = {2, 3}; // there shouldn't be invariant a.kaal == 2 before this line
return 0;
}
119 changes: 119 additions & 0 deletions tests/regression/pr-758.t/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
$ goblint --enable ana.int.interval --enable witness.yaml.enabled --set witness.yaml.entry-types '["loop_invariant", "location_invariant"]' pr-758.c
[Info][Deadcode] Logical lines of code (LLoC) summary:
live: 6
dead: 0
total lines: 6
[Info][Witness] witness generation summary:
total generation entries: 10

$ yamlWitnessStrip < witness.yml
- entry_type: loop_invariant
location:
file_name: pr-758.c
file_hash: $FILE_HASH
line: 6
column: 2
function: main
loop_invariant:
string: (0 <= x && (x <= 9 || x <= 10))
type: assertion
format: C
- entry_type: location_invariant
location:
file_name: pr-758.c
file_hash: $FILE_HASH
line: 21
column: 2
function: main
location_invariant:
string: x == 10
type: assertion
format: C
- entry_type: location_invariant
location:
file_name: pr-758.c
file_hash: $FILE_HASH
line: 21
column: 2
function: main
location_invariant:
string: k == 0
type: assertion
format: C
- entry_type: location_invariant
location:
file_name: pr-758.c
file_hash: $FILE_HASH
line: 21
column: 2
function: main
location_invariant:
string: i == 0
type: assertion
format: C
- entry_type: location_invariant
location:
file_name: pr-758.c
file_hash: $FILE_HASH
line: 21
column: 2
function: main
location_invariant:
string: a.kaal == 2
type: assertion
format: C
- entry_type: location_invariant
location:
file_name: pr-758.c
file_hash: $FILE_HASH
line: 21
column: 2
function: main
location_invariant:
string: a.hind == 3
type: assertion
format: C
- entry_type: location_invariant
location:
file_name: pr-758.c
file_hash: $FILE_HASH
line: 20
column: 2
function: main
location_invariant:
string: x == 10
type: assertion
format: C
- entry_type: location_invariant
location:
file_name: pr-758.c
file_hash: $FILE_HASH
line: 20
column: 2
function: main
location_invariant:
string: k == 0
type: assertion
format: C
- entry_type: location_invariant
location:
file_name: pr-758.c
file_hash: $FILE_HASH
line: 20
column: 2
function: main
location_invariant:
string: i == 0
type: assertion
format: C
- entry_type: location_invariant
location:
file_name: pr-758.c
file_hash: $FILE_HASH
line: 12
column: 2
function: main
location_invariant:
string: x == 10
type: assertion
format: C

0 comments on commit 990cf0c

Please sign in to comment.