Skip to content

Added testing harness for proofs from rust input#542

Merged
ehildenb merged 9 commits into
masterfrom
dc/rust2proof
Apr 30, 2025
Merged

Added testing harness for proofs from rust input#542
ehildenb merged 9 commits into
masterfrom
dc/rust2proof

Conversation

@dkcumming
Copy link
Copy Markdown
Collaborator

@dkcumming dkcumming commented Apr 29, 2025

This PR introduces a new testing harness that for running rust proofs. In particular we:

  • Introduced a new python utility cargo_get_smir_json that runs Stable MIR JSON through cargo on a given rust file (all very hardcoded right now)
  • Created a test directory tests/integration/data/prove-rs of rust programs to prove do not end in error state or break assertions
  • Created a testing harness test_prove_rs to generate a claims for the test rust files and then prove those claims

Two tests are currently added, one that expects a pass, one that expects a fail and both work. I also tested putting incorrect values in there and they did fail as expected.

NEXT STEPS

  • Refactor the test into it's own method which the test and gen-spec use
  • Debug the failing sub and div proofs

@dkcumming dkcumming self-assigned this Apr 29, 2025
@ehildenb ehildenb force-pushed the dc/rust2proof branch 2 times, most recently from cd4e14e to cb58c32 Compare April 30, 2025 00:50
ehildenb added a commit that referenced this pull request Apr 30, 2025
As part of
#542, we
noticed that the `Dockerfile` does not install Rust, and we need it for
integration tests run there. This PR makes sure `rustc` and `cargo` are
available to run in the docker image for CI:

- The `rustup` install step is moved to inside the docker image.
- The steps for building KMir in the tests "Integration with
stable-mir-json" are all moved to being in the docker image.

---------

Co-authored-by: devops <devops@runtimeverification.com>
@dkcumming dkcumming requested review from gtrepta and jberthold April 30, 2025 02:05
Comment on lines +97 to +100
def cargo_get_smir_json(rs_file: Path) -> dict[str, Any]:
smir_json_result = SMIR_JSON_DIR / rs_file.with_suffix('.smir.json').name
run_process_2(['cargo', 'run', '--', '-Zno-codegen', str(rs_file)], cwd=SMIR_JSON_DIR)
json_smir = json.loads(smir_json_result.read_text())
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Remark: This does not actually have to use cargo, it is a single crate because it starts from a single Rust file.
We don't have linking for multi-crate programs atm, but let's still use cargo here (recompilation might become a bit tricky, though)

Copy link
Copy Markdown
Collaborator

@jberthold jberthold left a comment

Choose a reason for hiding this comment

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

As discussed, let's merge this and follow up making it a command.

@ehildenb ehildenb merged commit e322c01 into master Apr 30, 2025
6 checks passed
@ehildenb ehildenb deleted the dc/rust2proof branch April 30, 2025 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants