Path: blob/devel/elmerice/Tests/ElmerIceSolver_cmake_test_how-to.txt
3204 views
ElmerIce Solver cmake test case "How-to"1========================================2Laure Tavard / LGGE, 2016/013Adapted from ElmerSolver_cmake_test-how-to.txt (J. Kataja)45This How-to describes how to create and use test cases in software6development and case definition.78The test cases are used to check for possible bugs, and to ensure9backward compatibility. For that purpose they are currently around1039 repertories (Jan 2016) . The tests should be located in directory1112[TRUNK]/elmerice/Tests1314To run the test-cases, compile Elmer, go to the build repertory and run:15ctest -L elmerice (all Elmer/Ice tests)16ctest -L elmerice-fast (all fast Elmer/Ice tests)17ctest -L slow (all slow Elmer/Ice tests)18ctest -R <TestName> (all tests matching expression)192021B. How to create a test22=======================2324When a new feature has been verified it is often a good idea to25create a test case that ensures the feature will be maintained26also in the future versions of Elmer. To do this:27281) Create new directory in the "tests" directory under [TRUNK]/elmerice.29The folders in this directory will be automatically scanned and30tests run.31322) Define your analysis: .sif file, mesh files, F90 files &33ELMERSOLVER_STARTINFO3435In order to test a norm resulting from a solver <N>,36add those lines at the end of .sif file:37*** CODE ***38Solver N :: Reference Norm = Real <norm>39Solver N :: Reference Norm Tolerance = Real <tol>40$fprintf( stderr, "TEST CASE 1\n");41RUN42$fprintf( stderr, "END TEST CASE 1: Target NRM=<norm>,EPS=<tol>\n" );43************4445Equivalent to those lines inside the solver block to be tested4647*** CODE ***48Reference Norm = real <norm>49Reference Norm Tolerance = Real <tol>50************51523) Create CMakeLists.txt file in the test directory containing53*** CODE ***54INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/../test_macros.cmake)55CONFIGURE_FILE(<sif_name>.sif <sif_name>.sif COPYONLY)56ADD_ELMERICETEST_MODULE(<test_name> <module_name> <module_source.f90>)57FILE(COPY ELMERSOLVER_STARTINFO <file1> <file2> <directory1> ...DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/")58ADD_ELMERICE_TEST(<test_name>)59ADD_ELMERICE_LABEL(<test_name> <label>)60************61For label,62test < 10s, <label>=elmerice-fast63test > 100s, <label>=slow64654) Create runTest.cmake with66*** CODE ***67INCLUDE(${TEST_SOURCE}/../test_macros.cmake)68EXECUTE_PROCESS(COMMAND <command_name> <arg1> <arg2> ...)69RUN_ELMERICE_TEST()70************717273C. Results74============75On screen76---------77Run the tests will print some information for each test-case. For example:78Start 1: Teterousse3a791/36 Test #1: Teterousse3a .....................***Passed 503.64 sec80Start 2: Dating812/36 Test #2: Dating ...........................***Passed 2.73 sec8283In directory build/elmerice/Testing/Temporary/84----------------------------------------------85LastTest.log with all the details about the tests and86LastTestsFailed.log with the list of failed tests.878889D. How to use the test case as starting point90==============================================9192One can take these tests as a starting point or copy-paste93appropriate solver sections from there. These tests do not include94any ElmerGUI project file and therefore the graphical user interface95cannot be used to view these cases. You can look at the README.txt in96each test to see what sequence of command is usually needed.979899