]> rtime.felk.cvut.cz Git - can-benchmark.git/blob - gw-tests/rtems_bench.py
run.pl redirects stdout rather than stderr in order to not loose error messages
[can-benchmark.git] / gw-tests / rtems_bench.py
1 #!/usr/local/bin/python3.3
2
3 #note, this script should generally work with any version of Python above 2.5 (lot of used functions of the subprocess module are there since 2.6)
4 """
5 Quick and dirty script to automate benchmarking ryu board with RTEMS on board.
6
7 Creates the same general directory structure and contents as do the shell scripts.
8
9 Takes tests from tests.py (see its docstring for defining new tests) and relies on functions from lib.py
10
11 Expects to be run from within the gw-tests directory and that the layout of boot files remains constant.
12 """
13
14 import os
15 from time import sleep
16
17 import tests
18 import lib
19
20 if os.geteuid() != 0:
21     print("This script needs to be run as root.")
22     exit(1)
23
24
25     
26 def run():
27     print("Starting the benchmark.")
28     hostname = lib.read_hostname()
29     print("Hostname is: ", hostname)
30     lib.set_hostname(hostname)
31     for test in tests.tests:
32         testname = test.name
33         print("Current test is: ", testname)
34         lib.set_testname(testname)
35         for load in lib.load_types:
36             lib.set_load(load)
37             print("Current load is: ", load)
38
39             #Currently, because of problems with serial port, tests have associated images for behaviour
40             #otherwise, they are just histogram generators
41             if test.has_image:
42                 #First part of load "handlers" -> start the proper load.
43                 if load == "cpu":
44                     #we have to reflash cpu load image
45                     #thus, this function actually waits for ~15s
46                     print("Starting CPU load.")
47                     lib.start_cpu_load(testname)
48         
49                 if load == "eth":
50                     print("Starting eth load")
51                     lib.start_eth_load()
52     
53             for traffic in lib.traffic_modes:
54                 if traffic == "flood":
55                     lib.set_txqueuelen(200) #this stops latester from ending due to ENOBUFS errors
56                 print("Can mode: ", traffic)
57
58                 lib.set_traffic(traffic)
59                 print("Testenv prepared")
60                 #Tests are run here.
61                 lib.run_test(test)
62                 
63                 
64                 #restart every can_mode change, just to be sure?
65                 #restart_board()
66             #give time to recover from load?
67             sleep(5)
68
69             #Currently, because of problems with serial port, tests have associated images for behaviour
70             #otherwise, they are just histogram generators
71             if test.has_image:
72                 #second part of the load "handlers" -> stopping the load
73                 if load == "cpu":
74                     #we have to reflash "no cpu load" image
75                     #thus, this function actually waits for ~15s
76                     print("Stopping cpu load")
77                     lib.stop_cpu_load(testname)
78     
79                 if load == "eth":
80                     print("Stopping eth load")
81                     lib.stop_eth_load()
82
83     
84                         
85     
86     print("Run should be now finished.")
87
88     
89     
90     
91
92 if __name__ == "__main__":
93     run()