Skip to content

Commit 50e8ab9

Browse files
Merge pull request #1703 from goblint/issue_1647
Fix flaky cram tests where `vid`s leak into witnesses
2 parents b90ee73 + fcdcf13 commit 50e8ab9

File tree

3 files changed

+42
-14
lines changed

3 files changed

+42
-14
lines changed

tests/regression/56-witness/66-ghost-alloc-lock.t

+14-13
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,18 @@
1616
unsafe: 0
1717
total memory locations: 4
1818

19-
$ yamlWitnessStrip < witness.yml
19+
$ (yamlWitnessStrip < witness.yml) > new-stripped.yml
20+
$ ./strip-ghost-alloc.sh new-stripped.yml
2021
- entry_type: ghost_instrumentation
2122
content:
2223
ghost_variables:
23-
- name: alloc_m559918035_locked
24+
- name: ALLOC_VAR1_LOCKED
2425
scope: global
2526
type: int
2627
initial:
2728
value: "0"
2829
format: c_expression
29-
- name: alloc_m861095507_locked
30+
- name: ALLOC_VAR2_LOCKED
3031
scope: global
3132
type: int
3233
initial:
@@ -46,7 +47,7 @@
4647
column: 3
4748
function: t_fun
4849
updates:
49-
- variable: alloc_m559918035_locked
50+
- variable: ALLOC_VAR1_LOCKED
5051
value: "1"
5152
format: c_expression
5253
- location:
@@ -56,7 +57,7 @@
5657
column: 3
5758
function: t_fun
5859
updates:
59-
- variable: alloc_m559918035_locked
60+
- variable: ALLOC_VAR1_LOCKED
6061
value: "0"
6162
format: c_expression
6263
- location:
@@ -66,7 +67,7 @@
6667
column: 3
6768
function: t_fun
6869
updates:
69-
- variable: alloc_m861095507_locked
70+
- variable: ALLOC_VAR2_LOCKED
7071
value: "1"
7172
format: c_expression
7273
- location:
@@ -76,7 +77,7 @@
7677
column: 3
7778
function: t_fun
7879
updates:
79-
- variable: alloc_m861095507_locked
80+
- variable: ALLOC_VAR2_LOCKED
8081
value: "0"
8182
format: c_expression
8283
- location:
@@ -96,7 +97,7 @@
9697
column: 3
9798
function: main
9899
updates:
99-
- variable: alloc_m559918035_locked
100+
- variable: ALLOC_VAR1_LOCKED
100101
value: "1"
101102
format: c_expression
102103
- location:
@@ -106,7 +107,7 @@
106107
column: 3
107108
function: main
108109
updates:
109-
- variable: alloc_m559918035_locked
110+
- variable: ALLOC_VAR1_LOCKED
110111
value: "0"
111112
format: c_expression
112113
- location:
@@ -116,7 +117,7 @@
116117
column: 3
117118
function: main
118119
updates:
119-
- variable: alloc_m861095507_locked
120+
- variable: ALLOC_VAR2_LOCKED
120121
value: "1"
121122
format: c_expression
122123
- location:
@@ -126,17 +127,17 @@
126127
column: 3
127128
function: main
128129
updates:
129-
- variable: alloc_m861095507_locked
130+
- variable: ALLOC_VAR2_LOCKED
130131
value: "0"
131132
format: c_expression
132133
- entry_type: flow_insensitive_invariant
133134
flow_insensitive_invariant:
134-
string: '! multithreaded || (alloc_m861095507_locked || g2 == 0)'
135+
string: '! multithreaded || (ALLOC_VAR2_LOCKED || g2 == 0)'
135136
type: assertion
136137
format: C
137138
- entry_type: flow_insensitive_invariant
138139
flow_insensitive_invariant:
139-
string: '! multithreaded || (alloc_m559918035_locked || g1 == 0)'
140+
string: '! multithreaded || (ALLOC_VAR1_LOCKED || g1 == 0)'
140141
type: assertion
141142
format: C
142143
- entry_type: flow_insensitive_invariant

tests/regression/56-witness/dune

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
(run %{update_suite} apron-unassume-set-tokens -q)))))
2626

2727
(cram
28-
(deps (glob_files *.c) (glob_files ??-*.yml)))
28+
(deps (glob_files *.c) (glob_files ??-*.yml) (glob_files strip-ghost-alloc.sh)))
2929

3030
(cram
3131
(applies_to 54-witness-lifter-abortUnless)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
# Check if the correct number of arguments are provided
4+
if [ "$#" -ne 1 ]; then
5+
echo "Usage: $0 <file>"
6+
exit 1
7+
fi
8+
9+
file="$1"
10+
11+
# Function to extract the first and second occurrences of the pattern
12+
extract_variables() {
13+
grep -o -m 2 'alloc_m[0-9]\+_locked' "$1"
14+
}
15+
16+
# Extract variables from the file
17+
var1=$(extract_variables "$file" | sed -n '1p')
18+
var2=$(extract_variables "$file" | sed -n '2p')
19+
20+
# Check if both variables were found
21+
if [ -z "$var1" ] || [ -z "$var2" ]; then
22+
echo "Error: Could not find two occurrences of the pattern 'alloc_m[0-9]+_locked' in the file."
23+
exit 1
24+
fi
25+
26+
# Rename variables and print the modified file to stdout
27+
sed -e "s/$var1/ALLOC_VAR1_LOCKED/g" -e "s/$var2/ALLOC_VAR2_LOCKED/g" "$file"

0 commit comments

Comments
 (0)