X-Git-Url: http://rtime.felk.cvut.cz/gitweb/can-benchmark.git/blobdiff_plain/9b45ba73353ebf67b1c9583cea7e57e6b32dd29a..4b9389362dbefcb559e4167296484f2aca475b5e:/gw-tests/rtems_bench.py diff --git a/gw-tests/rtems_bench.py b/gw-tests/rtems_bench.py new file mode 100755 index 0000000..51539b8 --- /dev/null +++ b/gw-tests/rtems_bench.py @@ -0,0 +1,93 @@ +#!/usr/local/bin/python3.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) +""" +Quick and dirty script to automate benchmarking ryu board with RTEMS on board. + +Should create the same directory structure as the shell scripts used when targeting linux, +but only uses two tests (one actually, the second one is reinterpretation of the data of the first one.) + +Expects to be run from within the gw-tests directory and that the layout of boot files remains constant. +""" + +import subprocess +import sys, os, shutil, stat +from time import sleep + +import tests +import lib + +if os.geteuid() != 0: + print("This script needs to be run as root.") + exit(1) + + + +def run(): + print("Starting the benchmark.") + hostname = lib.read_hostname() + print("Hostname is: ", hostname) + lib.set_hostname(hostname) + for test in tests.tests: + testname = test.name + print("Current test is: ", testname) + lib.set_testname(testname) + for load in lib.load_types: + lib.set_load(load) + print("Current load is: ", load) + + #Currently, because of problems with serial port, tests have associated images for behaviour + #otherwise, they are just histogram generators + if test.has_image: + #First part of load "handlers" -> start the proper load. + if load == "cpu": + #we have to reflash cpu load image + #thus, this function actually waits for ~15s + print("Starting CPU load.") + lib.start_cpu_load(testname) + + if load == "eth": + print("Starting eth load") + lib.start_eth_load() + + for traffic in lib.traffic_modes: + if traffic == "flood": + subprocess.call("ifconfig can0 txqueuelen 200".split()) #this stops latester from ending due to ENOBUFS errors + print("Can mode: ", traffic) + + lib.set_traffic(traffic) + print("Testenv prepared") + #Tests are run here. + lib.run_test(test) + + + #restart every can_mode change, just to be sure? + #restart_board() + #give time to recover from load? + sleep(5) + + #Currently, because of problems with serial port, tests have associated images for behaviour + #otherwise, they are just histogram generators + if test.has_image: + #second part of the load "handlers" -> stopping the load + if load == "cpu": + #we have to reflash "no cpu load" image + #thus, this function actually waits for ~15s + print("Stopping cpu load") + lib.stop_cpu_load(testname) + + if load == "eth": + print("Stopping eth load") + lib.stop_eth_load() + + + + + print("Run should be now finished.") + + + + + +if __name__ == "__main__": + run()