Skip to content

Commit

Permalink
Fix: Replace self.datadir with self.get_data()
Browse files Browse the repository at this point in the history
This patch replaces self.datadir with self.get_data() as former is
deprecated. This patch addresses 25 such tests across fs, fuzz,
generic, kernel, memory, perf, toolchain.

Signed-off-by: Harish <harish@linux.vnet.ibm.com>
  • Loading branch information
Harish committed Jun 12, 2018
1 parent c9e3e7c commit 6ded44a
Show file tree
Hide file tree
Showing 25 changed files with 38 additions and 54 deletions.
3 changes: 1 addition & 2 deletions fs/flail.py
Expand Up @@ -39,8 +39,7 @@ def setUp(self):
self.cancel(package + ' is needed for the test to be run')
self.fs_type = self.params.get('fstype', default='xfs')

tarball = os.path.join(self.datadir, "flail-0.2.0.tar.gz")
archive.extract(tarball, self.workdir)
archive.extract(self.get_data("flail-0.2.0.tar.gz"), self.workdir)
self.build_dir = os.path.join(self.workdir, 'flail-0.2.0')

build.make(self.build_dir)
Expand Down
4 changes: 2 additions & 2 deletions fs/xfstests.py
Expand Up @@ -105,9 +105,9 @@ def setUp(self):
self.cancel('Unknown filesystem %s' % self.fs_to_test)
mount = True
self.devices = []
shutil.copyfile(os.path.join(self.datadir, 'local.config'),
shutil.copyfile(self.get_data('local.config'),
os.path.join(self.teststmpdir, 'local.config'))
shutil.copyfile(os.path.join(self.datadir, 'group'),
shutil.copyfile(self.get_data('group'),
os.path.join(self.teststmpdir, 'group'))

if self.dev_type == 'loop':
Expand Down
3 changes: 1 addition & 2 deletions fuzz/fsfuzzer.py
Expand Up @@ -68,8 +68,7 @@ def setUp(self):

if d_name == "ubuntu":
# Patch for ubuntu
fuzz_fix_patch = 'patch -p1 < %s' % (
os.path.join(self.datadir, 'fsfuzz_fix.patch'))
fuzz_fix_patch = 'patch -p1 < %s' % self.get_data('fsfuzz_fix.patch')
if process.system(fuzz_fix_patch, shell=True, ignore_status=True):
self.log.warn("Unable to apply sh->bash patch!")

Expand Down
1 change: 0 additions & 1 deletion generic/connectathon.py
Expand Up @@ -66,7 +66,6 @@ def setUp(self):
package)

self.tmpdir = tempfile.mkdtemp(prefix='avocado_' + __name__)
data_dir = os.path.abspath(self.datadir)
git.get_repo('git://git.linux-nfs.org/projects/steved/cthon04.git',
destination_dir=self.workdir)
os.chdir(self.workdir)
Expand Down
4 changes: 1 addition & 3 deletions generic/interbench.py
Expand Up @@ -56,15 +56,13 @@ def setUp(self):
tarball = self.fetch_asset('http://slackware.cs.utah.edu/pub/kernel'
'.org/pub/linux/kernel/people/ck/apps/'
'interbench/interbench-0.31.tar.gz')
data_dir = os.path.abspath(self.datadir)
archive.extract(tarball, self.workdir)
version = os.path.basename(tarball.split('.tar.')[0])
self.sourcedir = os.path.join(self.workdir, version)

# Patch for make file
os.chdir(self.sourcedir)
makefile_patch = 'patch -p1 < %s ' % (
os.path.join(data_dir, 'makefile_fix.patch'))
makefile_patch = 'patch -p1 < %s ' % self.get_data('makefile_fix.patch')
process.run(makefile_patch, shell=True)

build.make(self.sourcedir)
Expand Down
5 changes: 3 additions & 2 deletions generic/ltp.py
Expand Up @@ -63,9 +63,10 @@ def test(self):
if script == 'runltp':
logfile = os.path.join(self.logdir, 'ltp.log')
failcmdfile = os.path.join(self.logdir, 'failcmdfile')
skipfile = os.path.join(self.datadir, 'skipfile')

args += (" -q -p -l %s -C %s -d %s -S %s"
% (logfile, failcmdfile, self.workdir, skipfile))
% (logfile, failcmdfile, self.workdir,
self.get_data('skipfile')))
ltpbin_dir = os.path.join(self.workdir, "ltp-master", 'bin')
cmd = os.path.join(ltpbin_dir, script) + ' ' + args
result = process.run(cmd, ignore_status=True)
Expand Down
4 changes: 2 additions & 2 deletions generic/ras.py
Expand Up @@ -232,7 +232,7 @@ def test12_rtas_errd_and_rtas_dump(self):
self.log.info("===============Executing rtas_errd and rtas_dump tools"
" test===============")
self.log.info("1 - Injecting event")
rtas_file = os.path.join(self.datadir, 'rtas')
rtas_file = self.get_data('rtas')
self.run_cmd("/usr/sbin/rtas_errd -d -f %s" % rtas_file)
self.log.info("2 - Checking if the event was dumped to /var/log/"
"platform")
Expand Down Expand Up @@ -260,7 +260,7 @@ def test13_rtas_event_decode(self):
self.log.info("===============Executing rtas_event_decode tool test===="
"===========")
cmd_result = process.run("rtas_event_decode -w 500 -dv -n 2302 < %s" %
os.path.join(self.datadir, 'rtas'), ignore_status=True,
self.get_data('rtas'), ignore_status=True,
sudo=True, shell=True)
if cmd_result.exit_status != 17:
self.fail("%s command(s) failed in rtas_event_decode tool "
Expand Down
3 changes: 1 addition & 2 deletions generic/service_check.py
Expand Up @@ -33,8 +33,7 @@ class service_check(Test):
def test(self):
detected_distro = distro.detect()
parser = ConfigParser.ConfigParser()
config_file = self.datadir + '/services.cfg'
parser.read(config_file)
parser.read(self.get_data('services.cfg'))
services_list = parser.get(detected_distro.name, 'services').split(',')

smm = SoftwareManager()
Expand Down
2 changes: 1 addition & 1 deletion generic/servicelog.py
Expand Up @@ -93,7 +93,7 @@ def test_servicelog_notify(self):
Manageservice.stop("rtas_errd")
self.log.info("===============1. Creating notification tool ===="
"===========")
notify_script = os.path.join(self.datadir, "notify_script.sh")
notify_script = self.get_data("notify_script.sh")
cmd = "chmod 777 %s" % notify_script
process.run(cmd, ignore_status=True, sudo=True, shell=True)
self.log.info("=======2 - Adding notification tool to servicelog ="
Expand Down
1 change: 0 additions & 1 deletion kernel/posixtest.py
Expand Up @@ -51,7 +51,6 @@ def setUp(self):
tarball = self.fetch_asset("http://ufpr.dl.sourceforge.net"
"/sourceforge/posixtest"
"/posixtestsuite-1.5.2.tar.gz")
data_dir = os.path.abspath(self.datadir)
archive.extract(tarball, self.workdir)
version = os.path.basename(tarball.split('-1.')[0])
self.sourcedir = os.path.join(self.workdir, version)
Expand Down
7 changes: 2 additions & 5 deletions kernel/tlbflush.py
Expand Up @@ -46,14 +46,11 @@ def setUp(self):
if not smm.check_installed(package) and not smm.install(package):
self.cancel("%s is needed for this test." % package)

data_dir = os.path.abspath(self.datadir)

shutil.copyfile(os.path.join(data_dir, 'tlbflush.c'),
shutil.copyfile(self.get_data('tlbflush.c'),
os.path.join(self.workdir, 'tlbflush.c'))

os.chdir(self.workdir)
tlbflush_patch = 'patch -p1 < %s' % (
os.path.join(data_dir, 'tlbflush.patch'))
tlbflush_patch = 'patch -p1 < %s' % self.get_data('tlbflush.patch')

process.run(tlbflush_patch, shell=True)
cmd = 'gcc -DFILE_SIZE=$((128*1048576)) -g -O2 tlbflush.c \
Expand Down
3 changes: 1 addition & 2 deletions memory/eatmemory.py
Expand Up @@ -43,8 +43,7 @@ def setUp(self):
archive.extract(tarball, self.workdir)
self.sourcedir = os.path.join(self.workdir, "eatmemory-master")
# patch for getch remove
getch_patch = 'patch -p1 < %s' % (os.path.join(
self.datadir, 'eatmem_getch.patch'))
getch_patch = 'patch -p1 < %s' % self.get_data('eatmem_getch.patch')
os.chdir(self.sourcedir)
process.run(getch_patch, shell=True)
build.make(self.sourcedir)
Expand Down
4 changes: 2 additions & 2 deletions memory/fork_mem.py
Expand Up @@ -53,10 +53,10 @@ def setUp(self):
if not smm.check_installed(packages) and not smm.install(packages):
self.cancel('%s is needed for the test to be run' % packages)

shutil.copyfile(os.path.join(self.datadir, 'forkoff.c'),
shutil.copyfile(self.get_data('forkoff.c'),
os.path.join(self.teststmpdir, 'forkoff.c'))

shutil.copyfile(os.path.join(self.datadir, 'Makefile'),
shutil.copyfile(self.get_data('Makefile'),
os.path.join(self.teststmpdir, 'Makefile'))

build.make(self.teststmpdir)
Expand Down
2 changes: 1 addition & 1 deletion memory/hugepage_sanity.py
Expand Up @@ -31,7 +31,7 @@ class HugepageSanity(Test):
"""

def copyutil(self, file_name):
shutil.copyfile(os.path.join(self.datadir, file_name),
shutil.copyfile(self.get_data(file_name),
os.path.join(self.teststmpdir, file_name))

def setUp(self):
Expand Down
3 changes: 1 addition & 2 deletions memory/integrity.py
Expand Up @@ -54,8 +54,7 @@ def setUp(self):
if not smm.check_installed(packages) and not smm.install(packages):
self.cancel('%s is needed for the test to be run' % packages)

tarball = os.path.join(self.datadir, "Integritytests.tar")
archive.extract(tarball, self.workdir)
archive.extract(self.get_data("Integritytests.tar"), self.workdir)
self.build_dir = os.path.join(self.workdir, 'Integritytests')
build.make(self.build_dir)

Expand Down
2 changes: 1 addition & 1 deletion memory/ksm_poison.py
Expand Up @@ -32,7 +32,7 @@ class KsmPoison(Test):
"""

def copyutil(self, file_name):
shutil.copyfile(os.path.join(self.datadir, file_name),
shutil.copyfile(self.get_data(file_name),
os.path.join(self.teststmpdir, file_name))

def setUp(self):
Expand Down
6 changes: 2 additions & 4 deletions memory/libhugetlbfs.py
Expand Up @@ -102,19 +102,17 @@ def setUp(self):
os.makedirs(self.hugetlbfs_dir)
process.system('mount -t hugetlbfs none %s' % self.hugetlbfs_dir)

data_dir = os.path.abspath(self.datadir)
git.get_repo('https://github.com/libhugetlbfs/libhugetlbfs.git',
destination_dir=self.workdir)
os.chdir(self.workdir)
patch = self.params.get('patch', default='elflink.patch')
process.run('patch -p1 < %s' % data_dir + '/' + patch, shell=True)
process.run('patch -p1 < %s' % self.get_data(patch), shell=True)

# FIXME: "redhat" as the distro name for RHEL is deprecated
# on Avocado versions >= 50.0. This is a temporary compatibility
# enabler for older runners, but should be removed soon
if detected_distro.name in ["rhel", "fedora", "redhat", "centos"]:
falloc_patch = 'patch -p1 < %s ' % (
os.path.join(data_dir, 'falloc.patch'))
falloc_patch = 'patch -p1 < %s ' % self.get_data('falloc.patch')
process.run(falloc_patch, shell=True)

build.make(self.workdir, extra_args='BUILDTYPE=NATIVEONLY')
Expand Down
2 changes: 1 addition & 1 deletion memory/memory_api.py
Expand Up @@ -35,7 +35,7 @@ class MemorySyscall(Test):
"""

def copyutil(self, file_name):
shutil.copyfile(os.path.join(self.datadir, file_name),
shutil.copyfile(self.get_data(file_name),
os.path.join(self.teststmpdir, file_name))

def setUp(self):
Expand Down
2 changes: 1 addition & 1 deletion memory/mprotect.py
Expand Up @@ -32,7 +32,7 @@ class Mprotect(Test):
"""

def copyutil(self, file_name):
shutil.copyfile(os.path.join(self.datadir, file_name),
shutil.copyfile(self.get_data(file_name),
os.path.join(self.teststmpdir, file_name))

def setUp(self):
Expand Down
2 changes: 1 addition & 1 deletion memory/numa_test.py
Expand Up @@ -32,7 +32,7 @@ class NumaTest(Test):
"""

def copyutil(self, file_name):
shutil.copyfile(os.path.join(self.datadir, file_name),
shutil.copyfile(self.get_data(file_name),
os.path.join(self.teststmpdir, file_name))

def setUp(self):
Expand Down
4 changes: 2 additions & 2 deletions memory/vatest.py
Expand Up @@ -92,10 +92,10 @@ def setUp(self):
if not smm.check_installed(packages) and not smm.install(packages):
self.cancel('%s is needed for the test to be run' % packages)

shutil.copyfile(os.path.join(self.datadir, 'va_test.c'),
shutil.copyfile(self.get_data('va_test.c'),
os.path.join(self.teststmpdir, 'va_test.c'))

shutil.copyfile(os.path.join(self.datadir, 'Makefile'),
shutil.copyfile(self.get_data('Makefile'),
os.path.join(self.teststmpdir, 'Makefile'))

build.make(self.teststmpdir)
Expand Down
2 changes: 1 addition & 1 deletion perf/blogbench.py
Expand Up @@ -45,7 +45,7 @@ def setUp(self):
os.chdir(self.blogbench_dir)
patch = self.params.get('patch', default='config_guess.patch')
process.run('patch -p1 config.guess %s' %
os.path.join(self.datadir, patch), shell=True)
self.get_data(patch), shell=True)
process.system('./configure')
build.make(self.blogbench_dir, extra_args='install-strip')

Expand Down
16 changes: 7 additions & 9 deletions perf/lmbench.py
Expand Up @@ -52,7 +52,6 @@ def setUp(self):
self.cancel("%s is needed for the test to be run" % package)
tarball = self.fetch_asset('http://www.bitmover.com'
'/lmbench/lmbench3.tar.gz')
data_dir = os.path.abspath(self.datadir)
archive.extract(tarball, self.workdir)
version = os.path.basename(tarball.split('.tar.')[0])
self.sourcedir = os.path.join(self.workdir, version)
Expand All @@ -61,14 +60,13 @@ def setUp(self):

os.chdir(self.sourcedir)

makefile_patch = 'patch -p1 < %s' % (
os.path.join(data_dir, 'makefile.patch'))
build_patch = 'patch -p1 < %s' % (os.path.join(
data_dir, '0001-Fix-build-issues-with-lmbench.patch'))
lmbench_fix_patch = 'patch -p1 < %s' % (os.path.join(
data_dir, '0002-Changing-shebangs-on-lmbench-scripts.patch'))
ostype_fix_patch = 'patch -p1 < %s' % (
os.path.join(data_dir, 'fix_add_os_type.patch'))
makefile_patch = 'patch -p1 < %s' % self.get_data('makefile.patch')
build_patch = 'patch -p1 < %s' % self.get_data(
'0001-Fix-build-issues-with-lmbench.patch')
lmbench_fix_patch = 'patch -p1 < %s' % self.get_data(
'0002-Changing-shebangs-on-lmbench-scripts.patch')
ostype_fix_patch = 'patch -p1 < %s' % self.get_data(
'fix_add_os_type.patch')

process.run(makefile_patch, shell=True)
process.run(build_patch, shell=True)
Expand Down
3 changes: 1 addition & 2 deletions toolchain/ltrace.py
Expand Up @@ -78,8 +78,7 @@ def setUp(self):

self.src_lt = os.path.join(self.workdir, "ltrace")
os.chdir(self.src_lt)
process.run('patch -p1 < %s' %
os.path.join(self.datadir, 'ltrace.patch'), shell=True)
process.run('patch -p1 < %s' % self.get_data('ltrace.patch'), shell=True)
elif run_type == "distro":
self.src_lt = os.path.join(self.workdir, "ltrace-distro")
if not os.path.exists(self.src_lt):
Expand Down
4 changes: 2 additions & 2 deletions toolchain/power_time_base_bug.py
Expand Up @@ -49,11 +49,11 @@ def setUp(self):
self.cancel('%s is needed for the test to be run' % package)

self.log.info("Tranferring the files ...")
shutil.copyfile(os.path.join(self.datadir, 'print_power_time_base.c'),
shutil.copyfile(self.get_data('print_power_time_base.c'),
os.path.join(self.teststmpdir, 'print_power_time_base.c'))

self.log.info("About to compile ...")
shutil.copyfile(os.path.join(self.datadir, 'Makefile'),
shutil.copyfile(self.get_data('Makefile'),
os.path.join(self.teststmpdir, 'Makefile'))

build.make(self.teststmpdir)
Expand Down

0 comments on commit 6ded44a

Please sign in to comment.