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

Side by Side Diff: runtime/vm/object_id_ring_test.cc

Issue 2666133002: Added new type of unit test, RAW_UNIT_TEST_CASE, which is used for tests that can be flaky if run w… (Closed)
Patch Set: Fixed name of UNIT_TEST_CASE macro Created 3 years, 10 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 | « runtime/vm/object_graph_test.cc ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/globals.h" 6 #include "vm/globals.h"
7 #include "vm/object_id_ring.h" 7 #include "vm/object_id_ring.h"
8 #include "vm/unit_test.h" 8 #include "vm/unit_test.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_api_state.h" 10 #include "vm/dart_api_state.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 static void ExpectString(RawObject* obj, const char* s) { 44 static void ExpectString(RawObject* obj, const char* s) {
45 String& str = String::Handle(); 45 String& str = String::Handle();
46 str ^= obj; 46 str ^= obj;
47 EXPECT(str.Equals(s)); 47 EXPECT(str.Equals(s));
48 } 48 }
49 }; 49 };
50 50
51 51
52 // Test that serial number wrapping works. 52 // Test that serial number wrapping works.
53 VM_TEST_CASE(ObjectIdRingSerialWrapTest) { 53 ISOLATE_UNIT_TEST_CASE(ObjectIdRingSerialWrapTest) {
54 Isolate* isolate = Isolate::Current(); 54 Isolate* isolate = Isolate::Current();
55 ObjectIdRing* ring = isolate->object_id_ring(); 55 ObjectIdRing* ring = isolate->object_id_ring();
56 ObjectIdRingTestHelper::SetCapacityAndMaxSerial(ring, 2, 4); 56 ObjectIdRingTestHelper::SetCapacityAndMaxSerial(ring, 2, 4);
57 intptr_t id; 57 intptr_t id;
58 ObjectIdRing::LookupResult kind = ObjectIdRing::kInvalid; 58 ObjectIdRing::LookupResult kind = ObjectIdRing::kInvalid;
59 id = ring->GetIdForObject(ObjectIdRingTestHelper::MakeString("0")); 59 id = ring->GetIdForObject(ObjectIdRingTestHelper::MakeString("0"));
60 EXPECT_EQ(0, id); 60 EXPECT_EQ(0, id);
61 ObjectIdRingTestHelper::ExpectIndexId(ring, 0, 0); 61 ObjectIdRingTestHelper::ExpectIndexId(ring, 0, 0);
62 ObjectIdRingTestHelper::ExpectInvalidIndex(ring, 1); 62 ObjectIdRingTestHelper::ExpectInvalidIndex(ring, 1);
63 id = ring->GetIdForObject(ObjectIdRingTestHelper::MakeString("1")); 63 id = ring->GetIdForObject(ObjectIdRingTestHelper::MakeString("1"));
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 EXPECT(Dart_IsList(moved_handle)); 183 EXPECT(Dart_IsList(moved_handle));
184 EXPECT_VALID(Dart_ListLength(moved_handle, &list_length)); 184 EXPECT_VALID(Dart_ListLength(moved_handle, &list_length));
185 EXPECT_EQ(3, list_length); 185 EXPECT_EQ(3, list_length);
186 // Test id reuse. 186 // Test id reuse.
187 EXPECT_EQ(raw_obj_id1, 187 EXPECT_EQ(raw_obj_id1,
188 ring->GetIdForObject(raw_object_moved1, ObjectIdRing::kReuseId)); 188 ring->GetIdForObject(raw_object_moved1, ObjectIdRing::kReuseId));
189 } 189 }
190 190
191 191
192 // Test that the ring table is updated with nulls when the old GC collects. 192 // Test that the ring table is updated with nulls when the old GC collects.
193 VM_TEST_CASE(ObjectIdRingOldGCTest) { 193 ISOLATE_UNIT_TEST_CASE(ObjectIdRingOldGCTest) {
194 Isolate* isolate = thread->isolate(); 194 Isolate* isolate = thread->isolate();
195 Heap* heap = isolate->heap(); 195 Heap* heap = isolate->heap();
196 ObjectIdRing* ring = isolate->object_id_ring(); 196 ObjectIdRing* ring = isolate->object_id_ring();
197 197
198 ObjectIdRing::LookupResult kind = ObjectIdRing::kInvalid; 198 ObjectIdRing::LookupResult kind = ObjectIdRing::kInvalid;
199 intptr_t raw_obj_id1 = -1; 199 intptr_t raw_obj_id1 = -1;
200 intptr_t raw_obj_id2 = -1; 200 intptr_t raw_obj_id2 = -1;
201 { 201 {
202 Dart_EnterScope(); 202 Dart_EnterScope();
203 Dart_Handle result; 203 Dart_Handle result;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 EXPECT_EQ(ObjectIdRing::kCollected, kind); 237 EXPECT_EQ(ObjectIdRing::kCollected, kind);
238 EXPECT_EQ(Object::null(), raw_object_moved1); 238 EXPECT_EQ(Object::null(), raw_object_moved1);
239 RawObject* raw_object_moved2 = ring->GetObjectForId(raw_obj_id2, &kind); 239 RawObject* raw_object_moved2 = ring->GetObjectForId(raw_obj_id2, &kind);
240 EXPECT_EQ(ObjectIdRing::kCollected, kind); 240 EXPECT_EQ(ObjectIdRing::kCollected, kind);
241 EXPECT_EQ(Object::null(), raw_object_moved2); 241 EXPECT_EQ(Object::null(), raw_object_moved2);
242 } 242 }
243 243
244 244
245 // Test that the ring table correctly reports an entry as expired when it is 245 // Test that the ring table correctly reports an entry as expired when it is
246 // overridden by new entries. 246 // overridden by new entries.
247 VM_TEST_CASE(ObjectIdRingExpiredEntryTest) { 247 ISOLATE_UNIT_TEST_CASE(ObjectIdRingExpiredEntryTest) {
248 Isolate* isolate = Isolate::Current(); 248 Isolate* isolate = Isolate::Current();
249 ObjectIdRing* ring = isolate->object_id_ring(); 249 ObjectIdRing* ring = isolate->object_id_ring();
250 250
251 // Insert an object and check we can look it up. 251 // Insert an object and check we can look it up.
252 String& obj = String::Handle(String::New("I will expire")); 252 String& obj = String::Handle(String::New("I will expire"));
253 intptr_t obj_id = ring->GetIdForObject(obj.raw()); 253 intptr_t obj_id = ring->GetIdForObject(obj.raw());
254 ObjectIdRing::LookupResult kind = ObjectIdRing::kInvalid; 254 ObjectIdRing::LookupResult kind = ObjectIdRing::kInvalid;
255 RawObject* obj_lookup = ring->GetObjectForId(obj_id, &kind); 255 RawObject* obj_lookup = ring->GetObjectForId(obj_id, &kind);
256 EXPECT_EQ(ObjectIdRing::kValid, kind); 256 EXPECT_EQ(ObjectIdRing::kValid, kind);
257 EXPECT_EQ(obj.raw(), obj_lookup); 257 EXPECT_EQ(obj.raw(), obj_lookup);
(...skipping 12 matching lines...) Expand all
270 // Check our first entry reports it has expired. 270 // Check our first entry reports it has expired.
271 obj_lookup = ring->GetObjectForId(obj_id, &kind); 271 obj_lookup = ring->GetObjectForId(obj_id, &kind);
272 EXPECT_EQ(ObjectIdRing::kExpired, kind); 272 EXPECT_EQ(ObjectIdRing::kExpired, kind);
273 EXPECT_NE(obj.raw(), obj_lookup); 273 EXPECT_NE(obj.raw(), obj_lookup);
274 EXPECT_EQ(Object::null(), obj_lookup); 274 EXPECT_EQ(Object::null(), obj_lookup);
275 } 275 }
276 276
277 #endif // !PRODUCT 277 #endif // !PRODUCT
278 278
279 } // namespace dart 279 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object_graph_test.cc ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698