Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/test/test_server.h" | 5 #include "net/test/test_server.h" |
| 6 | 6 |
| 7 #include <poll.h> | 7 #include <poll.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/process_util.h" | 14 #include "base/process_util.h" |
| 15 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "base/test/test_timeouts.h" | 17 #include "base/test/test_timeouts.h" |
| 18 #include "net/test/python_utils.h" | |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 // Helper class used to detect and kill orphaned python test server processes. | 22 // Helper class used to detect and kill orphaned python test server processes. |
| 22 // Checks if the command line of a process contains |path_string| (the path | 23 // Checks if the command line of a process contains |path_string| (the path |
| 23 // from which the test server was launched) and |port_string| (the port used by | 24 // from which the test server was launched) and |port_string| (the port used by |
| 24 // the test server), and if the parent pid of the process is 1 (indicating that | 25 // the test server), and if the parent pid of the process is 1 (indicating that |
| 25 // it is an orphaned process). | 26 // it is an orphaned process). |
| 26 class OrphanedTestServerFilter : public base::ProcessFilter { | 27 class OrphanedTestServerFilter : public base::ProcessFilter { |
| 27 public: | 28 public: |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 bytes_read += num_bytes; | 88 bytes_read += num_bytes; |
| 88 } | 89 } |
| 89 return true; | 90 return true; |
| 90 } | 91 } |
| 91 | 92 |
| 92 } // namespace | 93 } // namespace |
| 93 | 94 |
| 94 namespace net { | 95 namespace net { |
| 95 | 96 |
| 96 bool TestServer::LaunchPython(const FilePath& testserver_path) { | 97 bool TestServer::LaunchPython(const FilePath& testserver_path) { |
| 98 VLOG(1) << "LaunchPython called with PYTHONPATH = " << | |
|
Paweł Hajdan Jr.
2012/03/13 17:15:23
Is this needed?
tim (not reviewing)
2012/03/15 00:41:40
Fred asked for this in review, and I think it's us
| |
| 99 getenv(kPythonPathEnv); | |
| 97 CommandLine python_command(FilePath(FILE_PATH_LITERAL("python"))); | 100 CommandLine python_command(FilePath(FILE_PATH_LITERAL("python"))); |
| 98 python_command.AppendArgPath(testserver_path); | 101 python_command.AppendArgPath(testserver_path); |
| 99 if (!AddCommandLineArguments(&python_command)) | 102 if (!AddCommandLineArguments(&python_command)) |
| 100 return false; | 103 return false; |
| 101 | 104 |
| 102 int pipefd[2]; | 105 int pipefd[2]; |
| 103 if (pipe(pipefd) != 0) { | 106 if (pipe(pipefd) != 0) { |
| 104 PLOG(ERROR) << "Could not create pipe."; | 107 PLOG(ERROR) << "Could not create pipe."; |
| 105 return false; | 108 return false; |
| 106 } | 109 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 | 159 |
| 157 if (!ParseServerData(server_data)) { | 160 if (!ParseServerData(server_data)) { |
| 158 LOG(ERROR) << "Could not parse server_data: " << server_data; | 161 LOG(ERROR) << "Could not parse server_data: " << server_data; |
| 159 return false; | 162 return false; |
| 160 } | 163 } |
| 161 | 164 |
| 162 return true; | 165 return true; |
| 163 } | 166 } |
| 164 | 167 |
| 165 } // namespace net | 168 } // namespace net |
| OLD | NEW |