OLD | NEW |
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 EXPECT_GE(diff, nanoseconds); | 62 EXPECT_GE(diff, nanoseconds); |
63 | 63 |
64 // It’s difficult to set an upper bound for the time spent sleeping, and | 64 // It’s difficult to set an upper bound for the time spent sleeping, and |
65 // attempting to do so results in a flaky test. | 65 // attempting to do so results in a flaky test. |
66 } | 66 } |
67 | 67 |
68 TEST(Clock, SleepNanoseconds) { | 68 TEST(Clock, SleepNanoseconds) { |
69 const uint64_t kTestData[] = { | 69 const uint64_t kTestData[] = { |
70 0, | 70 0, |
71 1, | 71 1, |
72 static_cast<uint64_t>(1E3), // 1 microsecond | 72 implicit_cast<uint64_t>(1E3), // 1 microsecond |
73 static_cast<uint64_t>(1E4), // 10 microseconds | 73 implicit_cast<uint64_t>(1E4), // 10 microseconds |
74 static_cast<uint64_t>(1E5), // 100 microseconds | 74 implicit_cast<uint64_t>(1E5), // 100 microseconds |
75 static_cast<uint64_t>(1E6), // 1 millisecond | 75 implicit_cast<uint64_t>(1E6), // 1 millisecond |
76 static_cast<uint64_t>(1E7), // 10 milliseconds | 76 implicit_cast<uint64_t>(1E7), // 10 milliseconds |
77 static_cast<uint64_t>(2E7), // 20 milliseconds | 77 implicit_cast<uint64_t>(2E7), // 20 milliseconds |
78 static_cast<uint64_t>(5E7), // 50 milliseconds | 78 implicit_cast<uint64_t>(5E7), // 50 milliseconds |
79 }; | 79 }; |
80 | 80 |
81 for (size_t index = 0; index < arraysize(kTestData); ++index) { | 81 for (size_t index = 0; index < arraysize(kTestData); ++index) { |
82 const uint64_t nanoseconds = kTestData[index]; | 82 const uint64_t nanoseconds = kTestData[index]; |
83 SCOPED_TRACE( | 83 SCOPED_TRACE( |
84 base::StringPrintf("index %zu, nanoseconds %llu", index, nanoseconds)); | 84 base::StringPrintf("index %zu, nanoseconds %llu", index, nanoseconds)); |
85 | 85 |
86 TestSleepNanoseconds(nanoseconds); | 86 TestSleepNanoseconds(nanoseconds); |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
90 } // namespace | 90 } // namespace |
91 } // namespace test | 91 } // namespace test |
92 } // namespace crashpad | 92 } // namespace crashpad |
OLD | NEW |