From c79d1e0192d13fe261a2b06893ff58211d78f5d4 Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Wed, 7 Feb 2024 23:52:21 -0500 Subject: [PATCH] test_manager: ensure test independence (#31364) * ensure independent * still run 10- times * need index --------- Co-authored-by: Comma Device --- selfdrive/manager/test/test_manager.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/selfdrive/manager/test/test_manager.py b/selfdrive/manager/test/test_manager.py index fbeb932a86cc38..04af87d9c8f682 100755 --- a/selfdrive/manager/test/test_manager.py +++ b/selfdrive/manager/test/test_manager.py @@ -5,6 +5,8 @@ import time import unittest +from parameterized import parameterized + from cereal import car from openpilot.common.params import Params import openpilot.selfdrive.manager.manager as manager @@ -38,13 +40,13 @@ def test_blacklisted_procs(self): # TODO: ensure there are blacklisted procs until we have a dedicated test self.assertTrue(len(BLACKLIST_PROCS), "No blacklisted procs to test not_run") - def test_startup_time(self): - for _ in range(10): - start = time.monotonic() - os.environ['PREPAREONLY'] = '1' - manager.main() - t = time.monotonic() - start - assert t < MAX_STARTUP_TIME, f"startup took {t}s, expected <{MAX_STARTUP_TIME}s" + @parameterized.expand(range(10)) + def test_startup_time(self, index): + start = time.monotonic() + os.environ['PREPAREONLY'] = '1' + manager.main() + t = time.monotonic() - start + assert t < MAX_STARTUP_TIME, f"startup took {t}s, expected <{MAX_STARTUP_TIME}s" @unittest.skip("this test is flaky the way it's currently written, should be moved to test_onroad") def test_clean_exit(self):