Skip to content

Commit e185f72

Browse files
committed
Separate main for HPX tests
1 parent 545e0fb commit e185f72

File tree

3 files changed

+64
-3
lines changed

3 files changed

+64
-3
lines changed

tests/backends/HPX/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ set(PLSSVM_HPX_TEST_SOURCES
1515
)
1616

1717
# add test executable
18-
add_executable(${PLSSVM_HPX_TEST_NAME} ${CMAKE_CURRENT_LIST_DIR}/../../main.cpp ${PLSSVM_HPX_TEST_SOURCES})
18+
add_executable(${PLSSVM_HPX_TEST_NAME} ${CMAKE_CURRENT_LIST_DIR}/../../hpx_main.cpp ${PLSSVM_HPX_TEST_SOURCES})
1919

2020
# link against test library
2121
target_link_libraries(${PLSSVM_HPX_TEST_NAME} PRIVATE ${PLSSVM_BASE_TEST_LIBRARY_NAME})

tests/hpx_main.cpp

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
* @file
3+
* @author Alexander Van Craen
4+
* @author Marcel Breyer
5+
* @copyright 2018-today The PLSSVM project - All Rights Reserved
6+
* @license This file is part of the PLSSVM project which is released under the MIT license.
7+
* See the LICENSE.md file in the project root for full license information.
8+
*
9+
* @brief Contains the googletest main function. Sets the DeathTest to "threadsafe" execution instead of "fast".
10+
*/
11+
12+
#include "plssvm/environment.hpp" // plssvm::environment::scope_guard
13+
14+
#include "gtest/gtest.h" // RUN_ALL_TESTS, ::testing::{InitGoogleTest, GTEST_FLAG},GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST definitions
15+
16+
#include <cstdlib> // std::atexit
17+
18+
// Workaround as Scope Guard not working properly with Google Test
19+
// Run the entire main function in HPX runtime
20+
#include <hpx/hpx_main.hpp>
21+
22+
// silence GTest warnings/test errors
23+
24+
// generic CSVM tests
25+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GenericCSVM);
26+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GenericCSVMKernelFunction);
27+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GenericCSVMSolver);
28+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GenericCSVMSolverKernelFunction);
29+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GenericCSVMKernelFunctionClassification);
30+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GenericCSVMSolverKernelFunctionClassification);
31+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GenericCSVMDeathTest);
32+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GenericCSVMSolverDeathTest);
33+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GenericCSVMKernelFunctionDeathTest);
34+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GenericCSVMSolverKernelFunctionDeathTest);
35+
// generic GPU CSVM tests
36+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GenericGPUCSVM);
37+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GenericGPUCSVMKernelFunction);
38+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GenericGPUCSVMDeathTest);
39+
// pinned memory tests
40+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(PinnedMemory);
41+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(PinnedMemoryLayout);
42+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(PinnedMemoryDeathTest);
43+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(PinnedMemoryLayoutDeathTest);
44+
// device pointer tests
45+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DevicePtr);
46+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DevicePtrLayout);
47+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DevicePtrDeathTest);
48+
// exception tests
49+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(Exception);
50+
51+
int main(int argc, char **argv) {
52+
::testing::InitGoogleTest(&argc, argv);
53+
54+
// prevent problems with fork() in the presence of multiple threads
55+
// https://github.com/google/googletest/blob/main/docs/advanced.md#death-tests-and-threads
56+
// NOTE: may reduce performance of the (death) tests
57+
#if !defined(_WIN32)
58+
::testing::GTEST_FLAG(death_test_style) = "threadsafe";
59+
#endif
60+
return RUN_ALL_TESTS();
61+
}

tests/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
#if defined(PLSSVM_HAS_HPX_BACKEND)
1919
// Workaround as Scope Guard not working properly with Google Test
20-
// Run the entire main function in HPX rutime
21-
#include <hpx/hpx_main.hpp>
20+
// Run the entire main function in HPX runtime
21+
//#include <hpx/hpx_main.hpp>
2222
#endif
2323

2424
// silence GTest warnings/test errors

0 commit comments

Comments
 (0)