Risk: Required
Visibility: Minimal
Second pass on clean up. 
I tested all test to make sure they at least run correctly, adding a few control
file stubs here and there.
Most of the fixes are import os fixes along with a few incorrect references

Signed-off-by: Scott Zawalski <scottz@google.com>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@1607 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/bin/autotest_utils.py b/client/bin/autotest_utils.py
index 8e73215..1e6c725 100755
--- a/client/bin/autotest_utils.py
+++ b/client/bin/autotest_utils.py
@@ -373,7 +373,7 @@
 	"""
 	Return path of config file of the currently running kernel
 	"""
-	version = system_output('uname -r')
+	version = utils.system_output('uname -r')
 	for config in ('/proc/config.gz', \
 		       '/boot/config-%s' % version,
 		       '/lib/modules/%s/build/.config' % version):
diff --git a/client/bin/cpuset.py b/client/bin/cpuset.py
index 719fe09..a870e76 100644
--- a/client/bin/cpuset.py
+++ b/client/bin/cpuset.py
@@ -2,7 +2,7 @@
 
 import os, sys, re, glob, math
 from autotest_lib.client.bin import autotest_utils
-from autotest_lib.client.common_lib import error
+from autotest_lib.client.common_lib import utils, error
 
 super_root = "/dev/cpuset"
 
@@ -61,13 +61,13 @@
 def my_container_name():
 	# Get current process's inherited or self-built container name
 	#   within /dev/cpuset.  Is '/' for root container, '/sys', etc. 
-	return autotest_utils.read_one_line('/proc/%i/cpuset' % os.getpid())
+	return utils.read_one_line('/proc/%i/cpuset' % os.getpid())
 
 
 def get_mem_nodes(container_full_name):
 	file_name = os.path.join(container_full_name, "mems")
 	if os.path.exists(file_name):
-		return rangelist_to_list(autotest_utils.read_one_line(file_name))
+		return rangelist_to_list(utils.read_one_line(file_name))
 	else:
 		return []
 
@@ -110,7 +110,7 @@
 def get_cpus(container_full_name):
 	file_name = os.path.join(container_full_name, "cpus")
 	if os.path.exists(file_name):
-		return rangelist_to_list(autotest_utils.read_one_line(file_name))
+		return rangelist_to_list(utils.read_one_line(file_name))
 	else:
 		return []
 
@@ -126,8 +126,8 @@
 
 def print_one_cpuset(name):
 	dir = os.path.join('/dev/cpuset', name)
-	cpus = autotest_utils.read_one_line(dir + '/cpus')
-	mems = autotest_utils.read_one_line(dir + '/mems')
+	cpus = utils.read_one_line(dir + '/cpus')
+	mems = utils.read_one_line(dir + '/mems')
 	node_size_ = int(mbytes_per_mem_node()) << 20
 	memtotal = node_size_ * len(rangelist_to_list(mems))
 	tasks = ','.join(get_tasks(dir))
@@ -165,7 +165,7 @@
 		parent_t = os.path.join(self.root, 'tasks')
 		# Transfer survivors (and self) to parent
 		for task in get_tasks(self.cpudir):
-			autotest_utils.write_one_line(parent_t, task)
+			utils.write_one_line(parent_t, task)
 		os.rmdir(self.cpudir)
 		if os.path.exists(self.cpudir):
 			raise error.AutotestError('Could not delete container '
@@ -247,9 +247,9 @@
 			mems = mems[-nodes_needed:]
 			mems_spec = ','.join(['%d' % x for x in mems])
 			os.mkdir(self.cpudir)
-			autotest_utils.write_one_line(os.path.join(self.cpudir,
+			utils.write_one_line(os.path.join(self.cpudir,
 					'mem_exclusive'), '1')
-			autotest_utils.write_one_line(os.path.join(self.cpudir,
+			utils.write_one_line(os.path.join(self.cpudir,
 								   'mems'),
 						      mems_spec)
 			# Above sends err msg to client.log.0, but no exception,
@@ -264,10 +264,10 @@
 
 		# add specified cpu cores and own task pid to container:
 		cpu_spec = ','.join(['%d' % x for x in cpus])
-		autotest_utils.write_one_line(os.path.join(self.cpudir,
+		utils.write_one_line(os.path.join(self.cpudir,
 							   'cpus'),
 					      cpu_spec)
-		autotest_utils.write_one_line(os.path.join(self.cpudir,
+		utils.write_one_line(os.path.join(self.cpudir,
 							   'tasks'),
 					      "%d" % job_pid)
 		self.display()
diff --git a/client/bin/kernel.py b/client/bin/kernel.py
index bc4397c..fca8f7e 100755
--- a/client/bin/kernel.py
+++ b/client/bin/kernel.py
@@ -86,7 +86,7 @@
 		self.build_target = 'bzImage'
 		self.build_image = None
 
-		arch = get_current_kernel_arch()
+		arch = autotest_utils.get_current_kernel_arch()
 		if arch == 's390' or arch == 's390x':
 			self.build_target = 'image'
 		elif arch == 'ia64':
@@ -177,7 +177,7 @@
 			# FIXME: this isn't unique. Append something to it
 			# like wget does if it's not there?
 			print "get_file %s %s %s %s" % (patch, dest, self.src_dir, basename(patch))
-			get_file(patch, dest)
+			utils.get_file(patch, dest)
 			# probably safer to use the command, not python library
 			md5sum = utils.system_output('md5sum ' + dest).split()[0]
 			local_patches.append((patch, dest, md5sum))
@@ -218,7 +218,7 @@
 			os.chdir(os.path.dirname(self.src_dir))
 			# Figure out local destination for tarball
 			tarball = os.path.join(self.src_dir, os.path.basename(base_tree))
-			get_file(base_tree, tarball)
+			utils.get_file(base_tree, tarball)
 			print 'Extracting kernel tarball:', tarball, '...'
 			autotest_utils.extract_tarball_to_dir(tarball,
 			                                      self.build_dir)
@@ -558,7 +558,7 @@
 
 		# If no 'target_arch' given assume native compilation
 		if target_arch == None:
-			target_arch = get_current_kernel_arch()
+			target_arch = autotest_utils.get_current_kernel_arch()
 			if target_arch == 'ppc64':
 				if self.build_target == 'bzImage':
 					self.build_target = 'vmlinux'
diff --git a/client/bin/xen.py b/client/bin/xen.py
index ec093fa..d69b2c5 100644
--- a/client/bin/xen.py
+++ b/client/bin/xen.py
@@ -3,6 +3,7 @@
 
 import os, shutil, copy, pickle, re, glob
 from autotest_lib.client.bin import kernel, kernel_config, os_dep, test
+from autotest_lib.client.bin import autotest_utils
 
 
 class xen(kernel.kernel):
@@ -43,7 +44,7 @@
 
 		# build xen hypervisor and user-space tools
 		targets = ['xen', 'tools']
-		threads = 2 * count_cpus()
+		threads = 2 * autotest_utils.count_cpus()
 		for t in targets:
 			build_string = 'make -j %d %s %s' % (threads, make_opts, t)
 			self.log('build_string: %s' % build_string)
diff --git a/client/tests/aio_dio_bugs/aio_dio_bugs.py b/client/tests/aio_dio_bugs/aio_dio_bugs.py
index 44611f9..a4563d8 100644
--- a/client/tests/aio_dio_bugs/aio_dio_bugs.py
+++ b/client/tests/aio_dio_bugs/aio_dio_bugs.py
@@ -32,7 +32,7 @@
 		os.chdir(self.tmpdir)
 		libs = self.autodir + '/deps/libaio/lib/'
 		ld_path = autotest_utils.prepend_path(libs,
-		                                     environ('LD_LIBRARY_PATH'))
+                                      autotest_utils.environ('LD_LIBRARY_PATH'))
 		var_ld_path = 'LD_LIBRARY_PATH=' + ld_path
 		for test in tests:
 			cmd = self.srcdir + '/' + test[name] + ' ' \
diff --git a/client/tests/aiostress/aiostress.py b/client/tests/aiostress/aiostress.py
index 2ef1376..14878f8 100755
--- a/client/tests/aiostress/aiostress.py
+++ b/client/tests/aiostress/aiostress.py
@@ -3,7 +3,7 @@
 
 # NOTE - this should also have the ability to mount a filesystem, 
 # run the tests, unmount it, then fsck the filesystem
-
+import os
 from autotest_lib.client.bin import test, autotest_utils
 from autotest_lib.client.common_lib import utils
 
@@ -34,7 +34,7 @@
 		os.chdir(self.tmpdir)
 		libs = self.autodir+'/deps/libaio/lib/'
 		ld_path = autotest_utils.prepend_path(libs,
-		                                     environ('LD_LIBRARY_PATH'))
+		                      autotest_utils.environ('LD_LIBRARY_PATH'))
 		var_ld_path = 'LD_LIBRARY_PATH=' + ld_path
 		cmd = self.srcdir + '/aio-stress ' + args + ' poo'
 		profilers = self.job.profilers
diff --git a/client/tests/bash_shared_mapping/bash_shared_mapping.py b/client/tests/bash_shared_mapping/bash_shared_mapping.py
index 8aac2b0..e3fb69d 100755
--- a/client/tests/bash_shared_mapping/bash_shared_mapping.py
+++ b/client/tests/bash_shared_mapping/bash_shared_mapping.py
@@ -1,17 +1,18 @@
-import test
-from autotest_utils import *
-import signal
+import signal, os
+from autotest_lib.client.bin import autotest_utils, test
+from autotest_lib.client.common_lib import utils
 
 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'):
-		self.tarball = unmap_url(self.bindir, tarball, self.tmpdir)
-		extract_tarball_to_dir(self.tarball, self.srcdir)
+		self.tarball = utils.unmap_url(self.bindir, tarball,
+		                               self.tmpdir)
+		autotest_utils.extract_tarball_to_dir(self.tarball, self.srcdir)
 
 		os.chdir(self.srcdir)
-		system('make bash-shared-mapping usemem')
+		utils.system('make bash-shared-mapping usemem')
 
 
 	def execute(self, testdir = None, iterations = 10000):
@@ -21,7 +22,7 @@
 		file = os.path.join(testdir, 'foo')
 		# Want to use 3/4 of all memory for each of 
 		# bash-shared-mapping and usemem
-		kilobytes = (3 * memtotal()) / 4
+		kilobytes = (3 * autotest_utils.memtotal()) / 4
 
 		# Want two usemem -m megabytes in parallel in background.
 		pid = [None, None]
diff --git a/client/tests/bonnie/bonnie.py b/client/tests/bonnie/bonnie.py
index f7302af..e025221 100755
--- a/client/tests/bonnie/bonnie.py
+++ b/client/tests/bonnie/bonnie.py
@@ -1,5 +1,6 @@
-import autotest_lib.client.bin import test, os_dep, autotest_utils
-import autotest_lib.client.common_lib import utils
+import os
+from autotest_lib.client.bin import test, os_dep, autotest_utils
+from autotest_lib.client.common_lib import utils
 
 
 def convert_size(values):
@@ -28,7 +29,7 @@
 
 	# http://www.coker.com.au/bonnie++/bonnie++-1.03a.tgz
 	def setup(self, tarball = 'bonnie++-1.03a.tgz'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 		os.chdir(self.srcdir)
diff --git a/client/tests/btreplay/btreplay.py b/client/tests/btreplay/btreplay.py
index 439a213..ba6e5cb 100644
--- a/client/tests/btreplay/btreplay.py
+++ b/client/tests/btreplay/btreplay.py
@@ -1,4 +1,4 @@
-import time
+import time, os
 from autotest_lib.client.bin import test, os_dep, autotest_utils
 from autotest_lib.client.common_lib import error, utils
 
@@ -8,7 +8,7 @@
 
 	# http://brick.kernel.dk/snaps/blktrace-git-latest.tar.gz
 	def setup(self, tarball = 'blktrace-git-latest.tar.gz'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 
diff --git a/client/tests/cpu_hotplug/cpu_hotplug.py b/client/tests/cpu_hotplug/cpu_hotplug.py
index ed55bb8..69003e3 100644
--- a/client/tests/cpu_hotplug/cpu_hotplug.py
+++ b/client/tests/cpu_hotplug/cpu_hotplug.py
@@ -7,13 +7,13 @@
 
 	# http://developer.osdl.org/dev/hotplug/tests/lhcs_regression-1.6.tgz
 	def setup(self, tarball = 'lhcs_regression-1.6.tgz'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 		
 	def execute(self):
 		# Check if the kernel supports cpu hotplug
-		if running_config():
+		if autotest_utils.running_config():
 			autotest_utils.check_for_kernel_feature('HOTPLUG_CPU')
 		
 		# Check cpu nums, if equals 1, quit.
@@ -26,10 +26,10 @@
 		for cpu in cpu_online_map():
 			if os.path.isfile('/sys/devices/system/cpu/cpu%s/online' % cpu):
 				utils.system('echo 0 > /sys/devices/system/cpu/cpu%s/online' % cpu, 1)
-				utils.system('dmesg -c'
+				utils.system('dmesg -c')
 				time.sleep(3)
-				utils.system('echo 1 > /sys/devices/system/cpu/cpu%s/online' % cpu, 1
-				utils.system('dmesg -c'
+				utils.system('echo 1 > /sys/devices/system/cpu/cpu%s/online' % cpu, 1)
+				utils.system('dmesg -c')
 				time.sleep(3)
 		
 		# Begin this cpu hotplug test big guru.
diff --git a/client/tests/cyclictest/cyclictest.py b/client/tests/cyclictest/cyclictest.py
index 95a6416..5f0f98e 100755
--- a/client/tests/cyclictest/cyclictest.py
+++ b/client/tests/cyclictest/cyclictest.py
@@ -1,3 +1,4 @@
+import os
 from autotest_lib.client.bin import test
 from autotest_lib.client.common_lib import utils
 
diff --git a/client/tests/dacapo/dacapo.py b/client/tests/dacapo/dacapo.py
index 7d3c8c8..38bb711 100644
--- a/client/tests/dacapo/dacapo.py
+++ b/client/tests/dacapo/dacapo.py
@@ -8,7 +8,7 @@
 # National Science Foundation ITR Grant, CCR-0085792.
 #
 import os
-from autotest_lib.client.bin import autotest_utils, package
+from autotest_lib.client.bin import autotest_utils, package, test
 from autotest_lib.client.bin.test_config import config_loader
 from autotest_lib.client.common_lib import utils
 
diff --git a/client/tests/dbt2/dbt2.py b/client/tests/dbt2/dbt2.py
index 945768f..d35018b 100644
--- a/client/tests/dbt2/dbt2.py
+++ b/client/tests/dbt2/dbt2.py
@@ -1,5 +1,6 @@
 import os
 from autotest_lib.client.bin import test, autotest_utils
+from autotest_lib.client.common_lib import utils
 
 
 # Dbt-2 is a fair-use implementation of the TPC-C benchmark.  The test is 
@@ -10,7 +11,7 @@
 
 	# http://osdn.dl.sourceforge.net/sourceforge/osdldbt/dbt2-0.39.tar.gz
 	def setup(self, tarball = 'dbt2-0.39.tar.bz2'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 		self.job.setup_dep(['pgsql', 'pgpool', 'mysql'])
@@ -53,7 +54,7 @@
 	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
+		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' \
diff --git a/client/tests/disktest/disktest.py b/client/tests/disktest/disktest.py
index 400cf90..e021cb8 100755
--- a/client/tests/disktest/disktest.py
+++ b/client/tests/disktest/disktest.py
@@ -1,7 +1,6 @@
-import os, sys
-import subprocess
+import os, sys, subprocess
 from autotest_lib.client.bin import test, autotest_utils
-from autotest_lib.client.common_lib import utils, errors
+from autotest_lib.client.common_lib import utils, error
 
 
 class disktest(test.test):
@@ -26,7 +25,7 @@
 
 
 	def execute(self, disks = None, gigabytes = None,
-						chunk_mb = memtotal() / 1024):
+				chunk_mb = autotest_utils.memtotal() / 1024):
 		os.chdir(self.srcdir)
 
 		if not disks:
diff --git a/client/tests/fio/fio.py b/client/tests/fio/fio.py
index 6cfc065..e1d9734 100644
--- a/client/tests/fio/fio.py
+++ b/client/tests/fio/fio.py
@@ -1,4 +1,5 @@
-from autotest_lib.client.bin import test
+import os
+from autotest_lib.client.bin import test, autotest_utils
 from autotest_lib.client.common_lib import utils
 
 
@@ -7,7 +8,7 @@
 
 	# http://brick.kernel.dk/snaps/fio-1.16.5.tar.bz2
 	def setup(self, tarball = 'fio-1.16.5.tar.bz2'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 
@@ -27,12 +28,12 @@
 		vars = 'LD_LIBRARY_PATH="' + self.autodir + '/deps/libaio/lib"'
 		##args = '-m -o ' + self.resultsdir + '/fio-tio.log ' + self.srcdir + '/examples/tiobench-example';
 		args = '--output ' + self.resultsdir + '/fio-mixed.log ' + self.bindir + '/fio-mixed.job';
-		util.system(vars + ' ./fio ' + args)
+		utils.system(vars + ' ./fio ' + args)
 
 		# Do a profiling run if necessary
 		profilers = self.job.profilers
 		if profilers.present():
 			profilers.start(self)
-			util.system(vars + ' ./fio ' + args)
+			utils.system(vars + ' ./fio ' + args)
 			profilers.stop(self)
 			profilers.report(self)
diff --git a/client/tests/fs_mark/fs_mark.py b/client/tests/fs_mark/fs_mark.py
index cc3c69d..f38f011 100644
--- a/client/tests/fs_mark/fs_mark.py
+++ b/client/tests/fs_mark/fs_mark.py
@@ -1,4 +1,6 @@
+import os
 from autotest_lib.client.bin import test, autotest_utils
+from autotest_lib.client.common_lib import utils
 
 
 class fs_mark(test.test):
@@ -6,7 +8,7 @@
 
 	# http://developer.osdl.org/dev/doubt/fs_mark/archive/fs_mark-3.2.tgz
 	def setup(self, tarball = 'fs_mark-3.2.tgz'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 		os.chdir(self.srcdir)
diff --git a/client/tests/fsfuzzer/fsfuzzer.py b/client/tests/fsfuzzer/fsfuzzer.py
index 5abda51..07d2c09 100755
--- a/client/tests/fsfuzzer/fsfuzzer.py
+++ b/client/tests/fsfuzzer/fsfuzzer.py
@@ -1,5 +1,6 @@
+import os
 from autotest_lib.client.bin import test, autotest_utils
-from autotest_lib.client.bin import utils
+from autotest_lib.client.common_lib import utils
 
 
 class fsfuzzer(test.test):
@@ -7,7 +8,7 @@
 
 	# http://people.redhat.com/sgrubb/files/fsfuzzer-0.6.tar.gz
 	def setup(self, tarball = 'fsfuzzer-0.6.tar.gz'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 		os.chdir(self.srcdir)
diff --git a/client/tests/fsstress/fsstress.py b/client/tests/fsstress/fsstress.py
index 87c6f14..9b2a2db 100644
--- a/client/tests/fsstress/fsstress.py
+++ b/client/tests/fsstress/fsstress.py
@@ -1,3 +1,4 @@
+import os
 from autotest_lib.client.bin import test, autotest_utils
 from autotest_lib.client.common_lib import utils
 
@@ -8,7 +9,7 @@
 
 	# http://www.zip.com.au/~akpm/linux/patches/stuff/ext3-tools.tar.gz
 	def setup(self, tarball = 'ext3-tools.tar.gz'):
-		self.tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		self.tarball = utils.unmap_url(self.bindir, tarball,
 		                                        self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(self.tarball, self.srcdir)
 
diff --git a/client/tests/fsx/fsx.py b/client/tests/fsx/fsx.py
index df4db70..5e77cf1 100755
--- a/client/tests/fsx/fsx.py
+++ b/client/tests/fsx/fsx.py
@@ -3,7 +3,7 @@
 
 # NOTE - this should also have the ability to mount a filesystem, 
 # run the tests, unmount it, then fsck the filesystem
-
+import os
 from autotest_lib.client.bin import test, autotest_utils
 from autotest_lib.client.common_lib import utils
 
@@ -13,9 +13,9 @@
 
 	# http://www.zip.com.au/~akpm/linux/patches/stuff/ext3-tools.tar.gz
 	def setup(self, tarball = 'ext3-tools.tar.gz'):
-		self.tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		self.tarball = utils.unmap_url(self.bindir, tarball,
 		                                        self.tmpdir)
-		autoetst_utils.extract_tarball_to_dir(self.tarball, self.srcdir)
+		autotest_utils.extract_tarball_to_dir(self.tarball, self.srcdir)
 
 		self.job.setup_dep(['libaio'])
 		ldflags = '-L' + self.autodir + '/deps/libaio/lib'
@@ -36,7 +36,7 @@
 		os.chdir(testdir)
 		libs = self.autodir+'/deps/libaio/lib/'
 		ld_path = autotest_utils.prepend_path(libs,
-		                                   environ('LD_LIBRARY_PATH'))
+                                   autotest_utils.environ('LD_LIBRARY_PATH'))
 		var_ld_path = 'LD_LIBRARY_PATH=' + ld_path
 		cmd = self.srcdir + '/fsx-linux ' + args + ' poo'
 		profilers = self.job.profilers
diff --git a/client/tests/interbench/interbench.py b/client/tests/interbench/interbench.py
index 60b1d80..0bbdec4 100644
--- a/client/tests/interbench/interbench.py
+++ b/client/tests/interbench/interbench.py
@@ -1,3 +1,4 @@
+import os
 from autotest_lib.client.bin import test, autotest_utils
 from autotest_lib.client.common_lib import utils
 
@@ -7,7 +8,7 @@
 
 	# 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'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 		os.chdir(self.srcdir)
diff --git a/client/tests/iozone/iozone.py b/client/tests/iozone/iozone.py
index 9cd705e..26c23d6 100644
--- a/client/tests/iozone/iozone.py
+++ b/client/tests/iozone/iozone.py
@@ -9,7 +9,7 @@
 
 	# http://www.iozone.org/src/current/iozone3_283.tar
 	def setup(self, tarball = 'iozone3_283.tar'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 		os.chdir(os.path.join(self.srcdir, 'src/current'))
diff --git a/client/tests/isic/isic.py b/client/tests/isic/isic.py
index a9af20f..9378830 100644
--- a/client/tests/isic/isic.py
+++ b/client/tests/isic/isic.py
@@ -1,3 +1,4 @@
+import os
 from autotest_lib.client.bin import test, autotest_utils
 from autotest_lib.client.common_lib import utils
 
@@ -12,7 +13,7 @@
 		self.job.setup_dep(['libnet'])
 
 	def setup(self, tarball = 'isic-0.06.tar.bz2'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 		os.chdir(self.srcdir)
diff --git a/client/tests/kvmtest/kvmtest.py b/client/tests/kvmtest/kvmtest.py
index 4cabe69..96806c0 100644
--- a/client/tests/kvmtest/kvmtest.py
+++ b/client/tests/kvmtest/kvmtest.py
@@ -7,7 +7,7 @@
 	version = 1
 
 	def setup(self, tarball = 'kvm-test.tar.gz'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 		os.chdir(self.srcdir)
diff --git a/client/tests/libhugetlbfs/libhugetlbfs.py b/client/tests/libhugetlbfs/libhugetlbfs.py
index dcab973..1f0aed1 100644
--- a/client/tests/libhugetlbfs/libhugetlbfs.py
+++ b/client/tests/libhugetlbfs/libhugetlbfs.py
@@ -1,5 +1,5 @@
 import re, os
-from autotest_lib.client.bin import autotest_utils, tests
+from autotest_lib.client.bin import autotest_utils, test
 from autotest_lib.client.common_lib import utils, error
 
 class libhugetlbfs(test.test):
@@ -7,7 +7,7 @@
 
 	# http://libhugetlbfs.ozlabs.org/releases/libhugetlbfs-1.3-pre1.tar.gz
 	def setup(self, tarball = 'libhugetlbfs-1.3-pre1.tar.gz'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 		os.chdir(self.srcdir)
@@ -25,7 +25,7 @@
 		# Check huge page number
 		pages_available = 0
 		if os.path.exists('/proc/sys/vm/nr_hugepages'):
-			autotest_utils.write_one_line('/proc/sys/vm/nr_hugepages',
+			utils.write_one_line('/proc/sys/vm/nr_hugepages',
 						      str(pages_requested))
 			pages_available = int(open('/proc/sys/vm/nr_hugepages', 'r').readline())
 		else:
diff --git a/client/tests/linus_stress/linus_stress.py b/client/tests/linus_stress/linus_stress.py
index 6532668..3a81134 100755
--- a/client/tests/linus_stress/linus_stress.py
+++ b/client/tests/linus_stress/linus_stress.py
@@ -15,11 +15,11 @@
 
 
 	def run_the_test(self, iterations):
-		write_one_line('/proc/sys/vm/dirty_ratio', '4')
-		write_one_line('/proc/sys/vm/dirty_background_ratio', '2')
+		utils.write_one_line('/proc/sys/vm/dirty_ratio', '4')
+		utils.write_one_line('/proc/sys/vm/dirty_background_ratio', '2')
 
 		cmd = os.path.join(self.srcdir, 'linus_stress')
-		args = "%d" % (memtotal() / 32)
+		args = "%d" % (autotest_utils.memtotal() / 32)
 
 		profilers = self.job.profilers
 		if profilers.present():
@@ -34,10 +34,10 @@
 
 
 	def execute(self, iterations = 1):
-		dirty_ratio = autotest_utils.read_one_line('/proc/sys/vm/dirty_ratio')
-		dirty_background_ratio = autotest_utils.read_one_line('/proc/sys/vm/dirty_background_ratio')
+		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:
 			self.run_the_test(iterations)
 		finally:
-			autotest_utils.write_one_line('/proc/sys/vm/dirty_ratio', dirty_ratio)
-			autotest_utils.write_one_line('/proc/sys/vm/dirty_background_ratio', dirty_background_ratio)
+			utils.write_one_line('/proc/sys/vm/dirty_ratio', dirty_ratio)
+			utils.write_one_line('/proc/sys/vm/dirty_background_ratio', dirty_background_ratio)
diff --git a/client/tests/lmbench/lmbench.py b/client/tests/lmbench/lmbench.py
index cf22586..fc4807b 100755
--- a/client/tests/lmbench/lmbench.py
+++ b/client/tests/lmbench/lmbench.py
@@ -1,4 +1,5 @@
 # This will need more work on the configuration stuff before it will function
+import os
 from autotest_lib.client.bin import test, autotest_utils
 from autotest_lib.client.common_lib import utils
 
@@ -7,7 +8,7 @@
 	version = 2
 
 	def setup(self, tarball = 'lmbench3.tar.bz2'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		# http://www.bitmover.com/lm/lmbench/lmbench3.tar.gz
 		# + lmbench3.diff 
diff --git a/client/tests/ltp/ltp.py b/client/tests/ltp/ltp.py
index 98535b8..043ac00 100755
--- a/client/tests/ltp/ltp.py
+++ b/client/tests/ltp/ltp.py
@@ -1,13 +1,13 @@
 import os
 from autotest_lib.client.bin import autotest_utils, test
-from autotest_lib.client.common_lib import utils
+from autotest_lib.client.common_lib import utils, error
 
 class ltp(test.test):
 	version = 4
 
 	# http://prdownloads.sourceforge.net/ltp/ltp-full-20080229.tgz
 	def setup(self, tarball = 'ltp-full-20080229.tar.bz2'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 		os.chdir(self.srcdir)
@@ -17,11 +17,11 @@
 		# comment the capability tests if we fail to load the capability module
 		try:
 			utils.system('modprobe capability')
-		except CmdError, detail:
+		except error.CmdError, detail:
 			utils.system('patch -p1 < ../ltp_capability.patch')
 
 		utils.system('cp ../scan.c pan/')   # saves having lex installed
-		utils.system('make -j %d' % count_cpus())
+		utils.system('make -j %d' % autotest_utils.count_cpus())
 		utils.system('yes n | make install')
 
 
diff --git a/client/tests/netperf2/netperf2.py b/client/tests/netperf2/netperf2.py
index 8555b45..1f7fb66 100755
--- a/client/tests/netperf2/netperf2.py
+++ b/client/tests/netperf2/netperf2.py
@@ -1,3 +1,4 @@
+import os
 from autotest_lib.client.bin import test, autotest_utils
 from autotest_lib.client.common_lib import utils, error
 
@@ -7,7 +8,7 @@
 
 	# ftp://ftp.netperf.org/netperf/netperf-2.4.1.tar.gz
 	def setup(self, tarball = 'netperf-2.4.1.tar.gz'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 		os.chdir(self.srcdir)
diff --git a/client/tests/parallel_dd/parallel_dd.py b/client/tests/parallel_dd/parallel_dd.py
index ddc941a..a524e6d 100755
--- a/client/tests/parallel_dd/parallel_dd.py
+++ b/client/tests/parallel_dd/parallel_dd.py
@@ -1,4 +1,4 @@
-import re, time, subprocess
+import os, re, time, subprocess, sys
 from autotest_lib.client.bin import test, autotest_utils
 from autotest_lib.client.common_lib import utils
 
diff --git a/client/tests/pi_tests/pi_tests.py b/client/tests/pi_tests/pi_tests.py
index d7bd56c..54872f4 100644
--- a/client/tests/pi_tests/pi_tests.py
+++ b/client/tests/pi_tests/pi_tests.py
@@ -1,3 +1,4 @@
+import os
 from autotest_lib.client.bin import test, autotest_utils
 from autotest_lib.client.common_lib import utils
 
@@ -8,7 +9,7 @@
 	# http://www.stardust.webpages.pl/files/patches/autotest/pi_tests.tar.bz2
 
 	def setup(self, tarball = 'pi_tests.tar.bz2'):
-		check_glibc_ver('2.5')
+		autotest_utils.check_glibc_ver('2.5')
 		tarball = autotest_utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
diff --git a/client/tests/pktgen/pktgen.py b/client/tests/pktgen/pktgen.py
index 5cc5e5f..c70cb43 100755
--- a/client/tests/pktgen/pktgen.py
+++ b/client/tests/pktgen/pktgen.py
@@ -1,3 +1,4 @@
+import os
 from autotest_lib.client.bin import test, autotest_utils
 from autotest_lib.client.common_lib import utils, error
 
@@ -46,8 +47,8 @@
 		file.write(command + '\n');
 		file.close
 
-		if not grep('Result: OK', self.pgdev):
-			if not grep('Result: NA', self.pgdev):
+		if not autotest_utils.grep('Result: OK', self.pgdev):
+			if not autotest_utils.grep('Result: NA', self.pgdev):
 				utils.system('cat ' + self.pgdev)
 				# raise UnhandledError('Result not OK')
 
diff --git a/client/tests/posixtest/posixtest.py b/client/tests/posixtest/posixtest.py
index 9eb15aa..e11989a 100755
--- a/client/tests/posixtest/posixtest.py
+++ b/client/tests/posixtest/posixtest.py
@@ -11,7 +11,7 @@
 	version = 1
 	# http://ufpr.dl.sourceforge.net/sourceforge/posixtest/posixtestsuite-1.5.2.tar.gz
 	def setup(self, tarball = 'posixtestsuite-1.5.2.tar.gz'):
-		self.posix_tarball = autotest_utils.unmap_url(self.bindir,
+		self.posix_tarball = utils.unmap_url(self.bindir,
 		                                              tarball,
 		                                              self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(self.posix_tarball,
diff --git a/client/tests/reaim/reaim.py b/client/tests/reaim/reaim.py
index 51815f9..7e43723 100755
--- a/client/tests/reaim/reaim.py
+++ b/client/tests/reaim/reaim.py
@@ -9,7 +9,7 @@
 
 	# 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'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 
diff --git a/client/tests/rtlinuxtests/rtlinuxtests.py b/client/tests/rtlinuxtests/rtlinuxtests.py
index bafb24d..e6df6e3 100644
--- a/client/tests/rtlinuxtests/rtlinuxtests.py
+++ b/client/tests/rtlinuxtests/rtlinuxtests.py
@@ -17,8 +17,8 @@
 	# http://www.kernel.org/pub/linux/kernel/people/dvhart/realtime/tests/tests.tar.bz2
 
 	def setup(self, tarball = 'tests.tar.bz2'):
-		check_glibc_ver('2.5')
-		self.tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		autotest_utils.check_glibc_ver('2.5')
+		self.tarball = utils.unmap_url(self.bindir, tarball,
 		                                        self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(self.tarball, self.srcdir)
 		os.chdir(self.srcdir)
diff --git a/client/tests/rttester/rttester.py b/client/tests/rttester/rttester.py
index b3c9652..97cea0a 100644
--- a/client/tests/rttester/rttester.py
+++ b/client/tests/rttester/rttester.py
@@ -1,3 +1,4 @@
+import os
 from autotest_lib.client.bin import test, autotest_utils, os_dep
 from autotest_lib.client.common_lib import utils
 
@@ -8,7 +9,7 @@
 	# http://www.stardust.webpages.pl/files/patches/autotest/rttester.tar.bz2
 
 	def setup(self, tarball = 'rttester.tar.bz2'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 
diff --git a/client/tests/scrashme/scrashme.py b/client/tests/scrashme/scrashme.py
index 7c7dd1e..3d8b237 100644
--- a/client/tests/scrashme/scrashme.py
+++ b/client/tests/scrashme/scrashme.py
@@ -8,7 +8,7 @@
 
 	# http://www.codemonkey.org.uk/projects/git-snapshots/scrashme/scrashme-2007-07-08.tar.gz
 	def setup(self, tarball = 'scrashme-2007-07-08.tar.gz'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 		os.chdir(self.srcdir)
diff --git a/client/tests/signaltest/signaltest.py b/client/tests/signaltest/signaltest.py
index c0b22ff..9c483c9 100644
--- a/client/tests/signaltest/signaltest.py
+++ b/client/tests/signaltest/signaltest.py
@@ -1,3 +1,4 @@
+import os
 from autotest_lib.client.bin import test
 from autotest_lib.client.common_lib import utils
 
diff --git a/client/tests/sparse/sparse.py b/client/tests/sparse/sparse.py
index 6f31b62..3a434cd 100755
--- a/client/tests/sparse/sparse.py
+++ b/client/tests/sparse/sparse.py
@@ -8,7 +8,7 @@
 
 	# http://www.codemonkey.org.uk/projects/git-snapshots/sparse/sparse-2006-04-28.tar.gz
 	def setup(self, tarball = 'sparse-2006-04-28.tar.gz'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 		os.chdir(self.srcdir)
diff --git a/client/tests/spew/spew.py b/client/tests/spew/spew.py
index cf12136..7c04cc8 100755
--- a/client/tests/spew/spew.py
+++ b/client/tests/spew/spew.py
@@ -8,7 +8,7 @@
 
 	# ftp://ftp.berlios.de/pub/spew/1.0.5/spew-1.0.5.tgz
 	def setup(self, tarball = 'spew-1.0.5.tgz'):
-		self.tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		self.tarball = utils.unmap_url(self.bindir, tarball,
 		                                        self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(self.tarball, self.srcdir)
 
diff --git a/client/tests/stress/stress.py b/client/tests/stress/stress.py
index d5120b8..5714045 100644
--- a/client/tests/stress/stress.py
+++ b/client/tests/stress/stress.py
@@ -8,7 +8,7 @@
 
 	# http://weather.ou.edu/~apw/projects/stress/stress-0.18.8.tar.gz
 	def setup(self, tarball = 'stress-0.18.8.tar.gz'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 		os.chdir(self.srcdir)
@@ -19,7 +19,7 @@
 
 	def execute(self, iterations = 1, args = ''):
 		if not args:
-			threads = 2*count_cpus()
+			threads = 2*autotest_utils.count_cpus()
 			args = '-c %d -i %d -m %d -d %d -t 60 -v' % \
 				(threads, threads, threads, threads)
 
diff --git a/client/tests/sysbench/sysbench.py b/client/tests/sysbench/sysbench.py
index 7a19745..58b7d25 100644
--- a/client/tests/sysbench/sysbench.py
+++ b/client/tests/sysbench/sysbench.py
@@ -8,7 +8,7 @@
 
 	# http://osdn.dl.sourceforge.net/sourceforge/sysbench/sysbench-0.4.8.tar.gz
 	def setup(self, tarball = 'sysbench-0.4.8.tar.bz2'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 		self.job.setup_dep(['pgsql', 'mysql'])
@@ -20,11 +20,11 @@
 
 		# configure wants to get at pg_config, so add its path
 		utils.system('PATH=%s/bin:$PATH ./configure --with-mysql=%s --with-pgsql' % (pgsql_dir, mysql_dir))
-		utils.system('make -j %d' % count_cpus())
+		utils.system('make -j %d' % autotest_utils.count_cpus())
 
 
 	def execute(self, db_type = 'pgsql', build = 1, \
-			num_threads = count_cpus(), max_time = 60, \
+			num_threads = autotest_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')
diff --git a/client/tests/tbench/tbench.py b/client/tests/tbench/tbench.py
index 7e2fd39..3bc0667 100755
--- a/client/tests/tbench/tbench.py
+++ b/client/tests/tbench/tbench.py
@@ -8,7 +8,7 @@
 
 	# http://samba.org/ftp/tridge/dbench/dbench-3.04.tar.gz
 	def setup(self, tarball = 'dbench-3.04.tar.gz'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 		os.chdir(self.srcdir)
diff --git a/client/tests/tiobench/tiobench.py b/client/tests/tiobench/tiobench.py
index cd7c165..6c55567 100644
--- a/client/tests/tiobench/tiobench.py
+++ b/client/tests/tiobench/tiobench.py
@@ -8,7 +8,7 @@
 
 	# http://prdownloads.sourceforge.net/tiobench/tiobench-0.3.3.tar.gz
 	def setup(self, tarball = 'tiobench-0.3.3.tar.bz2'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 		os.chdir(self.srcdir)
diff --git a/client/tests/tsc/tsc.py b/client/tests/tsc/tsc.py
index 6476eb9..79b5c26 100755
--- a/client/tests/tsc/tsc.py
+++ b/client/tests/tsc/tsc.py
@@ -6,7 +6,7 @@
 	version = 1
 
 	def setup(self, tarball = 'checktsc.tar'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 		os.chdir(self.srcdir)
diff --git a/client/tests/unixbench/unixbench.py b/client/tests/unixbench/unixbench.py
index 6d8c810..5685404 100755
--- a/client/tests/unixbench/unixbench.py
+++ b/client/tests/unixbench/unixbench.py
@@ -8,7 +8,7 @@
 
 	# http://www.tux.org/pub/tux/niemi/unixbench/unixbench-4.1.0.tgz
 	def setup(self, tarball = 'unixbench-4.1.0.tar.bz2'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 		os.chdir(self.srcdir)
diff --git a/client/tests/xmtest/xmtest.py b/client/tests/xmtest/xmtest.py
index e8b2b69..32c649a 100644
--- a/client/tests/xmtest/xmtest.py
+++ b/client/tests/xmtest/xmtest.py
@@ -18,7 +18,7 @@
 	# cd tools
 	# tar -czf xm-test.tgz xm-test
 	def setup(self, tarball = 'xm-test.tar.bz2'):
-		tarball = autotest_utils.unmap_url(self.bindir, tarball,
+		tarball = utils.unmap_url(self.bindir, tarball,
 		                                   self.tmpdir)
 		autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
 		os.chdir(self.srcdir)