def main(): """CLI frontend to validate arguments.""" parser = run_test_cases.OptionParserTestCases( usage='%prog <options> [gtest]', description=sys.modules['__main__'].__doc__) parser.format_description = lambda *_: parser.description parser.add_option( '-o', '--out', help='output file, defaults to <executable>.test_cases') options, args = parser.parse_args() if not args: parser.error( 'Please provide the executable line to run, if you need fancy things ' 'like xvfb, start this script from *inside* xvfb, it\'ll be much faster' '.') cmd = run_test_cases.fix_python_path(args) if not options.out: options.out = '%s.test_cases' % cmd[-1] test_cases = parser.process_gtest_options(cmd, options) # Then run them. return trace_test_cases( cmd, os.getcwd(), test_cases, options.jobs, # TODO(maruel): options.timeout, options.out)
def map(self, test_case): """Traces a single test case and returns its output.""" cmd = [self.executable, '--gtest_filter=%s' % test_case] cmd = run_test_cases.fix_python_path(cmd) tracename = test_case.replace('/', '-') out = [] for retry in range(5): start = time.time() returncode, output = self.tracer.trace( cmd, self.cwd_dir, tracename, True) duration = time.time() - start # TODO(maruel): Define a way to detect if an strace log is valid. valid = True out.append( { 'test_case': test_case, 'returncode': returncode, 'duration': duration, 'valid': valid, 'output': output, }) logging.debug( 'Tracing %s done: %d, %.1fs' % (test_case, returncode, duration)) if retry: self.progress.update_item( '%s - %d' % (test_case, retry), True, not valid) else: self.progress.update_item(test_case, True, not valid) if valid: break return out
def main(): """CLI frontend to validate arguments.""" run_test_cases.run_isolated.disable_buffering() parser = run_test_cases.OptionParserWithTestShardingAndFiltering( usage='%prog <options> [gtest]') options, args = parser.parse_args() if not args: parser.error('Please provide the executable to run') cmd = run_test_cases.fix_python_path(args) try: tests = run_test_cases.list_test_cases( cmd, os.getcwd(), index=options.index, shards=options.shards, disabled=options.disabled, fails=options.fails, flaky=options.flaky, pre=False, manual=options.manual, seed=0) for test in tests: print test except run_test_cases.Failure, e: print e.args[0] return e.args[1]
def main(): """CLI frontend to validate arguments.""" parser = run_test_cases.OptionParserWithTestSharding( usage='%prog <options> [gtest]') parser.add_option( '-d', '--disabled', action='store_true', help='Include DISABLED_ tests') parser.add_option( '-f', '--fails', action='store_true', help='Include FAILS_ tests') parser.add_option( '-F', '--flaky', action='store_true', help='Include FLAKY_ tests') options, args = parser.parse_args() if not args: parser.error('Please provide the executable to run') cmd = run_test_cases.fix_python_path(args) try: tests = run_test_cases.list_test_cases( cmd, options.index, options.shards, options.disabled, options.fails, options.flaky) for test in tests: print test except run_test_cases.Failure, e: print e.args[0] return e.args[1]
def main(): """CLI frontend to validate arguments.""" parser = run_test_cases.OptionParserTestCases( usage='%prog <options> [gtest]') parser.format_description = lambda *_: parser.description parser.add_option( '-o', '--out', help='output file, defaults to <executable>.test_cases') parser.add_option( '-r', '--root-dir', help='Root directory under which file access should be noted') # TODO(maruel): Add support for options.timeout. parser.remove_option('--timeout') options, args = parser.parse_args() if not args: parser.error( 'Please provide the executable line to run, if you need fancy things ' 'like xvfb, start this script from *inside* xvfb, it\'ll be much faster' '.') cmd = run_test_cases.fix_python_path(args) cmd[0] = os.path.abspath(cmd[0]) if not os.path.isfile(cmd[0]): parser.error('Tracing failed for: %s\nIt doesn\'t exit' % ' '.join(cmd)) if not options.out: options.out = '%s.test_cases' % cmd[-1] options.out = os.path.abspath(options.out) if options.root_dir: options.root_dir = os.path.abspath(options.root_dir) logname = options.out + '.log' def blacklist(f): return any(re.match(b, f) for b in options.blacklist) test_cases = parser.process_gtest_options(cmd, os.getcwd(), options) # Then run them. print('Tracing...') results = trace_test_cases( cmd, os.getcwd(), test_cases, options.jobs, logname) print('Reading trace logs...') write_details(logname, options.out, options.root_dir, blacklist, results) return 0
def main(): """CLI frontend to validate arguments.""" run_test_cases.run_isolated.disable_buffering() parser = run_test_cases.OptionParserTestCases( usage='%prog <options> [gtest]') parser.format_description = lambda *_: parser.description parser.add_option('-o', '--out', help='output file, defaults to <executable>.test_cases') parser.add_option( '-r', '--root-dir', help='Root directory under which file access should be noted') # TODO(maruel): Add support for options.timeout. parser.remove_option('--timeout') options, args = parser.parse_args() if not args: parser.error( 'Please provide the executable line to run, if you need fancy things ' 'like xvfb, start this script from *inside* xvfb, it\'ll be much faster' '.') cmd = run_test_cases.fix_python_path(args) cmd[0] = os.path.abspath(cmd[0]) if not os.path.isfile(cmd[0]): parser.error('Tracing failed for: %s\nIt doesn\'t exit' % ' '.join(cmd)) if not options.out: options.out = '%s.test_cases' % cmd[-1] options.out = os.path.abspath(options.out) if options.root_dir: options.root_dir = os.path.abspath(options.root_dir) logname = options.out + '.log' def blacklist(f): return any(re.match(b, f) for b in options.blacklist) test_cases = parser.process_gtest_options(cmd, os.getcwd(), options) # Then run them. print('Tracing...') results = trace_test_cases(cmd, os.getcwd(), test_cases, options.jobs, logname) print('Reading trace logs...') write_details(logname, options.out, options.root_dir, blacklist, results) return 0
def safely_load_isolated(parser, options): """Loads a .isolated.state to extract the executable information. Returns the CompleteState instance, the command and the list of test cases. """ config = isolate.CompleteState.load_files(options.isolated) logging.debug('root_dir: %s relative_cwd: %s isolated: %s', config.root_dir, config.saved_state.relative_cwd, options.isolated) reldir = os.path.join(config.root_dir, config.saved_state.relative_cwd) command = config.saved_state.command test_cases = [] if command: command = run_test_cases.fix_python_path(command) test_xvfb(command, reldir) test_cases = parser.process_gtest_options(command, reldir, options) return config, command, test_cases
def safely_load_isolated(parser, options): """Loads a .isolated.state to extract the executable information. Returns the CompleteState instance, the command and the list of test cases. """ config = isolate.CompleteState.load_files(options.isolated) logging.debug( 'root_dir: %s relative_cwd: %s isolated: %s', config.root_dir, config.saved_state.relative_cwd, options.isolated) reldir = os.path.join(config.root_dir, config.saved_state.relative_cwd) command = config.saved_state.command test_cases = [] if command: command = run_test_cases.fix_python_path(command) test_xvfb(command, reldir) test_cases = parser.process_gtest_options(command, reldir, options) return config, command, test_cases
def expect( executable, cwd, test_cases, jobs, timeout, retries, run_all, max_failures, no_cr, gtest_output, result_file, verbose): self.assertEqual(run_test_cases.fix_python_path([exe]), executable) self.assertEqual(os.getcwd(), cwd) # They are in reverse order due to test shuffling. self.assertEqual(['Foo.Bar1', 'Foo.Bar/3'], test_cases) self.assertEqual(run_test_cases.num_processors(), jobs) self.assertEqual(120, timeout) self.assertEqual(2, retries) self.assertEqual(None, run_all) self.assertEqual(None, no_cr) self.assertEqual('', gtest_output) self.assertEqual(None, max_failures) self.assertEqual(exe + '.run_test_cases', result_file) self.assertFalse(verbose) return 89
def expect(executable, cwd, test_cases, jobs, timeout, clusters, retries, run_all, max_failures, no_cr, gtest_output, result_file, verbose): self.assertEqual(run_test_cases.fix_python_path([exe]), executable) self.assertEqual(os.getcwd(), cwd) # They are in reverse order due to test shuffling. self.assertEqual(['Foo.Bar1', 'Foo.Bar/3'], test_cases) self.assertEqual(run_test_cases.num_processors(), jobs) self.assertEqual(75, timeout) self.assertEqual(None, clusters) self.assertEqual(2, retries) self.assertEqual(None, run_all) self.assertEqual(None, no_cr) self.assertEqual('', gtest_output) self.assertEqual(None, max_failures) self.assertEqual(exe + '.run_test_cases', result_file) self.assertFalse(verbose) return 89
def test_xvfb(command, rel_dir): """Calls back ourself if not running inside Xvfb and it's on the command line to run. Otherwise the X session will die while trying to start too many Xvfb instances. """ if os.environ.get('_CHROMIUM_INSIDE_XVFB') == '1': return for index, item in enumerate(command): if item.endswith('xvfb.py'): # Note this has inside knowledge about src/testing/xvfb.py. print('Restarting itself under Xvfb') prefix = command[index:index + 2] prefix[0] = os.path.normpath(os.path.join(rel_dir, prefix[0])) prefix[1] = os.path.normpath(os.path.join(rel_dir, prefix[1])) cmd = run_test_cases.fix_python_path(prefix + sys.argv) sys.exit(subprocess.call(cmd))
def test_xvfb(command, rel_dir): """Calls back ourself if not running inside Xvfb and it's on the command line to run. Otherwise the X session will die while trying to start too many Xvfb instances. """ if os.environ.get('_CHROMIUM_INSIDE_XVFB') == '1': return for index, item in enumerate(command): if item.endswith('xvfb.py'): # Note this has inside knowledge about src/testing/xvfb.py. print('Restarting itself under Xvfb') prefix = command[index:index+2] prefix[0] = os.path.normpath(os.path.join(rel_dir, prefix[0])) prefix[1] = os.path.normpath(os.path.join(rel_dir, prefix[1])) cmd = run_test_cases.fix_python_path(prefix + sys.argv) sys.exit(subprocess.call(cmd))
def main(): """CLI frontend to validate arguments.""" run_test_cases.run_isolated.disable_buffering() parser = run_test_cases.OptionParserTestCases(usage="%prog <options> [gtest]") parser.format_description = lambda *_: parser.description parser.add_option("-o", "--out", help="output file, defaults to <executable>.test_cases") parser.add_option("-r", "--root-dir", help="Root directory under which file access should be noted") # TODO(maruel): Add support for options.timeout. parser.remove_option("--timeout") options, args = parser.parse_args() if not args: parser.error( "Please provide the executable line to run, if you need fancy things " "like xvfb, start this script from *inside* xvfb, it'll be much faster" "." ) cmd = run_test_cases.fix_python_path(args) cmd[0] = os.path.abspath(cmd[0]) if not os.path.isfile(cmd[0]): parser.error("Tracing failed for: %s\nIt doesn't exit" % " ".join(cmd)) if not options.out: options.out = "%s.test_cases" % cmd[-1] options.out = os.path.abspath(options.out) if options.root_dir: options.root_dir = os.path.abspath(options.root_dir) logname = options.out + ".log" def blacklist(f): return any(re.match(b, f) for b in options.blacklist) test_cases = parser.process_gtest_options(cmd, os.getcwd(), options) # Then run them. print("Tracing...") results = trace_test_cases(cmd, os.getcwd(), test_cases, options.jobs, logname) print("Reading trace logs...") write_details(logname, options.out, options.root_dir, blacklist, results) return 0
def main(): """CLI frontend to validate arguments.""" parser = run_test_cases.OptionParserTestCases( usage='%prog <options> --isolated <.isolated>') parser.format_description = lambda *_: parser.description isolate.add_variable_option(parser) # TODO(maruel): Add support for options.timeout. parser.remove_option('--timeout') options, args = parser.parse_args() if args: parser.error('Unsupported arg: %s' % args) isolate.parse_variable_option(parser, options, True) try: config = isolate.CompleteState.load_files(options.isolated) reldir = os.path.join(config.root_dir, config.isolated.relative_cwd) command = run_test_cases.fix_python_path(config.isolated.command) test_xvfb(command, reldir) test_cases = parser.process_gtest_options(command, reldir, options) if not test_cases: print >> sys.stderr, 'No test case to run' return 1 config.saved_state.variables.update(options.variables) return isolate_test_cases( command, test_cases, options.jobs, config.isolated_filepath, config.saved_state.isolate_file, config.root_dir, config.isolated.relative_cwd, config.saved_state.variables) except isolate.ExecutionError, e: print >> sys.stderr, str(e) return 1