Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt existing Ruby scripts to Python framework #17

Merged
merged 28 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
36c2600
Split the time and values in output file
healthypunk Mar 14, 2023
e1fad64
Added template for line summary as well as extraction class and line …
healthypunk Mar 23, 2023
8f31b0b
Changed line summary extraction method
healthypunk Mar 24, 2023
1bb6a9b
Added PrivPrecTool class with corresponding result class
healthypunk Mar 27, 2023
0f0ecc7
Temporary fixes
healthypunk Apr 3, 2023
c19f340
Temporary changes
healthypunk Apr 6, 2023
1a3d89b
Added PrivPrecTool run function and added template for PrivPrecResult
healthypunk Apr 7, 2023
25ba44c
Added a test file with some minor changes
healthypunk Apr 13, 2023
8020e89
Fixed output html
healthypunk Apr 17, 2023
23bc7ab
Fixed html and PrivPrecTool output as well as added changing of direc…
healthypunk Apr 17, 2023
961904a
Added ThreadSummary class as well as ApronPrecTool with result class …
healthypunk Apr 19, 2023
94b6661
Added AssertTypeSummary class with template and created a testfile
healthypunk Apr 21, 2023
6115b6d
Added update_bench_traces_rel_assert.py, update_bench_traces_rel_ratc…
healthypunk Apr 26, 2023
d0082df
Minor fixes
healthypunk May 2, 2023
f63f1ad
Added update_bench_concrat.py script
healthypunk May 10, 2023
b2b44e1
Merge pull request #1 from healthypunk/concrat
healthypunk Jun 20, 2023
07b2252
Update README.md
healthypunk Jun 20, 2023
4ef7ed3
Merge branch 'goblint:master' into master
healthypunk Jun 20, 2023
bd43104
Added yaml file generation for update_bench_traces_rel_yaml.py as wel…
healthypunk Mar 3, 2024
19ec7cc
Fixed update_bench_traces_rel_assert.py throwing an error
healthypunk Mar 14, 2024
1f93bb4
Created initial Incremental benchmark class and GoblintToolFromScratc…
healthypunk Mar 25, 2024
2e4406e
Fixed GoblintToolFromScratch and GoblintToolIncremental classes and m…
healthypunk Apr 1, 2024
0eb4f5c
Fixed GoblintToolFromScratch and GoblintToolIncremental and added cod…
healthypunk Apr 4, 2024
77320c7
Added ToolFactory class and load function to yamlindex.py.
healthypunk Apr 19, 2024
729ac8a
Changed update_bench_incremental.py to use yamlindex.py
healthypunk Apr 24, 2024
d92d246
Fixed update_bench_incremental.py to use yamlindex.py
healthypunk Apr 24, 2024
531a711
Fixed minor errors in update_bench_incremental.py and yamlindex.py
healthypunk May 6, 2024
6e373d5
Fixed minor errors in update_bench_traces_rel_assert.py and update_be…
healthypunk May 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gobexec/goblint/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class ConcratSummary(Result):
unsafe: int
uncalled: int

def __init__(self, safe: int, vulnerable: int, unsafe: int, uncalled: int):
def __init__(self, safe: int, vulnerable: int, unsafe: int, uncalled: int) -> None:
self.safe = safe
self.vulnerable = vulnerable
self.unsafe = unsafe
Expand Down
42 changes: 27 additions & 15 deletions gobexec/goblint/tool.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import asyncio
import tempfile
from typing import List
from typing import List, Optional

from gobexec.model.benchmark import Single
from gobexec.model.context import ExecutionContext, CompletedSubprocess
Expand All @@ -15,22 +15,26 @@ class GoblintTool(Tool[Single, CompletedSubprocess]):
program: str
args: List[str]
dump: str
validate: bool
validate: Optional["GoblintTool"]
assertion: Optional["GoblintTool"]

def __init__(self,
name: str = "Goblint",
program: str = "goblint",
args: List[str] = None,
dump: str = '',
validate: bool = False
validate: Optional["GoblintTool"] = None,
assertion: Optional["GoblintTool"] = None
) -> None:
self.name = name
self.program = program
self.args = args if args else []
self.dump = dump
self.validate = validate
self.assertion = assertion

# def run(self, benchmark: Single) -> str:

# def run(self, benchmark: Single) -> str:
# bench = Path("/home/simmo/dev/goblint/sv-comp/goblint-bench")
# args = ["/home/simmo/dev/goblint/sv-comp/goblint/goblint"] + self.args + benchmark.tool_data.get(ARGS_TOOL_KEY, []) + [str(bench / file) for file in benchmark.files]
# print(args)
Expand All @@ -51,22 +55,29 @@ async def run_async(self, ec: ExecutionContext[Single], benchmark: Single) -> Co
["--set", "goblint-dir", goblint_dir.absolute()] + \
self.args + \
benchmark.tool_data.get(ARGS_TOOL_KEY, []) + \
[str(file) for file in benchmark.files]
[str(file) for file in benchmark.files] if self.assertion is None else [ec.get_tool_data_path(self.assertion).absolute() / "out.c"]
if self.dump == "priv":
args += ["--set", "exp.priv-prec-dump", data_path.absolute() / "priv.txt"]
elif self.dump == "apron":
args += ["--set", "exp.relation.prec-dump", data_path.absolute() / "apron.txt"]

if self.validate is True:
args += ["--set", "witness.yaml.validate", str(benchmark.files[0].parent / (str(benchmark.files[0].name)[:-2] + "_traces_rel.yml"))]
elif self.dump == "witness":
args += ["--set", "witness.yaml.path", data_path.absolute() / "witness.yaml"]
elif self.dump == "assert":
args += ["--set", "trans.output",data_path.absolute() / "out.c"]
if self.validate is not None:
await ec.get_tool_result(self.validate)
args += ["--set", "witness.yaml.validate",
ec.get_tool_data_path(self.validate).absolute() / "witness.yaml"]
if self.assertion is not None:
await ec.get_tool_result(self.assertion)

cp = await ec.subprocess_exec(
args[0],
*args[1:],
# capture_output=True,
stdout=out_file,
stderr=asyncio.subprocess.STDOUT,
cwd = benchmark.files[0].parent
cwd=benchmark.files[0].parent
)
out_file.seek(0)
cp.stdout = out_file.read() # currently for extractors
Expand All @@ -92,7 +103,7 @@ async def run_async(self, ec: ExecutionContext[Single], benchmark: Single) -> Pr
for tool in self.args:
await ec.get_tool_result(tool)
with(path / 'priv_compare_out.txt').open("w") as out_file:
args = [self.program] + [str(ec.get_tool_data_path(tool)/"priv.txt") for tool in self.args]
args = [self.program] + [str(ec.get_tool_data_path(tool) / "priv.txt") for tool in self.args]
await ec.subprocess_exec(
args[0],
stdout=out_file,
Expand All @@ -101,7 +112,8 @@ async def run_async(self, ec: ExecutionContext[Single], benchmark: Single) -> Pr
)
return PrivPrecResult(str(path / 'out.txt'))

class ApronPrecTool(Tool[Single,ApronPrecResult]):

class ApronPrecTool(Tool[Single, ApronPrecResult]):
name: str
program: str
args: List[GoblintTool]
Expand All @@ -120,11 +132,11 @@ async def run_async(self, ec: ExecutionContext[Single], benchmark: Single) -> Ap
for tool in self.args:
await ec.get_tool_result(tool)
with (path / 'out.txt').open('w') as out_file:
args = [self.program] + [str(ec.get_tool_data_path(tool).absolute()/'apron.txt') for tool in self.args]
args = [self.program] + [str(ec.get_tool_data_path(tool).absolute() / 'apron.txt') for tool in self.args]
await ec.subprocess_exec(
args[0],
*args[1:],
stdout = out_file,
stderr = asyncio.subprocess.STDOUT,
stdout=out_file,
stderr=asyncio.subprocess.STDOUT,
)
return ApronPrecResult(str(path/'out.txt'))
return ApronPrecResult(str(path / 'out.txt'))
2 changes: 1 addition & 1 deletion gobexec/output/html/templates/progress.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{% block title %}Results ({{ progress.done }}/{{ progress.total }}){% endblock %}
{% block head %}
{{ super() }}
<meta http-equiv="refresh" content="1">
{#<meta http-equiv="refresh" content="1">#}
{% endblock %}
{% block body %}
<p>
Expand Down
12 changes: 10 additions & 2 deletions update_bench_traces_rel_assert.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@
from gobexec.model.tools import ExtractTool
from gobexec.output.renderer import FileRenderer, ConsoleRenderer, MultiRenderer

goblint_assert = GoblintTool(
name="goblint_assert",
program=str(Path("../analyzer/goblint").absolute()),
args=["-v", "--conf", str(Path("../analyzer/conf/traces-rel.json").absolute()), "--enable", "dbg.debug","--set", "trans.activated[+]", "assert"],
sim642 marked this conversation as resolved.
Show resolved Hide resolved
dump = "assert"
)

def index_tool_factory(name, args):
goblint = GoblintTool(
name=name,
program=str(Path("../analyzer/goblint").absolute()),
args=["-v", "--conf", str(Path("../analyzer/conf/traces-rel.json").absolute()), "--enable", "dbg.debug"] + args,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the assertion transformation now outputs SV-COMP things with __VERIFIER_*, this should also have --enable ana.sv-comp.functions I think.

dump= 'apron'
dump= 'apron',
assertion = goblint_assert
)

return ExtractTool(
Expand All @@ -25,7 +32,8 @@ def index_tool_factory(name, args):

)

matrix = txtindex.load(Path("../bench/index/traces-rel-assert.txt").absolute(),index_tool_factory)
matrix = txtindex.load(Path("../bench/index/traces-rel-yaml.txt").absolute(),index_tool_factory)
matrix.tools.insert(0,ExtractTool(goblint_assert))
html_renderer = FileRenderer(Path("out.html"))
console_renderer = ConsoleRenderer()
renderer = MultiRenderer([html_renderer, console_renderer])
Expand Down
19 changes: 15 additions & 4 deletions update_bench_traces_rel_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,23 @@
from gobexec.model.tools import ExtractTool
from gobexec.output.renderer import FileRenderer, ConsoleRenderer, MultiRenderer

goblint_witness = GoblintTool(
name="witness_gen",
program=str(Path("../analyzer/goblint").absolute()),
args=["--conf", str(Path("../analyzer/conf/traces-rel.json").absolute()), "--enable", "dbg.debug", "--enable",
"witness.yaml.enabled"],
sim642 marked this conversation as resolved.
Show resolved Hide resolved
dump='witness'

)


def index_tool_factory(name, args):
goblint = GoblintTool(
name=name,
program=str(Path("../analyzer/goblint").absolute()),
args=["--conf", str(Path("../analyzer/conf/traces-rel.json").absolute()), "--enable", "dbg.debug"] + args,
dump= 'apron',
validate= True
dump='apron',
validate= goblint_witness
)

return ExtractTool(
Expand All @@ -26,9 +35,11 @@ def index_tool_factory(name, args):

)

matrix = txtindex.load(Path("../bench/index/traces-rel-yaml.txt").absolute(),index_tool_factory)

matrix = txtindex.load(Path("../bench/index/traces-rel-yaml.txt").absolute(), index_tool_factory)
matrix.tools.insert(0,ExtractTool(goblint_witness))
html_renderer = FileRenderer(Path("out.html"))
console_renderer = ConsoleRenderer()
renderer = MultiRenderer([html_renderer, console_renderer])

gobexec.main.run(matrix, renderer)
gobexec.main.run(matrix, renderer)