Commit af192c89 authored by Michal Majewski's avatar Michal Majewski Committed by Commit Bot

[test] Remove output from testcase.

Bug: v8:6917
Cq-Include-Trybots: master.tryserver.v8:v8_linux_noi18n_rel_ng
Change-Id: I5ca840db75766413659cb96fd28b922712040cec
Reviewed-on: https://chromium-review.googlesource.com/823843
Commit-Queue: Michał Majewski <majeski@google.com>
Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Reviewed-by: 's avatarSergiy Byelozyorov <sergiyb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50078}
parent 5760d76e
...@@ -47,7 +47,7 @@ class TestSuite(testsuite.TestSuite): ...@@ -47,7 +47,7 @@ class TestSuite(testsuite.TestSuite):
string == "Warning: unknown flag --enable-slow-asserts." or string == "Warning: unknown flag --enable-slow-asserts." or
string == "Try --help for options") string == "Try --help for options")
def IsFailureOutput(self, test): def IsFailureOutput(self, test, output):
file_name = os.path.join(self.root, test.path) + EXPECTED_SUFFIX file_name = os.path.join(self.root, test.path) + EXPECTED_SUFFIX
with file(file_name, "r") as expected: with file(file_name, "r") as expected:
expected_lines = expected.readlines() expected_lines = expected.readlines()
...@@ -66,7 +66,7 @@ class TestSuite(testsuite.TestSuite): ...@@ -66,7 +66,7 @@ class TestSuite(testsuite.TestSuite):
def ActBlockIterator(): def ActBlockIterator():
"""Iterates over blocks of actual output lines.""" """Iterates over blocks of actual output lines."""
lines = test.output.stdout.splitlines() lines = output.stdout.splitlines()
start_index = 0 start_index = 0
found_eqeq = False found_eqeq = False
for index, line in enumerate(lines): for index, line in enumerate(lines):
......
...@@ -81,11 +81,10 @@ class TestSuite(testsuite.TestSuite): ...@@ -81,11 +81,10 @@ class TestSuite(testsuite.TestSuite):
path = head path = head
return False return False
def IsFailureOutput(self, test): def IsFailureOutput(self, test, output):
output = test.output
testpath = test.path testpath = test.path
expected_fail = self._GetExpectedFail(test) expected_fail = self._GetExpectedFail(test)
fail = test.output.exit_code != 0 fail = output.exit_code != 0
if expected_fail != fail: if expected_fail != fail:
return True return True
expected_path = os.path.join(self.root, testpath + ".out") expected_path = os.path.join(self.root, testpath + ".out")
......
...@@ -19,8 +19,7 @@ class TestSuite(testsuite.TestSuite): ...@@ -19,8 +19,7 @@ class TestSuite(testsuite.TestSuite):
def _test_class(self): def _test_class(self):
return TestCase return TestCase
def IsFailureOutput(self, test): def IsFailureOutput(self, test, output):
output = test.output
v8_path = os.path.dirname(os.path.dirname(os.path.abspath(self.root))) v8_path = os.path.dirname(os.path.dirname(os.path.abspath(self.root)))
expected_path = os.path.join(v8_path, "tools", "v8heapconst.py") expected_path = os.path.join(v8_path, "tools", "v8heapconst.py")
with open(expected_path) as f: with open(expected_path) as f:
......
...@@ -86,10 +86,10 @@ class TestSuite(testsuite.TestSuite): ...@@ -86,10 +86,10 @@ class TestSuite(testsuite.TestSuite):
def IsNegativeTest(self, test): def IsNegativeTest(self, test):
return test.path.endswith("-n") return test.path.endswith("-n")
def IsFailureOutput(self, test): def IsFailureOutput(self, test, output):
if test.output.exit_code != 0: if output.exit_code != 0:
return True return True
return "FAILED!" in test.output.stdout return "FAILED!" in output.stdout
class TestCase(testcase.TestCase): class TestCase(testcase.TestCase):
......
...@@ -190,8 +190,7 @@ class TestSuite(testsuite.TestSuite): ...@@ -190,8 +190,7 @@ class TestSuite(testsuite.TestSuite):
def _test_class(self): def _test_class(self):
return TestCase return TestCase
def IsFailureOutput(self, test): def IsFailureOutput(self, test, output):
output = test.output
test_record = test.test_record test_record = test.test_record
if output.exit_code != 0: if output.exit_code != 0:
return True return True
......
...@@ -73,8 +73,8 @@ class TestSuite(testsuite.TestSuite): ...@@ -73,8 +73,8 @@ class TestSuite(testsuite.TestSuite):
string == "Warning: unknown flag --enable-slow-asserts." or string == "Warning: unknown flag --enable-slow-asserts." or
string == "Try --help for options") string == "Try --help for options")
def IsFailureOutput(self, test): def IsFailureOutput(self, test, output):
if super(TestSuite, self).IsFailureOutput(test): if super(TestSuite, self).IsFailureOutput(test, output):
return True return True
file_name = os.path.join(self.root, test.path) + "-expected.txt" file_name = os.path.join(self.root, test.path) + "-expected.txt"
with file(file_name, "r") as expected: with file(file_name, "r") as expected:
...@@ -94,7 +94,7 @@ class TestSuite(testsuite.TestSuite): ...@@ -94,7 +94,7 @@ class TestSuite(testsuite.TestSuite):
def ActBlockIterator(): def ActBlockIterator():
"""Iterates over blocks of actual output lines.""" """Iterates over blocks of actual output lines."""
lines = test.output.stdout.splitlines() lines = output.stdout.splitlines()
start_index = 0 start_index = 0
found_eqeq = False found_eqeq = False
for index, line in enumerate(lines): for index, line in enumerate(lines):
......
...@@ -332,7 +332,7 @@ class DeoptFuzzer(base_runner.BaseTestRunner): ...@@ -332,7 +332,7 @@ class DeoptFuzzer(base_runner.BaseTestRunner):
for s in suites: for s in suites:
test_results = {} test_results = {}
for t in s.tests: for t in s.tests:
for line in t.output.stdout.splitlines(): for line in runner.outputs[t].stdout.splitlines():
if line.startswith("=== Stress deopt counter: "): if line.startswith("=== Stress deopt counter: "):
test_results[t.path] = MAX_DEOPT - int(line.split(" ")[-1]) test_results[t.path] = MAX_DEOPT - int(line.split(" ")[-1])
for t in s.tests: for t in s.tests:
......
...@@ -213,13 +213,15 @@ class GCFuzzer(base_runner.BaseTestRunner): ...@@ -213,13 +213,15 @@ class GCFuzzer(base_runner.BaseTestRunner):
for s in suites: for s in suites:
for t in s.tests: for t in s.tests:
# Skip failed tests. # Skip failed tests.
if s.HasUnexpectedOutput(t): if s.HasUnexpectedOutput(t, runner.outputs[t]):
print '%s failed, skipping' % t.path print '%s failed, skipping' % t.path
continue continue
max_limit = self._get_max_limit_reached(t) max_limit = self._get_max_limit_reached(runner.outputs[t])
if max_limit: if max_limit:
test_results[t.path] = max_limit test_results[t.path] = max_limit
runner = None
if options.dump_results_file: if options.dump_results_file:
with file("%s.%d.txt" % (options.dump_results_file, time.time()), with file("%s.%d.txt" % (options.dump_results_file, time.time()),
"w") as f: "w") as f:
...@@ -308,7 +310,7 @@ class GCFuzzer(base_runner.BaseTestRunner): ...@@ -308,7 +310,7 @@ class GCFuzzer(base_runner.BaseTestRunner):
# incremental marking limit (0-100). # incremental marking limit (0-100).
# Skips values >=100% since they already trigger incremental marking. # Skips values >=100% since they already trigger incremental marking.
@staticmethod @staticmethod
def _get_max_limit_reached(test): def _get_max_limit_reached(output):
def is_im_line(l): def is_im_line(l):
return 'IncrementalMarking' in l and '% of the memory limit reached' in l return 'IncrementalMarking' in l and '% of the memory limit reached' in l
...@@ -318,10 +320,10 @@ class GCFuzzer(base_runner.BaseTestRunner): ...@@ -318,10 +320,10 @@ class GCFuzzer(base_runner.BaseTestRunner):
def percent_str_to_float(s): def percent_str_to_float(s):
return float(s[:-1]) return float(s[:-1])
if not (test.output and test.output.stdout): if not (output and output.stdout):
return None return None
im_lines = filter(is_im_line, test.output.stdout.splitlines()) im_lines = filter(is_im_line, output.stdout.splitlines())
percents_str = map(line_to_percent, im_lines) percents_str = map(line_to_percent, im_lines)
percents = map(percent_str_to_float, percents_str) percents = map(percent_str_to_float, percents_str)
......
...@@ -37,7 +37,6 @@ from . import command ...@@ -37,7 +37,6 @@ from . import command
from . import perfdata from . import perfdata
from . import statusfile from . import statusfile
from . import utils from . import utils
from ..objects import output
from pool import Pool from pool import Pool
...@@ -119,6 +118,10 @@ class Runner(object): ...@@ -119,6 +118,10 @@ class Runner(object):
self.perf_failures = False self.perf_failures = False
self.printed_allocations = False self.printed_allocations = False
self.tests = [t for s in suites for t in s.tests] self.tests = [t for s in suites for t in s.tests]
# TODO(majeski): Pass outputs dynamically instead of keeping them in the
# runner.
self.outputs = {t: None for t in self.tests}
self.suite_names = [s.name for s in suites] self.suite_names = [s.name for s in suites]
# Always pre-sort by status file, slowest tests first. # Always pre-sort by status file, slowest tests first.
...@@ -174,19 +177,20 @@ class Runner(object): ...@@ -174,19 +177,20 @@ class Runner(object):
# Rerun this test. # Rerun this test.
test.duration = None test.duration = None
test.output = None
test.run += 1 test.run += 1
pool.add([TestJob(test.id, test.cmd, test.run)]) pool.add([TestJob(test.id, test.cmd, test.run)])
self.remaining += 1 self.remaining += 1
self.total += 1 self.total += 1
def _ProcessTest(self, test, result, pool): def _ProcessTest(self, test, result, pool):
test.output = result[1] output = result[1]
self.outputs[test] = output
test.duration = result[2] test.duration = result[2]
has_unexpected_output = test.suite.HasUnexpectedOutput(test, self.context) has_unexpected_output = test.suite.HasUnexpectedOutput(
test, output, self.context)
if has_unexpected_output: if has_unexpected_output:
self.failed.append(test) self.failed.append(test)
if test.output.HasCrashed(): if output.HasCrashed():
self.crashed += 1 self.crashed += 1
else: else:
self.succeeded += 1 self.succeeded += 1
...@@ -194,7 +198,7 @@ class Runner(object): ...@@ -194,7 +198,7 @@ class Runner(object):
# For the indicator, everything that happens after the first run is treated # For the indicator, everything that happens after the first run is treated
# as unexpected even if it flakily passes in order to include it in the # as unexpected even if it flakily passes in order to include it in the
# output. # output.
self.indicator.HasRun(test, has_unexpected_output or test.run > 1) self.indicator.HasRun(test, output, has_unexpected_output or test.run > 1)
if has_unexpected_output: if has_unexpected_output:
# Rerun test failures after the indicator has processed the results. # Rerun test failures after the indicator has processed the results.
self._VerbosePrint("Attempting to rerun test after failure.") self._VerbosePrint("Attempting to rerun test after failure.")
......
...@@ -50,7 +50,7 @@ class ProgressIndicator(object): ...@@ -50,7 +50,7 @@ class ProgressIndicator(object):
def Done(self): def Done(self):
pass pass
def HasRun(self, test, has_unexpected_output): def HasRun(self, test, output, has_unexpected_output):
pass pass
def Heartbeat(self): def Heartbeat(self):
...@@ -100,18 +100,19 @@ class SimpleProgressIndicator(ProgressIndicator): ...@@ -100,18 +100,19 @@ class SimpleProgressIndicator(ProgressIndicator):
def Done(self): def Done(self):
print print
for failed in self.runner.failed: for failed in self.runner.failed:
output = self.runner.outputs[failed]
self.PrintFailureHeader(failed) self.PrintFailureHeader(failed)
if failed.output.stderr: if output.stderr:
print "--- stderr ---" print "--- stderr ---"
print failed.output.stderr.strip() print output.stderr.strip()
if failed.output.stdout: if output.stdout:
print "--- stdout ---" print "--- stdout ---"
print failed.output.stdout.strip() print output.stdout.strip()
print "Command: %s" % failed.cmd.to_string() print "Command: %s" % failed.cmd.to_string()
if failed.output.HasCrashed(): if output.HasCrashed():
print "exit code: %d" % failed.output.exit_code print "exit code: %d" % output.exit_code
print "--- CRASHED ---" print "--- CRASHED ---"
if failed.output.HasTimedOut(): if output.HasTimedOut():
print "--- TIMEOUT ---" print "--- TIMEOUT ---"
if len(self.runner.failed) == 0: if len(self.runner.failed) == 0:
print "===" print "==="
...@@ -128,9 +129,9 @@ class SimpleProgressIndicator(ProgressIndicator): ...@@ -128,9 +129,9 @@ class SimpleProgressIndicator(ProgressIndicator):
class VerboseProgressIndicator(SimpleProgressIndicator): class VerboseProgressIndicator(SimpleProgressIndicator):
def HasRun(self, test, has_unexpected_output): def HasRun(self, test, output, has_unexpected_output):
if has_unexpected_output: if has_unexpected_output:
if test.output.HasCrashed(): if output.HasCrashed():
outcome = 'CRASH' outcome = 'CRASH'
else: else:
outcome = 'FAIL' outcome = 'FAIL'
...@@ -146,15 +147,15 @@ class VerboseProgressIndicator(SimpleProgressIndicator): ...@@ -146,15 +147,15 @@ class VerboseProgressIndicator(SimpleProgressIndicator):
class DotsProgressIndicator(SimpleProgressIndicator): class DotsProgressIndicator(SimpleProgressIndicator):
def HasRun(self, test, has_unexpected_output): def HasRun(self, test, output, has_unexpected_output):
total = self.runner.succeeded + len(self.runner.failed) total = self.runner.succeeded + len(self.runner.failed)
if (total > 1) and (total % 50 == 1): if (total > 1) and (total % 50 == 1):
sys.stdout.write('\n') sys.stdout.write('\n')
if has_unexpected_output: if has_unexpected_output:
if test.output.HasCrashed(): if output.HasCrashed():
sys.stdout.write('C') sys.stdout.write('C')
sys.stdout.flush() sys.stdout.flush()
elif test.output.HasTimedOut(): elif output.HasTimedOut():
sys.stdout.write('T') sys.stdout.write('T')
sys.stdout.flush() sys.stdout.flush()
else: else:
...@@ -178,22 +179,22 @@ class CompactProgressIndicator(ProgressIndicator): ...@@ -178,22 +179,22 @@ class CompactProgressIndicator(ProgressIndicator):
self.PrintProgress('Done') self.PrintProgress('Done')
print "" # Line break. print "" # Line break.
def HasRun(self, test, has_unexpected_output): def HasRun(self, test, output, has_unexpected_output):
self.PrintProgress(str(test)) self.PrintProgress(str(test))
if has_unexpected_output: if has_unexpected_output:
self.ClearLine(self.last_status_length) self.ClearLine(self.last_status_length)
self.PrintFailureHeader(test) self.PrintFailureHeader(test)
stdout = test.output.stdout.strip() stdout = output.stdout.strip()
if len(stdout): if len(stdout):
print self.templates['stdout'] % stdout print self.templates['stdout'] % stdout
stderr = test.output.stderr.strip() stderr = output.stderr.strip()
if len(stderr): if len(stderr):
print self.templates['stderr'] % stderr print self.templates['stderr'] % stderr
print "Command: %s" % test.cmd.to_string() print "Command: %s" % test.cmd.to_string()
if test.output.HasCrashed(): if output.HasCrashed():
print "exit code: %d" % test.output.exit_code print "exit code: %d" % output.exit_code
print "--- CRASHED ---" print "--- CRASHED ---"
if test.output.HasTimedOut(): if output.HasTimedOut():
print "--- TIMEOUT ---" print "--- TIMEOUT ---"
def Truncate(self, string, length): def Truncate(self, string, length):
...@@ -269,19 +270,19 @@ class JUnitTestProgressIndicator(ProgressIndicator): ...@@ -269,19 +270,19 @@ class JUnitTestProgressIndicator(ProgressIndicator):
if self.outfile != sys.stdout: if self.outfile != sys.stdout:
self.outfile.close() self.outfile.close()
def HasRun(self, test, has_unexpected_output): def HasRun(self, test, output, has_unexpected_output):
fail_text = "" fail_text = ""
if has_unexpected_output: if has_unexpected_output:
stdout = test.output.stdout.strip() stdout = output.stdout.strip()
if len(stdout): if len(stdout):
fail_text += "stdout:\n%s\n" % stdout fail_text += "stdout:\n%s\n" % stdout
stderr = test.output.stderr.strip() stderr = output.stderr.strip()
if len(stderr): if len(stderr):
fail_text += "stderr:\n%s\n" % stderr fail_text += "stderr:\n%s\n" % stderr
fail_text += "Command: %s" % self.test.cmd.to_string() fail_text += "Command: %s" % self.test.cmd.to_string()
if test.output.HasCrashed(): if output.HasCrashed():
fail_text += "exit code: %d\n--- CRASHED ---" % test.output.exit_code fail_text += "exit code: %d\n--- CRASHED ---" % output.exit_code
if test.output.HasTimedOut(): if output.HasTimedOut():
fail_text += "--- TIMEOUT ---" fail_text += "--- TIMEOUT ---"
self.outputter.HasRunTest( self.outputter.HasRunTest(
test_name=str(test), test_name=str(test),
...@@ -340,7 +341,7 @@ class JsonTestProgressIndicator(ProgressIndicator): ...@@ -340,7 +341,7 @@ class JsonTestProgressIndicator(ProgressIndicator):
with open(self.json_test_results, "w") as f: with open(self.json_test_results, "w") as f:
f.write(json.dumps(complete_results)) f.write(json.dumps(complete_results))
def HasRun(self, test, has_unexpected_output): def HasRun(self, test, output, has_unexpected_output):
# Buffer all tests for sorting the durations in the end. # Buffer all tests for sorting the durations in the end.
self.tests.append(test) self.tests.append(test)
if not has_unexpected_output: if not has_unexpected_output:
...@@ -353,9 +354,9 @@ class JsonTestProgressIndicator(ProgressIndicator): ...@@ -353,9 +354,9 @@ class JsonTestProgressIndicator(ProgressIndicator):
"flags": test.cmd.args, "flags": test.cmd.args,
"command": test.cmd.to_string(relative=True), "command": test.cmd.to_string(relative=True),
"run": test.run, "run": test.run,
"stdout": test.output.stdout, "stdout": output.stdout,
"stderr": test.output.stderr, "stderr": output.stderr,
"exit_code": test.output.exit_code, "exit_code": output.exit_code,
"result": test.suite.GetOutcome(test), "result": test.suite.GetOutcome(test),
"expected": test.suite.GetExpectedOutcomes(test), "expected": test.suite.GetExpectedOutcomes(test),
"duration": test.duration, "duration": test.duration,
...@@ -393,7 +394,7 @@ class FlakinessTestProgressIndicator(ProgressIndicator): ...@@ -393,7 +394,7 @@ class FlakinessTestProgressIndicator(ProgressIndicator):
"version": 3, "version": 3,
}, f) }, f)
def HasRun(self, test, has_unexpected_output): def HasRun(self, test, output, has_unexpected_output):
key = test.get_id() key = test.get_id()
outcome = test.suite.GetOutcome(test) outcome = test.suite.GetOutcome(test)
assert outcome in ["PASS", "FAIL", "CRASH", "TIMEOUT"] assert outcome in ["PASS", "FAIL", "CRASH", "TIMEOUT"]
......
...@@ -276,36 +276,36 @@ class TestSuite(object): ...@@ -276,36 +276,36 @@ class TestSuite(object):
return self._outcomes_cache[cache_key] return self._outcomes_cache[cache_key]
def IsFailureOutput(self, testcase): def IsFailureOutput(self, testcase, output):
return testcase.output.exit_code != 0 return output.exit_code != 0
def IsNegativeTest(self, testcase): def IsNegativeTest(self, testcase):
return False return False
def HasFailed(self, testcase, ctx=None): def HasFailed(self, testcase, output, ctx=None):
if ctx and ctx.predictable: if ctx and ctx.predictable:
# Only check the exit code of the predictable_wrapper in # Only check the exit code of the predictable_wrapper in
# verify-predictable mode. # verify-predictable mode.
execution_failed = testcase.output.exit_code != 0 execution_failed = output.exit_code != 0
else: else:
execution_failed = self.IsFailureOutput(testcase) execution_failed = self.IsFailureOutput(testcase, output)
if self.IsNegativeTest(testcase): if self.IsNegativeTest(testcase):
return not execution_failed return not execution_failed
else: else:
return execution_failed return execution_failed
def GetOutcome(self, testcase, ctx=None): def GetOutcome(self, testcase, output, ctx=None):
if testcase.output.HasCrashed(): if output.HasCrashed():
return statusfile.CRASH return statusfile.CRASH
elif testcase.output.HasTimedOut(): elif output.HasTimedOut():
return statusfile.TIMEOUT return statusfile.TIMEOUT
elif self.HasFailed(testcase, ctx): elif self.HasFailed(testcase, output, ctx):
return statusfile.FAIL return statusfile.FAIL
else: else:
return statusfile.PASS return statusfile.PASS
def HasUnexpectedOutput(self, testcase, ctx=None): def HasUnexpectedOutput(self, testcase, output, ctx=None):
return (self.GetOutcome(testcase, ctx) return (self.GetOutcome(testcase, output, ctx)
not in self.GetExpectedOutcomes(testcase)) not in self.GetExpectedOutcomes(testcase))
def _create_test(self, path, **kwargs): def _create_test(self, path, **kwargs):
......
...@@ -45,7 +45,6 @@ class TestCase(object): ...@@ -45,7 +45,6 @@ class TestCase(object):
self.variant = None # name of the used testing variant self.variant = None # name of the used testing variant
self.variant_flags = [] # list of strings, flags specific to this test self.variant_flags = [] # list of strings, flags specific to this test
self.output = None
self.id = None # int, used to map result back to TestCase instance self.id = None # int, used to map result back to TestCase instance
self.duration = None # assigned during execution self.duration = None # assigned during execution
self.run = 1 # The nth time this test is executed. self.run = 1 # The nth time this test is executed.
...@@ -198,6 +197,9 @@ class TestCase(object): ...@@ -198,6 +197,9 @@ class TestCase(object):
(other.suite.name, other.name, other.variant_flags) (other.suite.name, other.name, other.variant_flags)
) )
def __hash__(self):
return hash((self.suite.name, self.name, ''.join(self.variant_flags)))
def __str__(self): def __str__(self):
return self.suite.name + '/' + self.name return self.suite.name + '/' + self.name
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment