Skip to content

Commit

Permalink
test_onroad: fix test_log_sizes when running inside a prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
adeebshihadeh committed Dec 15, 2023
1 parent da12a34 commit 10ea451
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions selfdrive/test/test_onroad.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ def setUpClass(cls):
cls.lr = list(LogReader(os.path.join(str(cls.segments[1]), "rlog")))
cls.log_path = cls.segments[1]

cls.log_sizes = {}
for f in cls.log_path.iterdir():
assert f.is_file()
cls.log_sizes[f] = f.stat().st_size / 1e6
if f.name in ("qlog", "rlog"):
with open(f, 'rb') as ff:
cls.log_sizes[f] = len(bz2.compress(ff.read())) / 1e6


@cached_property
def service_msgs(self):
msgs = defaultdict(list)
Expand Down Expand Up @@ -198,14 +207,7 @@ def test_cloudlog_size(self):
self.assertEqual(len(big_logs), 0, f"Log spam: {big_logs}")

def test_log_sizes(self):
for f in self.log_path.iterdir():
assert f.is_file()

sz = f.stat().st_size / 1e6
if f.name in ("qlog", "rlog"):
with open(f, 'rb') as ff:
sz = len(bz2.compress(ff.read())) / 1e6

for f, sz in self.log_sizes.items():
if f.name == "qcamera.ts":
assert 2.15 < sz < 2.35
elif f.name == "qlog":
Expand Down

0 comments on commit 10ea451

Please sign in to comment.