2017-12-11 20:24:21 +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
|
|
|
|
|
|
|
|
from testrunner.local import command
|
|
|
|
from testrunner.local import utils
|
2017-12-13 12:47:24 +00:00
|
|
|
from testrunner.local import testsuite
|
|
|
|
from testrunner.objects import testcase
|
2017-12-11 20:24:21 +00:00
|
|
|
|
|
|
|
|
2022-11-25 12:13:14 +00:00
|
|
|
ADDITIONAL_VARIANTS = set(["minor_mc"])
|
|
|
|
|
|
|
|
|
2018-01-22 19:16:58 +00:00
|
|
|
class VariantsGenerator(testsuite.VariantsGenerator):
|
2022-11-25 12:13:14 +00:00
|
|
|
|
|
|
|
def __init__(self, variants):
|
|
|
|
super().__init__(variants)
|
|
|
|
self._supported_variants = self._standard_variant + [
|
|
|
|
v for v in variants if v in ADDITIONAL_VARIANTS
|
|
|
|
]
|
|
|
|
|
2018-01-22 19:16:58 +00:00
|
|
|
def _get_variants(self, test):
|
2022-11-25 12:13:14 +00:00
|
|
|
if test.only_standard_variant:
|
|
|
|
return self._standard_variant
|
|
|
|
return self._supported_variants
|
2018-01-22 19:16:58 +00:00
|
|
|
|
|
|
|
|
2019-02-05 14:00:49 +00:00
|
|
|
class TestLoader(testsuite.TestLoader):
|
|
|
|
def _list_test_filenames(self):
|
|
|
|
shell = os.path.abspath(
|
|
|
|
os.path.join(self.test_config.shell_dir, "unittests"))
|
2017-12-11 20:24:21 +00:00
|
|
|
if utils.IsWindows():
|
|
|
|
shell += ".exe"
|
|
|
|
|
|
|
|
output = None
|
2019-02-24 18:17:25 +00:00
|
|
|
for i in range(3): # Try 3 times in case of errors.
|
2022-07-18 09:05:55 +00:00
|
|
|
cmd = self.ctx.command(
|
|
|
|
cmd_prefix=self.test_config.command_prefix,
|
|
|
|
shell=shell,
|
|
|
|
args=['--gtest_list_tests'] + self.test_config.extra_flags)
|
2017-12-11 20:24:21 +00:00
|
|
|
output = cmd.execute()
|
|
|
|
if output.exit_code == 0:
|
|
|
|
break
|
2019-02-05 14:00:49 +00:00
|
|
|
|
2019-02-24 18:17:25 +00:00
|
|
|
print("Test executable failed to list the tests (try %d).\n\nCmd:" % i)
|
|
|
|
print(cmd)
|
|
|
|
print("\nStdout:")
|
|
|
|
print(output.stdout)
|
|
|
|
print("\nStderr:")
|
|
|
|
print(output.stderr)
|
|
|
|
print("\nExit code: %d" % output.exit_code)
|
2017-12-11 20:24:21 +00:00
|
|
|
else:
|
|
|
|
raise Exception("Test executable failed to list the tests.")
|
|
|
|
|
2019-02-05 14:00:49 +00:00
|
|
|
# TODO create an ExecutableTestLoader for refactoring this similar to
|
|
|
|
# JSTestLoader.
|
|
|
|
test_names = []
|
2020-06-05 11:37:03 +00:00
|
|
|
test_case = ''
|
2017-12-11 20:24:21 +00:00
|
|
|
for line in output.stdout.splitlines():
|
|
|
|
test_desc = line.strip().split()[0]
|
|
|
|
if test_desc.endswith('.'):
|
|
|
|
test_case = test_desc
|
|
|
|
elif test_case and test_desc:
|
2019-02-05 14:00:49 +00:00
|
|
|
test_names.append(test_case + test_desc)
|
|
|
|
|
2019-02-06 12:17:05 +00:00
|
|
|
return sorted(test_names)
|
2019-02-05 14:00:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestSuite(testsuite.TestSuite):
|
|
|
|
def _test_loader_class(self):
|
|
|
|
return TestLoader
|
2017-12-11 20:24:21 +00:00
|
|
|
|
2017-12-12 21:33:16 +00:00
|
|
|
def _test_class(self):
|
2017-12-13 12:47:24 +00:00
|
|
|
return TestCase
|
2017-12-11 20:24:21 +00:00
|
|
|
|
2018-01-22 19:16:58 +00:00
|
|
|
def _variants_gen_class(self):
|
|
|
|
return VariantsGenerator
|
|
|
|
|
2017-12-12 21:33:16 +00:00
|
|
|
|
2017-12-13 12:47:24 +00:00
|
|
|
class TestCase(testcase.TestCase):
|
2018-01-31 12:01:49 +00:00
|
|
|
def _get_suite_flags(self):
|
2017-12-12 21:33:16 +00:00
|
|
|
return (
|
|
|
|
["--gtest_filter=" + self.path] +
|
2018-01-31 09:18:13 +00:00
|
|
|
["--gtest_random_seed=%s" % self.random_seed] +
|
2017-12-12 21:33:16 +00:00
|
|
|
["--gtest_print_time=0"]
|
|
|
|
)
|
|
|
|
|
2017-12-19 14:48:08 +00:00
|
|
|
def get_shell(self):
|
2017-12-12 21:33:16 +00:00
|
|
|
return self.suite.name
|
2017-12-11 20:24:21 +00:00
|
|
|
|
2022-06-10 12:20:35 +00:00
|
|
|
def _get_resources(self):
|
|
|
|
# Bytecode-generator tests are the only ones requiring extra files on
|
|
|
|
# Android.
|
|
|
|
parts = self.name.split('.')
|
|
|
|
if parts[0] == 'BytecodeGeneratorTest':
|
|
|
|
expectation_file = os.path.join(self.suite.root, 'interpreter',
|
|
|
|
'bytecode_expectations',
|
|
|
|
'%s.golden' % parts[1])
|
|
|
|
if os.path.exists(expectation_file):
|
|
|
|
return [expectation_file]
|
|
|
|
return []
|