commit b5df2e27be7b9fd3e1fa53e6fd796c44a0706091
parent 2894f2e3ebe783ceb9993c4e883ed4f67f976228
Author: James Prestwood <prestwoj@gmail.com>
Date: Thu, 31 Mar 2022 16:16:31 -0700
test-runner: add initial UmlRunner implementation
This allows test-runner to run inside a UML binary which has some
advantages, specifically time-travel/infinite CPU speed. This should
fix any scheduler related failures we have on slower systems.
Currently this runner does not suppor the same features as the Qemu
runner, specifically:
- No hardware passthrough
- No logging/monitor (UML -> host mounting isn't implemented yet)
Diffstat:
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/tools/runner.py b/tools/runner.py
@@ -213,7 +213,9 @@ class Runner:
else:
args.runner = 'qemu'
- if args.runner == 'qemu':
+ if args.runner == 'uml':
+ return UmlRunner(args)
+ elif args.runner == 'qemu':
return QemuRunner(args)
else:
raise Exception("Unknown runner %s" % args.runner)
@@ -483,3 +485,29 @@ class QemuRunner(RunnerAbstract):
# gracefully.
#
libc.reboot(RB_AUTOBOOT)
+
+class UmlRunner(RunnerAbstract):
+ name = "UML Runner"
+
+ def __init__(self, args):
+ super().__init__(args)
+
+ if len(sys.argv) <= 1:
+ return
+
+ if not which(args.kernel):
+ raise Exception('Cannot locate UML binary %s' % args.kernel)
+
+ kern_log = "ignore_loglevel" if "kernel" in args.verbose else "quiet"
+
+ cmd = [args.kernel, 'rootfstype=hostfs', 'ro', 'mem=256M', 'mac80211_hwsim.radios=0',
+ 'time-travel=inf-cpu', 'eth0=mcast', 'eth1=mcast',
+ '%s '% kern_log, 'init=%s' % args.start]
+ cmd.extend(args.to_cmd().split(' '))
+
+ self.cmdline = cmd
+
+ def prepare_environment(self):
+ self._prepare_mounts()
+
+ super().prepare_environment()