@@ -509,37 +509,63 @@ endfunction()
509509
510510###------------------------------------------------------------------ Framework Tests
511511# Testing the whole framework: pre_exodus, 4C, and post-filter
512- # Usage in tests/lists_of_tests.cmake: "four_c_test_framework(<name_of_input_file> <num_proc> <xml_filename>)"
513- # <name_of_input_file>: must equal the name of a .e/.bc/.head file in directory tests/framework-test
514- # <num_proc>: number of processors the test should use
515- # <xml_filename>: copy any xml-file to the build directory. May also be ""
516- function (four_c_test_framework name_of_input_file num_proc xml_filename)
512+ #
513+ # Usage in tests/lists_of_tests.cmake:
514+ #
515+ # four_c_test_framework(PREFIX <prefix> NP <NP> [COPY_FILES <file1> <file2> ...])"
516+ #
517+ # PREFIX: must equal the name of a .e/.bc/.head file in directory tests/framework-test
518+ # NP: number of MPI ranks for this test
519+ # COPY_FILES: copy any additional files to the test directory
520+ function (four_c_test_framework)
521+ set (options "" )
522+ set (oneValueArgs PREFIX NP)
523+ set (multiValueArgs COPY_FILES)
524+ cmake_parse_arguments (
525+ _parsed
526+ "${options} "
527+ "${oneValueArgs} "
528+ "${multiValueArgs} "
529+ ${ARGN}
530+ )
531+
532+ # validate input arguments
533+ if (DEFINED _parsed_UNPARSED_ARGUMENTS)
534+ message (FATAL_ERROR "There are unparsed arguments: ${_parsed_UNPARSED_ARGUMENTS} !" )
535+ endif ()
536+
537+ set (name_of_input_file ${_parsed_PREFIX} )
538+ set (num_proc ${_parsed_NP} )
517539 set (name_of_test ${name_of_input_file} -p${num_proc} -fw)
518540 set (test_directory framework_test_output/${name_of_input_file} )
519541
520- set (RUNPREEXODUS
542+ set (_run_pre_exodus
521543 ${FOUR_C_ENABLE_ADDRESS_SANITIZER_TEST_OPTIONS} \ ./pre_exodus\ --exo=${PROJECT_SOURCE_DIR} /tests/framework -test /${name_of_input_file} .e\ --bc=${PROJECT_SOURCE_DIR} /tests/framework -test /${name_of_input_file} .bc\ --head=${PROJECT_SOURCE_DIR} /tests/framework -test /${name_of_input_file} .head\ --out=${test_directory} /xxx.4C.yaml
522544 ) # pre_exodus is run to generate an input file
523545
524- if (NOT ${xml_filename} STREQUAL "" )
525- # if a XML file name is given, it is copied from the 4C input directory to the build directory
526- set (RUNCOPYXML
527- "cp ${PROJECT_SOURCE_DIR} /tests/input_files/${xml_filename} ./${test_directory} /"
528- )
546+ # copy additional files to the test directory
547+ if (_parsed_COPY_FILES)
548+ foreach (_file_name IN LISTS _parsed_COPY_FILES)
549+ if (NOT EXISTS ${_file_name} )
550+ message (FATAL_ERROR "File ${_file_name} does not exist!" )
551+ endif ()
552+ list (APPEND _run_copy_files "cp ${_file_name} ${test_directory} " )
553+ endforeach ()
554+ list (JOIN _run_copy_files " && " _run_copy_files)
529555 else ()
530556 # no-op command to do nothing
531- set (RUNCOPYXML : )
557+ set (_run_copy_files ":" )
532558 endif ()
533559
534- set (RUNFOURC
560+ set (_run_4C
535561 ${MPIEXEC_EXECUTABLE} \ ${MPIEXEC_EXTRA_OPTS_FOR_TESTING} \ -np\ ${num_proc} \ $<TARGET_FILE:${FOUR_C_EXECUTABLE_NAME} >\ ${test_directory} /xxx.4C.yaml\ ${test_directory} /xxx
536562 ) # 4C is run using the generated input file
537563
538564 add_test (
539565 NAME ${name_of_test}
540566 COMMAND
541567 bash -c
542- "mkdir -p ${PROJECT_BINARY_DIR} /${test_directory} && ${RUNCOPYXML } && ${RUNPREEXODUS } && ${RUNFOURC } "
568+ "mkdir -p ${PROJECT_BINARY_DIR} /${test_directory} && ${_run_copy_files } && ${_run_pre_exodus } && ${_run_4C } "
543569 )
544570
545571 require_fixture(${name_of_test} test_cleanup)
0 commit comments