3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-22 14:49:24 +01:00

test-runner: remove concept of 'multi_test'

Though multi-test processes seemed like a good idea in terms of
efficiency, the additional code/special cases was not worth it
for the only two multi-test processes (dbus/haveged). Intead this
concept was removed completely and TestContext/Namespaces will
now start all processes for each individual test. This also is
fair to all tests as a previous failed test could end up bleeding
into future tests.
This commit is contained in:
James Prestwood 2021-02-25 14:00:56 -08:00 committed by Denis Kenzior
parent 80ff2fe140
commit 697b4ce82f

View File

@ -157,16 +157,13 @@ class Process:
''' '''
Start a process. If 'wait' is True the constructor will start Start a process. If 'wait' is True the constructor will start
the process and wait for it to exit. No PID is tracked in this the process and wait for it to exit. No PID is tracked in this
case. If 'multi_test' is True this indicates the process is case.
run over the entire test run and will not be killed after each
test exits.
''' '''
def __init__(self, args, wait=False, multi_test=False, env=None, ctx=None, check=False, def __init__(self, args, wait=False, env=None, ctx=None, check=False,
outfile=None, namespace=None, need_out=False): outfile=None, namespace=None, need_out=False):
self.args = args self.args = args
self.wait = wait self.wait = wait
self.name = args[0] self.name = args[0]
self.multi_test = multi_test
self.ret = None self.ret = None
self.ctx = ctx self.ctx = ctx
self.write_fds = [] self.write_fds = []
@ -311,9 +308,7 @@ class Process:
raise Exception("Timed out waiting for socket") raise Exception("Timed out waiting for socket")
def __str__(self): def __str__(self):
ret = str(self.args) + ' multi_test=%s' % str(self.multi_test) return str(self.args) + '\n'
ret += '\n'
return ret
class Interface: class Interface:
def __init__(self, name, config): def __init__(self, name, config):
@ -528,7 +523,6 @@ class Namespace:
dbus_address = None dbus_address = None
processes = [] processes = []
radios = [] radios = []
dbus_pid = None
def __init__(self, args, name, radios): def __init__(self, args, name, radios):
self.name = name self.name = name
@ -539,7 +533,7 @@ class Namespace:
for r in radios: for r in radios:
Process(['iw', 'phy', r.name, 'set', 'netns', 'name', name], wait=True) Process(['iw', 'phy', r.name, 'set', 'netns', 'name', name], wait=True)
self.dbus_pid = self.start_dbus(multi_test=False) self.start_dbus()
def reset(self): def reset(self):
self.radios = [] self.radios = []
@ -548,12 +542,11 @@ class Namespace:
if self.name == "root": if self.name == "root":
self._bus = dbus.bus.BusConnection(address_or_type=self.dbus_address) self._bus = dbus.bus.BusConnection(address_or_type=self.dbus_address)
for p in [p for p in self.processes if p.multi_test is False]: for p in self.processes:
print("Killing process %s" % p.name) print("Killing process %s" % p.name)
self.stop_process(p) p.kill()
if self.dbus_pid and not self.dbus_pid.multi_test: self.processes = []
os.remove(self.dbus_cfg)
def __del__(self): def __del__(self):
print("Removing namespace %s" % self.name) print("Removing namespace %s" % self.name)
@ -607,14 +600,12 @@ class Namespace:
f.write('</busconfig>\n') f.write('</busconfig>\n')
p = self.start_process(['dbus-daemon', '--config-file=%s' % self.dbus_cfg], p = self.start_process(['dbus-daemon', '--config-file=%s' % self.dbus_cfg],
wait=False, multi_test=multi_test) wait=False)
p.wait_for_socket(self.dbus_address.split('=')[1], wait=5) p.wait_for_socket(self.dbus_address.split('=')[1], wait=5)
self._bus = dbus.bus.BusConnection(address_or_type=self.dbus_address) self._bus = dbus.bus.BusConnection(address_or_type=self.dbus_address)
return p
def start_iwd(self, config_dir = '/tmp', storage_dir = '/tmp/iwd'): def start_iwd(self, config_dir = '/tmp', storage_dir = '/tmp/iwd'):
args = [] args = []
iwd_radios = ','.join([r.name for r in self.radios if r.use == 'iwd']) iwd_radios = ','.join([r.name for r in self.radios if r.use == 'iwd'])
@ -726,7 +717,7 @@ class TestContext(Namespace):
self.start_process(['dbus-monitor', '--address', self.dbus_address]) self.start_process(['dbus-monitor', '--address', self.dbus_address])
def start_haveged(self): def start_haveged(self):
self.start_process(['haveged'], multi_test=True) self.start_process(['haveged'])
def create_radios(self): def create_radios(self):
setup = self.hw_config['SETUP'] setup = self.hw_config['SETUP']
@ -1085,6 +1076,8 @@ def pre_test(ctx, test, copied):
subtests = pruned subtests = pruned
ctx.start_dbus()
ctx.start_haveged()
ctx.start_dbus_monitor() ctx.start_dbus_monitor()
ctx.start_radios() ctx.start_radios()
ctx.create_namespaces() ctx.create_namespaces()
@ -1177,9 +1170,6 @@ def print_results(results):
def run_auto_tests(ctx, args): def run_auto_tests(ctx, args):
tests = build_test_list(args) tests = build_test_list(args)
ctx.start_dbus(multi_test=True)
ctx.start_haveged()
# Copy autotests/misc/{certs,secrets,phonesim} so any test can refer to them # Copy autotests/misc/{certs,secrets,phonesim} so any test can refer to them
shutil.copytree(args.testhome + '/autotests/misc/certs', '/tmp/certs') shutil.copytree(args.testhome + '/autotests/misc/certs', '/tmp/certs')
shutil.copytree(args.testhome + '/autotests/misc/secrets', '/tmp/secrets') shutil.copytree(args.testhome + '/autotests/misc/secrets', '/tmp/secrets')