Commit c5f310de by Derek Mauro Committed by Copybara-Service

Don't override clock_gettime in the KernelTimeout and Waiter

tests under sanitizers. The overrides break the sanitizers.

PiperOrigin-RevId: 524037272
Change-Id: I85b87d3870c488cb316505e94b394c6f98e9f60f
parent c23acb9b
...@@ -351,6 +351,7 @@ cc_test( ...@@ -351,6 +351,7 @@ cc_test(
":kernel_timeout_internal", ":kernel_timeout_internal",
":synchronization", ":synchronization",
":thread_pool", ":thread_pool",
"//absl/base:config",
"//absl/random", "//absl/random",
"//absl/time", "//absl/time",
"@com_google_googletest//:gtest_main", "@com_google_googletest//:gtest_main",
......
...@@ -259,6 +259,7 @@ absl_cc_test( ...@@ -259,6 +259,7 @@ absl_cc_test(
COPTS COPTS
${ABSL_TEST_COPTS} ${ABSL_TEST_COPTS}
DEPS DEPS
absl::config
absl::kernel_timeout_internal absl::kernel_timeout_internal
absl::random_random absl::random_random
absl::synchronization absl::synchronization
......
...@@ -18,16 +18,19 @@ ...@@ -18,16 +18,19 @@
#include <chrono> // NOLINT(build/c++11) #include <chrono> // NOLINT(build/c++11)
#include <limits> #include <limits>
#include "absl/random/random.h"
#include "gtest/gtest.h"
#include "absl/base/config.h" #include "absl/base/config.h"
#include "absl/random/random.h"
#include "absl/time/clock.h" #include "absl/time/clock.h"
#include "absl/time/time.h" #include "absl/time/time.h"
#include "gtest/gtest.h"
// Test go/btm support by randomizing the value clock_gettime() for // Test go/btm support by randomizing the value of clock_gettime() for
// CLOCK_MONOTONIC. This works by overriding a weak symbol in glibc. // CLOCK_MONOTONIC. This works by overriding a weak symbol in glibc.
// We should be resistant to this randomization when !SupportsSteadyClock(). // We should be resistant to this randomization when !SupportsSteadyClock().
#ifdef __GOOGLE_GRTE_VERSION__ #if defined(__GOOGLE_GRTE_VERSION__) && \
!defined(ABSL_HAVE_ADDRESS_SANITIZER) && \
!defined(ABSL_HAVE_MEMORY_SANITIZER) && \
!defined(ABSL_HAVE_THREAD_SANITIZER)
extern "C" int __clock_gettime(clockid_t c, struct timespec* ts); extern "C" int __clock_gettime(clockid_t c, struct timespec* ts);
extern "C" int clock_gettime(clockid_t c, struct timespec* ts) { extern "C" int clock_gettime(clockid_t c, struct timespec* ts) {
...@@ -40,7 +43,7 @@ extern "C" int clock_gettime(clockid_t c, struct timespec* ts) { ...@@ -40,7 +43,7 @@ extern "C" int clock_gettime(clockid_t c, struct timespec* ts) {
} }
return __clock_gettime(c, ts); return __clock_gettime(c, ts);
} }
#endif // __GOOGLE_GRTE_VERSION__ #endif
namespace { namespace {
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <iostream> #include <iostream>
#include <ostream> #include <ostream>
#include "absl/base/config.h"
#include "absl/random/random.h" #include "absl/random/random.h"
#include "absl/synchronization/internal/create_thread_identity.h" #include "absl/synchronization/internal/create_thread_identity.h"
#include "absl/synchronization/internal/futex_waiter.h" #include "absl/synchronization/internal/futex_waiter.h"
...@@ -31,10 +32,13 @@ ...@@ -31,10 +32,13 @@
#include "absl/time/time.h" #include "absl/time/time.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
// Test go/btm support by randomizing the value clock_gettime() for // Test go/btm support by randomizing the value of clock_gettime() for
// CLOCK_MONOTONIC. This works by overriding a weak symbol in glibc. // CLOCK_MONOTONIC. This works by overriding a weak symbol in glibc.
// We should be resistant to this randomization when !SupportsSteadyClock(). // We should be resistant to this randomization when !SupportsSteadyClock().
#ifdef __GOOGLE_GRTE_VERSION__ #if defined(__GOOGLE_GRTE_VERSION__) && \
!defined(ABSL_HAVE_ADDRESS_SANITIZER) && \
!defined(ABSL_HAVE_MEMORY_SANITIZER) && \
!defined(ABSL_HAVE_THREAD_SANITIZER)
extern "C" int __clock_gettime(clockid_t c, struct timespec* ts); extern "C" int __clock_gettime(clockid_t c, struct timespec* ts);
extern "C" int clock_gettime(clockid_t c, struct timespec* ts) { extern "C" int clock_gettime(clockid_t c, struct timespec* ts) {
...@@ -47,7 +51,7 @@ extern "C" int clock_gettime(clockid_t c, struct timespec* ts) { ...@@ -47,7 +51,7 @@ extern "C" int clock_gettime(clockid_t c, struct timespec* ts) {
} }
return __clock_gettime(c, ts); return __clock_gettime(c, ts);
} }
#endif // __GOOGLE_GRTE_VERSION__ #endif
namespace { namespace {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment