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

Side by Side Diff: third_party/crashpad/crashpad/client/crashpad_client_win_test.cc

Issue 2478633002: Update Crashpad to b47bf6c250c6b825dee1c5fbad9152c2c962e828 (Closed)
Patch Set: mac comment 2 Created 4 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
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 "client/crashpad_client.h" 15 #include "client/crashpad_client.h"
16 16
17 #include "base/files/file_path.h" 17 #include "base/files/file_path.h"
18 #include "base/macros.h"
18 #include "gtest/gtest.h" 19 #include "gtest/gtest.h"
19 #include "test/paths.h" 20 #include "test/paths.h"
20 #include "test/scoped_temp_dir.h" 21 #include "test/scoped_temp_dir.h"
21 #include "test/win/win_multiprocess.h" 22 #include "test/win/win_multiprocess.h"
23 #include "util/win/termination_codes.h"
22 24
23 namespace crashpad { 25 namespace crashpad {
24 namespace test { 26 namespace test {
25 namespace { 27 namespace {
26 28
27 void StartAndUseHandler() { 29 void StartAndUseHandler() {
28 ScopedTempDir temp_dir; 30 ScopedTempDir temp_dir;
29 base::FilePath handler_path = Paths::Executable().DirName().Append( 31 base::FilePath handler_path = Paths::Executable().DirName().Append(
30 FILE_PATH_LITERAL("crashpad_handler.com")); 32 FILE_PATH_LITERAL("crashpad_handler.com"));
31 CrashpadClient client; 33 CrashpadClient client;
32 ASSERT_TRUE(client.StartHandler(handler_path, 34 ASSERT_TRUE(client.StartHandler(handler_path,
33 temp_dir.path(), 35 temp_dir.path(),
34 base::FilePath(), 36 base::FilePath(),
35 "", 37 "",
36 std::map<std::string, std::string>(), 38 std::map<std::string, std::string>(),
37 std::vector<std::string>(), 39 std::vector<std::string>(),
38 false)); 40 true,
39 EXPECT_TRUE(client.UseHandler()); 41 true));
42 ASSERT_TRUE(client.WaitForHandlerStart());
40 } 43 }
41 44
42 class StartWithInvalidHandles final : public WinMultiprocess { 45 class StartWithInvalidHandles final : public WinMultiprocess {
43 public: 46 public:
44 StartWithInvalidHandles() : WinMultiprocess() {} 47 StartWithInvalidHandles() : WinMultiprocess() {}
45 ~StartWithInvalidHandles() {} 48 ~StartWithInvalidHandles() {}
46 49
47 private: 50 private:
48 void WinMultiprocessParent() override {} 51 void WinMultiprocessParent() override {}
49 52
(...skipping 30 matching lines...) Expand all
80 StartAndUseHandler(); 83 StartAndUseHandler();
81 84
82 SetStdHandle(STD_OUTPUT_HANDLE, original_stdout); 85 SetStdHandle(STD_OUTPUT_HANDLE, original_stdout);
83 } 86 }
84 }; 87 };
85 88
86 TEST(CrashpadClient, StartWithSameStdoutStderr) { 89 TEST(CrashpadClient, StartWithSameStdoutStderr) {
87 WinMultiprocess::Run<StartWithSameStdoutStderr>(); 90 WinMultiprocess::Run<StartWithSameStdoutStderr>();
88 } 91 }
89 92
93 void StartAndUseBrokenHandler(CrashpadClient* client) {
94 ScopedTempDir temp_dir;
95 base::FilePath handler_path = Paths::Executable().DirName().Append(
96 FILE_PATH_LITERAL("fake_handler_that_crashes_at_startup.exe"));
97 ASSERT_TRUE(client->StartHandler(handler_path,
98 temp_dir.path(),
99 base::FilePath(),
100 "",
101 std::map<std::string, std::string>(),
102 std::vector<std::string>(),
103 false,
104 true));
105 }
106
107 class HandlerLaunchFailureCrash : public WinMultiprocess {
108 public:
109 HandlerLaunchFailureCrash() : WinMultiprocess() {}
110
111 private:
112 void WinMultiprocessParent() override {
113 SetExpectedChildExitCode(crashpad::kTerminationCodeCrashNoDump);
114 }
115
116 void WinMultiprocessChild() override {
117 CrashpadClient client;
118 StartAndUseBrokenHandler(&client);
119 __debugbreak();
120 exit(0);
121 }
122 };
123
124 TEST(CrashpadClient, HandlerLaunchFailureCrash) {
125 WinMultiprocess::Run<HandlerLaunchFailureCrash>();
126 }
127
128 class HandlerLaunchFailureDumpAndCrash : public WinMultiprocess {
129 public:
130 HandlerLaunchFailureDumpAndCrash() : WinMultiprocess() {}
131
132 private:
133 void WinMultiprocessParent() override {
134 SetExpectedChildExitCode(crashpad::kTerminationCodeCrashNoDump);
135 }
136
137 void WinMultiprocessChild() override {
138 CrashpadClient client;
139 StartAndUseBrokenHandler(&client);
140 // We don't need to fill this out as we're only checking that we're
141 // terminated with the correct failure code.
142 EXCEPTION_POINTERS info = {};
143 client.DumpAndCrash(&info);
144 exit(0);
145 }
146 };
147
148 TEST(CrashpadClient, HandlerLaunchFailureDumpAndCrash) {
149 WinMultiprocess::Run<HandlerLaunchFailureDumpAndCrash>();
150 }
151
152 class HandlerLaunchFailureDumpWithoutCrash : public WinMultiprocess {
153 public:
154 HandlerLaunchFailureDumpWithoutCrash() : WinMultiprocess() {}
155
156 private:
157 void WinMultiprocessParent() override {
158 // DumpWithoutCrash() normally blocks indefinitely. There's no return value,
159 // but confirm that it exits cleanly because it'll return right away if the
160 // handler didn't start.
161 SetExpectedChildExitCode(0);
162 }
163
164 void WinMultiprocessChild() override {
165 CrashpadClient client;
166 StartAndUseBrokenHandler(&client);
167 // We don't need to fill this out as we're only checking that we're
168 // terminated with the correct failure code.
169 CONTEXT context = {};
170 client.DumpWithoutCrash(context);
171 exit(0);
172 }
173 };
174
175 TEST(CrashpadClient, HandlerLaunchFailureDumpWithoutCrash) {
176 WinMultiprocess::Run<HandlerLaunchFailureDumpWithoutCrash>();
177 }
178
90 } // namespace 179 } // namespace
91 } // namespace test 180 } // namespace test
92 } // namespace crashpad 181 } // namespace crashpad
OLDNEW
« no previous file with comments | « third_party/crashpad/crashpad/client/crashpad_client_win.cc ('k') | third_party/crashpad/crashpad/client/crashpad_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698