iwd.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.01.org
Subject: [PATCH 1/6] test-runner: remove special case for "root" namespace
Date: Tue, 07 Sep 2021 09:54:34 -0700	[thread overview]
Message-ID: <20210907165439.9913-1-prestwoj@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2827 bytes --]

This was a placeholder at one point but modules grew to depend on it
being a string. Fix these dependencies and set the root namespace
name to None so there is no more special case needed to handle both
a named namespace and the original 'root' namespace.
---
 autotests/util/hwsim.py |  8 ++++----
 autotests/util/iwd.py   |  2 +-
 tools/test-runner       | 10 ++--------
 3 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/autotests/util/hwsim.py b/autotests/util/hwsim.py
index cc62495c..26092379 100755
--- a/autotests/util/hwsim.py
+++ b/autotests/util/hwsim.py
@@ -301,15 +301,15 @@ class Hwsim(iwd.AsyncOpAbstract):
     _instances = WeakValueDictionary()
 
     def __new__(cls, namespace=ctx):
-        name = namespace.name
+        key = id(namespace)
 
-        if name not in cls._instances.keys():
+        if key not in cls._instances.keys():
             obj = object.__new__(cls)
             obj._initialized = False
 
-            cls._instances[name] = obj
+            cls._instances[key] = obj
 
-        return cls._instances[name]
+        return cls._instances[key]
 
     def __init__(self, namespace=ctx):
         if self._initialized:
diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py
index 730659ac..63b526fd 100755
--- a/autotests/util/iwd.py
+++ b/autotests/util/iwd.py
@@ -1053,7 +1053,7 @@ class IWD(AsyncOpAbstract):
         # reference so that __del__ gets called when it's released. This is only
         # done for the root namespace in order to allow testutil to function
         # correctly in non-namespace tests.
-        if self.namespace.name == "root":
+        if self.namespace.name is None:
             IWD._default_instance = weakref.ref(self)
 
     def __del__(self):
diff --git a/tools/test-runner b/tools/test-runner
index 9e4d0780..210e4f5f 100755
--- a/tools/test-runner
+++ b/tools/test-runner
@@ -599,12 +599,6 @@ class Namespace:
 		return self._bus
 
 	def start_process(self, args, env=None, **kwargs):
-		# Special case for 'root' namespace (aka TestContext)
-		if self.name == "root":
-			ns = None
-		else:
-			ns = self.name
-
 		if not env:
 			env = os.environ.copy()
 
@@ -612,7 +606,7 @@ class Namespace:
 			# In case this process needs DBus...
 			env['DBUS_SYSTEM_BUS_ADDRESS'] = self.dbus_address
 
-		p = Process(args, namespace=ns, env=env, **kwargs)
+		p = Process(args, namespace=self.name, env=env, **kwargs)
 
 		if not kwargs.get('wait', False):
 			self.processes.append(p)
@@ -791,7 +785,7 @@ class TestContext(Namespace):
 		such as processes, radios, interfaces and test results.
 	'''
 	def __init__(self, args):
-		self.name = "root"
+		self.name = None
 		self.processes = []
 		self.args = args
 		self.hw_config = None
-- 
2.31.1

             reply	other threads:[~2021-09-07 16:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-07 16:54 James Prestwood [this message]
2021-09-07 16:54 ` [PATCH 2/6] test-runner: don't use start_process for transient processes James Prestwood
2021-09-07 16:54 ` [PATCH 3/6] test-runner: fix process cleanup James Prestwood
2021-09-07 16:54 ` [PATCH 4/6] test-runner: use Process to start hostapd James Prestwood
2021-09-07 16:54 ` [PATCH 5/6] test-runner: write out separators in log files James Prestwood
2021-09-07 16:54 ` [PATCH 6/6] test-runner: move process tracking out of Namespace James Prestwood
2021-09-07 17:46 ` [PATCH 1/6] test-runner: remove special case for "root" namespace Denis Kenzior

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=20210907165439.9913-1-prestwoj@gmail.com \
    --to=prestwoj@gmail.com \
    --cc=iwd@lists.01.org \
    /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;
as well as URLs for NNTP newsgroup(s).