mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-17 15:22:10 +08:00
test_logreader: test run_across_segments (#31305)
* more logreader tests * not in ci for now * enable cache old-commit-hash: b17f24d68ea560722a1596840ec0c79cf928f0ab
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import shutil
|
||||
import tempfile
|
||||
import numpy as np
|
||||
import os
|
||||
import unittest
|
||||
import pytest
|
||||
import requests
|
||||
@@ -8,7 +9,7 @@ import requests
|
||||
from parameterized import parameterized
|
||||
from unittest import mock
|
||||
|
||||
from openpilot.tools.lib.logreader import LogReader, parse_indirect, parse_slice, ReadMode
|
||||
from openpilot.tools.lib.logreader import LogIterable, LogReader, parse_indirect, parse_slice, ReadMode
|
||||
from openpilot.tools.lib.route import SegmentRange
|
||||
|
||||
NUM_SEGS = 17 # number of segments in the test route
|
||||
@@ -16,6 +17,11 @@ ALL_SEGS = list(np.arange(NUM_SEGS))
|
||||
TEST_ROUTE = "344c5c15b34f2d8a/2024-01-03--09-37-12"
|
||||
QLOG_FILE = "https://commadataci.blob.core.windows.net/openpilotci/0375fdf7b1ce594d/2019-06-13--08-32-25/3/qlog.bz2"
|
||||
|
||||
|
||||
def noop(segment: LogIterable):
|
||||
return segment
|
||||
|
||||
|
||||
class TestLogReader(unittest.TestCase):
|
||||
@parameterized.expand([
|
||||
(f"{TEST_ROUTE}", ALL_SEGS),
|
||||
@@ -124,6 +130,13 @@ class TestLogReader(unittest.TestCase):
|
||||
self.assertEqual(lr.first("carParams").carFingerprint, "SUBARU OUTBACK 6TH GEN")
|
||||
self.assertTrue(0 < len(list(lr.filter("carParams"))) < len(list(lr)))
|
||||
|
||||
@parameterized.expand([(True,), (False,)])
|
||||
@pytest.mark.slow
|
||||
def test_run_across_segments(self, cache_enabled):
|
||||
os.environ["FILEREADER_CACHE"] = "1" if cache_enabled else "0"
|
||||
lr = LogReader(f"{TEST_ROUTE}/0:4")
|
||||
self.assertEqual(len(lr.run_across_segments(4, noop)), len(list(lr)))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user