Deleted Added
sdiff udiff text old ( 13181:768a9881729b ) new ( 13183:fb400e21c46f )
full compact
1#!/usr/bin/env python2
2#
3# Copyright 2018 Google, Inc.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

--- 110 unchanged lines hidden (view full) ---

119 return self.number < other.number
120
121class CompilePhase(TestPhaseBase):
122 name = 'compile'
123 number = 1
124
125 def run(self, tests):
126 targets = list([test.full_path() for test in tests])
127 scons_args = [ 'USE_SYSTEMC=1' ] + list(self.args) + targets
128 scons(*scons_args)
129
130class RunPhase(TestPhaseBase):
131 name = 'execute'
132 number = 2
133
134 def run(self, tests):
135 parser = argparse.ArgumentParser()
136 parser.add_argument('--timeout', type=int, metavar='SECONDS',
137 help='Time limit for each run in seconds.',
138 default=0)
139 parser.add_argument('-j', type=int, default=1,
140 help='How many tests to run in parallel.')
141 args = parser.parse_args(self.args)
142
143 timeout_cmd = [
144 'timeout',
145 '--kill-after', str(args.timeout * 2),
146 str(args.timeout)
147 ]

--- 19 unchanged lines hidden (view full) ---

167 except subprocess.CalledProcessError, error:
168 returncode = error.returncode
169 else:
170 returncode = 0
171 os.chdir(curdir)
172 with open(test.returncode_file(), 'w') as rc:
173 rc.write('%d\n' % returncode)
174
175 runnable = filter(lambda t: not t.compile_only, tests)
176 if args.j == 1:
177 map(run_test, runnable)
178 else:
179 tp = multiprocessing.pool.ThreadPool(args.j)
180 map(lambda t: tp.apply_async(run_test, (t,)), runnable)
181 tp.close()
182 tp.join()
183
184class Checker(object):
185 def __init__(self, ref, test, tag):
186 self.ref = ref
187 self.test = test

--- 186 unchanged lines hidden (view full) ---

374
375 def run(self, tests):
376 parser = argparse.ArgumentParser()
377 result_opts = parser.add_mutually_exclusive_group()
378 result_opts.add_argument('--result-file', action='store_true',
379 help='Create a results.json file in the current directory.')
380 result_opts.add_argument('--result-file-at', metavar='PATH',
381 help='Create a results json file at the given path.')
382 parser.add_argument('--print-results', action='store_true',
383 help='Print a list of tests that passed or failed')
384 args = parser.parse_args(self.args)
385
386 self.reset_status()
387
388 runnable = filter(lambda t: not t.compile_only, tests)
389 compile_only = filter(lambda t: t.compile_only, tests)
390
391 for test in compile_only:

--- 55 unchanged lines hidden (view full) ---

447 failed_diffs = filter(lambda d: not d.check(), diffs)
448 if failed_diffs:
449 tags = map(lambda d: d.tag, failed_diffs)
450 self.failed(test, 'failed diffs', ' '.join(tags))
451 continue
452
453 self.passed(test)
454
455 if args.print_results:
456 self.print_results()
457
458 self.print_status()
459
460 result_path = None
461 if args.result_file:
462 result_path = os.path.join(os.getcwd(), 'results.json')
463 elif args.result_file_at:

--- 13 unchanged lines hidden (view full) ---

477
478parser.add_argument('--flavor', choices=['debug', 'opt', 'fast'],
479 default='opt',
480 help='Flavor of binary to test.')
481
482parser.add_argument('--list', action='store_true',
483 help='List the available tests')
484
485filter_opts = parser.add_mutually_exclusive_group()
486filter_opts.add_argument('--filter', default='True',
487 help='Python expression which filters tests based '
488 'on their properties')
489filter_opts.add_argument('--filter-file', default=None,
490 type=argparse.FileType('r'),
491 help='Same as --filter, but read from a file')
492

--- 63 unchanged lines hidden ---