Skip to content

Commit

Permalink
PEP8 mass fixes
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
lmr committed Sep 10, 2013
1 parent 9fff09d commit 4181b54
Show file tree
Hide file tree
Showing 108 changed files with 702 additions and 712 deletions.
1 change: 1 addition & 0 deletions aborttest/aborttest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from autotest.client.shared import error
from autotest.client import test


class aborttest(test.test):
version = 1

Expand Down
11 changes: 5 additions & 6 deletions aio_dio_bugs/aio_dio_bugs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
13 changes: 5 additions & 8 deletions aiostress/aiostress.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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:
Expand Down
9 changes: 6 additions & 3 deletions asynctest/asynctest.py
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
5 changes: 4 additions & 1 deletion autotest_regression/autotest_regression.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
4 changes: 2 additions & 2 deletions barriertest/barriertest.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# 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


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()
Expand Down
16 changes: 8 additions & 8 deletions bash_shared_mapping/bash_shared_mapping.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
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)

os.chdir(self.srcdir)
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)
Expand All @@ -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):
Expand Down
15 changes: 7 additions & 8 deletions bonnie/bonnie.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os, re
import os
import re
from autotest.client import test, os_dep, utils


Expand All @@ -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]
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)

Expand All @@ -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)))
32 changes: 15 additions & 17 deletions btreplay/btreplay.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -7,29 +8,27 @@ 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)

self.job.setup_dep(['libaio'])
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)

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"
Expand Down Expand Up @@ -59,16 +58,16 @@ 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
# analyse the trace with btt to determine the average request
# 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")

Expand All @@ -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:
Expand All @@ -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})
Loading

0 comments on commit 4181b54

Please sign in to comment.