From e5b32dd82d54b16d2a2fb6bf1e340f9d1f22e69e Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 3 Apr 2020 10:15:49 +0200 Subject: [PATCH] add norne and norne_parallel as ExtraTests to execute these you have to use ctest -C ExtraTests or 'make extra_test' --- CMakeLists.txt | 2 ++ compareECLFiles.cmake | 42 ++++++++++++++++++++++++++++++++++++++++++ tests/run-test.sh | 21 +++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100755 tests/run-test.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f62d7538..8d934caf4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -352,6 +352,8 @@ if (OPM_ENABLE_PYTHON) add_subdirectory(python) endif() +add_custom_target(extra_test ${CMAKE_CTEST_COMMAND} -C ExtraTests) + # must link libraries after target 'flow' has been defined if(CUDA_FOUND) target_link_libraries( opmsimulators PUBLIC ${CUDA_cusparse_LIBRARY} ) diff --git a/compareECLFiles.cmake b/compareECLFiles.cmake index e639abf51..e2c9e0289 100755 --- a/compareECLFiles.cmake +++ b/compareECLFiles.cmake @@ -11,6 +11,35 @@ # Define some paths set(BASE_RESULT_PATH ${PROJECT_BINARY_DIR}/tests/results) +########################################################################### +# TEST: runSim +########################################################################### + +# Input: +# - casename: basename (no extension) +# +# Details: +# - This test class simply runs a simulation. +function(add_test_runSimulator) + set(oneValueArgs CASENAME FILENAME SIMULATOR DIR DIR_PREFIX PROCS) + set(multiValueArgs TEST_ARGS) + cmake_parse_arguments(PARAM "$" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + if(NOT PARAM_DIR) + set(PARAM_DIR ${PARAM_CASENAME}) + endif() + set(RESULT_PATH ${BASE_RESULT_PATH}${PARAM_DIR_PREFIX}/${PARAM_SIMULATOR}+${PARAM_CASENAME}) + set(TEST_ARGS ${OPM_TESTS_ROOT}/${PARAM_DIR}/${PARAM_FILENAME} ${PARAM_TEST_ARGS}) + opm_add_test(runSimulator/${PARAM_CASENAME} NO_COMPILE + EXE_NAME ${PARAM_SIMULATOR} + DRIVER_ARGS ${OPM_TESTS_ROOT}/${PARAM_DIR} + ${RESULT_PATH} + ${PROJECT_BINARY_DIR}/bin + ${PARAM_FILENAME} + ${PARAM_PROCS} + TEST_ARGS ${TEST_ARGS} + CONFIGURATION extra) +endfunction() + ########################################################################### # TEST: compareECLFiles ########################################################################### @@ -142,6 +171,19 @@ if(NOT TARGET test-suite) add_custom_target(test-suite) endif() +# Simple execution tests +opm_set_test_driver(${PROJECT_SOURCE_DIR}/tests/run-test.sh "") +add_test_runSimulator(CASENAME norne + FILENAME NORNE_ATW2013 + SIMULATOR flow + PROCS 1) + +add_test_runSimulator(CASENAME norne_parallel + FILENAME NORNE_ATW2013 + SIMULATOR flow + DIR norne + PROCS 4) + # Regression tests opm_set_test_driver(${PROJECT_SOURCE_DIR}/tests/run-regressionTest.sh "") diff --git a/tests/run-test.sh b/tests/run-test.sh new file mode 100755 index 000000000..9b79476d2 --- /dev/null +++ b/tests/run-test.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# This simply runs a simulator. + +INPUT_DATA_PATH="$1" +RESULT_PATH="$2" +BINPATH="$3" +EXE_NAME="$4" +FILENAME="$5" +MPI_PROCS="$6" +shift 7 +TEST_ARGS="$@" + +mkdir -p ${RESULT_PATH} +if (( ${MPI_PROCS} > 1)) +then + mpirun -np ${MPI_PROCS} ${BINPATH}/${EXE_NAME} ${TEST_ARGS} --output-dir=${RESULT_PATH} +else + ${BINPATH}/${EXE_NAME} ${TEST_ARGS} --output-dir=${RESULT_PATH} +fi +test $? -eq 0 || exit 1