-
Notifications
You must be signed in to change notification settings - Fork 1
/
.run_cheri_qemu_and_test.py
34 lines (26 loc) · 1.25 KB
/
.run_cheri_qemu_and_test.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
#!/usr/bin/env python3
# Adapted from
# https://github.com/capablevms/cheri-examples/blob/master/tests/run_cheri_examples.py
import argparse
import importlib.util
import os
import subprocess
import sys
from pathlib import Path
# Emulate `sys.path` from path of module `run_tests_common` (found via
# environment variable `PYTHONPATH`), as required by the CHERI testing
# infrastructure which we are using to simplify booting a QEMU instance
test_scripts_dir = str(Path(importlib.util.find_spec("run_tests_common").origin).parent.absolute())
sys.path = sys.path[sys.path.index(test_scripts_dir):]
from run_tests_common import boot_cheribsd, run_tests_main
def run_tests(qemu: boot_cheribsd.QemuCheriBSDInstance, args: argparse.Namespace) -> bool:
if args.sysroot_dir is not None:
boot_cheribsd.set_ld_library_path_with_sysroot(qemu)
boot_cheribsd.info("Running tests for cheri-morello-compartmentalisation")
# Run command on host to test the executed client
os.chdir(f"{args.build_dir}/build")
subprocess.run(["/usr/bin/ctest", "-V"], check=True)
return True
if __name__ == '__main__':
# This call has the side-effect of booting a QEMU instance
run_tests_main(test_function=run_tests, need_ssh=True, should_mount_builddir=False)