Exemple #1
0
def environ():
    return ProgEnvironment(name='test_env',
                           cc='gcc',
                           cxx='g++',
                           ftn='gfortran',
                           cppflags=['-DNDEBUG'],
                           cflags=['-Wall', '-std=c99'],
                           cxxflags=['-Wall', '-std=c++11'],
                           fflags=['-Wall'],
                           ldflags=['-dynamic'])
Exemple #2
0
 def setUp(self):
     self.environ = ProgEnvironment(name='test_env',
                                    cc='gcc',
                                    cxx='g++',
                                    ftn='gfortran',
                                    cppflags=['-DNDEBUG'],
                                    cflags=['-Wall', '-std=c99'],
                                    cxxflags=['-Wall', '-std=c++11'],
                                    fflags=['-Wall'],
                                    ldflags=['-dynamic'])
     self.build_system = self.create_build_system()
Exemple #3
0
    def test_hellocheck_local_slashes(self):
        # Try to fool path creation by adding slashes to environment partitions
        # names
        from reframe.core.environments import ProgEnvironment

        self.progenv = ProgEnvironment('bad/name', self.progenv.modules,
                                       self.progenv.variables)

        # That's a bit hacky, but we are in a unit test
        self.system._name += os.sep + 'bad'
        self.partition._name += os.sep + 'bad'
        self.test_hellocheck_local()
Exemple #4
0
def test_compiler_pick(lang):
    ext = {'C': '.c', 'C++': '.cpp', 'Fortran': '.f90', 'CUDA': '.cu'}
    build_system = bs.SingleSource()
    build_system.cc = 'cc'
    build_system.cxx = 'CC'
    build_system.ftn = 'ftn'
    build_system.nvcc = 'nvcc'
    build_system.srcfile = 'foo' + ext[lang]
    compilers = {
        'C': build_system.cc,
        'C++': build_system.cxx,
        'Fortran': build_system.ftn,
        'CUDA': build_system.nvcc
    }
    assert ([f'{compilers[lang]} {build_system.srcfile} -o foo.x'] ==
            build_system.emit_build_commands(ProgEnvironment('testenv')))
Exemple #5
0
    def create(cls, site_config):
        # Create the whole system hierarchy from bottom up
        sysname = site_config.get('systems/0/name')
        partitions = []
        config_save = site_config.subconfig_system
        for p in site_config.get('systems/0/partitions'):
            site_config.select_subconfig(f'{sysname}:{p["name"]}')
            partid = f"systems/0/partitions/@{p['name']}"
            part_name = site_config.get(f'{partid}/name')
            part_sched = getscheduler(site_config.get(f'{partid}/scheduler'))
            part_launcher = getlauncher(site_config.get(f'{partid}/launcher'))
            part_container_environs = {}
            for i, p in enumerate(
                    site_config.get(f'{partid}/container_platforms')):
                ctype = p['type']
                part_container_environs[ctype] = Environment(
                    name=f'__rfm_env_{ctype}',
                    modules=site_config.get(
                        f'{partid}/container_platforms/{i}/modules'),
                    variables=site_config.get(
                        f'{partid}/container_platforms/{i}/variables'))

            part_environs = [
                ProgEnvironment(
                    name=e,
                    modules=site_config.get(f'environments/@{e}/modules'),
                    variables=site_config.get(f'environments/@{e}/variables'),
                    cc=site_config.get(f'environments/@{e}/cc'),
                    cxx=site_config.get(f'environments/@{e}/cxx'),
                    ftn=site_config.get(f'environments/@{e}/ftn'),
                    cppflags=site_config.get(f'environments/@{e}/cppflags'),
                    cflags=site_config.get(f'environments/@{e}/cflags'),
                    cxxflags=site_config.get(f'environments/@{e}/cxxflags'),
                    fflags=site_config.get(f'environments/@{e}/fflags'),
                    ldflags=site_config.get(f'environments/@{e}/ldflags'))
                for e in site_config.get(f'{partid}/environs')
            ]
            partitions.append(
                SystemPartition(
                    parent=site_config.get('systems/0/name'),
                    name=part_name,
                    scheduler=part_sched,
                    launcher=part_launcher,
                    descr=site_config.get(f'{partid}/descr'),
                    access=site_config.get(f'{partid}/access'),
                    resources=site_config.get(f'{partid}/resources'),
                    environs=part_environs,
                    container_environs=part_container_environs,
                    local_env=Environment(
                        name=f'__rfm_env_{part_name}',
                        modules=site_config.get(f'{partid}/modules'),
                        variables=site_config.get(f'{partid}/variables')),
                    max_jobs=site_config.get(f'{partid}/max_jobs')))

        # Restore configuration
        site_config.select_subconfig(config_save)
        return System(
            name=sysname,
            descr=site_config.get('systems/0/descr'),
            hostnames=site_config.get('systems/0/hostnames'),
            modules_system=site_config.get('systems/0/modules_system'),
            preload_env=Environment(
                name=f'__rfm_env_{sysname}',
                modules=site_config.get('systems/0/modules'),
                variables=site_config.get('systems/0/variables')),
            prefix=site_config.get('systems/0/prefix'),
            outputdir=site_config.get('systems/0/outputdir'),
            resourcesdir=site_config.get('systems/0/resourcesdir'),
            stagedir=site_config.get('systems/0/stagedir'),
            partitions=partitions)
Exemple #6
0
def test_singlesource_unknown_language():
    build_system = bs.SingleSource()
    build_system.srcfile = 'foo.bar'
    with pytest.raises(BuildSystemError, match='could not guess language'):
        build_system.emit_build_commands(ProgEnvironment('testenv'))
Exemple #7
0
    def create(cls, site_config):
        # Create the whole system hierarchy from bottom up
        sysname = site_config.get('systems/0/name')
        partitions = []
        config_save = site_config.subconfig_system
        for p in site_config.get('systems/0/partitions'):
            site_config.select_subconfig(f'{sysname}:{p["name"]}')
            partid = f"systems/0/partitions/@{p['name']}"
            part_name = site_config.get(f'{partid}/name')
            part_sched = getscheduler(site_config.get(f'{partid}/scheduler'))
            part_launcher = getlauncher(site_config.get(f'{partid}/launcher'))
            part_container_environs = {}
            for i, p in enumerate(
                    site_config.get(f'{partid}/container_platforms')):
                ctype = p['type']
                part_container_environs[ctype] = Environment(
                    name=f'__rfm_env_{ctype}',
                    modules=site_config.get(
                        f'{partid}/container_platforms/{i}/modules'),
                    variables=site_config.get(
                        f'{partid}/container_platforms/{i}/variables'))

            part_environs = [
                ProgEnvironment(
                    name=e,
                    modules=site_config.get(f'environments/@{e}/modules'),
                    variables=site_config.get(f'environments/@{e}/variables'),
                    cc=site_config.get(f'environments/@{e}/cc'),
                    cxx=site_config.get(f'environments/@{e}/cxx'),
                    ftn=site_config.get(f'environments/@{e}/ftn'),
                    cppflags=site_config.get(f'environments/@{e}/cppflags'),
                    cflags=site_config.get(f'environments/@{e}/cflags'),
                    cxxflags=site_config.get(f'environments/@{e}/cxxflags'),
                    fflags=site_config.get(f'environments/@{e}/fflags'),
                    ldflags=site_config.get(f'environments/@{e}/ldflags'))
                for e in site_config.get(f'{partid}/environs')
            ]
            partitions.append(
                SystemPartition(
                    parent=site_config.get('systems/0/name'),
                    name=part_name,
                    sched_type=part_sched,
                    launcher_type=part_launcher,
                    descr=site_config.get(f'{partid}/descr'),
                    access=site_config.get(f'{partid}/access'),
                    resources=site_config.get(f'{partid}/resources'),
                    environs=part_environs,
                    container_environs=part_container_environs,
                    local_env=Environment(
                        name=f'__rfm_env_{part_name}',
                        modules=site_config.get(f'{partid}/modules'),
                        variables=site_config.get(f'{partid}/variables')),
                    max_jobs=site_config.get(f'{partid}/max_jobs'),
                    prepare_cmds=site_config.get(f'{partid}/prepare_cmds'),
                    processor=site_config.get(f'{partid}/processor'),
                    devices=site_config.get(f'{partid}/devices'),
                    extras=site_config.get(f'{partid}/extras')))

        # Restore configuration, but ignore unresolved sections or
        # configuration parameters at the system level; if we came up to this
        # point, then all is good at the partition level, which is enough.
        site_config.select_subconfig(config_save, ignore_resolve_errors=True)
        return System(
            name=sysname,
            descr=site_config.get('systems/0/descr'),
            hostnames=site_config.get('systems/0/hostnames'),
            modules_system=site_config.get('systems/0/modules_system'),
            preload_env=Environment(
                name=f'__rfm_env_{sysname}',
                modules=site_config.get('systems/0/modules'),
                variables=site_config.get('systems/0/variables')),
            prefix=site_config.get('systems/0/prefix'),
            outputdir=site_config.get('systems/0/outputdir'),
            resourcesdir=site_config.get('systems/0/resourcesdir'),
            stagedir=site_config.get('systems/0/stagedir'),
            partitions=partitions)