feat: metaverif function

Co-Authored-By: Benjamin Lipp <blipp@rosenpass.eu>
This commit is contained in:
Anja Rabich
2025-07-01 17:37:38 +02:00
parent c259be76c8
commit d20bb137c9
2 changed files with 5 additions and 40 deletions

View File

@@ -15,10 +15,11 @@
* ~~click function intervention weirdness~~ * ~~click function intervention weirdness~~
* ~~why is everything red in the pretty output? (see line 96 in __init__.py)~~ * ~~why is everything red in the pretty output? (see line 96 in __init__.py)~~
* ~~awk RESULT flush in marzipan()~~ * ~~awk RESULT flush in marzipan()~~
* ~~move the whole metaverif function to Python~~
## Next Steps ## Next Steps
* move the whole metaverif function to Python
* move the whole analyze function to Python * move the whole analyze function to Python
* find the files * find the files
* start subprocesses in parallel * start subprocesses in parallel

View File

@@ -28,34 +28,7 @@ def exc_piped(argv, **kwargs):
@click.argument("file") @click.argument("file")
@click.argument("extra_args", required=False) @click.argument("extra_args", required=False)
def run_proverif(file, extra_args=[]): def run_proverif(file, extra_args=[]):
if extra_args is None: _run_proverif(file, extra_args)
extra_args = []
params = ["proverif", "-test", *extra_args, file]
print(params)
eprint(params)
process = exc_piped(params, stderr=pkgs.sys.subprocess.PIPE, stdout=pkgs.sys.subprocess.PIPE, text=True, bufsize=1)
try:
null, p = clean_warnings_init()
for line in process.stdout:
print(f"received a line: {line.strip()}")
# clean warnings
line = line.rstrip()
if not pkgs.re.match(r"^Warning: identifier \w+ rebound.$", line):
if p != null:
yield p
#print(p)
p = line
else:
p = null
if p != null:
yield p
#print(p)
except Exception as e:
print(f"An error occurred: {e}")
finally:
process.stdout.close()
process.wait()
def _run_proverif(file, extra_args=[]): def _run_proverif(file, extra_args=[]):
if extra_args is None: if extra_args is None:
@@ -92,13 +65,7 @@ def _run_proverif(file, extra_args=[]):
@click.argument("file") @click.argument("file")
@click.argument("cpp_prep") @click.argument("cpp_prep")
def cpp(file, cpp_prep): def cpp(file, cpp_prep):
file_path = pkgs.pathlib.Path(file) _cpp(file, cpp_prep)
dirname = file_path.parent
cwd = pkgs.pathlib.Path.cwd()
params = ["cpp", "-P", f"-I{cwd}/{dirname}", file, "-o", cpp_prep]
return exc(params, stderr=pkgs.sys.stderr)
def _cpp(file, cpp_prep): def _cpp(file, cpp_prep):
@@ -128,10 +95,7 @@ def parse_result_line():
@click.argument("cpp_prep") @click.argument("cpp_prep")
@click.argument("awk_prep") @click.argument("awk_prep")
def awk(cpp_prep, awk_prep): def awk(cpp_prep, awk_prep):
params = ["awk", "-f", "marzipan/marzipan.awk", cpp_prep] _awk(cpp_prep, awk_prep)
with open(awk_prep, 'w') as file:
exc(params, stderr=pkgs.sys.stderr, stdout=file)
file.write("\nprocess main")
def _awk(cpp_prep, awk_prep): def _awk(cpp_prep, awk_prep):
params = ["awk", "-f", "marzipan/marzipan.awk", cpp_prep] params = ["awk", "-f", "marzipan/marzipan.awk", cpp_prep]