diff options
author | Arthur She <arthur.she@linaro.org> | 2015-02-09 12:11:41 +0800 |
---|---|---|
committer | Milosz Wasilewski <milosz.wasilewski@linaro.org> | 2015-02-26 09:20:20 +0000 |
commit | 450cb6ed9d9d6d615f9a828e73e66658cddb1b5a (patch) | |
tree | 0d02fb7faf04cc8bc7f3f2f74b9274487848763d /common | |
parent | 502e9259edabcedcdce5d29448c77ed0bfaac54f (diff) |
fix PEP8 issues in python scripts
Change-Id: I4635323eb8fb2ed852ca5e4ab3cbedf866e1269a
Diffstat (limited to 'common')
-rwxr-xr-x | common/scripts/fwts-parser.py | 12 | ||||
-rwxr-xr-x | common/scripts/ltp-realtime2LAVA.py | 88 | ||||
-rwxr-xr-x | common/scripts/min_max_avg_parse.py | 12 | ||||
-rwxr-xr-x | common/scripts/netperf2LAVA.py | 14 |
4 files changed, 79 insertions, 47 deletions
diff --git a/common/scripts/fwts-parser.py b/common/scripts/fwts-parser.py index bc20133..ce26484 100755 --- a/common/scripts/fwts-parser.py +++ b/common/scripts/fwts-parser.py @@ -3,12 +3,12 @@ import re import sys -RESULT_MAP = { 'PAS': 'pass', - 'FAL': 'fail', - 'SKP': 'skip', - 'ABT': 'fail', - 'WRN': 'fail', - 'ERR': 'fail' } +RESULT_MAP = {'PAS': 'pass', + 'FAL': 'fail', + 'SKP': 'skip', + 'ABT': 'fail', + 'WRN': 'fail', + 'ERR': 'fail'} line = re.compile("(?P<owner>[a-z_]+)\\s*-(?P<field>[A-Z]+):(?P<content>.*)") header = re.compile("(?P<gowner>[a-z]+):\\s(?P<group_name>[ ()a-zA-Z-_]+)") result = re.compile("(?P<r>.*):\\s(?P<test_name>Test [0-9]),\\s(?P<comment>.*)") diff --git a/common/scripts/ltp-realtime2LAVA.py b/common/scripts/ltp-realtime2LAVA.py index f5f41fa..77e479f 100755 --- a/common/scripts/ltp-realtime2LAVA.py +++ b/common/scripts/ltp-realtime2LAVA.py @@ -3,15 +3,16 @@ import re import sys import fileinput -#extract a standard results block from the stream -def standard_results (): + +# extract a standard results block from the stream +def standard_results(): minimum = re.compile("^Min:\s+(?P<min>[\d\.]+)\s+(?P<units>\w+)") maximum = re.compile("^Max:\s+(?P<max>[\d\.]+)\s+(?P<units>\w+)") average = re.compile("^Avg:\s+(?P<average>[\d\.]+)\s+(?P<units>\w+)") standarddev = re.compile("^StdDev:\s+(?P<stddev>[\d\.]+)\s+(?P<units>\w+)") - finished=0 + finished = 0 for line in sys.stdin: - for parser in [maximum,minimum,average,standarddev]: + for parser in [maximum, minimum, average, standarddev]: result = parser.search(line) if result is not None: if parser is minimum: @@ -40,15 +41,16 @@ def standard_results (): break else: continue - if finished ==4: - return + if finished == 4: + return print "ERROR: Parser failed and ran to EOF" sys.exit(-1) -def result_results (): + +def result_results(): results = re.compile("Result:\s+(?P<result>\w+)") - finished=0 + finished = 0 for line in sys.stdin: for parser in [results]: result = parser.search(line) @@ -60,16 +62,16 @@ def result_results (): break else: continue - if finished ==1: - return + if finished == 1: + return print "ERROR: Parser failed and ran to EOF" sys.exit(-1) -def sched_jitter_results (): +def sched_jitter_results(): maximum = re.compile("^max jitter:\s+(?P<max>[\d\.]+)\s+(?P<units>\w+)") - finished=0 + finished = 0 for line in sys.stdin: for parser in [maximum]: result = parser.search(line) @@ -82,21 +84,22 @@ def sched_jitter_results (): break else: continue - if finished ==1: - #print "min:%s max:%s avg:%s stddev:%s" % (test_min, test_max, test_avg, test_stddev) - return + if finished == 1: + # print "min:%s max:%s avg:%s stddev:%s" % (test_min, test_max, test_avg, test_stddev) + return print "ERROR: Parser failed and ran to EOF" sys.exit(-1) -def pi_perf_results (): + +def pi_perf_results(): minimum = re.compile("^Min delay =\s+(?P<min>[\d\.]+)\s+(?P<units>\w+)") maximum = re.compile("^Max delay =\s+(?P<max>[\d\.]+)\s+(?P<units>\w+)") average = re.compile("^Average delay =\s+(?P<average>[\d\.]+)\s+(?P<units>\w+)") standarddev = re.compile("^Standard Deviation =\s+(?P<stddev>[\d\.]+)\s+(?P<units>\w+)") - finished=0 + finished = 0 for line in sys.stdin: - for parser in [maximum,minimum,average,standarddev]: + for parser in [maximum, minimum, average, standarddev]: result = parser.search(line) if result is not None: if parser is minimum: @@ -125,65 +128,95 @@ def pi_perf_results (): break else: continue - if finished ==4: - return + if finished == 4: + return print "ERROR: Parser failed and ran to EOF" sys.exit(-1) -def do_nothing (): + +def do_nothing(): return -#names of the test parsed out fo the input stream, converted to functioncalls + +# names of the test parsed out fo the input stream, converted to functioncalls def async_handler(): standard_results() result_results() + + def tc_2(): result_results() + + def gtod_latency(): standard_results() + + def periodic_cpu_load_single(): standard_results() + + def sched_latency(): standard_results() + + def sched_jitter(): sched_jitter_results() + + def sched_football(): result_results() + + def rt_migrate(): result_results() + + def pthread_kill_latency(): standard_results() result_results() + + def prio_wake(): result_results() + + def pi_perf(): pi_perf_results() + + def prio_preempt(): result_results() + + def matrix_mult(): result_results() + + def periodic_cpu_load(): result_results() + + def async_handler_jk(): result_results() -#Parse the input stream and tuen test names into function calls to parse their -#details +# Parse the input stream and tuen test names into function calls to parse their +# details test_start = re.compile("--- Running testcase (?P<name>[a-zA-Z0-9_-]+)\s+(?P<args>[a-zA-Z0-9_.\- ]*?)\s*---") test_finish = re.compile("The .* test appears to have completed.") for line in sys.stdin: - for parser in [test_start,test_finish]: + for parser in [test_start, test_finish]: result = parser.search(line) if result is not None: if parser is test_start: test_name = result.group('name') func_name = result.group('name') - func_name = func_name.replace("-","_") + func_name = func_name.replace("-", "_") test_args = result.group('args') - test_args = test_args.replace(" ","-") + test_args = test_args.replace(" ", "-") print print " test_start= " + test_name + test_args globals()[func_name]() @@ -194,4 +227,3 @@ for line in sys.stdin: break else: continue - diff --git a/common/scripts/min_max_avg_parse.py b/common/scripts/min_max_avg_parse.py index 1735e34..543fe40 100755 --- a/common/scripts/min_max_avg_parse.py +++ b/common/scripts/min_max_avg_parse.py @@ -6,7 +6,7 @@ from numpy import * values = [] -r = re.compile(sys.argv[2]+"\s+(?P<measurement>[0-9.]+)") +r = re.compile(sys.argv[2] + "\s+(?P<measurement>[0-9.]+)") f = open(sys.argv[1], "r") for line in f.readlines(): search = r.search(line) @@ -23,8 +23,8 @@ else: np_array = array(values) format = "%-16s%-16s%-16s%-16s" -print format % (sys.argv[1].split('.', 1)[0]+cmd_options+"_min:", str(min(np_array)), sys.argv[3], "pass") -print format % (sys.argv[1].split('.', 1)[0]+cmd_options+"_max:", str(max(np_array)), sys.argv[3], "pass") -print format % (sys.argv[1].split('.', 1)[0]+cmd_options+"_avg:", str(mean(np_array)), sys.argv[3], "pass") -print format % (sys.argv[1].split('.', 1)[0]+cmd_options+"_mdn:", str(median(np_array)), sys.argv[3], "pass") -print format % (sys.argv[1].split('.', 1)[0]+cmd_options+"_std:", str(std(np_array)), sys.argv[3], "pass") +print format % (sys.argv[1].split('.', 1)[0] + cmd_options + "_min:", str(min(np_array)), sys.argv[3], "pass") +print format % (sys.argv[1].split('.', 1)[0] + cmd_options + "_max:", str(max(np_array)), sys.argv[3], "pass") +print format % (sys.argv[1].split('.', 1)[0] + cmd_options + "_avg:", str(mean(np_array)), sys.argv[3], "pass") +print format % (sys.argv[1].split('.', 1)[0] + cmd_options + "_mdn:", str(median(np_array)), sys.argv[3], "pass") +print format % (sys.argv[1].split('.', 1)[0] + cmd_options + "_std:", str(std(np_array)), sys.argv[3], "pass") diff --git a/common/scripts/netperf2LAVA.py b/common/scripts/netperf2LAVA.py index 2b3f4b3..b2fb4ad 100755 --- a/common/scripts/netperf2LAVA.py +++ b/common/scripts/netperf2LAVA.py @@ -2,13 +2,13 @@ import re import sys -#Parse netperf/ping/tcpreplay results looking for the data in the form of -#line = "Actual: 113000 packets (7810000 bytes) sent in 4.75 seconds. Rated: 1644210.5 bps, 12.54 Mbps, 23789.47 pps" -#line = "rtt min/avg/max/mdev = 4.037/4.037/4.037/0.000 ms" -#line = "87380 16384 2048 10.00 4289.48 51.12 51.12 3.905 3.905" ./netperf -l 10 -c -C -- -m 2048 -D -#line = "180224 8192 10.00 1654855 0 10845.1 52.60 1.589" ./netperf -t UDP_STREAM -l 10 -c -C -- -m 8192 -D -#line = "180224 10.00 1649348 10809.0 52.60 1.589" rcv side of UDP_STREAM -#line = "16384 87380 1 1 10.00 47469.68 29.84 29.84 25.146 25.146" ./netperf -t TCP_RR -l 10 -c -C -- -r 1,1 +# Parse netperf/ping/tcpreplay results looking for the data in the form of +# line = "Actual: 113000 packets (7810000 bytes) sent in 4.75 seconds. Rated: 1644210.5 bps, 12.54 Mbps, 23789.47 pps" +# line = "rtt min/avg/max/mdev = 4.037/4.037/4.037/0.000 ms" +# line = "87380 16384 2048 10.00 4289.48 51.12 51.12 3.905 3.905" ./netperf -l 10 -c -C -- -m 2048 -D +# line = "180224 8192 10.00 1654855 0 10845.1 52.60 1.589" ./netperf -t UDP_STREAM -l 10 -c -C -- -m 8192 -D +# line = "180224 10.00 1649348 10809.0 52.60 1.589" rcv side of UDP_STREAM +# line = "16384 87380 1 1 10.00 47469.68 29.84 29.84 25.146 25.146" ./netperf -t TCP_RR -l 10 -c -C -- -r 1,1 found_result = "false" parser_replay = re.compile("Rated:\s+(?P<throughput1>\d+\.\d+)\s+\S+\s+(?P<throughput2>\d+\.\d+)\s+\S+\s+(?P<throughput3>\d+\.\d+)") |