blob: 2671e8b0f57a274823f3198918f2697203ac4e23 [file] [log] [blame]
Mike Truty07dabdb2012-02-24 23:57:14 -07001# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import logging
mbligh9424c662007-10-03 20:27:58 +00006import os
mbligh53da18e2009-01-05 21:13:26 +00007from autotest_lib.client.bin import utils, test
8from autotest_lib.client.common_lib import error
mblighaa0e5692006-04-23 05:34:45 +00009
Mike Truty07dabdb2012-02-24 23:57:14 -070010import parse_ltp_out
11
12
mbligh7b740c12006-04-22 21:37:01 +000013class ltp(test.test):
mbligh0a591662010-01-06 18:26:20 +000014 version = 6
mbligh7b740c12006-04-22 21:37:01 +000015
mblighd8d6c482009-02-17 15:54:36 +000016 def _import_site_config(self):
17 site_config_path = os.path.join(os.path.dirname(__file__),
18 'site_config.py')
19 if os.path.exists(site_config_path):
20 # for some reason __import__ with full path does not work within
21 # autotest, although it works just fine on the same client machine
22 # in the python interactive shell or separate testcases
23 execfile(site_config_path)
24 self.site_ignore_tests = locals().get('ignore_tests', [])
25 else:
26 self.site_ignore_tests = []
27
28
mblighc5ddfd12008-08-04 17:15:00 +000029 def initialize(self):
mblighd8d6c482009-02-17 15:54:36 +000030 self._import_site_config()
mblighc5ddfd12008-08-04 17:15:00 +000031 self.job.require_gcc()
32
33
Mike Truty07dabdb2012-02-24 23:57:14 -070034 # http://sourceforge.net/projects/ltp/files/LTP%20Source/ltp-20120104/
35 # ltp-full-20120104.bz2
36 def setup(self, tarball = 'ltp-full-20120104.bz2'):
mbligh8b352852008-06-07 01:07:08 +000037 tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir)
mbligh53da18e2009-01-05 21:13:26 +000038 utils.extract_tarball_to_dir(tarball, self.srcdir)
jadmanski0afbb632008-06-06 21:10:57 +000039 os.chdir(self.srcdir)
mbligh0a591662010-01-06 18:26:20 +000040 ltpbin_dir = os.path.join(self.srcdir, 'bin')
41 os.mkdir(ltpbin_dir)
mbligh7b740c12006-04-22 21:37:01 +000042
Mike Truty3743a312012-06-10 21:56:43 -070043 utils.system('patch -p1 < ../patches/getdents.patch')
44 utils.system('patch -p1 < ../patches/cpuid.patch')
45 utils.system('patch -p1 < ../patches/kill-ipc.patch')
46 utils.system('patch -p1 < ../patches/genpow.patch')
Mike Frysinger13a7f292013-02-08 19:42:14 -050047 utils.system('patch -p1 < ../patches/sysctl.patch')
Eric Li6f27d4f2010-09-29 10:55:17 -070048 utils.make('autotools')
Kenneth Waters4cefaef2010-03-24 11:23:51 -070049 utils.configure('--prefix=%s' % ltpbin_dir)
Eric Li6f27d4f2010-09-29 10:55:17 -070050 utils.make('-j %d all' % utils.count_cpus())
mbligh0a591662010-01-06 18:26:20 +000051 utils.system('yes n | make SKIP_IDCHECK=1 install')
mblighcac5cb22006-08-29 23:42:50 +000052
mbligha65cd332007-10-04 15:53:07 +000053
Mike Truty07dabdb2012-02-24 23:57:14 -070054 # Note: to run specific test(s), runltp supports an option (-f)
55 # to specify a custom 'scenario group' which is a comma-separated
56 # list of cmdfiles and/or an option (-s) to specify a grep match
57 # pattern for individual test names.
58 # e.g. -for all tests in math cmdfile:
59 # job.run_test('ltp', '-f math')
60 # -for just the float_bessel test in the math cmdfile:
61 # job.run_test('ltp', '-f math -s float_bessel')
62 # -for the math and memory management cmdfiles:
63 # job.run_test('ltp', '-f math,mm')
64 # Note: the site_excluded file lists individual test tags for tests
65 # to exclude (see the comment at the top of site_excluded).
mbligh82203222009-05-21 16:32:34 +000066 def run_once(self, args = '', script = 'runltp', ignore_tests=[]):
mbligh9424c662007-10-03 20:27:58 +000067
mblighd8d6c482009-02-17 15:54:36 +000068 ignore_tests = ignore_tests + self.site_ignore_tests
69
jadmanski0afbb632008-06-06 21:10:57 +000070 # In case the user wants to run another test script
71 if script == 'runltp':
72 logfile = os.path.join(self.resultsdir, 'ltp.log')
Eric Li9ba0b032010-01-29 15:38:04 -080073 outfile = os.path.join(self.resultsdir, 'ltp.out')
jadmanski0afbb632008-06-06 21:10:57 +000074 failcmdfile = os.path.join(self.debugdir, 'failcmdfile')
Eric Li9ba0b032010-01-29 15:38:04 -080075 excludecmdfile = os.path.join(self.bindir, 'site_excluded')
Mike Truty07dabdb2012-02-24 23:57:14 -070076 args2 = '-p -l %s -C %s -d %s -o %s -S %s' % (logfile, failcmdfile,
Eric Li9ba0b032010-01-29 15:38:04 -080077 self.tmpdir, outfile,
78 excludecmdfile)
jadmanski0afbb632008-06-06 21:10:57 +000079 args = args + ' ' + args2
mbligh772942d2007-11-20 16:32:07 +000080
mbligh0a591662010-01-06 18:26:20 +000081 ltpbin_dir = os.path.join(self.srcdir, 'bin')
82 cmd = os.path.join(ltpbin_dir, script) + ' ' + args
mbligh82203222009-05-21 16:32:34 +000083 result = utils.run(cmd, ignore_status=True)
84
Mike Truty07dabdb2012-02-24 23:57:14 -070085 if script == 'runltp':
86 parse_ltp_out.summarize(outfile)
87
88 # look for any failed test command.
89 try:
90 f = open(failcmdfile)
91 except IOError:
92 logging.warning('Expected to find failcmdfile but did not.')
93 return
94 failed_cmd = f.read().strip()
95 f.close()
Eric Li9ba0b032010-01-29 15:38:04 -080096 if failed_cmd:
97 raise error.TestFail(failed_cmd)