OLD | NEW |
---|---|
(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 | |
22 namespace crashpad { | |
23 namespace test { | |
24 namespace { | |
25 | |
26 TEST(CrashpadClient, StartWithInvalidHandles) { | |
Mark Mentovai
2015/11/19 19:00:19
…that argues for these being out-of-process tests.
| |
27 HANDLE original_stdout = GetStdHandle(STD_OUTPUT_HANDLE); | |
28 HANDLE original_stderr = GetStdHandle(STD_ERROR_HANDLE); | |
29 SetStdHandle(STD_OUTPUT_HANDLE, INVALID_HANDLE_VALUE); | |
30 SetStdHandle(STD_ERROR_HANDLE, INVALID_HANDLE_VALUE); | |
31 | |
32 ScopedTempDir temp_dir; | |
33 base::FilePath handler_path = Paths::Executable().DirName().Append( | |
34 FILE_PATH_LITERAL("crashpad_handler.exe")); | |
35 CrashpadClient client; | |
36 ASSERT_TRUE(client.StartHandler(handler_path, | |
37 temp_dir.path(), | |
38 "", | |
39 std::map<std::string, std::string>(), | |
40 std::vector<std::string>(), | |
41 false)); | |
42 EXPECT_TRUE(client.UseHandler()); | |
43 | |
44 SetStdHandle(STD_OUTPUT_HANDLE, original_stdout); | |
45 SetStdHandle(STD_ERROR_HANDLE, original_stderr); | |
46 } | |
47 | |
48 TEST(CrashpadClient, StartWithSameStdoutStderr) { | |
49 HANDLE original_stdout = GetStdHandle(STD_OUTPUT_HANDLE); | |
50 HANDLE original_stderr = GetStdHandle(STD_ERROR_HANDLE); | |
51 SetStdHandle(STD_OUTPUT_HANDLE, original_stderr); | |
52 | |
53 ScopedTempDir temp_dir; | |
54 base::FilePath handler_path = Paths::Executable().DirName().Append( | |
55 FILE_PATH_LITERAL("crashpad_handler.exe")); | |
56 CrashpadClient client; | |
57 ASSERT_TRUE(client.StartHandler(handler_path, | |
58 temp_dir.path(), | |
59 "", | |
60 std::map<std::string, std::string>(), | |
61 std::vector<std::string>(), | |
62 false)); | |
63 EXPECT_TRUE(client.UseHandler()); | |
64 | |
65 SetStdHandle(STD_OUTPUT_HANDLE, original_stdout); | |
66 } | |
67 | |
68 } // namespace | |
69 } // namespace test | |
70 } // namespace crashpad | |
OLD | NEW |