Skip to content

Commit

Permalink
Make tests more convenient to run (#26)
Browse files Browse the repository at this point in the history
* Enable CMake testing

* Update docs

* Transform IBM tests to gtest

* Tweak DPStokes test tolerance

* Add missing include

* Add lanczos gtests

* fix cmakelists
  • Loading branch information
RaulPPelaez authored Dec 21, 2023
1 parent 4e13030 commit 716a529
Show file tree
Hide file tree
Showing 11 changed files with 273 additions and 300 deletions.
7 changes: 4 additions & 3 deletions docs/Tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ Tests

The folder "test" in the main UAMMD repository contains test scripts for the different solvers. Mostly these consist on a bash script accompanied by a readme and an UAMMD code reproducing a certain known solution. The test script will typically generate messages stating the result of the tests in addition to some figures that can be inspected to evaluate the correctness of the solver.

In order to run them simply go into the folder of a certain test and run :code:`bash test.bash`. Note that these tests can typically take a lot of time, as averaging is required. Check the test script for a certain solver for more information and customization. You may have to tweak the Makefiles. Finally, test scripts usually include the possibility of using many GPUs.
In order to run them go into the folder of a certain test and run :code:`bash test.bash`. Note that these tests can typically take a lot of time, as averaging is required. Check the test script for a certain solver for more information and customization. You may have to tweak the Makefiles. Finally, test scripts usually include the possibility of using many GPUs.

Recent Unit Tests are written using `GTest <https://google.github.io/googletest/primer.html>`. In these instances a CMakeLists.txt file is present. To compile and run the tests use the standard steps:
Recent Unit Tests are written using `GTest <https://google.github.io/googletest/primer.html>`_. In these instances a CMakeLists.txt file is present. To compile and run the tests use the standard steps:

.. code:: bash
mkdir build && cd build
cmake ..
#Solve any dependency issues raised by CMake
make
make test
Note that some tests are stochastic in nature and can thus fail intermittently. Typically rerunning these tests solves the issue.
2 changes: 1 addition & 1 deletion src/misc/IBM.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ REFERENCES:
#include "IBM.cu"
#include "IBM_utils.cuh"
#include "utils/Grid.cuh"

#include "third_party/type_names.h"
namespace uammd{
namespace IBM_ns{
struct LinearIndex3D{
Expand Down
18 changes: 9 additions & 9 deletions test/BDHI/DPStokes/dpstokes_test.cu
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ TEST(DPStokes, ReproducesOpenBoundarySelfMobilityWithLargeDomainSlitChannel){
force[0] = {1,1,1};
auto mf = dpstokes->Mdot(pos.data().get(), force.data().get(), 1);
real3 disp = mf[0];
ASSERT_THAT(disp.x, ::testing::DoubleNear(1.0, 1e-2));
ASSERT_THAT(disp.y, ::testing::DoubleNear(1.0, 1e-2));
ASSERT_THAT(disp.z, ::testing::DoubleNear(1.0, 1e-2));
ASSERT_THAT(disp.x, ::testing::DoubleNear(1.0, 0.1));
ASSERT_THAT(disp.y, ::testing::DoubleNear(1.0, 0.1));
ASSERT_THAT(disp.z, ::testing::DoubleNear(1.0, 0.1));
}

TEST(DPStokes, ReproducesOpenBoundarySelfMobilityWithLargeDomainBottomWall){
Expand All @@ -120,9 +120,9 @@ TEST(DPStokes, ReproducesOpenBoundarySelfMobilityWithLargeDomainBottomWall){
force[0] = {1,1,1};
auto mf = dpstokes->Mdot(pos.data().get(), force.data().get(), 1);
real3 disp = mf[0];
ASSERT_THAT(disp.x, ::testing::DoubleNear(1.0, 1e-2));
ASSERT_THAT(disp.y, ::testing::DoubleNear(1.0, 1e-2));
ASSERT_THAT(disp.z, ::testing::DoubleNear(1.0, 1e-2));
ASSERT_THAT(disp.x, ::testing::DoubleNear(1.0, 0.1));
ASSERT_THAT(disp.y, ::testing::DoubleNear(1.0, 0.1));
ASSERT_THAT(disp.z, ::testing::DoubleNear(1.0, 0.1));
}

TEST(DPStokes, ReproducesOpenBoundarySelfMobilityWithLargeDomainOpen){
Expand All @@ -138,9 +138,9 @@ TEST(DPStokes, ReproducesOpenBoundarySelfMobilityWithLargeDomainOpen){
force[0] = {1,1,1};
auto mf = dpstokes->Mdot(pos.data().get(), force.data().get(), 1);
real3 disp = mf[0];
ASSERT_THAT(disp.x, ::testing::DoubleNear(1.0, 1e-2));
ASSERT_THAT(disp.y, ::testing::DoubleNear(1.0, 1e-2));
ASSERT_THAT(disp.z, ::testing::DoubleNear(1.0, 1e-2));
ASSERT_THAT(disp.x, ::testing::DoubleNear(1.0, 0.1));
ASSERT_THAT(disp.y, ::testing::DoubleNear(1.0, 0.1));
ASSERT_THAT(disp.z, ::testing::DoubleNear(1.0, 0.1));
}

//TESTS for the Integrator start here
Expand Down
5 changes: 4 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@ FetchContent_Declare(
GIT_TAG release-1.12.1
)
FetchContent_MakeAvailable(googletest)

enable_testing()
include(CTest)
add_subdirectory(BDHI/DPStokes)
add_subdirectory(BDHI/FCM)
add_subdirectory(BDHI/quasi2D)
add_subdirectory(utils)
add_subdirectory(misc/chebyshev)
add_subdirectory(misc/ibm)
add_subdirectory(misc/lanczos)

IF (CMAKE_BUILD_TYPE MATCHES "Debug")
if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
Expand Down
10 changes: 10 additions & 0 deletions test/misc/ibm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
add_executable(ibm test_ibm.cu)
target_include_directories(ibm PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties(ibm PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
target_link_libraries(
ibm
GTest::gtest_main
GTest::gmock_main
)
include(GoogleTest)
gtest_discover_tests(ibm)
25 changes: 0 additions & 25 deletions test/misc/ibm/Makefile

This file was deleted.

150 changes: 0 additions & 150 deletions test/misc/ibm/ibm.cu

This file was deleted.

Loading

0 comments on commit 716a529

Please sign in to comment.