1import time, os 2from autotest_lib.client.bin import test, utils 3from autotest_lib.client.common_lib import error 4 5class cpu_hotplug(test.test): 6 version = 2 7 8 # http://developer.osdl.org/dev/hotplug/tests/lhcs_regression-1.6.tgz 9 def setup(self, tarball = 'lhcs_regression-1.6.tgz'): 10 tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) 11 utils.extract_tarball_to_dir(tarball, self.srcdir) 12 13 14 def initialize(self): 15 # Check if the kernel supports cpu hotplug 16 if utils.running_config(): 17 utils.check_for_kernel_feature('HOTPLUG_CPU') 18 19 # Check cpu nums, if equals 1, quit. 20 if utils.count_cpus() == 1: 21 e_msg = 'Single CPU online detected, test not supported.' 22 raise error.TestNAError(e_msg) 23 24 # Have a simple and quick check first, FIX me please. 25 utils.system('dmesg -c > /dev/null') 26 for cpu in utils.cpu_online_map(): 27 if os.path.isfile('/sys/devices/system/cpu/cpu%s/online' % cpu): 28 utils.system('echo 0 > /sys/devices/system/cpu/cpu%s/online' % cpu, 1) 29 utils.system('dmesg -c') 30 time.sleep(3) 31 utils.system('echo 1 > /sys/devices/system/cpu/cpu%s/online' % cpu, 1) 32 utils.system('dmesg -c') 33 time.sleep(3) 34 35 36 def run_once(self): 37 # Begin this cpu hotplug test big guru. 38 os.chdir(self.srcdir) 39 utils.system('./runtests.sh') 40