Skip to contentSkip to conversation

auto-t: testEAD: stop ead when test finishes

PATCH In review James Prestwood 2 participants 18 messages Feb 25, 2021 – Feb 26, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/17 auto-t: testEAD: stop ead when test finishes

---
 autotests/testEAD/connection_test.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
autotests/testEAD/connection_test.py +5 -1
index bdf242b6..7f23f0d6 100644
@@ -3,6 +3,7 @@
 import unittest
 import sys
 import os
+import shutil
 
 sys.path.append('../util')
 from iwd import IWD
@@ -14,7 +15,7 @@ class Test(unittest.TestCase):
     def test_connection_success(self):
         env = os.environ.copy()
         env['STATE_DIRECTORY'] = '/tmp/ead'
-        ctx.start_process(['ead', '-i', 'eth1', '-d'], env=env)
+        p = ctx.start_process(['ead', '-i', 'eth1', '-d'], env=env)
 
         ead = EAD()
 
@@ -26,6 +27,7 @@ class Test(unittest.TestCase):
         condition = 'obj.authenticated == True'
         ead.wait_for_object_condition(adapter, condition)
 
+        ctx.stop_process(p)
     @classmethod
     def setUpClass(cls):
         os.mkdir('/tmp/ead')
@@ -36,5 +38,7 @@ class Test(unittest.TestCase):
     def tearDownClass(cls):
         IWD.clear_storage(storage_dir='/tmp/ead')
 
+        shutil.rmtree('/tmp/ead')
+
 if __name__ == '__main__':
     unittest.main(exit=True)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 2/17 auto-t: hlrauc.py: remove unix socket on cleanup

---
 autotests/util/hlrauc.py | 5 +++++
 1 file changed, 5 insertions(+)
autotests/util/hlrauc.py +5 -0
index 4491a0ef..ab143acc 100644
@@ -12,6 +12,7 @@ class AuthCenter:
         hostapd can communicate with to obtain SIM values.
     '''
     def __init__(self, sock_path, config_file):
+        self._sock_path = sock_path
         self._read_config(config_file)
         self._socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
         if os.path.exists(sock_path):
@@ -25,6 +26,10 @@ class AuthCenter:
         # wait for rx thread to start
         self._rxhandle.ready.wait()
 
+    def __del__(self):
+        os.remove(self._sock_path)
+        self._socket.close()
+
     def _rx_thread(self):
         self._rxhandle.ready.set()
         while (True):
Signature · 1 line
2.26.2
#2 lore raw

PATCH 3/17 auto-t: testutil.py: pass wait into ping

In reply to James Prestwood

This will wait for the process and cleanup ping-out file

---
 autotests/util/testutil.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
autotests/util/testutil.py +2 -2
index f50223b1..c649b387 100644
@@ -164,7 +164,7 @@ def test_ip_connected(tup0, tup1):
     ip1, ns1 = tup1
 
     try:
-        ns0.start_process(['ping', '-c', '5', '-i', '0.2', ip1], check=True)
-        ns1.start_process(['ping', '-c', '5', '-i', '0.2', ip0], check=True)
+        ns0.start_process(['ping', '-c', '5', '-i', '0.2', ip1], wait=True, check=True)
+        ns1.start_process(['ping', '-c', '5', '-i', '0.2', ip0], wait=True, check=True)
     except:
         raise Exception('Could not ping between %s and %s' % (ip0, ip1))
Signature · 1 line
2.26.2
#3 lore raw

PATCH 4/17 auto-t: testNetconfig stop dhcpd correctly

In reply to James Prestwood

Use stop_process instead of kill as this removes the process from the test context.

---
 autotests/testNetconfig/connection_test.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
autotests/testNetconfig/connection_test.py +3 -2
index caab090c..fad0e82b 100644
@@ -70,8 +70,9 @@ class Test(unittest.TestCase):
     @classmethod
     def tearDownClass(cls):
         IWD.clear_storage()
-        cls.dhcpd_pid.kill()
-        os.system('rm -rf /tmp/dhcpd.leases')
+        ctx.stop_process(cls.dhcpd_pid)
+        cls.dhcpd_pid = None
+        os.remove('/tmp/dhcpd.leases')
 
 if __name__ == '__main__':
     unittest.main(exit=True)
Signature · 1 line
2.26.2
#4 lore raw

PATCH 5/17 auto-t: release radio/hostapd instances from cls

In reply to James Prestwood

The cls object is part of the unittest framework and its lifespan is out of test-runner's control. Setting objects into the cls object sometimes keeps those objects around longer than desired. Its best to unset anything set in cls when the test is tore down.

---
 autotests/testEAP-WPS-Frag/wps_frag_test.py     | 1 +
 autotests/testEAP-WPS/four_digit_pin_test.py    | 1 +
 autotests/testEAP-WPS/pin_test.py               | 1 +
 autotests/testEAP-WPS/push_button_test.py       | 1 +
 autotests/testFT-8021x-roam/connection_test.py  | 2 ++
 autotests/testFT-FILS-SHA256/connection_test.py | 2 ++
 autotests/testFT-FILS-SHA384/connection_test.py | 3 +++
 autotests/testFT-PSK-over-DS/connection_test.py | 2 ++
 autotests/testFT-PSK-roam/connection_test.py    | 2 ++
 autotests/testFT-SAE-roam/connection_test.py    | 2 ++
 10 files changed, 17 insertions(+)
autotests/testEAP-WPS-Frag/wps_frag_test.py +1 -0
index b9be0159..dcaf1ae2 100644
@@ -38,6 +38,7 @@ class Test(unittest.TestCase):
     @classmethod
     def tearDownClass(cls):
         IWD.clear_storage()
+        cls.hostapd = None
 
 if __name__ == '__main__':
     unittest.main(exit=True)
autotests/testEAP-WPS/four_digit_pin_test.py +1 -0
index 10afaa5d..7bdb57cb 100644
@@ -43,6 +43,7 @@ class Test(unittest.TestCase):
     @classmethod
     def tearDownClass(cls):
         IWD.clear_storage()
+        cls.hostapd = None
 
 if __name__ == '__main__':
     unittest.main(exit=True)
autotests/testEAP-WPS/pin_test.py +1 -0
index 706dc20b..e2fef335 100644
@@ -46,6 +46,7 @@ class Test(unittest.TestCase):
     @classmethod
     def tearDownClass(cls):
         IWD.clear_storage()
+        cls.hostapd = None
 
 if __name__ == '__main__':
     unittest.main(exit=True)
autotests/testEAP-WPS/push_button_test.py +1 -0
index f82a56b5..08463f15 100644
@@ -41,6 +41,7 @@ class Test(unittest.TestCase):
     @classmethod
     def tearDownClass(cls):
         IWD.clear_storage()
+        cls.hostapd = None
 
 if __name__ == '__main__':
     unittest.main(exit=True)
autotests/testFT-8021x-roam/connection_test.py +2 -0
index c50c90ee..f83c430d 100644
@@ -143,6 +143,8 @@ class Test(unittest.TestCase):
     @classmethod
     def tearDownClass(cls):
         IWD.clear_storage()
+        cls.bss_hostapd = None
+        cls.bss_radio = None
 
 if __name__ == '__main__':
     unittest.main(exit=True)
autotests/testFT-FILS-SHA256/connection_test.py +2 -0
index 81201e08..c9e8ac7d 100644
@@ -174,6 +174,8 @@ class Test(unittest.TestCase):
     @classmethod
     def tearDownClass(cls):
         IWD.clear_storage()
+        cls.bss_hostapd = None
+        cls.bss_radio = None
 
 if __name__ == '__main__':
     unittest.main(exit=True)
autotests/testFT-FILS-SHA384/connection_test.py +3 -0
index 81201e08..0495d77e 100644
@@ -174,6 +174,9 @@ class Test(unittest.TestCase):
     @classmethod
     def tearDownClass(cls):
         IWD.clear_storage()
+        cls.bss_hostapd = None
+        cls.bss_radio = None
+
 
 if __name__ == '__main__':
     unittest.main(exit=True)
autotests/testFT-PSK-over-DS/connection_test.py +2 -0
index ad186d07..4c751841 100644
@@ -147,6 +147,8 @@ class Test(unittest.TestCase):
     @classmethod
     def tearDownClass(cls):
         IWD.clear_storage()
+        cls.bss_hostapd = None
+        cls.bss_radio = None
 
 if __name__ == '__main__':
     unittest.main(exit=True)
autotests/testFT-PSK-roam/connection_test.py +2 -0
index c0eec0ae..37c6da18 100644
@@ -140,6 +140,8 @@ class Test(unittest.TestCase):
     @classmethod
     def tearDownClass(cls):
         IWD.clear_storage()
+        cls.bss_hostapd = None
+        cls.bss_radio = None
 
 if __name__ == '__main__':
     unittest.main(exit=True)
autotests/testFT-SAE-roam/connection_test.py +2 -0
index f2c694dd..da1ef731 100644
@@ -197,6 +197,8 @@ class Test(unittest.TestCase):
     @classmethod
     def tearDownClass(cls):
         IWD.clear_storage()
+        cls.bss_hostapd = None
+        cls.bss_radio = None
 
 if __name__ == '__main__':
     unittest.main(exit=True)
Signature · 1 line
2.26.2
#5 lore raw

PATCH 6/17 auto-t: iwd.py: release namespace on IWD close

In reply to James Prestwood
---
 autotests/util/iwd.py | 2 ++
 1 file changed, 2 insertions(+)
autotests/util/iwd.py +2 -0
index 8ea1dfb9..6cd7a1a8 100755
@@ -989,6 +989,8 @@ class IWD(AsyncOpAbstract):
             self.namespace.stop_process(self._iwd_proc)
             self._iwd_proc = None
 
+        self.namespace = None
+
     @property
     def _object_manager(self):
         if self._object_manager_if is None:
Signature · 1 line
2.26.2
#6 lore raw

PATCH 7/17 test-runner: remove concept of 'multi_test'

In reply to James Prestwood

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.

---
 tools/test-runner | 32 +++++++++++---------------------
 1 file changed, 11 insertions(+), 21 deletions(-)
tools/test-runner +11 -21
index 662931b1..d63faf8c 100755
@@ -157,16 +157,13 @@ class Process:
 	'''
 		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
-		case. If 'multi_test' is True this indicates the process is
-		run over the entire test run and will not be killed after each
-		test exits.
+		case.
 	'''
-	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):
 		self.args = args
 		self.wait = wait
 		self.name = args[0]
-		self.multi_test = multi_test
 		self.ret = None
 		self.ctx = ctx
 		self.write_fds = []
@@ -311,9 +308,7 @@ class Process:
 				raise Exception("Timed out waiting for socket")
 
 	def __str__(self):
-		ret = str(self.args) + ' multi_test=%s' % str(self.multi_test)
-		ret += '\n'
-		return ret
+		return str(self.args) + '\n'
 
 class Interface:
 	def __init__(self, name, config):
@@ -528,7 +523,6 @@ class Namespace:
 	dbus_address = None
 	processes = []
 	radios = []
-	dbus_pid = None
 
 	def __init__(self, args, name, radios):
 		self.name = name
@@ -539,7 +533,7 @@ class Namespace:
 		for r in radios:
 			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):
 		self.radios = []
@@ -548,12 +542,11 @@ class Namespace:
 		if self.name == "root":
 			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)
-			self.stop_process(p)
+			p.kill()
 
-		if self.dbus_pid and not self.dbus_pid.multi_test:
-			os.remove(self.dbus_cfg)
+		self.processes = []
 
 	def __del__(self):
 		print("Removing namespace %s" % self.name)
@@ -607,14 +600,12 @@ class Namespace:
 			f.write('</busconfig>\n')
 
 		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)
 
 		self._bus = dbus.bus.BusConnection(address_or_type=self.dbus_address)
 
-		return p
-
 	def start_iwd(self, config_dir = '/tmp', storage_dir = '/tmp/iwd'):
 		args = []
 		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])
 
 	def start_haveged(self):
-		self.start_process(['haveged'], multi_test=True)
+		self.start_process(['haveged'])
 
 	def create_radios(self):
 		setup = self.hw_config['SETUP']
@@ -1085,6 +1076,8 @@ def pre_test(ctx, test, copied):
 
 		subtests = pruned
 
+	ctx.start_dbus()
+	ctx.start_haveged()
 	ctx.start_dbus_monitor()
 	ctx.start_radios()
 	ctx.create_namespaces()
@@ -1177,9 +1170,6 @@ def print_results(results):
 def run_auto_tests(ctx, 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
 	shutil.copytree(args.testhome + '/autotests/misc/certs', '/tmp/certs')
 	shutil.copytree(args.testhome + '/autotests/misc/secrets', '/tmp/secrets')
Signature · 1 line
2.26.2
#7 lore raw

PATCH 8/17 test-runner: cleanup output files/others in Process

In reply to James Prestwood

A cleanup parameter was added to __init__ which can be used by processes which create any additional files or require more a custom cleanup routine. Some additional house keeping was done to make Process cleanup more robust.

---
 tools/test-runner | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
tools/test-runner +16 -5
index d63faf8c..2fb7a613 100755
@@ -160,7 +160,7 @@ class Process:
 		case.
 	'''
 	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, cleanup=None):
 		self.args = args
 		self.wait = wait
 		self.name = args[0]
@@ -168,6 +168,7 @@ class Process:
 		self.ctx = ctx
 		self.write_fds = []
 		self.io_watch = None
+		self.cleanup = cleanup
 
 		if not namespace:
 			self.output_name = '/tmp/%s-out' % self.name
@@ -250,6 +251,9 @@ class Process:
 		if len(self.write_fds) > 0:
 			for fd in self.write_fds:
 				fd.write(self.out)
+				fd.close()
+
+			self.write_fds = []
 
 		print("%s returned %d" % (args[0], self.ret))
 		if check and self.ret != 0:
@@ -283,11 +287,16 @@ class Process:
 		if self.io_watch:
 			GLib.source_remove(self.io_watch)
 
-		if self.write_fds != []:
-			for f in self.write_fds:
-				f.close()
+		for f in self.write_fds:
+			f.close()
+
+		try:
+			os.remove(self.output_name)
+		except:
+			pass
 
-		os.remove(self.output_name)
+		if self.cleanup:
+			self.cleanup()
 
 	def kill(self, force=False):
 		print("Killing process %s" % self.args)
@@ -298,6 +307,8 @@ class Process:
 			self.pid.kill()
 
 		self.pid.wait(timeout=15)
+		self.pid = None
+		self.write_fds = []
 
 	def wait_for_socket(self, socket, wait):
 		waited = 0
Signature · 1 line
2.26.2
#8 lore raw

PATCH 9/17 test-runner: allow radio remove failure

In reply to James Prestwood

This is somewhat of an open issue/TODO but for now this avoids the exception caused by trying to remove a radio that has been moved to a namespace. Once a radio is moved hwsim loses that phy and can no longer interact with it. This causes the Destroy() method call to fail.

---
 tools/test-runner | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/test-runner +6 -1
index 2fb7a613..62c4bd75 100755
@@ -395,7 +395,12 @@ class VirtualRadio(Radio):
 	def __del__(self):
 		super().__del__()
 
-		self._radio.remove()
+		# If the radio was moved into a namespace this will fail
+		try:
+			self._radio.remove()
+		except:
+			pass
+
 		self._radio = None
 
 	def __str__(self):
Signature · 1 line
2.26.2
#9 lore raw

PATCH 10/17 test-runner: add better Hostapd cleanup

In reply to James Prestwood

There were a few issues with the cleanup of Hostapd. First the process was only being killed, which did not actually remove the process from the list.

In addition, with EAP-SIM/AKA tests, hostapd created sim_db unix socket files which it does not clean up.

---
 tools/test-runner | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
tools/test-runner +13 -1
index 62c4bd75..f6d7784d 100755
@@ -449,6 +449,8 @@ class Hostapd:
 		process since hostapd can be started with multiple config files.
 	'''
 	def __init__(self, ctx, radios, configs, radius):
+		self.ctx = ctx
+
 		if len(configs) != len(radios):
 			raise Exception("Config (%d) and radio (%d) list length not equal" % \
 						(len(configs), len(radios)))
@@ -531,7 +533,17 @@ class Hostapd:
 			dbg("Failed to remove %s" % self.global_ctrl_iface)
 
 		self.instances = None
-		self.process.kill()
+
+		# Hostapd may have already been stopped
+		if self.process:
+			self.ctx.stop_process(self.process)
+
+		self.ctx = None
+
+		# Hostapd creates simdb sockets for EAP-SIM/AKA tests but does not
+		# clean them up.
+		for f in glob("/tmp/eap_sim_db*"):
+			os.remove(f)
 
 dbus_count = 0
 
Signature · 1 line
2.26.2
#10 lore raw

PATCH 11/17 test-runner: use cleanup() for start_dbus

In reply to James Prestwood

Use a cleanup routine to remove the dbus_address/dbus_cfg files

---
 tools/test-runner | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
tools/test-runner +10 -2
index f6d7784d..fccb6233 100755
@@ -615,7 +615,15 @@ class Namespace:
 				return True
 		return False
 
-	def start_dbus(self, multi_test=True):
+	def _cleanup_dbus(self):
+		try:
+			os.remove(self.dbus_address.split('=')[1])
+		except:
+			pass
+
+		os.remove(self.dbus_cfg)
+
+	def start_dbus(self):
 		global dbus_count
 
 		self.dbus_address = 'unix:path=/tmp/dbus%d' % dbus_count
@@ -628,7 +636,7 @@ class Namespace:
 			f.write('</busconfig>\n')
 
 		p = self.start_process(['dbus-daemon', '--config-file=%s' % self.dbus_cfg],
-					wait=False)
+					wait=False, cleanup=self._cleanup_dbus)
 
 		p.wait_for_socket(self.dbus_address.split('=')[1], wait=5)
 
Signature · 1 line
2.26.2
#11 lore raw

PATCH 12/17 test-runner: reset namespaces on test completion

In reply to James Prestwood
---
 tools/test-runner | 3 +++
 1 file changed, 3 insertions(+)
tools/test-runner +3 -0
index fccb6233..80bdae30 100755
@@ -913,6 +913,9 @@ class TestContext(Namespace):
 		return None
 
 	def stop_test_processes(self):
+		for n in self.namespaces:
+			n.reset()
+
 		self.namespaces = []
 		self.hostapd = None
 		self.wpas_interfaces = None
Signature · 1 line
2.26.2
#12 lore raw

PATCH 13/17 test-runner: move process cleanup into kill()

In reply to James Prestwood

This moves all the de-init code into kill(), which fixes a few reference issues causing processes to hang around longer than desired. If the process terminates on its own and/or the last reference is lost __del__ will kill the process and clean up.

---
 tools/test-runner | 48 +++++++++++++++++++++++++++++++----------------
 1 file changed, 32 insertions(+), 16 deletions(-)
tools/test-runner +32 -16
index 80bdae30..ae02578e 100755
@@ -161,6 +161,7 @@ class Process:
 	'''
 	def __init__(self, args, wait=False, env=None, ctx=None, check=False,
 				outfile=None, namespace=None, need_out=False, cleanup=None):
+		self.killed = False
 		self.args = args
 		self.wait = wait
 		self.name = args[0]
@@ -238,6 +239,7 @@ class Process:
 			return
 
 		self.pid.wait()
+		self.killed = True
 
 		self.stdout.seek(self.io_position)
 		self.out = self.stdout.read()
@@ -282,34 +284,49 @@ class Process:
 
 	def __del__(self):
 		print("Del process %s" % self.args)
-		self.stdout.close()
 
-		if self.io_watch:
-			GLib.source_remove(self.io_watch)
+		if not self.killed:
+			self.kill()
 
-		for f in self.write_fds:
-			f.close()
-
-		try:
-			os.remove(self.output_name)
-		except:
-			pass
-
-		if self.cleanup:
-			self.cleanup()
+		os.remove(self.output_name)
 
 	def kill(self, force=False):
 		print("Killing process %s" % self.args)
 
+		if self.killed:
+			return
+
 		if force:
-			os.kill(self.pid.pid, signal.SIGKILL)
-		else:
 			self.pid.kill()
+		else:
+			self.pid.terminate()
 
 		self.pid.wait(timeout=15)
 		self.pid = None
+
+		if self.ctx and self in self.ctx.processes:
+			self.ctx.processes.remove(self)
+
+		self.ctx = None
+
+		for f in self.write_fds:
+			f.close()
+
 		self.write_fds = []
 
+		if self.io_watch:
+			GLib.source_remove(self.io_watch)
+			self.io_watch = None
+
+		if self.cleanup:
+			self.cleanup()
+
+		self.cleanup = None
+
+		self.stdout.close()
+
+		self.killed = True
+
 	def wait_for_socket(self, socket, wait):
 		waited = 0
 		while not os.path.exists(socket):
@@ -607,7 +624,6 @@ class Namespace:
 
 	def stop_process(self, p, force=False):
 		p.kill(force)
-		self.processes.remove(p)
 
 	def is_process_running(self, process):
 		for p in self.processes:
Signature · 1 line
2.26.2
#13 lore raw

PATCH 14/17 test-runner: fix Namespace class ref problems

In reply to James Prestwood

The Namespace class was never being removed when tests finished. This is fixed by unreffing the hwsim internal _radio object which both cleans up the radio and allows the Namespace to be removed.

---
 tools/test-runner | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
tools/test-runner +7 -6
index ae02578e..19272774 100755
@@ -565,11 +565,9 @@ class Hostapd:
 dbus_count = 0
 
 class Namespace:
-	dbus_address = None
-	processes = []
-	radios = []
-
 	def __init__(self, args, name, radios):
+		self.dbus_address = None
+		self.processes = []
 		self.name = name
 		self.radios = radios
 		self.args = args
@@ -581,9 +579,13 @@ class Namespace:
 		self.start_dbus()
 
 	def reset(self):
-		self.radios = []
 		self._bus = None
 
+		for r in self.radios:
+			r._radio = None
+
+		self.radios = []
+
 		if self.name == "root":
 			self._bus = dbus.bus.BusConnection(address_or_type=self.dbus_address)
 
@@ -595,7 +597,6 @@ class Namespace:
 
 	def __del__(self):
 		print("Removing namespace %s" % self.name)
-		self.reset()
 
 		Process(['ip', 'netns', 'del', self.name], wait=True)
 
Signature · 1 line
2.26.2
#14 lore raw

PATCH 15/17 test-runner: start haveged in foreground

In reply to James Prestwood

haveged was forking itself which then prevented test-runner from cleaning it up.

---
 tools/test-runner | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/test-runner +1 -1
index 19272774..412998ba 100755
@@ -770,7 +770,7 @@ class TestContext(Namespace):
 		self.start_process(['dbus-monitor', '--address', self.dbus_address])
 
 	def start_haveged(self):
-		self.start_process(['haveged'])
+		self.start_process(['haveged', '-F'])
 
 	def create_radios(self):
 		setup = self.hw_config['SETUP']
Signature · 1 line
2.26.2
#15 lore raw

PATCH 16/17 test-runner: warn on files left after test completes

In reply to James Prestwood
---
 tools/test-runner | 5 +++++
 1 file changed, 5 insertions(+)
tools/test-runner +5 -0
index 412998ba..7c1498d0 100755
@@ -1179,6 +1179,10 @@ def post_test(ctx, to_copy):
 	finally:
 		ctx.stop_test_processes()
 
+	allowed = ['phonesim.conf', 'certs', 'secrets', 'iwd']
+	for f in [f for f in os.listdir('/tmp') if f not in allowed]:
+		dbg("File %s was not cleaned up!" % f)
+
 	if ctx.args.valgrind:
 		with open('/tmp/valgrind.log', 'r') as f:
 				dbg(f.read())
@@ -1274,6 +1278,7 @@ def run_auto_tests(ctx, args):
 		finally:
 			post_test(ctx, copied)
 
+	shutil.rmtree('/tmp/iwd')
 	shutil.rmtree('/tmp/certs')
 	shutil.rmtree('/tmp/secrets')
 	os.remove('/tmp/phonesim.conf')
Signature · 1 line
2.26.2
#16 lore raw

PATCH 17/17 test-runner: stop/warn on processes running after test

In reply to James Prestwood

This gives the dev some inidication their test did not clean up correctly and running processes remain.

---
 tools/test-runner | 4 ++++
 1 file changed, 4 insertions(+)
tools/test-runner +4 -0
index 7c1498d0..eab0f0ab 100755
@@ -56,6 +56,10 @@ def exit_vm():
 	if config:
 		for p in config.ctx.processes:
 			print("Process %s still running!" % p.name)
+			p.kill()
+			p = None
+
+		config.ctx.processes = []
 
 	if config.ctx and config.ctx.results:
 		print_results(config.ctx.results)
Signature · 1 line
2.26.2
#17 lore raw
In reply to James Prestwood

Hi James,

Quoted 3 lines · James Prestwood
---
  autotests/testEAD/connection_test.py | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)

All applied, thanks.

Regards,
-Denis