From 4181b54bfd08a767301100b8a6f94fcf5fbf751c Mon Sep 17 00:00:00 2001 From: Lucas Meneghel Rodrigues Date: Mon, 9 Sep 2013 21:18:05 -0300 Subject: [PATCH] PEP8 mass fixes With the help of the PEP8 script, a semi-automated clean of the code base was made, and effectively changing some of the coding style rules of our code base: * No more 2 lines spacing among functions * No more combined module imports In the end, it was going to be too difficult to take into consideration E501 (line length > 80) errors and W601 (.has_key() is deprecated), so these were ignored, at least for now. Signed-off-by: Lucas Meneghel Rodrigues --- aborttest/aborttest.py | 1 + aio_dio_bugs/aio_dio_bugs.py | 11 ++-- aiostress/aiostress.py | 13 ++-- asynctest/asynctest.py | 9 ++- autotest_regression/autotest_regression.py | 5 +- barriertest/barriertest.py | 4 +- bash_shared_mapping/bash_shared_mapping.py | 16 ++--- bonnie/bonnie.py | 15 +++-- btreplay/btreplay.py | 32 +++++----- cgroup/cgroup.py | 48 ++++++++------- cgroup/cgroup_client.py | 13 ++-- cgroup_tests/cgroup_tests.py | 4 +- cgroup_tests/cpu_high_load_test.py | 27 +++++---- cgroup_tests/device_rate_test.py | 12 ++-- cgroup_tests/memory_migrate_test.py | 21 ++++--- check_patch.py | 60 ++++++++----------- compilebench/compilebench.py | 17 +++--- connectathon/connectathon.py | 10 ++-- cpu_hotplug/cpu_hotplug.py | 15 +++-- cpuflags/cpuflags.py | 10 ++-- ctcs/ctcs.py | 9 +-- cyclictest/cyclictest.py | 4 +- dacapo/dacapo.py | 10 ++-- dbench/dbench.py | 9 ++- dbt2/dbt2.py | 22 +++---- disktest/disktest.py | 18 +++--- dma_memtest/dma_memtest.py | 15 +++-- ebizzy/ebizzy.py | 5 +- error_cleanup/error_cleanup.py | 3 +- error_initialize/error_initialize.py | 3 +- error_setup/error_setup.py | 2 +- error_test_bug/error_test_bug.py | 2 +- error_test_error/error_test_error.py | 2 +- error_test_fail/error_test_fail.py | 2 +- error_test_na/error_test_na.py | 2 +- ffsb/ffsb.py | 45 +++++++------- fio/fio.py | 9 ++- flail/flail.py | 7 +-- fs_mark/fs_mark.py | 8 +-- fsfuzzer/fsfuzzer.py | 6 +- fsstress/fsstress.py | 6 +- fsx/fsx.py | 10 ++-- hackbench/hackbench.py | 5 +- hwclock/hwclock.py | 6 +- interbench/interbench.py | 6 +- iosched_bugs/iosched_bugs.py | 5 +- iozone/common.py | 3 +- iozone/iozone.py | 19 +++--- iozone/postprocessing.py | 34 +++++------ iperf/iperf.py | 37 ++++++------ ipv6connect/ipv6connect.py | 7 +-- isic/isic.py | 7 +-- kernbench/kernbench.py | 20 +++---- kernelbuild/kernelbuild.py | 2 +- kernelinstall/kernelinstall.py | 15 ++--- libhugetlbfs/libhugetlbfs.py | 7 ++- libvirt_tck/libvirt_tck.py | 6 +- libvirt_test_api/libvirt_test_api.py | 12 ++-- linus_stress/linus_stress.py | 8 +-- lmbench/lmbench.py | 5 +- ltp/ltp-diff.py | 21 ++++--- ltp/ltp.py | 10 ++-- lvsetup/lvsetup.py | 9 +-- memory_api/memory_api.py | 37 ++++++------ monotonic_time/monotonic_time.py | 9 +-- netperf2/netperf2.py | 36 +++++------ netpipe/netpipe.py | 16 ++--- npb/npb.py | 17 +++--- parallel_dd/parallel_dd.py | 34 +++++------ perfmon/perfmon.py | 11 ++-- pi_tests/pi_tests.py | 6 +- pktgen/pktgen.py | 18 +++--- posixtest/posixtest.py | 5 +- profiler_sync/profiler_sync.py | 2 +- profiler_test/profiler_test.py | 2 - qemu_iotests/qemu_iotests.py | 10 ++-- reaim/reaim.py | 18 +++--- real_time_tests/real_time_tests.py | 5 +- regression/regression.py | 21 +++---- reindent.py | 35 +++++++---- rmaptest/rmaptest.py | 7 +-- rtc/rtc.py | 3 +- rttester/rttester.py | 2 +- run_pylint.py | 11 +++- scrashme/scrashme.py | 5 +- scsi_testsuite/scsi_testsuite.py | 49 +++++++-------- selftest/selftest.py | 8 ++- signaltest/signaltest.py | 4 +- sleeptest/sleeptest.py | 1 + smatch/smatch.py | 15 +++-- sparse/sparse.py | 13 ++-- spew/spew.py | 8 +-- stress/stress.py | 7 +-- synctest/synctest.py | 2 - sysbench/sysbench.py | 47 +++++++-------- systemtap/systemtap.py | 12 ++-- tbench/tbench.py | 14 ++--- tiobench/tiobench.py | 9 ++- tracing_microbenchmark/base_tracer.py | 6 ++ .../tracing_microbenchmark.py | 1 + tsc/tsc.py | 39 ++++++------ unixbench/unixbench.py | 12 ++-- unixbench5/unixbench5.py | 12 ++-- wb_kupdate/common.py | 3 +- wb_kupdate/wb_kupdate.py | 24 +++----- wb_kupdate/wb_kupdate_unittest.py | 15 +++-- xfstests/xfstests.py | 11 ++-- xmtest/xmtest.py | 6 +- 108 files changed, 702 insertions(+), 712 deletions(-) diff --git a/aborttest/aborttest.py b/aborttest/aborttest.py index d6c7bf887..e0c25f742 100644 --- a/aborttest/aborttest.py +++ b/aborttest/aborttest.py @@ -1,6 +1,7 @@ from autotest.client.shared import error from autotest.client import test + class aborttest(test.test): version = 1 diff --git a/aio_dio_bugs/aio_dio_bugs.py b/aio_dio_bugs/aio_dio_bugs.py index a7634dcad..4773bec83 100644 --- a/aio_dio_bugs/aio_dio_bugs.py +++ b/aio_dio_bugs/aio_dio_bugs.py @@ -8,10 +8,11 @@ ["aio-free-ring-with-bogus-nr-pages", ""], ["aio-io-setup-with-nonwritable-context-pointer", ""], ["aio-dio-extend-stat", "file"], - ] + ] name = 0 arglist = 1 + class aio_dio_bugs(test.test): version = 5 preserve_srcdir = True @@ -23,19 +24,17 @@ def initialize(self): cflags = '-I ' + self.autodir + '/deps/libaio/include' self.gcc_flags = ldflags + ' ' + cflags - def setup(self): os.chdir(self.srcdir) utils.make('"CFLAGS=' + self.gcc_flags + '"') - - def execute(self, args = ''): + def execute(self, args=''): os.chdir(self.tmpdir) libs = self.autodir + '/deps/libaio/lib/' ld_path = utils.prepend_path(libs, - utils.environ('LD_LIBRARY_PATH')) + utils.environ('LD_LIBRARY_PATH')) var_ld_path = 'LD_LIBRARY_PATH=' + ld_path for test in tests: cmd = self.srcdir + '/' + test[name] + ' ' + args + ' ' \ - + test[arglist] + + test[arglist] utils.system(var_ld_path + ' ' + cmd) diff --git a/aiostress/aiostress.py b/aiostress/aiostress.py index 1061597d5..ec7d059ae 100644 --- a/aiostress/aiostress.py +++ b/aiostress/aiostress.py @@ -14,23 +14,21 @@ def initialize(self): cflags = '-I ' + self.autodir + '/deps/libaio/include' self.gcc_flags = ldflags + ' ' + cflags - # ftp://ftp.suse.com/pub/people/mason/utils/aio-stress.c - def setup(self, tarball = None): + def setup(self, tarball=None): if not os.path.exists(self.srcdir): os.mkdir(self.srcdir) os.chdir(self.srcdir) - utils.system('cp ' + self.bindir+'/aio-stress.c .') + utils.system('cp ' + self.bindir + '/aio-stress.c .') self.gcc_flags += ' -Wall -lpthread -laio' cmd = 'gcc ' + self.gcc_flags + ' aio-stress.c -o aio-stress' utils.system(cmd) - - def run_once(self, args = ''): + def run_once(self, args=''): os.chdir(self.tmpdir) - libs = self.autodir+'/deps/libaio/lib/' + libs = self.autodir + '/deps/libaio/lib/' ld_path = utils.prepend_path(libs, - utils.environ('LD_LIBRARY_PATH')) + utils.environ('LD_LIBRARY_PATH')) var_ld_path = 'LD_LIBRARY_PATH=' + ld_path cmd = self.srcdir + '/aio-stress ' + args + ' poo' @@ -39,7 +37,6 @@ def run_once(self, args = ''): report = open(stderr) self.format_results(report) - def format_results(self, report): for line in report: if 'threads' in line: diff --git a/asynctest/asynctest.py b/asynctest/asynctest.py index d2d62db2c..6391a4583 100644 --- a/asynctest/asynctest.py +++ b/asynctest/asynctest.py @@ -1,12 +1,15 @@ -import os, re, time +import os +import re +import time from autotest.client import utils, test + class asynctest(test.test): version = 1 def run_once(self): - #We create 2 processes to show that progress continues on each independently + # We create 2 processes to show that progress continues on each independently x = utils.AsyncJob("sleep 1 && echo hi && sleep 1 && echo hi && sleep 1 && echo hi && sleep 1") y = utils.AsyncJob("sleep 100") time.sleep(2) @@ -16,4 +19,4 @@ def run_once(self): t = time.time() y.wait_for(timeout=1) - print "Process 2 took %d to be killed" % (time.time()-t) + print "Process 2 took %d to be killed" % (time.time() - t) diff --git a/autotest_regression/autotest_regression.py b/autotest_regression/autotest_regression.py index 1a9d0ebd0..a4338efb4 100644 --- a/autotest_regression/autotest_regression.py +++ b/autotest_regression/autotest_regression.py @@ -1,9 +1,12 @@ -import logging, os +import logging +import os from autotest.client import test, utils from autotest.client.shared import git, error + class autotest_regression(test.test): version = 1 + @error.context_aware def run_once(self, uri='git://github.com/autotest/autotest.git', branch='next', commit=None, base_uri=None): diff --git a/barriertest/barriertest.py b/barriertest/barriertest.py index bfe237590..781b87be3 100644 --- a/barriertest/barriertest.py +++ b/barriertest/barriertest.py @@ -1,6 +1,7 @@ # This is used directly by server/tests/barriertest/control.srv -import logging, time +import logging +import time from autotest.client import test from autotest.client.shared import barrier, error @@ -8,7 +9,6 @@ class barriertest(test.test): version = 2 - def run_once(self, our_addr, hostnames, master, timeout=120): # A reusable local server as we're using multiple barriers in one test. server = barrier.listen_server() diff --git a/bash_shared_mapping/bash_shared_mapping.py b/bash_shared_mapping/bash_shared_mapping.py index f577029af..eca60c3aa 100644 --- a/bash_shared_mapping/bash_shared_mapping.py +++ b/bash_shared_mapping/bash_shared_mapping.py @@ -1,12 +1,14 @@ -import signal, os +import signal +import os from autotest.client import utils, test from autotest.client.shared import utils_memory + class bash_shared_mapping(test.test): version = 3 # http://www.zip.com.au/~akpm/linux/patches/stuff/ext3-tools.tar.gz - def setup(self, tarball = 'ext3-tools.tar.gz'): + def setup(self, tarball='ext3-tools.tar.gz'): self.tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(self.tarball, self.srcdir) @@ -14,12 +16,10 @@ def setup(self, tarball = 'ext3-tools.tar.gz'): utils.system('patch -p1 < %s/makefile.patch' % self.bindir) utils.make('bash-shared-mapping usemem') - def initialize(self): self.job.require_gcc() - - def execute(self, testdir = None, iterations = 10000): + def execute(self, testdir=None, iterations=10000): if not testdir: testdir = self.tmpdir os.chdir(testdir) @@ -33,12 +33,12 @@ def execute(self, testdir = None, iterations = 10000): usemem = os.path.join(self.srcdir, 'usemem') args = ('usemem', '-N', '-m', '%d' % (kilobytes / 1024)) # print_to_tty ('2 x ' + ' '.join(args)) - for i in (0,1): + for i in (0, 1): pid[i] = os.spawnv(os.P_NOWAIT, usemem, args) cmd = "%s/bash-shared-mapping %s %d -t %d -n %d" % \ - (self.srcdir, file, kilobytes, - utils.count_cpus(), iterations) + (self.srcdir, file, kilobytes, + utils.count_cpus(), iterations) os.system(cmd) for i in (0, 1): diff --git a/bonnie/bonnie.py b/bonnie/bonnie.py index e02a63ddf..326830654 100644 --- a/bonnie/bonnie.py +++ b/bonnie/bonnie.py @@ -1,4 +1,5 @@ -import os, re +import os +import re from autotest.client import test, os_dep, utils @@ -10,14 +11,14 @@ def convert_size(values): else: chunk = 0 if size.endswith('G') or size.endswith('g'): - size = int(size[:-1]) * 2**30 + size = int(size[:-1]) * 2 ** 30 else: if size.endswith('M') or size.endswith('m'): size = int(size[:-1]) - size = int(size) * 2**20 + size = int(size) * 2 ** 20 if chunk: if chunk.endswith('K') or chunk.endswith('k'): - chunk = int(chunk[:-1]) * 2**10 + chunk = int(chunk[:-1]) * 2 ** 10 else: chunk = int(chunk) return [size, chunk] @@ -31,7 +32,7 @@ def initialize(self): self.results = [] # http://www.coker.com.au/bonnie++/experimental/bonnie++-1.96.tgz - def setup(self, tarball = 'bonnie++-1.96.tgz'): + def setup(self, tarball='bonnie++-1.96.tgz'): tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) os.chdir(self.srcdir) @@ -40,7 +41,6 @@ def setup(self, tarball = 'bonnie++-1.96.tgz'): utils.configure() utils.make() - def run_once(self, dir=None, extra_args='', user='root'): if not dir: dir = self.tmpdir @@ -53,7 +53,6 @@ def run_once(self, dir=None, extra_args='', user='root'): self.results.append(utils.system_output(cmd, retain_output=True)) - def postprocess(self): strip_plus = lambda s: re.sub(r"^\++$", "0", s) @@ -77,4 +76,4 @@ def postprocess(self): fields = [strip_plus(f) for f in fields] fields = convert_size(fields[1]) + fields[2:] - self.write_perf_keyval(dict(zip(keys,fields))) + self.write_perf_keyval(dict(zip(keys, fields))) diff --git a/btreplay/btreplay.py b/btreplay/btreplay.py index ba9ed734e..49327ad0e 100644 --- a/btreplay/btreplay.py +++ b/btreplay/btreplay.py @@ -1,4 +1,5 @@ -import time, os +import time +import os from autotest.client import test, os_dep, utils from autotest.client.shared import error @@ -7,7 +8,7 @@ class btreplay(test.test): version = 1 # http://brick.kernel.dk/snaps/blktrace-git-latest.tar.gz - def setup(self, tarball = 'blktrace-git-latest.tar.gz'): + def setup(self, tarball='blktrace-git-latest.tar.gz'): tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) @@ -15,7 +16,7 @@ def setup(self, tarball = 'blktrace-git-latest.tar.gz'): libs = '-L' + self.autodir + '/deps/libaio/lib -laio' cflags = '-I ' + self.autodir + '/deps/libaio/include' var_libs = 'LIBS="' + libs + '"' - var_cflags = 'CFLAGS="' + cflags + '"' + var_cflags = 'CFLAGS="' + cflags + '"' self.make_flags = var_libs + ' ' + var_cflags os.chdir(self.srcdir) @@ -23,13 +24,11 @@ def setup(self, tarball = 'blktrace-git-latest.tar.gz'): utils.system('patch -p1 < %s/Makefile.patch' % self.bindir) utils.system(self.make_flags + ' make') - def initialize(self): self.job.require_gcc() - self.ldlib = 'LD_LIBRARY_PATH=%s/deps/libaio/lib'%(self.autodir) + self.ldlib = 'LD_LIBRARY_PATH=%s/deps/libaio/lib' % (self.autodir) self.results = [] - def run_once(self, dev="", devices="", extra_args='', tmpdir=None): # @dev: The device against which the trace will be replayed. # e.g. "sdb" or "md_d1" @@ -59,8 +58,8 @@ def run_once(self, dev="", devices="", extra_args='', tmpdir=None): # time a replay that omits "thinktime" between requests # (by use of the -N flag) - cmd = self.ldlib + " /usr/bin/time ./btreplay/btreplay -d "+\ - tmpdir+" -N -W "+dev+" "+extra_args+" 2>&1" + cmd = self.ldlib + " /usr/bin/time ./btreplay/btreplay -d " +\ + tmpdir + " -N -W " + dev + " " + extra_args + " 2>&1" self.results.append(utils.system_output(cmd, retain_output=True)) # trace a replay that reproduces inter-request delays, and @@ -68,7 +67,7 @@ def run_once(self, dev="", devices="", extra_args='', tmpdir=None): # completion latency utils.system("./blktrace -D %s %s >/dev/null &" % (tmpdir, alldevs)) cmd = self.ldlib + " ./btreplay/btreplay -d %s -W %s %s" %\ - (tmpdir, dev, extra_args) + (tmpdir, dev, extra_args) self.results.append(utils.system_output(cmd, retain_output=True)) utils.system("killall -INT blktrace") @@ -86,23 +85,22 @@ def run_once(self, dev="", devices="", extra_args='', tmpdir=None): cmd = "./btt/btt -i %s/trace.bin" % tmpdir self.results.append(utils.system_output(cmd, retain_output=True)) - def postprocess(self): for n in range(len(self.results)): if self.results[n].strip() == "==================== All Devices ====================": - words = self.results[n-2].split() + words = self.results[n - 2].split() s = words[1].strip('sytem').split(':') e = words[2].strip('elapsd').split(':') break systime = 0.0 for n in range(len(s)): - i = (len(s)-1) - n - systime += float(s[i]) * (60**n) + i = (len(s) - 1) - n + systime += float(s[i]) * (60 ** n) elapsed = 0.0 for n in range(len(e)): - i = (len(e)-1) - n - elapsed += float(e[i]) * (60**n) + i = (len(e) - 1) - n + elapsed += float(e[i]) * (60 ** n) q2c = 0.0 for line in self.results: @@ -113,5 +111,5 @@ def postprocess(self): q2c = float(words[2]) break - self.write_perf_keyval({'time':elapsed, 'systime':systime, - 'avg_q2c_latency':q2c}) + self.write_perf_keyval({'time': elapsed, 'systime': systime, + 'avg_q2c_latency': q2c}) diff --git a/cgroup/cgroup.py b/cgroup/cgroup.py index 76fd8d63b..466218656 100755 --- a/cgroup/cgroup.py +++ b/cgroup/cgroup.py @@ -6,7 +6,10 @@ @copyright: 2011 Red Hat Inc. @author: Lukas Doktor """ -import os, sys, logging, time +import os +import sys +import logging +import time from tempfile import NamedTemporaryFile from subprocess import Popen @@ -22,6 +25,7 @@ class cgroup(test.test): + """ Tests the cgroup functionalities. It works by creating a process (which is also a python application) that will try to use CPU and memory. We will @@ -87,9 +91,9 @@ def cleanup(self): logging.debug('cgroup_test cleanup') del (self.modules) - ############################# + # # TESTS - ############################# + # def test_memory(self): """ Memory test @@ -150,10 +154,10 @@ def cleanup(suppress=False): dir="/tmp") logging.debug("test_memory: Initializition passed") - ################################################ + # # Fill the memory without cgroup limitation # Should pass - ################################################ + # logging.debug("test_memory: Memfill WO cgroup") ps = item.test("memfill %d %s" % (mem, outf.name)) ps.stdin.write('\n') @@ -177,11 +181,11 @@ def cleanup(suppress=False): "(WO cgroup)") logging.debug("test_memory: Memfill WO cgroup passed") - ################################################ + # # Fill the memory with 1/2 memory limit # memsw: should swap out part of the process and pass # WO memsw: should fail (SIGKILL) - ################################################ + # logging.debug("test_memory: Memfill mem only limit") ps = item.test("memfill %d %s" % (mem, outf.name)) item.set_cgroup(ps.pid, pwd) @@ -201,7 +205,7 @@ def cleanup(suppress=False): out = outf.readlines() if (len(out) < 2): raise error.TestFail("Process failed (mem); output:\n%s" - "\nReturn: %d" % (out, ps.poll())) + "\nReturn: %d" % (out, ps.poll())) if memsw: if not out[-1].startswith("PASS"): logging.error("test_memory: cgroup_client.py returned %d; " @@ -222,11 +226,11 @@ def cleanup(suppress=False): filled) logging.debug("test_memory: Memfill mem only cgroup passed") - ################################################ + # # Fill the memory with 1/2 memory+swap limit # Should fail # (memory.limit_in_bytes have to be set prior to this test) - ################################################ + # if memsw: logging.debug("test_memory: Memfill mem + swap limit") ps = item.test("memfill %d %s" % (mem, outf.name)) @@ -251,7 +255,7 @@ def cleanup(suppress=False): "\nReturn: %d" % (out, ps.poll())) if out[-1].startswith("PASS"): raise error.TestFail("Unexpected memory filling (memsw)", - mem) + mem) else: filled = int(out[-2].split()[1][:-1]) if mem / 2 > 1.5 * filled: @@ -264,9 +268,9 @@ def cleanup(suppress=False): filled) logging.debug("test_memory: Memfill mem + swap cgroup passed") - ################################################ + # # CLEANUP - ################################################ + # cleanup() def test_cpuset(self): @@ -306,7 +310,7 @@ def cleanup(suppress=False): # in cpuset cgroup it's necessarily to set certain values before # usage. Thus smoke_test will fail. - #if item.smoke_test(): + # if item.smoke_test(): # raise error.TestFail("smoke_test failed") try: @@ -327,10 +331,10 @@ def cleanup(suppress=False): raise error.TestFail("Failed to set cpus and mems of" "a new cgroup") - ################################################ + # # Cpu allocation test # Use cpu0 and verify, than all cpu* - cpu0 and verify - ################################################ + # logging.debug("test_cpuset: Cpu allocation test") tasks = [] @@ -375,9 +379,9 @@ def cleanup(suppress=False): % (stat1, stat2)) logging.debug("test_cpuset: Cpu allocation test passed") - ################################################ + # # CLEANUP - ################################################ + # cleanup() def test_cpu(self): @@ -445,14 +449,14 @@ def _stress_cpu(no_cpus): self.item.smoke_test() logging.info("test_cpu: smoke_test passed") - ################################################ + # # test_cpu_many_cgroups # Tests known issue with lots of cgroups in cpu subsystem defined on # large SMP host. # The test creates 10 cgroups, measure go-throught time, than the same # with 110 and 1110 cgroups. # IMPORTANT: Is reproducible only on large SMP > 64 cpus - ################################################ + # no_cpus = utils.count_cpus() if no_cpus < 64: logging.warn("test_cpu_many_cgroups: SKIPPED as it needs >64 " @@ -507,7 +511,7 @@ def _stress_cpu(no_cpus): cleanup() raise error.TestFail("CPU stress %d took over %s-times longer" " than with 10 cgroups" % (i, limits[i])) - ################################################ + # # CLEANUP - ################################################ + # cleanup() diff --git a/cgroup/cgroup_client.py b/cgroup/cgroup_client.py index 189d24fb3..8b770c613 100755 --- a/cgroup/cgroup_client.py +++ b/cgroup/cgroup_client.py @@ -8,9 +8,14 @@ @copyright: 2011 Red Hat Inc. @author: Lukas Doktor """ -import array, sys, time, math, os +import array +import sys +import time +import math +import os from tempfile import mktemp + def test_smoke(args): """ SIGSTOP the process and after SIGCONT exits. @@ -59,7 +64,7 @@ def test_cpu(args): print "TEST: wait for input" raw_input() while True: - for i in range (1000, 10000): + for i in range(1000, 10000): math.factorial(i) @@ -85,7 +90,7 @@ def test_devices_read(): while True: print "TEST: tick" dev.flush() - dev.read(1024*1024) + dev.read(1024 * 1024) time.sleep(1) @@ -99,7 +104,7 @@ def test_devices_write(): dev = open("/dev/null", 'w') buf = "" - for _ in range(1024*1024): + for _ in range(1024 * 1024): buf += '\x00' while True: print "TEST: tick" diff --git a/cgroup_tests/cgroup_tests.py b/cgroup_tests/cgroup_tests.py index be3bb88e4..345662cfd 100644 --- a/cgroup_tests/cgroup_tests.py +++ b/cgroup_tests/cgroup_tests.py @@ -1,14 +1,15 @@ from autotest.client import test from autotest.client.shared import error, utils_cgroup + class cgroup_tests(test.test): + """ Test cgroup sub systems. """ version = 1 _cgroup_dir = "/cgroup" - def run_once(self, item=""): """ Test several subsystems @@ -22,7 +23,6 @@ def run_once(self, item=""): raise error.TestNAError("%s module doesn't exist!" % item) mod.execute(self) - def initialize(self): """ Initialize environment. diff --git a/cgroup_tests/cpu_high_load_test.py b/cgroup_tests/cpu_high_load_test.py index 73b7b4645..3b0a06482 100644 --- a/cgroup_tests/cpu_high_load_test.py +++ b/cgroup_tests/cpu_high_load_test.py @@ -1,6 +1,13 @@ -import os, tempfile, signal, time, threading, stat, logging +import os +import tempfile +import signal +import time +import threading +import stat +import logging from autotest.client.shared import error, utils_cgroup, utils, pexpect + def cpu_use_flle(shell_file): """ Make a shell file to get high load cpu @@ -19,7 +26,7 @@ def cpu_use_flle(shell_file): sh_file = open(shell_file, 'w') sh_file.write(shell_detail) sh_file.close() - os.chmod(shell_file, stat.S_IRWXU|stat.S_IRGRP|stat.S_IROTH) + os.chmod(shell_file, stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH) def get_cpu_rate(pid_list): @@ -102,7 +109,7 @@ def cgconfig_file_modify(cgconfig_file, controller_list, time.sleep(1) dic_controller_property = dic_cgroup_property.get(cgroup) for controller in dic_controller_property: - session.sendline('%s {' % controller) + session.sendline('%s {' % controller) time.sleep(1) dic_property = dic_controller_property.get(controller) if dic_property is None or dic_property == '': @@ -126,6 +133,7 @@ def cgconfig_file_modify(cgconfig_file, controller_list, class CpuHighLoad(object): + """ Test cpu sub system. Use it to control cpu rate. @@ -145,7 +153,6 @@ def __init__(self, cgroup_dir=None, tmpdir="/tmp"): self.cgroup_dir = cgroup_dir self.tmpdir = tmpdir - def test(self): """ Start testing @@ -155,12 +162,12 @@ def test(self): cgroup_name1 = "test1" cgroup_name2 = "test2" cgconfig_file = "/etc/cgconfig.conf" - property_value1 = {"cpu.shares":"500", - "cpuset.cpus":"1", - "cpuset.mems":"0"} - property_value2 = {"cpu.shares":"1000", - "cpuset.cpus":"1", - "cpuset.mems":"0"} + property_value1 = {"cpu.shares": "500", + "cpuset.cpus": "1", + "cpuset.mems": "0"} + property_value2 = {"cpu.shares": "1000", + "cpuset.cpus": "1", + "cpuset.mems": "0"} tmp_file1 = tempfile.NamedTemporaryFile(dir=self.tmpdir).name + ".sh" tmp_file2 = tempfile.NamedTemporaryFile(dir=self.tmpdir).name + ".sh" cpu_use_flle(tmp_file1) diff --git a/cgroup_tests/device_rate_test.py b/cgroup_tests/device_rate_test.py index 8161fb5b8..b3501f344 100644 --- a/cgroup_tests/device_rate_test.py +++ b/cgroup_tests/device_rate_test.py @@ -1,7 +1,11 @@ -import os, itertools, tempfile +import os +import itertools +import tempfile from autotest.client.shared import error, utils_cgroup + class DeviceRate(object): + """ Test cgroup blkio sub system. Use it to control file write/read rate. @@ -20,7 +24,6 @@ def __init__(self, cgroup_dir=None): """ self.cgroup_dir = cgroup_dir - def get_create_rate(self, output): """ Get file create rate by "dd" command output. @@ -35,7 +38,6 @@ def get_create_rate(self, output): except (IndexError, ValueError): return None - def test(self): """ Start testing @@ -48,8 +50,8 @@ def test(self): # file: file write directly. cgset: cgset command set_mode_list = ["file", "cgset"] cgroup_name = "test" - property_value = {'blkio.throttle.read_bps_device':'8:0 1048576', - 'blkio.throttle.write_bps_device':'8:0 524288'} + property_value = {'blkio.throttle.read_bps_device': '8:0 1048576', + 'blkio.throttle.write_bps_device': '8:0 524288'} # Must belong to "8:0"(sda) tmp_file = tempfile.NamedTemporaryFile(dir="/").name file_size = "20M" diff --git a/cgroup_tests/memory_migrate_test.py b/cgroup_tests/memory_migrate_test.py index a41a7f980..f0a2cde18 100644 --- a/cgroup_tests/memory_migrate_test.py +++ b/cgroup_tests/memory_migrate_test.py @@ -1,7 +1,14 @@ -import os, itertools, tempfile, subprocess, signal, time +import os +import itertools +import tempfile +import subprocess +import signal +import time from autotest.client.shared import error, utils_cgroup + class MemoryMigrate(object): + """ Test memory sub system. Use it to control file write/read rate. @@ -22,7 +29,6 @@ def __init__(self, cgroup_dir=None, tmpdir="/tmp"): self.cgroup_dir = cgroup_dir self.tmpdir = tmpdir - def memory_use_flle(self, memory, memory_file, binary_file): """ Make a C file and compile it @@ -46,14 +52,13 @@ def memory_use_flle(self, memory, memory_file, binary_file): try: process = subprocess.Popen(binary_file, shell=True, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) return process.pid except Exception, err: raise error.TestError("Execute malloc process failed!\n" "%s", err) - def test(self): """ Start testing @@ -67,10 +72,10 @@ def test(self): set_mode_list = ["file", "cgset"] cgroup_name1 = "test1" cgroup_name2 = "test2" - property_value1 = {'memory.move_charge_at_immigrate':'0'} - property_value2 = {'memory.move_charge_at_immigrate':'1'} + property_value1 = {'memory.move_charge_at_immigrate': '0'} + property_value2 = {'memory.move_charge_at_immigrate': '1'} get_property = "memory.usage_in_bytes" - memory_use = 10 # M + memory_use = 10 # M tmp_file = tempfile.NamedTemporaryFile(dir=self.tmpdir).name memory_file = tmp_file + ".c" binary_file = tmp_file + ".o" diff --git a/check_patch.py b/check_patch.py index 6b07a2fd3..772fe4531 100755 --- a/check_patch.py +++ b/check_patch.py @@ -22,7 +22,16 @@ @author: Lucas Meneghel Rodrigues """ -import os, stat, logging, sys, optparse, re, urllib, shutil, unittest, tempfile +import os +import stat +import logging +import sys +import optparse +import re +import urllib +import shutil +import unittest +import tempfile try: import autotest.common as common except ImportError: @@ -30,7 +39,8 @@ from autotest.client.shared import utils, error, logging_config from autotest.client.shared import logging_manager -import run_pylint, reindent +import run_pylint +import reindent # Hostname of patchwork server to use PWHOST = "patchwork.virt.bos.redhat.com" @@ -38,17 +48,22 @@ TMP_FILE_DIR = tempfile.gettempdir() LOG_FILE_PATH = os.path.join(TMP_FILE_DIR, 'check-patch.log') + class CheckPatchLoggingConfig(logging_config.LoggingConfig): + def configure_logging(self, results_dir=None, verbose=True): super(CheckPatchLoggingConfig, self).configure_logging( use_console=True, verbose=verbose) self.add_file_handler(file_path=LOG_FILE_PATH) + class VCS(object): + """ Abstraction layer to the version control system. """ + def __init__(self): """ Class constructor. Guesses the version control name and instantiates it @@ -64,7 +79,6 @@ def __init__(self): else: self.backend = None - def guess_vcs_name(self): if os.path.isdir(".svn"): return "SVN" @@ -75,49 +89,42 @@ def guess_vcs_name(self): "on a working directory? Aborting.") sys.exit(1) - def get_unknown_files(self): """ Return a list of files unknown to the VCS. """ return self.backend.get_unknown_files() - def get_modified_files(self): """ Return a list of files that were modified, according to the VCS. """ return self.backend.get_modified_files() - def is_file_tracked(self, fl): """ Return whether a file is tracked by the VCS. """ return self.backend.is_file_tracked(fl) - def add_untracked_file(self, fl): """ Add an untracked file to version control. """ return self.backend.add_untracked_file(file) - def revert_file(self, fl): """ Restore file according to the latest state on the reference repo. """ return self.backend.revert_file(file) - def apply_patch(self, patch): """ Applies a patch using the most appropriate method to the particular VCS. """ return self.backend.apply_patch(patch) - def update(self): """ Updates the tree according to the latest state of the public tree @@ -126,14 +133,15 @@ def update(self): class SubVersionBackend(object): + """ Implementation of a subversion backend for use with the VCS abstraction layer. """ + def __init__(self): self.ignored_extension_list = ['.orig', '.bak'] - def get_unknown_files(self): status = utils.system_output("svn status --ignore-externals") unknown_files = [] @@ -145,7 +153,6 @@ def get_unknown_files(self): unknown_files.append(line[1:].strip()) return unknown_files - def get_modified_files(self): status = utils.system_output("svn status --ignore-externals") modified_files = [] @@ -155,7 +162,6 @@ def get_modified_files(self): modified_files.append(line[1:].strip()) return modified_files - def is_file_tracked(self, fl): stdout = None try: @@ -176,7 +182,6 @@ def is_file_tracked(self, fl): else: return False - def add_untracked_file(self, fl): """ Add an untracked file under revision control. @@ -189,7 +194,6 @@ def add_untracked_file(self, fl): logging.error("Problem adding file %s to svn: %s", fl, e) sys.exit(1) - def revert_file(self, fl): """ Revert file against last revision. @@ -202,7 +206,6 @@ def revert_file(self, fl): logging.error("Problem reverting file %s: %s", fl, e) sys.exit(1) - def apply_patch(self, patch): """ Apply a patch to the code base. Patches are expected to be made using @@ -228,13 +231,14 @@ def update(self): class GitBackend(object): + """ Implementation of a git backend for use with the VCS abstraction layer. """ + def __init__(self): self.ignored_extension_list = ['.orig', '.bak'] - def get_unknown_files(self): status = utils.system_output("git status --porcelain") unknown_files = [] @@ -247,7 +251,6 @@ def get_unknown_files(self): unknown_files.append(line[2:].strip()) return unknown_files - def get_modified_files(self): status = utils.system_output("git status --porcelain") modified_files = [] @@ -258,7 +261,6 @@ def get_modified_files(self): modified_files.append(line[1:].strip()) return modified_files - def is_file_tracked(self, fl): try: utils.run("git ls-files %s --error-unmatch" % fl, @@ -267,7 +269,6 @@ def is_file_tracked(self, fl): except error.CmdError: return False - def add_untracked_file(self, fl): """ Add an untracked file under revision control. @@ -280,7 +281,6 @@ def add_untracked_file(self, fl): logging.error("Problem adding file %s to git: %s", fl, e) sys.exit(1) - def revert_file(self, fl): """ Revert file against last revision. @@ -293,7 +293,6 @@ def revert_file(self, fl): logging.error("Problem reverting file %s: %s", fl, e) sys.exit(1) - def apply_patch(self, patch): """ Apply a patch to the code base using git am. @@ -311,7 +310,6 @@ def apply_patch(self, patch): logging.error("Failed to apply patch to the git repo: %s" % e) sys.exit(1) - def update(self): return try: @@ -321,10 +319,12 @@ def update(self): class FileChecker(object): + """ Picks up a given file and performs various checks, looking after problems and eventually suggesting solutions. """ + def __init__(self, path=None, vcs=None, confirm=False): """ Class constructor, sets the path attribute. @@ -373,14 +373,12 @@ def set_path(self, path, vcs=None, confirm=False): else: self.bkp_path = None - def _get_checked_filename(self): if self.bkp_path is not None: return self.bkp_path else: return self.path - def _check_indent(self): """ Verifies the file with the reindent module @@ -396,7 +394,7 @@ def _check_indent(self): """ success = True for exc in self.indent_exceptions: - if re.search (exc, self.path): + if re.search(exc, self.path): return success path = self._get_checked_filename() @@ -423,7 +421,6 @@ def _check_indent(self): return success - def _check_code(self): """ Verifies the file with run_pylint. @@ -435,7 +432,7 @@ def _check_code(self): """ success = True for exc in self.check_exceptions: - if re.search (exc, self.path): + if re.search(exc, self.path): return success path = self._get_checked_filename() @@ -450,7 +447,6 @@ def _check_code(self): return success - def _check_unittest(self): """ Verifies if the file in question has a unittest suite, if so, run the @@ -485,7 +481,6 @@ def _check_unittest(self): return success - def _check_permissions(self): """ Verifies the execution permissions. @@ -510,7 +505,6 @@ def _check_permissions(self): utils.run("chmod -x %s" % self.path, ignore_status=True) - def report(self, skip_unittest=False): """ Executes all required checks, if problems are found, the possible @@ -534,6 +528,7 @@ def report(self, skip_unittest=False): class PatchChecker(object): + def __init__(self, patch=None, patchwork_id=None, github_id=None, pwhost=None, vcs=None, confirm=False): self.confirm = confirm @@ -575,7 +570,6 @@ def __init__(self, patch=None, patchwork_id=None, github_id=None, self.untracked_files_before = self.vcs.get_unknown_files() self.vcs.update() - def _fetch_from_patchwork(self, pw_id): """ Gets a patch file from patchwork and puts it under the cwd so it can @@ -617,7 +611,6 @@ def _fetch_from_github(self, gh_id): urllib.urlretrieve(patch_url, patch_dest) return patch_dest - def _check_files_modified_patch(self): modified_files_after = [] if self.vcs.type == "subversion": @@ -662,7 +655,6 @@ def _check_files_modified_patch(self): else: return True - def check(self): self.vcs.apply_patch(self.patch) return self._check_files_modified_patch() diff --git a/compilebench/compilebench.py b/compilebench/compilebench.py index 782abf06a..378ffd20e 100644 --- a/compilebench/compilebench.py +++ b/compilebench/compilebench.py @@ -4,37 +4,36 @@ test_name = 'compilebench' + class compilebench(test.test): version = 1 - def setup(self, tarball = 'compilebench-0.6.tar.gz'): + def setup(self, tarball='compilebench-0.6.tar.gz'): self.tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(self.tarball, self.srcdir) os.chdir(self.srcdir) utils.system('patch -p1 < %s/compilebench.patch' % self.bindir) - def run_once(self, dir=None, num_kernel_trees=10, num_random_runs=30): if not dir: dir = self.tmpdir cmd = "%s -D %s -s %s -i %d -r %d" % ( - os.path.join(self.srcdir, test_name), - dir, - self.srcdir, - num_kernel_trees, - num_random_runs) + os.path.join(self.srcdir, test_name), + dir, + self.srcdir, + num_kernel_trees, + num_random_runs) output = utils.system_output(cmd) self.__format_results(output) - def __format_results(self, output): keylist = {} THROUGHPUT = "MB_s" - TIME = "secs" + TIME = "secs" run_type_list = ( ('intial create', THROUGHPUT, 6, 'initial_create'), diff --git a/connectathon/connectathon.py b/connectathon/connectathon.py index 2b235d738..3f2885837 100644 --- a/connectathon/connectathon.py +++ b/connectathon/connectathon.py @@ -1,9 +1,13 @@ -import os, shutil, glob, logging +import os +import shutil +import glob +import logging from autotest.client import test, utils from autotest.client.shared import error class connectathon(test.test): + """ Connectathon test is an nfs testsuite which can run on both BSD and System V based systems. The tests.init file @@ -16,13 +20,13 @@ class connectathon(test.test): @author Poornima.Nayak (Poornima.Nayak@in.ibm.com)(original code) """ version = 1 + def initialize(self): """ Sets the overall failure counter for the test. """ self.nfail = 0 - def setup(self, tarball='connectathon.tar.bz2'): connectathon_tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) @@ -32,7 +36,6 @@ def setup(self, tarball='connectathon.tar.bz2'): utils.system('make clean') utils.system('make') - def run_once(self, testdir=None, args='', cthon_iterations=1): """ Runs the test, with the appropriate control file. @@ -58,7 +61,6 @@ def run_once(self, testdir=None, args='', cthon_iterations=1): self.nfail += 1 logging.error("Test failed: %s", e) - def postprocess(self): """ Raises on failure. diff --git a/cpu_hotplug/cpu_hotplug.py b/cpu_hotplug/cpu_hotplug.py index 54a8feeed..3bd07665f 100644 --- a/cpu_hotplug/cpu_hotplug.py +++ b/cpu_hotplug/cpu_hotplug.py @@ -1,18 +1,22 @@ -import time, os, logging, re, sys +import time +import os +import logging +import re +import sys from autotest.client import test, utils, os_dep from autotest.client.shared import error + class cpu_hotplug(test.test): version = 2 # http://developer.osdl.org/dev/hotplug/tests/lhcs_regression-1.6.tgz - def setup(self, tarball = 'lhcs_regression-1.6.tgz'): + def setup(self, tarball='lhcs_regression-1.6.tgz'): tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) os.chdir(self.srcdir) - utils.run('patch -p1 < %s/0001-LHCS-Cleanups-and-bugfixes.patch' \ - % self.bindir) - + utils.run('patch -p1 < %s/0001-LHCS-Cleanups-and-bugfixes.patch' + % self.bindir) def initialize(self): # Check if the kernel supports cpu hotplug @@ -37,7 +41,6 @@ def initialize(self): utils.system('dmesg -c') time.sleep(3) - def run_once(self): tests_fail = [] tests_pass = [] diff --git a/cpuflags/cpuflags.py b/cpuflags/cpuflags.py index bca4ac085..d8c889d44 100644 --- a/cpuflags/cpuflags.py +++ b/cpuflags/cpuflags.py @@ -4,13 +4,16 @@ @copyright: 2011 Red Hat Inc. @author: Jiri Zupka """ -import os, logging +import os +import logging from autotest.client import test, utils from autotest.client.shared import error from virttest import utils_misc + class cpuflags(test.test): + """ Tests the cpuflags functionality. """ @@ -27,12 +30,12 @@ def setup(self): utils.make() utils.system('sync') - def run_once(self): """ Try to access different resources which are restricted by cgroup. """ logging.info('Starting cpuflags testing') + def check_cpuflags_work(flags): """ Check which flags work. @@ -56,7 +59,6 @@ def check_cpuflags_work(flags): not_tested.append(f) return (pass_Flags, not_working, not_tested) - def run_stress(timeout, flags, smp): """ Run stress on vm for timeout time. @@ -71,11 +73,9 @@ def run_stress(timeout, flags, smp): ret = True return ret - os.chdir(self.srcdir) run_stress(60, set(map(utils_misc.Flag, utils_misc.get_cpu_flags())), 4) - def cleanup(self): """ Cleanup diff --git a/ctcs/ctcs.py b/ctcs/ctcs.py index 5ec513558..9e79a5f35 100644 --- a/ctcs/ctcs.py +++ b/ctcs/ctcs.py @@ -1,9 +1,13 @@ -import os, shutil, glob, logging +import os +import shutil +import glob +import logging from autotest.client import test, utils from autotest.client.shared import error class ctcs(test.test): + """ This autotest module runs CTCS (Cerberus Test Control System), that is being maintained on a new location, since both CTCS and CTCS2 on sourceforge @@ -30,7 +34,6 @@ def initialize(self): """ self.nfail = 0 - def setup(self, tarball='ctcs.tar.bz2', length='4h', tc_opt='-k', tcf_contents=None): """ @@ -72,7 +75,6 @@ def setup(self, tarball='ctcs.tar.bz2', length='4h', tc_opt='-k', buf = tcf.read() logging.debug(buf) - def run_once(self): """ Runs the test, with the appropriate control file. @@ -89,7 +91,6 @@ def run_once(self): dst = os.path.join(self.resultsdir, os.path.basename(log_dir)) shutil.move(log_dir, dst) - def cleanup(self): """ Cleans up source directory and raises on failure. diff --git a/cyclictest/cyclictest.py b/cyclictest/cyclictest.py index 38c131a74..ad5b69fcc 100644 --- a/cyclictest/cyclictest.py +++ b/cyclictest/cyclictest.py @@ -11,11 +11,9 @@ class cyclictest(test.test): def initialize(self): self.job.require_gcc() - def setup(self): os.chdir(self.srcdir) utils.make() - - def execute(self, args = '-t 10 -l 100000'): + def execute(self, args='-t 10 -l 100000'): utils.system(self.srcdir + '/cyclictest ' + args) diff --git a/dacapo/dacapo.py b/dacapo/dacapo.py index 87200e352..8f62c0cad 100644 --- a/dacapo/dacapo.py +++ b/dacapo/dacapo.py @@ -1,10 +1,14 @@ -import os, re, logging, shutil +import os +import re +import logging +import shutil from autotest.client import utils, test from autotest.client.test_config import config_loader from autotest.client.shared import error, software_manager class dacapo(test.test): + """ This autotest module runs the dacapo benchmark suite. @@ -31,7 +35,7 @@ def set_java_environment(self, jvm, java_root): else: java_home = java_root java_bin = os.path.join(java_home, 'bin') - java_lib = os.path.join(java_home, 'lib') + java_lib = os.path.join(java_home, 'lib') os.environ['JAVA_ROOT'] = java_root os.environ['JAVA_HOME'] = java_home os.environ['JRE_HOME'] = java_home @@ -39,7 +43,6 @@ def set_java_environment(self, jvm, java_root): os.environ['JAVA_BINDIR'] = java_bin os.environ['PATH'] = java_bin + ':' + os.environ['PATH'] - def run_once(self, test='antlr', config='./dacapo.cfg', jvm='default'): cfg = config_loader(cfg=config, tmpdir=self.tmpdir, raise_errors=True) self.test = test @@ -92,7 +95,6 @@ def run_once(self, test='antlr', config='./dacapo.cfg', jvm='default'): raise error.TestError('Dacapo benchmark %s has failed: %s' % (test, e)) - def postprocess_iteration(self): result_line = self.results.splitlines()[-1] time_regexp = re.compile('PASSED in (\d+) ms') diff --git a/dbench/dbench.py b/dbench/dbench.py index bfe1a1397..a221fba2e 100644 --- a/dbench/dbench.py +++ b/dbench/dbench.py @@ -1,7 +1,9 @@ -import os, re +import os +import re from autotest.client import utils, test + class dbench(test.test): version = 3 @@ -16,13 +18,11 @@ def setup(self, tarball='dbench-3.04.tar.gz'): utils.configure() utils.make() - def initialize(self): self.job.require_gcc() self.results = [] self.dbench = os.path.join(self.srcdir, 'dbench') - def run_once(self, dir='.', nprocs=None, seconds=600, args=''): if not nprocs: nprocs = self.job.cpu_count() @@ -31,8 +31,7 @@ def run_once(self, dir='.', nprocs=None, seconds=600, args=''): dir, loadfile, seconds) self.results = utils.system_output(cmd, retain_output=True) - def postprocess_iteration(self): pattern = re.compile(r"Throughput (.*?) MB/sec (.*?) procs") (throughput, procs) = pattern.findall(self.results)[0] - self.write_perf_keyval({'throughput':throughput, 'procs':procs}) + self.write_perf_keyval({'throughput': throughput, 'procs': procs}) diff --git a/dbt2/dbt2.py b/dbt2/dbt2.py index fa8489d84..f28d7e04a 100644 --- a/dbt2/dbt2.py +++ b/dbt2/dbt2.py @@ -1,4 +1,5 @@ -import os, shutil +import os +import shutil from autotest.client import test, utils @@ -11,9 +12,8 @@ class dbt2(test.test): def initialize(self): self.job.require_gcc() - # http://osdn.dl.sourceforge.net/sourceforge/osdldbt/dbt2-0.39.tar.gz - def setup(self, tarball = 'dbt2-0.39.tar.bz2'): + def setup(self, tarball='dbt2-0.39.tar.bz2'): tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) profile_src = os.path.join(self.bindir, 'pgpool.conf') @@ -44,8 +44,7 @@ def setup(self, tarball = 'dbt2-0.39.tar.bz2'): utils.system('ln -s %s %s' % (self.resultsdir, self.srcdir + '.pgsql/scripts/output')) - - def execute(self, db_type, args = ''): + def execute(self, db_type, args=''): logfile = self.resultsdir + '/dbt2.log' if (db_type == "mysql"): @@ -55,21 +54,18 @@ def execute(self, db_type, args = ''): elif (db_type == "pgsql"): self.execute_pgsql(args) - - def execute_mysql(self, args = ''): + def execute_mysql(self, args=''): args = args utils.system(self.srcdir + '.mysql/scripts/mysql/build_db.sh -g -w 1') utils.system(self.srcdir + '.mysql/scripts/run_workload.sh ' + args) - - def execute_pgpool(self, args = ''): - utils.system('%s/deps/pgpool/pgpool/bin/pgpool -f %s/../pgpool.conf' \ - % (self.autodir, self.srcdir)) + def execute_pgpool(self, args=''): + utils.system('%s/deps/pgpool/pgpool/bin/pgpool -f %s/../pgpool.conf' + % (self.autodir, self.srcdir)) self.execute_pgsql(args) utils.system('%s/deps/pgpool/pgpool/bin/pgpool stop' % self.autodir) - - def execute_pgsql(self, args = ''): + def execute_pgsql(self, args=''): utils.system(self.srcdir + '.pgsql/scripts/pgsql/build_db.sh -g -w 1') utils.system(self.srcdir + '.pgsql/scripts/run_workload.sh ' + args) # diff --git a/disktest/disktest.py b/disktest/disktest.py index 5fdf84a3f..ff2fe109f 100644 --- a/disktest/disktest.py +++ b/disktest/disktest.py @@ -1,9 +1,13 @@ -import os, sys, subprocess, logging +import os +import sys +import subprocess +import logging from autotest.client import test, utils from autotest.client.shared import error, utils_memory class disktest(test.test): + """ Autotest module for disktest. @@ -18,7 +22,6 @@ class disktest(test.test): version = 2 preserve_srcdir = True - def initialize(self): """ Verifies if we have gcc to compile disktest. @@ -28,7 +31,6 @@ def initialize(self): self.disk_srcdir = os.path.join(self.autodir, 'deps', 'disktest', 'src') self.build(self.disk_srcdir) - def build(self, srcdir): """ Compiles disktest. @@ -37,7 +39,6 @@ def build(self, srcdir): utils.make('clean') utils.make() - def test_one_disk_chunk(self, disk, chunk): """ Tests one part of the disk by spawning a disktest instance. @@ -53,7 +54,6 @@ def test_one_disk_chunk(self, disk, chunk): p = subprocess.Popen(cmd, shell=True) return(p.pid) - def run_once(self, disks=None, gigabytes=None, chunk_mb=None): """ Runs one iteration of disktest. @@ -66,19 +66,19 @@ def run_once(self, disks=None, gigabytes=None, chunk_mb=None): """ os.chdir(self.disk_srcdir) if chunk_mb is None: - chunk_mb = utils_memory.memtotal() / 1024/8 + chunk_mb = utils_memory.memtotal() / 1024 / 8 if disks is None: disks = [self.tmpdir] if gigabytes is None: - free = 100 # cap it at 100GB by default + free = 100 # cap it at 100GB by default for disk in disks: - free = min(utils.freespace(disk) / 1024**3, free) + free = min(utils.freespace(disk) / 1024 ** 3, free) gigabytes = free logging.info("Resizing to %s GB", gigabytes) sys.stdout.flush() self.chunk_mb = chunk_mb - self.memory_mb = utils_memory.memtotal()/1024/8 + self.memory_mb = utils_memory.memtotal() / 1024 / 8 if self.memory_mb > chunk_mb: raise error.TestError("Too much RAM (%dMB) for this test to work" % self.memory_mb) diff --git a/dma_memtest/dma_memtest.py b/dma_memtest/dma_memtest.py index e4cf17b99..3a9ecdb9b 100644 --- a/dma_memtest/dma_memtest.py +++ b/dma_memtest/dma_memtest.py @@ -1,9 +1,15 @@ -import os, time, re, subprocess, shutil, logging +import os +import time +import re +import subprocess +import shutil +import logging from autotest.client import utils, test from autotest.client.shared import error class dma_memtest(test.test): + """ A test for the memory subsystem against heavy IO and DMA operations, implemented based on the work of Doug Leford @@ -13,11 +19,11 @@ class dma_memtest(test.test): @author Rodrigo Sampaio Vaz (rsampaio@br.ibm.com) """ version = 1 + def initialize(self): self.cachedir = os.path.join(os.path.dirname(self.srcdir), 'cache') self.nfail = 0 - def setup(self, tarball_base='linux-2.6.18.tar.bz2', parallel=True): """ Downloads a copy of the linux kernel, calculate an estimated size of @@ -51,7 +57,6 @@ def setup(self, tarball_base='linux-2.6.18.tar.bz2', parallel=True): logging.info('Number of copies: %s' % self.sim_cps) logging.info('Parallel: %s' % parallel) - def get_sim_cps(self, est_size): ''' Calculate the amount of simultaneous copies that can be uncompressed @@ -78,7 +83,6 @@ def get_sim_cps(self, est_size): return int(sim_cps) - def run_once(self): """ Represents a single iteration of the process. Uncompresses a previously @@ -120,7 +124,7 @@ def run_once(self): logging.info('Comparing test copies with base copy') for j in range(self.sim_cps): tmp_dir = 'linux.%s/%s' % (j, - os.path.basename(self.tarball).strip('.tar.bz2')) + os.path.basename(self.tarball).strip('.tar.bz2')) if self.parallel: diff_cmd = ['diff', '-U3', '-rN', 'linux.orig', tmp_dir] logging.debug("Comparing linux.orig with %s", tmp_dir) @@ -153,7 +157,6 @@ def run_once(self): shutil.rmtree(tmp_dir) shutil.rmtree(base_dir) - def cleanup(self): if self.nfail != 0: raise error.TestError('DMA memory test failed.') diff --git a/ebizzy/ebizzy.py b/ebizzy/ebizzy.py index 6f395ad93..fcbe278f0 100644 --- a/ebizzy/ebizzy.py +++ b/ebizzy/ebizzy.py @@ -2,13 +2,13 @@ from autotest.client import utils, test from autotest.client.shared import error + class ebizzy(test.test): version = 3 def initialize(self): self.job.require_gcc() - # http://sourceforge.net/project/downloading.php?group_id=202378&filename=ebizzy-0.3.tar.gz def setup(self, tarball='ebizzy-0.3.tar.gz'): tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) @@ -18,12 +18,11 @@ def setup(self, tarball='ebizzy-0.3.tar.gz'): utils.system('[ -x configure ] && ./configure') utils.make() - # Note: default we use always mmap() def run_once(self, args='', num_chunks=1000, chunk_size=512000, seconds=100, num_threads=100): - #TODO: Write small functions which will choose many of the above + # TODO: Write small functions which will choose many of the above # variables dynamicaly looking at guest's total resources logfile = os.path.join(self.resultsdir, 'ebizzy.log') args2 = '-m -n %s -P -R -s %s -S %s -t %s' % (num_chunks, chunk_size, diff --git a/error_cleanup/error_cleanup.py b/error_cleanup/error_cleanup.py index 8440ef323..5aabf44ba 100644 --- a/error_cleanup/error_cleanup.py +++ b/error_cleanup/error_cleanup.py @@ -1,12 +1,11 @@ from autotest.client import test + class error_cleanup(test.test): version = 1 - def execute(self): pass - def cleanup(self): raise NameError("test a bug in cleanup()") diff --git a/error_initialize/error_initialize.py b/error_initialize/error_initialize.py index becfa667e..db727b6f5 100644 --- a/error_initialize/error_initialize.py +++ b/error_initialize/error_initialize.py @@ -1,12 +1,11 @@ from autotest.client import test + class error_initialize(test.test): version = 1 - def initialize(self): raise NameError("test a bug in initialize()") - def execute(self): pass diff --git a/error_setup/error_setup.py b/error_setup/error_setup.py index 34bd64587..c497292e4 100644 --- a/error_setup/error_setup.py +++ b/error_setup/error_setup.py @@ -1,9 +1,9 @@ from autotest.client import test + class error_setup(test.test): version = 1 - def setup(self): raise ValueError("test a bug in setup()") diff --git a/error_test_bug/error_test_bug.py b/error_test_bug/error_test_bug.py index bd10e9860..dbf0b0a96 100644 --- a/error_test_bug/error_test_bug.py +++ b/error_test_bug/error_test_bug.py @@ -1,9 +1,9 @@ from autotest.client.shared import error from autotest.client import test + class error_test_bug(test.test): version = 1 - def execute(self): raise RuntimeError("Woof Woof, Timmy's trapped in the well!") diff --git a/error_test_error/error_test_error.py b/error_test_error/error_test_error.py index 04ece6793..a1047815b 100644 --- a/error_test_error/error_test_error.py +++ b/error_test_error/error_test_error.py @@ -1,9 +1,9 @@ from autotest.client.shared import error from autotest.client import test + class error_test_error(test.test): version = 1 - def execute(self): raise error.TestError("This test always causes an error.") diff --git a/error_test_fail/error_test_fail.py b/error_test_fail/error_test_fail.py index 301fb0b07..fdf02f8d4 100644 --- a/error_test_fail/error_test_fail.py +++ b/error_test_fail/error_test_fail.py @@ -1,9 +1,9 @@ from autotest.client.shared import error from autotest.client import test + class error_test_fail(test.test): version = 1 - def execute(self): raise error.TestFail("This test always fails.") diff --git a/error_test_na/error_test_na.py b/error_test_na/error_test_na.py index b3120c01b..357f3e849 100644 --- a/error_test_na/error_test_na.py +++ b/error_test_na/error_test_na.py @@ -1,9 +1,9 @@ from autotest.client.shared import error from autotest.client import test + class error_test_na(test.test): version = 1 - def execute(self): raise error.TestNAError("This test can't run on this host.") diff --git a/ffsb/ffsb.py b/ffsb/ffsb.py index d48a58567..3a90c0129 100644 --- a/ffsb/ffsb.py +++ b/ffsb/ffsb.py @@ -1,4 +1,9 @@ -import os, string, logging, re, random, shutil +import os +import string +import logging +import re +import random +import shutil from autotest.client import test, os_dep, utils from autotest.client.shared import error @@ -16,6 +21,7 @@ def find_mnt_pt(path): class ffsb(test.test): + """ This class wraps FFSB (Flexible File System Benchmark) execution under autotest. @@ -25,18 +31,16 @@ class ffsb(test.test): version = 1 params = {} tempdirs = [] - bytes = {'K':1024 , 'k':1024, - 'M':1048576, 'm':1048576, - 'G':1073741824, 'g':1073741824, - 'T':1099511627776 , 't':1099511627776} - + bytes = {'K': 1024, 'k': 1024, + 'M': 1048576, 'm': 1048576, + 'G': 1073741824, 'g': 1073741824, + 'T': 1099511627776, 't': 1099511627776} def initialize(self): self.job.require_gcc() self.results = [] self.nfail = 0 - def set_ffsb_params(self, usrfl): """ This function checks for the user supplied FFSB profile file @@ -48,7 +52,7 @@ def set_ffsb_params(self, usrfl): @param usrfl: Path to the user profile file. """ d = {} - fr = open(usrfl,'r') + fr = open(usrfl, 'r') for line in fr.read().split('\n'): p = re.compile(r'\s*\t*\[{1}filesystem(\d+)\]{1}') m = p.match(line) @@ -78,7 +82,7 @@ def set_ffsb_params(self, usrfl): usrmaxflsz = int(usrmaxflsz[0:-1]) * self.bytes[usrmaxflsz[-1]] d[fsno].append(usrmaxflsz) for k in d.keys(): - while d[k][2]*d[k][3] >= d[k][1]: + while d[k][2] * d[k][3] >= d[k][1]: d[k][2] -= 1 if d[k][2] == 0: d[k][2] = 1 @@ -88,11 +92,10 @@ def set_ffsb_params(self, usrfl): # tests for k1 in d.keys(): if d[k1][0] == d[k][0]: - d[k1][1] -= (d[k][2]*d[k][3]) + d[k1][1] -= (d[k][2] * d[k][3]) fr.close() return d - def dup_ffsb_profilefl(self): """ Validates the path from the FFSB configuration file, the @@ -101,14 +104,14 @@ def dup_ffsb_profilefl(self): generating the workload according to the available disk space on the guest. """ - self.usrfl = '%s/%s' % (os.path.split(self.srcdir)[0],'profile.cfg') - self.sysfl = '%s/%s' % (self.srcdir,'profile.cfg') + self.usrfl = '%s/%s' % (os.path.split(self.srcdir)[0], 'profile.cfg') + self.sysfl = '%s/%s' % (self.srcdir, 'profile.cfg') params = self.set_ffsb_params(self.usrfl) fsno = 0 - fr = open(self.usrfl,'r') - fw = open(self.sysfl,'w') + fr = open(self.usrfl, 'r') + fw = open(self.sysfl, 'w') for line in fr.read().split('\n'): p = re.compile(r'\s*\t*\[{1}filesystem(\d+)\]{1}') m = p.match(line) @@ -131,25 +134,24 @@ def dup_ffsb_profilefl(self): else: os.makedirs(ffsbdir) break - fw.write(newline+'\n') + fw.write(newline + '\n') continue p = re.compile(r'(\s*\t*num_files)\=(.*)') m = p.match(line) if m: newline = '%s=%s' % (line[0:m.end(1)], str(params[fsno][2])) - fw.write(newline+'\n') + fw.write(newline + '\n') continue p = re.compile(r'(\s*\t*max_filesize)\=(\d+[kKMmGgTt]?)') m = p.match(line) if m: newline = '%s%s' % (line[0:m.start(2)], str(params[fsno][3])) - fw.write(newline+'\n') + fw.write(newline + '\n') continue - fw.write(line+'\n') + fw.write(line + '\n') fr.close() fw.close() - def setup(self, tarball='ffsb-6.0-rc2.tar.bz2'): """ Uncompress the FFSB tarball and compiles it. @@ -165,7 +167,6 @@ def setup(self, tarball='ffsb-6.0-rc2.tar.bz2'): utils.configure() utils.make() - def update_config(self, cfg): """ Update the profile.cfg file. @@ -180,7 +181,6 @@ def update_config(self, cfg): profile_dst = os.path.join(os.path.dirname(self.srcdir), 'profile.cfg') shutil.copyfile(profile_src, profile_dst) - def run_once(self, cfg=None): """ Runs a single iteration of the FFSB. @@ -202,7 +202,6 @@ def run_once(self, cfg=None): self.nfail += 1 logging.error('Failed to execute FFSB : %s', e) - def postprocess(self): """ Do test postprocessing. Fail the test or clean up results. diff --git a/fio/fio.py b/fio/fio.py index 7ca577c27..54db986aa 100644 --- a/fio/fio.py +++ b/fio/fio.py @@ -3,6 +3,7 @@ class fio(test.test): + """ fio is an I/O tool mean for benchmark and stress/hardware verification. @@ -13,8 +14,7 @@ class fio(test.test): def initialize(self): self.job.require_gcc() - - def setup(self, tarball = 'fio-2.0.5.tar.bz2'): + def setup(self, tarball='fio-2.0.5.tar.bz2'): """ Compiles and installs fio. @@ -27,14 +27,13 @@ def setup(self, tarball = 'fio-2.0.5.tar.bz2'): ldflags = '-L' + self.autodir + '/deps/libaio/lib' cflags = '-I' + self.autodir + '/deps/libaio/include' var_ldflags = 'LDFLAGS="' + ldflags + '"' - var_cflags = 'CFLAGS="' + cflags + '"' + var_cflags = 'CFLAGS="' + cflags + '"' os.chdir(self.srcdir) utils.system('patch -p1 < %s/Makefile.patch' % self.bindir) utils.system('%s %s make' % (var_ldflags, var_cflags)) - - def run_once(self, args = '', user = 'root'): + def run_once(self, args='', user='root'): os.chdir(self.srcdir) ##vars = 'TMPDIR=\"%s\" RESULTDIR=\"%s\"' % (self.tmpdir, self.resultsdir) vars = 'LD_LIBRARY_PATH="' + self.autodir + '/deps/libaio/lib"' diff --git a/flail/flail.py b/flail/flail.py index dcdfe07c8..8bdb0afc1 100644 --- a/flail/flail.py +++ b/flail/flail.py @@ -3,6 +3,7 @@ class flail(test.test): + """ This autotest module runs the flail system call fuzzer. @@ -18,8 +19,7 @@ class flail(test.test): def initialize(self): self.job.require_gcc() - - def setup(self, tarball = 'flail-0.2.0.tar.gz'): + def setup(self, tarball='flail-0.2.0.tar.gz'): """ Compiles flail with the appropriate parameters. @@ -30,8 +30,7 @@ def setup(self, tarball = 'flail-0.2.0.tar.gz'): os.chdir(self.srcdir) utils.make() - - def run_once(self, fstype = 'iso9660'): + def run_once(self, fstype='iso9660'): """ Runs flail with the appropriate parameters. diff --git a/fs_mark/fs_mark.py b/fs_mark/fs_mark.py index cc031d5b0..90ed3a7f8 100644 --- a/fs_mark/fs_mark.py +++ b/fs_mark/fs_mark.py @@ -8,19 +8,17 @@ class fs_mark(test.test): def initialize(self): self.job.require_gcc() - # http://developer.osdl.org/dev/doubt/fs_mark/archive/fs_mark-3.2.tgz - def setup(self, tarball = 'fs_mark-3.2.tgz'): + def setup(self, tarball='fs_mark-3.2.tgz'): tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) os.chdir(self.srcdir) utils.make() - - def run_once(self, dir, args = None): + def run_once(self, dir, args=None): if not args: # Just provide a sample run parameters args = '-s 10240 -n 1000' os.chdir(self.srcdir) - utils.system('./fs_mark -d %s %s' %(dir, args)) + utils.system('./fs_mark -d %s %s' % (dir, args)) diff --git a/fsfuzzer/fsfuzzer.py b/fsfuzzer/fsfuzzer.py index fc385adf5..20771a7ed 100644 --- a/fsfuzzer/fsfuzzer.py +++ b/fsfuzzer/fsfuzzer.py @@ -8,16 +8,14 @@ class fsfuzzer(test.test): def initialize(self): self.job.require_gcc() - # http://people.redhat.com/sgrubb/files/fsfuzzer-0.6.tar.gz - def setup(self, tarball = 'fsfuzzer-0.6.tar.gz'): + def setup(self, tarball='fsfuzzer-0.6.tar.gz'): tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) os.chdir(self.srcdir) utils.system('patch -p1 < %s/makefile.patch' % self.bindir) utils.make() - - def run_once(self, fstype = 'iso9660'): + def run_once(self, fstype='iso9660'): args = fstype + ' 1' utils.system(self.srcdir + '/run_test ' + args) diff --git a/fsstress/fsstress.py b/fsstress/fsstress.py index 5a232d331..e4e063777 100644 --- a/fsstress/fsstress.py +++ b/fsstress/fsstress.py @@ -8,9 +8,8 @@ class fsstress(test.test): def initialize(self): self.job.require_gcc() - # http://www.zip.com.au/~akpm/linux/patches/stuff/ext3-tools.tar.gz - def setup(self, tarball = 'ext3-tools.tar.gz'): + def setup(self, tarball='ext3-tools.tar.gz'): self.tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(self.tarball, self.srcdir) @@ -19,8 +18,7 @@ def setup(self, tarball = 'ext3-tools.tar.gz'): utils.system('patch -p1 < %s/makefile.patch' % self.bindir) utils.make('fsstress') - - def run_once(self, testdir = None, extra_args = '', nproc = '1000', nops = '1000'): + def run_once(self, testdir=None, extra_args='', nproc='1000', nops='1000'): if not testdir: testdir = self.tmpdir diff --git a/fsx/fsx.py b/fsx/fsx.py index 420a34aa2..e1bcbbb10 100644 --- a/fsx/fsx.py +++ b/fsx/fsx.py @@ -13,9 +13,8 @@ class fsx(test.test): def initialize(self): self.job.require_gcc() - # http://www.zip.com.au/~akpm/linux/patches/stuff/ext3-tools.tar.gz - def setup(self, tarball = 'ext3-tools.tar.gz'): + def setup(self, tarball='ext3-tools.tar.gz'): self.tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(self.tarball, self.srcdir) @@ -23,7 +22,7 @@ def setup(self, tarball = 'ext3-tools.tar.gz'): ldflags = '-L' + self.autodir + '/deps/libaio/lib' cflags = '-I' + self.autodir + '/deps/libaio/include' var_ldflags = 'LDFLAGS="' + ldflags + '"' - var_cflags = 'CFLAGS="' + cflags + '"' + var_cflags = 'CFLAGS="' + cflags + '"' self.make_flags = var_ldflags + ' ' + var_cflags os.chdir(self.srcdir) @@ -33,15 +32,14 @@ def setup(self, tarball = 'ext3-tools.tar.gz'): utils.system('patch -p1 < %s/%s' % (self.bindir, p2)) utils.system(self.make_flags + ' make fsx-linux') - def run_once(self, dir=None, repeat=100000): args = '-N %s' % repeat if not dir: dir = self.tmpdir os.chdir(dir) - libs = self.autodir+'/deps/libaio/lib/' + libs = self.autodir + '/deps/libaio/lib/' ld_path = utils.prepend_path(libs, - utils.environ('LD_LIBRARY_PATH')) + utils.environ('LD_LIBRARY_PATH')) var_ld_path = 'LD_LIBRARY_PATH=' + ld_path cmd = self.srcdir + '/fsx-linux ' + args + ' poo' utils.system(var_ld_path + ' ' + cmd) diff --git a/hackbench/hackbench.py b/hackbench/hackbench.py index 78b4ca044..2849f77eb 100644 --- a/hackbench/hackbench.py +++ b/hackbench/hackbench.py @@ -3,6 +3,7 @@ class hackbench(test.test): + """ This module will run the hackbench benchmark. Hackbench is a benchmark for measuring the performance, overhead and scalability of the Linux scheduler. @@ -14,7 +15,6 @@ class hackbench(test.test): version = 1 preserve_srcdir = True - def setup(self): os.chdir(self.srcdir) if 'CC' in os.environ: @@ -23,12 +23,10 @@ def setup(self): cc = 'cc' utils.system('%s -lpthread hackbench.c -o hackbench' % cc) - def initialize(self): self.job.require_gcc() self.results = None - def run_once(self, num_groups=90): """ Run hackbench, store the output in raw output files per iteration and @@ -44,7 +42,6 @@ def run_once(self, num_groups=90): path = os.path.join(self.resultsdir, 'raw_output_%s' % self.iteration) utils.open_write_close(path, raw_output) - def postprocess_iteration(self): """ Pick up the results attribute and write it in the performance keyval. diff --git a/hwclock/hwclock.py b/hwclock/hwclock.py index 9a84cbd1f..1797a6477 100644 --- a/hwclock/hwclock.py +++ b/hwclock/hwclock.py @@ -1,6 +1,9 @@ from autotest.client import test, utils from autotest.client.shared import error -import re, os, logging +import re +import os +import logging + class hwclock(test.test): version = 1 @@ -17,7 +20,6 @@ def run_once(self): raise error.TestFail("Failed to set hwclock back to the eighties. " "Output of hwclock is '%s'" % date) - def cleanup(self): """ Restore hardware clock to current system time. diff --git a/interbench/interbench.py b/interbench/interbench.py index 601be0d50..ade92f19b 100644 --- a/interbench/interbench.py +++ b/interbench/interbench.py @@ -8,17 +8,15 @@ class interbench(test.test): def initialize(self): self.job.require_gcc() - # http://www.kernel.org/pub/linux/kernel/people/ck/apps/interbench/interbench-0.30.tar.bz2 - def setup(self, tarball = 'interbench-0.30.tar.bz2'): + def setup(self, tarball='interbench-0.30.tar.bz2'): tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) os.chdir(self.srcdir) utils.system('patch -p1 < %s/makefile.patch' % self.bindir) utils.make() - - def run_once(self, args = ''): + def run_once(self, args=''): os.chdir(self.tmpdir) args += " -c" utils.system("%s/interbench -m 'run #%s' %s" % (self.srcdir, diff --git a/iosched_bugs/iosched_bugs.py b/iosched_bugs/iosched_bugs.py index fa05d336c..8a0d5434b 100644 --- a/iosched_bugs/iosched_bugs.py +++ b/iosched_bugs/iosched_bugs.py @@ -1,4 +1,5 @@ -import os, time +import os +import time import subprocess from autotest.client import test from autotest.client.shared import utils, error @@ -11,12 +12,10 @@ class iosched_bugs(test.test): def initialize(self): self.job.require_gcc() - def setup(self): os.chdir(self.srcdir) utils.make() - def execute(self): os.chdir(self.tmpdir) (p1, _) = utils.run_bg('dd if=/dev/hda3 of=/dev/null') diff --git a/iozone/common.py b/iozone/common.py index 025386c44..367b25318 100644 --- a/iozone/common.py +++ b/iozone/common.py @@ -1,4 +1,5 @@ -import os, sys +import os +import sys try: import autotest.client.setup_modules as setup_modules client_dir = os.path.dirname(setup_modules.__file__) diff --git a/iozone/iozone.py b/iozone/iozone.py index 4bd2995d1..652baedf8 100644 --- a/iozone/iozone.py +++ b/iozone/iozone.py @@ -1,9 +1,11 @@ -import os, re +import os +import re from autotest.client import test, utils import postprocessing class iozone(test.test): + """ This autotest module runs the IOzone filesystem benchmark. The benchmark generates and measures a variety of file operations. Iozone has been ported @@ -24,7 +26,6 @@ class iozone(test.test): def initialize(self): self.job.require_gcc() - def setup(self, tarball='iozone3_414.tar'): """ Builds the given version of IOzone from a tarball. @@ -47,7 +48,6 @@ def setup(self, tarball='iozone3_414.tar'): else: utils.make('linux') - def run_once(self, dir=None, args=None): """ Runs IOzone with appropriate parameters, record raw results in a per @@ -73,11 +73,9 @@ def run_once(self, dir=None, args=None): utils.open_write_close(self.results_path, self.results) - def __get_section_name(self, desc): return desc.strip().replace(' ', '_') - def generate_keyval(self): keylist = {} @@ -97,13 +95,13 @@ def generate_keyval(self): key_name = "%d-%d-%s" % (fields[0], fields[1], l) keylist[key_name] = v else: - child_regexp = re.compile('Children see throughput for[\s]+' - '([\d]+)\s+([-\w]+[-\w\s]*)\=[\s]+([\d\.]*) KB/sec') + child_regexp = re.compile('Children see throughput for[\s]+' + '([\d]+)\s+([-\w]+[-\w\s]*)\=[\s]+([\d\.]*) KB/sec') parent_regexp = re.compile('Parent sees throughput for[\s]+' - '([\d]+)\s+([-\w]+[-\w\s]*)\=[\s]+([\d\.]*) KB/sec') + '([\d]+)\s+([-\w]+[-\w\s]*)\=[\s]+([\d\.]*) KB/sec') - KBsec_regexp = re.compile('\=[\s]+([\d\.]*) KB/sec') - KBval_regexp = re.compile('\=[\s]+([\d\.]*) KB') + KBsec_regexp = re.compile('\=[\s]+([\d\.]*) KB/sec') + KBval_regexp = re.compile('\=[\s]+([\d\.]*) KB') section = None w_count = 0 @@ -156,7 +154,6 @@ def generate_keyval(self): self.write_perf_keyval(keylist) - def postprocess_iteration(self): self.generate_keyval() if self.auto_mode: diff --git a/iozone/postprocessing.py b/iozone/postprocessing.py index c8ca101db..0b29b9fb3 100755 --- a/iozone/postprocessing.py +++ b/iozone/postprocessing.py @@ -8,7 +8,12 @@ @copyright: Red Hat 2010 """ -import os, sys, optparse, logging, math, time +import os +import sys +import optparse +import logging +import math +import time try: import autotest.common as common except ImportError: @@ -59,7 +64,7 @@ def geometric_mean(values): n = len(values) if n == 0: return None - return math.exp(sum([math.log(x) for x in values])/n) + return math.exp(sum([math.log(x) for x in values]) / n) def compare_matrices(matrix1, matrix2, treshold=0.05): @@ -101,6 +106,7 @@ def compare_matrices(matrix1, matrix2, treshold=0.05): class IOzoneAnalyzer(object): + """ Analyze an unprocessed IOzone file, and generate the following types of report: @@ -112,6 +118,7 @@ class IOzoneAnalyzer(object): If more than one file is provided to the analyzer object, a comparison between the two runs is made, searching for regressions in performance. """ + def __init__(self, list_files, output_dir): self.list_files = list_files if not os.path.isdir(output_dir): @@ -119,7 +126,6 @@ def __init__(self, list_files, output_dir): self.output_dir = output_dir logging.info("Results will be stored in %s", output_dir) - def average_performance(self, results, size=None): """ Flattens a list containing performance results. @@ -139,7 +145,6 @@ def average_performance(self, results, size=None): average_line.append(average) return average_line - def process_results(self, results, label=None): """ Process a list of IOzone results according to label. @@ -164,7 +169,6 @@ def process_results(self, results, label=None): return performance - def parse_file(self, file): """ Parse an IOzone results file. @@ -183,7 +187,6 @@ def parse_file(self, file): continue return lines - def report(self, overall_results, record_size_results, file_size_results): """ Generates analysis data for IOZone run. @@ -253,7 +256,6 @@ def report(self, overall_results, record_size_results, file_size_results): logging.info("") - def report_comparison(self, record, file): """ Generates comparison data for 2 IOZone runs. @@ -281,9 +283,9 @@ def report_comparison(self, record, file): logging.info("%-10s%-8.6s%-8.6s%-8.6s%-8.6s%-8.6s%-8.6s%-8.6s%-8.6s%-8.6s%-8.6s%-8.6s%-8.6s%-8.6s" % tuple(result_line)) logging.info("REGRESSIONS: %d (%.2f%%) Improvements: %d (%.2f%%)", record_regressions, - (100 * record_regressions/float(record_total)), + (100 * record_regressions / float(record_total)), record_improvements, - (100 * record_improvements/float(record_total))) + (100 * record_improvements / float(record_total))) logging.info("") logging.info("") @@ -296,12 +298,11 @@ def report_comparison(self, record, file): logging.info("%-10s%-8.6s%-8.6s%-8.6s%-8.6s%-8.6s%-8.6s%-8.6s%-8.6s%-8.6s%-8.6s%-8.6s%-8.6s%-8.6s" % tuple(result_line)) logging.info("REGRESSIONS: %d (%.2f%%) Improvements: %d (%.2f%%)", file_regressions, - (100 * file_regressions/float(file_total)), + (100 * file_regressions / float(file_total)), file_improvements, - (100 * file_improvements/float(file_total))) + (100 * file_improvements / float(file_total))) logging.info("") - def analyze(self): """ Analyzes and eventually compares sets of IOzone data. @@ -332,12 +333,14 @@ def analyze(self): class IOzonePlotter(object): + """ Plots graphs based on the results of an IOzone run. Plots graphs based on the results of an IOzone run. Uses gnuplot to generate the graphs. """ + def __init__(self, results_file, output_dir): self.active = True try: @@ -360,7 +363,6 @@ def __init__(self, results_file, output_dir): self.results_file = results_file self.generate_data_source() - def generate_data_source(self): """ Creates data file without headers for gnuplot consumption. @@ -379,7 +381,6 @@ def generate_data_source(self): continue datasource.close() - def plot_2d_graphs(self): """ For each one of the throughput parameters, generate a set of gnuplot @@ -408,7 +409,6 @@ def plot_2d_graphs(self): logging.error("Problem plotting from commands file %s", commands_path) - def plot_3d_graphs(self): """ For each one of the throughput parameters, generate a set of gnuplot @@ -447,7 +447,6 @@ def plot_3d_graphs(self): logging.error("Problem plotting from commands file %s", commands_path) - def plot_all(self): """ Plot all graphs that are to be plotted, provided that we have gnuplot. @@ -458,9 +457,10 @@ def plot_all(self): class AnalyzerLoggingConfig(logging_config.LoggingConfig): + def configure_logging(self, results_dir=None, verbose=False): super(AnalyzerLoggingConfig, self).configure_logging(use_console=True, - verbose=verbose) + verbose=verbose) if __name__ == "__main__": diff --git a/iperf/iperf.py b/iperf/iperf.py index 926f0ff70..c7b274ed9 100644 --- a/iperf/iperf.py +++ b/iperf/iperf.py @@ -1,4 +1,8 @@ -import os, re, socket, time, logging +import os +import re +import socket +import time +import logging from autotest.client import test, utils from autotest.client.net import net_utils from autotest.client.shared import error @@ -6,11 +10,12 @@ MPSTAT_IX = 0 IPERF_IX = 1 + class iperf(test.test): version = 1 # http://downloads.sourceforge.net/iperf/iperf-2.0.4.tar.gz - def setup(self, tarball = 'iperf-2.0.4.tar.gz'): + def setup(self, tarball='iperf-2.0.4.tar.gz'): self.job.require_gcc() tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) @@ -20,7 +25,6 @@ def setup(self, tarball = 'iperf-2.0.4.tar.gz'): utils.make() utils.system('sync') - def initialize(self): self.SERVER_PORT = '5001' @@ -38,7 +42,6 @@ def initialize(self): self.netif = '' self.network_utils = net_utils.network_utils() - def run_once(self, server_ip, client_ip, role, udp=False, bidirectional=False, test_time=10, dev='', stream_list=[1]): self.role = role @@ -72,7 +75,7 @@ def run_once(self, server_ip, client_ip, role, udp=False, # Stop the server when the client finishes # Wait up to test_time + five minutes self.job.barrier(server_tag, 'finish_%d' % num_streams, - test_time+300).rendezvous(*all) + test_time + 300).rendezvous(*all) finally: self.server_stop() @@ -92,19 +95,16 @@ def run_once(self, server_ip, client_ip, role, udp=False, self.restore_interface() - def configure_interface(self, dev, ip_addr): self.netif = net_utils.netif(dev) self.netif.up() if self.netif.get_ipaddr() != ip_addr: self.netif.set_ipaddr(ip_addr) - def restore_interface(self): if self.netif: self.netif.restore() - def server_start(self): args = '' if self.udp: @@ -114,11 +114,9 @@ def server_start(self): self.results.append(utils.system_output(self.server_path % args, retain_output=True)) - def server_stop(self): utils.system('killall -9 iperf', ignore_status=True) - def client(self, server_ip, test_time, num_streams): args = '-t %d -P %d ' % (test_time, num_streams) if self.udp: @@ -139,7 +137,7 @@ def client(self, server_ip, test_time, num_streams): cmds.append(cmd) t0 = time.time() - out = utils.run_parallel(cmds, timeout = test_time + 60) + out = utils.run_parallel(cmds, timeout=test_time + 60) t1 = time.time() self.results.append(out) @@ -160,7 +158,6 @@ def client(self, server_ip, test_time, num_streams): else: raise - def postprocess(self): """The following patterns parse the following outputs: TCP -- bidirectional @@ -197,7 +194,7 @@ def postprocess(self): raise error.TestError('Mismatched number of results') for i, streams in enumerate(self.stream_list): - attr = {'stream_count':streams} + attr = {'stream_count': streams} keyval = {} # Short circuit to handle errors due to client timeouts @@ -216,14 +213,14 @@ def postprocess(self): keyval['CPU_C_SI'] = cpu_stats['soft'] keyval['INTRS_C'] = cpu_stats['intr/s'] - runs = {'Bandwidth_S2C':[], 'Bandwidth_C2S':[], - 'Jitter_S2C':[], 'Jitter_C2S':[]} + runs = {'Bandwidth_S2C': [], 'Bandwidth_C2S': [], + 'Jitter_S2C': [], 'Jitter_C2S': []} if self.udp: regex = udp_regex keys = udp_keys # Ignore the first line - stdout = iperf_out.split('\n',1)[1] + stdout = iperf_out.split('\n', 1)[1] else: regex = tcp_regex keys = tcp_keys @@ -232,11 +229,11 @@ def postprocess(self): # This will not find the average lines because the 'id' field # is negative and doesn't match the patterns -- this is good for match in regex.findall(stdout): - stats = dict(zip(keys,match)) + stats = dict(zip(keys, match)) # Determine Flow Direction if (stats['local_ip'] == self.ip and - stats['local_port'] == self.SERVER_PORT): + stats['local_port'] == self.SERVER_PORT): runs['Bandwidth_S2C'].append(int(stats['bandwidth'])) try: runs['Jitter_S2C'].append(float(stats['jitter'])) @@ -255,7 +252,7 @@ def postprocess(self): # scale the bandwidth based on the actual time taken # by tests to run - scale = self.test_time/self.actual_times[i] + scale = self.test_time / self.actual_times[i] total_bw = 0 for key in ['Bandwidth_S2C', 'Bandwidth_C2S']: if len(runs[key]) > 0: @@ -263,7 +260,7 @@ def postprocess(self): total_bw = total_bw + keyval[key] if keyval['CPU_C']: - keyval['Efficiency_C'] = total_bw/keyval['CPU_C'] + keyval['Efficiency_C'] = total_bw / keyval['CPU_C'] else: keyval['Efficiency_C'] = total_bw self.write_iteration_keyval(attr, keyval) diff --git a/ipv6connect/ipv6connect.py b/ipv6connect/ipv6connect.py index 57648cbc1..838c36bbd 100644 --- a/ipv6connect/ipv6connect.py +++ b/ipv6connect/ipv6connect.py @@ -1,4 +1,6 @@ -import os, re, sys +import os +import re +import sys from autotest.client import test from autotest.client.shared import utils @@ -13,12 +15,10 @@ def setup(self, src='ipv6connect.c'): os.chdir(self.srcdir) utils.system('gcc ipv6connect.c -o ipv6connect -lpthread -static -s') - def initialize(self): self.job.require_gcc() self.results = [] - def run_once(self, dir=None, nprocs=None, args=''): (lower, upper) = utils.get_ip_local_port_range() utils.set_ip_local_port_range(4096, 65535) @@ -30,7 +30,6 @@ def run_once(self, dir=None, nprocs=None, args=''): utils.set_ip_local_port_range(lower, upper) self.results.append(result.stderr) - def postprocess(self): pattern = re.compile(r'\nTotal time = ([0-9.]+)s\n') for duration in pattern.findall('\n'.join(self.results)): diff --git a/isic/isic.py b/isic/isic.py index 40bf2ba63..da48bcc5c 100644 --- a/isic/isic.py +++ b/isic/isic.py @@ -12,15 +12,14 @@ def initialize(self): self.job.require_gcc() self.job.setup_dep(['libnet']) - - def setup(self, tarball = 'isic-0.06.tar.bz2'): + def setup(self, tarball='isic-0.06.tar.bz2'): tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) os.chdir(self.srcdir) utils.system('patch -p1 < %s/build-fixes.patch' % self.bindir) - utils.system('PREFIX=%s/deps/libnet/libnet/ ./configure' %self.autodir) + utils.system('PREFIX=%s/deps/libnet/libnet/ ./configure' % self.autodir) utils.system('make') - def execute(self, args = '-s rand -d 127.0.0.1 -p 10000000'): + def execute(self, args='-s rand -d 127.0.0.1 -p 10000000'): utils.system(self.srcdir + '/isic ' + args) diff --git a/kernbench/kernbench.py b/kernbench/kernbench.py index 97a334a82..e9a33146f 100644 --- a/kernbench/kernbench.py +++ b/kernbench/kernbench.py @@ -1,4 +1,7 @@ -import re, pickle, os, logging +import re +import pickle +import os +import logging from autotest.client import utils, test @@ -9,7 +12,6 @@ def initialize(self): self.job.require_gcc() self.job.drop_caches_between_iterations = False - def __init_tree(self, version=None): # # If we have a local copy of the 3.2.1 tarball use that @@ -38,12 +40,11 @@ def __init_tree(self, version=None): kernel.config(defconfig=True, logged=False) return kernel - def warmup(self, threads=None, version=None): if threads: self.threads = threads else: - self.threads = self.job.cpu_count()*2 + self.threads = self.job.cpu_count() * 2 self.kernel = self.__init_tree(version) logging.info("Warmup run ...") @@ -54,7 +55,6 @@ def warmup(self, threads=None, version=None): if os.path.exists(logfile): utils.system("gzip -9 '%s'" % logfile, ignore_status=True) - def run_once(self): logging.info("Performance run, iteration %d," " %d threads" % (self.iteration, self.threads)) @@ -65,18 +65,16 @@ def run_once(self): self.timefile = os.path.join(self.resultsdir, timefile) self.kernel.build_timed(self.threads, self.timefile) - def cleanup(self): self.kernel.clean(logged=False) # Don't leave litter lying around - def postprocess_iteration(self): os.chdir(self.resultsdir) utils.system("grep -h elapsed %s >> time" % self.timefile) results = open(self.timefile).read() (user, system, elapsed) = utils.extract_all_time_results(results)[0] - self.write_perf_keyval({'user':user, - 'system':system, - 'elapsed':elapsed - }) + self.write_perf_keyval({'user': user, + 'system': system, + 'elapsed': elapsed + }) diff --git a/kernelbuild/kernelbuild.py b/kernelbuild/kernelbuild.py index deb7e7161..30413fd77 100644 --- a/kernelbuild/kernelbuild.py +++ b/kernelbuild/kernelbuild.py @@ -4,7 +4,7 @@ class kernelbuild(test.test): version = 1 - def execute(self, base_tree, patches, config, config_list = None): + def execute(self, base_tree, patches, config, config_list=None): kernel = self.job.kernel(base_tree, self.outputdir) if patches: kernel.patch(*patches) diff --git a/kernelinstall/kernelinstall.py b/kernelinstall/kernelinstall.py index 0152ff184..cbbfccb45 100644 --- a/kernelinstall/kernelinstall.py +++ b/kernelinstall/kernelinstall.py @@ -1,4 +1,5 @@ -import os, logging +import os +import logging from autotest.client import test from autotest.client import utils from autotest.client.shared import git, utils_koji, error, software_manager @@ -31,7 +32,6 @@ def _kernel_install_rpm(self, rpm_file, kernel_deps_rpms=None, else: kernel.add_to_bootloader() - def _kernel_install_koji(self, koji_tag, package="kernel", dep_pkgs=None, need_reboot=True, sub_pkgs=None): sm = software_manager.SoftwareManager() @@ -51,11 +51,11 @@ def _kernel_install_koji(self, koji_tag, package="kernel", dep_pkgs=None, for p in dep_pkgs.split(): logging.info('Fetching kernel dependencies: %s', p) k_dep = utils_koji.KojiPkgSpec(tag=koji_tag, package=p, - subpackages=[p]) + subpackages=[p]) c.get_pkgs(k_dep, self.bindir) deps_rpms += " " deps_rpms += os.path.join(self.bindir, - c.get_pkg_rpm_file_names(k_dep)[0]) + c.get_pkg_rpm_file_names(k_dep)[0]) if sub_pkgs: sub_pkgs = sub_pkgs.split() @@ -79,9 +79,8 @@ def _kernel_install_koji(self, koji_tag, package="kernel", dep_pkgs=None, # Then install kernel rpm packages. self._kernel_install_rpm(kernel_rpm, deps_rpms, need_reboot) - def _kernel_install_src(self, base_tree, config, config_list=None, - patch_list=None, need_reboot=True): + patch_list=None, need_reboot=True): if not utils.is_url(base_tree): base_tree = os.path.join(self.bindir, base_tree) if not utils.is_url(config): @@ -106,7 +105,6 @@ def _kernel_install_src(self, base_tree, config, config_list=None, else: kernel.add_to_bootloader() - def _kernel_install_git(self, repo, config, repo_base=None, branch="master", commit=None, config_list=None, patch_list=None, need_reboot=True): @@ -115,8 +113,7 @@ def _kernel_install_git(self, repo, config, repo_base=None, destination_dir=repodir, commit=commit, base_uri=repo_base) self._kernel_install_src(repodir, config, config_list, patch_list, - need_reboot) - + need_reboot) def execute(self, install_type="koji", params=None): need_reboot = params.get("need_reboot") == "yes" diff --git a/libhugetlbfs/libhugetlbfs.py b/libhugetlbfs/libhugetlbfs.py index 8879d10e4..65210bf2a 100644 --- a/libhugetlbfs/libhugetlbfs.py +++ b/libhugetlbfs/libhugetlbfs.py @@ -1,4 +1,5 @@ -import re, os +import re +import os from autotest.client import utils, test, os_dep from autotest.client.shared import error @@ -18,7 +19,7 @@ def initialize(self, hugetlbfs_dir=None, pages_requested=20): pages_available = 0 if os.path.exists('/proc/sys/vm/nr_hugepages'): utils.write_one_line('/proc/sys/vm/nr_hugepages', - str(pages_requested)) + str(pages_requested)) nr_hugepages = utils.read_one_line('/proc/sys/vm/nr_hugepages') pages_available = int(nr_hugepages) else: @@ -26,7 +27,7 @@ def initialize(self, hugetlbfs_dir=None, pages_requested=20): if pages_available < pages_requested: raise error.TestError('%d pages available, < %d pages requested' - % (pages_available, pages_requested)) + % (pages_available, pages_requested)) # Check if hugetlbfs has been mounted if not utils.file_contains_pattern('/proc/mounts', 'hugetlbfs'): diff --git a/libvirt_tck/libvirt_tck.py b/libvirt_tck/libvirt_tck.py index 6ac4809e6..a86df2dee 100644 --- a/libvirt_tck/libvirt_tck.py +++ b/libvirt_tck/libvirt_tck.py @@ -1,10 +1,14 @@ -import os, re, shutil, logging +import os +import re +import shutil +import logging from autotest.client.shared import error from autotest.client import utils, test class libvirt_tck(test.test): + """ Autotest wrapper for the libvirt Technology Compatibility toolkit. diff --git a/libvirt_test_api/libvirt_test_api.py b/libvirt_test_api/libvirt_test_api.py index 56cea123f..692c8a339 100644 --- a/libvirt_test_api/libvirt_test_api.py +++ b/libvirt_test_api/libvirt_test_api.py @@ -1,4 +1,8 @@ -import os, re, shutil, glob, logging +import os +import re +import shutil +import glob +import logging from autotest.client.shared import error from autotest.client import utils, test, os_dep @@ -6,11 +10,11 @@ class libvirt_test_api(test.test): version = 1 + def setup(self, tarball='libvirt-test-API.tar.gz'): tarpath = utils.unmap_url(self.bindir, tarball) utils.extract_tarball_to_dir(tarpath, self.srcdir) - def initialize(self): try: import pexpect @@ -25,7 +29,6 @@ def initialize(self): "install the package nmap or the equivalent" "for your distro") - def get_tests_from_cfg(self, cfg, item): """ Get all available tests for the given item in the config file cfg. @@ -60,7 +63,6 @@ def get_tests_from_cfg(self, cfg, item): cfg.close() return testcases - def run_once(self, item=''): if not item: raise error.TestError('No test item provided') @@ -77,7 +79,7 @@ def run_once(self, item=''): test_items = self.get_tests_from_cfg(config_files_cfg, item) if not test_items: raise error.TestError('No test available for item %s in ' - 'config_files.cfg' % item) + 'config_files.cfg' % item) os.chdir(self.srcdir) failed_tests = [] diff --git a/linus_stress/linus_stress.py b/linus_stress/linus_stress.py index 39934ec88..a2cb7ba8a 100644 --- a/linus_stress/linus_stress.py +++ b/linus_stress/linus_stress.py @@ -1,4 +1,5 @@ -import os, shutil +import os +import shutil from autotest.client import test, utils from autotest.client.shared import utils_memory @@ -12,11 +13,9 @@ def setup(self): os.chdir(self.srcdir) utils.system(utils.get_cc() + ' linus_stress.c -D_POSIX_C_SOURCE=200112 -o linus_stress') - def initialize(self): self.job.require_gcc() - def run_the_test(self, iterations): utils.write_one_line('/proc/sys/vm/dirty_ratio', '4') utils.write_one_line('/proc/sys/vm/dirty_background_ratio', '2') @@ -35,8 +34,7 @@ def run_the_test(self, iterations): profilers.stop(self) profilers.report(self) - - def execute(self, iterations = 1): + def execute(self, iterations=1): dirty_ratio = utils.read_one_line('/proc/sys/vm/dirty_ratio') dirty_background_ratio = utils.read_one_line('/proc/sys/vm/dirty_background_ratio') try: diff --git a/lmbench/lmbench.py b/lmbench/lmbench.py index c9135a73a..1002645cf 100644 --- a/lmbench/lmbench.py +++ b/lmbench/lmbench.py @@ -10,8 +10,7 @@ class lmbench(test.test): def initialize(self): self.job.require_gcc() - - def setup(self, tarball = 'lmbench3.tar.bz2', fsdir=None, file=None): + def setup(self, tarball='lmbench3.tar.bz2', fsdir=None, file=None): """ Uncompresses the original lmbench tarball, applies a patch to fix some build issues, configures lmbench and then modifies the config @@ -61,12 +60,10 @@ def setup(self, tarball = 'lmbench3.tar.bz2', fsdir=None, file=None): utils.system("sed 's!^FILE=.*$!FILE=%s!' '%s' > '%s'" % (file, tmp_config_file, config_file)) - def run_once(self): os.chdir(self.srcdir) utils.make('rerun') - def postprocess(self): # Get the results: outputdir = self.srcdir + "/results" diff --git a/ltp/ltp-diff.py b/ltp/ltp-diff.py index 6fde58ec2..86f2ac8b7 100755 --- a/ltp/ltp-diff.py +++ b/ltp/ltp-diff.py @@ -14,15 +14,19 @@ # Non-zero if results differ, or bad input -import sys, string, re +import sys +import string +import re from autotest.client.shared import utils + def usage(): print "\nUsage: \n\ ltp-diff results1 results2 ... locationN \n\ Note: location[1,2,N] may be local files or URLs of LTP results\n" sys.exit(1) + def get_results(results_files): """ Download the results if needed. @@ -56,7 +60,6 @@ def get_results(results_files): return (runs, testnames) - def compare_results(runs): """ Loop through all testnames alpahbetically. @@ -74,15 +77,15 @@ def compare_results(runs): all_testnames.sort() for testname in all_testnames: differ = 0 - for i in range(1,len(runs)): + for i in range(1, len(runs)): # Must handle testcases that executed in one run # but not another by setting status to "null" if not runs[i].has_key(testname): runs[i][testname] = "null" - if not runs[i-1].has_key(testname): - runs[i-1][testname] = "null" + if not runs[i - 1].has_key(testname): + runs[i - 1][testname] = "null" # Check for the results inconsistencies - if runs[i][testname] != runs[i-1][testname]: + if runs[i][testname] != runs[i - 1][testname]: differ = 1 if differ: if header == 0: @@ -98,7 +101,7 @@ def compare_results(runs): all_results = "" for i in range(len(runs)): all_results += runs[i][testname] - if i+1= mem_start) and - (vma_start < (mem_start + mem_len))): - vma_count+=1 + (vma_start < (mem_start + mem_len))): + vma_count += 1 if (('file' not in output) and (vma_max_shift != 0)): expected_vma_count = mem_len >> vma_max_shift @@ -71,4 +74,4 @@ def run_once(self, memsize = "1000000000", args=''): if p1.poll() != 0: raise error.TestFail("Unexpected application abort") - utils.system('%s/mremaps ' % self.tmpdir + '100000000') + utils.system('%s/mremaps ' % self.tmpdir + '100000000') diff --git a/monotonic_time/monotonic_time.py b/monotonic_time/monotonic_time.py index 0c5066b35..bf5eab17f 100644 --- a/monotonic_time/monotonic_time.py +++ b/monotonic_time/monotonic_time.py @@ -1,7 +1,10 @@ -import os, re, logging +import os +import re +import logging from autotest.client import test, utils from autotest.client.shared import error + class monotonic_time(test.test): version = 1 @@ -11,12 +14,10 @@ def setup(self): os.chdir(self.srcdir) utils.make() - def initialize(self): self.job.require_gcc() - - def run_once(self, test_type = None, duration = 300, threshold = None): + def run_once(self, test_type=None, duration=300, threshold=None): if not test_type: raise error.TestError('missing test type') diff --git a/netperf2/netperf2.py b/netperf2/netperf2.py index 59c2c1ef3..973cdd8b8 100644 --- a/netperf2/netperf2.py +++ b/netperf2/netperf2.py @@ -1,4 +1,7 @@ -import os, time, re, logging +import os +import time +import re +import logging from autotest.client import test, utils from autotest.client.net import net_utils from autotest.client.shared import error @@ -6,11 +9,12 @@ MPSTAT_IX = 0 NETPERF_IX = 1 + class netperf2(test.test): version = 3 # ftp://ftp.netperf.org/netperf/netperf-2.6.0.tar.bz2 - def setup(self, tarball = 'netperf-2.6.0.tar.bz2'): + def setup(self, tarball='netperf-2.6.0.tar.bz2'): self.job.require_gcc() tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) @@ -20,7 +24,6 @@ def setup(self, tarball = 'netperf-2.6.0.tar.bz2'): utils.make() utils.system('sync') - def initialize(self): self.server_prog = '%s&' % os.path.join(self.srcdir, 'src/netserver') self.client_prog = '%s' % os.path.join(self.srcdir, 'src/netperf') @@ -32,10 +35,9 @@ def initialize(self): self.network = net_utils.network() self.network_utils = net_utils.network_utils() - - def run_once(self, server_ip, client_ip, role, test = 'TCP_STREAM', - test_time = 15, stream_list = [1], test_specific_args = '', - cpu_affinity = '', dev = '', bidi = False, wait_time = 5): + def run_once(self, server_ip, client_ip, role, test='TCP_STREAM', + test_time=15, stream_list=[1], test_specific_args='', + cpu_affinity='', dev='', bidi=False, wait_time=5): """ server_ip: IP address of host running netserver client_ip: IP address of host running netperf client(s) @@ -93,7 +95,7 @@ def run_once(self, server_ip, client_ip, role, test = 'TCP_STREAM', # Wait up to test_time + 5 minutes for the test to # complete self.job.barrier(server_tag, 'stop_%d' % num_streams, - test_time+300).rendezvous(*all) + test_time + 300).rendezvous(*all) finally: self.server_stop() @@ -111,19 +113,16 @@ def run_once(self, server_ip, client_ip, role, test = 'TCP_STREAM', self.restore_interface() - def configure_interface(self, dev, ip_addr): self.netif = net_utils.netif(dev) self.netif.up() if self.netif.get_ipaddr() != ip_addr: self.netif.set_ipaddr(ip_addr) - def restore_interface(self): if self.netif: self.netif.restore() - def server_start(self, cpu_affinity): utils.system('killall netserver', ignore_status=True) cmd = self.server_prog @@ -132,11 +131,9 @@ def server_start(self, cpu_affinity): self.results.append(utils.system_output(cmd, retain_output=True)) - def server_stop(self): utils.system('killall netserver', ignore_status=True) - def client(self, server_ip, test, test_time, num_streams, test_specific_args, cpu_affinity): args = '-H %s -t %s -l %d' % (server_ip, test, test_time) @@ -189,19 +186,18 @@ def client(self, server_ip, test, test_time, num_streams, works for now""" if ('within' in e.additional_text - or 'non-zero' in e.additional_text): + or 'non-zero' in e.additional_text): logging.debug(e.additional_text) self.results.append(None) self.actual_times.append(1) else: raise - def postprocess(self): if self.role == 'client': # if profilers are enabled, the test gets runs twice if (len(self.stream_list) != len(self.results) and - 2*len(self.stream_list) != len(self.results)): + 2 * len(self.stream_list) != len(self.results)): raise error.TestError('Mismatched number of results') function = None @@ -222,7 +218,7 @@ def postprocess(self): raise error.TestError('Unhandled test') for i, streams in enumerate(self.stream_list): - attr = {'stream_count':streams} + attr = {'stream_count': streams} keyval = {} temp_vals = [] @@ -263,13 +259,12 @@ def postprocess(self): # record 'Efficiency' as perf/CPU if keyval['CPU_C'] != 0: - keyval['Efficieny_C'] = keyval[keys[0]]/keyval['CPU_C'] + keyval['Efficieny_C'] = keyval[keys[0]] / keyval['CPU_C'] else: keyval['Efficieny_C'] = keyval[keys[0]] self.write_iteration_keyval(attr, keyval) - def process_tcp_stream(self, output): """Parses the following (works for both TCP_STREAM, TCP_MAERTS and TCP_SENDFILE) and returns a singleton containing throughput. @@ -286,7 +281,6 @@ def process_tcp_stream(self, output): return float(output.splitlines()[6].split()[4]), - def process_udp_stream(self, output): """Parses the following and returns a touple containing throughput and the number of errors. @@ -304,7 +298,6 @@ def process_udp_stream(self, output): line_tokens = output.splitlines()[5].split() return float(line_tokens[5]), int(line_tokens[4]) - def process_request_response(self, output): """Parses the following which works for both rr (TCP and UDP) and crr tests and returns a singleton containing transfer rate. @@ -322,7 +315,6 @@ def process_request_response(self, output): return float(output.splitlines()[6].split()[5]), - def ping(self, ip, timeout): curr_time = time.time() end_time = curr_time + timeout diff --git a/netpipe/netpipe.py b/netpipe/netpipe.py index ca3d1b0ba..960ba93b8 100644 --- a/netpipe/netpipe.py +++ b/netpipe/netpipe.py @@ -1,4 +1,6 @@ -import os, time, logging +import os +import time +import logging from autotest.client import test, utils from autotest.client.shared import error @@ -15,7 +17,6 @@ def setup(self, tarball='NetPIPE-3.7.1.tar.gz'): utils.system('patch -p1 < %s/makefile.patch' % self.bindir) utils.make() - def initialize(self): self.job.require_gcc() @@ -30,7 +31,6 @@ def cleanup(self): # Just in case... utils.system('killall -9 NPtcp', ignore_status=True) - def run_once(self, server_ip, client_ip, role, bidirectional=False, buffer_size=None, upper_bound=None, perturbation_size=3): @@ -45,7 +45,6 @@ def run_once(self, server_ip, client_ip, role, bidirectional=False, if upper_bound: args += '-u %d ' % upper_bound - server_tag = server_ip + '#netpipe-server' client_tag = client_ip + '#netpipe-client' all = [server_tag, client_tag] @@ -68,12 +67,10 @@ def run_once(self, server_ip, client_ip, role, bidirectional=False, else: raise error.TestError('invalid role specified') - def server_start(self, args): cmd = self.server_path % args self.results.append(utils.system_output(cmd, retain_output=True)) - def client(self, server_ip, args): cmd = self.client_path % (server_ip, args) @@ -91,20 +88,19 @@ def client(self, server_ip, args): works for now""" if ('within' in e.additional_text - or 'non-zero' in e.additional_text): + or 'non-zero' in e.additional_text): logging.debug(e.additional_text) else: raise - def postprocess(self): if self.role == 'client': try: output = open(self.NP_FILE) for line in output.readlines(): buff, bandwidth, latency = line.split() - attr = {'buffer_size':buff} - keyval = {'bandwidth':bandwidth, 'latency':latency} + attr = {'buffer_size': buff} + keyval = {'bandwidth': bandwidth, 'latency': latency} self.write_iteration_keyval(attr, keyval) finally: output.close() diff --git a/npb/npb.py b/npb/npb.py index 29f133d1f..b730fe8de 100644 --- a/npb/npb.py +++ b/npb/npb.py @@ -1,8 +1,13 @@ -import os, shutil, logging, re +import os +import shutil +import logging +import re from autotest.client import test, utils from autotest.client.shared import error + class npb(test.test): + """ This module runs the NAS Parallel Benchmarks on the client machine @@ -11,6 +16,7 @@ class npb(test.test): @see: http://www.nas.nasa.gov/Resources/Software/npb.html """ version = 1 + def initialize(self, tests=''): # Initialize failure counter self.n_fail = 0 @@ -20,7 +26,6 @@ def initialize(self, tests=''): self.ratio = 1.0 / utils.count_cpus() logging.debug('Ratio (1/n_cpus) found for this system: %s' % self.ratio) - def setup(self, tarball='NPB3.3.tar.gz'): tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) @@ -29,7 +34,6 @@ def setup(self, tarball='NPB3.3.tar.gz'): utils.system('patch -p1 < %s/enable-all-tests.patch' % self.bindir) utils.system('cd NPB3.3-OMP && make suite') - def run_once(self): """ Run each benchmark twice, with different number of threads. @@ -58,7 +62,7 @@ def run_once(self): itest_cmd = os.path.join('NPB3.3-OMP/bin/', itest) try: itest = utils.run(itest_cmd) - except Exception, e : + except Exception, e: logging.error('NPB benchmark %s has failed. Output: %s', itest_cmd, e) self.n_fail += 1 @@ -82,7 +86,7 @@ def run_once(self): logging.info('Time (s): %s', time_seconds) logging.info('Total operations executed (mops/s): %s', mops_total) logging.info('Total operations per thread (mops/s/thread): %s', - mops_per_thread) + mops_per_thread) self.write_test_keyval({'test': itest_cmd}) self.write_test_keyval({'time_seconds': time_seconds}) @@ -107,7 +111,7 @@ def run_once(self): itest_single_cmd = ''.join(['OMP_NUM_THREADS=1 ', itest_cmd]) try: itest_single = utils.run(itest_single_cmd) - except Exception, e : + except Exception, e: logging.error('NPB benchmark single thread %s has failed. ' 'Output: %s', itest_single_cmd, e) self.n_fail += 1 @@ -134,7 +138,6 @@ def run_once(self): else: logging.debug('NPB benchmark %s sanity check PASS' % itest_cmd) - def cleanup(self): """ Raise TestError if failures were detected during test execution. diff --git a/parallel_dd/parallel_dd.py b/parallel_dd/parallel_dd.py index 0edc694bf..928fe9fed 100644 --- a/parallel_dd/parallel_dd.py +++ b/parallel_dd/parallel_dd.py @@ -1,4 +1,9 @@ -import os, re, time, subprocess, sys, logging +import os +import re +import time +import subprocess +import sys +import logging from autotest.client import test, utils from autotest.client.shared import error @@ -6,8 +11,8 @@ class parallel_dd(test.test): version = 2 - def initialize(self, fs, fstype = 'ext2', megabytes = 1000, streams = 2, - seq_read = True): + def initialize(self, fs, fstype='ext2', megabytes=1000, streams=2, + seq_read=True): self.megabytes = megabytes self.blocks = megabytes * 256 self.blocks_per_file = self.blocks / streams @@ -25,7 +30,6 @@ def initialize(self, fs, fstype = 'ext2', megabytes = 1000, streams = 2, logging.info('Dumping %d megabytes across %d streams', megabytes, streams) - def raw_write(self): logging.info("Timing raw write of %d megabytes" % self.megabytes) sys.stdout.flush() @@ -33,7 +37,6 @@ def raw_write(self): self.blocks) utils.system(dd + ' > /dev/null') - def raw_read(self): logging.info("Timing raw read of %d megabytes", self.megabytes) sys.stdout.flush() @@ -41,14 +44,13 @@ def raw_read(self): self.blocks) utils.system(dd + ' > /dev/null') - def fs_write(self): p = [] # Write out 'streams' files in parallel background tasks for i in range(self.streams): - file = os.path.join(self.job.tmpdir, 'poo%d' % (i+1)) + file = os.path.join(self.job.tmpdir, 'poo%d' % (i + 1)) dd = 'dd if=/dev/zero of=%s bs=4k count=%d' % \ - (file, self.blocks_per_file) + (file, self.blocks_per_file) p.append(subprocess.Popen(dd + ' > /dev/null', shell=True)) logging.info("Waiting for %d streams", self.streams) # Wait for everyone to complete @@ -59,14 +61,13 @@ def fs_write(self): sys.stdout.flush() sys.stderr.flush() - def fs_read(self): p = [] # Read in 'streams' files in parallel background tasks for i in range(self.streams): - file = os.path.join(self.job.tmpdir, 'poo%d' % (i+1)) + file = os.path.join(self.job.tmpdir, 'poo%d' % (i + 1)) dd = 'dd if=%s of=/dev/null bs=4k count=%d' % \ - (file, self.blocks_per_file) + (file, self.blocks_per_file) if self.seq_read: utils.system(dd + ' > /dev/null') else: @@ -80,7 +81,6 @@ def fs_read(self): sys.stdout.flush() os.waitpid(p[i].pid, 0) - def _device_to_fstype(self, file): device = self.fs.device try: @@ -93,7 +93,6 @@ def _device_to_fstype(self, file): logging.error('No %s found in %s', device, file) return None - def run_once(self): try: self.fs.unmount() @@ -125,11 +124,10 @@ def run_once(self): self.fs_read_rate = self.megabytes / (time.time() - start) self.write_perf_keyval({ - 'raw_write' : self.raw_write_rate, - 'raw_read' : self.raw_read_rate, - 'fs_write' : self.fs_write_rate, - 'fs_read' : self.fs_read_rate }) - + 'raw_write': self.raw_write_rate, + 'raw_read': self.raw_read_rate, + 'fs_write': self.fs_write_rate, + 'fs_read': self.fs_read_rate}) def cleanup(self): try: diff --git a/perfmon/perfmon.py b/perfmon/perfmon.py index 541be6c22..09d995ccf 100644 --- a/perfmon/perfmon.py +++ b/perfmon/perfmon.py @@ -1,24 +1,25 @@ -import os, re +import os +import re from autotest.client import utils, test from autotest.client.shared import error # test requires at least 2.6.26, will skip otherwise (check is internal) + + class perfmon(test.test): version = 16 - def setup(self, tarball = 'perfmon-tests-0.3.tar.gz'): + def setup(self, tarball='perfmon-tests-0.3.tar.gz'): tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) os.chdir(self.srcdir) utils.make() - def initialize(self): self.job.require_gcc() self.results = [] - - def run_once(self, dir = None, nprocs = None, args = ''): + def run_once(self, dir=None, nprocs=None, args=''): cmd = self.srcdir + '/tests/pfm_tests' + args # self.results.append(utils.system_output(cmd, retain_output=True)) if 'FAIL' in utils.system_output(cmd, retain_output=True): diff --git a/pi_tests/pi_tests.py b/pi_tests/pi_tests.py index 43bf99589..7c3bfcf8c 100644 --- a/pi_tests/pi_tests.py +++ b/pi_tests/pi_tests.py @@ -8,16 +8,14 @@ class pi_tests(test.test): def initialize(self): self.job.require_gcc() - # http://www.stardust.webpages.pl/files/patches/autotest/pi_tests.tar.bz2 - def setup(self, tarball = 'pi_tests.tar.bz2'): + def setup(self, tarball='pi_tests.tar.bz2'): utils.check_glibc_ver('2.5') tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) os.chdir(self.srcdir) utils.make() - - def execute(self, args = '1 300'): + def execute(self, args='1 300'): os.chdir(self.srcdir) utils.system('./start.sh ' + args) diff --git a/pktgen/pktgen.py b/pktgen/pktgen.py index 824357e1b..05d654f06 100644 --- a/pktgen/pktgen.py +++ b/pktgen/pktgen.py @@ -1,4 +1,5 @@ -import os, logging +import os +import logging from autotest.client import test, utils from autotest.client.shared import error @@ -6,8 +7,8 @@ class pktgen(test.test): version = 1 - def execute(self, eth='eth0', count=50000, clone_skb=1, \ - dst_ip='192.168.210.210', dst_mac='01:02:03:04:05:07'): + def execute(self, eth='eth0', count=50000, clone_skb=1, + dst_ip='192.168.210.210', dst_mac='01:02:03:04:05:07'): if not os.path.exists('/proc/net/pktgen'): utils.system('/sbin/modprobe pktgen') if not os.path.exists('/proc/net/pktgen'): @@ -23,8 +24,8 @@ def execute(self, eth='eth0', count=50000, clone_skb=1, \ # Configure the individual devices logging.info('Configuring devices') - self.ethdev='/proc/net/pktgen/' + eth - self.pgdev=self.ethdev + self.ethdev = '/proc/net/pktgen/' + eth + self.pgdev = self.ethdev if clone_skb: self.pgset('clone_skb %d' % (count)) @@ -35,16 +36,15 @@ def execute(self, eth='eth0', count=50000, clone_skb=1, \ self.pgset('count %d' % (count)) # Time to run - self.pgdev='/proc/net/pktgen/pgctrl' + self.pgdev = '/proc/net/pktgen/pgctrl' self.pgset('start') output = os.path.join(self.resultsdir, eth) - utils.system ('cp %s %s' % (self.ethdev, output)) - + utils.system('cp %s %s' % (self.ethdev, output)) def pgset(self, command): file = open(self.pgdev, 'w') - file.write(command + '\n'); + file.write(command + '\n') file.close if not utils.grep('Result: OK', self.pgdev): diff --git a/posixtest/posixtest.py b/posixtest/posixtest.py index dcf0ca5b0..3c09af8ee 100644 --- a/posixtest/posixtest.py +++ b/posixtest/posixtest.py @@ -6,15 +6,15 @@ __author__ = '''mohd.omar@in.ibm.com (Mohammed Omar)''' + class posixtest(test.test): version = 1 def initialize(self): self.job.require_gcc() - # http://ufpr.dl.sourceforge.net/sourceforge/posixtest/posixtestsuite-1.5.2.tar.gz - def setup(self, tarball = 'posixtestsuite-1.5.2.tar.gz'): + def setup(self, tarball='posixtestsuite-1.5.2.tar.gz'): self.posix_tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(self.posix_tarball, self.srcdir) os.chdir(self.srcdir) @@ -23,7 +23,6 @@ def setup(self, tarball = 'posixtestsuite-1.5.2.tar.gz'): utils.system('patch -p1 < %s/posix-linux.patch' % self.bindir) utils.make() - def execute(self): os.chdir(self.srcdir) utils.system('./run_tests THR') diff --git a/profiler_sync/profiler_sync.py b/profiler_sync/profiler_sync.py index ee1fceec9..39be91c7a 100644 --- a/profiler_sync/profiler_sync.py +++ b/profiler_sync/profiler_sync.py @@ -5,10 +5,10 @@ from autotest.client import test from autotest.client.shared import barrier + class profiler_sync(test.test): version = 1 - def execute(self, timeout_sync, timeout_start, timeout_stop, hostid, masterid, all_ids): """ diff --git a/profiler_test/profiler_test.py b/profiler_test/profiler_test.py index 652759d48..da07a3add 100644 --- a/profiler_test/profiler_test.py +++ b/profiler_test/profiler_test.py @@ -6,7 +6,6 @@ class profiler_test(test.test): version = 2 - def initialize(self, profiler=None, profiler_args=(), profiler_dargs=None): """ Initialize this test with the profiler name, args and dargs. @@ -21,7 +20,6 @@ def initialize(self, profiler=None, profiler_args=(), profiler_dargs=None): self._profiler_args = profiler_args self._profiler_dargs = profiler_dargs or {} - def execute(self, seconds=5): """ Add and start the profiler, sleep some seconds, stop and delete it. diff --git a/qemu_iotests/qemu_iotests.py b/qemu_iotests/qemu_iotests.py index 71b693245..37603160c 100644 --- a/qemu_iotests/qemu_iotests.py +++ b/qemu_iotests/qemu_iotests.py @@ -1,9 +1,12 @@ -import os, re, logging +import os +import re +import logging from autotest.client import test, utils, os_dep from autotest.client.shared import error class qemu_iotests(test.test): + """ This autotest module runs the qemu_iotests testsuite. @@ -12,11 +15,12 @@ class qemu_iotests(test.test): @see: http://www.kernel.org/pub/scm/linux/kernel/git/hch/qemu-iotests.git """ version = 2 + def initialize(self, qemu_path=''): if qemu_path: # Prepending the path at the beginning of $PATH will make the # version found on qemu_path be preferred over other ones. - os.environ['PATH'] = qemu_path + ":" + os.environ['PATH'] + os.environ['PATH'] = qemu_path + ":" + os.environ['PATH'] try: self.qemu_img_path = os_dep.command('qemu-img') self.qemu_io_path = os_dep.command('qemu-io') @@ -24,7 +28,6 @@ def initialize(self, qemu_path=''): raise error.TestNAError('Commands qemu-img or qemu-io missing') self.job.require_gcc() - def setup(self, tarball='qemu-iotests.tar.bz2'): """ Uncompresses the tarball and cleans any leftover output files. @@ -36,7 +39,6 @@ def setup(self, tarball='qemu-iotests.tar.bz2'): os.chdir(self.srcdir) utils.make('clean') - def run_once(self, options='', testlist=''): """ Passes the appropriate parameters to the testsuite. diff --git a/reaim/reaim.py b/reaim/reaim.py index 7fa92afec..1b10e0554 100644 --- a/reaim/reaim.py +++ b/reaim/reaim.py @@ -1,5 +1,6 @@ # Needs autoconf & automake & libtool to be installed. Ewwwwwwwwwwwwwwwwwwwwww -import re, os +import re +import os from autotest.client import test, utils, os_dep @@ -7,7 +8,7 @@ class reaim(test.test): version = 1 # http://prdownloads.sourceforge.net/re-aim-7/osdl-aim-7.0.1.13.tar.gz - def setup(self, tarball = 'osdl-aim-7.0.1.13.tar.gz'): + def setup(self, tarball='osdl-aim-7.0.1.13.tar.gz'): tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) @@ -15,7 +16,7 @@ def setup(self, tarball = 'osdl-aim-7.0.1.13.tar.gz'): libs = '-L' + self.autodir + '/deps/libaio/lib -laio' cflags = '-I ' + self.autodir + '/deps/libaio/include' var_libs = 'LIBS="' + libs + '"' - var_cflags = 'CFLAGS="' + cflags + '"' + var_cflags = 'CFLAGS="' + cflags + '"' self.make_flags = var_libs + ' ' + var_cflags os_dep.commands('autoconf', 'automake', 'libtoolize') @@ -31,15 +32,13 @@ def setup(self, tarball = 'osdl-aim-7.0.1.13.tar.gz'): utils.system(self.make_flags + ' make') os.rename('src/reaim', 'reaim') - def initialize(self): self.job.require_gcc() - self.ldlib = 'LD_LIBRARY_PATH=%s/deps/libaio/lib'%(self.autodir) - + self.ldlib = 'LD_LIBRARY_PATH=%s/deps/libaio/lib' % (self.autodir) - def execute(self, iterations = 1, workfile = 'workfile.short', - start = 1, end = 10, increment = 2, - extra_args = '', tmpdir = None): + def execute(self, iterations=1, workfile='workfile.short', + start=1, end=10, increment=2, + extra_args='', tmpdir=None): if not tmpdir: tmpdir = self.tmpdir @@ -72,7 +71,6 @@ def execute(self, iterations = 1, workfile = 'workfile.short', self.__format_results("\n".join(results)) - def __format_results(self, results): out = open(self.resultsdir + '/keyval', 'w') for line in results.split('\n'): diff --git a/real_time_tests/real_time_tests.py b/real_time_tests/real_time_tests.py index 178241436..d8c7638d4 100644 --- a/real_time_tests/real_time_tests.py +++ b/real_time_tests/real_time_tests.py @@ -1,18 +1,19 @@ import os from autotest.client import test, utils + class real_time_tests(test.test): version = 1 preserve_srcdir = True # http://git.kernel.org/?p=linux/kernel/git/galak/ltp.git;a=tree;f=testcases/realtime - def setup(self, tarball = 'realtime-latest-git-snapshot.tar.bz2'): + def setup(self, tarball='realtime-latest-git-snapshot.tar.bz2'): utils.check_glibc_ver('2.5') self.tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(self.tarball, self.srcdir) os.chdir(self.srcdir) utils.system('patch -p1 < %s/path-fix.patch' % self.bindir) - def execute(self, args = '-l 10'): + def execute(self, args='-l 10'): os.chdir(self.srcdir) utils.system('./run.sh -t func ' + args) diff --git a/regression/regression.py b/regression/regression.py index e74694de5..1dfd44ce7 100644 --- a/regression/regression.py +++ b/regression/regression.py @@ -2,6 +2,7 @@ from autotest.client import test, utils from autotest.client.shared import error + class regression(test.test): version = 1 @@ -14,20 +15,20 @@ def execute(self, old, new, compare_list): """ kv_old = utils.read_keyval(old) kv_new = utils.read_keyval(new) - failed = 0; - first_regression = None; + failed = 0 + first_regression = None logging.info('========= Comparison table for %30s ' - '=========' % self.tagged_testname) + '=========' % self.tagged_testname) logging.info("%20s | %10s | %10s | %10s | %10s | %s" % - ('field name', 'old value', 'new value', - 'cmp res', 'status', 'cmp function')) + ('field name', 'old value', 'new value', + 'cmp res', 'status', 'cmp function')) for field, cmpfn in compare_list: if not field in kv_old: - raise error.TestError('Cant not find field:%s in %s' \ - % (field, old + '/keyval')) + raise error.TestError('Cant not find field:%s in %s' + % (field, old + '/keyval')) if not field in kv_new: - raise error.TestError('Cant not find field:%s in %s' \ - % (field, new + '/keyval')) + raise error.TestError('Cant not find field:%s in %s' + % (field, new + '/keyval')) res = cmpfn(kv_old[field], kv_new[field]) if res: failed += 1 @@ -38,7 +39,7 @@ def execute(self, old, new, compare_list): msg = 'OK' logging.info("%20s | %10s | %10s | %5s | %5s | %s" % (field, kv_old[field], - kv_new[field],res, msg, cmpfn)) + kv_new[field], res, msg, cmpfn)) logging.info("========= RESULT: total:%10d failed:%10d " "==================" % diff --git a/reindent.py b/reindent.py index 65749f0be..5c5bb9dbb 100755 --- a/reindent.py +++ b/reindent.py @@ -42,19 +42,22 @@ __version__ = "1" import tokenize -import os, shutil +import os +import shutil import sys -verbose = 0 -recurse = 0 -dryrun = 0 +verbose = 0 +recurse = 0 +dryrun = 0 makebackup = True + def usage(msg=None): if msg is not None: print >> sys.stderr, msg print >> sys.stderr, __doc__ + def errprint(*args): sep = "" for arg in args: @@ -62,12 +65,13 @@ def errprint(*args): sep = " " sys.stderr.write("\n") + def main(): import getopt global verbose, recurse, dryrun, makebackup try: opts, args = getopt.getopt(sys.argv[1:], "drnvh", - ["dryrun", "recurse", "nobackup", "verbose", "help"]) + ["dryrun", "recurse", "nobackup", "verbose", "help"]) except getopt.error, msg: usage(msg) return @@ -91,6 +95,7 @@ def main(): for arg in args: check(arg) + def check(file): if os.path.isdir(file) and not os.path.islink(file): if verbose: @@ -100,7 +105,7 @@ def check(file): fullname = os.path.join(file, name) if ((recurse and os.path.isdir(fullname) and not os.path.islink(fullname)) - or name.lower().endswith(".py")): + or name.lower().endswith(".py")): check(fullname) return @@ -136,6 +141,7 @@ def check(file): print "unchanged." return False + def _rstrip(line, JUNK='\n \t'): """Return line stripped of trailing spaces, tabs, newlines. @@ -145,10 +151,11 @@ def _rstrip(line, JUNK='\n \t'): """ i = len(line) - while i > 0 and line[i-1] in JUNK: + while i > 0 and line[i - 1] in JUNK: i -= 1 return line[:i] + class Reindenter: def __init__(self, f): @@ -189,9 +196,9 @@ def run(self): # we see a line with *something* on it. i = stats[0][0] after.extend(lines[1:i]) - for i in range(len(stats)-1): + for i in range(len(stats) - 1): thisstmt, thislevel = stats[i] - nextstmt = stats[i+1][0] + nextstmt = stats[i + 1][0] have = getlspace(lines[thisstmt]) want = thislevel * 4 if want < 0: @@ -203,7 +210,7 @@ def run(self): want = have2want.get(have, -1) if want < 0: # Then it probably belongs to the next real stmt. - for j in xrange(i+1, len(stats)-1): + for j in xrange(i + 1, len(stats) - 1): jline, jlevel = stats[j] if jlevel >= 0: if have == getlspace(lines[jline]): @@ -213,11 +220,11 @@ def run(self): # comment like this one, # in which case we should shift it like its base # line got shifted. - for j in xrange(i-1, -1, -1): + for j in xrange(i - 1, -1, -1): jline, jlevel = stats[j] if jlevel >= 0: - want = have + getlspace(after[jline-1]) - \ - getlspace(lines[jline]) + want = have + getlspace(after[jline - 1]) - \ + getlspace(lines[jline]) break if want < 0: # Still no luck -- leave it alone. @@ -293,6 +300,8 @@ def tokeneater(self, type, token, (sline, scol), end, line, self.stats.append((sline, self.level)) # Count number of leading blanks. + + def getlspace(line): i, n = 0, len(line) while i < n and line[i] == " ": diff --git a/rmaptest/rmaptest.py b/rmaptest/rmaptest.py index aae64b66b..9d70041f8 100644 --- a/rmaptest/rmaptest.py +++ b/rmaptest/rmaptest.py @@ -6,10 +6,11 @@ tests = [["rmaptest", "-h -i100 -n100 -s100 -t100 -V10 -v file1.dat"], ["rmaptest", "-l -i100 -n100 -s100 -t100 -V10 -v file2.dat"], ["rmaptest", "-r -i100 -n100 -s100 -t100 -V10 -v file3.dat"], - ] + ] name = 0 arglist = 1 + class rmaptest(test.test): version = 1 preserve_srcdir = True @@ -17,13 +18,11 @@ class rmaptest(test.test): def initialize(self): self.job.require_gcc() - def setup(self): os.chdir(self.srcdir) utils.system(utils.get_cc() + ' -Wall -o rmaptest rmap-test.c') - - def execute(self, args = ''): + def execute(self, args=''): os.chdir(self.tmpdir) for test in tests: cmd = '%s/%s %s %s' % (self.srcdir, test[name], args, test[arglist]) diff --git a/rtc/rtc.py b/rtc/rtc.py index 65f12f52b..d4a71a386 100644 --- a/rtc/rtc.py +++ b/rtc/rtc.py @@ -2,6 +2,7 @@ from autotest.client import test, utils from autotest.client.shared import error + class rtc(test.test): version = 1 preserve_srcdir = True @@ -11,11 +12,9 @@ def setup(self): utils.make('clobber') utils.make() - def initialize(self): self.job.require_gcc() - def run_once(self, def_rtc="/dev/rtc0", maxfreq=64): if not os.path.exists(def_rtc): raise error.TestNAError("RTC device %s does not exist" % def_rtc) diff --git a/rttester/rttester.py b/rttester/rttester.py index 1805d5747..cdae390dd 100644 --- a/rttester/rttester.py +++ b/rttester/rttester.py @@ -7,7 +7,7 @@ class rttester(test.test): # http://www.stardust.webpages.pl/files/patches/autotest/rttester.tar.bz2 - def setup(self, tarball = 'rttester.tar.bz2'): + def setup(self, tarball='rttester.tar.bz2'): tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) diff --git a/run_pylint.py b/run_pylint.py index 162bb7aac..70b884e44 100755 --- a/run_pylint.py +++ b/run_pylint.py @@ -1,6 +1,8 @@ #!/usr/bin/python -u -import os, sys, fnmatch +import os +import sys +import fnmatch # do a basic check to see if pylint is even installed try: @@ -14,6 +16,7 @@ # By default, complain about all things LINT_VERBOSE = True + def set_verbosity(verbose): ''' Changes the verbosity level @@ -27,6 +30,8 @@ def set_verbosity(verbose): # patch up the logilab module lookup tools to understand autotest.* trash import logilab.common.modutils _ffm = logilab.common.modutils.file_from_modpath + + def file_from_modpath(modpath, path=None, context_file=None): if modpath[0] == "autotest": if modpath[1:]: @@ -47,7 +52,9 @@ def file_from_modpath(modpath, path=None, context_file=None): # patch up pylint import checker to handle our importing magic RealImportsChecker = imports.ImportsChecker + class CustomImportsChecker(imports.ImportsChecker): + def visit_from(self, node): if node.modname.startswith(ROOT_MODULE): node.modname = node.modname[len(ROOT_MODULE):] @@ -120,7 +127,7 @@ def check_dir(dir_path): pylint_base_opts = get_pylint_opts() if '--' in file_list: index = file_list.index('--') - pylint_base_opts.extend(file_list[index+1:]) + pylint_base_opts.extend(file_list[index + 1:]) file_list = file_list[:index] if len(file_list) > 0: for path in file_list: diff --git a/scrashme/scrashme.py b/scrashme/scrashme.py index 6ab8175a6..13b027cd5 100644 --- a/scrashme/scrashme.py +++ b/scrashme/scrashme.py @@ -3,6 +3,7 @@ class scrashme(test.test): + """ Runs the scrashme syscalls test suite. This test mode will exercise kernel syscalls randomically, or in a sequential fashion. @@ -38,14 +39,12 @@ class scrashme(test.test): def initialize(self): self.job.require_gcc() - - def setup(self, tarball = 'scrashme-git-snapshot-03-18-2010.tar.bz2'): + def setup(self, tarball='scrashme-git-snapshot-03-18-2010.tar.bz2'): tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) os.chdir(self.srcdir) utils.make() - def run_once(self, args_list=''): if args_list: args = args_list diff --git a/scsi_testsuite/scsi_testsuite.py b/scsi_testsuite/scsi_testsuite.py index 4b96053c5..046fbe77b 100644 --- a/scsi_testsuite/scsi_testsuite.py +++ b/scsi_testsuite/scsi_testsuite.py @@ -1,20 +1,24 @@ -import re, os,logging,shutil +import re +import os +import logging +import shutil from autotest.client import utils, test from autotest.client.shared import git, software_manager, error + class SCSIUtilNotAvailable(Exception): + def __init__(self, name): self.util_name = name - def __str__(self): return "%s not installed" % self.util_name class UnknownSourceType(Exception): - def __init__(self,source): - self.source = source + def __init__(self, source): + self.source = source def __str__(self): return "Unknown source type: %s" % self.source @@ -24,8 +28,7 @@ class scsi_testsuite(test.test): version = 1 scsi_testsuite_config = "/etc/scsi-testsuite.config" - - def setup(self,source_type, source_location, disk_addr, **kwargs): + def setup(self, source_type, source_location, disk_addr, **kwargs): if source_type == "tar": tarball = utils.unmap_url(self.bindir, source_location, self.tmpdir) self.repodir = os.path.join(self.tmpdir, "scsi_testsuite") @@ -53,17 +56,17 @@ def setup(self,source_type, source_location, disk_addr, **kwargs): disk_addr[1]["lun"]) self.devname = utils.system_output( - "lsscsi %d %d %d %d | sed -n 's,.*/dev,/dev,p' " % - addr) + "lsscsi %d %d %d %d | sed -n 's,.*/dev,/dev,p' " % + addr) elif disk_addr[0] == "serial": disklist = os.listdir("/dev/disk/by-id/") for diskfile in disklist: - if re.match("scsi-.*%s$" % disk_addr[1],diskfile) is not None: - self.devname = os.path.join("/dev/disk/by-id",diskfile) + if re.match("scsi-.*%s$" % disk_addr[1], diskfile) is not None: + self.devname = os.path.join("/dev/disk/by-id", diskfile) break elif disk_addr[0] == "file": - if os.access(disk_addr[1],os.F_OK) == True: + if os.access(disk_addr[1], os.F_OK) == True: self.devname = disk_addr[1] if self.devname == "": @@ -72,40 +75,38 @@ def setup(self,source_type, source_location, disk_addr, **kwargs): raise error.TestFail("Disk not found, cannot execute tests") try: - cf = open(self.scsi_testsuite_config,"w") + cf = open(self.scsi_testsuite_config, "w") cf.write("export TEST_DEV=%s" % self.devname) cf.close() except IOError: logging.warning("Can't write configuration file. Using defaults") - - def run_once(self,run_tests,**kwargs): + def run_once(self, run_tests, **kwargs): os.chdir(self.repodir) failed = 0 run = 0 for testname in run_tests: - result = utils.run("./check %s" % testname,ignore_status=True) - run = run + 1 + result = utils.run("./check %s" % testname, ignore_status=True) + run = run + 1 shutil.copy( - os.path.join(self.repodir,"%s.out" % testname), - os.path.join(self.resultsdir,"%s.out" % testname)) + os.path.join(self.repodir, "%s.out" % testname), + os.path.join(self.resultsdir, "%s.out" % testname)) if result.exit_status == 0: logging.info("Test %s SUCCEED" % testname) - self.write_attr_keyval({testname:"Succeed"}) + self.write_attr_keyval({testname: "Succeed"}) else: failed = failed + 1 shutil.copy( - os.path.join(self.repodir,"%s.out.bad" % testname), - os.path.join(self.resultsdir,"%s.out.bad" % testname)) + os.path.join(self.repodir, "%s.out.bad" % testname), + os.path.join(self.resultsdir, "%s.out.bad" % testname)) logging.info("Test %s FAILED" % testname) - self.write_attr_keyval({testname:"Failed"}) + self.write_attr_keyval({testname: "Failed"}) if failed > 0: raise error.TestFail("Failed %d of %d tests" % (failed, run)) - def cleanup(self): shutil.rmtree(self.repodir) - if os.access(self.scsi_testsuite_config,os.F_OK): + if os.access(self.scsi_testsuite_config, os.F_OK): os.remove(self.scsi_testsuite_config) diff --git a/selftest/selftest.py b/selftest/selftest.py index 26cefcae5..58370f7fe 100644 --- a/selftest/selftest.py +++ b/selftest/selftest.py @@ -1,4 +1,6 @@ -import os, sys, logging +import os +import sys +import logging from autotest.client import test from autotest.client.shared import error @@ -30,11 +32,11 @@ def __mark(self, checkpoint): if (current != checkpoint): raise error.JobError("selftest: sequence was " + - "%d when %d expected" % (current, checkpoint)) + "%d when %d expected" % (current, checkpoint)) def __throw(self): # pylint: disable=E0602 - __does_not_exist = __does_not_exist_either # @UndefinedVariable + __does_not_exist = __does_not_exist_either # @UndefinedVariable def __print(self, msg): sys.stdout.write(msg) diff --git a/signaltest/signaltest.py b/signaltest/signaltest.py index 5b822c1ee..0b29e6e56 100644 --- a/signaltest/signaltest.py +++ b/signaltest/signaltest.py @@ -10,12 +10,10 @@ class signaltest(test.test): def initialize(self): self.job.require_gcc() - # git://git.kernel.org/pub/scm/linux/kernel/git/tglx/rt-tests.git def setup(self): os.chdir(self.srcdir) utils.make() - - def execute(self, args = '-t 10 -l 100000'): + def execute(self, args='-t 10 -l 100000'): utils.system(self.srcdir + '/signaltest ' + args) diff --git a/sleeptest/sleeptest.py b/sleeptest/sleeptest.py index f1b42a0d2..cba99c28f 100644 --- a/sleeptest/sleeptest.py +++ b/sleeptest/sleeptest.py @@ -1,6 +1,7 @@ import time from autotest.client import test + class sleeptest(test.test): version = 1 diff --git a/smatch/smatch.py b/smatch/smatch.py index 6df5443a3..e06df79a7 100644 --- a/smatch/smatch.py +++ b/smatch/smatch.py @@ -1,7 +1,12 @@ -import os, logging, commands, re, shutil +import os +import logging +import commands +import re +import shutil from autotest.client import kernel, test, utils from autotest.client.shared import software_manager, error + class smatch(test.test): version = 1 @@ -39,7 +44,6 @@ def execute(self, kernel=None, build_target=None, base_tree=None, if (kernel is None) and (base_tree is None): raise error.TestError("Test requires at least one parameter {kernel | base_tree}") - if not kernel: kernel = self.job.kernel(base_tree) own_kernel = True @@ -69,16 +73,15 @@ def execute(self, kernel=None, build_target=None, base_tree=None, logfile = os.path.join(self.resultsdir, 'smatch.log') errlog = os.path.join(self.resultsdir, 'smatch.log.error') - if not build_target: - build_target = self.build_target + build_target = self.build_target # TODO Add more debug defines - debug_def='CF="-D__CHECK_ENDIAN__"' + debug_def = 'CF="-D__CHECK_ENDIAN__"' make_opts = 'C=2 %s CHECK="%s -p=kernel"' % \ (debug_def, os.path.join(self.srcdir, 'smatch')) - make_cmd = " %s %s 2> %s | tee %s" %(make_opts, build_target, errlog, logfile) + make_cmd = " %s %s 2> %s | tee %s" % (make_opts, build_target, errlog, logfile) utils.make(make_cmd) # Account errors and warnings and save it in key-value diff --git a/sparse/sparse.py b/sparse/sparse.py index b531abcd6..792666d58 100644 --- a/sparse/sparse.py +++ b/sparse/sparse.py @@ -1,4 +1,5 @@ -import os, re +import os +import re from autotest.client.shared import error from autotest.client import test, utils, kernel @@ -17,15 +18,13 @@ def setup(self, tarball='sparse-2013-06-26.tar.gz'): utils.make() - self.top_dir = self.job.tmpdir+'/sparse' - + self.top_dir = self.job.tmpdir + '/sparse' def execute(self, kernel=None, patch=None, build_target=None, base_tree=None, config=None): if (kernel is None) and (base_tree is None): raise error.TestError("Test requires at least kernel or base_tree parameters") - if not kernel: kernel = self.job.kernel(base_tree) if patch: @@ -45,13 +44,13 @@ def execute(self, kernel=None, patch=None, build_target=None, base_tree=None, co kernel.clean() if not build_target: - build_target = self.build_target + build_target = self.build_target # TODO Add more debug defines - debug_def='CF="-D__CHECK_ENDIAN__"' + debug_def = 'CF="-D__CHECK_ENDIAN__"' make_opts = 'C=2 %s CHECK="%s -p=kernel"' % (debug_def, os.path.join(self.srcdir, 'sparse')) - make_cmd = " %s %s 2> %s | tee %s" %(make_opts, build_target, errlog, logfile) + make_cmd = " %s %s 2> %s | tee %s" % (make_opts, build_target, errlog, logfile) utils.make(make_cmd) # Account number of warnings and error and store as key-value diff --git a/spew/spew.py b/spew/spew.py index 9374144e2..70fe162b5 100644 --- a/spew/spew.py +++ b/spew/spew.py @@ -8,9 +8,8 @@ class spew(test.test): def initialize(self): self.job.require_gcc() - # ftp://ftp.berlios.de/pub/spew/1.0.5/spew-1.0.5.tgz - def setup(self, tarball = 'spew-1.0.5.tgz'): + def setup(self, tarball='spew-1.0.5.tgz'): self.tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(self.tarball, self.srcdir) @@ -18,8 +17,7 @@ def setup(self, tarball = 'spew-1.0.5.tgz'): utils.configure() utils.make() - - def run_once(self, testdir = None, filesize='100M', type='write', + def run_once(self, testdir=None, filesize='100M', type='write', pattern='random'): cmd = os.path.join(self.srcdir, 'src/spew') if not testdir: @@ -27,7 +25,7 @@ def run_once(self, testdir = None, filesize='100M', type='write', tmpfile = os.path.join(testdir, 'spew-test.%d' % os.getpid()) results = os.path.join(self.resultsdir, 'stdout.%d' % self.iteration) args = '--%s -p %s -b 2k -B 2M %s %s' % \ - (type, pattern, filesize, tmpfile) + (type, pattern, filesize, tmpfile) cmd += ' ' + args open(self.resultsdir + '/command', 'w').write(cmd + '\n') diff --git a/stress/stress.py b/stress/stress.py index a29ac0b71..e5ee21abf 100644 --- a/stress/stress.py +++ b/stress/stress.py @@ -4,6 +4,7 @@ class stress(test.test): + """ Calls stress, a simple program which aims to impose certain types of computing stress on the target machine. @@ -17,9 +18,8 @@ class stress(test.test): def initialize(self): self.job.require_gcc() - # http://weather.ou.edu/~apw/projects/stress/stress-1.0.4.tar.gz - def setup(self, tarball = 'stress-1.0.4.tar.gz'): + def setup(self, tarball='stress-1.0.4.tar.gz'): tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) os.chdir(self.srcdir) @@ -27,8 +27,7 @@ def setup(self, tarball = 'stress-1.0.4.tar.gz'): utils.configure() utils.make() - - def run_once(self, args = '', stress_length=60): + def run_once(self, args='', stress_length=60): if not args: # We will use 2 workers of each type for each CPU detected threads = 2 * utils.count_cpus() diff --git a/synctest/synctest.py b/synctest/synctest.py index 2fba6b81a..5d7653d84 100644 --- a/synctest/synctest.py +++ b/synctest/synctest.py @@ -10,12 +10,10 @@ class synctest(test.test): def initialize(self): self.job.require_gcc() - def setup(self): os.chdir(self.srcdir) utils.make() - def run_once(self, len, loop, testdir=None): args = len + ' ' + loop output = os.path.join(self.srcdir, 'synctest ') diff --git a/sysbench/sysbench.py b/sysbench/sysbench.py index c34beb8fa..915df1c60 100644 --- a/sysbench/sysbench.py +++ b/sysbench/sysbench.py @@ -1,4 +1,7 @@ -import os, time, re, pwd +import os +import time +import re +import pwd from autotest.client import test, utils from autotest.client.shared import error @@ -11,7 +14,7 @@ def initialize(self): self.results = [] # http://osdn.dl.sourceforge.net/sourceforge/sysbench/sysbench-0.4.8.tar.gz - def setup(self, tarball = 'sysbench-0.4.8.tar.bz2'): + def setup(self, tarball='sysbench-0.4.8.tar.bz2'): tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) self.job.setup_dep(['pgsql', 'mysql']) @@ -27,14 +30,13 @@ def setup(self, tarball = 'sysbench-0.4.8.tar.bz2'): % (pgsql_dir, mysql_dir)) utils.make('-j %d' % utils.count_cpus()) - - def run_once(self, db_type = 'pgsql', build = 1, \ - num_threads = utils.count_cpus(), max_time = 60, \ - read_only = 0, args = ''): + def run_once(self, db_type='pgsql', build=1, + num_threads=utils.count_cpus(), max_time=60, + read_only=0, args=''): plib = os.path.join(self.autodir, 'deps/pgsql/pgsql/lib') mlib = os.path.join(self.autodir, 'deps/mysql/mysql/lib/mysql') ld_path = utils.prepend_path(plib, - utils.environ('LD_LIBRARY_PATH')) + utils.environ('LD_LIBRARY_PATH')) ld_path = utils.prepend_path(mlib, ld_path) os.environ['LD_LIBRARY_PATH'] = ld_path @@ -54,7 +56,6 @@ def run_once(self, db_type = 'pgsql', build = 1, \ elif (db_type == 'mysql'): self.execute_mysql(build, num_threads, max_time, read_only, args) - def execute_pgsql(self, build, num_threads, max_time, read_only, args): bin = os.path.join(self.autodir, 'deps/pgsql/pgsql/bin') data = os.path.join(self.autodir, 'deps/pgsql/pgsql/data') @@ -68,24 +69,24 @@ def execute_pgsql(self, build, num_threads, max_time, read_only, args): # Database must be able to write its output into debugdir os.chown(self.debugdir, self.dbuid, 0) - utils.system(self.sudo + bin + '/pg_ctl -D %s -l %s start' %(data, log)) + utils.system(self.sudo + bin + '/pg_ctl -D %s -l %s start' % (data, log)) # Wait for database to start time.sleep(5) try: base_cmd = self.srcdir + '/sysbench/sysbench --test=oltp ' \ - '--db-driver=pgsql --pgsql-user=' + self.dbuser + '--db-driver=pgsql --pgsql-user=' + self.dbuser if build == 1: utils.system(self.sudo + bin + '/createdb sbtest') - cmd = base_cmd +' prepare' + cmd = base_cmd + ' prepare' utils.system(cmd) cmd = base_cmd + \ - ' --num-threads=' + str(num_threads) + \ - ' --max-time=' + str(max_time) + \ - ' --max-requests=0' + ' --num-threads=' + str(num_threads) + \ + ' --max-time=' + str(max_time) + \ + ' --max-requests=0' if read_only: cmd = cmd + ' --oltp-read-only=on' @@ -99,7 +100,6 @@ def execute_pgsql(self, build, num_threads, max_time, read_only, args): utils.system(self.sudo + bin + '/pg_ctl -D ' + data + ' stop') - def execute_mysql(self, build, num_threads, max_time, read_only, args): bin = os.path.join(self.autodir, 'deps/mysql/mysql/bin') data = os.path.join(self.autodir, 'deps/mysql/mysql/var') @@ -111,8 +111,8 @@ def execute_mysql(self, build, num_threads, max_time, read_only, args): os.chown(data, self.dbuid, 0) utils.system(bin + '/mysql_install_db --user=' + self.dbuser) - utils.system(bin + '/mysqld_safe --log-error=' + log + \ - ' --user=' + self.dbuser + ' &') + utils.system(bin + '/mysqld_safe --log-error=' + log + + ' --user=' + self.dbuser + ' &') # Wait for database to start time.sleep(5) @@ -122,15 +122,15 @@ def execute_mysql(self, build, num_threads, max_time, read_only, args): '--db-driver=mysql --mysql-user=root' if build == 1: - utils.system('echo "create database sbtest" | ' + \ - bin + '/mysql -u root') - cmd = base_cmd +' prepare' + utils.system('echo "create database sbtest" | ' + + bin + '/mysql -u root') + cmd = base_cmd + ' prepare' utils.system(cmd) cmd = base_cmd + \ - ' --num-threads=' + str(num_threads) + \ - ' --max-time=' + str(max_time) + \ - ' --max-requests=0' + ' --num-threads=' + str(num_threads) + \ + ' --max-time=' + str(max_time) + \ + ' --max-requests=0' if read_only: cmd = cmd + ' --oltp-read-only=on' @@ -144,7 +144,6 @@ def execute_mysql(self, build, num_threads, max_time, read_only, args): utils.system(bin + '/mysqladmin shutdown') - def postprocess(self): self.__format_results("\n".join(self.results)) diff --git a/systemtap/systemtap.py b/systemtap/systemtap.py index ab04df4f2..242faeb34 100644 --- a/systemtap/systemtap.py +++ b/systemtap/systemtap.py @@ -1,9 +1,12 @@ -import os, shutil, re +import os +import shutil +import re from autotest.client import test, utils from autotest.client.shared import error class systemtap(test.test): + """ This autotest module runs the systemtap test suite. @@ -11,13 +14,14 @@ class systemtap(test.test): """ version = 1 + def initialize(self, local=False): self.job.require_gcc() self.systemtap_dir = '' if local == False: self.systemtap_dir = os.path.join(self.autodir, - 'deps/systemtap/systemtap') + 'deps/systemtap/systemtap') def setup(self, local=False, tarball_systemtap='systemtap-1.8.tar.gz', tarball_elfutils='elfutils-0.155.tar.bz2'): @@ -55,7 +59,6 @@ def setup(self, local=False, tarball_systemtap='systemtap-1.8.tar.gz', except Exception: raise error.TestError('simple systemtap test failed, kernel debuginfo package may be missing: %s' % script) - def run_once(self): testsuite = os.path.join(self.srcdir, 'testsuite') os.chdir(testsuite) @@ -63,7 +66,7 @@ def run_once(self): dejagnu_dir = os.path.join(self.autodir, 'deps/dejagnu/dejagnu') utils.system('PATH=%s/bin:%s/bin:$PATH make installcheck' % - (self.systemtap_dir, dejagnu_dir)) + (self.systemtap_dir, dejagnu_dir)) # After we are done with this iteration, we move the log files to # the results dir @@ -83,7 +86,6 @@ def run_once(self): shutil.move(log, self.logfile) shutil.move(sum, self.sumfile) - def postprocess_iteration(self): os.chdir(self.resultsdir) diff --git a/tbench/tbench.py b/tbench/tbench.py index 2f2b532ae..54af93ee6 100644 --- a/tbench/tbench.py +++ b/tbench/tbench.py @@ -1,4 +1,7 @@ -import time, os, signal, re +import time +import os +import signal +import re from autotest.client import test, utils @@ -8,9 +11,8 @@ class tbench(test.test): def initialize(self): self.job.require_gcc() - # http://samba.org/ftp/tridge/dbench/dbench-3.04.tar.gz - def setup(self, tarball = 'dbench-3.04.tar.gz'): + def setup(self, tarball='dbench-3.04.tar.gz'): tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) os.chdir(self.srcdir) @@ -18,8 +20,7 @@ def setup(self, tarball = 'dbench-3.04.tar.gz'): utils.configure() utils.make() - - def run_once(self, nprocs = None, args = ''): + def run_once(self, nprocs=None, args=''): # only supports combined server+client model at the moment # should support separate I suppose, but nobody uses it if not nprocs: @@ -40,8 +41,7 @@ def run_once(self, nprocs = None, args = ''): server = self.srcdir + '/tbench_srv' os.execlp(server, server) - def postprocess_iteration(self): pattern = re.compile(r"Throughput (.*?) MB/sec (.*?) procs") (throughput, procs) = pattern.findall(self.results)[0] - self.write_perf_keyval({'throughput':throughput, 'procs':procs}) + self.write_perf_keyval({'throughput': throughput, 'procs': procs}) diff --git a/tiobench/tiobench.py b/tiobench/tiobench.py index 39bb3dc05..ee6f1cfd2 100644 --- a/tiobench/tiobench.py +++ b/tiobench/tiobench.py @@ -1,4 +1,5 @@ -import os, logging +import os +import logging from autotest.client import test, utils @@ -6,7 +7,7 @@ class tiobench(test.test): version = 1 # http://prdownloads.sourceforge.net/tiobench/tiobench-0.3.3.tar.gz - def setup(self, tarball = 'tiobench-0.3.3.tar.bz2'): + def setup(self, tarball='tiobench-0.3.3.tar.bz2'): tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) os.chdir(self.srcdir) @@ -14,12 +15,10 @@ def setup(self, tarball = 'tiobench-0.3.3.tar.bz2'): utils.system('patch -p1 < %s/tiotest.patch' % self.bindir) utils.system('make') - def initialize(self): self.job.require_gcc() - - def run_once(self, dir = None, args = None): + def run_once(self, dir=None, args=None): if not dir: self.dir = self.tmpdir else: diff --git a/tracing_microbenchmark/base_tracer.py b/tracing_microbenchmark/base_tracer.py index ca12e3bc1..bf9ab4b7e 100644 --- a/tracing_microbenchmark/base_tracer.py +++ b/tracing_microbenchmark/base_tracer.py @@ -3,6 +3,7 @@ class Tracer(object): + """ Common interface for tracing. """ @@ -18,13 +19,18 @@ def trace_config(self, path, value): def warmup(self, buffer_size_kb): pass + def cleanup(self): pass + def start_tracing(self): pass + def stop_tracing(self): pass + def gather_stats(self, results): pass + def reset_tracing(self): pass diff --git a/tracing_microbenchmark/tracing_microbenchmark.py b/tracing_microbenchmark/tracing_microbenchmark.py index 41489eacb..42a9ed17b 100644 --- a/tracing_microbenchmark/tracing_microbenchmark.py +++ b/tracing_microbenchmark/tracing_microbenchmark.py @@ -6,6 +6,7 @@ import tracers import base_tracer + class tracing_microbenchmark(test.test): version = 1 preserve_srcdir = True diff --git a/tsc/tsc.py b/tsc/tsc.py index b0154ea52..65273d6c2 100644 --- a/tsc/tsc.py +++ b/tsc/tsc.py @@ -1,7 +1,10 @@ -import os, re, logging +import os +import re +import logging from autotest.client import test, utils from autotest.client.shared import error + class tsc(test.test): version = 3 @@ -11,12 +14,10 @@ def setup(self): os.chdir(self.srcdir) utils.make() - def initialize(self): self.job.require_gcc() - - def run_once(self, args = '-t 650'): + def run_once(self, args='-t 650'): result = utils.run(self.srcdir + '/checktsc ' + args, stdout_tee=open(os.path.join(self.resultsdir, 'checktsc.log'), 'w'), @@ -26,21 +27,21 @@ def run_once(self, args = '-t 650'): result.exit_status) default_reason = ("UNKNOWN FAILURE: rc=%d from %s" % (result.exit_status, result.command)) - ## Analyze result.stdout to see if it is possible to form qualified - ## reason of failure and to raise an appropriate exception. - ## For this test we qualify the reason of failure if the - ## following conditions are met: - ## (i) result.exit_status = 1 - ## (ii) result.stdout ends with 'FAIL' - ## (iii) "FAIL" is preceded by one or more - ## lines in the following format: - ## CPU x - CPU y = - ## Set as a reason the line that contains max abs(delta) + # Analyze result.stdout to see if it is possible to form qualified + # reason of failure and to raise an appropriate exception. + # For this test we qualify the reason of failure if the + # following conditions are met: + # (i) result.exit_status = 1 + # (ii) result.stdout ends with 'FAIL' + # (iii) "FAIL" is preceded by one or more + # lines in the following format: + # CPU x - CPU y = + # Set as a reason the line that contains max abs(delta) if result.exit_status == 1: if result.stdout.strip('\n').endswith('FAIL'): - ## find all lines - ## CPU x - CPU y = - ## and parse out delta of max abs value + # find all lines + # CPU x - CPU y = + # and parse out delta of max abs value max_delta = 0 reason = '' threshold = int(args.split()[1]) @@ -56,6 +57,6 @@ def run_once(self, args = '-t 650'): threshold) raise error.TestFail(reason) - ## If we are here, we failed to qualify the reason of test failre - ## Consider it as a test error + # If we are here, we failed to qualify the reason of test failre + # Consider it as a test error raise error.TestError(default_reason) diff --git a/unixbench/unixbench.py b/unixbench/unixbench.py index ffbd2c417..c0ec74d65 100644 --- a/unixbench/unixbench.py +++ b/unixbench/unixbench.py @@ -1,4 +1,5 @@ -import os, re +import os +import re from autotest.client import test, utils from autotest.client.shared import error @@ -10,9 +11,8 @@ def initialize(self): self.job.require_gcc() self.err = None - # http://www.tux.org/pub/tux/niemi/unixbench/unixbench-4.1.0.tgz - def setup(self, tarball = 'unixbench-4.1.0.tar.bz2'): + def setup(self, tarball='unixbench-4.1.0.tar.bz2'): tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) os.chdir(self.srcdir) @@ -22,7 +22,6 @@ def setup(self, tarball = 'unixbench-4.1.0.tar.bz2'): utils.make() utils.system('rm pgms/select') - def run_once(self, args='', stepsecs=0): vars = ('TMPDIR=\"%s\" RESULTDIR=\"%s\"' % (self.tmpdir, self.resultsdir)) @@ -31,7 +30,7 @@ def run_once(self, args='', stepsecs=0): # 10 secs for small tests, 30 secs for bigger tests vars += ' systime=%i looper=%i seconds=%i'\ ' dhrytime=%i arithtime=%i' \ - % ((stepsecs,)*5) + % ((stepsecs,) * 5) os.chdir(self.srcdir) try: @@ -47,13 +46,11 @@ def run_once(self, args='', stepsecs=0): report_path = os.path.join(self.resultsdir, 'report') self.report_data = open(report_path).readlines()[9:] - def cleanup(self): # check err string and possible throw if self.err is not None: raise error.TestError(self.err) - def check_for_error(self, words): l = len(words) if l >= 3 and words[-3:l] == ['no', 'measured', 'results']: @@ -67,7 +64,6 @@ def check_for_error(self, words): else: return False - def postprocess_iteration(self): keyval = {} for line in self.report_data: diff --git a/unixbench5/unixbench5.py b/unixbench5/unixbench5.py index 4ef400d14..f214b54d3 100644 --- a/unixbench5/unixbench5.py +++ b/unixbench5/unixbench5.py @@ -1,9 +1,11 @@ -import os, re +import os +import re from autotest.client import test, utils from autotest.client.shared import error class unixbench5(test.test): + """ This test measure system wide performance by running the following tests: - Dhrystone - focuses on string handling. @@ -22,12 +24,10 @@ class unixbench5(test.test): """ version = 1 - def initialize(self): self.job.require_gcc() self.err = [] - def setup(self, tarball='unixbench-5.1.3.tgz'): """ Compiles unixbench. @@ -42,7 +42,6 @@ def setup(self, tarball='unixbench-5.1.3.tgz'): utils.system('patch -p0 < %s/Makefile.patch' % self.bindir) utils.make() - def run_once(self, args=''): vars = 'UB_TMPDIR="%s" UB_RESULTDIR="%s"' % (self.tmpdir, self.resultsdir) @@ -52,7 +51,6 @@ def run_once(self, args=''): 'raw_output_%s' % self.iteration) utils.open_write_close(self.results_path, self.report_data) - def cleanup(self): """ Check error index list and throw TestError if necessary. @@ -62,7 +60,6 @@ def cleanup(self): (" ".join(self.err), self.report_data)) raise error.TestError(e_msg) - def process_section(self, section, suffix): keyval = {} subsections = section.split('\n\n') @@ -89,10 +86,9 @@ def process_section(self, section, suffix): self.write_perf_keyval(keyval) - def postprocess_iteration(self): # Break up sections around dividing lines. - sections = self.report_data.split('-'*72) + sections = self.report_data.split('-' * 72) # First section is junk to us, second has results for single CPU run. if len(sections) > 1: diff --git a/wb_kupdate/common.py b/wb_kupdate/common.py index c18a7eb4c..2e2c9f1e4 100644 --- a/wb_kupdate/common.py +++ b/wb_kupdate/common.py @@ -1,4 +1,5 @@ -import os, sys +import os +import sys try: import autotest.client.setup_modules as setup_modules dirname = os.path.dirname(setup_modules.__file__) diff --git a/wb_kupdate/wb_kupdate.py b/wb_kupdate/wb_kupdate.py index adffb6513..b2a9c5919 100644 --- a/wb_kupdate/wb_kupdate.py +++ b/wb_kupdate/wb_kupdate.py @@ -1,11 +1,14 @@ -import datetime, logging, os, time +import datetime +import logging +import os +import time from autotest.client import test, utils from autotest.client.shared import error, utils_memory + class wb_kupdate(test.test): version = 1 - def _check_parameters(self, mount_point, write_size, file_count, old_cleanup=False): """ @@ -34,10 +37,9 @@ def _check_parameters(self, mount_point, write_size, file_count, raise error.TestError('Write size should be a positive integer.') # Check file_count > 0. - if not (file_count > 0) : + if not (file_count > 0): raise error.TestError('File count shoulde be a positive integer.') - def _reset_device(self): """ Reset the test. Reinitialize sparse file. @@ -54,14 +56,13 @@ def _reset_device(self): logging.debug('Cleanup - removing the mount_point.') os.rmdir(self.mount_point) - def _create_partition(self): """ Create and initialize the sparse file. """ # Recreate sparse_file. utils.system('dd if=/dev/zero of=%s bs=1M seek=1024 count=1' % - self.sparse_file) + self.sparse_file) # Format sparse_file. utils.system('echo "y" | mkfs -t %s %s' % @@ -71,7 +72,6 @@ def _create_partition(self): utils.system('mount -o loop -t %s %s %s' % (self.file_system, self.sparse_file, self.mount_point)) - def _needs_more_time(self, start_time, duration, _now=None): """ Checks to see if the test has run its course. @@ -89,8 +89,7 @@ def _needs_more_time(self, start_time, duration, _now=None): time_diff = datetime.datetime.now() - start_time else: time_diff = _now - start_time - return time_diff <= datetime.timedelta(seconds=duration*60) - + return time_diff <= datetime.timedelta(seconds=duration * 60) def _write_data(self, destination, counter, write_size): """ @@ -115,7 +114,6 @@ def _write_data(self, destination, counter, write_size): # Return write completion time. return write_completion_time - def _get_disk_usage(self, file_name): """ Returns the disk usage of given file. @@ -135,7 +133,6 @@ def _get_disk_usage(self, file_name): return int(output[0]) - def _wait_until_data_flushed(self, start_time, max_wait_time): """ Check to see if the sparse file size increases. @@ -167,7 +164,6 @@ def _wait_until_data_flushed(self, start_time, max_wait_time): # Return time waited. return datetime.datetime.now() - start_time - def initialize(self): """ Initialize all private and global member variables. @@ -179,10 +175,9 @@ def initialize(self): self.result_map = {} self.file_system = None - def run_once(self, mount_point, file_count, write_size, max_flush_time=1, file_system=None, remove_previous=False, - sparse_file=os.path.join(os.getcwd(),'sparse_file'), + sparse_file=os.path.join(os.getcwd(), 'sparse_file'), old_cleanup=False): """ Control execution of the test. @@ -255,7 +250,6 @@ def run_once(self, mount_point, file_count, write_size, # Increment the counter. counter += 1 - def postprocess(self): """ Cleanup routine. diff --git a/wb_kupdate/wb_kupdate_unittest.py b/wb_kupdate/wb_kupdate_unittest.py index 684042b10..fb11d108b 100755 --- a/wb_kupdate/wb_kupdate_unittest.py +++ b/wb_kupdate/wb_kupdate_unittest.py @@ -12,7 +12,9 @@ from autotest.client.shared.test_utils import mock from autotest.client.tests.wb_kupdate import wb_kupdate + class WbKupdateUnitTest(unittest.TestCase): + def setUp(self): """Set up all required variables for the Unittest. """ @@ -27,14 +29,14 @@ def test_needs_more_time(self): # Obvious failure - since start_time < start_time + 1. self.assertTrue(self._wbkupdate_obj._needs_more_time( - start_time=datetime.datetime.now(), - duration=1)) + start_time=datetime.datetime.now(), + duration=1)) # Check if 1 minute has elapsed since start_time. self.assertFalse(self._wbkupdate_obj._needs_more_time( - start_time=datetime.datetime.now(), - duration=1, - _now=datetime.datetime.now() + datetime.timedelta(seconds=60))) + start_time=datetime.datetime.now(), + duration=1, + _now=datetime.datetime.now() + datetime.timedelta(seconds=60))) def test_wait_until_data_flushed_pass(self): """Tests the _wait_until_data_flushed method. @@ -63,7 +65,6 @@ def test_wait_until_data_flushed_pass(self): # Ensure all stubbed methods called. self._god.check_playback() - def test_wait_until_data_flushed_fail(self): """Tests the _wait_until_data_flushed method. @@ -92,8 +93,10 @@ def test_wait_until_data_flushed_fail(self): class WbKupdateSubclass(wb_kupdate.wb_kupdate): + """Sub-classing the wb_kupdate class. """ + def __init__(self): """Empty constructor. """ diff --git a/xfstests/xfstests.py b/xfstests/xfstests.py index 1027ffb4b..322d1c765 100644 --- a/xfstests/xfstests.py +++ b/xfstests/xfstests.py @@ -1,7 +1,11 @@ -import os, re, glob, logging +import os +import re +import glob +import logging from autotest.client.shared import error, software_manager from autotest.client import test, utils, os_dep + class xfstests(test.test): version = 2 @@ -20,7 +24,6 @@ def _get_available_tests(self): tests_list.sort() return tests_list - def _run_sub_test(self, test): os.chdir(self.srcdir) output = utils.system_output('./check %s' % test, @@ -49,7 +52,6 @@ def _run_sub_test(self, test): raise error.TestError('Could not assert test success or failure, ' 'assuming failure. Please check debug logs') - def _get_groups(self): ''' Returns the list of groups known to xfstests @@ -66,7 +68,6 @@ def _get_groups(self): groups.add(g) return groups - def _get_tests_for_group(self, group): ''' Returns the list of tests that belong to a certain test group @@ -82,7 +83,6 @@ def _get_tests_for_group(self, group): tests.append(test) return tests - def setup(self, tarball='xfstests.tar.bz2'): ''' Sets up the environment necessary for running xfstests @@ -112,7 +112,6 @@ def setup(self, tarball='xfstests.tar.bz2'): logging.debug("Available tests in srcdir: %s" % ", ".join(self._get_available_tests())) - def run_once(self, test_number, skip_dangerous=True): os.chdir(self.srcdir) if test_number == '000': diff --git a/xmtest/xmtest.py b/xmtest/xmtest.py index 3e84d1ab2..d44e70f3f 100644 --- a/xmtest/xmtest.py +++ b/xmtest/xmtest.py @@ -13,14 +13,13 @@ class xmtest(test.test): def initialize(self): self.job.require_gcc() - # This test expects just the xm-test directory, as a tarball # from the Xen source tree # hg clone http://xenbits.xensource.com/xen-unstable.hg # or wget http://www.cl.cam.ac.uk/Research/SRG/netos/xen/downloads/xen-unstable-src.tgz # cd tools # tar -czf xm-test.tgz xm-test - def setup(self, tarball = 'xm-test.tar.bz2'): + def setup(self, tarball='xm-test.tar.bz2'): tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(tarball, self.srcdir) os.chdir(self.srcdir) @@ -29,8 +28,7 @@ def setup(self, tarball = 'xm-test.tar.bz2'): utils.configure() utils.make('existing') - - def execute(self, args = ''): + def execute(self, args=''): os.chdir(self.srcdir) utils.system('./runtest.sh ' + args) utils.system('mv xmtest.* ' + self.resultsdir)