def read_trace(logname, root_dir, cwd_dir, product_dir): # Resolve any symlink root_dir = os.path.realpath(root_dir) api = trace_inputs.get_api() _, _, _, _, simplified = trace_inputs.load_trace(logname, root_dir, api) variables = trace_inputs.generate_dict(simplified, cwd_dir, product_dir) trace_inputs.pretty_print(variables, sys.stdout)
def trace_test_case(test_case, executable, root_dir, cwd_dir, product_dir, leak): """Traces a single test case and returns the .isolate compatible variable dict. """ # Resolve any symlink root_dir = os.path.realpath(root_dir) api = trace_inputs.get_api() cmd = [executable, '--gtest_filter=%s' % test_case] if not leak: f, logname = tempfile.mkstemp(prefix='trace') os.close(f) else: logname = '%s.%s.log' % (executable, test_case.replace('/', '-')) f = None try: simplified = None processes = 0 for i in range(10): start = time.time() returncode, output = trace_inputs.trace( logname, cmd, os.path.join(root_dir, cwd_dir), api, True) if returncode and i < 5: print '\nFailed while running: %s' % ' '.join(cmd) continue duration = time.time() - start try: results, simplified = trace_inputs.load_trace( logname, root_dir, api) break except Exception: print '\nFailed loading the trace for: %s' % ' '.join(cmd) if simplified: variables = trace_inputs.generate_dict(simplified, cwd_dir, product_dir) else: variables = {} return { 'case': test_case, 'duration': duration, 'output': output, 'processes': processes, 'result': returncode, 'variables': variables, 'results': results.flatten(), } finally: if f: os.remove(logname)
def trace_test_case( test_case, executable, root_dir, cwd_dir, product_dir, leak): """Traces a single test case and returns the .isolate compatible variable dict. """ # Resolve any symlink root_dir = os.path.realpath(root_dir) api = trace_inputs.get_api() cmd = [executable, '--gtest_filter=%s' % test_case] if not leak: f, logname = tempfile.mkstemp(prefix='trace') os.close(f) else: logname = '%s.%s.log' % (executable, test_case.replace('/', '-')) f = None try: simplified = None processes = 0 for i in range(10): start = time.time() returncode, output = trace_inputs.trace( logname, cmd, os.path.join(root_dir, cwd_dir), api, True) if returncode and i < 5: print '\nFailed while running: %s' % ' '.join(cmd) continue duration = time.time() - start try: results, simplified = trace_inputs.load_trace(logname, root_dir, api) break except Exception: print '\nFailed loading the trace for: %s' % ' '.join(cmd) if simplified: variables = trace_inputs.generate_dict(simplified, cwd_dir, product_dir) else: variables = {} return { 'case': test_case, 'duration': duration, 'output': output, 'processes': processes, 'result': returncode, 'variables': variables, 'results': results.flatten(), } finally: if f: os.remove(logname)