OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "platform/assert.h" | 5 #include "platform/assert.h" |
6 #include "vm/isolate.h" | 6 #include "vm/isolate.h" |
7 #include "vm/unit_test.h" | 7 #include "vm/unit_test.h" |
8 #include "vm/profiler.h" | 8 #include "vm/profiler.h" |
9 #include "vm/thread.h" | 9 #include "vm/thread.h" |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 // purpose. | 28 // purpose. |
29 isolate->Shutdown(); | 29 isolate->Shutdown(); |
30 delete isolate; | 30 delete isolate; |
31 delete mutex; | 31 delete mutex; |
32 } | 32 } |
33 | 33 |
34 | 34 |
35 UNIT_TEST_CASE(Monitor) { | 35 UNIT_TEST_CASE(Monitor) { |
36 // This unit test case needs a running isolate. | 36 // This unit test case needs a running isolate. |
37 Isolate* isolate = Isolate::Init(NULL); | 37 Isolate* isolate = Isolate::Init(NULL); |
38 // Profiler interrupts interfere with this test. | 38 // Thread interrupter interferes with this test, disable interrupts. |
| 39 isolate->set_thread_state(NULL); |
39 Profiler::EndExecution(isolate); | 40 Profiler::EndExecution(isolate); |
40 Monitor* monitor = new Monitor(); | 41 Monitor* monitor = new Monitor(); |
41 monitor->Enter(); | 42 monitor->Enter(); |
42 monitor->Exit(); | 43 monitor->Exit(); |
43 | 44 |
44 const int kNumAttempts = 5; | 45 const int kNumAttempts = 5; |
45 int attempts = 0; | 46 int attempts = 0; |
46 while (attempts < kNumAttempts) { | 47 while (attempts < kNumAttempts) { |
47 MonitorLocker ml(monitor); | 48 MonitorLocker ml(monitor); |
48 int64_t start = OS::GetCurrentTimeMillis(); | 49 int64_t start = OS::GetCurrentTimeMillis(); |
(...skipping 20 matching lines...) Expand all Loading... |
69 EXPECT_LT(attempts, kNumAttempts); | 70 EXPECT_LT(attempts, kNumAttempts); |
70 | 71 |
71 // The isolate shutdown and the destruction of the mutex are out-of-order on | 72 // The isolate shutdown and the destruction of the mutex are out-of-order on |
72 // purpose. | 73 // purpose. |
73 isolate->Shutdown(); | 74 isolate->Shutdown(); |
74 delete isolate; | 75 delete isolate; |
75 delete monitor; | 76 delete monitor; |
76 } | 77 } |
77 | 78 |
78 } // namespace dart | 79 } // namespace dart |
OLD | NEW |