-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[OpenMP] Add libomp unit test infrastructure #168063
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
base: main
Are you sure you want to change the base?
Conversation
4c9e176 to
c801cb4
Compare
2f30670 to
b12ff59
Compare
shiltian
left a comment
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.
LGTM in geenral.
| set_target_properties(OpenMPUnitTests PROPERTIES FOLDER "OpenMP/Tests") | ||
|
|
||
| if(WIN32 OR STUBS_LIBRARY) | ||
| message(WARNING "OpenMP unittests disabled due to stub library or Windows") |
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.
Any reason this doesn't work on Windows?
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.
I don't think so. But since the CMake changes are already complicated enough to review and test as they are, I thought it might be best to get things working first and then add something like the Windows support in a follow-up
Co-authored-by: Shilei Tian <[email protected]>
jplehr
left a comment
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.
+1 for adding unit tests here!
| target_link_libraries(omp_testing PUBLIC default_gtest) | ||
| target_link_libraries(omp_testing PUBLIC ${LIBOMP_TEST_LIBFLAGS} ${LIBOMP_DL_LIBS}) | ||
| set_target_properties(omp_testing PROPERTIES | ||
| PREFIX "" SUFFIX "" OUTPUT_NAME "libomp_testing${LIBOMP_LIBRARY_SUFFIX}" |
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.
| PREFIX "" SUFFIX "" OUTPUT_NAME "libomp_testing${LIBOMP_LIBRARY_SUFFIX}" | |
| PREFIX "" | |
| SUFFIX "" | |
| OUTPUT_NAME "libomp_testing${LIBOMP_LIBRARY_SUFFIX}" |
Why override SUFFIX/PREFIX? Would
PREFIX ""
SUFFIX "${LIBOMP_LIBRARY_SUFFIX}"
get the same result?
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.
I just used
llvm-project/openmp/runtime/src/CMakeLists.txt
Lines 233 to 237 in a3b7989
| set_target_properties(omp PROPERTIES | |
| PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_LIB_FILE}" | |
| LINK_FLAGS "${LIBOMP_CONFIGURED_LDFLAGS}" | |
| LINKER_LANGUAGE ${LIBOMP_LINKER_LANGUAGE} | |
| ) |
| PREFIX "" SUFFIX "" OUTPUT_NAME "libomp_testing${LIBOMP_LIBRARY_SUFFIX}" | ||
| LINK_FLAGS "${LIBOMP_TEST_LDFLAGS}" | ||
| LINKER_LANGUAGE ${LIBOMP_LINKER_LANGUAGE} | ||
| EXCLUDE_FROM_ALL TRUE # Don't build by default, only when tests need it |
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.
| EXCLUDE_FROM_ALL TRUE # Don't build by default, only when tests need it |
EXCLUDE_FROM_ALL can be also just part of add_library:
add_library(omp_testing ... EXCLUDE_FROM_ALL)
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.
add_library(omp_testing SHARED $<TARGET_OBJECTS:obj.omp> EXCLUDE_FROM_ALL)
whould lead to
CMake Error at .../llvm-project/openmp/runtime/unittests/CMakeLists.txt:17 (add_library):
Cannot find source file:
EXCLUDE_FROM_ALL
CMake Error at .../llvm-project/openmp/runtime/unittests/CMakeLists.txt:17 (add_library):
No SOURCES given to target: omp_testing
tho
| if(TARGET default_gtest) | ||
| target_link_libraries(${test_name} PRIVATE default_gtest_main default_gtest) | ||
| else () | ||
| target_link_libraries(${test_name} PRIVATE llvm_gtest_main llvm_gtest) | ||
| 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.
[not a change request] default_gtest exists to make this switch unnecessary. I assume you have it here for standalone builds?
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.
I used what you used in your PR you linked previously: https://github.com/llvm/llvm-project/pull/164794/changes#diff-f60dae8e82f67fa5e534e9ea566430d5b79f36119020865dc37b95d9a3635c5e
(The tests in
TestKmpStr.cppare an automatically generated POC to make sure things work.)