Skip to content

Commit

Permalink
Merge pull request #45 from bhourahine/buildTesting
Browse files Browse the repository at this point in the history
Build testing
  • Loading branch information
bhourahine authored May 8, 2022
2 parents d2062d2 + 0adfd6d commit c6605c4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ endif()
include(GNUInstallDirs)

add_subdirectory(lib)
if(NOT BUILD_EXPORTED_TARGETS_ONLY)
include(CTest) # note: this adds a BUILD_TESTING which defaults to ON
if(BUILD_TESTING)
enable_testing()
add_subdirectory(test)
endif()
Expand Down
9 changes: 6 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@ You can influence the configuration via CMake-variables, which are listed in
`config.cmake <config.cmake>`_. You can either modify the values directly there
or pass them as command line options at the configuration phase, e.g.::

FC=ifort cmake -B _build -DBUILD_LIBRARY_ONLY=True
FC=ifort cmake -B _build -DBUILD_TESTING=NO .

Testing
-------

A few tests / usage examples can be found in the `test/` subdirectory. The
compiled test programs will be in the `test/` subfolder of your build directory.
A few tests / usage examples can be found in the `test/` subdirectory,
a sub-set of which can be checked with ctest. The compiled test
programs will be in the `test/` subfolder of your build directory.

To disable building tests, include the cmake option -DBUILD_TESTING=OFF


Using the library
Expand Down
18 changes: 9 additions & 9 deletions test/test_allgather.f90
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ program test_allgather
write(formstr, "(A,I0,A)") "A,", size(recv1), "(1X,I0))"
write(*, label // formstr) 2, mycomm%rank, "Recv1 buffer:", recv1(:)
if (sum(recv1) /= mycomm%size * (mycomm%size-1)) then
tPassed = .false.
isPassed = .false.
else
tPassed = .true.
isPassed = .true.
end if
call testReturn(mycomm, tPassed)
call testReturn(mycomm, isPassed)
deallocate(recv1)

! I1 -> I1
Expand All @@ -42,11 +42,11 @@ program test_allgather
write(formstr, "(A,I0,A)") "A,", size(recv1), "(1X,I0))"
write(*, label // formstr) 4, mycomm%rank, "Recv1 buffer:", recv1
if (sum(recv1) /= mycomm%size**2) then
tPassed = .false.
isPassed = .false.
else
tPassed = .true.
isPassed = .true.
end if
call testReturn(mycomm, tPassed)
call testReturn(mycomm, isPassed)

! I1 -> I2
allocate(recv2(size(send1), mycomm%size))
Expand All @@ -58,11 +58,11 @@ program test_allgather
write(formstr, "(A,I0,A)") "A,", size(recv2), "(1X,I0))"
write(*, label // formstr) 6, mycomm%rank, "Recv2 buffer:", recv2
if (sum(recv1) /= mycomm%size**2) then
tPassed = .false.
isPassed = .false.
else
tPassed = .true.
isPassed = .true.
end if
call testReturn(mycomm, tPassed)
call testReturn(mycomm, isPassed)

call mpifx_finalize()

Expand Down

0 comments on commit c6605c4

Please sign in to comment.