Wireless Daemon for Linux
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH 2/3] test-runner: allow hwsim in namespaces
Date: Thu,  4 May 2023 14:52:46 -0700	[thread overview]
Message-ID: <20230504215247.581443-2-prestwoj@gmail.com> (raw)
In-Reply-To: <20230504215247.581443-1-prestwoj@gmail.com>

Starts the hwsim daemon per-namespace rather than only in the
root namespace.
---
 tools/run-tests | 16 ++++++++--------
 tools/utils.py  | 13 ++++++++++++-
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/tools/run-tests b/tools/run-tests
index 32c09723..ef316666 100755
--- a/tools/run-tests
+++ b/tools/run-tests
@@ -319,6 +319,7 @@ class TestContext(Namespace):
 		self.namespaces = []
 		self._last_mem_available = 0
 		self._mem_chart = BarChart()
+		self.register_hwsim = False;
 
 	def start_dbus_monitor(self):
 		if not Process.is_verbose('dbus-monitor'):
@@ -329,18 +330,16 @@ class TestContext(Namespace):
 	def start_haveged(self):
 		self.start_process(['haveged', '-F'])
 
+	def start_hwsim(self):
+		self.register_hwsim = self.hw_config['SETUP'].get('hwsim_medium', 'no') in ['no', '0', 'false']
+
+		super().start_hwsim(self.register_hwsim)
+
 	def create_radios(self):
 		setup = self.hw_config['SETUP']
 		nradios = int(setup['num_radios'])
 		args = ['hwsim']
 
-		if self.hw_config['SETUP'].get('hwsim_medium', 'no') in ['no', '0', 'false']:
-			# register hwsim as medium
-			args.extend(['--no-register'])
-
-		proc = self.start_process(args)
-		proc.wait_for_service(self, 'net.connman.hwsim', 20)
-
 		for i in range(nradios):
 			name = 'rad%u' % i
 
@@ -524,7 +523,7 @@ class TestContext(Namespace):
 			# Remove radios from 'root' namespace
 			self.radios = list(set(self.radios) - set(radios))
 
-			self.namespaces.append(Namespace(self.args, key, radios))
+			self.namespaces.append(Namespace(self.args, key, radios, self.register_hwsim))
 
 	def get_namespace(self, ns):
 		for n in self.namespaces:
@@ -865,6 +864,7 @@ def pre_test(ctx, test, copied):
 	ctx.start_dbus()
 	ctx.start_haveged()
 	ctx.start_dbus_monitor()
+	ctx.start_hwsim()
 	ctx.start_radios()
 	ctx.create_namespaces()
 	ctx.start_hostapd()
diff --git a/tools/utils.py b/tools/utils.py
index a07c3183..d2e1c33b 100644
--- a/tools/utils.py
+++ b/tools/utils.py
@@ -320,7 +320,7 @@ busconfig.dtd\">
 '''
 
 class Namespace:
-	def __init__(self, args, name, radios):
+	def __init__(self, args, name, radios, hwsim_register=False):
 		self.dbus_address = None
 		self.name = name
 		self.radios = radios
@@ -331,6 +331,7 @@ class Namespace:
 			r.set_namespace(self)
 
 		self.start_dbus()
+		self.start_hwsim(register=hwsim_register)
 
 	def reset(self):
 		self._bus = None
@@ -458,6 +459,16 @@ class Namespace:
 
 		return proc
 
+	def start_hwsim(self, register=False):
+		args = ['hwsim']
+
+		if register:
+			# register hwsim as medium
+			args.extend(['--no-register'])
+
+		proc = self.start_process(args)
+		proc.wait_for_service(self, 'net.connman.hwsim', 20)
+
 	@staticmethod
 	def non_block_wait(func, timeout, *args, exception=True):
 		'''
-- 
2.25.1


  reply	other threads:[~2023-05-04 21:52 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-04 21:52 [PATCH 1/3] hwsim: remove 'optimization' sending to only known MACs James Prestwood
2023-05-04 21:52 ` James Prestwood [this message]
2023-05-04 21:52 ` [PATCH 3/3] test-runner: fix __str__ for namespace processes James Prestwood
2023-05-07 23:21 ` [PATCH 1/3] hwsim: remove 'optimization' sending to only known MACs Denis Kenzior
2023-05-08 13:43   ` James Prestwood
2023-05-08 18:05     ` Denis Kenzior
2023-05-08 18:55       ` James Prestwood
2023-05-08 19:00         ` Denis Kenzior
2023-05-08 19:03         ` James Prestwood
2023-05-08 19:01           ` Denis Kenzior
2023-06-21 21:05             ` James Prestwood
2023-06-27  2:31               ` Denis Kenzior
2023-06-27 15:15                 ` James Prestwood
2023-06-27 18:00                   ` Denis Kenzior
2023-06-27 18:56                     ` James Prestwood
2023-06-27 19:23                       ` Denis Kenzior
2023-06-27 20:09                     ` James Prestwood
2023-06-28 14:49                       ` Denis Kenzior
2023-06-28 15:33                         ` James Prestwood
2023-06-28 15:40                           ` Denis Kenzior
2023-06-28 16:14                             ` James Prestwood
2023-06-28 16:25                               ` Denis Kenzior
2023-06-28 16:47                                 ` James Prestwood
2023-06-28 16:57                                   ` Denis Kenzior
2023-06-28 17:22                                     ` James Prestwood
2023-06-28 23:19                               ` Andrew Zaborowski
2023-06-28 23:28                                 ` James Prestwood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230504215247.581443-2-prestwoj@gmail.com \
    --to=prestwoj@gmail.com \
    --cc=iwd@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox