From 597f695d267970a7dd260f938e50efadc4fefa7d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Mon, 16 Sep 2013 16:20:26 +0200 Subject: [PATCH] Minor, mostly cosmetic, changes to RTEMS bench scripts. Updated docstrings, removed out of date comments, added some new ones. --- gw-tests/lib.py | 10 +++++++++- gw-tests/rtems_bench.py | 16 ++++++++-------- gw-tests/tests.py | 9 ++++++++- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/gw-tests/lib.py b/gw-tests/lib.py index 700eacb..4cccc27 100644 --- a/gw-tests/lib.py +++ b/gw-tests/lib.py @@ -1,3 +1,7 @@ +""" +Contains various helper functions and information for benchmarking RTEMS CAN GW implementation. +""" + import subprocess import sys import os @@ -152,4 +156,8 @@ def read_hostname(): def original_name_from_histogram_name(hist_name): """Retuns name of the original test from the name of its histogram.""" - return "-".join(hist_name.split("-")[:-1]) \ No newline at end of file + return "-".join(hist_name.split("-")[:-1]) + +def set_txqueuelen(length): + """Sets txqueuelen on can0 interface to given length""" + subprocess.call("ifconfig can0 txqueuelen {}".format(length).split()) diff --git a/gw-tests/rtems_bench.py b/gw-tests/rtems_bench.py index 51539b8..e1b40eb 100755 --- a/gw-tests/rtems_bench.py +++ b/gw-tests/rtems_bench.py @@ -4,14 +4,14 @@ """ 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.) +Creates the same general directory structure and contents as do the shell scripts. + +Takes tests from tests.py (see its docstring for defining new tests) and relies on functions from lib.py 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 +import os from time import sleep import tests @@ -52,7 +52,7 @@ def run(): 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 + lib.set_txqueuelen(200) #this stops latester from ending due to ENOBUFS errors print("Can mode: ", traffic) lib.set_traffic(traffic) @@ -66,9 +66,9 @@ def run(): #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: + #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 diff --git a/gw-tests/tests.py b/gw-tests/tests.py index a06a1ae..cc5cd30 100644 --- a/gw-tests/tests.py +++ b/gw-tests/tests.py @@ -1,3 +1,9 @@ +""" +This file contains and defines tests for use in rtems_bench. + +Any new tests should be added to module variable tests to be seen by the bench. +""" + import lib @@ -8,7 +14,7 @@ class Test: self.has_image = has_image def run(self): - self.func(self) + self.func(self) # def nop(self): print(self.name) @@ -18,6 +24,7 @@ def nop(self): def nop_time(self): + print(self.name) lib.symlink_results(lib.original_name_from_histogram_name(self.name)) lib.create_plot_script() -- 2.39.2