-
Notifications
You must be signed in to change notification settings - Fork 342
test: add unit tests for common utilities from PR #1249 #2237
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
Merged
habajpai-amd
merged 7 commits into
develop
from
users/habajpai-amd/common-utilities-unit-tests
Dec 18, 2025
+1,441
−191
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
112456f
test: add unit tests for common utilities from PR #1249
habajpai-amd d982ede
incorporate review comments specific to tests formatting
habajpai-amd ae9dcfb
use filesystem API instead of std::system for safer cleanup
habajpai-amd 6afbbc4
Add ghc/filesystem submodule v1.5.14 for portable C++17 filesystem su…
habajpai-amd d249fe2
fix: add cmake/GhcFilesystem.cmake for CI submodule auto-checkout
habajpai-amd 4c9c5e6
incorporate review comment
habajpai-amd 31db5b9
incorporate review comment
habajpai-amd 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 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,58 @@ | ||
| # MIT License | ||
| # | ||
| # Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved. | ||
| # | ||
| # Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| # of this software and associated documentation files (the "Software"), to deal | ||
| # in the Software without restriction, including without limitation the rights | ||
| # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| # copies of the Software, and to permit persons to whom the Software is | ||
| # furnished to do so, subject to the following conditions: | ||
| # | ||
| # The above copyright notice and this permission notice shall be included in | ||
| # all copies or substantial portions of the Software. | ||
| # | ||
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| # THE SOFTWARE. | ||
|
|
||
| include_guard(GLOBAL) | ||
|
|
||
| message(STATUS "Setting up ghc::filesystem for tests") | ||
|
|
||
| include(FetchContent) | ||
|
|
||
| rocprofiler_systems_checkout_git_submodule( | ||
| RELATIVE_PATH external/filesystem | ||
| WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | ||
| TEST_FILE include/ghc/filesystem.hpp | ||
| REPO_URL https://github.com/gulrak/filesystem.git | ||
| REPO_BRANCH "v1.5.14" | ||
| ) | ||
|
|
||
| # Configure ghc/filesystem options before adding it | ||
| set(GHC_FILESYSTEM_BUILD_TESTING OFF CACHE BOOL "Disable ghc filesystem tests" FORCE) | ||
| set(GHC_FILESYSTEM_BUILD_EXAMPLES OFF CACHE BOOL "Disable ghc filesystem examples" FORCE) | ||
| set(GHC_FILESYSTEM_WITH_INSTALL OFF CACHE BOOL "Disable ghc filesystem install" FORCE) | ||
|
|
||
| # Declare ghc/filesystem from the submodule | ||
| FetchContent_Declare(ghc_filesystem SOURCE_DIR ${PROJECT_SOURCE_DIR}/external/filesystem) | ||
|
|
||
| # Make ghc/filesystem available | ||
| FetchContent_MakeAvailable(ghc_filesystem) | ||
|
|
||
| # Create interface library that wraps ghc::filesystem target | ||
| add_library(rocprofiler-systems-ghc-filesystem INTERFACE) | ||
|
|
||
| target_link_libraries(rocprofiler-systems-ghc-filesystem INTERFACE ghc_filesystem) | ||
|
|
||
| target_compile_definitions( | ||
| rocprofiler-systems-ghc-filesystem | ||
| INTERFACE ROCPROFSYS_TESTS_HAS_GHC_LIB_FILESYSTEM=1 | ||
| ) | ||
|
|
||
| message(STATUS "ghc::filesystem configured successfully using FetchContent") | ||
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
Submodule filesystem
added at
8a2edd
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
76 changes: 76 additions & 0 deletions
76
projects/rocprofiler-systems/source/lib/common/tests/filesystem.hpp
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 @@ | ||
| // MIT License | ||
| // | ||
| // Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved. | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| // of this software and associated documentation files (the "Software"), to deal | ||
| // in the Software without restriction, including without limitation the rights | ||
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| // copies of the Software, and to permit persons to whom the Software is | ||
| // furnished to do so, subject to the following conditions: | ||
| // | ||
| // The above copyright notice and this permission notice shall be included in all | ||
| // copies or substantial portions of the Software. | ||
| // | ||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| // SOFTWARE. | ||
|
|
||
| #pragma once | ||
|
|
||
| #if !defined(ROCPROFSYS_TESTS_HAS_GHC_LIB_FILESYSTEM) | ||
| # if defined __has_include | ||
| # if __has_include(<ghc/filesystem.hpp>) | ||
| # define ROCPROFSYS_TESTS_HAS_GHC_LIB_FILESYSTEM 1 | ||
| # else | ||
| # define ROCPROFSYS_TESTS_HAS_GHC_LIB_FILESYSTEM 0 | ||
| # endif | ||
| # else | ||
| # define ROCPROFSYS_TESTS_HAS_GHC_LIB_FILESYSTEM 0 | ||
| # endif | ||
| #endif | ||
|
|
||
| #if ROCPROFSYS_TESTS_HAS_GHC_LIB_FILESYSTEM == 0 | ||
| # if defined __has_include | ||
| # if __has_include(<version>) | ||
| # include <version> | ||
| # endif | ||
| # endif | ||
|
|
||
| # if defined(__cpp_lib_filesystem) | ||
| # define ROCPROFSYS_TESTS_HAS_CPP_LIB_FILESYSTEM 1 | ||
| # else | ||
| # if defined __has_include | ||
| # if __has_include(<filesystem>) | ||
| # define ROCPROFSYS_TESTS_HAS_CPP_LIB_FILESYSTEM 1 | ||
| # endif | ||
| # endif | ||
| # endif | ||
| #endif | ||
|
|
||
| #if defined(ROCPROFSYS_TESTS_HAS_GHC_LIB_FILESYSTEM) && \ | ||
| ROCPROFSYS_TESTS_HAS_GHC_LIB_FILESYSTEM > 0 | ||
| # include <ghc/filesystem.hpp> | ||
| #elif defined(ROCPROFSYS_TESTS_HAS_CPP_LIB_FILESYSTEM) && \ | ||
| ROCPROFSYS_TESTS_HAS_CPP_LIB_FILESYSTEM > 0 | ||
| # include <filesystem> | ||
| #else | ||
| # include <experimental/filesystem> | ||
| #endif | ||
|
|
||
| namespace test_common | ||
| { | ||
| #if defined(ROCPROFSYS_TESTS_HAS_GHC_LIB_FILESYSTEM) && \ | ||
| ROCPROFSYS_TESTS_HAS_GHC_LIB_FILESYSTEM > 0 | ||
| namespace fs = ::ghc::filesystem; // NOLINT(misc-unused-alias-decls) | ||
| #elif defined(ROCPROFSYS_TESTS_HAS_CPP_LIB_FILESYSTEM) && \ | ||
| ROCPROFSYS_TESTS_HAS_CPP_LIB_FILESYSTEM > 0 | ||
| namespace fs = ::std::filesystem; // NOLINT(misc-unused-alias-decls) | ||
| #else | ||
| namespace fs = ::std::experimental::filesystem; // NOLINT(misc-unused-alias-decls) | ||
| #endif | ||
| } // namespace test_common |
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.