fix: free resources when a suite run is done
Add missing code to free resources, not upon program exit, but when a suite is
done.
This allows running more than one suite in a row.
Also add a check to not attempt to free if there is nothing to be freed, to
avoid a regression test failure triggered when a suite exits without reserving
anything.
Change-Id: Ic017a1cf07052f5e48812c8553fba6f972d280f0
Related: OS#2301
diff --git a/src/osmo_gsm_tester/suite.py b/src/osmo_gsm_tester/suite.py
index ac56ada..6a1796f 100644
--- a/src/osmo_gsm_tester/suite.py
+++ b/src/osmo_gsm_tester/suite.py
@@ -248,6 +248,7 @@
# base exception is raised. Make sure to stop processes in this
# finally section. Resources are automatically freed with 'atexit'.
self.stop_processes()
+ self.free_resources()
event_loop.unregister_poll_func(self.poll)
self.duration = time.time() - self.start_timestamp
if self.test_failed_ctr:
@@ -268,6 +269,11 @@
for process in self._processes:
process.terminate()
+ def free_resources(self):
+ if self.reserved_resources is None:
+ return
+ self.reserved_resources.free()
+
def ip_address(self):
return self.reserved_resources.get(resource.R_IP_ADDRESS)