diff --git a/eessi/testsuite/eessi_staging.py b/eessi/testsuite/eessi_staging.py new file mode 100644 index 00000000..9d2bcf9a --- /dev/null +++ b/eessi/testsuite/eessi_staging.py @@ -0,0 +1,34 @@ +from pathlib import Path + +import reframe as rfm +from reframe.utility import sanity as sn +from reframe.core.builtins import run_after, sanity_function + + +@rfm.simple_test +class EESSI_Staging(rfm.RunOnlyRegressionTest): + '''Stage input files''' + + valid_systems = ['*'] + valid_prog_environs = ['*'] + executable = "true" + local = True + + @run_after('init') + def remove_modules(self): + "Remove any modules that have been set on the cmd line: they are not needed for staging" + self.modules = [] + + @sanity_function + def check_stagedir(self): + "Check that all input files have been correctly copied to the stagedir" + ignore = {'rfm_job.sh', 'rfm_job.out', 'rfm_job.err'} + sourcepath = Path(self.sourcesdir) + sourcefiles = {x.relative_to(sourcepath).as_posix() for x in sourcepath.rglob('*')} + stagepath = Path(self.stagedir) + stagefiles = {x.relative_to(stagepath).as_posix() for x in stagepath.rglob('*')} - ignore + + return sn.assert_eq( + sourcefiles, stagefiles, + f'sourcesdir {self.sourcesdir} and stagedir {self.stagedir} do not have the same contents' + ) diff --git a/eessi/testsuite/tests/apps/cp2k/cp2k.py b/eessi/testsuite/tests/apps/cp2k/cp2k.py index f45525ec..ffbcc0cf 100644 --- a/eessi/testsuite/tests/apps/cp2k/cp2k.py +++ b/eessi/testsuite/tests/apps/cp2k/cp2k.py @@ -1,17 +1,20 @@ +import os + import reframe as rfm from reframe.core.builtins import parameter, run_after, performance_function, sanity_function, fixture import reframe.utility.sanity as sn from eessi.testsuite.constants import SCALES, COMPUTE_UNIT, DEVICE_TYPES, CPU from eessi.testsuite.eessi_mixin import EESSI_Mixin +from eessi.testsuite.eessi_staging import EESSI_Staging from eessi.testsuite.utils import find_modules -from eessi.testsuite.tests.apps.cp2k.cp2k_staging.cp2k_stage_input import EESSI_CP2K_stage_input @rfm.simple_test class EESSI_CP2K(rfm.RunOnlyRegressionTest, EESSI_Mixin): - stage_files = fixture(EESSI_CP2K_stage_input, scope='session') + srcdir = os.path.join(os.getcwd(), 'cp2k_staging', 'src') + stage_files = fixture(EESSI_Staging, scope='session', variables={'sourcesdir': srcdir}) benchmark_info = parameter([ # (bench_name, energy_ref, energy_tol) diff --git a/eessi/testsuite/tests/apps/cp2k/cp2k_staging/cp2k_stage_input.py b/eessi/testsuite/tests/apps/cp2k/cp2k_staging/cp2k_stage_input.py deleted file mode 100644 index 73bd4f12..00000000 --- a/eessi/testsuite/tests/apps/cp2k/cp2k_staging/cp2k_stage_input.py +++ /dev/null @@ -1,24 +0,0 @@ -import reframe as rfm -from reframe.utility import sanity as sn - - -@rfm.simple_test -class EESSI_CP2K_stage_input(rfm.RunOnlyRegressionTest): - '''Stage input files for CP2K''' - - valid_systems = ['*'] - valid_prog_environs = ['*'] - executable = "true" - local = True - - # Check that all files have been staged correctly - input_file_list = [ - 'QS/H2O-32.inp', - 'QS/H2O-128.inp', - 'QS/H2O-512.inp', - ] - sn_list = [sn.assert_found('.*', input_file) for input_file in input_file_list] - sanity_patterns = sn.all([ - sn.assert_found('.*', input_file, f"input file '{input_file}' seems to be missing") - for input_file in input_file_list - ])