Skip to content

Commit

Permalink
test_manager: ensure test independence (commaai#31364)
Browse files Browse the repository at this point in the history
* ensure independent

* still run 10- times

* need index

---------

Co-authored-by: Comma Device <device@comma.ai>
  • Loading branch information
jnewb1 and Comma Device authored Feb 8, 2024
1 parent 0355cea commit c79d1e0
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions selfdrive/manager/test/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit c79d1e0

Please sign in to comment.