Skip to content

Commit 74dc542

Browse files
Stevengretothtamas28rv-auditor
authored
Allow --temp-dir option for test-prove (#77)
- Introduced a `--temp-dir <debug-dir-path>` option to save temporary files in a debug directory. - Enhanced the `test_specs` function to write proof results to a file in the temp directory. --------- Co-authored-by: Tamás Tóth <tothtamas28@users.noreply.github.com> Co-authored-by: devops <devops@runtimeverification.com>
1 parent 1e43e19 commit 74dc542

4 files changed

Lines changed: 26 additions & 12 deletions

File tree

package/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.58
1+
0.1.59

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "kriscv"
7-
version = "0.1.58"
7+
version = "0.1.59"
88
description = "K tooling for the RISC-V architecture"
99
authors = [
1010
"Runtime Verification, Inc. <contact@runtimeverification.com>",

src/tests/integration/test-data/specs/add-spec.k

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires "riscv-semantics/riscv.md"
33
module ADD-SPEC
44
imports RISCV
55

6-
claim [add]:
6+
claim [id]:
77
<instrs> (.K => #HALT) ~> #EXECUTE ... </instrs>
88
<regs>
99
1 |-> X

src/tests/integration/test_prove.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import pytest
77
from pyk.proof import ProofStatus
8+
from pyk.proof.show import APRProofShow
89

910
from kriscv.symtools import SymTools
1011

@@ -16,6 +17,7 @@
1617

1718

1819
SPEC_DIR: Final = TEST_DATA_DIR / 'specs'
20+
SPEC_TESTS: Final = list(SPEC_DIR.glob('*.k'))
1921

2022

2123
@dataclass
@@ -31,28 +33,40 @@ def __call__(self, file_name: str) -> Path:
3133

3234

3335
@pytest.fixture
34-
def load_spec(tmp_path: Path) -> SpecLoader:
35-
return SpecLoader(temp_dir=tmp_path)
36+
def load_spec(temp_dir: Path) -> SpecLoader:
37+
return SpecLoader(temp_dir=temp_dir)
3638

3739

3840
@pytest.fixture
39-
def symtools(tmp_path: Path) -> SymTools:
40-
return SymTools.default(proof_dir=tmp_path)
41+
def symtools(temp_dir: Path) -> SymTools:
42+
return SymTools.default(proof_dir=temp_dir, bug_report=temp_dir / 'bug-reports')
4143

4244

43-
def test_add(
45+
@pytest.mark.parametrize(
46+
'spec_file',
47+
SPEC_TESTS,
48+
ids=[str(test.relative_to(SPEC_DIR)) for test in SPEC_TESTS],
49+
)
50+
def test_specs(
4451
load_spec: SpecLoader,
4552
symtools: SymTools,
53+
temp_dir: Path,
54+
spec_file: Path,
4655
) -> None:
4756
# Given
48-
spec_file = load_spec('add-spec.k')
57+
spec_file = load_spec(spec_file.name)
4958

5059
# When
5160
proof = symtools.prove(
5261
spec_file=spec_file,
53-
spec_module='ADD-SPEC',
54-
claim_id='ADD-SPEC.add',
62+
spec_module=spec_file.stem.upper(),
63+
claim_id=f'{spec_file.stem.upper()}.id',
64+
max_depth=1000,
5565
)
5666

67+
proof_show_file = temp_dir / f'{spec_file.stem}-proof.txt'
68+
proof_show_lines = APRProofShow(symtools.kprove).show(proof, nodes=[node.id for node in proof.kcfg.nodes])
69+
proof_show_file.write_text('\n'.join(proof_show_lines))
70+
5771
# Then
58-
assert proof.status == ProofStatus.PASSED
72+
assert proof.status == ProofStatus.PASSED, f'Proof failed: {proof.failure_info}'

0 commit comments

Comments
 (0)