Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/elmerice/Tests/ElmerIceSolver_cmake_test_how-to.txt
3204 views
1
ElmerIce Solver cmake test case "How-to"
2
========================================
3
Laure Tavard / LGGE, 2016/01
4
Adapted from ElmerSolver_cmake_test-how-to.txt (J. Kataja)
5
6
This How-to describes how to create and use test cases in software
7
development and case definition.
8
9
The test cases are used to check for possible bugs, and to ensure
10
backward compatibility. For that purpose they are currently around
11
39 repertories (Jan 2016) . The tests should be located in directory
12
13
[TRUNK]/elmerice/Tests
14
15
To run the test-cases, compile Elmer, go to the build repertory and run:
16
ctest -L elmerice (all Elmer/Ice tests)
17
ctest -L elmerice-fast (all fast Elmer/Ice tests)
18
ctest -L slow (all slow Elmer/Ice tests)
19
ctest -R <TestName> (all tests matching expression)
20
21
22
B. How to create a test
23
=======================
24
25
When a new feature has been verified it is often a good idea to
26
create a test case that ensures the feature will be maintained
27
also in the future versions of Elmer. To do this:
28
29
1) Create new directory in the "tests" directory under [TRUNK]/elmerice.
30
The folders in this directory will be automatically scanned and
31
tests run.
32
33
2) Define your analysis: .sif file, mesh files, F90 files &
34
ELMERSOLVER_STARTINFO
35
36
In order to test a norm resulting from a solver <N>,
37
add those lines at the end of .sif file:
38
*** CODE ***
39
Solver N :: Reference Norm = Real <norm>
40
Solver N :: Reference Norm Tolerance = Real <tol>
41
$fprintf( stderr, "TEST CASE 1\n");
42
RUN
43
$fprintf( stderr, "END TEST CASE 1: Target NRM=<norm>,EPS=<tol>\n" );
44
************
45
46
Equivalent to those lines inside the solver block to be tested
47
48
*** CODE ***
49
Reference Norm = real <norm>
50
Reference Norm Tolerance = Real <tol>
51
************
52
53
3) Create CMakeLists.txt file in the test directory containing
54
*** CODE ***
55
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/../test_macros.cmake)
56
CONFIGURE_FILE(<sif_name>.sif <sif_name>.sif COPYONLY)
57
ADD_ELMERICETEST_MODULE(<test_name> <module_name> <module_source.f90>)
58
FILE(COPY ELMERSOLVER_STARTINFO <file1> <file2> <directory1> ...DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/")
59
ADD_ELMERICE_TEST(<test_name>)
60
ADD_ELMERICE_LABEL(<test_name> <label>)
61
************
62
For label,
63
test < 10s, <label>=elmerice-fast
64
test > 100s, <label>=slow
65
66
4) Create runTest.cmake with
67
*** CODE ***
68
INCLUDE(${TEST_SOURCE}/../test_macros.cmake)
69
EXECUTE_PROCESS(COMMAND <command_name> <arg1> <arg2> ...)
70
RUN_ELMERICE_TEST()
71
************
72
73
74
C. Results
75
============
76
On screen
77
---------
78
Run the tests will print some information for each test-case. For example:
79
Start 1: Teterousse3a
80
1/36 Test #1: Teterousse3a .....................***Passed 503.64 sec
81
Start 2: Dating
82
2/36 Test #2: Dating ...........................***Passed 2.73 sec
83
84
In directory build/elmerice/Testing/Temporary/
85
----------------------------------------------
86
LastTest.log with all the details about the tests and
87
LastTestsFailed.log with the list of failed tests.
88
89
90
D. How to use the test case as starting point
91
==============================================
92
93
One can take these tests as a starting point or copy-paste
94
appropriate solver sections from there. These tests do not include
95
any ElmerGUI project file and therefore the graphical user interface
96
cannot be used to view these cases. You can look at the README.txt in
97
each test to see what sequence of command is usually needed.
98
99