Skip to content

Commit b985446

Browse files
rem1776rem1776
authored andcommitted
add mpp unit test scripts
1 parent c6c7eef commit b985446

10 files changed

Lines changed: 35 additions & 28 deletions

CMakeLists.txt

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,11 @@ install(
440440
### Unit Testing
441441
include(CTest)
442442

443+
# TODO set these like autotools
444+
set(MPI_LAUNCHER "mpirun")
445+
443446
# parse and add build info to test script util functions (test-lib-cmake.sh.in)
444-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test_fms/test-lib-cmake.sh.in ${CMAKE_CURRENT_SOURCE_DIR}/test_fms/test-lib.sh
447+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test_fms/test-lib.sh.in ${CMAKE_CURRENT_SOURCE_DIR}/test-lib.sh
445448
@ONLY)
446449

447450
# single test for reference
@@ -466,7 +469,7 @@ list(APPEND TEST_MODS_SRC
466469
test_fms/mpp/test_domains_utility_mod.F90
467470
test_fms/mpp/test_mpp_update_domains_int.F90
468471
test_fms/mpp/test_mpp_update_domains_real.F90
469-
test_fms/mpp/test_system_clock.F90)
472+
test_fms/mpp/test_system_clock.F90)
470473

471474

472475
add_library(testLibs "${TEST_MODS_SRC}")
@@ -488,7 +491,7 @@ foreach (testFile ${TEST_SRC})
488491
add_executable(${TName} ${testFile})
489492
# openmp/ mpi ?
490493
target_link_libraries(${TName} PUBLIC FMS::fms_r4
491-
494+
492495
PRIVATE testLibs)
493496

494497
set_target_properties(${TName} PROPERTIES Fortran_MODULE_DIRECTORY
@@ -519,12 +522,18 @@ foreach (testFile ${TEST_SRC})
519522
PRIVATE TEST_TM_KIND_=r8_kind)
520523
endforeach ()
521524

522-
# TODO find any test scripts and run them
523-
#file(GLOB_RECURSE TEST_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/test_fms/*/*.sh)
524-
#foreach (testScript ${TEST_SCRIPTS})
525-
# get_filename_component(TSName ${testScript} NAME_WE)
526-
# get_
527-
#endforeach()
525+
526+
# find any test scripts and run them
527+
file(GLOB_RECURSE TEST_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/test_fms/mpp/*.sh)
528+
#list(FILTER ${TEST_SCRIPTS} EXCLUDE REGEX "test-lib*")
529+
#list(FILTER ${TEST_SCRIPTS} EXCLUDE REGEX "tap-driver.*")
530+
531+
foreach (testScript ${TEST_SCRIPTS})
532+
get_filename_component(testName ${testScript} NAME_WE)
533+
add_test(NAME ${testName}
534+
COMMAND ${testScript}
535+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
536+
endforeach()
528537

529538

530539

test_fms/horiz_interp/test_create_xgrid_order2.F90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ program test_create_xgrid_order2
2626

2727
use horiz_interp_mod
2828
use constants_mod, only: DEG_TO_RAD
29+
use platform_mod
2930
implicit none
3031

3132
integer, parameter :: lkind = HI_TEST_KIND_

test_fms/mosaic2/test_grid2.F90

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
!! with C1 tiles where tiles 1-6 are identical. The tile points are made up with
2222
!! values that result in simple answers. See write_files module for grid details.
2323

24-
#include "write_files.inc" !> including write_files.mod because I don't know how to compile when write_files.mod is
25-
!! in a separate file.
2624
program test_mosaic
2725

2826
use mpp_mod, only : mpp_init, mpp_error, FATAL, mpp_npes, mpp_pe, mpp_root_pe

test_fms/mosaic2/test_mosaic2.F90

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
!! get_mosaic_grid_sizes, get_mosaic_contact. The subroutines are tested with
2222
!! made up C1 grids and exchange grids. See write_files mod for grid details.
2323

24-
#include "write_files.inc" !> including write_files.mod because I don't know how to compile when write_files.mod is
25-
!! in a separate file.
2624
program test_mosaic
2725

2826
use mosaic2_mod

test_fms/mpp/Makefile.am

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ check_PROGRAMS = test_mpp \
3737
test_mpp_print_memuse_stats_file \
3838
test_mpp_memutils_begin_2x \
3939
test_mpp_memutils_end_before_begin \
40-
test_read_ascii_file \
40+
test_mpp_read_ascii_file \
4141
test_read_input_nml \
4242
test_stdout \
4343
test_stderr \
@@ -87,7 +87,7 @@ test_mpp_print_memuse_stats_stderr_SOURCES = test_mpp_print_memuse_stats_stderr.
8787
test_mpp_print_memuse_stats_file_SOURCES = test_mpp_print_memuse_stats_file.F90
8888
test_mpp_memutils_begin_2x_SOURCES = test_mpp_memutils_begin_2x.F90
8989
test_mpp_memutils_end_before_begin_SOURCES = test_mpp_memutils_end_before_begin.F90
90-
test_read_ascii_file_SOURCES = test_read_ascii_file.F90
90+
test_read_ascii_file_SOURCES = test_mpp_read_ascii_file.F90
9191
test_read_input_nml_SOURCES = test_read_input_nml.F90
9292
test_stdout_SOURCES = test_stdout.F90
9393
test_stderr_SOURCES = test_stderr.F90
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
!! @author Colin Gladue
2323
!! @email gfdl.climate.model.info@noaa.gov
2424

25-
program test_read_ascii_file
25+
program test_mpp_read_ascii_file
2626

2727
use mpp_mod, only : mpp_init, mpp_init_test_peset_allocated
2828
use mpp_mod, only : mpp_error, FATAL, NOTE
@@ -111,4 +111,4 @@ program test_read_ascii_file
111111
end if
112112
end if
113113
call MPI_FINALIZE(ierr)
114-
end program test_read_ascii_file
114+
end program test_mpp_read_ascii_file

test_fms/mpp/test_read_ascii_file.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,65 +39,65 @@ test_number = <test_num>
3939
_EOF
4040

4141
touch test_numb_base_ascii.nml
42-
echo "&test_read_ascii_file_nml" > test_numb_base_ascii.nml
42+
echo "&test_mpp_read_ascii_file_nml" > test_numb_base_ascii.nml
4343
echo "test_numb = 0" >> test_numb_base_ascii.nml
4444
echo "/" >> test_numb_base_ascii.nml
4545

4646
# Test 1
4747
# Normal Usage
4848
sed "s/test_numb = [0-9]/test_numb = 1/" test_numb_base_ascii.nml>test_numb_ascii.nml
4949
test_expect_success "normal ascii usage" '
50-
mpirun -n 1 ../test_read_ascii_file
50+
mpirun -n 1 ../test_mpp_read_ascii_file
5151
'
5252

5353
# Test 2
5454
# get_ascii_file_num_lines not called before, fatal error
5555
sed "s/test_numb = [0-9]/test_numb = 2/" test_numb_base_ascii.nml>test_numb_ascii.nml
5656
test_expect_failure "failure caught if get_ascii_file_num_lines not called before" '
57-
mpirun -n 1 ../test_read_ascii_file
57+
mpirun -n 1 ../test_mpp_read_ascii_file
5858
'
5959

6060
# Test 3
6161
# File does not exist, fatal error
6262
sed "s/test_numb = [0-9]/test_numb = 3/" test_numb_base_ascii.nml>test_numb_ascii.nml
6363
test_expect_failure "failure caught if file does not exist" '
64-
mpirun -n 1 ../test_read_ascii_file
64+
mpirun -n 1 ../test_mpp_read_ascii_file
6565
'
6666

6767
# Test 4
6868
# Number of line in file is greater than size(Content(:)), fatal error
6969
sed "s/test_numb = [0-9]/test_numb = 4/" test_numb_base_ascii.nml>test_numb_ascii.nml
7070
echo "" > empty.nml
7171
test_expect_failure "failure caught from too few input lines" '
72-
mpirun -n 1 ../test_read_ascii_file
72+
mpirun -n 1 ../test_mpp_read_ascii_file
7373
'
7474
# Test 5
7575
# Length of output string is too small, fatal error
7676
sed "s/test_numb = [0-9]/test_numb = 5/" test_numb_base_ascii.nml>test_numb_ascii.nml
7777
test_expect_failure "failure caught from too small output string" '
78-
mpirun -n 1 ../test_read_ascii_file
78+
mpirun -n 1 ../test_mpp_read_ascii_file
7979
'
8080

8181
# Test 6
8282
# Number of lines in file does not equal to size(Content(:)), fatal error
8383
sed "s/test_numb = [0-9]/test_numb = 6/" test_numb_base_ascii.nml>test_numb_ascii.nml
8484
test_expect_failure "failure caught from mismatching numbers of lines" '
85-
mpirun -n 1 ../test_read_ascii_file
85+
mpirun -n 1 ../test_mpp_read_ascii_file
8686
'
8787

8888
# Test 7
8989
# Normal usage, with optional PELIST argument passed in
9090
sed "s/test_numb = [0-9]/test_numb = 7/" test_numb_base_ascii.nml>test_numb_ascii.nml
9191
test_expect_success "normal ascii usage with PELIST" '
92-
mpirun -n 1 ../test_read_ascii_file
92+
mpirun -n 1 ../test_mpp_read_ascii_file
9393
'
9494

9595
# Test 8
9696
# Normal usage, with an empty file passed in
9797
sed "s/test_numb = [0-9]/test_numb = 8/" test_numb_base_ascii.nml>test_numb_ascii.nml
9898
touch empty.nml
9999
test_expect_success "normal ascii usage with empty file" '
100-
mpirun -n 1 ../test_read_ascii_file
100+
mpirun -n 1 ../test_mpp_read_ascii_file
101101
'
102102

103103
test_done

test_fms/test-lib.sh.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
# Thank you Junio.
2727

2828
# Useful locations
29-
top_srcdir='@abs_top_srcdir@'
30-
top_buildir='@abs_top_builddir@'
29+
top_srcdir='@abs_top_srcdir@@CMAKE_CURRENT_SOURCE_DIR@'
30+
top_buildir='@abs_top_builddir@@CMAKE_CURRENT_SOURCE_DIR@'
3131

3232
TEST_NAME="$(basename "$0" .sh)"
3333
TEST_NUMBER="${TEST_NAME%%-*}"

test_fms/time_interp/test_time_interp_external.F90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ program test_time_interp_external
3838
use axis_utils2_mod, only : axis_edges
3939
use fms2_io_mod, only : FmsNetcdfFile_t, fms2_io_init, open_file, close_file, write_data, register_axis
4040
use fms2_io_mod, only : register_field, unlimited, register_variable_attribute
41+
use platform_mod
4142

4243
implicit none
4344

0 commit comments

Comments
 (0)