| OLD | NEW |
| 1 // Copyright 2016 The Crashpad Authors. All rights reserved. | 1 // Copyright 2016 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, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 namespace crashpad { | 22 namespace crashpad { |
| 23 namespace test { | 23 namespace test { |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 class ModuleAnnotationsMultiprocessTest final : public WinMultiprocess { | 26 class ModuleAnnotationsMultiprocessTest final : public WinMultiprocess { |
| 27 private: | 27 private: |
| 28 void WinMultiprocessParent() override { | 28 void WinMultiprocessParent() override { |
| 29 // Read the child executable module. | 29 // Read the child executable module. |
| 30 HMODULE module = nullptr; | 30 HMODULE module = nullptr; |
| 31 CheckedReadFile(ReadPipeHandle(), &module, sizeof(module)); | 31 CheckedReadFileExactly(ReadPipeHandle(), &module, sizeof(module)); |
| 32 | 32 |
| 33 // Reopen the child process with necessary access. | 33 // Reopen the child process with necessary access. |
| 34 HANDLE process_handle = | 34 HANDLE process_handle = |
| 35 OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, | 35 OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, |
| 36 FALSE, | 36 FALSE, |
| 37 GetProcessId(ChildProcess())); | 37 GetProcessId(ChildProcess())); |
| 38 EXPECT_TRUE(process_handle); | 38 EXPECT_TRUE(process_handle); |
| 39 | 39 |
| 40 // Read the module annotations in the child process and verify them. | 40 // Read the module annotations in the child process and verify them. |
| 41 std::map<std::string, std::string> annotations; | 41 std::map<std::string, std::string> annotations; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 63 simple_annotations->SetKeyValue("#APITEST# empty_value", ""); | 63 simple_annotations->SetKeyValue("#APITEST# empty_value", ""); |
| 64 | 64 |
| 65 crashpad_info->set_simple_annotations(simple_annotations); | 65 crashpad_info->set_simple_annotations(simple_annotations); |
| 66 | 66 |
| 67 // Send the executable module. | 67 // Send the executable module. |
| 68 HMODULE module = GetModuleHandle(nullptr); | 68 HMODULE module = GetModuleHandle(nullptr); |
| 69 CheckedWriteFile(WritePipeHandle(), &module, sizeof(module)); | 69 CheckedWriteFile(WritePipeHandle(), &module, sizeof(module)); |
| 70 | 70 |
| 71 // Wait until a signal from the parent process to terminate. | 71 // Wait until a signal from the parent process to terminate. |
| 72 char c; | 72 char c; |
| 73 CheckedReadFile(ReadPipeHandle(), &c, sizeof(c)); | 73 CheckedReadFileExactly(ReadPipeHandle(), &c, sizeof(c)); |
| 74 } | 74 } |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 TEST(ModuleAnnotationsWin, ReadAnnotations) { | 77 TEST(ModuleAnnotationsWin, ReadAnnotations) { |
| 78 WinMultiprocess::Run<ModuleAnnotationsMultiprocessTest>(); | 78 WinMultiprocess::Run<ModuleAnnotationsMultiprocessTest>(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 } // namespace | 81 } // namespace |
| 82 } // namespace test | 82 } // namespace test |
| 83 } // namespace crashpad | 83 } // namespace crashpad |
| OLD | NEW |