Disable CpuTimeTest on instrumented builds.
The test relies on the ability to run a thread for a controllable duration of time, which is unreliable on instrumented builds (TSan, etc.). Also adding a minimal test which can still be run on instrumented builds, so they at least still exercise the code. BUG=webrtc:7542 TBR=kjellander@webrtc.org Review-Url: https://codereview.webrtc.org/2856473002 Cr-Commit-Position: refs/heads/master@{#17961}
This commit is contained in:
parent
d7851aad40
commit
7311b24660
@ -3,3 +3,6 @@
|
||||
PhysicalSocketTest.TestUdpReadyToSendIPv4
|
||||
PhysicalSocketTest.TestUdpIPv4
|
||||
PhysicalSocketTest.TestSocketRecvTimestampIPv4
|
||||
# Relies on actual CPU timing, so can be flaky on memcheck.
|
||||
CpuTimeTest.TwoThreads
|
||||
CpuTimeTest.Sleeping
|
||||
|
||||
@ -17,6 +17,15 @@
|
||||
#include "webrtc/system_wrappers/include/cpu_info.h"
|
||||
#include "webrtc/system_wrappers/include/sleep.h"
|
||||
|
||||
// Only run these tests on non-instrumented builds, because timing on
|
||||
// instrumented builds is unreliable, causing the test to be flaky.
|
||||
#if defined(THREAD_SANITIZER) || defined(MEMORY_SANITIZER) || \
|
||||
defined(ADDRESS_SANITIZER)
|
||||
#define MAYBE_TEST(test_name) DISABLED_##test_name
|
||||
#else
|
||||
#define MAYBE_TEST(test_name) test_name
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
const int kAllowedErrorMillisecs = 30;
|
||||
const int kProcessingTimeMillisecs = 300;
|
||||
@ -38,7 +47,20 @@ bool WorkingFunction(void* counter_pointer) {
|
||||
|
||||
namespace rtc {
|
||||
|
||||
TEST(CpuTimeTest, TwoThreads) {
|
||||
// A minimal test which can be run on instrumented builds, so that they're at
|
||||
// least exercising the code to check for memory leaks/etc.
|
||||
TEST(CpuTimeTest, BasicTest) {
|
||||
int64_t process_start_time_nanos = GetProcessCpuTimeNanos();
|
||||
int64_t thread_start_time_nanos = GetThreadCpuTimeNanos();
|
||||
int64_t process_duration_nanos =
|
||||
GetProcessCpuTimeNanos() - process_start_time_nanos;
|
||||
int64_t thread_duration_nanos =
|
||||
GetThreadCpuTimeNanos() - thread_start_time_nanos;
|
||||
EXPECT_GE(process_duration_nanos, 0);
|
||||
EXPECT_GE(thread_duration_nanos, 0);
|
||||
}
|
||||
|
||||
TEST(CpuTimeTest, MAYBE_TEST(TwoThreads)) {
|
||||
int64_t process_start_time_nanos = GetProcessCpuTimeNanos();
|
||||
int64_t thread_start_time_nanos = GetThreadCpuTimeNanos();
|
||||
int64_t counter1;
|
||||
@ -70,7 +92,7 @@ TEST(CpuTimeTest, TwoThreads) {
|
||||
* kNumNanosecsPerMillisec);
|
||||
}
|
||||
|
||||
TEST(CpuTimeTest, Sleeping) {
|
||||
TEST(CpuTimeTest, MAYBE_TEST(Sleeping)) {
|
||||
int64_t process_start_time_nanos = GetProcessCpuTimeNanos();
|
||||
webrtc::SleepMs(kProcessingTimeMillisecs);
|
||||
int64_t process_duration_nanos =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user