diff mbox series

test-runner: run prepare_environment with --start

Message ID 20220708190054.299224-1-prestwoj@gmail.com (mailing list archive)
State Accepted, archived
Headers show
Series test-runner: run prepare_environment with --start | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-alpine-ci-fetch success Fetch PR
prestwoj/iwd-ci-gitlint success GitLint
prestwoj/iwd-ci-fetch success Fetch PR
prestwoj/iwd-alpine-ci-makedistcheck success Make Distcheck
prestwoj/iwd-alpine-ci-incremental_build success Incremental build not run PASS
prestwoj/iwd-alpine-ci-build success Build - Configure
prestwoj/iwd-ci-makedistcheck success Make Distcheck
prestwoj/iwd-ci-incremental_build success Incremental build not run PASS
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-alpine-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-alpine-ci-makecheck success Make Check
prestwoj/iwd-ci-clang success clang PASS
prestwoj/iwd-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-ci-makecheck success Make Check
prestwoj/iwd-ci-testrunner success test-runner PASS

Commit Message

James Prestwood July 8, 2022, 7 p.m. UTC
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(-)

Comments

Denis Kenzior July 11, 2022, 4:11 p.m. UTC | #1
Hi James,

On 7/8/22 14:00, James Prestwood wrote:
> 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
diff mbox series

Patch

diff --git a/tools/run-tests b/tools/run-tests
index 565847df..8724877e 100755
--- a/tools/run-tests
+++ b/tools/run-tests
@@ -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()
diff --git a/tools/runner.py b/tools/runner.py
index d39b560f..cf904412 100644
--- a/tools/runner.py
+++ b/tools/runner.py
@@ -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