OLD | NEW |
1 import os, re, logging | 1 import os, re, logging |
2 from autotest_lib.client.bin import test, utils | 2 from autotest_lib.client.bin import test, utils |
3 from autotest_lib.client.common_lib import error | 3 from autotest_lib.client.common_lib import error |
4 | 4 |
5 class monotonic_time(test.test): | 5 class monotonic_time(test.test): |
6 version = 1 | 6 version = 1 |
7 | 7 |
8 preserve_srcdir = True | 8 preserve_srcdir = True |
9 | 9 |
10 def setup(self): | 10 def setup(self): |
11 os.chdir(self.srcdir) | 11 os.chdir(self.srcdir) |
12 utils.make() | 12 utils.system('make') |
13 | 13 |
14 | 14 |
15 def initialize(self): | 15 def initialize(self): |
16 self.job.require_gcc() | 16 self.job.require_gcc() |
17 | 17 |
18 | 18 |
19 def run_once(self, test_type = None, duration = 300, threshold = None): | 19 def run_once(self, test_type = None, duration = 300, threshold = None): |
20 if not test_type: | 20 if not test_type: |
21 raise error.TestError('missing test type') | 21 raise error.TestError('missing test type') |
22 | 22 |
23 cmd = self.srcdir + '/time_test' | 23 cmd = self.srcdir + '/time_test' |
24 cmd += ' --duration ' + str(duration) | 24 cmd += ' --duration ' + str(duration) |
25 if threshold: | 25 if threshold: |
26 cmd += ' --threshold ' + str(threshold) | 26 cmd += ' --threshold ' + str(threshold) |
27 cmd += ' ' + test_type | 27 cmd += ' ' + test_type |
28 | 28 |
29 self.results = utils.run(cmd, ignore_status=True) | 29 self.results = utils.run(cmd, ignore_status=True) |
30 logging.info('Time test command exit status: %s', | 30 logging.info('Time test command exit status: %s', |
31 self.results.exit_status) | 31 self.results.exit_status) |
32 if self.results.exit_status != 0: | 32 if self.results.exit_status != 0: |
33 for line in self.results.stdout.splitlines(): | 33 for line in self.results.stdout.splitlines(): |
34 if line.startswith('ERROR:'): | 34 if line.startswith('ERROR:'): |
35 raise error.TestError(line) | 35 raise error.TestError(line) |
36 if line.startswith('FAIL:'): | 36 if line.startswith('FAIL:'): |
37 raise error.TestFail(line) | 37 raise error.TestFail(line) |
38 raise error.TestError('unknown test failure') | 38 raise error.TestError('unknown test failure') |
OLD | NEW |