Compadre  1.3.3
Compadre_UnitTests.cpp
Go to the documentation of this file.
1 #include <gtest/gtest.h>
3 #include "unittests/test_XYZ.hpp"
4 #include "unittests/test_NeighborLists.hpp"
5 #include "unittests/test_PointCloudSearch.hpp"
6 #include "unittests/test_LinearAlgebra.hpp"
7 #ifdef COMPADRE_USE_MPI
8 #include <mpi.h>
9 #endif
10 
11 #define ASSERT_NO_DEATH(statement) \
12 ASSERT_EXIT({{ statement } ::exit(EXIT_SUCCESS); }, ::testing::ExitedWithCode(0), "")
13 
14 //
15 // KokkosParser tests go here because they modify the Kokkos backend
16 //
17 TEST (KokkosInitialize, NoArgsGiven) {
18  Kokkos::InitArguments args;
20  // default constructor is hidden for KokkosParser
21  // but still visible from this test
22  auto kp = Compadre::KokkosParser(false);
23  kp.finalize();
24  });
25 }
26 TEST (KokkosInitialize, NoCommandLineArgsGiven) {
28  std::vector<std::string> arguments = {"--kokkos-threads=4"};
29  auto kp = KokkosParser(arguments);
30  kp.finalize();
31  });
32 }
33 
34 
35 // this provides main(),
36 // but all other tests come from ./unittests/*.cpp
37 int main(int argc, char **argv) {
38 
39  // initializes MPI (if available) with command line arguments given
40  #ifdef COMPADRE_USE_MPI
41  MPI_Init(&argc, &argv);
42  #endif
43 
44  ::testing::InitGoogleTest(&argc, argv);
45  ::testing::GTEST_FLAG(filter) = "Kokkos*";
46  int sig = RUN_ALL_TESTS();
47 
48  // initializes kokkos
49  auto kp = KokkosParser(argc, argv, true);
50 
51  // execute all tests
52  ::testing::GTEST_FLAG(filter) = "-Kokkos*";
53  sig &= RUN_ALL_TESTS();
54 
55  // finalize Kokkos and MPI (if available)
56  kp.finalize();
57 
58  // finialize MPI (if available)
59  #ifdef COMPADRE_USE_MPI
60  MPI_Finalize();
61  #endif
62  return sig;
63 }
Class handling Kokkos command line arguments and returning parameters.
int main(int argc, char **argv)
#define ASSERT_NO_DEATH(statement)
TEST(KokkosInitialize, NoArgsGiven)