-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add sanitizer profiles and validation tests #918
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
niteshpurohit
wants to merge
4
commits into
feat/test-deterministic-time-entropy
from
feat/sanitizer-profiles
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6b30f18
feat: add sanitizer profiles and validation tests
niteshpurohit 18d0494
feat: enhance sanitizer configurations and tests
niteshpurohit 8e0acc7
feat: enhance sanitizer validation logic
niteshpurohit fdacafe
feat: enhance sanitizer profiles and validation tests
niteshpurohit 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
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
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,30 @@ | ||
| # SPDX-License-Identifier: AGPL-3.0-only | ||
| if(NOT DEFINED EXECUTABLE OR NOT DEFINED EXPECTED) | ||
| message(FATAL_ERROR "Laghu sanitizer fixture expectation requires EXECUTABLE and EXPECTED") | ||
| endif() | ||
|
|
||
| set(command "${CMAKE_COMMAND}" -E env) | ||
| foreach(environment IN ITEMS "${ENVIRONMENT_1}" "${ENVIRONMENT_2}") | ||
| if(NOT environment STREQUAL "") | ||
| list(APPEND command "${environment}") | ||
| endif() | ||
| endforeach() | ||
| list(APPEND command "${EXECUTABLE}") | ||
| execute_process(COMMAND ${command} | ||
| RESULT_VARIABLE result | ||
| OUTPUT_VARIABLE output | ||
| ERROR_VARIABLE diagnostics) | ||
| set(combined "${output}${diagnostics}") | ||
| if(result EQUAL 0) | ||
| message(FATAL_ERROR "Laghu sanitizer fixture expectation failed: fixture=${EXPECTED}; result=success") | ||
| endif() | ||
| if(EXPECTED STREQUAL "heap_misuse" AND | ||
| NOT combined MATCHES "ERROR: AddressSanitizer: heap-buffer-overflow") | ||
| message(FATAL_ERROR "Laghu sanitizer fixture expectation failed: fixture=heap_misuse; report=missing_heap_buffer_overflow") | ||
| elseif(EXPECTED STREQUAL "undefined_behavior" AND | ||
| NOT combined MATCHES "runtime error: signed integer overflow") | ||
| message(FATAL_ERROR "Laghu sanitizer fixture expectation failed: fixture=undefined_behavior; report=missing_undefined_sanitizer") | ||
| elseif(EXPECTED STREQUAL "data_race" AND | ||
| NOT combined MATCHES "WARNING: ThreadSanitizer: data race") | ||
| message(FATAL_ERROR "Laghu sanitizer fixture expectation failed: fixture=data_race; report=missing_data_race") | ||
| endif() |
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,27 @@ | ||
| # SPDX-License-Identifier: AGPL-3.0-only | ||
| if(NOT DEFINED BUILD_DIRECTORY OR NOT DEFINED MARKER_ARTIFACT OR NOT DEFINED MARKER OR | ||
| NOT DEFINED MARKER_PREFIX OR NOT DEFINED MARKER_TARGET OR NOT DEFINED NM) | ||
| message(FATAL_ERROR "Laghu sanitizer marker rejection requires BUILD_DIRECTORY MARKER_ARTIFACT MARKER MARKER_PREFIX MARKER_TARGET and NM") | ||
| endif() | ||
|
|
||
| execute_process( | ||
| COMMAND "${CMAKE_COMMAND}" | ||
| "-DBUILD_DIRECTORY=${BUILD_DIRECTORY}" | ||
| "-DARCHIVE=${MARKER_ARTIFACT}" | ||
| "-DEXECUTABLE=${MARKER_ARTIFACT}" | ||
| "-DNM=${NM}" | ||
| "-DMARKER_ARTIFACT=${MARKER_ARTIFACT}" | ||
| "-DMARKER=${MARKER}" | ||
| "-DMARKER_PREFIX=${MARKER_PREFIX}" | ||
| "-DMARKER_TARGET=${MARKER_TARGET}" | ||
| -P "${CMAKE_CURRENT_LIST_DIR}/ExpectSanitizerReleaseExclusion.cmake" | ||
| RESULT_VARIABLE result | ||
| OUTPUT_VARIABLE output | ||
| ERROR_VARIABLE diagnostics) | ||
| if(result EQUAL 0) | ||
| message(FATAL_ERROR "Laghu sanitizer marker rejection failed: marker=${MARKER}; rejection=missing") | ||
| endif() | ||
| set(combined "${output}${diagnostics}") | ||
| if(NOT combined MATCHES "test_symbol=present") | ||
| message(FATAL_ERROR "Laghu sanitizer marker rejection failed: marker=${MARKER}; rejection=unrelated") | ||
| endif() |
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,32 @@ | ||
| # SPDX-License-Identifier: AGPL-3.0-only | ||
| if(NOT DEFINED LAGHU_SOURCE) | ||
| message(FATAL_ERROR "Laghu sanitizer reconfigure expectation requires LAGHU_SOURCE") | ||
| endif() | ||
|
|
||
| set(CMAKE_SOURCE_DIR "${LAGHU_SOURCE}") | ||
| set(CMAKE_SYSTEM_NAME Linux) | ||
| set(CMAKE_CXX_COMPILER_ID Clang) | ||
| include("${LAGHU_SOURCE}/cmake/LaghuSanitizers.cmake") | ||
|
|
||
| set(LAGHU_SANITIZER_PROFILE ASAN_UBSAN) | ||
| laghu_configure_sanitizer_profile() | ||
| if(NOT LAGHU_SANITIZER_COMPILE_OPTIONS MATCHES "-fsanitize=address,undefined" OR | ||
| NOT LAGHU_SANITIZER_COMPILE_OPTIONS MATCHES "-fno-sanitize-recover=undefined" OR | ||
| NOT LAGHU_SANITIZER_LINK_OPTIONS STREQUAL "-fsanitize=address,undefined") | ||
| message(FATAL_ERROR "Laghu sanitizer reconfigure expectation failed: asan_ubsan_flags_missing") | ||
| endif() | ||
|
|
||
| set(LAGHU_SANITIZER_PROFILE NONE) | ||
| laghu_configure_sanitizer_profile() | ||
| if(NOT LAGHU_SANITIZER_COMPILE_OPTIONS STREQUAL "" OR | ||
| NOT LAGHU_SANITIZER_LINK_OPTIONS STREQUAL "") | ||
| message(FATAL_ERROR "Laghu sanitizer reconfigure expectation failed: none_retained_stale_flags") | ||
| endif() | ||
|
|
||
| set(LAGHU_SANITIZER_PROFILE TSAN) | ||
| laghu_configure_sanitizer_profile() | ||
| if(NOT LAGHU_SANITIZER_COMPILE_OPTIONS MATCHES "-fsanitize=thread" OR | ||
| LAGHU_SANITIZER_COMPILE_OPTIONS MATCHES "address" OR | ||
| NOT LAGHU_SANITIZER_LINK_OPTIONS STREQUAL "-fsanitize=thread") | ||
| message(FATAL_ERROR "Laghu sanitizer reconfigure expectation failed: tsan_retained_stale_flags") | ||
| endif() |
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,38 @@ | ||
| # SPDX-License-Identifier: AGPL-3.0-only | ||
| if(NOT DEFINED BUILD_DIRECTORY OR NOT DEFINED ARCHIVE OR NOT DEFINED EXECUTABLE OR NOT DEFINED NM OR | ||
| NOT DEFINED MARKER_ARTIFACT OR NOT DEFINED MARKER OR NOT DEFINED MARKER_PREFIX OR NOT DEFINED MARKER_TARGET) | ||
| message(FATAL_ERROR "Laghu sanitizer release exclusion requires BUILD_DIRECTORY ARCHIVE EXECUTABLE NM MARKER_ARTIFACT MARKER MARKER_PREFIX and MARKER_TARGET") | ||
| endif() | ||
|
|
||
| execute_process(COMMAND "${CMAKE_COMMAND}" --build "${BUILD_DIRECTORY}" --target | ||
| laghu_core laghu "${MARKER_TARGET}" | ||
| RESULT_VARIABLE build_result | ||
| OUTPUT_VARIABLE build_output | ||
| ERROR_VARIABLE build_diagnostics) | ||
| if(NOT build_result EQUAL 0) | ||
| message(FATAL_ERROR "Laghu sanitizer release exclusion failed: build=${build_output}${build_diagnostics}") | ||
| endif() | ||
|
|
||
| execute_process(COMMAND "${NM}" -g "${MARKER_ARTIFACT}" | ||
| RESULT_VARIABLE marker_result | ||
| OUTPUT_VARIABLE marker_symbols | ||
| ERROR_VARIABLE marker_diagnostics) | ||
| if(NOT marker_result EQUAL 0) | ||
| message(FATAL_ERROR "Laghu sanitizer release exclusion failed: marker_artifact=${MARKER_ARTIFACT}; nm=${marker_diagnostics}") | ||
| endif() | ||
| if(NOT marker_symbols MATCHES "${MARKER}") | ||
| message(FATAL_ERROR "Laghu sanitizer release exclusion failed: marker_artifact=${MARKER_ARTIFACT}; test_symbol=missing") | ||
| endif() | ||
|
|
||
| foreach(artifact IN ITEMS "${ARCHIVE}" "${EXECUTABLE}") | ||
| execute_process(COMMAND "${NM}" -g "${artifact}" | ||
| RESULT_VARIABLE result | ||
| OUTPUT_VARIABLE symbols | ||
| ERROR_VARIABLE diagnostics) | ||
| if(NOT result EQUAL 0) | ||
| message(FATAL_ERROR "Laghu sanitizer release exclusion failed: artifact=${artifact}; nm=${diagnostics}") | ||
| endif() | ||
| if(symbols MATCHES "${MARKER_PREFIX}") | ||
| message(FATAL_ERROR "Laghu sanitizer release exclusion failed: artifact=${artifact}; test_symbol=present") | ||
| endif() | ||
| endforeach() |
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,18 @@ | ||
| # SPDX-License-Identifier: AGPL-3.0-only | ||
| if(NOT DEFINED MANIFEST OR NOT DEFINED SOURCE_ROOT OR NOT DEFINED EXPECTED_DIAGNOSTIC) | ||
| message(FATAL_ERROR "Laghu sanitizer suppression expectation requires MANIFEST SOURCE_ROOT and EXPECTED_DIAGNOSTIC") | ||
| endif() | ||
|
|
||
| execute_process( | ||
| COMMAND "${CMAKE_COMMAND}" "-DMANIFEST=${MANIFEST}" "-DSOURCE_ROOT=${SOURCE_ROOT}" | ||
| -P "${CMAKE_CURRENT_LIST_DIR}/ValidateSanitizerSuppression.cmake" | ||
| RESULT_VARIABLE result | ||
| OUTPUT_VARIABLE output | ||
| ERROR_VARIABLE diagnostics) | ||
| if(result EQUAL 0) | ||
| message(FATAL_ERROR "Laghu sanitizer suppression expectation failed: manifest=${MANIFEST}; rejection=missing") | ||
| endif() | ||
| set(combined "${output}${diagnostics}") | ||
| if(NOT combined MATCHES "${EXPECTED_DIAGNOSTIC}") | ||
| message(FATAL_ERROR "Laghu sanitizer suppression expectation failed: manifest=${MANIFEST}; diagnostic=${EXPECTED_DIAGNOSTIC}; rejection=unrelated") | ||
| endif() |
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
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.