Mike Truty | 07dabdb | 2012-02-24 23:57:14 -0700 | [diff] [blame] | 1 | # 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 | |
| 5 | import logging |
mbligh | 9424c66 | 2007-10-03 20:27:58 +0000 | [diff] [blame] | 6 | import os |
mbligh | 53da18e | 2009-01-05 21:13:26 +0000 | [diff] [blame] | 7 | from autotest_lib.client.bin import utils, test |
| 8 | from autotest_lib.client.common_lib import error |
mbligh | aa0e569 | 2006-04-23 05:34:45 +0000 | [diff] [blame] | 9 | |
Mike Truty | 07dabdb | 2012-02-24 23:57:14 -0700 | [diff] [blame] | 10 | import parse_ltp_out |
| 11 | |
| 12 | |
mbligh | 7b740c1 | 2006-04-22 21:37:01 +0000 | [diff] [blame] | 13 | class ltp(test.test): |
mbligh | 0a59166 | 2010-01-06 18:26:20 +0000 | [diff] [blame] | 14 | version = 6 |
mbligh | 7b740c1 | 2006-04-22 21:37:01 +0000 | [diff] [blame] | 15 | |
mbligh | d8d6c48 | 2009-02-17 15:54:36 +0000 | [diff] [blame] | 16 | 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 | |
mbligh | c5ddfd1 | 2008-08-04 17:15:00 +0000 | [diff] [blame] | 29 | def initialize(self): |
mbligh | d8d6c48 | 2009-02-17 15:54:36 +0000 | [diff] [blame] | 30 | self._import_site_config() |
mbligh | c5ddfd1 | 2008-08-04 17:15:00 +0000 | [diff] [blame] | 31 | self.job.require_gcc() |
| 32 | |
| 33 | |
Mike Truty | 07dabdb | 2012-02-24 23:57:14 -0700 | [diff] [blame] | 34 | # http://sourceforge.net/projects/ltp/files/LTP%20Source/ltp-20120104/ |
| 35 | # ltp-full-20120104.bz2 |
| 36 | def setup(self, tarball = 'ltp-full-20120104.bz2'): |
mbligh | 8b35285 | 2008-06-07 01:07:08 +0000 | [diff] [blame] | 37 | tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) |
mbligh | 53da18e | 2009-01-05 21:13:26 +0000 | [diff] [blame] | 38 | utils.extract_tarball_to_dir(tarball, self.srcdir) |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 39 | os.chdir(self.srcdir) |
mbligh | 0a59166 | 2010-01-06 18:26:20 +0000 | [diff] [blame] | 40 | ltpbin_dir = os.path.join(self.srcdir, 'bin') |
| 41 | os.mkdir(ltpbin_dir) |
mbligh | 7b740c1 | 2006-04-22 21:37:01 +0000 | [diff] [blame] | 42 | |
Mike Truty | 3743a31 | 2012-06-10 21:56:43 -0700 | [diff] [blame] | 43 | 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 Frysinger | 13a7f29 | 2013-02-08 19:42:14 -0500 | [diff] [blame] | 47 | utils.system('patch -p1 < ../patches/sysctl.patch') |
Eric Li | 6f27d4f | 2010-09-29 10:55:17 -0700 | [diff] [blame] | 48 | utils.make('autotools') |
Kenneth Waters | 4cefaef | 2010-03-24 11:23:51 -0700 | [diff] [blame] | 49 | utils.configure('--prefix=%s' % ltpbin_dir) |
Eric Li | 6f27d4f | 2010-09-29 10:55:17 -0700 | [diff] [blame] | 50 | utils.make('-j %d all' % utils.count_cpus()) |
mbligh | 0a59166 | 2010-01-06 18:26:20 +0000 | [diff] [blame] | 51 | utils.system('yes n | make SKIP_IDCHECK=1 install') |
mbligh | cac5cb2 | 2006-08-29 23:42:50 +0000 | [diff] [blame] | 52 | |
mbligh | a65cd33 | 2007-10-04 15:53:07 +0000 | [diff] [blame] | 53 | |
Mike Truty | 07dabdb | 2012-02-24 23:57:14 -0700 | [diff] [blame] | 54 | # 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). |
mbligh | 8220322 | 2009-05-21 16:32:34 +0000 | [diff] [blame] | 66 | def run_once(self, args = '', script = 'runltp', ignore_tests=[]): |
mbligh | 9424c66 | 2007-10-03 20:27:58 +0000 | [diff] [blame] | 67 | |
mbligh | d8d6c48 | 2009-02-17 15:54:36 +0000 | [diff] [blame] | 68 | ignore_tests = ignore_tests + self.site_ignore_tests |
| 69 | |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 70 | # In case the user wants to run another test script |
| 71 | if script == 'runltp': |
| 72 | logfile = os.path.join(self.resultsdir, 'ltp.log') |
Eric Li | 9ba0b03 | 2010-01-29 15:38:04 -0800 | [diff] [blame] | 73 | outfile = os.path.join(self.resultsdir, 'ltp.out') |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 74 | failcmdfile = os.path.join(self.debugdir, 'failcmdfile') |
Eric Li | 9ba0b03 | 2010-01-29 15:38:04 -0800 | [diff] [blame] | 75 | excludecmdfile = os.path.join(self.bindir, 'site_excluded') |
Mike Truty | 07dabdb | 2012-02-24 23:57:14 -0700 | [diff] [blame] | 76 | args2 = '-p -l %s -C %s -d %s -o %s -S %s' % (logfile, failcmdfile, |
Eric Li | 9ba0b03 | 2010-01-29 15:38:04 -0800 | [diff] [blame] | 77 | self.tmpdir, outfile, |
| 78 | excludecmdfile) |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 79 | args = args + ' ' + args2 |
mbligh | 772942d | 2007-11-20 16:32:07 +0000 | [diff] [blame] | 80 | |
mbligh | 0a59166 | 2010-01-06 18:26:20 +0000 | [diff] [blame] | 81 | ltpbin_dir = os.path.join(self.srcdir, 'bin') |
| 82 | cmd = os.path.join(ltpbin_dir, script) + ' ' + args |
mbligh | 8220322 | 2009-05-21 16:32:34 +0000 | [diff] [blame] | 83 | result = utils.run(cmd, ignore_status=True) |
| 84 | |
Mike Truty | 07dabdb | 2012-02-24 23:57:14 -0700 | [diff] [blame] | 85 | 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 Li | 9ba0b03 | 2010-01-29 15:38:04 -0800 | [diff] [blame] | 96 | if failed_cmd: |
| 97 | raise error.TestFail(failed_cmd) |