Nav2 Navigation Stack - kilted  kilted
ROS 2 Navigation Stack
updownresults.py
1 #!/usr/bin/python3
2 # Copyright (c) 2019 Intel Corporation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 
16 
17 # To use this script, run the `test_updown_reliability` script and log the output
18 # > ./test_updown_reliability |& tee /tmp/updown.log
19 # When the test is completed, pipe the log to this script to get a summary of the
20 # results
21 # > ./updownresults.py < /tmp/updown.log
22 #
23 # This reports the number of successful tests, but also the number of times the
24 # tests were able to make it to the active state as well as the shutdown state.
25 # It can frequently occur that the system makes all the lifecycle state transitions
26 # but has an error during the final process termination.
27 
28 import sys
29 
30 
31 def main() -> None:
32  log = sys.stdin
33  test_count = 0
34  fail_count = 0
35  successful_bringup_count = 0
36  successful_shutdown_count = 0
37  for line in log.readlines():
38  if line.startswith('======= START OF RUN:'):
39  test_successful = True
40  shutdown_successful = False
41  bringup_successful = False
42 
43  if line.startswith('======== END OF RUN:'):
44  test_count += 1
45  conclusion = ''
46  if bringup_successful:
47  successful_bringup_count += 1
48  conclusion = ' but bringup was successful'
49  if shutdown_successful:
50  successful_shutdown_count += 1
51  conclusion = ' but shutdown was successful'
52  if not test_successful:
53  fail_count += 1
54  print('Failure in test ', test_count, conclusion)
55 
56  if '[ERROR]' in line:
57  test_successful = False
58 
59  if 'The system is active' in line:
60  bringup_successful = True
61 
62  if 'The system has been successfully shut down' in line:
63  shutdown_successful = True
64 
65  print('Number of tests: ', test_count)
66  print('Number of successes: ', test_count - fail_count)
67  print('Number of successful bringups', successful_bringup_count)
68  print('Number of successful shutdowns', successful_shutdown_count)
69 
70 
71 if __name__ == '__main__':
72  main()