Skip to content

Commit

Permalink
Stage input data using a fixture, so that it only happens once per se…
Browse files Browse the repository at this point in the history
…ssion
  • Loading branch information
Caspar van Leeuwen committed Nov 14, 2024
1 parent 62d84da commit c5b61ee
Show file tree
Hide file tree
Showing 6 changed files with 2,256 additions and 6 deletions.
17 changes: 11 additions & 6 deletions eessi/testsuite/tests/apps/cp2k/cp2k.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
from eessi.testsuite.constants import SCALES, COMPUTE_UNIT, DEVICE_TYPES, CPU
from eessi.testsuite.eessi_mixin import EESSI_Mixin
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')

benchmark_info = parameter([
# (bench_name, energy_ref, energy_tol)
('QS/H2O-32', -550.5055, 1e-4),
Expand All @@ -38,13 +40,16 @@ def required_mem_per_node(self):
return (self.num_tasks_per_node * mem['slope'] + mem['intercept']) * 1024

@run_after('init')
def prepare_test(self):
def set_bench_name(self):
self.bench_name, self.energy_ref, self.energy_tol = self.benchmark_info
self.descr = f'EESSI_CP2K {self.bench_name} benchmark'
self.prerun_cmds = [
f'cp {os.path.join(os.path.dirname(__file__), "input", self.bench_name)}.inp ./'
]
self.executable_opts += ['-i', f'{os.path.basename(self.bench_name)}.inp']

@run_after('setup')
def prepare_test(self):
# self.prerun_cmds = [
# f'cp {os.path.join(os.path.dirname(__file__), "input", self.bench_name)}.inp ./'
# ]
self.executable_opts += ['-i', f'{self.stage_files.stagedir}/input/QS/{os.path.basename(self.bench_name)}.inp']

@sanity_function
def assert_energy(self):
Expand Down
23 changes: 23 additions & 0 deletions eessi/testsuite/tests/apps/cp2k/cp2k_staging/cp2k_stage_input.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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 = [
'input/QS/H2O-32.inp',
'input/QS/H2O-128.inp',
'input/QS/H2O-512.inp'
]
sn_list = [sn.assert_found('.*', input_file) for input_file in input_file_list]
msg = "input file '%s' seems to be missing"
sanity_patterns = sn.all([
sn.assert_found('.*', input_file, msg % input_file) for input_file in input_file_list
])
Loading

0 comments on commit c5b61ee

Please sign in to comment.