from testlib.config import config, constants
from testlib.helper import log_call, cacheresult, joinpath, absdirpath
import testlib.log as log
+from testlib.state import Result
class VariableFixture(Fixture):
self.path = tempfile.mkdtemp(prefix='gem5out')
def teardown(self, testitem):
- if self.path is not None:
+ if testitem.result == Result.Passed:
shutil.rmtree(self.path)
- def skip_cleanup(self):
- # Set path to none so it's not deleted
- self.path = None
-
class UniqueFixture(Fixture):
'''
Base class for fixtures that generate a target in the
return test.TestFunction(self._test,
name=name, fixtures=self.fixtures)
- def failed(self, fixtures):
- '''
- Called if this verifier fails to cleanup (or not) as needed.
- '''
- try:
- fixtures[constants.tempdir_fixture_name].skip_cleanup()
- except KeyError:
- pass # No need to do anything if the tempdir fixture doesn't exist
-
-
class MatchGoldStandard(Verifier):
'''
Compares a standard output to the test output and passes if they match,
ignore_regexes=self.ignore_regex,
logger=params.log)
if diff is not None:
- self.failed(fixtures)
test.fail('Stdout did not match:\n%s\nSee %s for full results'
% (diff, tempdir))
if parse_file(joinpath(tempdir,
constants.gem5_simulation_stderr)):
return # Success
- self.failed(fixtures)
test.fail('Could not match regex.')
_re_type = type(re.compile(''))