mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-22 14:49:24 +01:00
test-runner: remove special case for "root" namespace
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.
This commit is contained in:
parent
9d045fae0e
commit
7123f47f84
@ -301,15 +301,15 @@ class Hwsim(iwd.AsyncOpAbstract):
|
|||||||
_instances = WeakValueDictionary()
|
_instances = WeakValueDictionary()
|
||||||
|
|
||||||
def __new__(cls, namespace=ctx):
|
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 = object.__new__(cls)
|
||||||
obj._initialized = False
|
obj._initialized = False
|
||||||
|
|
||||||
cls._instances[name] = obj
|
cls._instances[key] = obj
|
||||||
|
|
||||||
return cls._instances[name]
|
return cls._instances[key]
|
||||||
|
|
||||||
def __init__(self, namespace=ctx):
|
def __init__(self, namespace=ctx):
|
||||||
if self._initialized:
|
if self._initialized:
|
||||||
|
@ -1053,7 +1053,7 @@ class IWD(AsyncOpAbstract):
|
|||||||
# reference so that __del__ gets called when it's released. This is only
|
# 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
|
# done for the root namespace in order to allow testutil to function
|
||||||
# correctly in non-namespace tests.
|
# correctly in non-namespace tests.
|
||||||
if self.namespace.name == "root":
|
if self.namespace.name is None:
|
||||||
IWD._default_instance = weakref.ref(self)
|
IWD._default_instance = weakref.ref(self)
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
|
@ -599,12 +599,6 @@ class Namespace:
|
|||||||
return self._bus
|
return self._bus
|
||||||
|
|
||||||
def start_process(self, args, env=None, **kwargs):
|
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:
|
if not env:
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
|
|
||||||
@ -612,7 +606,7 @@ class Namespace:
|
|||||||
# In case this process needs DBus...
|
# In case this process needs DBus...
|
||||||
env['DBUS_SYSTEM_BUS_ADDRESS'] = self.dbus_address
|
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):
|
if not kwargs.get('wait', False):
|
||||||
self.processes.append(p)
|
self.processes.append(p)
|
||||||
@ -791,7 +785,7 @@ class TestContext(Namespace):
|
|||||||
such as processes, radios, interfaces and test results.
|
such as processes, radios, interfaces and test results.
|
||||||
'''
|
'''
|
||||||
def __init__(self, args):
|
def __init__(self, args):
|
||||||
self.name = "root"
|
self.name = None
|
||||||
self.processes = []
|
self.processes = []
|
||||||
self.args = args
|
self.args = args
|
||||||
self.hw_config = None
|
self.hw_config = None
|
||||||
|
Loading…
Reference in New Issue
Block a user