verify.py (13181:768a9881729b) verify.py (13183:fb400e21c46f)
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])
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
128 parser = argparse.ArgumentParser()
129 parser.add_argument('-j', type=int, default=0)
130 args, leftovers = parser.parse_known_args(self.args)
131 if args.j == 0:
132 self.args = ('-j', str(self.main_args.j)) + self.args
133
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',
134 scons_args = [ 'USE_SYSTEMC=1' ] + list(self.args) + targets
135 scons(*scons_args)
136
137class RunPhase(TestPhaseBase):
138 name = 'execute'
139 number = 2
140
141 def run(self, tests):
142 parser = argparse.ArgumentParser()
143 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,
144 help='Time limit for each run in seconds, '
145 '0 to disable.',
146 default=60)
147 parser.add_argument('-j', type=int, default=0,
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
148 help='How many tests to run in parallel.')
149 args = parser.parse_args(self.args)
150
151 timeout_cmd = [
152 'timeout',
153 '--kill-after', str(args.timeout * 2),
154 str(args.timeout)
155 ]

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

175 except subprocess.CalledProcessError, error:
176 returncode = error.returncode
177 else:
178 returncode = 0
179 os.chdir(curdir)
180 with open(test.returncode_file(), 'w') as rc:
181 rc.write('%d\n' % returncode)
182
183 j = self.main_args.j if args.j == 0 else args.j
184
175 runnable = filter(lambda t: not t.compile_only, tests)
185 runnable = filter(lambda t: not t.compile_only, tests)
176 if args.j == 1:
186 if j == 1:
177 map(run_test, runnable)
178 else:
187 map(run_test, runnable)
188 else:
179 tp = multiprocessing.pool.ThreadPool(args.j)
189 tp = multiprocessing.pool.ThreadPool(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.')
190 map(lambda t: tp.apply_async(run_test, (t,)), runnable)
191 tp.close()
192 tp.join()
193
194class Checker(object):
195 def __init__(self, ref, test, tag):
196 self.ref = ref
197 self.test = test

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

384
385 def run(self, tests):
386 parser = argparse.ArgumentParser()
387 result_opts = parser.add_mutually_exclusive_group()
388 result_opts.add_argument('--result-file', action='store_true',
389 help='Create a results.json file in the current directory.')
390 result_opts.add_argument('--result-file-at', metavar='PATH',
391 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')
392 parser.add_argument('--no-print-results', action='store_true',
393 help='Don\'t 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
394 args = parser.parse_args(self.args)
395
396 self.reset_status()
397
398 runnable = filter(lambda t: not t.compile_only, tests)
399 compile_only = filter(lambda t: t.compile_only, tests)
400
401 for test in compile_only:

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

457 failed_diffs = filter(lambda d: not d.check(), diffs)
458 if failed_diffs:
459 tags = map(lambda d: d.tag, failed_diffs)
460 self.failed(test, 'failed diffs', ' '.join(tags))
461 continue
462
463 self.passed(test)
464
455 if args.print_results:
465 if not args.no_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
466 self.print_results()
467
468 self.print_status()
469
470 result_path = None
471 if args.result_file:
472 result_path = os.path.join(os.getcwd(), 'results.json')
473 elif args.result_file_at:

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

487
488parser.add_argument('--flavor', choices=['debug', 'opt', 'fast'],
489 default='opt',
490 help='Flavor of binary to test.')
491
492parser.add_argument('--list', action='store_true',
493 help='List the available tests')
494
495parser.add_argument('-j', type=int, default=1,
496 help='Default level of parallelism, can be overriden '
497 'for individual stages')
498
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 ---
499filter_opts = parser.add_mutually_exclusive_group()
500filter_opts.add_argument('--filter', default='True',
501 help='Python expression which filters tests based '
502 'on their properties')
503filter_opts.add_argument('--filter-file', default=None,
504 type=argparse.FileType('r'),
505 help='Same as --filter, but read from a file')
506

--- 63 unchanged lines hidden ---