blob: 70777844dbbf5c5ea62c3a795ea2072802ad0278 [file] [log] [blame]
lmr4c607f22009-06-02 11:50:38 +00001import os, re, logging
mbligh53da18e2009-01-05 21:13:26 +00002from autotest_lib.client.bin import test, utils
3from autotest_lib.client.common_lib import error
mbligh50f4b3c2007-03-14 16:42:41 +00004
5class tsc(test.test):
mbligh9f0d48b2008-08-25 19:12:54 +00006 version = 2
mbligha8fe6372008-08-28 20:55:43 +00007
mbligh9f0d48b2008-08-25 19:12:54 +00008 preserve_srcdir = True
mbligh50f4b3c2007-03-14 16:42:41 +00009
mbligh9f0d48b2008-08-25 19:12:54 +000010 def setup(self):
jadmanski0afbb632008-06-06 21:10:57 +000011 os.chdir(self.srcdir)
12 utils.system('make')
mbligh50f4b3c2007-03-14 16:42:41 +000013
jadmanski0afbb632008-06-06 21:10:57 +000014
mblighc5ddfd12008-08-04 17:15:00 +000015 def initialize(self):
16 self.job.require_gcc()
17
18
mbligh9f0d48b2008-08-25 19:12:54 +000019 def run_once(self, args = '-t 650'):
mbligha8fe6372008-08-28 20:55:43 +000020 result = utils.run(self.srcdir + '/checktsc ' + args,
21 ignore_status=True)
mbligha8fe6372008-08-28 20:55:43 +000022 if result.exit_status != 0:
lmr4c607f22009-06-02 11:50:38 +000023 logging.error('Program checktsc exit status is %s',
24 result.exit_status)
mbligha8fe6372008-08-28 20:55:43 +000025 default_reason = ("UNKNOWN FAILURE: rc=%d from %s" %
26 (result.exit_status, result.command))
27 ## Analyze result.stdout to see if it is possible to form qualified
28 ## reason of failure and to raise an appropriate exception.
29 ## For this test we qualify the reason of failure if the
30 ## following conditions are met:
31 ## (i) result.exit_status = 1
32 ## (ii) result.stdout ends with 'FAIL'
33 ## (iii) "FAIL" is preceeded by one or more
34 ## lines in the following format:
35 ## CPU x - CPU y = <delta>
36 ## Set as a reason the line that contains max abs(delta)
37 if result.exit_status == 1:
38 if result.stdout.strip('\n').endswith('FAIL'):
39 ## find all lines
40 ## CPU x - CPU y = <delta>
41 ## and parse out delta of max abs value
42 max_delta = 0
43 reason = ''
44 threshold = int(args.split()[1])
45 latencies = re.findall("CPU \d+ - CPU \d+ =\s+-*\d+",
46 result.stdout)
47 for ln in latencies:
48 cur_delta = int(ln.split('=', 2)[1])
49 if abs(cur_delta) > max_delta:
50 max_delta = abs(cur_delta)
51 reason = ln
52 if max_delta > threshold:
53 reason = "Latency %s exceeds threshold %d" % (reason,
54 threshold)
55 raise error.TestFail(reason)
56
57 ## If we are here, we failed to qualify the reason of test failre
58 ## Consider it as a test error
59 raise error.TestError(default_reason)
60
61