ltp.py revision 6f27d4f22a1ba5063968b8c322fa0845f3279ade
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 = 6 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-20091231.tgz 27 def setup(self, tarball = 'ltp-full-20091231.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 ltpbin_dir = os.path.join(self.srcdir, 'bin') 32 os.mkdir(ltpbin_dir) 33 34 utils.system('patch -p1 < ../ltp.patch') 35 36 # comment the capability tests if we fail to load the capability module 37 try: 38 utils.system('modprobe capability') 39 except error.CmdError, detail: 40 utils.system('patch -p1 < ../ltp_capability.patch') 41 42 utils.system('cp ../scan.c pan/') # saves having lex installed 43 utils.make('autotools') 44 utils.configure('--prefix=%s' % ltpbin_dir) 45 utils.make('-j %d all' % utils.count_cpus()) 46 utils.system('yes n | make SKIP_IDCHECK=1 install') 47 48 49 # Note: to run a specific test, try '-f cmdfile -s test' in the 50 # in the args (-f for test file and -s for the test case) 51 # eg, job.run_test('ltp', '-f math -s float_bessel') 52 def run_once(self, args = '', script = 'runltp', ignore_tests=[]): 53 54 ignore_tests = ignore_tests + self.site_ignore_tests 55 56 # In case the user wants to run another test script 57 if script == 'runltp': 58 logfile = os.path.join(self.resultsdir, 'ltp.log') 59 outfile = os.path.join(self.resultsdir, 'ltp.out') 60 failcmdfile = os.path.join(self.debugdir, 'failcmdfile') 61 excludecmdfile = os.path.join(self.bindir, 'site_excluded') 62 args2 = '-q -l %s -C %s -d %s -o %s -S %s' % (logfile, failcmdfile, 63 self.tmpdir, outfile, 64 excludecmdfile) 65 args = args + ' ' + args2 66 67 ltpbin_dir = os.path.join(self.srcdir, 'bin') 68 cmd = os.path.join(ltpbin_dir, script) + ' ' + args 69 result = utils.run(cmd, ignore_status=True) 70 71 # look for if there is any failed test command. 72 failed_cmd = open(failcmdfile).read() 73 if failed_cmd: 74 raise error.TestFail(failed_cmd) 75