android logcatd test reliability (#20284)

* android logcatd test reliability

* remove that

* more fix

Co-authored-by: Comma Device <device@comma.ai>
pull/20285/head
Adeeb Shihadeh 2021-03-08 16:47:28 -08:00 committed by GitHub
parent bcbcc03dc7
commit 9151f55e5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 5 deletions

View File

@ -22,9 +22,11 @@ class TestLogcatdAndroid(unittest.TestCase):
# write some log messages
sent_msgs = {}
for __ in range(random.randint(5, 50)):
msg = ''.join([random.choice(string.ascii_letters) for _ in range(random.randrange(2, 200))])
msg = ''.join([random.choice(string.ascii_letters) for _ in range(random.randrange(2, 50))])
if msg in sent_msgs:
continue
sent_msgs[msg] = ''.join([random.choice(string.ascii_letters) for _ in range(random.randrange(2, 20))])
os.system(f"log -t {sent_msgs[msg]} {msg}")
os.system(f"log -t '{sent_msgs[msg]}' '{msg}'")
time.sleep(1)
msgs = messaging.drain_sock(sock)
@ -36,12 +38,13 @@ class TestLogcatdAndroid(unittest.TestCase):
if recv_msg not in sent_msgs:
continue
self.assertEqual(m.androidLog.tag, sent_msgs[recv_msg])
del sent_msgs[recv_msg]
# see https://android.googlesource.com/platform/system/core/+/android-2.1_r1/liblog/logd_write.c#144
radio_msg = m.androidLog.id == 1 and m.androidLog.tag.startswith("use-Rlog/RLOG-")
if m.androidLog.tag == sent_msgs[recv_msg] or radio_msg:
del sent_msgs[recv_msg]
# ensure we received all the logs we sent
self.assertEqual(len(sent_msgs), 0)
time.sleep(1)
if __name__ == "__main__":