2017-04-20 06:14:53 +00:00
|
|
|
# Copyright 2017 the V8 project authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
import os
|
|
|
|
import difflib
|
|
|
|
|
|
|
|
from testrunner.local import testsuite
|
2017-12-20 15:57:58 +00:00
|
|
|
from testrunner.objects import outproc
|
2017-12-13 12:47:24 +00:00
|
|
|
from testrunner.objects import testcase
|
2017-04-20 06:14:53 +00:00
|
|
|
|
|
|
|
|
2017-12-11 20:25:41 +00:00
|
|
|
SHELL = 'mkgrokdump'
|
|
|
|
|
2017-12-13 12:47:24 +00:00
|
|
|
class TestSuite(testsuite.TestSuite):
|
2017-12-20 15:57:58 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(TestSuite, self).__init__(*args, **kwargs)
|
|
|
|
|
|
|
|
v8_path = os.path.dirname(os.path.dirname(os.path.abspath(self.root)))
|
|
|
|
expected_path = os.path.join(v8_path, 'tools', 'v8heapconst.py')
|
|
|
|
self.out_proc = OutProc(expected_path)
|
|
|
|
|
2017-04-20 06:14:53 +00:00
|
|
|
def ListTests(self, context):
|
2017-12-12 21:33:16 +00:00
|
|
|
test = self._create_test(SHELL)
|
2017-04-20 06:14:53 +00:00
|
|
|
return [test]
|
|
|
|
|
2017-12-12 21:33:16 +00:00
|
|
|
def _test_class(self):
|
2017-12-13 12:47:24 +00:00
|
|
|
return TestCase
|
2017-04-20 06:14:53 +00:00
|
|
|
|
2017-12-20 15:57:58 +00:00
|
|
|
|
|
|
|
class TestCase(testcase.TestCase):
|
|
|
|
def _get_variant_flags(self):
|
|
|
|
return []
|
|
|
|
|
|
|
|
def _get_statusfile_flags(self):
|
|
|
|
return []
|
|
|
|
|
|
|
|
def _get_mode_flags(self, ctx):
|
|
|
|
return []
|
|
|
|
|
|
|
|
def get_shell(self):
|
|
|
|
return SHELL
|
|
|
|
|
|
|
|
def get_output_proc(self):
|
|
|
|
return self.suite.out_proc
|
|
|
|
|
|
|
|
|
|
|
|
class OutProc(outproc.OutProc):
|
|
|
|
def __init__(self, expected_path):
|
|
|
|
self._expected_path = expected_path
|
|
|
|
|
|
|
|
def _is_failure_output(self, output):
|
|
|
|
with open(self._expected_path) as f:
|
2017-04-20 06:14:53 +00:00
|
|
|
expected = f.read()
|
|
|
|
expected_lines = expected.splitlines()
|
|
|
|
actual_lines = output.stdout.splitlines()
|
|
|
|
diff = difflib.unified_diff(expected_lines, actual_lines, lineterm="",
|
|
|
|
fromfile="expected_path")
|
|
|
|
diffstring = '\n'.join(diff)
|
|
|
|
if diffstring is not "":
|
|
|
|
if "generated from a non-shipping build" in output.stdout:
|
|
|
|
return False
|
|
|
|
if not "generated from a shipping build" in output.stdout:
|
|
|
|
output.stdout = "Unexpected output:\n\n" + output.stdout
|
|
|
|
return True
|
|
|
|
output.stdout = diffstring
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2017-12-20 15:57:58 +00:00
|
|
|
def _is_negative(self):
|
|
|
|
return False
|
2017-12-12 21:33:16 +00:00
|
|
|
|
|
|
|
|
2017-04-20 06:14:53 +00:00
|
|
|
def GetSuite(name, root):
|
2017-12-13 12:47:24 +00:00
|
|
|
return TestSuite(name, root)
|