ltp.py revision d8d6c483ef43b611794fa5a67b04371de122a186
1import os 2from autotest_lib.client.bin import utils, test 3from autotest_lib.client.common_lib import error 4 5class ltp(test.test): 6 version = 5 7 8 def _import_site_config(self): 9 site_config_path = os.path.join(os.path.dirname(__file__), 10 'site_config.py') 11 if os.path.exists(site_config_path): 12 # for some reason __import__ with full path does not work within 13 # autotest, although it works just fine on the same client machine 14 # in the python interactive shell or separate testcases 15 execfile(site_config_path) 16 self.site_ignore_tests = locals().get('ignore_tests', []) 17 else: 18 self.site_ignore_tests = [] 19 20 21 def initialize(self): 22 self._import_site_config() 23 self.job.require_gcc() 24 25 26 # http://prdownloads.sourceforge.net/ltp/ltp-full-20080229.tgz 27 def setup(self, tarball = 'ltp-full-20080229.tar.bz2'): 28 tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) 29 utils.extract_tarball_to_dir(tarball, self.srcdir) 30 os.chdir(self.srcdir) 31 32 utils.system('patch -p1 < ../ltp.patch') 33 34 # comment the capability tests if we fail to load the capability module 35 try: 36 utils.system('modprobe capability') 37 except error.CmdError, detail: 38 utils.system('patch -p1 < ../ltp_capability.patch') 39 40 utils.system('cp ../scan.c pan/') # saves having lex installed 41 utils.system('[ -f configure.ac ] && make autotools || make autoconf') 42 utils.system('[ -x configure ] && ./configure') 43 utils.system('make -j %d || make' % autotest_utils.count_cpus()) 44 utils.system('yes n | make install') 45 46 47 # Note: to run a specific test, try '-f cmdfile -s test' in the 48 # in the args (-f for test file and -s for the test case) 49 # eg, job.run_test('ltp', '-f math -s float_bessel') 50 def run_once(self, args = '', script = 'runltp'): 51 52 ignore_tests = ignore_tests + self.site_ignore_tests 53 54 # In case the user wants to run another test script 55 if script == 'runltp': 56 logfile = os.path.join(self.resultsdir, 'ltp.log') 57 failcmdfile = os.path.join(self.debugdir, 'failcmdfile') 58 args2 = '-q -l %s -C %s -d %s' % (logfile, failcmdfile, self.tmpdir) 59 args = args + ' ' + args2 60 61 cmd = os.path.join(self.srcdir, script) + ' ' + args 62 utils.system(cmd) 63