Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
bd619dee
Commit
bd619dee
authored
Oct 27, 2020
by
Elliott Brossard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add instructions for sanitizer integration
parent
3005672d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
advanced.md
googletest/docs/advanced.md
+29
-0
No files found.
googletest/docs/advanced.md
View file @
bd619dee
...
...
@@ -2609,3 +2609,32 @@ to be handled by the debugger, such that you can examine the call stack when an
exception is thrown. To achieve that, set the
`GTEST_CATCH_EXCEPTIONS`
environment variable to
`0`
, or use the
`--gtest_catch_exceptions=0`
flag when
running the tests.
### Sanitizer Integration
The
[
Undefined Behavior Sanitizer
](
https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
)
,
[
Address Sanitizer
](
https://github.com/google/sanitizers/wiki/AddressSanitizer
)
,
and
[
Thread Sanitizer
](
https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual
)
all provide weak functions that you can override to trigger explicit failures
when they detect sanitizer errors, such as creating a reference from
`nullptr`
.
To override these functions, place definitions for them in a source file that
you compile as part of your main binary:
```
extern "C" {
void __ubsan_on_report() {
FAIL() << "Encountered an undefined behavior sanitizer error";
}
void __asan_on_error() {
FAIL() << "Encountered an address sanitizer error";
}
void __tsan_on_report() {
FAIL() << "Encountered a thread sanitizer error";
}
} // extern "C"
```
After compiling your project with one of the sanitizers enabled, if a particular
test triggers a sanitizer error, googletest will report that it failed.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment