forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v2: fix type check Signed-off-by: Azat Khuzhin <[email protected]>
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,33 @@ | ||
#include <base/defines.h> // ADDRESS_SANITIZER | ||
|
||
#ifdef ADDRESS_SANITIZER | ||
|
||
#include <cstdlib> | ||
#include <thread> | ||
|
||
#include <gtest/gtest.h> | ||
#include <sanitizer/lsan_interface.h> | ||
|
||
/// Test that ensures that LSan works. | ||
/// | ||
/// Regression test for the case when it may not work, | ||
/// because of broken getauxval() [1]. | ||
/// | ||
/// [1]: https://github.com/ClickHouse/ClickHouse/pull/33957 | ||
TEST(Common, LSan) | ||
{ | ||
int sanitizers_exit_code = 1; | ||
|
||
ASSERT_EXIT({ | ||
std::thread leak_in_thread([]() | ||
{ | ||
void * leak = malloc(4096); | ||
ASSERT_NE(leak, nullptr); | ||
}); | ||
leak_in_thread.join(); | ||
|
||
__lsan_do_leak_check(); | ||
}, ::testing::ExitedWithCode(sanitizers_exit_code), ".*LeakSanitizer: detected memory leaks.*"); | ||
} | ||
|
||
#endif |