From 1b86f0f477692731edaf4da99f3b639c63bbd8d0 Mon Sep 17 00:00:00 2001 From: Dave Wallace Date: Wed, 8 Nov 2023 15:55:56 -0500 Subject: tests: retry unlinking pcap files on os error Type: test Change-Id: I270798ed68f04bd3974dd39c44e85dad5fa02de0 Signed-off-by: Dave Wallace --- test/asf/asfframework.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/asf/asfframework.py b/test/asf/asfframework.py index 024d7f0127d..9839ff58543 100644 --- a/test/asf/asfframework.py +++ b/test/asf/asfframework.py @@ -853,8 +853,17 @@ class VppAsfTestCase(CPUInterface, unittest.TestCase): if hasattr(self, "pg_interfaces") and len(self.pg_interfaces) > 0: testcase_dir = os.path.dirname(self.pg_interfaces[0].out_path) for p in Path(testcase_dir).glob("pg*.pcap"): - self.logger.debug(f"Removing {p}") - p.unlink() + retries = 8 + while retries > 0: + retries = retries - 1 + self.logger.debug(f"Unlinking {p}") + try: + p.unlink() + break + except OSError: + self.logger.debug(f"OSError: unlinking {p}") + self.sleep(0.25, f"{retries} retries left") + self.logger.debug( f"--- END tearDown() {self.__class__.__name__}.{self._testMethodName}('{self._testMethodDoc}') ---" ) -- cgit 1.2.3-korg