validate-launcher: Fix race condition on repeated tests

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2900

The `reports` list was being copied as a reference, therefore, copies of
a test ended up inadvertedly sharing the same list of reports. Reports
added by one instance of the test would be reflected in all instances.

This caused a race condition where, if a test was run on repeat with
gst-validate-launcher -f, very often wrong log file was shown to the
user. For instance, gst-validate-launcher would say "test failed, see
log for iteration7", but iteration7 would contain "TEST PASSED".

Worse, the runner would add the report to that incorrect log file,
mixing problems between different executions of the tests.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5177>
This commit is contained in:
Alicia Boya García 2023-08-11 18:30:41 +02:00 committed by GStreamer Marge Bot
parent 4abe4b2d2a
commit ba61160d6c

View file

@ -163,6 +163,7 @@ class Test(Loggable):
def copy(self, nth=None):
copied_test = copy.copy(self)
copied_test.reports = copy.deepcopy(self.reports)
if nth:
copied_test.classname += '_it' + str(nth)
copied_test._uuid = None