-
Notifications
You must be signed in to change notification settings - Fork 236
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
[gtest] Combine gtests into single binary. #2599
Changes from 31 commits
faac072
ad3e487
645e289
f094cc9
85e64f8
47ee6e0
457d265
3dc71ef
c3229b8
532c75f
3e9d843
9c45745
1f87519
89f4782
b0d705d
f529d95
0f54296
a6cbc3b
c67f69e
8ac0916
f68938d
d912f17
7711895
d13348e
48a16ba
ce6a22c
aeaa83f
9b8cfa4
eb3812c
1e7c6fc
6d4e0e5
5c88612
ed002f5
7132297
a13243f
fed0b7c
b2eeb23
a719d15
cfdd95c
996e342
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
* SOFTWARE. | ||
* | ||
*******************************************************************************/ | ||
#include <gtest/gtest.h> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚓ |
||
#include "conv_common.hpp" | ||
|
||
template <class T> | ||
|
@@ -58,3 +59,19 @@ struct conv3d_driver : conv_driver<T> | |
this->add(this->out_layout, "out_layout", this->generate_data({"NCDHW"})); | ||
} | ||
}; | ||
|
||
class Conv3dFloat : public testing::TestWithParam<std::vector<std::string>> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are all these class definitions exactly the same? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They are ostensibly configuration definitions split by precision. Though in this instance their data is defined entirely by the test fetching function and as such have no defined members at this level. It's conceivable that they could be summarized into a single class. |
||
{ | ||
}; | ||
|
||
class Conv3dHalf : public testing::TestWithParam<std::vector<std::string>> | ||
{ | ||
}; | ||
|
||
class Conv3dBFloat16 : public testing::TestWithParam<std::vector<std::string>> | ||
{ | ||
}; | ||
|
||
class Conv3dInt8 : public testing::TestWithParam<std::vector<std::string>> | ||
{ | ||
}; | ||
Comment on lines
+67
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These definitions are used by gtests only and should reside in gtest/*.cpp files within respective namespaces. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,36 +7,34 @@ set(SOURCES | |
) | ||
|
||
if(MIOPEN_BACKEND_OPENCL) | ||
set(SKIP_TESTS dumpTensorTest) | ||
set(SKIP_TESTS dumpTensorTest.cpp) | ||
endif() | ||
|
||
function(add_gtest TEST_NAME) | ||
if( NOT (TEST_NAME IN_LIST SKIP_TESTS)) | ||
message("Adding Test: " ${TEST_NAME}) | ||
add_executable(test_${TEST_NAME} ${TEST_NAME}.cpp ${SOURCES}) | ||
if(WIN32) | ||
target_compile_definitions(test_${TEST_NAME} PRIVATE NOMINMAX) | ||
endif() | ||
add_dependencies(tests test_${TEST_NAME}) | ||
add_dependencies(check test_${TEST_NAME}) | ||
target_compile_options(test_${TEST_NAME} PRIVATE -Wno-global-constructors -Wno-undef) | ||
target_include_directories(test_${TEST_NAME} PRIVATE ../ ../../src/kernels) | ||
if(MIOPEN_ENABLE_AI_KERNEL_TUNING) | ||
target_link_libraries(test_${TEST_NAME} frugally-deep::fdeep Eigen3::Eigen) | ||
endif() | ||
target_link_libraries(test_${TEST_NAME} GTest::gtest GTest::gtest_main MIOpen ${Boost_LIBRARIES} hip::host $<BUILD_INTERFACE:roc::rocblas>) | ||
if(NOT MIOPEN_EMBED_DB STREQUAL "") | ||
target_link_libraries(test_${TEST_NAME} $<BUILD_INTERFACE:miopen_data>) | ||
endif() | ||
if(NOT WIN32) # TODO: cannot run on Windows due to missing DLL dependencies | ||
# Enable CMake to discover the test binary | ||
gtest_discover_tests(test_${TEST_NAME} PROPERTIES ENVIRONMENT "MIOPEN_USER_DB_PATH=${CMAKE_CURRENT_BINARY_DIR};MIOPEN_TEST_FLOAT_ARG=${MIOPEN_TEST_FLOAT_ARG};MIOPEN_TEST_ALL=${MIOPEN_TEST_ALL};MIOPEN_TEST_MLIR=${MIOPEN_TEST_MLIR};MIOPEN_TEST_COMPOSABLEKERNEL=${MIOPEN_TEST_COMPOSABLEKERNEL};CODECOV_TEST=${CODECOV_TEST}") | ||
endif() | ||
|
||
if(WIN32) | ||
# Refer to https://en.cppreference.com/w/cpp/language/types for details. | ||
target_compile_options(test_${TEST_NAME} PRIVATE $<BUILD_INTERFACE:$<$<CXX_COMPILER_ID:Clang>:-U__LP64__>>) | ||
endif() | ||
function(add_gtest TEST_NAME TEST_CPP) | ||
message("Adding Test: " ${TEST_NAME} " : " ${TEST_CPP}) | ||
add_executable(${TEST_NAME} ${TEST_CPP} ${SOURCES}) | ||
if(WIN32) | ||
target_compile_definitions(${TEST_NAME} PRIVATE NOMINMAX) | ||
endif() | ||
add_dependencies(tests ${TEST_NAME}) | ||
add_dependencies(check ${TEST_NAME}) | ||
target_compile_options(${TEST_NAME} PRIVATE -Wno-global-constructors -Wno-undef) | ||
target_include_directories(${TEST_NAME} PRIVATE ../ ../../src/kernels) | ||
if(MIOPEN_ENABLE_AI_KERNEL_TUNING) | ||
target_link_libraries(${TEST_NAME} frugally-deep::fdeep Eigen3::Eigen) | ||
endif() | ||
target_link_libraries(${TEST_NAME} GTest::gtest GTest::gtest_main MIOpen ${Boost_LIBRARIES} hip::host $<BUILD_INTERFACE:roc::rocblas>) | ||
if(NOT MIOPEN_EMBED_DB STREQUAL "") | ||
target_link_libraries(${TEST_NAME} $<BUILD_INTERFACE:miopen_data>) | ||
endif() | ||
if(NOT WIN32) # TODO: cannot run on Windows due to missing DLL dependencies | ||
# Enable CMake to discover the test binary | ||
gtest_discover_tests(${TEST_NAME} PROPERTIES ENVIRONMENT "MIOPEN_USER_DB_PATH=${CMAKE_CURRENT_BINARY_DIR};MIOPEN_TEST_FLOAT_ARG=${MIOPEN_TEST_FLOAT_ARG};MIOPEN_TEST_ALL=${MIOPEN_TEST_ALL};MIOPEN_TEST_MLIR=${MIOPEN_TEST_MLIR};MIOPEN_TEST_COMPOSABLEKERNEL=${MIOPEN_TEST_COMPOSABLEKERNEL};CODECOV_TEST=${CODECOV_TEST};MIOPEN_TEST_DBSYNC=${MIOPEN_TEST_DBSYNC}") | ||
endif() | ||
|
||
if(WIN32) | ||
# Refer to https://en.cppreference.com/w/cpp/language/types for details. | ||
target_compile_options(${TEST_NAME} PRIVATE $<BUILD_INTERFACE:$<$<CXX_COMPILER_ID:Clang>:-U__LP64__>>) | ||
endif() | ||
endfunction() | ||
|
||
|
@@ -46,7 +44,29 @@ foreach(SOURCE ${SOURCES}) | |
list(REMOVE_ITEM TESTS ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE}) | ||
endforeach() | ||
|
||
foreach(TEST ${TESTS}) | ||
get_filename_component(BASE_NAME ${TEST} NAME_WE) | ||
add_gtest(${BASE_NAME}) | ||
foreach(SOURCE ${SKIP_TESTS}) | ||
list(REMOVE_ITEM TESTS ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE}) | ||
endforeach() | ||
|
||
if( DISCRETE_GTEST ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this flag "ON" by default or "OFF"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Undefined maps to false. So default is false here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please check the PR description for updated info on this. |
||
foreach(TEST ${TESTS}) | ||
get_filename_component(BASE_NAME ${TEST} NAME_WE) | ||
add_gtest(test_${BASE_NAME} ${BASE_NAME}.cpp) | ||
endforeach() | ||
|
||
else() | ||
foreach(TEST ${TESTS}) | ||
get_filename_component(BASE_NAME ${TEST} NAME) | ||
list(APPEND TESTS_CPP ${BASE_NAME}) | ||
endforeach() | ||
|
||
add_gtest(miopen_gtest "${TESTS_CPP}") | ||
|
||
if( NOT ENABLE_ASAN_PACKAGING ) | ||
install(TARGETS miopen_gtest | ||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE | ||
DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
endif() | ||
endif() | ||
|
||
|
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.
Renaming of .cpp to .hpp silently removes
test_*
executable, and, consequently,test_* --all
from full tests etc.