Skip to content

Commit

Permalink
Move test logics to tests folder
Browse files Browse the repository at this point in the history
  • Loading branch information
krystophny committed Jan 19, 2024
1 parent 645141b commit 8a4ade9
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 37 deletions.
32 changes: 0 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,38 +88,6 @@ target_link_libraries(libneo
add_subdirectory(src)
add_subdirectory(tests)

## Standard tests according to standard libneo Fortran test convention.

function (add_fortran_test name)
add_test(NAME ${name} COMMAND tests/${name}.x)
set_tests_properties(${name} PROPERTIES FAIL_REGULAR_EXPRESSION "STOP")
endfunction()

add_fortran_test(test_binsrc)
add_fortran_test(test_boozer_class)
add_fortran_test(test_efit_class)
add_fortran_test(test_geqdsk_tools)
add_fortran_test(test_hdf5_tools)

## Custom tests

# This requires an additional call to test_arnoldi.py, so use the script
# instead of calling the executable directly.
# \note Maybe this could be solved with test_arnoldi.py && test_arnoldi.x.
# Afterwards fail condition is set: test will fail if the output
# contains 'STOP'.
add_test(NAME test_arnoldi
COMMAND ../tests/python_scripts/test_arnoldi.py && tests/test_arnoldi.x)
set_tests_properties(test_arnoldi PROPERTIES FAIL_REGULAR_EXPRESSION "STOP")

add_test(NAME test_mympilib
COMMAND tests/test_mympilib.x)
set_tests_properties(test_mympilib PROPERTIES PASS_REGULAR_EXPRESSION "Derived initMaster")
add_test(NAME test_system_utility
COMMAND tests/test_system_utility.x)
set_tests_properties(test_system_utility PROPERTIES FAIL_REGULAR_EXPRESSION "WARNING: resource usage could not be determined.")


# MacOS RPATH specifics
# see https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling

Expand Down
32 changes: 32 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,35 @@ target_link_libraries(test_system_utility.x

add_executable(test_util.x source/test_util.f90)
target_link_libraries(test_util.x ${COMMON_LIBS})


## Standard tests according to standard libneo Fortran test convention.

function (add_fortran_test name)
add_test(NAME ${name} COMMAND ${name}.x)
set_tests_properties(${name} PROPERTIES FAIL_REGULAR_EXPRESSION "STOP")
endfunction()

add_fortran_test(test_binsrc)
add_fortran_test(test_boozer_class)
add_fortran_test(test_efit_class)
add_fortran_test(test_geqdsk_tools)
add_fortran_test(test_hdf5_tools)

## Custom tests

# This requires an additional call to test_arnoldi.py, so use the script
# instead of calling the executable directly.
# \note Maybe this could be solved with test_arnoldi.py && test_arnoldi.x.
# Afterwards fail condition is set: test will fail if the output
# contains 'STOP'.
add_test(NAME test_arnoldi
COMMAND ../../tests/python_scripts/test_arnoldi.py && test_arnoldi.x)
set_tests_properties(test_arnoldi PROPERTIES FAIL_REGULAR_EXPRESSION "STOP")

add_test(NAME test_mympilib
COMMAND test_mympilib.x)
set_tests_properties(test_mympilib PROPERTIES PASS_REGULAR_EXPRESSION "Derived initMaster")
add_test(NAME test_system_utility
COMMAND test_system_utility.x)
set_tests_properties(test_system_utility PROPERTIES FAIL_REGULAR_EXPRESSION "WARNING: resource usage could not be determined.")
2 changes: 1 addition & 1 deletion tests/source/test_boozer_class.f90
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ program test_boozer_class
real, parameter :: tolerance = 1.0e-12
logical :: error_found = .false.

call boozer_file_orig%read_data('../tests/resources/input_boozer_file.dat')
call boozer_file_orig%read_data('../../tests/resources/input_boozer_file.dat')

call boozer_file_orig%write_data('output_boozer_file.dat')

Expand Down
2 changes: 1 addition & 1 deletion tests/source/test_efit_class.f90
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ program test_efit_class
real, parameter :: tolerance = 1.0e-12
logical :: error_found = .false.

call efit_file_orig%read_data('../tests/resources/input_efit_file.dat')
call efit_file_orig%read_data('../../tests/resources/input_efit_file.dat')

call efit_file_orig%write_data('output_efit_file.dat')

Expand Down
6 changes: 3 additions & 3 deletions tests/source/test_geqdsk_tools.f90
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ subroutine test_read_write(sucess)

type(geqdsk_t) :: geqdsk_in, geqdsk_out

character(len=*), parameter :: infilename = '../tests/resources/input_efit_file.dat', &
character(len=*), parameter :: infilename = '../../tests/resources/input_efit_file.dat', &
& outfilename = 'geqdsk_output'
integer :: file_unit, ios

Expand Down Expand Up @@ -115,7 +115,7 @@ subroutine test_classify(sucess)

type(geqdsk_t) :: geqdsk

character(len=*), parameter :: infilename = '../tests/resources/input_efit_file.dat'
character(len=*), parameter :: infilename = '../../tests/resources/input_efit_file.dat'

sucess = .false.

Expand Down Expand Up @@ -165,7 +165,7 @@ subroutine test_standardise(sucess)

type(geqdsk_t) :: geqdsk

character(len=*), parameter :: infilename = '../tests/resources/input_efit_file.dat'
character(len=*), parameter :: infilename = '../../tests/resources/input_efit_file.dat'

sucess = .false.

Expand Down
32 changes: 32 additions & 0 deletions tests/source/test_interpolate.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
program test_interpolate
use interpolate

implicit none

integer, parameter :: N_POINTS = 100
real(8), parameter :: X_MIN = 0.0d0, X_MAX = 2.0d0 * pi

real(8), dimension(N_POINTS) :: x, y, dy, d2y

call linspace(x, 0.0d0, 2.0d0 * pi, 100)

call test_interpolate_1d

contains

subroutine generate_test_data_1d(x, y, dy, d2y)
real, dimension(:), intent(in) :: x
real, dimension(:), intent(out) :: y, dy, d2y
integer :: i

y = cos(x)
dy = -sin(x)
d2y = -cos(x)

end subroutine generate_test_data_1d

subroutine test_interpolate_1d

end subroutine test_interpolate_1d

end program test_interpolate

0 comments on commit 8a4ade9

Please sign in to comment.