| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if defined(OS_WIN) | 5 #if defined(OS_WIN) |
| 6 #include <process.h> | 6 #include <process.h> |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #endif | 8 #endif |
| 9 | 9 |
| 10 #include "base/multiprocess_test.h" | 10 #include "base/multiprocess_test.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 if (id_ % 2) | 102 if (id_ % 2) |
| 103 mixed_counter.Decrement(); | 103 mixed_counter.Decrement(); |
| 104 else | 104 else |
| 105 mixed_counter.Increment(); | 105 mixed_counter.Increment(); |
| 106 PlatformThread::Sleep(index % 10); // short wait | 106 PlatformThread::Sleep(index % 10); // short wait |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 | 109 |
| 110 // Create a few threads and have them poke on their counters. | 110 // Create a few threads and have them poke on their counters. |
| 111 // Currently disabled. See bug report below: | 111 // Currently disabled. See bug report below: |
| 112 // Flaky, http://crbug.com/10611 | 112 // TODO(maruel): http://crbug.com/10611 |
| 113 TEST_F(StatsTableTest, FLAKY_MultipleThreads) { | 113 TEST_F(StatsTableTest, MultipleThreads) { |
| 114 #if 0 |
| 114 // Create a stats table. | 115 // Create a stats table. |
| 115 const std::string kTableName = "MultipleThreadStatTable"; | 116 const std::string kTableName = "MultipleThreadStatTable"; |
| 116 const int kMaxThreads = 20; | 117 const int kMaxThreads = 20; |
| 117 const int kMaxCounter = 5; | 118 const int kMaxCounter = 5; |
| 118 DeleteShmem(kTableName); | 119 DeleteShmem(kTableName); |
| 119 StatsTable table(kTableName, kMaxThreads, kMaxCounter); | 120 StatsTable table(kTableName, kMaxThreads, kMaxCounter); |
| 120 StatsTable::set_current(&table); | 121 StatsTable::set_current(&table); |
| 121 | 122 |
| 122 EXPECT_EQ(0, table.CountThreadsRegistered()); | 123 EXPECT_EQ(0, table.CountThreadsRegistered()); |
| 123 | 124 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 table.GetCounterValue(name)); | 157 table.GetCounterValue(name)); |
| 157 name = "c:" + kCounterDecrement; | 158 name = "c:" + kCounterDecrement; |
| 158 EXPECT_EQ(-kMaxThreads * kThreadLoops, | 159 EXPECT_EQ(-kMaxThreads * kThreadLoops, |
| 159 table.GetCounterValue(name)); | 160 table.GetCounterValue(name)); |
| 160 name = "c:" + kCounterMixed; | 161 name = "c:" + kCounterMixed; |
| 161 EXPECT_EQ((kMaxThreads % 2) * kThreadLoops, | 162 EXPECT_EQ((kMaxThreads % 2) * kThreadLoops, |
| 162 table.GetCounterValue(name)); | 163 table.GetCounterValue(name)); |
| 163 EXPECT_EQ(0, table.CountThreadsRegistered()); | 164 EXPECT_EQ(0, table.CountThreadsRegistered()); |
| 164 | 165 |
| 165 DeleteShmem(kTableName); | 166 DeleteShmem(kTableName); |
| 167 #endif |
| 166 } | 168 } |
| 167 | 169 |
| 168 const std::string kMPTableName = "MultipleProcessStatTable"; | 170 const std::string kMPTableName = "MultipleProcessStatTable"; |
| 169 | 171 |
| 170 MULTIPROCESS_TEST_MAIN(StatsTableMultipleProcessMain) { | 172 MULTIPROCESS_TEST_MAIN(StatsTableMultipleProcessMain) { |
| 171 // Each process will open the shared memory and set counters | 173 // Each process will open the shared memory and set counters |
| 172 // concurrently in a loop. We'll use some pauses to | 174 // concurrently in a loop. We'll use some pauses to |
| 173 // mixup the scheduling. | 175 // mixup the scheduling. |
| 174 | 176 |
| 175 StatsTable table(kMPTableName, 0, 0); | 177 StatsTable table(kMPTableName, 0, 0); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 PlatformThread::Sleep(500); | 398 PlatformThread::Sleep(500); |
| 397 } | 399 } |
| 398 EXPECT_LE(1000, table.GetCounterValue("t:foo")); | 400 EXPECT_LE(1000, table.GetCounterValue("t:foo")); |
| 399 EXPECT_LE(1000, table.GetCounterValue("t:bar")); | 401 EXPECT_LE(1000, table.GetCounterValue("t:bar")); |
| 400 EXPECT_EQ(2, table.GetCounterValue("c:bar")); | 402 EXPECT_EQ(2, table.GetCounterValue("c:bar")); |
| 401 | 403 |
| 402 DeleteShmem(kTableName); | 404 DeleteShmem(kTableName); |
| 403 } | 405 } |
| 404 | 406 |
| 405 } // namespace base | 407 } // namespace base |
| OLD | NEW |