tests: Refactor the Gem5Fixture to derive from UniqueFixture

Gem5Fixture is used to define a fixture for building the gem5
binary. Most tests are expected to define their own Gem5Fixture,
however, as some might depend on the same binary (e.g.,
./build/ARM/gem5.opt), they will try to re-define a fixture for the
same target. This patchset changes Gem5Fixture to derive from
UniqueFixture.

In addition, this patchset changes the way global fixtures are
discovered to work with the new Gem5Fixture class. Instead of
enumerating them when test definitions are loaded, we do so after the
tests have been filtered according to specified tags (e.g., include
opt variant, exclude fast, debug variants).

Change-Id: Ie868a7e18ef6c3271f3c8a658229657cd43997cb
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/19251
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Maintainer: Giacomo Travaglini <giacomo.travaglini@arm.com>
This commit is contained in:
Nikos Nikoleris
2019-06-18 11:50:24 +01:00
parent 5218914773
commit 8282b7408b
5 changed files with 51 additions and 121 deletions

View File

@@ -32,8 +32,6 @@ import traceback
import helper
import log
global_fixtures = []
class SkipException(Exception):
def __init__(self, fixture, testitem):
self.fixture = fixture
@@ -71,21 +69,11 @@ class Fixture(object):
if name is None:
name = self.__class__.__name__
self.name = name
self._is_global = False
def skip(self, testitem):
raise SkipException(self.name, testitem.metadata)
def schedule_finalized(self, schedule):
'''
This method is called once the schedule of for tests is known.
To enable tests to use the same fixture defintion for each execution
fixtures must return a copy of themselves in this method.
:returns: a copy of this fixture which will be setup/torndown
when the test item this object is tied to is about to execute.
'''
return self.copy()
def init(self, *args, **kwargs):
pass
@@ -95,9 +83,6 @@ class Fixture(object):
def teardown(self, testitem):
pass
def copy(self):
return copy.deepcopy(self)
def skip_cleanup(self):
'''
If this method is called, then we should make sure that nothing is
@@ -105,11 +90,8 @@ class Fixture(object):
'''
pass
def set_global(self):
self._is_global = True
def globalfixture(fixture):
'''
Store the given fixture as a global fixture. Its setup() method
will be called before the first test is executed.
'''
global_fixtures.append(fixture)
return fixture
def is_global(self):
return self._is_global