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 12 matching lines...) Expand all Loading... | |
23 #include "base/memory/scoped_ptr.h" | 23 #include "base/memory/scoped_ptr.h" |
24 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
26 #include "gtest/gtest.h" | 26 #include "gtest/gtest.h" |
27 #include "util/file/file_io.h" | 27 #include "util/file/file_io.h" |
28 #include "util/net/http_body.h" | 28 #include "util/net/http_body.h" |
29 #include "util/net/http_headers.h" | 29 #include "util/net/http_headers.h" |
30 #include "util/net/http_multipart_builder.h" | 30 #include "util/net/http_multipart_builder.h" |
31 #include "util/test/multiprocess_exec.h" | 31 #include "util/test/multiprocess_exec.h" |
32 | 32 |
33 #if defined(OS_WIN) | |
34 #include <stdlib.h> | |
Mark Mentovai
2015/01/21 19:23:17
This header is available on non-Windows, you don’t
scottmg
2015/01/21 19:48:26
Done.
| |
35 #endif // OS_WIN | |
36 | |
33 namespace crashpad { | 37 namespace crashpad { |
34 namespace test { | 38 namespace test { |
35 namespace { | 39 namespace { |
36 | 40 |
37 class HTTPTransportTestFixture : public MultiprocessExec { | 41 class HTTPTransportTestFixture : public MultiprocessExec { |
38 public: | 42 public: |
39 using RequestValidator = | 43 using RequestValidator = |
40 void(*)(HTTPTransportTestFixture*, const std::string&); | 44 void(*)(HTTPTransportTestFixture*, const std::string&); |
41 | 45 |
42 HTTPTransportTestFixture(const HTTPHeaders& headers, | 46 HTTPTransportTestFixture(const HTTPHeaders& headers, |
43 scoped_ptr<HTTPBodyStream> body_stream, | 47 scoped_ptr<HTTPBodyStream> body_stream, |
44 uint16_t http_response_code, | 48 uint16_t http_response_code, |
45 RequestValidator request_validator) | 49 RequestValidator request_validator) |
46 : MultiprocessExec(), | 50 : MultiprocessExec(), |
47 headers_(headers), | 51 headers_(headers), |
48 body_stream_(body_stream.Pass()), | 52 body_stream_(body_stream.Pass()), |
49 response_code_(http_response_code), | 53 response_code_(http_response_code), |
50 request_validator_(request_validator) { | 54 request_validator_(request_validator) { |
51 // TODO(rsesek): Use a more robust mechanism to locate testdata | 55 // TODO(rsesek): Use a more robust mechanism to locate testdata |
52 // <https://code.google.com/p/crashpad/issues/detail?id=4>. | 56 // <https://code.google.com/p/crashpad/issues/detail?id=4>. |
57 #if defined(OS_POSIX) | |
53 SetChildCommand("util/net/http_transport_test_server.py", nullptr); | 58 SetChildCommand("util/net/http_transport_test_server.py", nullptr); |
59 #elif defined(OS_WIN) | |
60 // Explicitly invoke a shell and python so that python can be found in the | |
61 // path, and run the test script. | |
62 std::vector<std::string> args; | |
63 args.push_back("/c"); | |
64 args.push_back("python"); | |
65 args.push_back("util/net/http_transport_test_server.py"); | |
66 SetChildCommand(getenv("COMSPEC"), &args); | |
67 #endif // OS_POSIX | |
54 } | 68 } |
55 | 69 |
56 const HTTPHeaders& headers() { return headers_; } | 70 const HTTPHeaders& headers() { return headers_; } |
57 | 71 |
58 private: | 72 private: |
59 void MultiprocessParent() override { | 73 void MultiprocessParent() override { |
60 // Use Logging*File() instead of Checked*File() so that the test can fail | 74 // Use Logging*File() instead of Checked*File() so that the test can fail |
61 // gracefully with a gtest assertion if the child does not execute properly. | 75 // gracefully with a gtest assertion if the child does not execute properly. |
62 | 76 |
63 // The child will write the HTTP server port number as a packed unsigned | 77 // The child will write the HTTP server port number as a packed unsigned |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
237 headers[kContentLength] = base::StringPrintf("%zu", strlen(kTextBody)); | 251 headers[kContentLength] = base::StringPrintf("%zu", strlen(kTextBody)); |
238 | 252 |
239 HTTPTransportTestFixture test(headers, body_stream.Pass(), 200, | 253 HTTPTransportTestFixture test(headers, body_stream.Pass(), 200, |
240 &UnchunkedPlainText); | 254 &UnchunkedPlainText); |
241 test.Run(); | 255 test.Run(); |
242 } | 256 } |
243 | 257 |
244 } // namespace | 258 } // namespace |
245 } // namespace test | 259 } // namespace test |
246 } // namespace crashpad | 260 } // namespace crashpad |
OLD | NEW |