Skip to content

Commit dacd357

Browse files
author
Vasileios Karakasis
committed
Merge branch 'feat/alt_flex_alloc' of github.com:ekouts/reframe into feat/alt_flex_alloc
2 parents 1eef8b5 + 6e56af7 commit dacd357

File tree

5 files changed

+110
-41
lines changed

5 files changed

+110
-41
lines changed

reframe/core/buildsystems.py

Lines changed: 75 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,10 @@ class Make(BuildSystem):
264264
def emit_build_commands(self, environ):
265265
cmd_parts = ['make']
266266
if self.makefile:
267-
cmd_parts += ['-f %s' % self.makefile]
267+
cmd_parts += [f'-f {self.makefile}']
268268

269269
if self.srcdir:
270-
cmd_parts += ['-C %s' % self.srcdir]
270+
cmd_parts += [f'-C {self.srcdir}']
271271

272272
cmd_parts += ['-j']
273273
if self.max_concurrency is not None:
@@ -283,31 +283,36 @@ def emit_build_commands(self, environ):
283283
fflags = self._fflags(environ)
284284
ldflags = self._ldflags(environ)
285285
if cc:
286-
cmd_parts += ['CC="%s"' % cc]
286+
cmd_parts += [f'CC="{cc}"']
287287

288288
if cxx:
289-
cmd_parts += ['CXX="%s"' % cxx]
289+
cmd_parts += [f'CXX="{cxx}"']
290290

291291
if ftn:
292-
cmd_parts += ['FC="%s"' % ftn]
292+
cmd_parts += [f'FC="{ftn}"']
293293

294294
if nvcc:
295-
cmd_parts += ['NVCC="%s"' % nvcc]
295+
cmd_parts += [f'NVCC="{nvcc}"']
296296

297297
if cppflags:
298-
cmd_parts += ['CPPFLAGS="%s"' % ' '.join(cppflags)]
298+
flags = ' '.join(cppflags)
299+
cmd_parts += [f'CPPFLAGS="{flags}"']
299300

300301
if cflags:
301-
cmd_parts += ['CFLAGS="%s"' % ' '.join(cflags)]
302+
flags = ' '.join(cflags)
303+
cmd_parts += [f'CFLAGS="{flags}"']
302304

303305
if cxxflags:
304-
cmd_parts += ['CXXFLAGS="%s"' % ' '.join(cxxflags)]
306+
flags = ' '.join(cxxflags)
307+
cmd_parts += [f'CXXFLAGS="{flags}"']
305308

306309
if fflags:
307-
cmd_parts += ['FCFLAGS="%s"' % ' '.join(fflags)]
310+
flags = ' '.join(fflags)
311+
cmd_parts += [f'FCFLAGS="{flags}"']
308312

309313
if ldflags:
310-
cmd_parts += ['LDFLAGS="%s"' % ' '.join(ldflags)]
314+
flags = ' '.join(ldflags)
315+
cmd_parts += [f'LDFLAGS="{flags}"']
311316

312317
if self.options:
313318
cmd_parts += self.options
@@ -384,13 +389,13 @@ class SingleSource(BuildSystem):
384389
lang = variable(str, type(None), value=None)
385390

386391
def _auto_exec_name(self):
387-
return '%s.x' % os.path.splitext(self.srcfile)[0]
392+
return os.path.splitext(self.srcfile)[0] + '.x'
388393

389394
def emit_build_commands(self, environ):
390395
if not self.srcfile:
391-
raise BuildSystemError(
392-
'a source file is required when using the %s build system' %
393-
type(self).__name__)
396+
bname = type(self).__name__
397+
raise BuildSystemError(f'a source file is required when using '
398+
f'the {bname!r} build system')
394399

395400
cc = self._cc(environ)
396401
cxx = self._cxx(environ)
@@ -527,11 +532,11 @@ def _combine_flags(self, cppflags, xflags):
527532
def emit_build_commands(self, environ):
528533
prepare_cmd = []
529534
if self.srcdir:
530-
prepare_cmd += ['cd %s' % self.srcdir]
535+
prepare_cmd += [f'cd {self.srcdir}']
531536

532537
if self.builddir:
533-
prepare_cmd += ['mkdir -p %s' % self.builddir,
534-
'cd %s' % self.builddir]
538+
prepare_cmd += [f'mkdir -p {self.builddir}',
539+
f'cd {self.builddir}']
535540

536541
cmake_cmd = ['cmake']
537542
cc = self._cc(environ)
@@ -544,28 +549,32 @@ def emit_build_commands(self, environ):
544549
fflags = self._combine_flags(cppflags, self._fflags(environ))
545550
ldflags = self._ldflags(environ)
546551
if cc:
547-
cmake_cmd += ['-DCMAKE_C_COMPILER="%s"' % cc]
552+
cmake_cmd += [f'-DCMAKE_C_COMPILER="{cc}"']
548553

549554
if cxx:
550-
cmake_cmd += ['-DCMAKE_CXX_COMPILER="%s"' % cxx]
555+
cmake_cmd += [f'-DCMAKE_CXX_COMPILER="{cxx}"']
551556

552557
if ftn:
553-
cmake_cmd += ['-DCMAKE_Fortran_COMPILER="%s"' % ftn]
558+
cmake_cmd += [f'-DCMAKE_Fortran_COMPILER="{ftn}"']
554559

555560
if nvcc:
556-
cmake_cmd += ['-DCMAKE_CUDA_COMPILER="%s"' % nvcc]
561+
cmake_cmd += [f'-DCMAKE_CUDA_COMPILER="{nvcc}"']
557562

558563
if cflags:
559-
cmake_cmd += ['-DCMAKE_C_FLAGS="%s"' % ' '.join(cflags)]
564+
flags = ' '.join(cflags)
565+
cmake_cmd += [f'-DCMAKE_C_FLAGS="{flags}"']
560566

561567
if cxxflags:
562-
cmake_cmd += ['-DCMAKE_CXX_FLAGS="%s"' % ' '.join(cxxflags)]
568+
flags = ' '.join(cxxflags)
569+
cmake_cmd += [f'-DCMAKE_CXX_FLAGS="{flags}"']
563570

564571
if fflags:
565-
cmake_cmd += ['-DCMAKE_Fortran_FLAGS="%s"' % ' '.join(fflags)]
572+
flags = ' '.join(fflags)
573+
cmake_cmd += [f'-DCMAKE_Fortran_FLAGS="{flags}"']
566574

567575
if ldflags:
568-
cmake_cmd += ['-DCMAKE_EXE_LINKER_FLAGS="%s"' % ' '.join(ldflags)]
576+
flags = ' '.join(ldflags)
577+
cmake_cmd += [f'-DCMAKE_EXE_LINKER_FLAGS="{flags}"']
569578

570579
if self.config_opts:
571580
cmake_cmd += self.config_opts
@@ -609,11 +618,11 @@ class Autotools(ConfigureBasedBuildSystem):
609618
def emit_build_commands(self, environ):
610619
prepare_cmd = []
611620
if self.srcdir:
612-
prepare_cmd += ['cd %s' % self.srcdir]
621+
prepare_cmd += [f'cd {self.srcdir}']
613622

614623
if self.builddir:
615-
prepare_cmd += ['mkdir -p %s' % self.builddir,
616-
'cd %s' % self.builddir]
624+
prepare_cmd += [f'mkdir -p {self.builddir}',
625+
f'cd {self.builddir}']
617626

618627
if self.builddir:
619628
configure_cmd = [os.path.join(
@@ -631,28 +640,33 @@ def emit_build_commands(self, environ):
631640
fflags = self._fflags(environ)
632641
ldflags = self._ldflags(environ)
633642
if cc:
634-
configure_cmd += ['CC="%s"' % cc]
643+
configure_cmd += [f'CC="{cc}"']
635644

636645
if cxx:
637-
configure_cmd += ['CXX="%s"' % cxx]
646+
configure_cmd += [f'CXX="{cxx}"']
638647

639648
if ftn:
640-
configure_cmd += ['FC="%s"' % ftn]
649+
configure_cmd += [f'FC="{ftn}"']
641650

642651
if cppflags:
643-
configure_cmd += ['CPPFLAGS="%s"' % ' '.join(cppflags)]
652+
flags = ' '.join(cppflags)
653+
configure_cmd += [f'CPPFLAGS="{flags}"']
644654

645655
if cflags:
646-
configure_cmd += ['CFLAGS="%s"' % ' '.join(cflags)]
656+
flags = ' '.join(cflags)
657+
configure_cmd += [f'CFLAGS="{flags}"']
647658

648659
if cxxflags:
649-
configure_cmd += ['CXXFLAGS="%s"' % ' '.join(cxxflags)]
660+
flags = ' '.join(cxxflags)
661+
configure_cmd += [f'CXXFLAGS="{flags}"']
650662

651663
if fflags:
652-
configure_cmd += ['FCFLAGS="%s"' % ' '.join(fflags)]
664+
flags = ' '.join(fflags)
665+
configure_cmd += [f'FCFLAGS="{flags}"']
653666

654667
if ldflags:
655-
configure_cmd += ['LDFLAGS="%s"' % ' '.join(ldflags)]
668+
flags = ' '.join(ldflags)
669+
configure_cmd += [f'LDFLAGS="{flags}"']
656670

657671
if self.config_opts:
658672
configure_cmd += self.config_opts
@@ -897,6 +911,29 @@ def prepare_cmds(self):
897911
return cmds
898912

899913

914+
class CustomBuild(BuildSystem):
915+
'''Custom build system.
916+
917+
This build system backend allows users to use custom build scripts to
918+
build the test code. It does not do any interpretation of the current test
919+
environment and it simply runs the supplied :attr:`commands`.
920+
921+
Users should use this build system with caution, because environment
922+
management, reproducibility and any potential side effects are all
923+
controlled by the user's custom build system.
924+
925+
.. versionadded:: 3.11.0
926+
'''
927+
928+
#: The commands to run for building the test code.
929+
#:
930+
#: :type: :class:`List[str]`
931+
commands = variable(typ.List[str])
932+
933+
def emit_build_commands(self, environ):
934+
return self.commands
935+
936+
900937
class BuildSystemField(fields.TypedField):
901938
def __init__(self, fieldname, *other_types):
902939
super().__init__(fieldname, BuildSystem, *other_types)
@@ -906,6 +943,6 @@ def __set__(self, obj, value):
906943
try:
907944
value = globals()[value]()
908945
except KeyError:
909-
raise ValueError('unknown build system: %s' % value) from None
946+
raise ValueError(f'unknown build system: {value}') from None
910947

911948
super().__set__(obj, value)

reframe/core/schedulers/slurm.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import glob
88
import itertools
99
import re
10+
import shlex
1011
import time
1112
from argparse import ArgumentParser
1213
from contextlib import suppress
@@ -305,6 +306,8 @@ def filternodes(self, job, nodes):
305306
# create a mutable list out of the immutable SequenceView that
306307
# sched_access is
307308
options = job.sched_access + job.options + job.cli_options
309+
options = list(itertools.chain.from_iterable(shlex.split(opt)
310+
for opt in options))
308311
option_parser = ArgumentParser()
309312
option_parser.add_argument('--reservation')
310313
option_parser.add_argument('-p', '--partition')

reframe/frontend/cli.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,14 @@ def _case_failed(t):
10371037

10381038
if options.distribute:
10391039
node_map = getallnodes(options.distribute, parsed_job_options)
1040+
# In the distribute option we need to remove the cli options that
1041+
# begin with '--nodelist' and '-w', so that we don't include them
1042+
# in the job scripts
1043+
parsed_job_options = list(
1044+
filter(lambda x: (not x.startswith('-w') and
1045+
not x.startswith('--nodelist')),
1046+
parsed_job_options)
1047+
)
10401048
testcases = distribute_tests(testcases, node_map)
10411049
testcases_all = testcases
10421050

@@ -1249,7 +1257,9 @@ def module_unuse(*paths):
12491257
success = True
12501258
if runner.stats.failed():
12511259
success = False
1252-
runner.stats.print_failure_report(printer, not options.distribute)
1260+
runner.stats.print_failure_report(
1261+
printer, not options.distribute
1262+
)
12531263
if options.failure_stats:
12541264
runner.stats.print_failure_stats(printer)
12551265

reframe/frontend/distribute_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from reframe.frontend.executors import generate_testcases
1616

1717

18-
def getallnodes(state='all', jobs_cli_options=[]):
18+
def getallnodes(state='all', jobs_cli_options=None):
1919
rt = runtime.runtime()
2020
nodes = {}
2121
for part in rt.system.partitions:

unittests/test_buildsystems.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def environ():
2525
ldflags=['-dynamic'])
2626

2727

28-
@pytest.fixture(params=['Autotools', 'CMake', 'Make', 'SingleSource'])
28+
@pytest.fixture(params=['Autotools', 'CMake',
29+
'CustomBuild', 'Make', 'SingleSource'])
2930
def build_system(request):
3031
return bs.__dict__[request.param]()
3132

@@ -127,6 +128,12 @@ def _emit_from_env_SingleSource(build_system, environ):
127128
assert expected == build_system.emit_build_commands(environ)
128129

129130

131+
def _emit_from_env_CustomBuild(build_system, environ):
132+
build_system.commands = ['./custom-configure --foo', 'make']
133+
expected = ['./custom-configure --foo', 'make']
134+
assert expected == build_system.emit_build_commands(environ)
135+
136+
130137
def _emit_from_buildsystem_Make(build_system_with_flags, environ):
131138
build_system_with_flags.makefile = 'Makefile_foo'
132139
build_system_with_flags.srcdir = 'foodir'
@@ -188,6 +195,12 @@ def _emit_from_buildsystem_SingleSource(build_system_with_flags, environ):
188195
assert expected == build_system_with_flags.emit_build_commands(environ)
189196

190197

198+
def _emit_from_buildsystem_CustomBuild(build_system_with_flags, environ):
199+
build_system_with_flags.commands = ['./custom-configure --foo', 'make']
200+
expected = ['./custom-configure --foo', 'make']
201+
assert expected == build_system_with_flags.emit_build_commands(environ)
202+
203+
191204
def _emit_no_env_defaults_Make(build_system, environ):
192205
build_system.flags_from_environ = False
193206
assert ['make -j 1'] == build_system.emit_build_commands(environ)
@@ -213,6 +226,12 @@ def _emit_no_env_defaults_SingleSource(build_system, environ):
213226
build_system.emit_build_commands(environ))
214227

215228

229+
def _emit_no_env_defaults_CustomBuild(build_system, environ):
230+
build_system.commands = ['./custom-configure --foo', 'make']
231+
expected = ['./custom-configure --foo', 'make']
232+
assert expected == build_system.emit_build_commands(environ)
233+
234+
216235
@pytest.fixture(params=['C', 'C++', 'Fortran', 'CUDA'])
217236
def lang(request):
218237
return request.param

0 commit comments

Comments
 (0)