diff --git a/eessi/testsuite/eessi_mixin.py b/eessi/testsuite/eessi_mixin.py new file mode 100644 index 00000000..259fcc65 --- /dev/null +++ b/eessi/testsuite/eessi_mixin.py @@ -0,0 +1,35 @@ +from reframe.core.pipeline import RegressionMixin +from reframe.core.exceptions import ReframeSyntaxError + +from eessi.testsuite import hooks + +class EESSI_Mixin(RegressionMixin): + """ + All EESSI tests should derive from this mixin class unless they have a very good reason not to. + """ + + # We have to make sure that these gets set in any test that inherits + # device_type = variable(str) + # scale = variable(str) + # module_name = variable(str) + + @run_after('init') + def validate(self): + """Check that all variables that have to be set for subsequent hooks in the init phase have been set""" + if not hasattr(self, 'device_type'): + raise ReframeSyntaxError("device_type should be defined in any class that inherits from EESSI_Mixin, but wasn't") + + + @run_after('init') + def run_after_init(self): + """Hooks to run after init phase""" + + # Filter on which scales are supported by the partitions defined in the ReFrame configuration + hooks.filter_supported_scales(self) + + hooks.filter_valid_systems_by_device_type(self, required_device_type=self.device_type) + + hooks.set_modules(self) + + # Set scales as tags + hooks.set_tag_scale(self) diff --git a/eessi/testsuite/tests/apps/lammps/lammps.py b/eessi/testsuite/tests/apps/lammps/lammps.py index b071d787..b92e03b8 100644 --- a/eessi/testsuite/tests/apps/lammps/lammps.py +++ b/eessi/testsuite/tests/apps/lammps/lammps.py @@ -8,9 +8,9 @@ from eessi.testsuite import hooks, utils from eessi.testsuite.constants import * # noqa +from eessi.testsuite.eessi_mixin import EESSI_Mixin - -class EESSI_LAMMPS_base(rfm.RunOnlyRegressionTest): +class EESSI_LAMMPS_base(rfm.RunOnlyRegressionTest, EESSI_Mixin): scale = parameter(SCALES.keys()) valid_prog_environs = ['default'] valid_systems = ['*'] @@ -47,19 +47,19 @@ def assert_run(self): return sn.assert_eq(n_atoms, 32000) - @run_after('init') - def run_after_init(self): - """hooks to run after init phase""" - - # Filter on which scales are supported by the partitions defined in the ReFrame configuration - hooks.filter_supported_scales(self) - - hooks.filter_valid_systems_by_device_type(self, required_device_type=self.device_type) - - hooks.set_modules(self) - - # Set scales as tags - hooks.set_tag_scale(self) +# @run_after('init') +# def run_after_init(self): +# """hooks to run after init phase""" +# +# # Filter on which scales are supported by the partitions defined in the ReFrame configuration +# hooks.filter_supported_scales(self) +# +# hooks.filter_valid_systems_by_device_type(self, required_device_type=self.device_type) +# +# hooks.set_modules(self) +# +# # Set scales as tags +# hooks.set_tag_scale(self) @run_after('setup') def run_after_setup(self):