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

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

Issue 632103004: Cleanup: Better constify some strings in base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix bad refactoring Created 6 years, 2 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/crash_logging_unittest.cc ('k') | base/debug/trace_event_android.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 Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/proc_maps_linux.h" 5 #include "base/debug/proc_maps_linux.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 } 232 }
233 233
234 TEST(ProcMapsTest, ReadProcMapsNonEmptyString) { 234 TEST(ProcMapsTest, ReadProcMapsNonEmptyString) {
235 std::string old_string("I forgot to clear the string"); 235 std::string old_string("I forgot to clear the string");
236 std::string proc_maps(old_string); 236 std::string proc_maps(old_string);
237 ASSERT_TRUE(ReadProcMaps(&proc_maps)); 237 ASSERT_TRUE(ReadProcMaps(&proc_maps));
238 EXPECT_EQ(std::string::npos, proc_maps.find(old_string)); 238 EXPECT_EQ(std::string::npos, proc_maps.find(old_string));
239 } 239 }
240 240
241 TEST(ProcMapsTest, MissingFields) { 241 TEST(ProcMapsTest, MissingFields) {
242 static const char* kTestCases[] = { 242 static const char* const kTestCases[] = {
243 "00400000\n", // Missing end + beyond. 243 "00400000\n", // Missing end + beyond.
244 "00400000-0040b000\n", // Missing perms + beyond. 244 "00400000-0040b000\n", // Missing perms + beyond.
245 "00400000-0040b000 r-xp\n", // Missing offset + beyond. 245 "00400000-0040b000 r-xp\n", // Missing offset + beyond.
246 "00400000-0040b000 r-xp 00000000\n", // Missing device + beyond. 246 "00400000-0040b000 r-xp 00000000\n", // Missing device + beyond.
247 "00400000-0040b000 r-xp 00000000 fc:00\n", // Missing inode + beyond. 247 "00400000-0040b000 r-xp 00000000 fc:00\n", // Missing inode + beyond.
248 "00400000-0040b000 00000000 fc:00 794418 /bin/cat\n", // Missing perms. 248 "00400000-0040b000 00000000 fc:00 794418 /bin/cat\n", // Missing perms.
249 "00400000-0040b000 r-xp fc:00 794418 /bin/cat\n", // Missing offset. 249 "00400000-0040b000 r-xp fc:00 794418 /bin/cat\n", // Missing offset.
250 "00400000-0040b000 r-xp 00000000 fc:00 /bin/cat\n", // Missing inode. 250 "00400000-0040b000 r-xp 00000000 fc:00 /bin/cat\n", // Missing inode.
251 "00400000 r-xp 00000000 fc:00 794418 /bin/cat\n", // Missing end. 251 "00400000 r-xp 00000000 fc:00 794418 /bin/cat\n", // Missing end.
252 "-0040b000 r-xp 00000000 fc:00 794418 /bin/cat\n", // Missing start. 252 "-0040b000 r-xp 00000000 fc:00 794418 /bin/cat\n", // Missing start.
253 "00400000-0040b000 r-xp 00000000 794418 /bin/cat\n", // Missing device. 253 "00400000-0040b000 r-xp 00000000 794418 /bin/cat\n", // Missing device.
254 }; 254 };
255 255
256 for (size_t i = 0; i < arraysize(kTestCases); ++i) { 256 for (size_t i = 0; i < arraysize(kTestCases); ++i) {
257 SCOPED_TRACE(base::StringPrintf("kTestCases[%zu] = %s", i, kTestCases[i])); 257 SCOPED_TRACE(base::StringPrintf("kTestCases[%zu] = %s", i, kTestCases[i]));
258 std::vector<MappedMemoryRegion> regions; 258 std::vector<MappedMemoryRegion> regions;
259 EXPECT_FALSE(ParseProcMaps(kTestCases[i], &regions)); 259 EXPECT_FALSE(ParseProcMaps(kTestCases[i], &regions));
260 } 260 }
261 } 261 }
262 262
263 TEST(ProcMapsTest, InvalidInput) { 263 TEST(ProcMapsTest, InvalidInput) {
264 static const char* kTestCases[] = { 264 static const char* const kTestCases[] = {
265 "thisisal-0040b000 rwxp 00000000 fc:00 794418 /bin/cat\n", 265 "thisisal-0040b000 rwxp 00000000 fc:00 794418 /bin/cat\n",
266 "0040000d-linvalid rwxp 00000000 fc:00 794418 /bin/cat\n", 266 "0040000d-linvalid rwxp 00000000 fc:00 794418 /bin/cat\n",
267 "00400000-0040b000 inpu 00000000 fc:00 794418 /bin/cat\n", 267 "00400000-0040b000 inpu 00000000 fc:00 794418 /bin/cat\n",
268 "00400000-0040b000 rwxp tforproc fc:00 794418 /bin/cat\n", 268 "00400000-0040b000 rwxp tforproc fc:00 794418 /bin/cat\n",
269 "00400000-0040b000 rwxp 00000000 ma:ps 794418 /bin/cat\n", 269 "00400000-0040b000 rwxp 00000000 ma:ps 794418 /bin/cat\n",
270 "00400000-0040b000 rwxp 00000000 fc:00 parse! /bin/cat\n", 270 "00400000-0040b000 rwxp 00000000 fc:00 parse! /bin/cat\n",
271 }; 271 };
272 272
273 for (size_t i = 0; i < arraysize(kTestCases); ++i) { 273 for (size_t i = 0; i < arraysize(kTestCases); ++i) {
274 SCOPED_TRACE(base::StringPrintf("kTestCases[%zu] = %s", i, kTestCases[i])); 274 SCOPED_TRACE(base::StringPrintf("kTestCases[%zu] = %s", i, kTestCases[i]));
(...skipping 29 matching lines...) Expand all
304 EXPECT_EQ(5ULL, regions.size()); 304 EXPECT_EQ(5ULL, regions.size());
305 EXPECT_EQ("/bin/cat", regions[0].path); 305 EXPECT_EQ("/bin/cat", regions[0].path);
306 EXPECT_EQ("/lib/x86_64-linux-gnu/libc-2.15.so", regions[1].path); 306 EXPECT_EQ("/lib/x86_64-linux-gnu/libc-2.15.so", regions[1].path);
307 EXPECT_EQ("/lib/x86_64-linux-gnu/ld-2.15.so", regions[2].path); 307 EXPECT_EQ("/lib/x86_64-linux-gnu/ld-2.15.so", regions[2].path);
308 EXPECT_EQ("\"vd so\"", regions[3].path); 308 EXPECT_EQ("\"vd so\"", regions[3].path);
309 EXPECT_EQ("[vsys call]", regions[4].path); 309 EXPECT_EQ("[vsys call]", regions[4].path);
310 } 310 }
311 311
312 } // namespace debug 312 } // namespace debug
313 } // namespace base 313 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/crash_logging_unittest.cc ('k') | base/debug/trace_event_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698