| 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 12 matching lines...) Expand all Loading... |
| 23 namespace crashpad { | 23 namespace crashpad { |
| 24 namespace test { | 24 namespace test { |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 TEST(Semaphore, Simple) { | 27 TEST(Semaphore, Simple) { |
| 28 Semaphore semaphore(1); | 28 Semaphore semaphore(1); |
| 29 semaphore.Wait(); | 29 semaphore.Wait(); |
| 30 semaphore.Signal(); | 30 semaphore.Signal(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 TEST(Semaphore, TimedWait) { |
| 34 Semaphore semaphore(0); |
| 35 semaphore.Signal(); |
| 36 EXPECT_TRUE(semaphore.TimedWait(0.01)); // 10ms |
| 37 } |
| 38 |
| 39 TEST(Semaphore, TimedWaitTimeout) { |
| 40 Semaphore semaphore(0); |
| 41 EXPECT_FALSE(semaphore.TimedWait(0.01)); // 10ms |
| 42 } |
| 43 |
| 33 struct ThreadMainInfo { | 44 struct ThreadMainInfo { |
| 34 #if defined(OS_POSIX) | 45 #if defined(OS_POSIX) |
| 35 pthread_t pthread; | 46 pthread_t pthread; |
| 36 #elif defined(OS_WIN) | 47 #elif defined(OS_WIN) |
| 37 HANDLE thread; | 48 HANDLE thread; |
| 38 #endif | 49 #endif |
| 39 Semaphore* semaphore; | 50 Semaphore* semaphore; |
| 40 size_t iterations; | 51 size_t iterations; |
| 41 }; | 52 }; |
| 42 | 53 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 } | 122 } |
| 112 | 123 |
| 113 for (size_t index = 0; index < kThreads; ++index) { | 124 for (size_t index = 0; index < kThreads; ++index) { |
| 114 JoinThread(&info[index]); | 125 JoinThread(&info[index]); |
| 115 } | 126 } |
| 116 } | 127 } |
| 117 | 128 |
| 118 } // namespace | 129 } // namespace |
| 119 } // namespace test | 130 } // namespace test |
| 120 } // namespace crashpad | 131 } // namespace crashpad |
| OLD | NEW |