From: Jason Lowe-Power Date: Fri, 5 Apr 2019 02:02:16 +0000 (-0700) Subject: tests: Add protocol as an option to SconsFixture X-Git-Tag: v19.0.0.0~968 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=10f946cd28417cd648fb7b80a4266d93fadee695;p=gem5.git tests: Add protocol as an option to SconsFixture Change-Id: I16e9a6169e7ad50601e460e221d6a05db1208783 Signed-off-by: Jason Lowe-Power Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17872 Reviewed-by: Anthony Gutierrez Reviewed-by: Nikos Nikoleris --- diff --git a/tests/gem5/fixture.py b/tests/gem5/fixture.py index 97aab46f5..00f43ef6a 100644 --- a/tests/gem5/fixture.py +++ b/tests/gem5/fixture.py @@ -69,11 +69,12 @@ class SConsFixture(Fixture): :param directory: The directory which scons will -C (cd) into before executing. If None is provided, will choose the config base_dir. ''' - def __init__(self, directory=None, target_class=None): + def __init__(self, directory=None, target_class=None, options=[]): self.directory = directory if directory else config.base_dir self.target_class = target_class if target_class else SConsTarget self.threads = config.threads self.targets = set() + self.options = options super(SConsFixture, self).__init__() def setup(self, testitem): @@ -101,9 +102,9 @@ class SConsFixture(Fixture): "You may want to run with only a single ISA" "(--isa=), use --skip-build, or use 'rerun'.") - - command.extend(self.targets) + if self.options: + command.extend(self.options) log_call(log.test_log, command) @@ -143,9 +144,27 @@ class SConsTarget(Fixture): return Fixture.schedule_finalized(self, schedule) class Gem5Fixture(SConsTarget): - def __init__(self, isa, variant): - target = joinpath(isa.upper(), 'gem5.%s' % variant) - super(Gem5Fixture, self).__init__(target) + other_invocations = {} # stores scons invocations other than the default + + def __init__(self, isa, variant, protocol=None): + if protocol: + # When specifying an non-default protocol, we have to make a + # separate scons invocation with specific parameters. However, if + # more than one tests needs the same target, we need to make sure + # that we don't call scons too many times. + target_dir = isa.upper()+'-'+protocol + target = joinpath(target_dir, 'gem5.%s' % variant) + if target_dir in self.other_invocations.keys(): + invocation = self.other_invocations[target_dir] + else: + options = ['PROTOCOL='+protocol, '--default='+isa.upper()] + invocation = SConsFixture(options=options) + globalfixture(invocation) + Gem5Fixture.other_invocations[target_dir] = invocation + else: + target = joinpath(isa.upper(), 'gem5.%s' % variant) + invocation = None # use default + super(Gem5Fixture, self).__init__(target, invocation=invocation) self.name = constants.gem5_binary_fixture_name self.path = self.target diff --git a/tests/gem5/suite.py b/tests/gem5/suite.py index 47cf421e1..2db1668cd 100644 --- a/tests/gem5/suite.py +++ b/tests/gem5/suite.py @@ -45,7 +45,8 @@ def gem5_verify_config(name, fixtures=[], valid_isas=constants.supported_isas, valid_variants=constants.supported_variants, - length=constants.supported_lengths[0]): + length=constants.supported_lengths[0], + protocol=None): ''' Helper class to generate common gem5 tests using verifiers. @@ -86,6 +87,8 @@ def gem5_verify_config(name, given_name=name, isa=isa, opt=opt) + if protocol: + _name += '-'+protocol # Create the running of gem5 subtest. # NOTE: We specifically create this test before our verifiers so @@ -107,7 +110,7 @@ def gem5_verify_config(name, # Create the gem5 target for the specific architecture and # variant. _fixtures = copy.copy(fixtures) - _fixtures.append(Gem5Fixture(isa, opt)) + _fixtures.append(Gem5Fixture(isa, opt, protocol)) _fixtures.append(tempdir) _fixtures.append(gem5_returncode)