-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[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
Open
ro-i
wants to merge
5
commits into
main
Choose a base branch
from
users/ro-i/check-libomp-unit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,22 @@ | ||
| # -*- Python -*- | ||
|
|
||
| # Configuration file for the 'lit' test runner. | ||
|
|
||
| import os | ||
| import subprocess | ||
|
|
||
| import lit.formats | ||
|
|
||
| # name: The name of this test suite. | ||
| config.name = "OpenMP-Unit" | ||
|
|
||
| # suffixes: A list of file extensions to treat as test files. | ||
| config.suffixes = [] | ||
|
|
||
| # test_source_root: The root path where tests are located. | ||
| # test_exec_root: The root path where tests should be run. | ||
| config.test_exec_root = config.openmp_unittests_dir | ||
| config.test_source_root = config.test_exec_root | ||
|
|
||
| # testFormat: The test format to use to interpret tests. | ||
| config.test_format = lit.formats.GoogleTest(config.llvm_build_mode, "Tests") |
This file contains hidden or 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,8 @@ | ||
| @AUTO_GEN_COMMENT@ | ||
|
|
||
| config.openmp_unittests_dir = "@CMAKE_CURRENT_BINARY_DIR@/../unittests" | ||
| config.llvm_build_mode = lit_config.substitute("@LLVM_BUILD_MODE@") | ||
|
|
||
| # Let the main config do the real work. | ||
| lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/../test/Unit/lit.cfg.py") | ||
|
|
This file contains hidden or 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,76 @@ | ||
| add_custom_target(OpenMPUnitTests) | ||
| set_target_properties(OpenMPUnitTests PROPERTIES FOLDER "OpenMP/Tests") | ||
|
|
||
| if(WIN32 OR STUBS_LIBRARY) | ||
| message(WARNING "OpenMP unittests disabled due to stub library or Windows") | ||
| return() | ||
| endif() | ||
|
|
||
| # Build a testing version of libomp that exports all symbols for unit tests. | ||
| # This library uses the same compiled objects as libomp, but with all symbols | ||
| # exported to allow testing internal functions. | ||
|
|
||
| libomp_get_ldflags(LIBOMP_TEST_LDFLAGS) | ||
| libomp_get_libflags(LIBOMP_TEST_LIBFLAGS) | ||
| # Replace the libomp exports with the test exports exporting all symbols. | ||
| if(LIBOMP_HAVE_VERSION_SCRIPT_FLAG) | ||
| string(REPLACE "${LIBOMP_SRC_DIR}/exports_so.txt" | ||
| "${LIBOMP_SRC_DIR}/exports_test_so.txt" | ||
| LIBOMP_TEST_LDFLAGS "${LIBOMP_TEST_LDFLAGS}") | ||
| endif() | ||
| # Duplicate setting of LIBOMP_LINKER_LANGUAGE to match libomp. | ||
| if(NOT ${LIBOMP_USE_STDCPPLIB}) | ||
| set(LIBOMP_LINKER_LANGUAGE C) | ||
| set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES) | ||
| else() | ||
| set(LIBOMP_LINKER_LANGUAGE CXX) | ||
| endif() | ||
|
|
||
| # Create the testing library from the same objects as libomp. | ||
| add_library(omp_testing SHARED $<TARGET_OBJECTS:obj.omp>) | ||
| set_property(TARGET omp_testing PROPERTY FOLDER "OpenMP/Libraries") | ||
| 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}" | ||
| LINK_FLAGS "${LIBOMP_TEST_LDFLAGS}" | ||
| LINKER_LANGUAGE ${LIBOMP_LINKER_LANGUAGE} | ||
| EXCLUDE_FROM_ALL TRUE # Don't build by default, only when tests need it | ||
| ) | ||
| target_include_directories(omp_testing PUBLIC | ||
| ${LIBOMP_INCLUDE_DIR} | ||
| ${LIBOMP_SRC_DIR} | ||
| ) | ||
|
|
||
| # Make the targets default_gtest and default_gtest_main available. | ||
| build_gtest() | ||
|
|
||
| function(add_openmp_unittest test_name) | ||
| add_unittest(OpenMPUnitTests ${test_name} ${ARGN}) | ||
|
|
||
| # Link against the testing library which exports all symbols. | ||
| target_link_libraries(${test_name} PRIVATE omp_testing) | ||
|
|
||
| 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 () | ||
| endfunction() | ||
|
|
||
| configure_lit_site_cfg( | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/../test/Unit/lit.site.cfg.py.in | ||
| ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py | ||
| MAIN_CONFIG | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/../test/Unit/lit.cfg.py | ||
| ) | ||
|
|
||
| add_openmp_testsuite( | ||
| check-libomp-unit | ||
| "Running libomp unit tests" | ||
| ${CMAKE_CURRENT_BINARY_DIR} | ||
| EXCLUDE_FROM_CHECK_ALL | ||
| DEPENDS OpenMPUnitTests | ||
| ) | ||
|
|
||
| add_subdirectory(String) |
This file contains hidden or 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,9 @@ | ||
| # libomp Unit Tests | ||
|
|
||
| Usage: | ||
| ``` | ||
| cd <your-llvm-build-directory>/runtimes/runtimes-bins | ||
| ninja check-libomp-unit | ||
| ``` | ||
|
|
||
| Note: unit tests are currently not supported on Windows |
This file contains hidden or 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,3 @@ | ||
| add_openmp_unittest(StringTests | ||
| TestKmpStr.cpp | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.