-
Notifications
You must be signed in to change notification settings - Fork 0
/
experiment-post.py
executable file
·65 lines (59 loc) · 2.07 KB
/
experiment-post.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
65
#!/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", "post")
RESULTS_FILENAME = "results.yml"
DIFF_FILENAME = "diff.yml"
ALL_PATTERNS_RESULTS_DIR = "all-patterns"
CUSTOM_PATTERNS_CONFIG_FILENAME = "config.yml"
CUSTOM_PATTERNS_DIR = "custom-patterns"
LIBRARIES = ["mbedtls-2", "mbedtls-3", "nettle-3", "sodium-1", "wolfssl-4", "curl-7"]
NEW_PATTERNS = [
"group-vars",
"reordered-bin-ops",
]
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)
custom_pattern_config_path = os.path.join(
CUSTOM_PATTERNS_DIR, library, CUSTOM_PATTERNS_CONFIG_FILENAME
)
analysis_cmd = [
ANALYSIS_SCRIPT,
config_filepath,
"--diffkemp",
DIFFKEMP_BINARY,
"--output",
all_pattern_results_dir,
]
if os.path.isfile(custom_pattern_config_path):
analysis_cmd += ["--custom-patterns", custom_pattern_config_path]
subprocess.run(analysis_cmd)
for pattern in NEW_PATTERNS:
results_dir = os.path.join(RESULTS_DIR, pattern)
analysis_cmd = [
ANALYSIS_SCRIPT,
config_filepath,
"--diffkemp",
DIFFKEMP_BINARY,
"--disable-patterns",
pattern,
"--output",
results_dir,
]
if os.path.isfile(custom_pattern_config_path):
analysis_cmd += ["--custom-patterns", custom_pattern_config_path]
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)