Skip to content

Commit

Permalink
Merge pull request #205 from casparvl/stage_lammps_data_using_fixture
Browse files Browse the repository at this point in the history
Stage lammps and cp2k data using fixture
  • Loading branch information
smoors authored Nov 22, 2024
2 parents e2c2306 + 1a2bf9e commit eaa1d68
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 9 deletions.
17 changes: 9 additions & 8 deletions eessi/testsuite/tests/apps/cp2k/cp2k.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import os

import reframe as rfm
from reframe.core.builtins import parameter, run_after, performance_function, sanity_function
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.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 +39,13 @@ 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.executable_opts += ['-i', f'{self.stage_files.stagedir}/{self.bench_name}.inp']

@sanity_function
def assert_energy(self):
Expand Down
24 changes: 24 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,24 @@
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
])
13 changes: 12 additions & 1 deletion eessi/testsuite/tests/apps/lammps/lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from eessi.testsuite.constants import * # noqa
from eessi.testsuite.eessi_mixin import EESSI_Mixin

from eessi.testsuite.tests.apps.lammps.lammps_staging.lammps_stage_input import EESSI_LAMMPS_stage_input


class EESSI_LAMMPS_base(rfm.RunOnlyRegressionTest, EESSI_Mixin):
time_limit = '30m'
Expand Down Expand Up @@ -125,9 +127,18 @@ def set_executable_opts(self):
@rfm.simple_test
class EESSI_LAMMPS_rhodo(EESSI_LAMMPS_base):
sourcesdir = 'src/rhodo'
readonly_files = ["data.rhodo"]
executable = 'lmp -in in.rhodo'

stage_input = fixture(EESSI_LAMMPS_stage_input, scope='session')

@run_after('setup')
def symlink_lammps_data(self):
'''Create a symlink to the data.rhodo file staged by the EESSI_LAMMPS_stage_input fixture.
Lammps needs this in the current working directory'''
self.prerun_cmds = [
f'ln -s {self.stage_input.stagedir}/rhodo/data.rhodo data.rhodo'
]

@deferrable
def check_number_neighbors(self):
'''Assert that the test calulated the right number of neighbours'''
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import reframe as rfm
from reframe.utility import sanity as sn


@rfm.simple_test
class EESSI_LAMMPS_stage_input(rfm.RunOnlyRegressionTest):
'''Stage input files for LAMMPS'''

valid_systems = ['*']
valid_prog_environs = ['*']
executable = "true"
local = True

# Check that all files have been staged correctly
sanity_patterns = sn.assert_found('.*', 'rhodo/data.rhodo', "input file 'data.rhodo' seems to be missing")

0 comments on commit eaa1d68

Please sign in to comment.