386 Run oomph-lib self tests in parallel.
388 Typical usage is just:
390 parallel_self_test.py
392 from within an oomph-lib directory, or
394 parallel_self_test.py -C /abs/path/to/oomph/root
399 For this script to work correctly ALL validate.sh scripts must return
400 an exit status. Use the --check-scripts option to check this.
402 Note: aborting with C-c will not work in python2 due to limitations
403 of python2's multiprocessing module. The easiest way to abort is
404 probably to kill the terminal emulator itself. Alternatively
405 background the python process with C-z then kill it (i.e. run "kill
406 %%"). Or just upgrade to python3.
411 parser = argparse.ArgumentParser(
412 description=main.__doc__,
415 formatter_class=argparse.RawDescriptionHelpFormatter,
420 '-C', dest=
'oomph_root',
421 help=
'Set the root directory of oomph-lib, by default try to extract it from a Makefile.'
425 '-a', action=
'store_true', dest=
'makeclean',
426 help=
'Run make clean on test folders before starting.'
430 '-l',
'--base-dir', action=
'append', dest=
'base_dirs',
432 help=
'Specify directories relative to the root to (recursively)'
433 +
' look for tests in.'
434 +
' Uses "demo_drivers" and "self_test" by default.'
438 '-L',
'--base-dirs-file', action=
'append', dest=
'base_dirs_files',
440 help=
'Specify files containing a list of directories relative to the root to (recursively) look for tests in. Uses "demo_drivers" and "self_test" by default.'
444 '-j',
'-n', dest=
'ncores',
445 help=
'Specifiy how many cores should be used altogether \
446 (taking mpi runs into account). By default use all cores.',
447 default=multiprocessing.cpu_count()
451 '--no-colour', action=
'store_true',
452 help=
'Disable colours in output.'
456 '--check-scripts', action=
'store_true',
457 help=
'Check all the validate.sh scripts using a simple '
458 +
'regex to make sure that they set an exit status.'
462 '--just-build', action=
'store_true',
463 help=
"Only build the tests, don't run them"
467 '--serial-mode', action=
'store_true',
468 help=
'Run the script without parallelism (for debugging'
472 args = parser.parse_args()
479 if args.oomph_root
is None:
484 if args.check_scripts:
487 print(
"Checking validate.sh scripts. Any scripts printed below do not set\n" +
488 "their exit status properly and so the results cannot be correctly\n" +
489 "reported by this script.")
490 print(
"Look in other validate scripts to see how to fix this.")
491 subp.call(
'find -name "validate.sh" | xargs grep -i -L "^exit \|^set -o errexit"',
492 shell=
True, cwd=args.oomph_root)
503 have_mpi =
"OOMPH_HAS_MPI" in \
505 "AM_CPPFLAGS", pjoin(args.oomph_root,
"Makefile"))
508 have_hlib =
"OOMPH_HAS_HLIB" in \
510 "AM_CPPFLAGS", pjoin(args.oomph_root,
"Makefile"))
518 'feature_name':
"arpack",
519 'check_driver_function': check_if_arpack_driver,
520 'have_feature': have_arpack
523 'feature_name':
"mpi",
524 'check_driver_function': check_if_mpi_driver,
525 'have_feature': have_mpi
528 'feature_name':
"hlib",
529 'check_driver_function': check_if_hlib_driver,
530 'have_feature': have_hlib,
535 print(
"\nChecked for the following features:")
536 for feature
in oomph_features:
537 print(
" ", feature[
'feature_name'],
":", feature[
'have_feature'])
541 base_dirs = args.base_dirs
544 for dirs_file_name
in args.base_dirs_files:
545 with open(dirs_file_name)
as f:
547 base_dirs = base_dirs + \
548 [l.strip()
for l
in f.readlines()
if l.strip() !=
""]
551 if len(base_dirs) == 0:
552 base_dirs = [
"demo_drivers",
"self_test"]
555 abs_base_dirs = [os.path.abspath(os.path.join(args.oomph_root, b))
558 print(
"\nLooking for validate.sh scripts in directories:")
559 pprint.pprint(abs_base_dirs)
567 print(
"Running (recursive) 'make clean' in", *abs_base_dirs)
568 for directory
in abs_base_dirs:
570 subp.check_call([
'make',
'clean',
'-k',
571 '-j',
str(args.ncores)],
572 stdout=open(os.devnull,
'w'),
579 f = pt(dispatch_dir, features=oomph_features, just_build=args.just_build)
583 test_results = list(map(f, validation_dirs))
587 with Pool(processes=
int(args.ncores))
as pool:
592 test_results = pool.map(f, validation_dirs, 1)
None print_results_summary(List[ExitCode] test_results)
Definition: parallel_self_test.py:124
def main()
Definition: parallel_self_test.py:384