Skip to content
This repository was archived by the owner on Oct 3, 2021. It is now read-only.

Commit bb3384c

Browse files
committed
Add benchmark tasks combined from seq-mthreaded/pals_lcr and eca-rers2012/Problem12_label0*
Used in 'Dirk Beyer, Marie-Christine Jakobs, Thomas Lemberger: Difference Verification with Conditions, SEFM20'
1 parent 63aba0a commit bb3384c

File tree

424 files changed

+1118918
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

424 files changed

+1118918
-0
lines changed

c/ReachSafety-Combinations.set

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
combinations/*.yml

c/combinations/Makefile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This file is part of the SV-Benchmarks collection of verification tasks:
2+
# https://github.com/sosy-lab/sv-benchmarks
3+
#
4+
# SPDX-FileCopyrightText: 2015-2016 Daniel Liew <[email protected]>
5+
# SPDX-FileCopyrightText: 2015-2020 The SV-Benchmarks Community
6+
#
7+
# SPDX-License-Identifier: Apache-2.0
8+
9+
LEVEL := ../
10+
11+
CLANG_WARNINGS := \
12+
-Wno-sometimes-uninitialized \
13+
-Wno-uninitialized \
14+
15+
include $(LEVEL)/Makefile.config
16+
17+
license-pals:
18+
reuse addheader --template header.jinja2 --copyright "The SV-Benchmarks Community" --year 2014-2020 --license Apache-2.0 pals_lcr.*c
19+
reuse addheader --template header.jinja2 --copyright "Carnegie Mellon University" --year 2013 --license "LicenseRef-BSD-3-Clause-Attribution-CMU" pals_lcr.*c
20+
reuse addheader --template header.jinja2 --copyright "The RERS Challenge <https://www.rers-challenge.org>" --year 2012 pals_lcr.*c
21+
22+
tasks:
23+
./generate-tasks.py --benchmark-dir ../../ --output-dir ./

c/combinations/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!--
2+
This file is part of the SV-Benchmarks collection of verification tasks:
3+
https://github.com/sosy-lab/sv-benchmarks
4+
5+
SPDX-FileCopyrightText: 2020 The SV-Benchmarks Community
6+
7+
SPDX-License-Identifier: Apache-2.0
8+
-->
9+
10+
This directory contains programs combined from other
11+
benchmark tasks that are available in sv-benchmarks.
12+
13+
The benchmarks were created for evaluation of the work
14+
"Dirk Beyer, Marie-Christine Jakobs, Thomas Lemberger: Difference Verification with Conditions, SEFM 2020."
15+
16+
Tasks were contributed by Marie-Christine Jakobs and Thomas Lemberger.
17+
18+
## Structure of benchmark tasks
19+
20+
Each benchmark task in this directory is created from two other tasks
21+
of other categories, according to the following pattern:
22+
23+
```
24+
/* definitions of Task 1 ... */
25+
int main1() { /* main-method of Task 1 ... */ }
26+
/* definitions of Task 2 ... */
27+
int main2() { /* main-method of Task 2 ... */ }
28+
29+
int main() {
30+
if (__VERIFIER_nondet_int()) {
31+
main1();
32+
} else {
33+
main2();
34+
}
35+
```
36+
37+
Definitions are renamed to avoid conflicts, if necessary.
38+
39+
This construction leads to programs with independent program parts.
40+
41+
The name of each benchmark task reveals its origin:
42+
All task names are created by the pattern ${TASK_1}+${TASK_2}.
43+

c/combinations/generate-tasks.py

Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
#!/usr/bin/env python3
2+
3+
# This file is part of the replication artifact for
4+
# difference verification with conditions:
5+
# https://gitlab.com/sosy-lab/research/data/difference-data
6+
#
7+
# SPDX-FileCopyrightText: 2020 Dirk Beyer <https://sosy-lab.org>
8+
# SPDX-FileCopyrightText: 2020 The SV-Benchmarks Community
9+
#
10+
# SPDX-License-Identifier: Apache-2.0
11+
12+
import argparse
13+
from pathlib import Path
14+
import yaml
15+
import sys
16+
17+
18+
class TaskError(Exception):
19+
pass
20+
21+
22+
def get_tasks(benchmark_dir: Path, glob_pattern):
23+
for file1 in benchmark_dir.glob(glob_pattern):
24+
input_file = _get_input_file(file1)
25+
try:
26+
verdict = _get_verdict(file1)
27+
except TaskError:
28+
print(
29+
"INFO: Ignoring %s because of missing verdict" % str(file1),
30+
file=sys.stderr,
31+
)
32+
continue
33+
else:
34+
yield input_file, verdict
35+
36+
37+
def _get_input_file(yml_task_def):
38+
with yml_task_def.open() as inp:
39+
yml_content = yaml.safe_load(inp)
40+
return yml_task_def.parent / Path(yml_content["input_files"])
41+
42+
43+
def _get_verdict(yml_task_def):
44+
with yml_task_def.open() as inp:
45+
yml_content = yaml.safe_load(inp)
46+
try:
47+
return next(
48+
p["expected_verdict"]
49+
for p in yml_content["properties"]
50+
if p["property_file"].endswith("unreach-call.prp")
51+
)
52+
except StopIteration:
53+
raise TaskError()
54+
55+
56+
def _create_combo(
57+
file1: Path, file2: Path, replacement1=None, replacement2=None
58+
) -> str:
59+
if replacement1:
60+
repl1 = replacement1
61+
else:
62+
repl1 = lambda x: x
63+
if replacement2:
64+
repl2 = replacement2
65+
else:
66+
repl2 = lambda x: x
67+
with file1.open() as inp:
68+
content1 = "".join(
69+
repl1(line.replace("main(", "main1(")) for line in inp.readlines()
70+
)
71+
with file2.open() as inp:
72+
content2 = "".join(
73+
repl2(line.replace("main(", "main2("))
74+
for line in inp.readlines()
75+
if not line.startswith("extern ")
76+
and not line.startswith("void reach_error")
77+
)
78+
79+
additional_defs = """extern unsigned int __VERIFIER_nondet_uint();
80+
extern char __VERIFIER_nondet_char();
81+
extern int __VERIFIER_nondet_int();
82+
extern long __VERIFIER_nondet_long();
83+
extern unsigned long __VERIFIER_nondet_ulong();
84+
extern float __VERIFIER_nondet_float();
85+
extern void exit(int);
86+
"""
87+
88+
return (
89+
additional_defs
90+
+ content1
91+
+ content2
92+
+ """int main()
93+
{
94+
if(__VERIFIER_nondet_int())
95+
main1();
96+
else
97+
main2();
98+
}"""
99+
)
100+
101+
102+
def _get_yml_content(verdict1, verdict2, input_file: str, data_model="ILP32"):
103+
verdict = verdict1 == verdict2 == True
104+
return f"""format_version: '2.0'
105+
106+
input_files: '{input_file}'
107+
108+
properties:
109+
- property_file: ../properties/unreach-call.prp
110+
expected_verdict: {verdict}
111+
112+
options:
113+
language: C
114+
data_model: {data_model}
115+
"""
116+
117+
118+
def create_combos(
119+
pattern1, pattern2, replacement1=None, replacement2=None, output_dir=None
120+
):
121+
tasks1 = list(get_tasks(args.benchmark_dir, pattern1))
122+
tasks2 = list(get_tasks(args.benchmark_dir, pattern2))
123+
124+
output_dir.mkdir(parents=True, exist_ok=True)
125+
126+
for file1, verdict1 in tasks1:
127+
for file2, verdict2 in tasks2:
128+
assert isinstance(verdict1, bool)
129+
assert isinstance(verdict2, bool)
130+
if verdict1 == verdict2 == False:
131+
continue
132+
basename = file1.name[:-2] + "+" + file2.name
133+
c_file = output_dir / Path(basename)
134+
c_content = _create_combo(file1, file2, replacement1, replacement2)
135+
yml_content = _get_yml_content(verdict1, verdict2, c_file.name)
136+
yml_file = output_dir / Path(basename[:-2] + ".yml")
137+
138+
with c_file.open("w") as outp:
139+
outp.write(c_content)
140+
with yml_file.open("w") as outp:
141+
outp.write(yml_content)
142+
143+
144+
def _systemc_replacements1(line) -> str:
145+
return (
146+
line.replace("error(", "error1(")
147+
.replace("init_threads(", "init_threads1(")
148+
.replace("exists_runnable_thread(", "exists_runnable_thread1(")
149+
.replace("eval(", "eval1(")
150+
.replace("init_model(", "init_model1(")
151+
.replace("stop_simulation(", "stop_simulation1(")
152+
.replace("start_simulation(", "start_simulation1(")
153+
.replace("reach_error1(", "reach_error(")
154+
.replace("update_channels(", "update_channels1(")
155+
.replace("fire_delta_events(", "fire_delta_events1(")
156+
.replace("reset_delta_events(", "reset_delta_events1(")
157+
.replace("activate_threads(", "activate_threads1(")
158+
.replace("fire_time_events(", "fire_time_events1(")
159+
.replace("reset_time_events(", "reset_time_events1(")
160+
)
161+
162+
163+
def _systemc_replacements2(line) -> str:
164+
return (
165+
line.replace("error(", "error2(")
166+
.replace("init_threads(", "init_threads2(")
167+
.replace("exists_runnable_thread(", "exists_runnable_thread2(")
168+
.replace("eval(", "eval2(")
169+
.replace("init_model(", "init_model2(")
170+
.replace("stop_simulation(", "stop_simulation2(")
171+
.replace("start_simulation(", "start_simulation2(")
172+
.replace("reach_error2(", "reach_error(")
173+
.replace("update_channels(", "update_channels2(")
174+
.replace("fire_delta_events(", "fire_delta_events2(")
175+
.replace("reset_delta_events(", "reset_delta_events2(")
176+
.replace("activate_threads(", "activate_threads2(")
177+
.replace("fire_time_events(", "fire_time_events2(")
178+
.replace("reset_time_events(", "reset_time_events2(")
179+
)
180+
181+
182+
if __name__ == "__main__":
183+
parser = argparse.ArgumentParser()
184+
parser.add_argument(
185+
"--benchmark-dir", required=True, help="sv-benchmarks directory"
186+
)
187+
parser.add_argument(
188+
"--output-dir", required=True, help="output directory for created files"
189+
)
190+
191+
args = parser.parse_args()
192+
args.benchmark_dir = Path(args.benchmark_dir)
193+
args.output_dir = Path(args.output_dir)
194+
195+
create_combos(
196+
"c/eca-rers2012/Problem05_label4*.yml",
197+
"c/systemc/token_ring*.yml",
198+
output_dir=args.output_dir,
199+
)
200+
create_combos(
201+
"c/bitvector/gcd_*.yml",
202+
"c/floats-cdfpl/newton_*.yml",
203+
output_dir=args.output_dir,
204+
)
205+
create_combos(
206+
"c/seq-mthreaded/pals_lcr.*.yml",
207+
"c/eca-rers2012/Problem12_label0*.yml",
208+
output_dir=args.output_dir,
209+
)
210+
create_combos(
211+
"c/floats-cdfpl/square*.yml",
212+
"c/bitvector/soft_float_*.yml",
213+
output_dir=args.output_dir,
214+
)
215+
create_combos(
216+
"c/systemc/pc_sfifo*.yml",
217+
"c/systemc/token_ring*.yml",
218+
replacement1=_systemc_replacements1,
219+
replacement2=_systemc_replacements2,
220+
output_dir=args.output_dir,
221+
)

0 commit comments

Comments
 (0)