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

Side by Side Diff: util/misc/clock_test.cc

Issue 838833004: win: Disable Clock tests that require SleepNanoseconds (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: ws Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 23 matching lines...) Expand all
34 uint64_t now = start; 34 uint64_t now = start;
35 for (size_t iteration = 0; iteration < 10; ++iteration) { 35 for (size_t iteration = 0; iteration < 10; ++iteration) {
36 uint64_t last = now; 36 uint64_t last = now;
37 now = ClockMonotonicNanoseconds(); 37 now = ClockMonotonicNanoseconds();
38 38
39 // Use EXPECT_GE instead of EXPECT_GT, because there are no guarantees about 39 // Use EXPECT_GE instead of EXPECT_GT, because there are no guarantees about
40 // the clock’s resolution. 40 // the clock’s resolution.
41 EXPECT_GE(now, last); 41 EXPECT_GE(now, last);
42 } 42 }
43 43
44 #if !defined(OS_WIN) // No SleepNanoseconds implemented on Windows.
44 // SleepNanoseconds() should sleep for at least the value of the clock’s 45 // SleepNanoseconds() should sleep for at least the value of the clock’s
45 // resolution, so the clock’s value should definitely increase after a sleep. 46 // resolution, so the clock’s value should definitely increase after a sleep.
46 // EXPECT_GT can be used instead of EXPECT_GE after the sleep. 47 // EXPECT_GT can be used instead of EXPECT_GE after the sleep.
47 SleepNanoseconds(1); 48 SleepNanoseconds(1);
48 now = ClockMonotonicNanoseconds(); 49 now = ClockMonotonicNanoseconds();
49 EXPECT_GT(now, start); 50 EXPECT_GT(now, start);
51 #endif // OS_WIN
50 } 52 }
51 53
54 #if !defined(OS_WIN) // No SleepNanoseconds implemented on Windows.
55
52 void TestSleepNanoseconds(uint64_t nanoseconds) { 56 void TestSleepNanoseconds(uint64_t nanoseconds) {
53 uint64_t start = ClockMonotonicNanoseconds(); 57 uint64_t start = ClockMonotonicNanoseconds();
54 58
55 SleepNanoseconds(nanoseconds); 59 SleepNanoseconds(nanoseconds);
56 60
57 uint64_t end = ClockMonotonicNanoseconds(); 61 uint64_t end = ClockMonotonicNanoseconds();
58 uint64_t diff = end - start; 62 uint64_t diff = end - start;
59 63
60 // |nanoseconds| is the lower bound for the actual amount of time spent 64 // |nanoseconds| is the lower bound for the actual amount of time spent
61 // sleeping. 65 // sleeping.
(...skipping 18 matching lines...) Expand all
80 84
81 for (size_t index = 0; index < arraysize(kTestData); ++index) { 85 for (size_t index = 0; index < arraysize(kTestData); ++index) {
82 const uint64_t nanoseconds = kTestData[index]; 86 const uint64_t nanoseconds = kTestData[index];
83 SCOPED_TRACE( 87 SCOPED_TRACE(
84 base::StringPrintf("index %zu, nanoseconds %llu", index, nanoseconds)); 88 base::StringPrintf("index %zu, nanoseconds %llu", index, nanoseconds));
85 89
86 TestSleepNanoseconds(nanoseconds); 90 TestSleepNanoseconds(nanoseconds);
87 } 91 }
88 } 92 }
89 93
94 #endif // OS_WIN
95
90 } // namespace 96 } // namespace
91 } // namespace test 97 } // namespace test
92 } // namespace crashpad 98 } // namespace crashpad
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698