Unuse resources after every test

Fix bug in put_all(). That method was unused before this commit.

Clean the process list after the processes are stopped,
otherwise the suite eventually fails with a 'process terminated
prematurely' error. Before it was not necessary because it was not
reused (a new suite run was created).

Change-Id: Iee12866045145544076c6c18786e1a54f18fc293
This commit is contained in:
Pau Espin 2017-06-13 18:07:57 +02:00 committed by Neels Hofmeyr
parent d091233934
commit 1dd2955cb1
2 changed files with 9 additions and 8 deletions

View File

@ -508,11 +508,11 @@ class ReservedResources(log.Origin):
my_item.pop(USED_KEY)
def put_all(self):
if not self.reserved:
return
for key, item_list in self.reserved.items():
my_list = self.get(key)
for my_item in my_list:
if my_item.get(USED_KEY):
my_item.pop(USED_KEY)
for item in item_list:
item.pop(USED_KEY, None)
def free(self):
if self.reserved:

View File

@ -256,6 +256,9 @@ class SuiteRun(log.Origin):
continue
self.current_test = test
test.run()
self.stop_processes()
self.objects_cleanup()
self.reserved_resources.put_all()
except Exception:
log.log_exn()
except BaseException as e:
@ -303,10 +306,8 @@ class SuiteRun(log.Origin):
self._processes.insert(0, process)
def stop_processes(self):
if not self._processes:
return
for process in self._processes:
process.terminate()
while self._processes:
self._processes.pop().terminate()
def free_resources(self):
if self.reserved_resources is None: