-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sl/google test #1611
Merged
Merged
Sl/google test #1611
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ec5fe42
Adding GoogleTest to Test framework
81b73f7
Added cache.cpp test to GoogleTest, to reduce duplicated code
9254c80
Add cache test to GoogleTest
8f1216e
LWPTUNA-53-1: Moved Cache.cpp and updated with googletest TEST()
7e5303d
Clean up gtest/CMakeLists.txt
1f0d964
PR#1611: Refactored activation test with GoogleTest
4f8ab4b
Added new include directories to eliminate the dependancy of specifiy…
0639314
Resolve Target not found CMake error on roc::rocblas
12a2a3e
Test if activation.cpp warning is causing CPPcheck failure in Hip Tidy
1a8dda4
Fix Cppcheck warnings
8419573
Bumped CMake ver from 3.5 to 3.11+ to support FetechContent
a59b507
Force docker to rebuild with changes to Jenkinsfile; will revert shor…
5d1413a
Revert the workaround in Jenkinsfile to force rebuild docker
7a65517
PR:1611 clean up Docerfile and Jenkinsfile
030457b
revert the changes that is meant for PR1628
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
include(FetchContent) | ||
|
||
set(GOOGLETEST_DIR "" CACHE STRING "Location of local GoogleTest repo to build against") | ||
|
||
if(GOOGLETEST_DIR) | ||
set(FETCHCONTENT_SOURCE_DIR_GOOGLETEST ${GOOGLETEST_DIR} CACHE STRING "GoogleTest source directory override") | ||
endif() | ||
|
||
message(STATUS "Fetching GoogleTest") | ||
|
||
list(APPEND GTEST_CMAKE_CXX_FLAGS | ||
-Wno-undef | ||
-Wno-reserved-identifier | ||
-Wno-global-constructors | ||
-Wno-missing-noreturn | ||
-Wno-disabled-macro-expansion | ||
-Wno-used-but-marked-unused | ||
-Wno-switch-enum | ||
-Wno-zero-as-null-pointer-constant | ||
-Wno-unused-member-function | ||
-Wno-comma | ||
-Wno-old-style-cast | ||
) | ||
message(STATUS "Suppressing googltest warnings with flags: ${GTEST_CMAKE_CXX_FLAGS}") | ||
|
||
FetchContent_Declare( | ||
googletest | ||
GIT_REPOSITORY https://github.com/google/googletest.git | ||
GIT_TAG e2239ee6043f73722e7aa812a459f54a28552929 | ||
) | ||
xinlipn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Will be necessary for windows build | ||
# set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
FetchContent_MakeAvailable(googletest) | ||
|
||
target_compile_options(gtest PRIVATE ${GTEST_CMAKE_CXX_FLAGS}) | ||
target_compile_options(gtest_main PRIVATE ${GTEST_CMAKE_CXX_FLAGS}) | ||
target_compile_options(gmock PRIVATE ${GTEST_CMAKE_CXX_FLAGS}) | ||
target_compile_options(gmock_main PRIVATE ${GTEST_CMAKE_CXX_FLAGS}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
include(googletest) #include googletest.cmake | ||
enable_testing() | ||
include(GoogleTest) | ||
|
||
#add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C ${CMAKE_CFG_INTDIR}) | ||
#add_custom_target(tests) | ||
|
||
find_package(rocblas) | ||
|
||
function(add_gtest TEST_NAME) | ||
message("Adding Test: " ${TEST_NAME}) | ||
add_executable(test_${TEST_NAME} ${TEST_NAME}.cpp ) | ||
add_dependencies(tests test_${TEST_NAME}) | ||
add_dependencies(check test_${TEST_NAME}) | ||
target_compile_options(test_${TEST_NAME} PRIVATE -Wno-global-constructors -Wno-undef) | ||
JehandadKhan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
target_link_libraries(test_${TEST_NAME} gtest_main MIOpen ${Boost_LIBRARIES} hip::host $<BUILD_INTERFACE:roc::rocblas>) | ||
#Enable CMake to discover the test binary | ||
gtest_discover_tests(test_${TEST_NAME}) | ||
endfunction() | ||
|
||
file(GLOB TESTS *.cpp) | ||
foreach(TEST ${TESTS}) | ||
get_filename_component(BASE_NAME ${TEST} NAME_WE) | ||
add_gtest(${BASE_NAME}) | ||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <gtest/gtest.h> | ||
#include <miopen/miopen.h> | ||
#include <miopen/solver_id.hpp> | ||
|
||
// Demonstrate some basic assertions. | ||
TEST(HelloTest, BasicAssertions) | ||
{ | ||
|
||
// Expect two strings not to be equal. | ||
EXPECT_STRNE("hello", "world"); | ||
// Expect equality. | ||
EXPECT_EQ(7 * 6, 42); | ||
|
||
// Check if we can access MIOpen internals | ||
auto idx = 0; | ||
for(const auto& solver_id : | ||
miopen::solver::GetSolversByPrimitive(miopen::solver::Primitive::Convolution)) | ||
{ | ||
std::ignore = solver_id; | ||
++idx; | ||
} | ||
EXPECT_GT(idx, 0); | ||
xinlipn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ubuntu 18.04 has cmake 3.10. Would this potentially cause a problem if releasing team build from source? (I see in our own docker file we have installed 3.15, so where is 3.11 coming from?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @junliume , 3.11 is the minimal version that supports FetchContent. If Docker is used on Ubuntu 18.04, I believe the following changes in Dockerfile should cover the lower cMake version issue.
wget --no-check-certificate -qO - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add - &&
sh -c "echo deb https://apt.kitware.com/ubuntu/ bionic main | tee -a /etc/apt/sources.list" && \