Skip to contentSkip to conversation

test-runner: run prepare_environment with --start

PATCH Applied James Prestwood 2 participants 2 messages Jul 8, 2022 – Jul 11, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test-runner: run prepare_environment with --start

The --start option was directly passed to the kernel init parameter, preventing any environment setup from happening.

Intead always use 'run-tests' as the init process but detect --start and execute that binary/script once inside the environment.

---
 tools/run-tests |  7 ++++++-
 tools/runner.py | 24 ++++++++++++++----------
 2 files changed, 20 insertions(+), 11 deletions(-)
tools/run-tests +6 -1
index 565847df..8724877e 100755
@@ -1011,5 +1011,10 @@ runner = Runner()
 
 atexit.register(exit_vm)
 runner.prepare_environment()
-run_tests(runner.args)
+
+if runner.args.start:
+	os.system(runner.args.start)
+else:
+	run_tests(runner.args)
+
 runner.cleanup_environment()
tools/runner.py +14 -10
index d39b560f..cf904412 100644
@@ -197,14 +197,6 @@ class Runner:
 			else:
 				args.testhome = os.getcwd()
 
-		if args.start is None:
-			if os.path.exists('run-tests'):
-				args.start = os.path.abspath('run-tests')
-			elif os.path.exists('tools/run-tests'):
-				args.start = os.path.abspath('tools/run-tests')
-			else:
-				raise Exception("Cannot locate run-tests binary")
-
 		# If no runner is specified but we have a kernel image assume
 		# if the kernel is executable its UML, otherwise qemu
 		if not args.runner:
@@ -231,6 +223,16 @@ class RunnerAbstract:
 	def __init__(self, args):
 		self.args = args
 
+		if len(sys.argv) <= 1:
+			return
+
+		if os.path.exists('run-tests'):
+			self.init = os.path.abspath('run-tests')
+		elif os.path.exists('tools/run-tests'):
+			self.init = os.path.abspath('tools/run-tests')
+		else:
+			raise Exception("Cannot locate run-tests binary")
+
 	def start(self):
 		print("Starting %s" % self.name)
 		os.execlpe(self.cmdline[0], *self.cmdline, self.env)
@@ -279,6 +281,8 @@ class RunnerAbstract:
 
 		fcntl.ioctl(STDIN_FILENO, TIOCSTTY, 1)
 
+		os.system('ip link set dev lo up')
+
 	def cleanup_environment(self):
 		rmtree('/tmp/iwd')
 		rmtree('/tmp/certs')
@@ -413,7 +417,7 @@ class QemuRunner(RunnerAbstract):
 				rootflags=trans=virtio \
 				acpi=off pci=noacpi %s ro \
 				mac80211_hwsim.radios=0 init=%s %s' %
-						(kern_log, args.start, args.to_cmd()),
+						(kern_log, self.init, args.to_cmd()),
 		]
 
 		# Add two ethernet devices for testing EAD
@@ -516,7 +520,7 @@ class UmlRunner(RunnerAbstract):
 
 		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]
+				'%s' % kern_log, 'init=%s' % self.init]
 		cmd.extend(args.to_cmd().split(' '))
 
 		self.cmdline = cmd
Signature · 1 line
2.34.1
#1 lore raw

Hi James,

Quoted 9 lines · James Prestwood

The --start option was directly passed to the kernel init parameter, preventing any environment setup from happening.

Intead always use 'run-tests' as the init process but detect --start and execute that binary/script once inside the environment.

---
  tools/run-tests |  7 ++++++-
  tools/runner.py | 24 ++++++++++++++----------
  2 files changed, 20 insertions(+), 11 deletions(-)

Applied, thanks.

Regards,
-Denis