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

Side by Side Diff: client/crashpad_client_win_test.cc

Issue 1464473003: win: Don't duplicate handles in handle restriction list (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: merge && 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 | « client/crashpad_client_win.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
(Empty)
1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "client/crashpad_client.h"
16
17 #include "base/files/file_path.h"
18 #include "gtest/gtest.h"
19 #include "test/paths.h"
20 #include "test/scoped_temp_dir.h"
21 #include "test/win/win_multiprocess.h"
22
23 namespace crashpad {
24 namespace test {
25 namespace {
26
27 void StartAndUseHandler() {
28 ScopedTempDir temp_dir;
29 base::FilePath handler_path = Paths::Executable().DirName().Append(
30 FILE_PATH_LITERAL("crashpad_handler.exe"));
31 CrashpadClient client;
32 ASSERT_TRUE(client.StartHandler(handler_path,
33 temp_dir.path(),
34 "",
35 std::map<std::string, std::string>(),
36 std::vector<std::string>(),
37 false));
38 EXPECT_TRUE(client.UseHandler());
39 }
40
41 class StartWithInvalidHandles final : public WinMultiprocess {
42 public:
43 StartWithInvalidHandles() : WinMultiprocess() {}
44 ~StartWithInvalidHandles() {}
45
46 private:
47 void WinMultiprocessParent() override {}
48
49 void WinMultiprocessChild() override {
50 HANDLE original_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
51 HANDLE original_stderr = GetStdHandle(STD_ERROR_HANDLE);
52 SetStdHandle(STD_OUTPUT_HANDLE, INVALID_HANDLE_VALUE);
53 SetStdHandle(STD_ERROR_HANDLE, INVALID_HANDLE_VALUE);
54
55 StartAndUseHandler();
56
57 SetStdHandle(STD_OUTPUT_HANDLE, original_stdout);
58 SetStdHandle(STD_ERROR_HANDLE, original_stderr);
59 }
60 };
61
62 TEST(CrashpadClient, StartWithInvalidHandles) {
63 WinMultiprocess::Run<StartWithInvalidHandles>();
64 }
65
66 class StartWithSameStdoutStderr final : public WinMultiprocess {
67 public:
68 StartWithSameStdoutStderr() : WinMultiprocess() {}
69 ~StartWithSameStdoutStderr() {}
70
71 private:
72 void WinMultiprocessParent() override {}
73
74 void WinMultiprocessChild() override {
75 HANDLE original_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
76 HANDLE original_stderr = GetStdHandle(STD_ERROR_HANDLE);
77 SetStdHandle(STD_OUTPUT_HANDLE, original_stderr);
78
79 StartAndUseHandler();
80
81 SetStdHandle(STD_OUTPUT_HANDLE, original_stdout);
82 }
83 };
84
85 TEST(CrashpadClient, StartWithSameStdoutStderr) {
86 WinMultiprocess::Run<StartWithSameStdoutStderr>();
87 }
88
89 } // namespace
90 } // namespace test
91 } // namespace crashpad
OLDNEW
« no previous file with comments | « client/crashpad_client_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698