Add script to rerun process on route and generate new logs (#22100)

* add script to rerun process on route and generate new logs

* cleanup

* move to root

* newline
pull/22094/head
Willem Melching 2021-09-01 14:48:41 -07:00 committed by GitHub
parent 6fad0055b4
commit 3b13eb8c7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 1 deletions

2
.gitignore vendored
View File

@ -76,3 +76,5 @@ comma*.sh
selfdrive/modeld/thneed/compile
models/*.thneed
*.bz2

View File

@ -0,0 +1,31 @@
#!/usr/bin/env python3
import argparse
from selfdrive.test.process_replay.compare_logs import save_log
from selfdrive.test.process_replay.process_replay import CONFIGS, replay_process
from tools.lib.logreader import MultiLogIterator
from tools.lib.route import Route
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Run process on route and create new logs",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("route", help="The route name to use")
parser.add_argument("process", help="The process to run")
args = parser.parse_args()
cfg = [c for c in CONFIGS if c.proc_name == args.process][0]
route = Route(args.route)
lr = MultiLogIterator(route.log_paths(), wraparound=False)
inputs = list(lr)
outputs = replay_process(cfg, inputs)
# Remove message generated by the process under test and merge in the new messages
produces = set(o.which() for o in outputs)
inputs = [i for i in inputs if i.which() not in produces]
outputs = sorted(inputs + outputs, key=lambda x: x.logMonoTime)
fn = f"{args.route}_{args.process}.bz2"
save_log(fn, outputs)

View File

@ -429,7 +429,10 @@ def python_replay_process(cfg, lr, fingerprint=None):
recv_cnt = len(recv_socks)
while recv_cnt > 0:
m = fpm.wait_for_msg()
m = fpm.wait_for_msg().as_builder()
m.logMonoTime = msg.logMonoTime
m = m.as_reader()
log_msgs.append(m)
recv_cnt -= m.which() in recv_socks
return log_msgs
@ -466,6 +469,10 @@ def cpp_replay_process(cfg, lr, fingerprint=None):
if response is None:
print(f"Warning, no response received {i}")
else:
response = response.as_builder()
response.logMonoTime = msg.logMonoTime
response = response.as_reader()
log_msgs.append(response)
if not len(resp_sockets): # We only need to wait if we didn't already wait for a response