-
Notifications
You must be signed in to change notification settings - Fork 0
/
experiment-pre.py
executable file
·64 lines (58 loc) · 1.9 KB
/
experiment-pre.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/python3
import os
import subprocess
CONFIG_DIR = "config"
ANALYSIS_SCRIPT = "../diffkemp-analysis/analyze.py"
DIFFKEMP_BINARY = "../diffkemp/bin/diffkemp"
RESULTS_DIFF_SCRIPT = "../diffkemp-analysis/diff-results.py"
RESULTS_DIR = os.path.join("results", "pre")
RESULTS_FILENAME = "results.yml"
DIFF_FILENAME = "diff.yml"
ALL_PATTERNS_RESULTS_DIR = "all-patterns"
DISABLED_PATTERNS = ["group-vars", "reordered-bin-ops"]
LIBRARIES = ["mbedtls-2", "mbedtls-3", "nettle-3", "sodium-1", "wolfssl-4"]
BUILTIN_PATTERNS = [
"struct-alignment",
"function-splits",
"numerical-macros",
"relocations",
"inverse-conditions",
]
for library in LIBRARIES:
config_filepath = os.path.join(CONFIG_DIR, f"{library}.yml")
all_pattern_results_dir = os.path.join(RESULTS_DIR, ALL_PATTERNS_RESULTS_DIR)
analysis_cmd = [
ANALYSIS_SCRIPT,
config_filepath,
"--diffkemp",
DIFFKEMP_BINARY,
"--disable-patterns",
",".join(DISABLED_PATTERNS),
"--output",
all_pattern_results_dir,
"--review-template"
]
subprocess.run(analysis_cmd)
for pattern in BUILTIN_PATTERNS:
results_dir = os.path.join(RESULTS_DIR, pattern)
disabled_patterns = DISABLED_PATTERNS + [pattern]
analysis_cmd = [
ANALYSIS_SCRIPT,
config_filepath,
"--diffkemp",
DIFFKEMP_BINARY,
"--disable-patterns",
",".join(disabled_patterns),
"--output",
results_dir,
]
subprocess.run(analysis_cmd)
diff_file = os.path.join(results_dir, library, DIFF_FILENAME)
diff_cmd = [
RESULTS_DIFF_SCRIPT,
os.path.join(all_pattern_results_dir, library, RESULTS_FILENAME),
os.path.join(results_dir, library, RESULTS_FILENAME),
"--output",
diff_file,
]
subprocess.run(diff_cmd)