Skip to content

Commit

Permalink
update x.py
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuyutian57 committed Oct 14, 2024
1 parent f76729c commit 4893211
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ We also provide a simple script `x.py`. We can easily to run SELO on a single fi
```sh
./x.py --run ./benchmark/tests/case_1.c
```
Mor details can be found by `./x.py --help`
Output of SELO will be stored in `./output/t.log`. More details can be found by `./x.py --help`

### TODO
Adjust the script later.
31 changes: 14 additions & 17 deletions x.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@


def compile():
os.system(f"cd {selo_build } && cmake --build .")
os.system(f"cd {selo_build} && cmake --build .")

def help():
os.system(f"{selo} -h")

cmds = {
"--compile" : ('',"Compile esbmc"),
"--run" : ("file extra_args","Only test a single file 'file'"),
Expand All @@ -35,10 +33,11 @@ def help():
args = {
"--esbmc" : "Disable SLHV and use default esbmc with solver Z3",
"--debug" : "Output debug info of SLHV",
"--std-out" : "Output info in std::out"
"--std-out" : "Output info in std::out",
"--vcc" : "Save VCC in output",
}

print("Commands for x.py:")
print("Args for x.py:")
for cmd in cmds.items():
cmdline = [cmd[0] + ' ' + cmd[1][0], cmd[1][1]]
print(" {:<35} {:<50}".format(*cmdline))
Expand All @@ -58,8 +57,6 @@ def collect_one_assert(info, aht):
res["Line"] = location[4]
res["Column"] = location[6]



# Property
prt = info[2].split(" ")
res["Property"] = prt[1]
Expand Down Expand Up @@ -112,24 +109,23 @@ def run_on(cprog, extra_args):
cprog_name = os.path.basename(cprog)
print(f"Verifying program: {cprog_name}")

# TODO: add more extra args
args = [
selo,
cprog,
"--no-library",
"--force-malloc-success",
"--memory-leak-check",
"--result-only",
"--show-vcc",
"--output",
vcc_log,
"--multi-property",
]

if "--esbmc" in extra_args:
args.append("--z3")
else:
args.append("--z3-slhv")

if "--vcc" in extra_args:
args += ["--show-vcc", "--output", vcc_log]

if "--debug" in extra_args:
args.append("--verbosity SLHV:8")
Expand All @@ -151,6 +147,11 @@ def run_on(cprog, extra_args):
return result

def collect_results(cprog):
if not os.path.exists(log_root):
os.mkdir(log_root)
if not os.path.exists(vcc_log):
os.mkdir(vcc_root)

cprog_name = cprog.split('.')[0]

log_file = cprog_name + "_log.log"
Expand Down Expand Up @@ -320,7 +321,7 @@ def run_expriment_on(benchmark_root, extra_args):
results = {}
for cprog in cprogs:
cprog_path = os.path.join(benchmark_root, cprog)
results[cprog] = run_on(cprog_path, extra_args)
results[cprog] = run_on(cprog_path, extra_args + ["--vcc"])
collect_results(cprog)

generate_csv(results)
Expand All @@ -330,14 +331,10 @@ def run_expriment_on(benchmark_root, extra_args):
if __name__ == '__main__':
if not os.path.exists(output_root):
os.mkdir(output_root)
if not os.path.exists(log_root):
os.mkdir(log_root)
if not os.path.exists(vcc_log):
os.mkdir(vcc_root)

if "--esbmc" in sys.argv:
csv_file = os.path.join(output_root, "results_esbmc.csv")

if sys.argv[1] == "--compile":
compile()
elif sys.argv[1] == "--run":
Expand Down

0 comments on commit 4893211

Please sign in to comment.