OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 request_validator_(request_validator) { | 50 request_validator_(request_validator) { |
51 // TODO(rsesek): Use a more robust mechanism to locate testdata | 51 // TODO(rsesek): Use a more robust mechanism to locate testdata |
52 // <https://code.google.com/p/crashpad/issues/detail?id=4>. | 52 // <https://code.google.com/p/crashpad/issues/detail?id=4>. |
53 SetChildCommand("util/net/http_transport_test_server.py", nullptr); | 53 SetChildCommand("util/net/http_transport_test_server.py", nullptr); |
54 } | 54 } |
55 | 55 |
56 const HTTPHeaders& headers() { return headers_; } | 56 const HTTPHeaders& headers() { return headers_; } |
57 | 57 |
58 private: | 58 private: |
59 void MultiprocessParent() override { | 59 void MultiprocessParent() override { |
| 60 // Use Logging*FD() instead of Checked*FD() so that the test can fail |
| 61 // gracefully with a gtest assertion if the child does not execute properly. |
| 62 |
60 // The child will write the HTTP server port number as a packed unsigned | 63 // The child will write the HTTP server port number as a packed unsigned |
61 // short to stdout. | 64 // short to stdout. |
62 uint16_t port; | 65 uint16_t port; |
63 CheckedReadFD(ReadPipeFD(), &port, sizeof(port)); | 66 ASSERT_TRUE(LoggingReadFD(ReadPipeFD(), &port, sizeof(port))); |
64 | 67 |
65 // Then the parent will tell the web server what response code to send | 68 // Then the parent will tell the web server what response code to send |
66 // for the HTTP request. | 69 // for the HTTP request. |
67 CheckedWriteFD(WritePipeFD(), &response_code_, sizeof(response_code_)); | 70 ASSERT_TRUE( |
| 71 LoggingWriteFD(WritePipeFD(), &response_code_, sizeof(response_code_))); |
68 | 72 |
69 // Now execute the HTTP request. | 73 // Now execute the HTTP request. |
70 scoped_ptr<HTTPTransport> transport(HTTPTransport::Create()); | 74 scoped_ptr<HTTPTransport> transport(HTTPTransport::Create()); |
71 transport->SetMethod("POST"); | 75 transport->SetMethod("POST"); |
72 transport->SetURL(base::StringPrintf("http://127.0.0.1:%d/upload", port)); | 76 transport->SetURL(base::StringPrintf("http://127.0.0.1:%d/upload", port)); |
73 for (const auto& pair : headers_) { | 77 for (const auto& pair : headers_) { |
74 transport->SetHeader(pair.first, pair.second); | 78 transport->SetHeader(pair.first, pair.second); |
75 } | 79 } |
76 transport->SetBodyStream(body_stream_.Pass()); | 80 transport->SetBodyStream(body_stream_.Pass()); |
77 | 81 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 headers[kContentLength] = base::StringPrintf("%zu", strlen(kTextBody)); | 237 headers[kContentLength] = base::StringPrintf("%zu", strlen(kTextBody)); |
234 | 238 |
235 HTTPTransportTestFixture test(headers, body_stream.Pass(), 200, | 239 HTTPTransportTestFixture test(headers, body_stream.Pass(), 200, |
236 &UnchunkedPlainText); | 240 &UnchunkedPlainText); |
237 test.Run(); | 241 test.Run(); |
238 } | 242 } |
239 | 243 |
240 } // namespace | 244 } // namespace |
241 } // namespace test | 245 } // namespace test |
242 } // namespace crashpad | 246 } // namespace crashpad |
OLD | NEW |