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

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

Issue 2702413006: Enable storing last-dispatched exception per-thread. (Closed)
Patch Set: fixed test (larger memory buffer) Created 3 years, 9 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
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_tracker.h" 5 #include "base/debug/activity_tracker.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file.h" 10 #include "base/files/file.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 ASSERT_EQ(1U, snapshot.activity_stack.size()); 243 ASSERT_EQ(1U, snapshot.activity_stack.size());
244 EXPECT_EQ(Activity::ACT_TASK, snapshot.activity_stack[0].activity_type); 244 EXPECT_EQ(Activity::ACT_TASK, snapshot.activity_stack[0].activity_type);
245 } 245 }
246 246
247 ASSERT_TRUE(tracker->CreateSnapshot(&snapshot)); 247 ASSERT_TRUE(tracker->CreateSnapshot(&snapshot));
248 ASSERT_EQ(0U, snapshot.activity_stack_depth); 248 ASSERT_EQ(0U, snapshot.activity_stack_depth);
249 ASSERT_EQ(0U, snapshot.activity_stack.size()); 249 ASSERT_EQ(0U, snapshot.activity_stack.size());
250 ASSERT_EQ(2U, GetGlobalUserDataMemoryCacheUsed()); 250 ASSERT_EQ(2U, GetGlobalUserDataMemoryCacheUsed());
251 } 251 }
252 252
253 TEST_F(ActivityTrackerTest, ExceptionTest) {
254 GlobalActivityTracker::CreateWithLocalMemory(kMemorySize, 0, "", 3);
255 GlobalActivityTracker* global = GlobalActivityTracker::Get();
256
257 ThreadActivityTracker* tracker =
258 GlobalActivityTracker::Get()->GetOrCreateTrackerForCurrentThread();
259 ThreadActivityTracker::Snapshot snapshot;
260 ASSERT_EQ(0U, GetGlobalUserDataMemoryCacheUsed());
261
262 ASSERT_TRUE(tracker->CreateSnapshot(&snapshot));
263 ASSERT_EQ(0U, snapshot.last_exception.activity_type);
264
265 char origin;
266 global->RecordException(&origin, 42);
267
268 ASSERT_TRUE(tracker->CreateSnapshot(&snapshot));
269 EXPECT_EQ(Activity::ACT_EXCEPTION, snapshot.last_exception.activity_type);
270 EXPECT_EQ(reinterpret_cast<uintptr_t>(&origin),
271 snapshot.last_exception.origin_address);
272 EXPECT_EQ(42U, snapshot.last_exception.data.exception.code);
273 }
274
253 TEST_F(ActivityTrackerTest, CreateWithFileTest) { 275 TEST_F(ActivityTrackerTest, CreateWithFileTest) {
254 const char temp_name[] = "CreateWithFileTest"; 276 const char temp_name[] = "CreateWithFileTest";
255 ScopedTempDir temp_dir; 277 ScopedTempDir temp_dir;
256 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 278 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
257 FilePath temp_file = temp_dir.GetPath().AppendASCII(temp_name); 279 FilePath temp_file = temp_dir.GetPath().AppendASCII(temp_name);
258 const size_t temp_size = 64 << 10; // 64 KiB 280 const size_t temp_size = 64 << 10; // 64 KiB
259 281
260 // Create a global tracker on a new file. 282 // Create a global tracker on a new file.
261 ASSERT_FALSE(PathExists(temp_file)); 283 ASSERT_FALSE(PathExists(temp_file));
262 GlobalActivityTracker::CreateWithFile(temp_file, temp_size, 0, "foo", 3); 284 GlobalActivityTracker::CreateWithFile(temp_file, temp_size, 0, "foo", 3);
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 global->allocator()->ChangeType( 493 global->allocator()->ChangeType(
472 tracker_ref, GlobalActivityTracker::kTypeIdActivityTracker, 494 tracker_ref, GlobalActivityTracker::kTypeIdActivityTracker,
473 GlobalActivityTracker::kTypeIdActivityTrackerFree, false); 495 GlobalActivityTracker::kTypeIdActivityTrackerFree, false);
474 global->allocator()->ChangeType( 496 global->allocator()->ChangeType(
475 user_data_ref, GlobalActivityTracker::kTypeIdUserDataRecord, 497 user_data_ref, GlobalActivityTracker::kTypeIdUserDataRecord,
476 GlobalActivityTracker::kTypeIdUserDataRecordFree, false); 498 GlobalActivityTracker::kTypeIdUserDataRecordFree, false);
477 } 499 }
478 500
479 } // namespace debug 501 } // namespace debug
480 } // namespace base 502 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/activity_tracker.cc ('k') | components/browser_watcher/postmortem_report_collector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698