From 5c2cc1d91dae7bd56745d4198a5436673f0decb4 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 20 Jul 2023 21:13:57 +0200 Subject: [PATCH 1/3] include Fortran test suite --- .gitlab-ci.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 25ffbc0f1..abfd3e1cf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -85,6 +85,37 @@ mypy: ################################################################################################### +unittest_GNU_DEBUG: + stage: compile + script: + - module load ${COMPILER_GNU} ${MPI_GNU} ${PETSC_GNU} + - TMPDIR=$(mktemp -d) + - cmake -B ${TMPDIR} -DDAMASK_SOLVER=test -DCMAKE_INSTALL_PREFIX=${TMPDIR} -DCMAKE_BUILD_TYPE=RELEASE + - cmake --build ${TMPDIR} --target install + - cd ${TMPDIR} + - ./bin/DAMASK_test + +unittest_GNU_RELEASE: + stage: compile + script: + - module load ${COMPILER_GNU} ${MPI_GNU} ${PETSC_GNU} + - TMPDIR=$(mktemp -d) + - cmake -B ${TMPDIR} -DDAMASK_SOLVER=test -DCMAKE_INSTALL_PREFIX=${TMPDIR} -DCMAKE_BUILD_TYPE=RELEASE + - cmake --build ${TMPDIR} --target install + - cd ${TMPDIR} + - ./bin/DAMASK_test + +unittest_GNU_PERFORMANCE: + stage: compile + script: + - module load ${COMPILER_GNU} ${MPI_GNU} ${PETSC_GNU} + - TMPDIR=$(mktemp -d) + - cmake -B ${TMPDIR} -DDAMASK_SOLVER=test -DCMAKE_INSTALL_PREFIX=${TMPDIR} -DCMAKE_BUILD_TYPE=PERFORMANCE + - cmake --build ${TMPDIR} --target install + - cd ${TMPDIR} + - ./bin/DAMASK_test + + grid_GNU: stage: compile script: From 8da3736d42a78080f0be559236703ca16abe9ae7 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 20 Jul 2023 21:16:31 +0200 Subject: [PATCH 2/3] extending test suite --- src/crystal.f90 | 7 ++++--- src/tables.f90 | 9 +++++---- src/test/DAMASK_test.f90 | 19 +++++++++++++++++-- src/test/test_HDF5_utilities.f90 | 14 ++++++-------- src/test/test_crystal.f90 | 17 +++++++++++++++++ src/test/test_prec.f90 | 8 +++----- src/test/test_tables.f90 | 17 +++++++++++++++++ 7 files changed, 69 insertions(+), 22 deletions(-) create mode 100644 src/test/test_crystal.f90 create mode 100644 src/test/test_tables.f90 diff --git a/src/crystal.f90 b/src/crystal.f90 index 724949180..ae460a811 100644 --- a/src/crystal.f90 +++ b/src/crystal.f90 @@ -377,6 +377,7 @@ module crystal public :: & crystal_init, & + crystal_selfTest, & crystal_isotropic_nu, & crystal_isotropic_mu, & crystal_symmetrize_33, & @@ -412,7 +413,7 @@ subroutine crystal_init() print'(/,1x,a)', '<<<+- crystal init -+>>>'; flush(IO_STDOUT) - call selfTest() + call crystal_selfTest() end subroutine crystal_init @@ -2226,7 +2227,7 @@ end function crystal_isotropic_mu !-------------------------------------------------------------------------------------------------- !> @brief Check correctness of some crystal functions. !-------------------------------------------------------------------------------------------------- -subroutine selfTest +subroutine crystal_selfTest real(pREAL), dimension(:,:,:), allocatable :: CoSy real(pREAL), dimension(:,:), allocatable :: system @@ -2333,6 +2334,6 @@ subroutine selfTest if (dNeq(crystal_isotropic_nu(C,'isostress','cF'), crystal_isotropic_nu(C,'isostress'), 1.0e-12_pREAL)) & error stop 'isotropic_nu/isostress/cF-tI' -end subroutine selfTest +end subroutine crystal_selfTest end module crystal diff --git a/src/tables.f90 b/src/tables.f90 index 65bd7e514..c067492d3 100644 --- a/src/tables.f90 +++ b/src/tables.f90 @@ -25,7 +25,8 @@ module tables public :: & table, & - tables_init + tables_init, & + tables_selfTest contains @@ -37,7 +38,7 @@ subroutine tables_init() print'(/,1x,a)', '<<<+- tables init -+>>>'; flush(IO_STDOUT) - call selfTest() + call tables_selfTest() end subroutine tables_init @@ -106,7 +107,7 @@ end function eval !-------------------------------------------------------------------------------------------------- !> @brief Check correctness of table functionality. !-------------------------------------------------------------------------------------------------- -subroutine selfTest() +subroutine tables_selfTest() type(tTable) :: t real(pREAL), dimension(*), parameter :: & @@ -140,6 +141,6 @@ subroutine selfTest() if (dNeq(y_true(i),t%at(x_eval(i)))) error stop 'table eval/dict' end do -end subroutine selfTest +end subroutine tables_selfTest end module tables diff --git a/src/test/DAMASK_test.f90 b/src/test/DAMASK_test.f90 index 34c1dc88a..8460a9fab 100644 --- a/src/test/DAMASK_test.f90 +++ b/src/test/DAMASK_test.f90 @@ -1,15 +1,30 @@ program DAMASK_test + use parallelization use HDF5_utilities use test_prec + use test_tables + use test_crystal use test_HDF5_utilities - call prec_test() + print('(/,a)'), 'begin test prec' + call test_prec_run() + print('(a)'), 'begin test prec' + + print('(/,a)'), 'begin test tables' + call test_tables_run() + print('(a)'), 'end test tables' + + print('(/,a)'), 'begin test crystal' + call test_crystal_run() + print('(a)'), 'end test crystal' call parallelization_init() call HDF5_utilities_init() - call HDF5_utilities_test() + print('(/,a)'), 'begin test HDF5_utilities' + call test_HDF5_utilities_run() + print('(a)'), 'begin test HDF5_utilities' end program DAMASK_test diff --git a/src/test/test_HDF5_utilities.f90 b/src/test/test_HDF5_utilities.f90 index 94e4175ce..fb43de8e2 100644 --- a/src/test/test_HDF5_utilities.f90 +++ b/src/test/test_HDF5_utilities.f90 @@ -6,20 +6,18 @@ module test_HDF5_utilities implicit none(type,external) private - public :: HDF5_utilities_test + public :: test_HDF5_utilities_run contains -subroutine HDF5_utilities_test() +subroutine test_HDF5_utilities_run() - print*, 'begin test HDF5_utilities' - call test_read_write() - print*, 'end test HDF5_utilities' + call read_write() -end subroutine HDF5_utilities_test +end subroutine test_HDF5_utilities_run -subroutine test_read_write() +subroutine read_write() integer(HID_T) :: f real(pREAL), dimension(3) :: d_in,d_out @@ -34,6 +32,6 @@ subroutine test_read_write() if (any(d_in /= d_out)) error stop 'test_read_write' -end subroutine test_read_write +end subroutine read_write end module test_HDF5_utilities diff --git a/src/test/test_crystal.f90 b/src/test/test_crystal.f90 new file mode 100644 index 000000000..4bb4d8a1e --- /dev/null +++ b/src/test/test_crystal.f90 @@ -0,0 +1,17 @@ +module test_crystal + use crystal + + implicit none(type,external) + + private + public :: test_crystal_run + + contains + +subroutine test_crystal_run() + + call crystal_selfTest() + +end subroutine test_crystal_run + +end module test_crystal diff --git a/src/test/test_prec.f90 b/src/test/test_prec.f90 index fa18d01a1..8aab59817 100644 --- a/src/test/test_prec.f90 +++ b/src/test/test_prec.f90 @@ -4,16 +4,14 @@ module test_prec implicit none(type,external) private - public :: prec_test + public :: test_prec_run contains -subroutine prec_test() +subroutine test_prec_run() - print*, 'begin test prec' call prec_selfTest() - print*, 'end test prec' -end subroutine prec_test +end subroutine test_prec_run end module test_prec diff --git a/src/test/test_tables.f90 b/src/test/test_tables.f90 new file mode 100644 index 000000000..5a66c23d0 --- /dev/null +++ b/src/test/test_tables.f90 @@ -0,0 +1,17 @@ +module test_tables + use tables + + implicit none(type,external) + + private + public :: test_tables_run + + contains + +subroutine test_tables_run() + + call tables_selfTest() + +end subroutine test_tables_run + +end module test_tables From 289dceb5842a4663f4041b5035a7fea7d862b96b Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 21 Jul 2023 11:46:21 +0200 Subject: [PATCH 3/3] simple coverage report --- .gitlab-ci.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index abfd3e1cf..5a1b0e700 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -90,30 +90,33 @@ unittest_GNU_DEBUG: script: - module load ${COMPILER_GNU} ${MPI_GNU} ${PETSC_GNU} - TMPDIR=$(mktemp -d) - - cmake -B ${TMPDIR} -DDAMASK_SOLVER=test -DCMAKE_INSTALL_PREFIX=${TMPDIR} -DCMAKE_BUILD_TYPE=RELEASE + - cmake -B ${TMPDIR} -DDAMASK_SOLVER=test -DCMAKE_INSTALL_PREFIX=${TMPDIR} -DCMAKE_BUILD_TYPE=RELEASE -DBUILDCMD_POST=-coverage - cmake --build ${TMPDIR} --target install - cd ${TMPDIR} - ./bin/DAMASK_test + - find -name \*.gcda | xargs gcov unittest_GNU_RELEASE: stage: compile script: - module load ${COMPILER_GNU} ${MPI_GNU} ${PETSC_GNU} - TMPDIR=$(mktemp -d) - - cmake -B ${TMPDIR} -DDAMASK_SOLVER=test -DCMAKE_INSTALL_PREFIX=${TMPDIR} -DCMAKE_BUILD_TYPE=RELEASE + - cmake -B ${TMPDIR} -DDAMASK_SOLVER=test -DCMAKE_INSTALL_PREFIX=${TMPDIR} -DCMAKE_BUILD_TYPE=RELEASE -DBUILDCMD_POST=-coverage - cmake --build ${TMPDIR} --target install - cd ${TMPDIR} - ./bin/DAMASK_test + - find -name \*.gcda | xargs gcov unittest_GNU_PERFORMANCE: stage: compile script: - module load ${COMPILER_GNU} ${MPI_GNU} ${PETSC_GNU} - TMPDIR=$(mktemp -d) - - cmake -B ${TMPDIR} -DDAMASK_SOLVER=test -DCMAKE_INSTALL_PREFIX=${TMPDIR} -DCMAKE_BUILD_TYPE=PERFORMANCE + - cmake -B ${TMPDIR} -DDAMASK_SOLVER=test -DCMAKE_INSTALL_PREFIX=${TMPDIR} -DCMAKE_BUILD_TYPE=PERFORMANCE -DBUILDCMD_POST=-coverage - cmake --build ${TMPDIR} --target install - cd ${TMPDIR} - ./bin/DAMASK_test + - find -name \*.gcda | xargs gcov grid_GNU: