2018-01-12 10:07:56 +00:00
|
|
|
# Copyright 2018 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.
|
|
|
|
|
|
|
|
from . import base
|
2018-01-15 09:35:02 +00:00
|
|
|
from ..local.variants import ALL_VARIANTS, ALL_VARIANT_FLAGS
|
2018-01-15 08:03:48 +00:00
|
|
|
from .result import GroupedResult
|
2018-01-12 10:07:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
STANDARD_VARIANT = set(["default"])
|
|
|
|
|
|
|
|
|
|
|
|
class VariantProc(base.TestProcProducer):
|
|
|
|
"""Processor creating variants.
|
|
|
|
|
|
|
|
For each test it keeps generator that returns variant, flags and id suffix.
|
|
|
|
It produces variants one at a time, so it's waiting for the result of one
|
|
|
|
variant to create another variant of the same test.
|
|
|
|
It maintains the order of the variants passed to the init.
|
|
|
|
|
|
|
|
There are some cases when particular variant of the test is not valid. To
|
|
|
|
ignore subtests like that, StatusFileFilterProc should be placed somewhere
|
|
|
|
after the VariantProc.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, variants):
|
|
|
|
super(VariantProc, self).__init__('VariantProc')
|
2018-01-17 10:59:24 +00:00
|
|
|
self._next_variant = {}
|
2018-01-12 10:07:56 +00:00
|
|
|
self._variant_gens = {}
|
|
|
|
self._variants = variants
|
|
|
|
|
2018-01-17 10:59:24 +00:00
|
|
|
def setup(self, requirement=base.DROP_RESULT):
|
|
|
|
super(VariantProc, self).setup(requirement)
|
|
|
|
|
|
|
|
# VariantProc is optimized for dropping the result and it should be placed
|
|
|
|
# in the chain where it's possible.
|
|
|
|
assert requirement == base.DROP_RESULT
|
|
|
|
|
2018-01-12 10:07:56 +00:00
|
|
|
def _next_test(self, test):
|
2018-01-17 10:59:24 +00:00
|
|
|
gen = self._variants_gen(test)
|
|
|
|
self._next_variant[test.procid] = gen
|
2019-01-30 12:20:17 +00:00
|
|
|
return self._try_send_new_subtest(test, gen)
|
2018-01-12 10:07:56 +00:00
|
|
|
|
2018-01-15 08:03:48 +00:00
|
|
|
def _result_for(self, test, subtest, result):
|
2018-01-17 10:59:24 +00:00
|
|
|
gen = self._next_variant[test.procid]
|
2019-01-30 12:20:17 +00:00
|
|
|
if not self._try_send_new_subtest(test, gen):
|
|
|
|
self._send_result(test, None)
|
2018-01-12 10:07:56 +00:00
|
|
|
|
2018-01-17 10:59:24 +00:00
|
|
|
def _try_send_new_subtest(self, test, variants_gen):
|
2018-01-15 08:03:48 +00:00
|
|
|
for variant, flags, suffix in variants_gen:
|
2018-01-12 10:07:56 +00:00
|
|
|
subtest = self._create_subtest(test, '%s-%s' % (variant, suffix),
|
|
|
|
variant=variant, flags=flags)
|
2019-01-30 12:20:17 +00:00
|
|
|
if self._send_test(subtest):
|
|
|
|
return True
|
2018-01-12 10:07:56 +00:00
|
|
|
|
2018-01-17 10:59:24 +00:00
|
|
|
del self._next_variant[test.procid]
|
2019-01-30 12:20:17 +00:00
|
|
|
return False
|
2018-01-12 10:07:56 +00:00
|
|
|
|
|
|
|
def _variants_gen(self, test):
|
|
|
|
"""Generator producing (variant, flags, procid suffix) tuples."""
|
|
|
|
return self._get_variants_gen(test).gen(test)
|
|
|
|
|
|
|
|
def _get_variants_gen(self, test):
|
|
|
|
key = test.suite.name
|
|
|
|
variants_gen = self._variant_gens.get(key)
|
|
|
|
if not variants_gen:
|
|
|
|
variants_gen = test.suite.get_variants_gen(self._variants)
|
|
|
|
self._variant_gens[key] = variants_gen
|
|
|
|
return variants_gen
|