def test_sourcesdir_none(self): test = rfm.RegressionTest() test._prefix = 'unittests/resources/checks' test.sourcesdir = None test.valid_prog_environs = ['*'] test.valid_systems = ['*'] self.assertRaises(ReframeError, self._run_test, test)
def create_test(self, name): test = rfm.RegressionTest() test.name = name test.valid_systems = ['*'] test.valid_prog_environs = ['*'] test.executable = 'echo' test.executable_opts = [name] return test
def test_sourcesdir_build_system(self): test = rfm.RegressionTest() test._prefix = 'unittests/resources/checks' test.build_system = 'Make' test.sourcepath = 'code' test.executable = './code/hello' test.local = True test.valid_systems = ['*'] test.valid_prog_environs = ['*'] test.sanity_patterns = sn.assert_found(r'Hello, World\!', test.stdout) self._run_test(test)
def test_sourcesdir_none_generated_sources(self): test = rfm.RegressionTest() test._prefix = 'unittests/resources/checks' test.sourcesdir = None test.prebuild_cmd = [ "printf '#include <stdio.h>\\n int main(){ " "printf(\"Hello, World!\\\\n\"); return 0; }' " "> hello.c" ] test.executable = './hello' test.sourcepath = 'hello.c' test.local = True test.valid_systems = ['*'] test.valid_prog_environs = ['*'] test.sanity_patterns = sn.assert_found(r'Hello, World\!', test.stdout) self._run_test(test)
def setUp(self): # Set up the test runtime self.resourcesdir = tempfile.mkdtemp(dir='unittests') rt.runtime().resources.prefix = self.resourcesdir # Set up RegressionTest instance self.test = rfm.RegressionTest() self.test._prefix = 'unittests/resources/checks' self.partition = rt.runtime().system.partition('gpu') self.prgenv = self.partition.environment('builtin-gcc') self.test.setup(self.partition, self.prgenv) self.test.reference = { 'testsys': { 'value1': (1.4, -0.1, 0.1), 'value2': (1.7, -0.1, 0.1), }, 'testsys:gpu': { 'value3': (3.1, -0.1, 0.1), } } self.perf_file = tempfile.NamedTemporaryFile(mode='wt', delete=False) self.output_file = tempfile.NamedTemporaryFile(mode='wt', delete=False) self.test.perf_patterns = { 'value1': sn.extractsingle(r'performance1 = (\S+)', self.perf_file.name, 1, float), 'value2': sn.extractsingle(r'performance2 = (\S+)', self.perf_file.name, 1, float), 'value3': sn.extractsingle(r'performance3 = (\S+)', self.perf_file.name, 1, float) } self.test.sanity_patterns = sn.assert_found(r'result = success', self.output_file.name)
def test_extra_resources(self): # Load test site configuration test = rfm.RegressionTest() test._prefix = 'unittests/resources/checks' test.valid_prog_environs = ['*'] test.valid_systems = ['*'] test.extra_resources = { 'gpu': { 'num_gpus_per_node': 2 }, 'datawarp': { 'capacity': '100GB', 'stagein_src': '/foo' } } partition = rt.runtime().system.partition('gpu') environ = partition.environment('builtin-gcc') test.setup(partition, environ) test.job.options += ['--foo'] expected_job_options = [ '--gres=gpu:2', '#DW jobdw capacity=100GB', '#DW stage_in source=/foo', '--foo' ] self.assertCountEqual(expected_job_options, test.job.options)