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

Side by Side Diff: chrome/app/mash/mash_crash_keys_unittest.cc

Issue 2718123003: mash: Store chrome --mash crash key metadata in shared memory
Patch Set: rebase 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/app/mash/mash_crash_keys.h"
6
7 #include <stdint.h>
8
9 #include "base/debug/crash_logging.h"
10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h"
12 #include "base/strings/stringprintf.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 TEST(MashCrashKeys, Basics) {
16 EXPECT_EQ(-1, mash_crash_keys::GetSharedMemoryFdForTesting());
17
18 mash_crash_keys::Initialize();
19
20 // Shared memory was allocated.
21 EXPECT_NE(-1, mash_crash_keys::GetSharedMemoryFdForTesting());
22 const base::FilePath expected_shm_path(
23 base::StringPrintf("/dev/shm/chrome_crash_keys_%d", getpid()));
24 EXPECT_TRUE(base::PathExists(expected_shm_path));
25 int64_t file_size;
26 EXPECT_TRUE(base::GetFileSize(expected_shm_path, &file_size));
27 // Hard-code size because the OS-level crash_reporter needs to be updated
28 // if breakpad changes the size of SimpleStringDictionary.
29 EXPECT_EQ(32768, file_size);
30
31 // Crash keys were registered and can be used.
32 base::debug::SetCrashKeyValue("url-chunk", "http://example.com");
hashimoto 2017/03/02 07:42:23 Please use the constant name kActiveUrl.
33 EXPECT_EQ(1u, mash_crash_keys::GetCrashKeyCountForTesting());
34 base::debug::ClearCrashKey("url-chunk");
hashimoto 2017/03/02 07:42:23 ditto.
35 EXPECT_EQ(0u, mash_crash_keys::GetCrashKeyCountForTesting());
36
37 mash_crash_keys::Shutdown();
38
39 // Shared memory was cleaned up.
40 EXPECT_EQ(-1, mash_crash_keys::GetSharedMemoryFdForTesting());
41 EXPECT_FALSE(base::PathExists(expected_shm_path));
42 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698