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

Side by Side Diff: base/debug/activity_analyzer_unittest.cc

Issue 2966563004: StabilityReport proto changes for multi-process support (Closed)
Patch Set: Merge Created 3 years, 4 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 | « base/debug/activity_analyzer.cc ('k') | chrome/browser/chrome_browser_field_trials_desktop.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "base/debug/activity_analyzer.h" 5 #include "base/debug/activity_analyzer.h"
6 6
7 #include <atomic> 7 #include <atomic>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 ASSERT_TRUE(ContainsKey(snapshot, "ref")); 363 ASSERT_TRUE(ContainsKey(snapshot, "ref"));
364 EXPECT_EQ(string1, snapshot.at("ref").GetReference().data()); 364 EXPECT_EQ(string1, snapshot.at("ref").GetReference().data());
365 EXPECT_EQ(sizeof(string1), snapshot.at("ref").GetReference().size()); 365 EXPECT_EQ(sizeof(string1), snapshot.at("ref").GetReference().size());
366 ASSERT_TRUE(ContainsKey(snapshot, "sref")); 366 ASSERT_TRUE(ContainsKey(snapshot, "sref"));
367 EXPECT_EQ(string2, snapshot.at("sref").GetStringReference().data()); 367 EXPECT_EQ(string2, snapshot.at("sref").GetStringReference().data());
368 EXPECT_EQ(strlen(string2), snapshot.at("sref").GetStringReference().size()); 368 EXPECT_EQ(strlen(string2), snapshot.at("sref").GetStringReference().size());
369 } 369 }
370 370
371 TEST_F(ActivityAnalyzerTest, GlobalModulesTest) { 371 TEST_F(ActivityAnalyzerTest, GlobalModulesTest) {
372 GlobalActivityTracker::CreateWithLocalMemory(kMemorySize, 0, "", 3, 0); 372 GlobalActivityTracker::CreateWithLocalMemory(kMemorySize, 0, "", 3, 0);
373 GlobalActivityTracker* global = GlobalActivityTracker::Get();
373 374
374 PersistentMemoryAllocator* allocator = 375 PersistentMemoryAllocator* allocator = global->allocator();
375 GlobalActivityTracker::Get()->allocator();
376 GlobalActivityAnalyzer global_analyzer( 376 GlobalActivityAnalyzer global_analyzer(
377 std::make_unique<PersistentMemoryAllocator>( 377 std::make_unique<PersistentMemoryAllocator>(
378 const_cast<void*>(allocator->data()), allocator->size(), 0, 0, "", 378 const_cast<void*>(allocator->data()), allocator->size(), 0, 0, "",
379 true)); 379 true));
380 380
381 GlobalActivityTracker::ModuleInfo info1; 381 GlobalActivityTracker::ModuleInfo info1;
382 info1.is_loaded = true; 382 info1.is_loaded = true;
383 info1.address = 0x12345678; 383 info1.address = 0x12345678;
384 info1.load_time = 1111; 384 info1.load_time = 1111;
385 info1.size = 0xABCDEF; 385 info1.size = 0xABCDEF;
386 info1.timestamp = 111; 386 info1.timestamp = 111;
387 info1.age = 11; 387 info1.age = 11;
388 info1.identifier[0] = 1; 388 info1.identifier[0] = 1;
389 info1.file = "anything"; 389 info1.file = "anything";
390 info1.debug_file = "elsewhere"; 390 info1.debug_file = "elsewhere";
391 391
392 GlobalActivityTracker::Get()->RecordModuleInfo(info1); 392 global->RecordModuleInfo(info1);
393 std::vector<GlobalActivityTracker::ModuleInfo> modules1; 393 std::vector<GlobalActivityTracker::ModuleInfo> modules1;
394 modules1 = global_analyzer.GetModules(); 394 modules1 = global_analyzer.GetModules(global_analyzer.GetFirstProcess());
395 ASSERT_EQ(1U, modules1.size()); 395 ASSERT_EQ(1U, modules1.size());
396 GlobalActivityTracker::ModuleInfo& stored1a = modules1[0]; 396 GlobalActivityTracker::ModuleInfo& stored1a = modules1[0];
397 EXPECT_EQ(info1.is_loaded, stored1a.is_loaded); 397 EXPECT_EQ(info1.is_loaded, stored1a.is_loaded);
398 EXPECT_EQ(info1.address, stored1a.address); 398 EXPECT_EQ(info1.address, stored1a.address);
399 EXPECT_NE(info1.load_time, stored1a.load_time); 399 EXPECT_NE(info1.load_time, stored1a.load_time);
400 EXPECT_EQ(info1.size, stored1a.size); 400 EXPECT_EQ(info1.size, stored1a.size);
401 EXPECT_EQ(info1.timestamp, stored1a.timestamp); 401 EXPECT_EQ(info1.timestamp, stored1a.timestamp);
402 EXPECT_EQ(info1.age, stored1a.age); 402 EXPECT_EQ(info1.age, stored1a.age);
403 EXPECT_EQ(info1.identifier[0], stored1a.identifier[0]); 403 EXPECT_EQ(info1.identifier[0], stored1a.identifier[0]);
404 EXPECT_EQ(info1.file, stored1a.file); 404 EXPECT_EQ(info1.file, stored1a.file);
405 EXPECT_EQ(info1.debug_file, stored1a.debug_file); 405 EXPECT_EQ(info1.debug_file, stored1a.debug_file);
406 406
407 info1.is_loaded = false; 407 info1.is_loaded = false;
408 GlobalActivityTracker::Get()->RecordModuleInfo(info1); 408 global->RecordModuleInfo(info1);
409 modules1 = global_analyzer.GetModules(); 409 modules1 = global_analyzer.GetModules(global_analyzer.GetFirstProcess());
410 ASSERT_EQ(1U, modules1.size()); 410 ASSERT_EQ(1U, modules1.size());
411 GlobalActivityTracker::ModuleInfo& stored1b = modules1[0]; 411 GlobalActivityTracker::ModuleInfo& stored1b = modules1[0];
412 EXPECT_EQ(info1.is_loaded, stored1b.is_loaded); 412 EXPECT_EQ(info1.is_loaded, stored1b.is_loaded);
413 EXPECT_EQ(info1.address, stored1b.address); 413 EXPECT_EQ(info1.address, stored1b.address);
414 EXPECT_NE(info1.load_time, stored1b.load_time); 414 EXPECT_NE(info1.load_time, stored1b.load_time);
415 EXPECT_EQ(info1.size, stored1b.size); 415 EXPECT_EQ(info1.size, stored1b.size);
416 EXPECT_EQ(info1.timestamp, stored1b.timestamp); 416 EXPECT_EQ(info1.timestamp, stored1b.timestamp);
417 EXPECT_EQ(info1.age, stored1b.age); 417 EXPECT_EQ(info1.age, stored1b.age);
418 EXPECT_EQ(info1.identifier[0], stored1b.identifier[0]); 418 EXPECT_EQ(info1.identifier[0], stored1b.identifier[0]);
419 EXPECT_EQ(info1.file, stored1b.file); 419 EXPECT_EQ(info1.file, stored1b.file);
420 EXPECT_EQ(info1.debug_file, stored1b.debug_file); 420 EXPECT_EQ(info1.debug_file, stored1b.debug_file);
421 421
422 GlobalActivityTracker::ModuleInfo info2; 422 GlobalActivityTracker::ModuleInfo info2;
423 info2.is_loaded = true; 423 info2.is_loaded = true;
424 info2.address = 0x87654321; 424 info2.address = 0x87654321;
425 info2.load_time = 2222; 425 info2.load_time = 2222;
426 info2.size = 0xFEDCBA; 426 info2.size = 0xFEDCBA;
427 info2.timestamp = 222; 427 info2.timestamp = 222;
428 info2.age = 22; 428 info2.age = 22;
429 info2.identifier[0] = 2; 429 info2.identifier[0] = 2;
430 info2.file = "nothing"; 430 info2.file = "nothing";
431 info2.debug_file = "farewell"; 431 info2.debug_file = "farewell";
432 432
433 GlobalActivityTracker::Get()->RecordModuleInfo(info2); 433 global->RecordModuleInfo(info2);
434 std::vector<GlobalActivityTracker::ModuleInfo> modules2; 434 std::vector<GlobalActivityTracker::ModuleInfo> modules2;
435 modules2 = global_analyzer.GetModules(); 435 modules2 = global_analyzer.GetModules(global_analyzer.GetFirstProcess());
436 ASSERT_EQ(2U, modules2.size()); 436 ASSERT_EQ(2U, modules2.size());
437 GlobalActivityTracker::ModuleInfo& stored2 = modules2[1]; 437 GlobalActivityTracker::ModuleInfo& stored2 = modules2[1];
438 EXPECT_EQ(info2.is_loaded, stored2.is_loaded); 438 EXPECT_EQ(info2.is_loaded, stored2.is_loaded);
439 EXPECT_EQ(info2.address, stored2.address); 439 EXPECT_EQ(info2.address, stored2.address);
440 EXPECT_NE(info2.load_time, stored2.load_time); 440 EXPECT_NE(info2.load_time, stored2.load_time);
441 EXPECT_EQ(info2.size, stored2.size); 441 EXPECT_EQ(info2.size, stored2.size);
442 EXPECT_EQ(info2.timestamp, stored2.timestamp); 442 EXPECT_EQ(info2.timestamp, stored2.timestamp);
443 EXPECT_EQ(info2.age, stored2.age); 443 EXPECT_EQ(info2.age, stored2.age);
444 EXPECT_EQ(info2.identifier[0], stored2.identifier[0]); 444 EXPECT_EQ(info2.identifier[0], stored2.identifier[0]);
445 EXPECT_EQ(info2.file, stored2.file); 445 EXPECT_EQ(info2.file, stored2.file);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 const ActivityUserData::Snapshot& pdata1 = 508 const ActivityUserData::Snapshot& pdata1 =
509 analyzer.GetProcessDataSnapshot(pid1); 509 analyzer.GetProcessDataSnapshot(pid1);
510 const ActivityUserData::Snapshot& pdata2 = 510 const ActivityUserData::Snapshot& pdata2 =
511 analyzer.GetProcessDataSnapshot(pid2); 511 analyzer.GetProcessDataSnapshot(pid2);
512 EXPECT_EQ(1001, pdata1.at("pid").GetInt()); 512 EXPECT_EQ(1001, pdata1.at("pid").GetInt());
513 EXPECT_EQ(2002, pdata2.at("pid").GetInt()); 513 EXPECT_EQ(2002, pdata2.at("pid").GetInt());
514 } 514 }
515 515
516 } // namespace debug 516 } // namespace debug
517 } // namespace base 517 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/activity_analyzer.cc ('k') | chrome/browser/chrome_browser_field_trials_desktop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698