Skip to content

Commit

Permalink
Complete support for Gtest.
Browse files Browse the repository at this point in the history
  • Loading branch information
neoblizz committed Feb 3, 2023
1 parent e51b617 commit c8feba9
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@

# Build directory
build/

# Externals directory
externals/
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,5 @@ option(HELLO_HIP_BUILD_TESTS
# Subdirectories for examples, testing and documentation
if(HELLO_HIP_BUILD_TESTS)
include(${PROJECT_SOURCE_DIR}/cmake/FetchGoogleTest.cmake)
# add_subdirectory(unittests)
add_subdirectory(unittests)
endif(HELLO_HIP_BUILD_TESTS)
28 changes: 28 additions & 0 deletions unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# begin /* Add unit tests */
set(UNITTEST_SOURCES
hello_test.cxx
)

foreach(SOURCE IN LISTS UNITTEST_SOURCES)
set_source_files_properties(${SOURCE}
PROPERTIES
LANGUAGE HIP
)
get_filename_component(TEST_NAME ${SOURCE} NAME_WLE)
add_executable(${TEST_NAME} ${SOURCE})
target_link_libraries(${TEST_NAME}
PRIVATE hello_hip
PRIVATE gtest::main
)

set_target_properties(${TEST_NAME}
PROPERTIES
CXX_STANDARD 17
HIP_STANDARD 17
HIP_ARCHITECTURES ${CMAKE_HIP_ARCHITECTURES}
)

add_test(NAME test_${TEST_NAME} COMMAND ${TEST_NAME})
message(STATUS "Unit Test Added: ${TEST_NAME}")
endforeach()
# end /* Add unit tests */
6 changes: 6 additions & 0 deletions unittests/hello_test.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "hello_hip.hxx"
#include "gtest/gtest.h"

TEST(HIP, HelloWorld) {
EXPECT_EQ(1, 1);
}

0 comments on commit c8feba9

Please sign in to comment.