diff --git a/cscs-checks/apps/openfoam-extend/check_openfoam_extend.py b/cscs-checks/apps/openfoam-extend/check_openfoam_extend.py deleted file mode 100644 index 2d2565b948..0000000000 --- a/cscs-checks/apps/openfoam-extend/check_openfoam_extend.py +++ /dev/null @@ -1,211 +0,0 @@ -import os - -import reframe.utility.sanity as sn -from reframe.core.pipeline import RunOnlyRegressionTest - - -class OpenfoamExtendBaseTest(RunOnlyRegressionTest): - def __init__(self, check_name, check_descr, **kwargs): - super().__init__('OpenfoamExtend_%s' % (check_name), - os.path.dirname(__file__), **kwargs) - - self.descr = check_descr - self.executable = check_name - self.sourcesdir = os.path.join(self.current_system.resourcesdir, - 'OpenFOAM-Extend', check_name) - - # OpenFOAM-Extend currently runs only on Leone - self.valid_systems = ['leone:normal'] - self.valid_prog_environs = ['PrgEnv-gnu'] - self.modules = ['OpenFOAM-Extend/4.0-foss-2016b'] - - self.num_tasks = 1 - self.num_tasks_per_node = 1 - self.num_cpus_per_task = 1 - - self.sanity_patterns = sn.assert_found(r'^\s*[Ee]nd', self.stdout) - - if self.num_tasks > 1: - self.sanity_patterns = sn.assert_found( - r'Finalising parallel run', self.stdout) - - self.maintainers = ['MaKra'] - self.tags = {'scs', 'production'} - - self.pre_run = ['source $FOAM_INST_DIR/foam-extend-4.0/etc/bashrc'] - - -class BlockMesh(OpenfoamExtendBaseTest): - def __init__(self, **kwargs): - super().__init__('blockMesh', - 'OpenFOAM-Extend blockMesh from ' - 'the dambreak tutorial', - **kwargs) - - -class SnappyHexMesh(OpenfoamExtendBaseTest): - def __init__(self, **kwargs): - super().__init__( - 'snappyHexMesh', - 'OpenFOAM-Extend check of snappyHexMesh: motorbike tutorial', - **kwargs) - - -class SimpleFoam(OpenfoamExtendBaseTest): - def __init__(self, **kwargs): - super().__init__( - 'simpleFoam', - 'OpenFOAM-Extend check of simpleFoam: motorbike tutorial', - **kwargs) - - self.executable_opts = ['-parallel'] - self.num_tasks = 6 - self.num_tasks_per_node = 6 - - result = sn.extractall( - r'time step continuity errors : ' - r'\S+\s\S+ = \S+\sglobal = (?P-?\S+),', - self.stdout, 'res', float) - self.sanity_patterns = sn.all( - sn.map(lambda x: sn.assert_lt(abs(x), 5.e-04), result)) - - -class SetFields(OpenfoamExtendBaseTest): - def __init__(self, **kwargs): - super().__init__( - 'setFields', - 'OpenFOA-Extend check of setFields: dambreak tutorial', - **kwargs) - - -class InterMixingFoam(OpenfoamExtendBaseTest): - def __init__(self, **kwargs): - super().__init__( - 'interMixingFoam', - 'OpenFOA-Extend check of interMixingFoam: dambreak tutorial', - **kwargs) - - self.sanity_patterns = sn.assert_eq(sn.count(sn.findall( - r'Air phase volume fraction', self.stdout)), 2944) - - -class BuoyantBoussinesqSimpleFoam(OpenfoamExtendBaseTest): - def __init__(self, **kwargs): - super().__init__( - 'buoyantBoussinesqSimpleFoam', - 'OpenFOAM-Extend check buoyantBoussinesqSimpleFoam: hotRoom test', - **kwargs) - - self.executable = 'buoyantBoussinesqSimpleFoam' - - result = sn.extractall( - r'\sglobal\s=\s(?P\S+),', - self.stdout, 'res', float) - self.sanity_patterns = sn.all( - sn.map(lambda x: sn.assert_lt(abs(x), 1.e-17), result)) - - -class LaplacianFoam(OpenfoamExtendBaseTest): - def __init__(self, **kwargs): - super().__init__('laplacianFoam', - 'OpenFOAM-Extend check of setFields: flange tutorial', - **kwargs) - - -class FoamToEnsight(OpenfoamExtendBaseTest): - def __init__(self, **kwargs): - super().__init__('foamToEnsight', - 'OpenFOAM-Extend check of setFields: flange tutorial', - **kwargs) - - -class SetSet(OpenfoamExtendBaseTest): - def __init__(self, **kwargs): - super().__init__( - 'setSet', - 'OpenFOAM-Extend check of setFields: multi region heater tutorial', - **kwargs) - - self.executable_opts = ['-batch makeCellSets.setSet'] - - -class SetsToZones(OpenfoamExtendBaseTest): - def __init__(self, **kwargs): - super().__init__( - 'setsToZones', - 'OpenFOAM-Extend check of setFields: multi region heater tutorial', - **kwargs) - - self.executable_opts = ['-noFlipMap'] - - -class SplitMeshRegions(OpenfoamExtendBaseTest): - def __init__(self, **kwargs): - super().__init__( - 'splitMeshRegions', - 'OpenFOAM-Extend check of setFields: multi region heater tutorial', - **kwargs) - - self.executable_opts = ['-cellZones', '-overwrite'] - - -class DecomposePar(OpenfoamExtendBaseTest): - def __init__(self, **kwargs): - super().__init__( - 'decomposePar', - 'OpenFOAM-Extend check of reconstructPar: multiRegionHeater test', - **kwargs) - - self.executable_opts = ['-region heater'] - - -class ChtMultiRegionSimpleFoam(OpenfoamExtendBaseTest): - def __init__(self, **kwargs): - super().__init__( - 'chtMultiRegionSimpleFoam', - 'OpenFOAM-Extend check of reconstructPar: multiRegionHeater test', - **kwargs) - - self.executable_opts = ['-parallel'] - self.num_tasks = 4 - self.num_tasks_per_node = 4 - - result = sn.extractall( - r'\sglobal\s=\s(?P-?\S+),', - self.stdout, 'res', float)[-5:] - self.sanity_patterns = sn.all( - sn.map(lambda x: sn.assert_lt(abs(x), 1.e-04), result)) - - -class ReconstructPar(OpenfoamExtendBaseTest): - def __init__(self, **kwargs): - super().__init__( - 'reconstructPar', - 'OpenFOAM-Extend check of reconstructPar: multiRegionHeater test', - **kwargs) - - self.executable_opts = ['-latestTime', '-region heater'] - self.readonly_files = ['processor0', - 'processor1', - 'processor2', - 'processor3'] - - self.sanity_patterns = sn.assert_found(r'Time = 1000', self.stdout) - - -def _get_checks(**kwargs): - return [ - BlockMesh(**kwargs), - SnappyHexMesh(**kwargs), - SimpleFoam(**kwargs), - SetFields(**kwargs), - InterMixingFoam(**kwargs), - BuoyantBoussinesqSimpleFoam(**kwargs), - LaplacianFoam(**kwargs), - FoamToEnsight(**kwargs), - SetSet(**kwargs), - SetsToZones(**kwargs), - SplitMeshRegions(**kwargs), - DecomposePar(**kwargs), - ChtMultiRegionSimpleFoam(**kwargs), - ReconstructPar(**kwargs)] diff --git a/cscs-checks/apps/openfoam/check_openfoam.py b/cscs-checks/apps/openfoam/check_openfoam.py index 26355c23f9..ade32256d7 100644 --- a/cscs-checks/apps/openfoam/check_openfoam.py +++ b/cscs-checks/apps/openfoam/check_openfoam.py @@ -1,18 +1,16 @@ import os +import reframe as rfm import reframe.utility.sanity as sn -from reframe.core.pipeline import RunOnlyRegressionTest -class OpenFOAMBaseTest(RunOnlyRegressionTest): - def __init__(self, check_name, check_descr, **kwargs): - super().__init__('Openfoam_%s' % (check_name), - os.path.dirname(__file__), **kwargs) - - self.descr = check_descr - self.executable = check_name +class OpenFOAMBaseTest(rfm.RunOnlyRegressionTest): + def __init__(self): + dirname = self.name[0].lower() + self.name[1:] + self.name = 'OpenFoam_' + self.name + self.executable = dirname self.sourcesdir = os.path.join(self.current_system.resourcesdir, - 'OpenFOAM', check_name) + 'OpenFOAM', dirname) # OpenFOAM currently runs only on Leone self.valid_systems = ['leone:normal'] @@ -23,28 +21,26 @@ def __init__(self, check_name, check_descr, **kwargs): self.num_tasks_per_node = 1 self.num_cpus_per_task = 1 - self.maintainers = ['MaKra'] + self.maintainers = ['MKr'] self.tags = {'scs', 'production'} self.pre_run = ['source $FOAM_BASH'] +@rfm.simple_test class BlockMesh(OpenFOAMBaseTest): - def __init__(self, **kwargs): - super().__init__('blockMesh', - 'OpenFOAM blockMesh from the dambreak tutorial', - **kwargs) - + def __init__(self): + super().__init__() + self.descr = 'OpenFOAM blockMesh from the dambreak tutorial' self.sanity_patterns = sn.assert_found(r'^\s*[Ee]nd', self.stdout) +@rfm.simple_test class BuoyantBoussinesqSimpleFoam(OpenFOAMBaseTest): - def __init__(self, **kwargs): - super().__init__( - 'buoyantBoussinesqSimpleFoam', - 'OpenFOAM check of buoyantBoussinesqSimpleFoam: hotroom tutorial', - **kwargs) - + def __init__(self): + super().__init__() + self.descr = ('OpenFOAM check of buoyantBoussinesqSimpleFoam: ' + 'hotroom tutorial') self.executable = 'buoyantBoussinesqSimpleFoam' residual = sn.extractall(r'\sglobal\s=\s(?P\S+),', self.stdout, 'res', float) @@ -53,35 +49,30 @@ def __init__(self, **kwargs): [sn.assert_found(r'^\s*[Ee]nd', self.stdout)])) +@rfm.simple_test class CheckMesh(OpenFOAMBaseTest): - def __init__(self, **kwargs): - super().__init__('checkMesh', - 'OpenFOAM check of checkMesh: flange tutorial', - **kwargs) - + def __init__(self): + super().__init__() + self.descr = 'OpenFOAM check of checkMesh: flange tutorial' self.executable_opts = ['-latestTime', '-allTopology', '-allGeometry', '-parallel'] self.num_tasks = 8 self.num_tasks_per_node = 8 - self.sanity_patterns = sn.all([ sn.assert_found('Finalising parallel run', self.stdout), sn.assert_found(r'^\s*[Ee]nd', self.stdout) ]) +@rfm.simple_test class ChtMultiRegionSimpleFoam(OpenFOAMBaseTest): - def __init__(self, **kwargs): - super().__init__( - 'chtMultiRegionSimpleFoam', - 'OpenFOAM check of chtMultiRegionSimpleFoam:' - ' heatexchanger tutorial', - **kwargs) - + def __init__(self): + super().__init__() + self.descr = ('OpenFOAM check of chtMultiRegionSimpleFoam:' + ' heatexchanger tutorial') self.executable_opts = ['-parallel'] self.num_tasks = 4 self.num_tasks_per_node = 4 - residual = sn.extractall(r'\sglobal\s=\s(?P\S+),', self.stdout, 'res', float)[-10:] self.sanity_patterns = sn.all(sn.chain( @@ -91,97 +82,83 @@ def __init__(self, **kwargs): sn.assert_found(r'^\s*[Ee]nd', self.stdout)])) +@rfm.simple_test class CollapseEdges(OpenFOAMBaseTest): - def __init__(self, **kwargs): - super().__init__('collapseEdges', - 'OpenFOAM check of collapseEdges: flange tutorial', - **kwargs) - + def __init__(self): + super().__init__() + self.descr = 'OpenFOAM check of collapseEdges: flange tutorial' self.executable_opts = ['-latestTime', '-collapseFaces', '-parallel'] self.num_tasks = 8 self.num_tasks_per_node = 8 - self.sanity_patterns = sn.all( [sn.assert_found('Finalising parallel run', self.stdout), sn.assert_found(r'^\s*[Ee]nd', self.stdout)]) +@rfm.simple_test class CreateBaffles(OpenFOAMBaseTest): - def __init__(self, **kwargs): - super().__init__( - 'createBaffles', - 'OpenFOAM check of createBaffles: heatexchanger tutorial', - **kwargs) - + def __init__(self): + super().__init__() + self.descr = 'OpenFOAM check of createBaffles: heatexchanger tutorial' self.executable_opts = ['-region air', '-overwrite'] - self.sanity_patterns = sn.assert_found(r'^\s*[Ee]nd', self.stdout) +@rfm.simple_test class DecomposePar(OpenFOAMBaseTest): - def __init__(self, **kwargs): - super().__init__( - 'decomposePar', - 'OpenFOAM check of decomposePar: heatexchanger tutorial', - **kwargs) - + def __init__(self): + super().__init__() + self.descr = 'OpenFOAM check of decomposePar: heatexchanger tutorial' self.executable_opts = ['-region air'] - self.sanity_patterns = sn.assert_found(r'^\s*[Ee]nd', self.stdout) +@rfm.simple_test class FoamyHexMesh(OpenFOAMBaseTest): - def __init__(self, **kwargs): - super().__init__('foamyHexMesh', - 'OpenFOAM check of foamyHexMesh: motorbike tutorial', - **kwargs) - + def __init__(self): + super().__init__() + self.descr = 'OpenFOAM check of foamyHexMesh: motorbike tutorial' self.executable_opts = ['-parallel'] self.num_tasks = 8 self.num_tasks_per_node = 8 - self.sanity_patterns = sn.all( [sn.assert_found('Time = 100\n', self.stdout), sn.assert_found('Finalising parallel run', self.stdout), sn.assert_found(r'^\s*[Ee]nd', self.stdout)]) +@rfm.simple_test class InterMixingFoam(OpenFOAMBaseTest): - def __init__(self, **kwargs): - super().__init__('interMixingFoam', - 'OpenFOAM check of interMixingFoam:' - 'dambreak tutorial', - **kwargs) - - self.sanity_patterns = sn.all( - [sn.assert_eq( + def __init__(self): + super().__init__() + self.descr = 'OpenFOAM check of interMixingFoam: dambreak tutorial' + self.sanity_patterns = sn.all([ + sn.assert_eq( sn.count(sn.findall('(?PAir phase volume fraction)', self.stdout)), 2534), - sn.assert_found(r'^\s*[Ee]nd', self.stdout)]) + sn.assert_found(r'^\s*[Ee]nd', self.stdout) + ]) +@rfm.simple_test class PatchSummary(OpenFOAMBaseTest): - def __init__(self, **kwargs): - super().__init__( - 'patchSummary', - 'OpenFOAM check of patchSummary: motorbike tutorial', - **kwargs) - + def __init__(self): + super().__init__() + self.descr = 'OpenFOAM check of patchSummary: motorbike tutorial' self.executable_opts = ['-parallel'] self.num_tasks = 6 self.num_tasks_per_node = 6 - - self.sanity_patterns = sn.all( - [sn.assert_found('Finalising parallel run', self.stdout), - sn.assert_found(r'^\s*[Ee]nd', self.stdout)]) + self.sanity_patterns = sn.all([ + sn.assert_found('Finalising parallel run', self.stdout), + sn.assert_found(r'^\s*[Ee]nd', self.stdout) + ]) +@rfm.simple_test class PimpleFoam(OpenFOAMBaseTest): - def __init__(self, **kwargs): - super().__init__('pimpleFoam', - 'OpenFOAM check of pimpleFoam: tjunction tutorial', - **kwargs) - + def __init__(self): + super().__init__() + self.descr = 'OpenFOAM check of pimpleFoam: tjunction tutorial' residual = sn.extractall(r'Solving for epsilon, \w+\s\w+\s=\s\d.\d+.\s' r'Final residual\s=\s(?P-?\S+),', self.stdout, 'res', float) @@ -191,12 +168,11 @@ def __init__(self, **kwargs): )) +@rfm.simple_test class PotentialFoam(OpenFOAMBaseTest): - def __init__(self, **kwargs): - super().__init__('potentialFoam', - 'OpenFOAM check of potentialFoam: motorbike tutorial', - **kwargs) - + def __init__(self): + super().__init__() + self.descr = 'OpenFOAM check of potentialFoam: motorbike tutorial' self.executable_opts = ['-parallel'] self.num_tasks = 6 self.num_tasks_per_node = 6 @@ -206,118 +182,88 @@ def __init__(self, **kwargs): sn.chain(sn.map(lambda x: sn.assert_lt(x, 1.e-07), residual), [sn.assert_eq(5, sn.count(residual)), sn.assert_found('Finalising parallel run', self.stdout), - sn.assert_found(r'^\s*[Ee]nd', self.stdout)])) + sn.assert_found(r'^\s*[Ee]nd', self.stdout)]) + ) +@rfm.simple_test class ReconstructPar(OpenFOAMBaseTest): - def __init__(self, **kwargs): - super().__init__( - 'reconstructPar', - 'OpenFOAM check of reconstructPar: heatexchanger tutorial', - **kwargs) - + def __init__(self): + super().__init__() + self.descr = 'OpenFOAM check of reconstructPar: heatexchanger tutorial' self.executable_opts = ['-latestTime', '-region air'] self.readonly_files = ['processor0', 'processor1', 'processor2', 'processor3'] - self.sanity_patterns = sn.all( - [sn.assert_found('Time = 2000', self.stdout), - sn.assert_found(r'^\s*[Ee]nd', self.stdout)]) + self.sanity_patterns = sn.all([ + sn.assert_found('Time = 2000', self.stdout), + sn.assert_found(r'^\s*[Ee]nd', self.stdout) + ]) +@rfm.simple_test class ReconstructParMesh(OpenFOAMBaseTest): - def __init__(self, **kwargs): - super().__init__( - 'reconstructParMesh', - 'OpenFOAM check of reconstructParMesh: motorbike tutorial', - **kwargs) - + def __init__(self): + super().__init__() + self.descr = 'OpenFOAM check of reconstructParMesh: motorbike tutorial' self.executable_opts = ['-constant'] self.readonly_files = ['processor0', 'processor1', 'processor2', 'processor3', 'processor4', 'processor5'] - self.sanity_patterns = sn.assert_found(r'^\s*[Ee]nd', self.stdout) +@rfm.simple_test class SetFields(OpenFOAMBaseTest): - def __init__(self, **kwargs): - super().__init__('setFields', - 'OpenFOAM check of setFields: dambreak tutorial', - **kwargs) - + def __init__(self): + super().__init__() + self.descr = 'OpenFOAM check of setFields: dambreak tutorial' self.sanity_patterns = sn.assert_found(r'^\s*[Ee]nd', self.stdout) +@rfm.simple_test class SimpleFoam(OpenFOAMBaseTest): - def __init__(self, **kwargs): - super().__init__('simpleFoam', - 'OpenFOAM check of simpleFoam: motorbike tutorial', - **kwargs) - + def __init__(self): + super().__init__() + self.descr = 'OpenFOAM check of simpleFoam: motorbike tutorial' self.executable_opts = ['-parallel'] self.num_tasks = 6 self.num_tasks_per_node = 6 - - self.sanity_patterns = sn.all( - [sn.assert_found('Finalising parallel run', self.stdout), - sn.assert_found(r'^\s*[Ee]nd', self.stdout), - sn.assert_lt(sn.abs(sn.extractsingle( - r'time step continuity errors : \S+\s\S+ = \S+\s' - r'global = (?P-?\S+),', - self.stdout, 'res', float)), 1.e-04)]) + self.sanity_patterns = sn.all([ + sn.assert_found('Finalising parallel run', self.stdout), + sn.assert_found(r'^\s*[Ee]nd', self.stdout), + sn.assert_lt(sn.abs(sn.extractsingle( + r'time step continuity errors : \S+\s\S+ = \S+\s' + r'global = (?P-?\S+),', + self.stdout, 'res', float)), 1.e-04) + ]) +@rfm.simple_test class SnappyHexMesh(OpenFOAMBaseTest): - def __init__(self, **kwargs): - super().__init__('snappyHexMesh', - 'OpenFOAM check of snappyHexMesh: motorbike tutorial', - **kwargs) - + def __init__(self): + super().__init__() + self.descr = 'OpenFOAM check of snappyHexMesh: motorbike tutorial' self.executable_opts = ['-overwrite', ' -parallel'] self.num_tasks = 6 self.num_tasks_per_node = 6 - - self.sanity_patterns = sn.all( - [sn.assert_found('Finalising parallel run', self.stdout), - sn.assert_found(r'^\s*[Ee]nd', self.stdout)]) + self.sanity_patterns = sn.all([ + sn.assert_found('Finalising parallel run', self.stdout), + sn.assert_found(r'^\s*[Ee]nd', self.stdout) + ]) +@rfm.simple_test class SurfaceFeatureExtract(OpenFOAMBaseTest): - def __init__(self, **kwargs): - super().__init__( - 'surfaceFeatureExtract', - 'OpenFOAM check of surfaceFeatureExtract: motorbike tutorial', - **kwargs) - + def __init__(self): + super().__init__() + self.descr = ('OpenFOAM check of surfaceFeatureExtract: ' + 'motorbike tutorial') self.sanity_patterns = sn.assert_found(r'^\s*[Ee]nd', self.stdout) +@rfm.simple_test class TopoSet(OpenFOAMBaseTest): - def __init__(self, **kwargs): - super().__init__('topoSet', - 'OpenFOAM check of topoSet: heatexchanger tutorial', - **kwargs) - + def __init__(self): + super().__init__() + self.descr = 'OpenFOAM check of topoSet: heatexchanger tutorial' self.executable_opts = ['-region air', '-dict system/topoSetDict.1'] self.sanity_patterns = sn.assert_found(r'^\s*[Ee]nd', self.stdout) - - -def _get_checks(**kwargs): - return [FoamyHexMesh(**kwargs), - BuoyantBoussinesqSimpleFoam(**kwargs), - ChtMultiRegionSimpleFoam(**kwargs), - InterMixingFoam(**kwargs), - SimpleFoam(**kwargs), - PimpleFoam(**kwargs), - PotentialFoam(**kwargs), - SnappyHexMesh(**kwargs), - SetFields(**kwargs), - BlockMesh(**kwargs), - CheckMesh(**kwargs), - CollapseEdges(**kwargs), - CreateBaffles(**kwargs), - DecomposePar(**kwargs), - PatchSummary(**kwargs), - ReconstructPar(**kwargs), - ReconstructParMesh(**kwargs), - SurfaceFeatureExtract(**kwargs), - TopoSet(**kwargs)] diff --git a/cscs-checks/apps/openfoam/check_openfoam_extend.py b/cscs-checks/apps/openfoam/check_openfoam_extend.py new file mode 100644 index 0000000000..68a9a440de --- /dev/null +++ b/cscs-checks/apps/openfoam/check_openfoam_extend.py @@ -0,0 +1,173 @@ +import os + +import reframe as rfm +import reframe.utility.sanity as sn + + +class OpenfoamExtendBaseTest(rfm.RunOnlyRegressionTest): + def __init__(self): + dirname = self.name[0].lower() + self.name[1:] + self.name = 'OpenfoamExtend_' + self.name + self.executable = dirname + self.sourcesdir = os.path.join(self.current_system.resourcesdir, + 'OpenFOAM-Extend', dirname) + + # OpenFOAM-Extend currently runs only on Leone + self.valid_systems = ['leone:normal'] + self.valid_prog_environs = ['PrgEnv-gnu'] + self.modules = ['OpenFOAM-Extend/4.0-foss-2016b'] + + self.num_tasks = 1 + self.num_tasks_per_node = 1 + self.num_cpus_per_task = 1 + + self.sanity_patterns = sn.assert_found(r'^\s*[Ee]nd', self.stdout) + + if self.num_tasks > 1: + self.sanity_patterns = sn.assert_found( + r'Finalising parallel run', self.stdout) + + self.maintainers = ['MKr'] + self.tags = {'scs', 'production'} + self.pre_run = ['source $FOAM_INST_DIR/foam-extend-4.0/etc/bashrc'] + + +@rfm.simple_test +class BlockMesh(OpenfoamExtendBaseTest): + def __init__(self): + super().__init__() + self.descr = 'OpenFOAM-Extend blockMesh from the dambreak tutorial' + + +@rfm.simple_test +class SnappyHexMesh(OpenfoamExtendBaseTest): + def __init__(self): + super().__init__() + self.descr = ('OpenFOAM-Extend check of snappyHexMesh: ' + 'motorbike tutorial') + + +@rfm.simple_test +class SimpleFoam(OpenfoamExtendBaseTest): + def __init__(self): + super().__init__() + self.descr = 'OpenFOAM-Extend check of simpleFoam: motorbike tutorial' + self.executable_opts = ['-parallel'] + self.num_tasks = 6 + self.num_tasks_per_node = 6 + result = sn.extractall( + r'time step continuity errors : ' + r'\S+\s\S+ = \S+\sglobal = (?P-?\S+),', + self.stdout, 'res', float) + self.sanity_patterns = sn.all( + sn.map(lambda x: sn.assert_lt(abs(x), 5.e-04), result)) + + +@rfm.simple_test +class SetFields(OpenfoamExtendBaseTest): + def __init__(self): + super().__init__() + self.descr = 'OpenFOAM-Extend check of setFields: dambreak tutorial' + + +@rfm.simple_test +class InterMixingFoam(OpenfoamExtendBaseTest): + def __init__(self): + super().__init__() + self.descr = ('OpenFOAM-Extend check of interMixingFoam: ' + 'dambreak tutorial') + self.sanity_patterns = sn.assert_eq(sn.count(sn.findall( + r'Air phase volume fraction', self.stdout)), 2944) + + +@rfm.simple_test +class BuoyantBoussinesqSimpleFoam(OpenfoamExtendBaseTest): + def __init__(self): + super().__init__() + self.descr = ('OpenFOAM-Extend check buoyantBoussinesqSimpleFoam: ' + 'hotRoom test') + self.executable = 'buoyantBoussinesqSimpleFoam' + result = sn.extractall(r'\sglobal\s=\s(?P\S+),', + self.stdout, 'res', float) + self.sanity_patterns = sn.all( + sn.map(lambda x: sn.assert_lt(abs(x), 1.e-17), result)) + + +@rfm.simple_test +class LaplacianFoam(OpenfoamExtendBaseTest): + def __init__(self): + super().__init__() + self.descr = 'OpenFOAM-Extend check of setFields: flange tutorial' + + +@rfm.simple_test +class FoamToEnsight(OpenfoamExtendBaseTest): + def __init__(self): + super().__init__() + self.descr = 'OpenFOAM-Extend check of setFields: flange tutorial' + + +@rfm.simple_test +class SetSet(OpenfoamExtendBaseTest): + def __init__(self): + super().__init__() + self.descr = ('OpenFOAM-Extend check of setFields: ' + 'multi region heater tutorial') + self.executable_opts = ['-batch makeCellSets.setSet'] + + +@rfm.simple_test +class SetsToZones(OpenfoamExtendBaseTest): + def __init__(self): + super().__init__() + self.descr = ('OpenFOAM-Extend check of setFields: ' + 'multi region heater tutorial') + self.executable_opts = ['-noFlipMap'] + + +@rfm.simple_test +class SplitMeshRegions(OpenfoamExtendBaseTest): + def __init__(self): + super().__init__() + self.descr = ('OpenFOAM-Extend check of setFields: ' + 'multi region heater tutorial') + self.executable_opts = ['-cellZones', '-overwrite'] + + +@rfm.simple_test +class DecomposePar(OpenfoamExtendBaseTest): + def __init__(self): + super().__init__() + self.descr = ('OpenFOAM-Extend check of reconstructPar: ' + 'multiRegionHeater test') + self.executable_opts = ['-region heater'] + + +@rfm.simple_test +class ChtMultiRegionSimpleFoam(OpenfoamExtendBaseTest): + def __init__(self): + super().__init__() + self.descr = ('OpenFOAM-Extend check of reconstructPar: ' + 'multiRegionHeater test') + self.executable_opts = ['-parallel'] + self.num_tasks = 4 + self.num_tasks_per_node = 4 + + result = sn.extractall(r'\sglobal\s=\s(?P-?\S+),', + self.stdout, 'res', float)[-5:] + self.sanity_patterns = sn.all( + sn.map(lambda x: sn.assert_lt(abs(x), 1.e-04), result)) + + +@rfm.simple_test +class ReconstructPar(OpenfoamExtendBaseTest): + def __init__(self): + super().__init__() + self.descr = ('OpenFOAM-Extend check of reconstructPar: ' + 'multiRegionHeater test') + self.executable_opts = ['-latestTime', '-region heater'] + self.readonly_files = ['processor0', + 'processor1', + 'processor2', + 'processor3'] + self.sanity_patterns = sn.assert_found(r'Time = 1000', self.stdout) diff --git a/docs/advanced.rst b/docs/advanced.rst index 58ed189d70..a7b16d260b 100644 --- a/docs/advanced.rst +++ b/docs/advanced.rst @@ -43,7 +43,7 @@ The contents of this regression test are the following (``tutorial/advanced/adva The important bit here is how we set up the build system for this test: .. literalinclude:: ../tutorial/advanced/advanced_example1.py - :lines: 14-15 + :lines: 13-14 :dedent: 4 @@ -210,7 +210,7 @@ This ensures that the environment of the test is also set correctly at runtime. Finally, as already mentioned `previously <#working-with-makefiles>`__, since the name of the makefile is not one of the standard ones, it must be set explicitly in the build system: .. literalinclude:: ../tutorial/advanced/advanced_example4.py - :lines: 17 + :lines: 16 :dedent: 8 Setting a Time Limit for Regression Tests @@ -224,7 +224,7 @@ The following example (``tutorial/advanced/advanced_example5.py``) demonstrates The important bit here is the following line that sets the time limit for the test to one minute: .. literalinclude:: ../tutorial/advanced/advanced_example5.py - :lines: 13 + :lines: 12 :dedent: 8 The :attr:`time_limit ` attribute is a three-tuple in the form ``(HOURS, MINUTES, SECONDS)``. @@ -233,7 +233,7 @@ Time limits are implemented for all the scheduler backends. The sanity condition for this test verifies that associated job has been canceled due to the time limit (note that this message is SLURM-specific). .. literalinclude:: ../tutorial/advanced/advanced_example5.py - :lines: 16-17 + :lines: 15-16 :dedent: 8 Applying a sanity function iteratively @@ -259,7 +259,7 @@ The contents of the ReFrame regression test contained in ``advanced_example6.py` First the random numbers are extracted through the :func:`extractall ` function as follows: .. literalinclude:: ../tutorial/advanced/advanced_example6.py - :lines: 14-15 + :lines: 13-14 :dedent: 8 The ``numbers`` variable is a deferred iterable, which upon evaluation will return all the extracted numbers. @@ -276,7 +276,7 @@ Note that the ``and`` operator is not deferrable and will trigger the evaluation The full syntax for the :attr:`sanity_patterns` is the following: .. literalinclude:: ../tutorial/advanced/advanced_example6.py - :lines: 16-18 + :lines: 15-17 :dedent: 8 Customizing the Generated Job Script @@ -422,13 +422,13 @@ The first thing to notice in this test is that :attr:`num_tasks ` attribute. .. note:: + Calling ``super().__init__()`` inside the constructor of a test is no more needed. + + .. versionchanged:: 2.19 + + +.. warning:: ReFrame requires that the names of all the tests it loads are unique. In case of name clashes, it will refuse to load the conflicting test. @@ -60,7 +64,7 @@ You may change the name of the test later in the constructor by setting the :att The next line sets a more detailed description of the test: .. literalinclude:: ../tutorial/example1.py - :lines: 8 + :lines: 7 :dedent: 8 This is optional and it defaults to the auto-generated test's name, if not specified. @@ -71,7 +75,7 @@ This is optional and it defaults to the auto-generated test's name, if not speci The next two lines specify the systems and the programming environments that this test is valid for: .. literalinclude:: ../tutorial/example1.py - :lines: 9-10 + :lines: 8-9 :dedent: 8 Both of these variables accept a list of system names or environment names, respectively. @@ -87,7 +91,7 @@ If only a system name (without a partition) is specified in the :attr:`self.vali The next line specifies the source file that needs to be compiled: .. literalinclude:: ../tutorial/example1.py - :lines: 11 + :lines: 10 :dedent: 8 ReFrame expects any source files, or generally resources, of the test to be inside an ``src/`` directory, which is at the same level as the regression test file. @@ -109,7 +113,7 @@ A user can associate compilers with programming environments in the ReFrame's `s The next line in our first regression test specifies a list of options to be used for running the generated executable (the matrix dimension and the number of iterations in this particular example): .. literalinclude:: ../tutorial/example1.py - :lines: 12 + :lines: 11 :dedent: 8 Notice that you do not need to specify the executable name. @@ -119,7 +123,7 @@ We will see in the `"Customizing Further A ReFrame Regression Test" The last two lines of the regression test are optional, but serve a good role in a production environment: .. literalinclude:: ../tutorial/example1.py - :lines: 15-16 + :lines: 14-15 :dedent: 8 In the :attr:`maintainers ` attribute you may store a list of people responsible for the maintenance of this test. @@ -331,7 +335,7 @@ In this example, we write a regression test to compile and run the OpenMP versio The full code of this test follows: .. literalinclude:: ../tutorial/example2.py - :lines: 1-34 + :lines: 1-32 This example introduces two new concepts: @@ -368,7 +372,7 @@ As described in `"The Regression Test Pipeline" `__ section, it i The following lines show the overriden ``setup()`` method: .. literalinclude:: ../tutorial/example2.py - :lines: 24-34 + :lines: 23-33 :dedent: 4 The current environment is passed as argument by the framework to the ``setup()`` method, so we differentiate the build system's flags based on its name. @@ -382,10 +386,7 @@ Finally, we need call the ``setup()`` method of the base class, in order to perf .. warning:: - Setting the compiler flags in the programming environment is now deprecated. - Users are advised to use the build systems feature instead. - - .. versionadded:: 2.14 + Setting the compiler flags in the programming environment has been dropped completely in version 2.17. An alternative implementation using dictionaries @@ -398,7 +399,7 @@ The ``setup()`` method is now very simple: it gets the correct compilation flags from the ``prgenv_flags`` dictionary and applies them to the build system. .. literalinclude:: ../tutorial/example2.py - :lines: 1-4,37-64 + :lines: 1-4,36-63 .. tip:: A regression test is like any other Python class, so you can freely define your own attributes. @@ -422,7 +423,7 @@ Let's take the changes step-by-step: First we need to specify for which partitions this test is meaningful by setting the :attr:`valid_systems ` attribute: .. literalinclude:: ../tutorial/example3.py - :lines: 10 + :lines: 9 :dedent: 8 We only specify the partitions that are configured with a job scheduler. @@ -432,7 +433,7 @@ So we remove this partition from the list of the supported systems. The most important addition to this check are the variables controlling the distributed execution: .. literalinclude:: ../tutorial/example3.py - :lines: 24-26 + :lines: 23-25 :dedent: 8 By setting these variables, we specify that this test should run with 8 MPI tasks in total, using two tasks per node. @@ -470,7 +471,7 @@ Let's start with the OpenACC regression test: The things to notice in this test are the restricted list of system partitions and programming environments that this test supports and the use of the :attr:`modules ` variable: .. literalinclude:: ../tutorial/example4.py - :lines: 15 + :lines: 14 :dedent: 8 The :attr:`modules ` variable takes a list of modules that should be loaded during the setup phase of the test. @@ -479,7 +480,7 @@ In this particular test, we need to load the ``craype-accel-nvidia60`` module, w It is also important to note that in GPU-enabled tests the number of GPUs for each node have to be specified by setting the corresponding variable :attr:`num_gpus_per_node `, as follows: .. literalinclude:: ../tutorial/example4.py - :lines: 16 + :lines: 15 :dedent: 8 The regression test for the CUDA code is slightly simpler: @@ -504,7 +505,7 @@ Let's go over it line-by-line. The first thing we do is to extract the norm printed in the standard output. .. literalinclude:: ../tutorial/example6.py - :lines: 19-21 + :lines: 18-20 :dedent: 8 The :func:`extractsingle ` sanity function extracts some information from a single occurrence (by default the first) of a pattern in a filename. @@ -529,7 +530,7 @@ For a more detailed description of this and other sanity functions, please refer The next four lines is the actual sanity check: .. literalinclude:: ../tutorial/example6.py - :lines: 22-26 + :lines: 21-25 :dedent: 8 This expression combines two conditions that need to be true, in order for the sanity check to succeed: @@ -570,7 +571,7 @@ The are two new variables set in this test that basically enable the performance Let's have a closer look at each of them: .. literalinclude:: ../tutorial/example7.py - :lines: 20-23 + :lines: 19-22 :dedent: 8 The :attr:`perf_patterns ` attribute is a dictionary, whose keys are *performance variables* (i.e., arbitrary names assigned to the performance values we are looking for), and its values are *sanity expressions* that specify how to obtain these performance values from the output. @@ -582,7 +583,7 @@ When the framework obtains a performance value from the output of the test it se Let's go over the :attr:`reference ` dictionary of our example and explain its syntax in more detail: .. literalinclude:: ../tutorial/example7.py - :lines: 24-28 + :lines: 23-27 :dedent: 8 This is a special type of dictionary that we call ``scoped dictionary``, because it defines scopes for its keys. diff --git a/reframe/core/pipeline.py b/reframe/core/pipeline.py index e5278dcfbc..b5f497f297 100644 --- a/reframe/core/pipeline.py +++ b/reframe/core/pipeline.py @@ -544,7 +544,6 @@ class RegressionTest: def __new__(cls, *args, **kwargs): obj = super().__new__(cls) - obj._prefix = os.path.abspath(os.path.dirname(inspect.getfile(cls))) # Create a test name from the class name and the constructor's # arguments @@ -554,10 +553,14 @@ def __new__(cls, *args, **kwargs): itertools.chain(args, kwargs.values())) name += '_' + '_'.join(arg_names) - obj.name = name + obj._rfm_init(name, + os.path.abspath(os.path.dirname(inspect.getfile(cls)))) return obj - def __init__(self, name=None, prefix=None): + def __init__(self): + pass + + def _rfm_init(self, name=None, prefix=None): if name is not None: self.name = name @@ -1287,8 +1290,8 @@ class CompileOnlyRegressionTest(RegressionTest): module. """ - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) + def _rfm_init(self, *args, **kwargs): + super()._rfm_init(*args, **kwargs) self.local = True def setup(self, partition, environ, **job_opts): diff --git a/reframe/frontend/loader.py b/reframe/frontend/loader.py index f09caebe9f..994550cabb 100644 --- a/reframe/frontend/loader.py +++ b/reframe/frontend/loader.py @@ -57,12 +57,7 @@ def _module_name(self, filename): return (os.path.splitext(filename)[0]).replace('/', '.') def _validate_source(self, filename): - """Check if `filename` is a valid Reframe source file. - - This is not a full validation test, but rather a first step that - verifies that the file defines the `_get_checks()` method correctly. - A second step follows, which actually loads the test file, performing - further tests and finalizes and validation.""" + """Check if `filename` is a valid Reframe source file.""" with open(filename, 'r') as f: source_tree = ast.parse(f.read(), filename) @@ -86,25 +81,22 @@ def recurse(self): def load_from_module(self, module): """Load user checks from module. - This method tries to call the `_get_checks()` method of the user check - and validates its return value.""" + This method tries to call the `_rfm_gettests()` method of the user + check and validates its return value.""" from reframe.core.pipeline import RegressionTest - old_syntax = hasattr(module, '_get_checks') - new_syntax = hasattr(module, '_rfm_gettests') - if old_syntax and new_syntax: - raise RegressionTestLoadError('%s: mixing old and new regression ' - 'test syntax is not allowed' % - module.__file__) + # Warn in case of old syntax + if hasattr(module, '_get_checks'): + getlogger().warning( + '%s: _get_checks() is no more supported in test files: ' + 'please use @reframe.simple_test or ' + '@reframe.parameterized_test decorators' % module.__file__ + ) - if not old_syntax and not new_syntax: + if not hasattr(module, '_rfm_gettests'): return [] - if old_syntax: - candidates = module._get_checks() - else: - candidates = module._rfm_gettests() - + candidates = module._rfm_gettests() if not isinstance(candidates, collections.abc.Sequence): return [] diff --git a/tutorial/advanced/advanced_example1.py b/tutorial/advanced/advanced_example1.py index 855be9ddd2..01b874a8ee 100644 --- a/tutorial/advanced/advanced_example1.py +++ b/tutorial/advanced/advanced_example1.py @@ -5,7 +5,6 @@ @rfm.simple_test class MakefileTest(rfm.RegressionTest): def __init__(self): - super().__init__() self.descr = ('ReFrame tutorial demonstrating the use of Makefiles ' 'and compile options') self.valid_systems = ['*'] diff --git a/tutorial/advanced/advanced_example2.py b/tutorial/advanced/advanced_example2.py index 0d18cef18c..e54eb25144 100644 --- a/tutorial/advanced/advanced_example2.py +++ b/tutorial/advanced/advanced_example2.py @@ -5,7 +5,6 @@ @rfm.simple_test class ExampleRunOnlyTest(rfm.RunOnlyRegressionTest): def __init__(self): - super().__init__() self.descr = ('ReFrame tutorial demonstrating the class' 'RunOnlyRegressionTest') self.valid_systems = ['*'] diff --git a/tutorial/advanced/advanced_example3.py b/tutorial/advanced/advanced_example3.py index 37db613229..9ae6c3a502 100644 --- a/tutorial/advanced/advanced_example3.py +++ b/tutorial/advanced/advanced_example3.py @@ -5,7 +5,6 @@ @rfm.simple_test class ExampleCompileOnlyTest(rfm.CompileOnlyRegressionTest): def __init__(self): - super().__init__() self.descr = ('ReFrame tutorial demonstrating the class' 'CompileOnlyRegressionTest') self.valid_systems = ['*'] diff --git a/tutorial/advanced/advanced_example4.py b/tutorial/advanced/advanced_example4.py index 685515bec7..9caef1eed7 100644 --- a/tutorial/advanced/advanced_example4.py +++ b/tutorial/advanced/advanced_example4.py @@ -5,7 +5,6 @@ @rfm.simple_test class EnvironmentVariableTest(rfm.RegressionTest): def __init__(self): - super().__init__() self.descr = ('ReFrame tutorial demonstrating the use' 'of environment variables provided by loaded modules') self.valid_systems = ['daint:gpu'] diff --git a/tutorial/advanced/advanced_example5.py b/tutorial/advanced/advanced_example5.py index 359c73bbe4..7b84d30fd6 100644 --- a/tutorial/advanced/advanced_example5.py +++ b/tutorial/advanced/advanced_example5.py @@ -5,7 +5,6 @@ @rfm.simple_test class TimeLimitTest(rfm.RunOnlyRegressionTest): def __init__(self): - super().__init__() self.descr = ('ReFrame tutorial demonstrating the use' 'of a user-defined time limit') self.valid_systems = ['daint:gpu', 'daint:mc'] diff --git a/tutorial/advanced/advanced_example6.py b/tutorial/advanced/advanced_example6.py index 0b80085bae..b3e1a31ec8 100644 --- a/tutorial/advanced/advanced_example6.py +++ b/tutorial/advanced/advanced_example6.py @@ -5,7 +5,6 @@ @rfm.simple_test class DeferredIterationTest(rfm.RunOnlyRegressionTest): def __init__(self): - super().__init__() self.descr = ('ReFrame tutorial demonstrating the use of deferred ' 'iteration via the `map` sanity function.') self.valid_systems = ['*'] diff --git a/tutorial/advanced/advanced_example7.py b/tutorial/advanced/advanced_example7.py index 2d6d35dfe1..8f00f4ebab 100644 --- a/tutorial/advanced/advanced_example7.py +++ b/tutorial/advanced/advanced_example7.py @@ -5,7 +5,6 @@ @rfm.simple_test class PrerunDemoTest(rfm.RunOnlyRegressionTest): def __init__(self): - super().__init__() self.descr = ('ReFrame tutorial demonstrating the use of ' 'pre- and post-run commands') self.valid_systems = ['*'] diff --git a/tutorial/advanced/advanced_example8.py b/tutorial/advanced/advanced_example8.py index cdce4fa6a9..00d240c0eb 100644 --- a/tutorial/advanced/advanced_example8.py +++ b/tutorial/advanced/advanced_example8.py @@ -5,7 +5,6 @@ @rfm.parameterized_test(['MPI'], ['OpenMP']) class MatrixVectorTest(rfm.RegressionTest): def __init__(self, variant): - super().__init__() self.descr = 'Matrix-vector multiplication test (%s)' % variant self.valid_systems = ['daint:gpu', 'daint:mc'] self.valid_prog_environs = ['PrgEnv-cray', 'PrgEnv-gnu', diff --git a/tutorial/advanced/advanced_example9.py b/tutorial/advanced/advanced_example9.py index b620c76fee..f9ac24f28e 100644 --- a/tutorial/advanced/advanced_example9.py +++ b/tutorial/advanced/advanced_example9.py @@ -5,7 +5,6 @@ @rfm.simple_test class HostnameCheck(rfm.RunOnlyRegressionTest): def __init__(self): - super().__init__() self.valid_systems = ['daint:gpu', 'daint:mc'] self.valid_prog_environs = ['PrgEnv-cray'] self.executable = 'hostname' diff --git a/tutorial/example1.py b/tutorial/example1.py index 243f7fc1db..930f398121 100644 --- a/tutorial/example1.py +++ b/tutorial/example1.py @@ -4,7 +4,6 @@ @rfm.simple_test class Example1Test(rfm.RegressionTest): def __init__(self): - super().__init__() self.descr = 'Simple matrix-vector multiplication example' self.valid_systems = ['*'] self.valid_prog_environs = ['*'] diff --git a/tutorial/example2.py b/tutorial/example2.py index 0bb9df5939..4b440a2713 100644 --- a/tutorial/example2.py +++ b/tutorial/example2.py @@ -5,7 +5,6 @@ @rfm.simple_test class Example2aTest(rfm.RegressionTest): def __init__(self): - super().__init__() self.descr = 'Matrix-vector multiplication example with OpenMP' self.valid_systems = ['*'] self.valid_prog_environs = ['PrgEnv-cray', 'PrgEnv-gnu', @@ -36,8 +35,7 @@ def setup(self, partition, environ, **job_opts): @rfm.simple_test class Example2bTest(rfm.RegressionTest): - def __init__(self, **kwargs): - super().__init__() + def __init__(self): self.descr = 'Matrix-vector multiplication example with OpenMP' self.valid_systems = ['*'] self.valid_prog_environs = ['PrgEnv-cray', 'PrgEnv-gnu', diff --git a/tutorial/example3.py b/tutorial/example3.py index 374ad2a9b1..bbd15482ef 100644 --- a/tutorial/example3.py +++ b/tutorial/example3.py @@ -5,7 +5,6 @@ @rfm.simple_test class Example3Test(rfm.RegressionTest): def __init__(self): - super().__init__() self.descr = 'Matrix-vector multiplication example with MPI' self.valid_systems = ['daint:gpu', 'daint:mc'] self.valid_prog_environs = ['PrgEnv-cray', 'PrgEnv-gnu', diff --git a/tutorial/example4.py b/tutorial/example4.py index b6ee11c39b..fbb6d5ce43 100644 --- a/tutorial/example4.py +++ b/tutorial/example4.py @@ -5,7 +5,6 @@ @rfm.simple_test class Example4Test(rfm.RegressionTest): def __init__(self): - super().__init__() self.descr = 'Matrix-vector multiplication example with OpenACC' self.valid_systems = ['daint:gpu'] self.valid_prog_environs = ['PrgEnv-cray', 'PrgEnv-pgi'] diff --git a/tutorial/example5.py b/tutorial/example5.py index 6c4827e608..71ca6ac57c 100644 --- a/tutorial/example5.py +++ b/tutorial/example5.py @@ -5,7 +5,6 @@ @rfm.simple_test class Example5Test(rfm.RegressionTest): def __init__(self): - super().__init__() self.descr = 'Matrix-vector multiplication example with CUDA' self.valid_systems = ['daint:gpu'] self.valid_prog_environs = ['PrgEnv-cray', 'PrgEnv-gnu', 'PrgEnv-pgi'] diff --git a/tutorial/example6.py b/tutorial/example6.py index 74103690e2..c40c92d0da 100644 --- a/tutorial/example6.py +++ b/tutorial/example6.py @@ -5,7 +5,6 @@ @rfm.simple_test class Example6Test(rfm.RegressionTest): def __init__(self): - super().__init__() self.descr = 'Matrix-vector multiplication with L2 norm check' self.valid_systems = ['*'] self.valid_prog_environs = ['*'] diff --git a/tutorial/example7.py b/tutorial/example7.py index de919766df..3d3fe89968 100644 --- a/tutorial/example7.py +++ b/tutorial/example7.py @@ -5,7 +5,6 @@ @rfm.simple_test class Example7Test(rfm.RegressionTest): def __init__(self): - super().__init__() self.descr = 'Matrix-vector multiplication (CUDA performance test)' self.valid_systems = ['daint:gpu'] self.valid_prog_environs = ['PrgEnv-gnu', 'PrgEnv-cray', 'PrgEnv-pgi'] diff --git a/tutorial/example8.py b/tutorial/example8.py index 6c2c22ec5b..1290e6236a 100644 --- a/tutorial/example8.py +++ b/tutorial/example8.py @@ -4,7 +4,6 @@ class BaseMatrixVectorTest(rfm.RegressionTest): def __init__(self, test_version): - super().__init__() self.descr = '%s matrix-vector multiplication' % test_version self.valid_systems = ['*'] self.valid_prog_environs = ['*'] diff --git a/unittests/resources/checks/bad/badentry.py b/unittests/resources/checks/bad/badentry.py deleted file mode 100644 index a832c17c1a..0000000000 --- a/unittests/resources/checks/bad/badentry.py +++ /dev/null @@ -1,11 +0,0 @@ -import os - -from reframe.core.pipeline import RegressionTest - - -class EmptyTest(RegressionTest): - def __init__(self, **kwargs): - super().__init__('emptycheck', os.path.dirname(__file__), **kwargs) - - def _get_checks(**kwargs): - return [self] diff --git a/unittests/resources/checks/bad/invalid_check.py b/unittests/resources/checks/bad/invalid_check.py index ee1e6fedd3..051337692b 100644 --- a/unittests/resources/checks/bad/invalid_check.py +++ b/unittests/resources/checks/bad/invalid_check.py @@ -1,17 +1,10 @@ -import os +import reframe as rfm -from reframe.core.pipeline import RegressionTest +@rfm.simple_test +class SomeTest(rfm.RegressionTest): + pass -class SomeTest(RegressionTest): - def __init__(self, **kwargs): - super().__init__('somecheck', os.path.dirname(__file__), **kwargs) - -class InvalidTest: - def __init__(self, **kwargs): - pass - - -def _get_checks(**kwargs): - return [SomeTest(**kwargs), InvalidTest(**kwargs)] +class NotATest: + pass diff --git a/unittests/resources/checks/bad/invalid_entry.py b/unittests/resources/checks/bad/invalid_entry.py deleted file mode 100644 index 7548806943..0000000000 --- a/unittests/resources/checks/bad/invalid_entry.py +++ /dev/null @@ -1 +0,0 @@ -_get_checks = 'foo' diff --git a/unittests/resources/checks/bad/invalid_iterable.py b/unittests/resources/checks/bad/invalid_iterable.py deleted file mode 100644 index 4e9e020b9c..0000000000 --- a/unittests/resources/checks/bad/invalid_iterable.py +++ /dev/null @@ -1,2 +0,0 @@ -def _get_checks(**kwargs): - return 123 diff --git a/unittests/resources/checks/bad/invalid_return.py b/unittests/resources/checks/bad/invalid_return.py deleted file mode 100644 index 4e9e020b9c..0000000000 --- a/unittests/resources/checks/bad/invalid_return.py +++ /dev/null @@ -1,2 +0,0 @@ -def _get_checks(**kwargs): - return 123 diff --git a/unittests/resources/checks/bad/relative_imports.py b/unittests/resources/checks/bad/relative_imports.py index deba89b30b..c63777edf8 100644 --- a/unittests/resources/checks/bad/relative_imports.py +++ b/unittests/resources/checks/bad/relative_imports.py @@ -1,7 +1,5 @@ # # module to test reframe's loader with relative imports # -from . import invalid_iterable from .. import hellocheck -from .invalid_iterable import _get_checks from ..hellocheck import HelloTest diff --git a/unittests/resources/checks/frontend_checks.py b/unittests/resources/checks/frontend_checks.py index fae813d109..b144f97668 100644 --- a/unittests/resources/checks/frontend_checks.py +++ b/unittests/resources/checks/frontend_checks.py @@ -9,7 +9,6 @@ class BaseFrontendCheck(rfm.RunOnlyRegressionTest): def __init__(self): - super().__init__() self.local = True self.executable = 'echo hello && echo perf: 10 Gflop/s' self.sanity_patterns = sn.assert_found('hello', self.stdout) diff --git a/unittests/resources/checks/hellocheck.py b/unittests/resources/checks/hellocheck.py index c4911593e5..62abd1d0f5 100644 --- a/unittests/resources/checks/hellocheck.py +++ b/unittests/resources/checks/hellocheck.py @@ -5,7 +5,6 @@ @rfm.simple_test class HelloTest(rfm.RegressionTest): def __init__(self): - super().__init__() self.name = 'hellocheck' self.descr = 'C Hello World test' diff --git a/unittests/resources/checks/hellocheck_make.py b/unittests/resources/checks/hellocheck_make.py index b67e3f3526..15d94fad69 100644 --- a/unittests/resources/checks/hellocheck_make.py +++ b/unittests/resources/checks/hellocheck_make.py @@ -1,17 +1,10 @@ -# -# We purposely use the old syntax here -# - -import os - +import reframe as rfm import reframe.utility.sanity as sn -from reframe.core.pipeline import RegressionTest -class HelloMakeTest(RegressionTest): - def __init__(self, **kwargs): - super().__init__('hellocheck_make', - os.path.dirname(__file__), **kwargs) +@rfm.simple_test +class HelloMakeTest(rfm.RegressionTest): + def __init__(self): self.descr = 'C++ Hello World test' # All available systems are supported @@ -26,7 +19,3 @@ def __init__(self, **kwargs): self.tags = {'foo', 'bar'} self.sanity_patterns = sn.assert_found(r'Hello, World\!', self.stdout) self.maintainers = ['VK'] - - -def _get_checks(**kwargs): - return [HelloMakeTest(**kwargs)] diff --git a/unittests/resources/checks_unlisted/dependencies/normal.py b/unittests/resources/checks_unlisted/dependencies/normal.py index 10f9e2d7de..c98e4ed479 100644 --- a/unittests/resources/checks_unlisted/dependencies/normal.py +++ b/unittests/resources/checks_unlisted/dependencies/normal.py @@ -5,7 +5,6 @@ @rfm.simple_test class Test0(rfm.RunOnlyRegressionTest): def __init__(self): - super().__init__() self.valid_systems = ['sys0:p0', 'sys0:p1'] self.valid_prog_environs = ['e0', 'e1'] self.executable = 'echo' @@ -17,7 +16,6 @@ def __init__(self): 'exact', 'default'])) class Test1(rfm.RunOnlyRegressionTest): def __init__(self, kind): - super().__init__() kindspec = { 'fully': rfm.DEPEND_FULLY, 'by_env': rfm.DEPEND_BY_ENV, diff --git a/unittests/resources/checks_unlisted/good.py b/unittests/resources/checks_unlisted/good.py index 4547c0cc02..cb86e5fe9c 100644 --- a/unittests/resources/checks_unlisted/good.py +++ b/unittests/resources/checks_unlisted/good.py @@ -11,7 +11,6 @@ @rfm.parameterized_test(*((x, y) for x in range(3) for y in range(2))) class MyBaseTest(RegressionTest): def __init__(self, a, b): - super().__init__() self.a = a self.b = b @@ -29,7 +28,6 @@ def __repr__(self): @rfm.parameterized_test(*({'a': x, 'b': y} for x in range(3) for y in range(2))) class AnotherBaseTest(RegressionTest): def __init__(self, a, b): - super().__init__() self.a = a self.b = b diff --git a/unittests/resources/checks_unlisted/kbd_interrupt.py b/unittests/resources/checks_unlisted/kbd_interrupt.py index 1a0e82c48d..20e82355c0 100644 --- a/unittests/resources/checks_unlisted/kbd_interrupt.py +++ b/unittests/resources/checks_unlisted/kbd_interrupt.py @@ -10,8 +10,7 @@ @rfm.simple_test class KeyboardInterruptCheck(rfm.RunOnlyRegressionTest): - def __init__(self, **kwargs): - super().__init__() + def __init__(self): self.local = True self.executable = 'sleep 1' self.valid_systems = ['*'] diff --git a/unittests/resources/checks_unlisted/mixed.py b/unittests/resources/checks_unlisted/mixed.py deleted file mode 100644 index e33a778966..0000000000 --- a/unittests/resources/checks_unlisted/mixed.py +++ /dev/null @@ -1,28 +0,0 @@ -import os - -import reframe.core.decorators as deco -from reframe.core.pipeline import RegressionTest - - -@deco.parameterized_test(*((x, y) for x in range(3) for y in range(2))) -class MyBaseTest(RegressionTest): - def __init__(self, a, b): - super().__init__() - self.a = a - self.b = b - - -@deco.simple_test -class MyTest(MyBaseTest): - def __init__(self): - super().__init__(10, 20) - - -class OldStyleTest(MyBaseTest): - def __init__(self, **kwargs): - super().__init__('old_style_test', - os.path.dirname(__file__), **kwargs) - - -def _get_checks(**kwargs): - return [OldStyleTest(**kwargs)] diff --git a/unittests/test_loader.py b/unittests/test_loader.py index d4656e2216..700e4c4968 100644 --- a/unittests/test_loader.py +++ b/unittests/test_loader.py @@ -47,10 +47,6 @@ def test_load_new_syntax(self): 'unittests/resources/checks_unlisted/good.py') self.assertEqual(13, len(checks)) - def test_load_mixed_syntax(self): - self.assertRaises(RegressionTestLoadError, self.loader.load_from_file, - 'unittests/resources/checks_unlisted/mixed.py') - def test_conflicted_checks(self): self.loader_with_path._ignore_conflicts = False self.assertRaises(NameConflictError, self.loader_with_path.load_all) diff --git a/unittests/test_logging.py b/unittests/test_logging.py index 11ff3f470f..71cc97c674 100644 --- a/unittests/test_logging.py +++ b/unittests/test_logging.py @@ -6,9 +6,13 @@ import unittest from datetime import datetime +import reframe as rfm import reframe.core.logging as rlog from reframe.core.exceptions import ConfigError, ReframeError -from reframe.core.pipeline import RegressionTest + + +class RandomCheck(rfm.RegressionTest): + pass class TestLogger(unittest.TestCase): @@ -29,8 +33,7 @@ def setUp(self): self.logger_without_check = rlog.LoggerAdapter(self.logger) # Logger adapter with an associated check - self.logger_with_check = rlog.LoggerAdapter( - self.logger, RegressionTest('random_check', '.')) + self.logger_with_check = rlog.LoggerAdapter(self.logger, RandomCheck()) def tearDown(self): os.remove(self.logfile) @@ -62,7 +65,7 @@ def test_check_logger(self): self.assertTrue(os.path.exists(self.logfile)) self.assertTrue(self.found_in_logfile('info')) self.assertTrue(self.found_in_logfile('verbose')) - self.assertTrue(self.found_in_logfile('random_check')) + self.assertTrue(self.found_in_logfile('RandomCheck')) def test_handler_types(self): self.assertTrue(issubclass(logging.Handler, rlog.Handler)) @@ -113,7 +116,7 @@ def setUp(self): } ] } - self.check = RegressionTest('random_check', '.') + self.check = RandomCheck() def tearDown(self): if os.path.exists(self.logfile): @@ -400,7 +403,7 @@ def test_logging_context_check(self): rlog.getlogger().error('error outside context') self.assertTrue(self.found_in_logfile( - 'random_check: %s: error from context' % sys.argv[0])) + 'RandomCheck: %s: error from context' % sys.argv[0])) self.assertTrue(self.found_in_logfile( 'reframe: %s: error outside context' % sys.argv[0])) diff --git a/unittests/test_pipeline.py b/unittests/test_pipeline.py index 52166d07c2..03fa947e68 100644 --- a/unittests/test_pipeline.py +++ b/unittests/test_pipeline.py @@ -178,8 +178,8 @@ def custom_setup(obj, partition, environ, **job_opts): self._run_test(test) def test_run_only_sanity(self): - test = RunOnlyRegressionTest('runonlycheck', - 'unittests/resources/checks') + test = RunOnlyRegressionTest() + test._prefix = 'unittests/resources/checks' test.executable = './hello.sh' test.executable_opts = ['Hello, World!'] test.local = True @@ -189,8 +189,8 @@ def test_run_only_sanity(self): self._run_test(test) def test_compile_only_failure(self): - test = CompileOnlyRegressionTest('compileonlycheck', - 'unittests/resources/checks') + test = CompileOnlyRegressionTest() + test._prefix = 'unittests/resources/checks' test.sourcepath = 'compiler_failure.c' test.valid_prog_environs = ['*'] test.valid_systems = ['*'] @@ -199,8 +199,8 @@ def test_compile_only_failure(self): self.assertRaises(BuildError, test.compile_wait) def test_compile_only_warning(self): - test = CompileOnlyRegressionTest('compileonlycheckwarning', - 'unittests/resources/checks') + test = CompileOnlyRegressionTest() + test._prefix = 'unittests/resources/checks' test.build_system = 'SingleSource' test.build_system.srcfile = 'compiler_warning.c' test.build_system.cflags = ['-Wall'] @@ -254,14 +254,16 @@ def test_supports_environ(self): self.assertTrue(test.supports_environ('*')) def test_sourcesdir_none(self): - test = RegressionTest('hellocheck', 'unittests/resources/checks') + test = RegressionTest() + test._prefix = 'unittests/resources/checks' test.sourcesdir = None test.valid_prog_environs = ['*'] test.valid_systems = ['*'] self.assertRaises(ReframeError, self._run_test, test) def test_sourcesdir_build_system(self): - test = RegressionTest('hellocheck_make', 'unittests/resources/checks') + test = RegressionTest() + test._prefix = 'unittests/resources/checks' test.build_system = 'Make' test.sourcepath = 'code' test.executable = './code/hello' @@ -272,8 +274,8 @@ def test_sourcesdir_build_system(self): self._run_test(test) def test_sourcesdir_none_generated_sources(self): - test = RegressionTest('hellocheck_generated_sources', - 'unittests/resources/checks') + test = RegressionTest() + test._prefix = 'unittests/resources/checks' test.sourcesdir = None test.prebuild_cmd = ["printf '#include \\n int main(){ " "printf(\"Hello, World!\\\\n\"); return 0; }' " @@ -287,16 +289,16 @@ def test_sourcesdir_none_generated_sources(self): self._run_test(test) def test_sourcesdir_none_compile_only(self): - test = CompileOnlyRegressionTest('hellocheck', - 'unittests/resources/checks') + test = CompileOnlyRegressionTest() + test._prefix = 'unittests/resources/checks' test.sourcesdir = None test.valid_prog_environs = ['*'] test.valid_systems = ['*'] self.assertRaises(BuildError, self._run_test, test) def test_sourcesdir_none_run_only(self): - test = RunOnlyRegressionTest('hellocheck', - 'unittests/resources/checks') + test = RunOnlyRegressionTest() + test._prefix = 'unittests/resources/checks' test.sourcesdir = None test.executable = 'echo' test.executable_opts = ["Hello, World!"] @@ -307,8 +309,8 @@ def test_sourcesdir_none_run_only(self): self._run_test(test) def test_sourcepath_abs(self): - test = CompileOnlyRegressionTest('compileonlycheck', - 'unittests/resources/checks') + test = CompileOnlyRegressionTest() + test._prefix = 'unittests/resources/checks' test.valid_prog_environs = [self.progenv.name] test.valid_systems = ['*'] test.setup(self.partition, self.progenv) @@ -316,8 +318,8 @@ def test_sourcepath_abs(self): self.assertRaises(PipelineError, test.compile) def test_sourcepath_upref(self): - test = CompileOnlyRegressionTest('compileonlycheck', - 'unittests/resources/checks') + test = CompileOnlyRegressionTest() + test._prefix = 'unittests/resources/checks' test.valid_prog_environs = ['*'] test.valid_systems = ['*'] test.setup(self.partition, self.progenv) @@ -327,7 +329,8 @@ def test_sourcepath_upref(self): @rt.switch_runtime(fixtures.TEST_SITE_CONFIG, 'testsys') def test_extra_resources(self): # Load test site configuration - test = RegressionTest('dummycheck', 'unittests/resources/checks') + test = RegressionTest() + test._prefix = 'unittests/resources/checks' test.valid_prog_environs = ['*'] test.valid_systems = ['*'] test.extra_resources = { @@ -345,18 +348,17 @@ def test_extra_resources(self): self.assertCountEqual(expected_job_options, test.job.options) -class TestNewStyleChecks(unittest.TestCase): +class TestSyntax(unittest.TestCase): def test_regression_test(self): class MyTest(RegressionTest): def __init__(self, a, b): - super().__init__() self.a = a self.b = b test = MyTest(1, 2) self.assertEqual(os.path.abspath(os.path.dirname(__file__)), test.prefix) - self.assertEqual('TestNewStyleChecks.test_regression_test.' + self.assertEqual('TestSyntax.test_regression_test.' '.MyTest_1_2', test.name) def test_regression_test_strange_names(self): @@ -369,19 +371,17 @@ def __repr__(self): class MyTest(RegressionTest): def __init__(self, a, b): - super().__init__() self.a = a self.b = b test = MyTest('(a*b+c)/12', C(33)) self.assertEqual( - 'TestNewStyleChecks.test_regression_test_strange_names.' + 'TestSyntax.test_regression_test_strange_names.' '.MyTest__a_b_c__12_C_33_', test.name) def test_user_inheritance(self): class MyBaseTest(RegressionTest): def __init__(self, a, b): - super().__init__() self.a = a self.b = b @@ -390,33 +390,31 @@ def __init__(self): super().__init__(1, 2) test = MyTest() - self.assertEqual('TestNewStyleChecks.test_user_inheritance.' + self.assertEqual('TestSyntax.test_user_inheritance.' '.MyTest', test.name) def test_runonly_test(self): class MyTest(RunOnlyRegressionTest): def __init__(self, a, b): - super().__init__() self.a = a self.b = b test = MyTest(1, 2) self.assertEqual(os.path.abspath(os.path.dirname(__file__)), test.prefix) - self.assertEqual('TestNewStyleChecks.test_runonly_test.' + self.assertEqual('TestSyntax.test_runonly_test.' '.MyTest_1_2', test.name) def test_compileonly_test(self): class MyTest(CompileOnlyRegressionTest): def __init__(self, a, b): - super().__init__() self.a = a self.b = b test = MyTest(1, 2) self.assertEqual(os.path.abspath(os.path.dirname(__file__)), test.prefix) - self.assertEqual('TestNewStyleChecks.test_compileonly_test.' + self.assertEqual('TestSyntax.test_compileonly_test.' '.MyTest_1_2', test.name) def test_registration(self): @@ -447,8 +445,8 @@ def setUp(self): rt.runtime().resources.prefix = self.resourcesdir # Set up RegressionTest instance - self.test = RegressionTest('test_performance', - 'unittests/resources/checks') + self.test = RegressionTest() + self.test._prefix = 'unittests/resources/checks' self.partition = rt.runtime().system.partition('gpu') self.progenv = self.partition.environment('builtin-gcc') diff --git a/unittests/test_utility.py b/unittests/test_utility.py index ce91bfb49e..cb3c506934 100644 --- a/unittests/test_utility.py +++ b/unittests/test_utility.py @@ -978,7 +978,6 @@ def test_reversed(self): assert list(reversed(s)) == list(reversed(l)) def test_concat_files(self): - tmpdir = tempfile.mkdtemp(dir='unittests') with tempfile.TemporaryDirectory(dir='unittests') as tmpdir: with os_ext.change_dir(tmpdir): file1 = 'in1.txt'