-
Notifications
You must be signed in to change notification settings - Fork 3
Integrate Rocq checker into CI #14
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
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/usr/bin/env python3 | ||
import sys | ||
import pathlib | ||
import argparse | ||
import subprocess | ||
|
||
HERE = pathlib.Path(__file__).parent | ||
EXAMPLES_ROOT = HERE.parent | ||
CASEMATE_ROOT = EXAMPLES_ROOT.parent | ||
CASEMATE_CHECK_ROCQ_ROOT = CASEMATE_ROOT / "src" / "casemate-check-rocq" | ||
|
||
EXAMPLES = ( | ||
subprocess.run( | ||
["make", "list-build-objs"], | ||
cwd=EXAMPLES_ROOT, | ||
capture_output=True, | ||
text=True, | ||
check=True, | ||
).stdout.strip().split() | ||
) | ||
|
||
|
||
def runmsg(prefix, s): | ||
print(f' {prefix:<8}\t\t\t{s}', file=sys.stderr) | ||
|
||
def check_expected(test_name): | ||
example_exe = EXAMPLES_ROOT / test_name | ||
out_path = (EXAMPLES_ROOT / "tests" / test_name).with_suffix(".log") | ||
|
||
runmsg("RUN", test_name) | ||
with open(out_path, "wb") as logf: | ||
subprocess.run( | ||
[str(example_exe)], | ||
cwd=EXAMPLES_ROOT, | ||
stdout=logf, | ||
check=False, | ||
) | ||
|
||
expected = (EXAMPLES_ROOT / "expected" / test_name).with_suffix(".log") | ||
runmsg("CHECK", test_name) | ||
subprocess.run( | ||
["python3", "./scripts/check_simulation.py", str(out_path), str(expected)], | ||
cwd=EXAMPLES_ROOT, | ||
check=True, | ||
) | ||
|
||
def check_rocq_trace(test_name): | ||
expected_log = (EXAMPLES_ROOT / "expected" / test_name).with_suffix(".log") | ||
|
||
runmsg("CHECK", test_name) | ||
|
||
expected_status = expected_log.read_text().strip().splitlines()[-1] | ||
expected_status = 121 if expected_status.startswith("!") else 0 | ||
|
||
cp = ( | ||
subprocess.run( | ||
["dune", "exec", "casemate", "--", str(expected_log)], | ||
cwd=CASEMATE_CHECK_ROCQ_ROOT, | ||
check=False, | ||
) | ||
) | ||
|
||
if cp.returncode != expected_status: | ||
raise ValueError(f"Fail check on {test_name}") | ||
|
||
|
||
def main(argv): | ||
args = parser.parse_args(argv) | ||
|
||
for example in EXAMPLES: | ||
expected_log = (EXAMPLES_ROOT / "expected" / example).with_suffix(".log") | ||
|
||
if expected_log.exists(): | ||
if args.rocq: | ||
check_rocq_trace(example) | ||
else: | ||
check_expected(example) | ||
|
||
|
||
parser = argparse.ArgumentParser() | ||
grp = parser.add_mutually_exclusive_group(required=True) | ||
grp.add_argument("--rocq", action="store_true", default=False) | ||
grp.add_argument("--examples", action="store_true", default=False) | ||
|
||
if __name__ == "__main__": | ||
sys.exit(main(sys.argv[1:])) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good for now, but maybe we can enhance the code later to check whether the error messages from the failing tests align with the expected errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, we are going to end up with multiple implementations (in-kernel runtime check, out-of-kernel-but-still-C checker and the rocq-extracted-to-ocaml checker) and want some way to check correspondence between them.
Perhaps (not in this PR) we should give all the violations some error codes, like linters do, e.g.:
E01 - BBM Vioaltion
E02 - Race on PTE
etc
Then we can check that it fails with the same code.