diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index bb5b0a137a..aba630f67c 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -213,6 +213,7 @@ jobs: run: | ${{ env.RUN }} "CI=1 coverage run selfdrive/test/process_replay/test_processes.py -j$(nproc) && \ chmod -R 777 /tmp/comma_download_cache && \ + coverage combine && \ coverage xml" - name: Print diff id: print-diff @@ -282,6 +283,7 @@ jobs: run: | ${{ env.RUN_CL }} "unset PYTHONWARNINGS && \ ONNXCPU=1 CI=1 NO_NAV=1 coverage run selfdrive/test/process_replay/model_replay.py && \ + coverage combine && \ coverage xml" - name: Run unit tests timeout-minutes: 4 diff --git a/pyproject.toml b/pyproject.toml index 71b677fbb7..16dad2c643 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -199,3 +199,6 @@ flake8-implicit-str-concat.allow-multiline=false "system".msg = "Use openpilot.system" "third_party".msg = "Use openpilot.third_party" "tools".msg = "Use openpilot.tools" + +[tool.coverage.run] +concurrency = ["multiprocessing", "thread"] \ No newline at end of file diff --git a/selfdrive/athena/tests/test_athenad.py b/selfdrive/athena/tests/test_athenad.py index e81753a6a0..8829ebfbf1 100755 --- a/selfdrive/athena/tests/test_athenad.py +++ b/selfdrive/athena/tests/test_athenad.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import json +import multiprocessing import os import requests import shutil @@ -12,7 +13,6 @@ from datetime import datetime, timedelta from parameterized import parameterized from typing import Optional -from multiprocessing import Process from pympler.tracker import SummaryTracker from unittest import mock from websocket import ABNF @@ -75,24 +75,25 @@ class TestAthenadMethods(unittest.TestCase): with self.assertRaises(TimeoutError) as _: dispatcher["getMessage"]("controlsState") - def send_deviceState(): - messaging.context = messaging.Context() - pub_sock = messaging.pub_sock("deviceState") - start = time.time() + end_event = multiprocessing.Event() + + pub_sock = messaging.pub_sock("deviceState") - while time.time() - start < 1: + def send_deviceState(): + while not end_event.is_set(): msg = messaging.new_message('deviceState') pub_sock.send(msg.to_bytes()) time.sleep(0.01) - p = Process(target=send_deviceState) + p = multiprocessing.Process(target=send_deviceState) p.start() time.sleep(0.1) try: deviceState = dispatcher["getMessage"]("deviceState") assert deviceState['deviceState'] finally: - p.terminate() + end_event.set() + p.join() def test_listDataDirectory(self): route = '2021-03-29--13-32-47'