summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Lowe-Power <jason@lowepower.com>2019-04-04 19:02:16 -0700
committerJason Lowe-Power <jason@lowepower.com>2019-04-12 15:31:55 +0000
commit10f946cd28417cd648fb7b80a4266d93fadee695 (patch)
tree6ca4815ade50dc60701ec4ae2cf4991bc39676c5
parent6b81e087c239e74a84405805bc8a3f6f3c1798a4 (diff)
downloadgem5-10f946cd28417cd648fb7b80a4266d93fadee695.tar.xz
tests: Add protocol as an option to SconsFixture
Change-Id: I16e9a6169e7ad50601e460e221d6a05db1208783 Signed-off-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17872 Reviewed-by: Anthony Gutierrez <anthony.gutierrez@amd.com> Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
-rw-r--r--tests/gem5/fixture.py31
-rw-r--r--tests/gem5/suite.py7
2 files changed, 30 insertions, 8 deletions
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)