-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_all.py
More file actions
93 lines (88 loc) · 4.36 KB
/
Copy pathrun_all.py
File metadata and controls
93 lines (88 loc) · 4.36 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
"""Drive the Charon pass over all extraction units in the required order
(untrusted-input first, then small LOC, then low unsafe). Writes results.csv
incrementally. Extraction happens at CRATE granularity: the 80 rust/kernel
modules are one crate (per project decision) recorded as `kernel_crate`."""
import subprocess, os, sys, csv, time
ROOT = os.path.expanduser("~/kernel-rust-coverage-map")
RUN = os.path.join(ROOT, "tools", "run_unit.py")
RESULTS = os.path.join(ROOT, "results.csv")
# (unit, root_rel_or_x, src_under_linux) — 'x' root means single-file (auto)
# Ordered: untrusted-input crate-units first, then by ascending size/unsafe.
UNITS = [
# --- untrusted-input first ---
("nova_core", "nova_core.rs", "drivers/gpu/nova-core"),
("android_binder", "rust_binder_main.rs", "drivers/android/binder"),
("drm_tyr", "tyr.rs", "drivers/gpu/drm/tyr"),
("sample_rust_misc_device", "x", "samples/rust/rust_misc_device.rs"),
("drm_nova", "nova.rs", "drivers/gpu/drm/nova"),
("sample_rust_debugfs_scoped", "x", "samples/rust/rust_debugfs_scoped.rs"),
# kernel crate (one attempt; covers all 80 modules incl. untrusted uaccess/iov/
# miscdevice/configfs/debugfs/drm/str)
("kernel_crate", "lib.rs", "rust/kernel"),
# --- remaining, small first ---
("drm_panic_qr", "x", "drivers/gpu/drm/drm_panic_qr.rs"),
("net_phy_qt2025", "x", "drivers/net/phy/qt2025.rs"),
("net_phy_ax88796b", "x", "drivers/net/phy/ax88796b_rust.rs"),
("cpufreq_dt", "x", "drivers/cpufreq/rcpufreq_dt.rs"),
("pwm_th1520", "x", "drivers/pwm/pwm_th1520.rs"),
("block_rnull", "rnull.rs", "drivers/block/rnull"),
# samples
("sample_rust_minimal", "x", "samples/rust/rust_minimal.rs"),
("sample_rust_driver_faux", "x", "samples/rust/rust_driver_faux.rs"),
("sample_rust_driver_usb", "x", "samples/rust/rust_driver_usb.rs"),
("sample_rust_driver_i2c", "x", "samples/rust/rust_driver_i2c.rs"),
("sample_rust_soc", "x", "samples/rust/rust_soc.rs"),
("sample_rust_print_main", "x", "samples/rust/rust_print_main.rs"),
("sample_rust_dma", "x", "samples/rust/rust_dma.rs"),
("sample_rust_i2c_client", "x", "samples/rust/rust_i2c_client.rs"),
("sample_rust_driver_auxiliary", "x", "samples/rust/rust_driver_auxiliary.rs"),
("sample_rust_debugfs", "x", "samples/rust/rust_debugfs.rs"),
("sample_rust_configfs", "x", "samples/rust/rust_configfs.rs"),
("sample_rust_driver_pci", "x", "samples/rust/rust_driver_pci.rs"),
("sample_rust_driver_platform", "x", "samples/rust/rust_driver_platform.rs"),
# support crates
("rust_build_error", "x", "rust/build_error.rs"),
("rust_ffi", "x", "rust/ffi.rs"),
("rust_compiler_builtins", "x", "rust/compiler_builtins.rs"),
("pin_init", "src/lib.rs", "rust/pin-init"),
("rust_macros", "lib.rs", "rust/macros"),
("rust_uapi", "lib.rs", "rust/uapi"),
("rust_bindings", "lib.rs", "rust/bindings"),
# misc in-tree tests
("lib_find_bit_benchmark", "x", "lib/find_bit_benchmark_rust.rs"),
("mm_kasan_test", "x", "mm/kasan/kasan_test_rust.rs"),
]
HEADER = ["unit", "outcome", "first_error", "failure_category", "minutes_spent", "has_unions"]
def main():
only = sys.argv[1:] if len(sys.argv) > 1 else None
rows = []
if os.path.exists(RESULTS):
rows = list(csv.reader(open(RESULTS)))
if rows and rows[0] == HEADER:
rows = rows[1:]
done = {r[0] for r in rows}
n = 0
for unit, root, src in UNITS:
if only and unit not in only:
continue
if unit in done and not only:
continue
print(f"[{unit}] running...", flush=True)
p = subprocess.run([sys.executable, RUN, unit, root, src],
capture_output=True, text=True)
line = p.stdout.strip().splitlines()[-1] if p.stdout.strip() else f'{unit},FAIL,"harness error: {p.stderr.strip()[:100]}",other,0,no'
print(" ->", line, flush=True)
rows = [r for r in rows if r[0] != unit] + [next(csv.reader([line]))]
n += 1
# write incrementally
with open(RESULTS, "w", newline="") as f:
w = csv.writer(f)
w.writerow(HEADER)
w.writerows(rows)
if n % 10 == 0:
print(f" (checkpoint: {n} units)", flush=True)
print(f"done: {n} units processed")
if __name__ == "__main__":
main()