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

Side by Side Diff: util/win/process_info_test.cc

Issue 1451793002: Add RandomString() and its test, and use it everywhere it makes sense (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Fix tpyo Created 5 years, 1 month 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 | « util/win/exception_handler_server.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Crashpad Authors. All rights reserved. 1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "util/win/process_info.h" 15 #include "util/win/process_info.h"
16 16
17 #include <dbghelp.h> 17 #include <dbghelp.h>
18 #include <intrin.h> 18 #include <intrin.h>
19 #include <wchar.h> 19 #include <wchar.h>
20 20
21 #include "base/files/file_path.h" 21 #include "base/files/file_path.h"
22 #include "base/memory/scoped_ptr.h" 22 #include "base/memory/scoped_ptr.h"
23 #include "base/rand_util.h"
24 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
25 #include "base/strings/utf_string_conversions.h" 24 #include "base/strings/utf_string_conversions.h"
26 #include "build/build_config.h" 25 #include "build/build_config.h"
27 #include "gtest/gtest.h" 26 #include "gtest/gtest.h"
28 #include "test/errors.h" 27 #include "test/errors.h"
29 #include "test/scoped_temp_dir.h" 28 #include "test/scoped_temp_dir.h"
30 #include "test/paths.h" 29 #include "test/paths.h"
31 #include "test/win/child_launcher.h" 30 #include "test/win/child_launcher.h"
32 #include "util/file/file_io.h" 31 #include "util/file/file_io.h"
32 #include "util/misc/random_string.h"
33 #include "util/misc/uuid.h" 33 #include "util/misc/uuid.h"
34 #include "util/win/command_line.h" 34 #include "util/win/command_line.h"
35 #include "util/win/get_function.h" 35 #include "util/win/get_function.h"
36 #include "util/win/handle.h" 36 #include "util/win/handle.h"
37 #include "util/win/scoped_handle.h" 37 #include "util/win/scoped_handle.h"
38 38
39 namespace crashpad { 39 namespace crashpad {
40 namespace test { 40 namespace test {
41 namespace { 41 namespace {
42 42
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 ASSERT_TRUE(inherited_file.is_valid()); 552 ASSERT_TRUE(inherited_file.is_valid());
553 553
554 HKEY key; 554 HKEY key;
555 ASSERT_EQ(ERROR_SUCCESS, 555 ASSERT_EQ(ERROR_SUCCESS,
556 RegOpenKeyEx( 556 RegOpenKeyEx(
557 HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft", 0, KEY_READ, &key)); 557 HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft", 0, KEY_READ, &key));
558 ScopedRegistryKey scoped_key(key); 558 ScopedRegistryKey scoped_key(key);
559 ASSERT_TRUE(scoped_key.is_valid()); 559 ASSERT_TRUE(scoped_key.is_valid());
560 560
561 std::wstring mapping_name = 561 std::wstring mapping_name =
562 base::UTF8ToUTF16(base::StringPrintf("Local\\test_mapping_%d_%I64x", 562 base::UTF8ToUTF16(base::StringPrintf("Local\\test_mapping_%d_%s",
563 GetCurrentProcessId(), 563 GetCurrentProcessId(),
564 base::RandUint64())); 564 RandomString().c_str()));
565 ScopedKernelHANDLE mapping(CreateFileMapping(INVALID_HANDLE_VALUE, 565 ScopedKernelHANDLE mapping(CreateFileMapping(INVALID_HANDLE_VALUE,
566 nullptr, 566 nullptr,
567 PAGE_READWRITE, 567 PAGE_READWRITE,
568 0, 568 0,
569 1024, 569 1024,
570 mapping_name.c_str())); 570 mapping_name.c_str()));
571 ASSERT_TRUE(mapping.is_valid()) << ErrorMessage("CreateFileMapping"); 571 ASSERT_TRUE(mapping.is_valid()) << ErrorMessage("CreateFileMapping");
572 572
573 ProcessInfo info; 573 ProcessInfo info;
574 info.Initialize(GetCurrentProcess()); 574 info.Initialize(GetCurrentProcess());
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 EXPECT_TRUE( 639 EXPECT_TRUE(
640 info.LoggingRangeIsFullyReadable(CheckedRange<WinVMAddress, WinVMSize>( 640 info.LoggingRangeIsFullyReadable(CheckedRange<WinVMAddress, WinVMSize>(
641 reinterpret_cast<WinVMAddress>(safe_memory.get()), kAllocationSize))); 641 reinterpret_cast<WinVMAddress>(safe_memory.get()), kAllocationSize)));
642 EXPECT_FALSE(info.LoggingRangeIsFullyReadable( 642 EXPECT_FALSE(info.LoggingRangeIsFullyReadable(
643 CheckedRange<WinVMAddress, WinVMSize>(0, 1024))); 643 CheckedRange<WinVMAddress, WinVMSize>(0, 1024)));
644 } 644 }
645 645
646 } // namespace 646 } // namespace
647 } // namespace test 647 } // namespace test
648 } // namespace crashpad 648 } // namespace crashpad
OLDNEW
« no previous file with comments | « util/win/exception_handler_server.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698