Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: webrtc/base/cpu_time_unittest.cc

Issue 2856473002: Disable CpuTimeTest on instrumented builds. (Closed)
Patch Set: Use EXPECT_GE to be even safer. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools-webrtc/valgrind/gtest_exclude/webrtc_nonparallel_tests.gtest-memcheck.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/cpu_time_unittest.cc
diff --git a/webrtc/base/cpu_time_unittest.cc b/webrtc/base/cpu_time_unittest.cc
index b6f6766dccac463b68d5e8e8c909fb42417ae93e..bfdd7ef4e62546320bc59ba39400fcf951f0dbe1 100644
--- a/webrtc/base/cpu_time_unittest.cc
+++ b/webrtc/base/cpu_time_unittest.cc
@@ -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 =
« no previous file with comments | « tools-webrtc/valgrind/gtest_exclude/webrtc_nonparallel_tests.gtest-memcheck.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698