summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur She <arthur.she@linaro.org>2015-02-09 12:11:41 +0800
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2015-02-26 09:20:20 +0000
commit450cb6ed9d9d6d615f9a828e73e66658cddb1b5a (patch)
tree0d02fb7faf04cc8bc7f3f2f74b9274487848763d
parent502e9259edabcedcdce5d29448c77ed0bfaac54f (diff)
fix PEP8 issues in python scripts
Change-Id: I4635323eb8fb2ed852ca5e4ab3cbedf866e1269a
-rw-r--r--android/scripts/parse-lat.py4
-rwxr-xr-xcommon/scripts/fwts-parser.py12
-rwxr-xr-xcommon/scripts/ltp-realtime2LAVA.py88
-rwxr-xr-xcommon/scripts/min_max_avg_parse.py12
-rwxr-xr-xcommon/scripts/netperf2LAVA.py14
-rw-r--r--ubuntu/scripts/bootcharttest.py3
-rwxr-xr-xubuntu/scripts/fio-test.py10
-rwxr-xr-xubuntu/scripts/phoronix.py10
-rwxr-xr-xubuntu/scripts/rcutorture.py6
-rwxr-xr-xubuntu/scripts/sata-partition-rw.py11
10 files changed, 113 insertions, 57 deletions
diff --git a/android/scripts/parse-lat.py b/android/scripts/parse-lat.py
index 2ecb011..584ef71 100644
--- a/android/scripts/parse-lat.py
+++ b/android/scripts/parse-lat.py
@@ -11,9 +11,9 @@ if __name__ == '__main__':
usage = "usage: %prog -f <results file> -t <test name>"
parser = OptionParser(usage=usage)
parser.add_option("-f", "--file", dest="filename",
- help="result file", metavar="FILE")
+ help="result file", metavar="FILE")
parser.add_option("-t", "--testcase", dest="testcase",
- help="lava-android-test test name")
+ help="lava-android-test test name")
(options, args) = parser.parse_args()
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+)")
diff --git a/ubuntu/scripts/bootcharttest.py b/ubuntu/scripts/bootcharttest.py
index 31e5527..f5b3d2a 100644
--- a/ubuntu/scripts/bootcharttest.py
+++ b/ubuntu/scripts/bootcharttest.py
@@ -10,11 +10,10 @@ if __name__ == '__main__':
options, args = parser.parse_args(argv)
writer = main._mk_writer(options)
res = parsing.parse(writer, args, options.prune, options.crop_after, options.annotate)
- duration = float(res[3].duration)/100
+ duration = float(res[3].duration) / 100
print res[0]['title']
print "uname:", res[0]['system.uname']
print "release:", res[0]['system.release']
print "CPU:", res[0]['system.cpu']
print "kernel options:", res[0]['system.kernel.options']
print "time:", duration
-
diff --git a/ubuntu/scripts/fio-test.py b/ubuntu/scripts/fio-test.py
index c64797e..d8df998 100755
--- a/ubuntu/scripts/fio-test.py
+++ b/ubuntu/scripts/fio-test.py
@@ -34,6 +34,7 @@ print os.getcwd()
commands.getstatusoutput("sudo fdisk -l > partition_layout.txt 2>&1")
device_name = sys.argv[1]
+
def fio_device_existence():
testcase_name = "fio_target_device_existence"
if sys.argv[1] == "":
@@ -54,6 +55,7 @@ def fio_device_existence():
print testcase_name + ": FAIL" + " 0" + " Inapplicable" + " - Could not locate " + sys.argv[1] + " on target board"
sys.exit(1)
+
def fio_existence():
testcase_name = "fio_binary_existence"
run_command = "which fio"
@@ -67,6 +69,7 @@ def fio_existence():
print "The FIO binary location is: " + fio_binary_location[1]
print testcase_name + ": PASS" + " 0" + " Inapplicable"
+
def fio_read():
testcase_name = "fio_bs4kread_iops"
run_command = "sudo fio -filename=" + device_name + " -rw=read -direct=1 -iodepth 1 -thread -ioengine=psync -bs=4k -numjobs=1 -runtime=10 -group_reporting -name=fio_read > fio_read.txt 2>&1"
@@ -97,6 +100,7 @@ def fio_read():
logfile.close()
print testcase_name + ": PASS" + " " + iops_result + " " + "IOPS"
+
def fio_randread():
testcase_name = "fio_randread_iops"
run_command = "sudo fio -filename=" + device_name + " -rw=randread -direct=1 -iodepth 1 -thread -ioengine=psync -bs=4k -numjobs=1 -runtime=10 -group_reporting -name=fio_randread > fio_randread.txt 2>&1"
@@ -127,6 +131,7 @@ def fio_randread():
logfile.close()
print testcase_name + ": PASS" + " " + iops_result + " " + "IOPS"
+
def fio_write():
testcase_name = "fio_write_iops"
run_command = "sudo fio -filename=" + device_name + " -rw=write -direct=1 -iodepth 1 -thread -ioengine=psync -bs=4k -numjobs=1 -runtime=10 -group_reporting -name=fio_write > fio_write.txt 2>&1"
@@ -157,6 +162,7 @@ def fio_write():
logfile.close()
print testcase_name + ": PASS" + " " + iops_result + " " + "IOPS"
+
def fio_randwrite():
testcase_name = "fio_randwrite_iops"
run_command = "sudo fio -filename=" + device_name + " -rw=randwrite -direct=1 -iodepth 1 -thread -ioengine=psync -bs=4k -numjobs=1 -runtime=10 -group_reporting -name=fio_randwrite > fio_randwrite.txt 2>&1"
@@ -187,6 +193,7 @@ def fio_randwrite():
logfile.close()
print testcase_name + ": PASS" + " " + iops_result + " " + "IOPS"
+
def fio_512k_write():
testcase_name = "fio_512k_write_bandwidth"
run_command = "sudo fio -filename=" + device_name + " -rw=write -direct=1 -iodepth 1 -thread -ioengine=psync -bs=512k -numjobs=1 -runtime=10 -group_reporting -name=fio_512k_write > fio_512k_write.txt 2>&1"
@@ -218,6 +225,7 @@ def fio_512k_write():
logfile.close()
print testcase_name + ": PASS" + " " + bandwidth_number + " " + "KB/s"
+
def fio_512k_read():
testcase_name = "fio_512k_read_bandwidth"
run_command = "sudo fio -filename=" + device_name + " -rw=read -direct=1 -iodepth 1 -thread -ioengine=psync -bs=512k -numjobs=1 -runtime=10 -group_reporting -name=fio_512k_read > fio_512k_read.txt 2>&1"
@@ -257,4 +265,4 @@ fio_randread()
fio_write()
fio_randwrite()
fio_512k_write()
-fio_512k_read() \ No newline at end of file
+fio_512k_read()
diff --git a/ubuntu/scripts/phoronix.py b/ubuntu/scripts/phoronix.py
index a2fa34c..3b7c174 100755
--- a/ubuntu/scripts/phoronix.py
+++ b/ubuntu/scripts/phoronix.py
@@ -32,18 +32,22 @@ print os.getcwd()
# Result collection for LAVA
debug_switcher = False
+
+
def collect_result(testcase, result):
- if debug_switcher == False:
+ if debug_switcher is False:
call(['lava-test-case', testcase, '--result', result])
else:
print ['lava-test-case', testcase, '--result', result]
+
def collect_score_with_measurement(testcase, result, score, unit):
- if debug_switcher == False:
+ if debug_switcher is False:
call(['lava-test-case', testcase, '--result', result, '--measurement', str(score), '--units', unit])
else:
print ['lava-test-case', testcase, '--result', result, '--measurement', str(score), '--units', unit]
+
# Installation check
def phoronix_install_check():
testcase = 'phoronix-install'
@@ -96,7 +100,7 @@ call(['cat', home_path + '/.phoronix-test-suite/user-config.xml'])
# Get all Ethernet interface name
# As the input is trusted, then call the function in this way
-eth_interface_list = check_output("ifconfig -a | grep eth | awk '{print $1}'", shell=True).split('\n')
+eth_interface_list = check_output("ifconfig -a | grep eth | awk '{print $1}'", shell=True).split('\n')
eth_interface_list = filter(None, eth_interface_list)
print eth_interface_list
diff --git a/ubuntu/scripts/rcutorture.py b/ubuntu/scripts/rcutorture.py
index 9e16c3b..6b7d6ac 100755
--- a/ubuntu/scripts/rcutorture.py
+++ b/ubuntu/scripts/rcutorture.py
@@ -28,8 +28,10 @@ import subprocess
# Result collection for LAVA
debug_switcher = False
+
+
def collect_result(testcase, result):
- if debug_switcher == False:
+ if debug_switcher is False:
subprocess.call(['lava-test-case', testcase, '--result', result])
else:
print ['lava-test-case', testcase, '--result', result]
@@ -57,7 +59,7 @@ else:
lsmod_output = subprocess.check_output(['lsmod'])
print lsmod_output
lsmod_list = lsmod_output.split()
-torture_list = filter(lambda x:x.find('torture')!=-1, lsmod_list)
+torture_list = filter(lambda x: x.find('torture') != -1, lsmod_list)
if torture_list == []:
print 'Cannot find rcutorture module in lsmod, abort!'
collect_result('rcutorture-module-check', 'fail')
diff --git a/ubuntu/scripts/sata-partition-rw.py b/ubuntu/scripts/sata-partition-rw.py
index c772538..64ae6b7 100755
--- a/ubuntu/scripts/sata-partition-rw.py
+++ b/ubuntu/scripts/sata-partition-rw.py
@@ -36,6 +36,7 @@ print os.getcwd()
test_case_list = ["sata_device_existence", "sata_mklabel_msdos", "sata_mklabel_gpt", "sata_first_ext2_partition", "sata_second_ext2_partition", "sata_ext3_format", "sata_ext4_format", "sata_ext4_mount", "sata_ext4_umount", "sata_ext4_file_fill", "sata_ext4_file_edit", "sata_ext4_dd_write", "sata_ext4_dd_read"]
print "There are " + str(len(test_case_list)) + " test cases in this test suite."
+
# All skipped - If test case sata_device_existence failed, then skip all the rest.
def all_skipped():
for element in test_case_list[1:]:
@@ -45,6 +46,7 @@ def all_skipped():
commands.getstatusoutput("fdisk -l > partition_layout.txt 2>&1")
device_name = sys.argv[1]
+
def sata_device_existence():
testcase_name = "sata_device_existence"
if device_name == "":
@@ -67,6 +69,7 @@ def sata_device_existence():
all_skipped()
sys.exit(1)
+
def sata_mklabel_msdos():
testcase_name = "sata_mklabel_msdos"
label_name = "msdos"
@@ -92,6 +95,7 @@ def sata_mklabel_msdos():
else:
print testcase_name + ": FAIL" + " 0" + " Inapplicable" + " - Could not find partition table " + label_name + " on " + device_name
+
def sata_mklabel_gpt():
testcase_name = "sata_mklabel_gpt"
label_name = "gpt"
@@ -117,6 +121,7 @@ def sata_mklabel_gpt():
else:
print testcase_name + ": FAIL" + " 0" + " Inapplicable" + " - Could not find partition table " + label_name + " on " + device_name
+
def sata_first_ext2_partition():
testcase_name = "sata_first_ext2_partition"
label_name = "msdos"
@@ -149,6 +154,7 @@ def sata_first_ext2_partition():
else:
print testcase_name + ": FAIL" + " 0" + " Inapplicable" + " - Could not find partition " + partition_name_first + " on " + device_name
+
def sata_second_ext2_partition():
testcase_name = "sata_second_ext2_partition"
second_partition_creation = "parted -s " + device_name + " mkpart primary ext2 11% 20%"
@@ -174,6 +180,7 @@ def sata_second_ext2_partition():
else:
print testcase_name + ": FAIL" + " 0" + " Inapplicable" + " - Could not find partition " + partition_name_second + " on " + device_name
+
def sata_ext3_format():
testcase_name = "sata_ext3_format"
target_partition_name = device_name + "1"
@@ -199,6 +206,7 @@ def sata_ext3_format():
else:
print testcase_name + ": FAIL" + " 0" + " Inapplicable" + " - Could not find ext3 partition on " + device_name
+
def sata_ext4_format():
testcase_name = "sata_ext4_format"
target_partition_name = device_name + "2"
@@ -224,6 +232,7 @@ def sata_ext4_format():
else:
print testcase_name + ": FAIL" + " 0" + " Inapplicable" + " - Could not find ext4 partition on " + device_name
+
def sata_ext4_mount_umount():
testcase_mount = "sata_ext4_mount"
testcase_umount = "sata_ext4_umount"
@@ -276,6 +285,7 @@ def sata_ext4_mount_umount():
else:
print testcase_umount + ": PASS" + " 0" + " Inapplicable"
+
def sata_ext4_file_fill_edit():
testcase_filefill = "sata_ext4_file_fill"
testcase_fileedit = "sata_ext4_file_edit"
@@ -335,6 +345,7 @@ def sata_ext4_file_fill_edit():
time.sleep(5)
print "mount point cleaned!"
+
def sata_ext4_dd_write_read():
testcase_dd_write = "sata_ext4_dd_write"
testcase_dd_read = "sata_ext4_dd_read"