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

Unified Diff: test/cctest/test-heap-profiler.cc

Issue 2843002: Fix HeapSnapshot test in the case when snapshotting is enabled. (Closed)
Patch Set: Created 10 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-heap-profiler.cc
diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc
index 594af697d7b2252e821f6afb475b6103d1fde036..478f00caf72d22cfb33cb32d79cf7268a384de67 100644
--- a/test/cctest/test-heap-profiler.cc
+++ b/test/cctest/test-heap-profiler.cc
@@ -6,6 +6,7 @@
#include "v8.h"
#include "heap-profiler.h"
+#include "snapshot.h"
#include "string-stream.h"
#include "cctest.h"
#include "zone-inl.h"
@@ -457,9 +458,23 @@ TEST(HeapSnapshot) {
"var c2 = new C2(a2);");
const v8::HeapSnapshot* snapshot_env2 =
v8::HeapProfiler::TakeSnapshot(v8::String::New("env2"));
- CHECK_EQ(1, snapshot_env2->GetHead()->GetChildrenCount());
- const v8::HeapGraphNode* global_env2 =
- snapshot_env2->GetHead()->GetChild(0)->GetToNode();
+ const v8::HeapGraphNode* global_env2;
+ if (i::Snapshot::IsEnabled()) {
+ // In case if snapshots are enabled, there will present a
+ // vanilla deserealized global object, without properties
+ // added by the test code.
+ CHECK_EQ(2, snapshot_env2->GetHead()->GetChildrenCount());
+ // Choose the global object of a bigger size.
+ const v8::HeapGraphNode* node0 =
+ snapshot_env2->GetHead()->GetChild(0)->GetToNode();
+ const v8::HeapGraphNode* node1 =
+ snapshot_env2->GetHead()->GetChild(1)->GetToNode();
+ global_env2 = node0->GetTotalSize() > node1->GetTotalSize() ?
+ node0 : node1;
+ } else {
+ CHECK_EQ(1, snapshot_env2->GetHead()->GetChildrenCount());
+ global_env2 = snapshot_env2->GetHead()->GetChild(0)->GetToNode();
+ }
// Verify, that JS global object of env2 doesn't have '..1'
// properties, but has '..2' properties.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698