| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/socket/ssl_test_util.h" | 5 #include "net/socket/ssl_test_util.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 // Do nothing if dir already on path. | 82 // Do nothing if dir already on path. |
| 83 | 83 |
| 84 #if defined(OS_WIN) | 84 #if defined(OS_WIN) |
| 85 const wchar_t kPythonPath[] = L"PYTHONPATH"; | 85 const wchar_t kPythonPath[] = L"PYTHONPATH"; |
| 86 // TODO(dkegel): handle longer PYTHONPATH variables | 86 // TODO(dkegel): handle longer PYTHONPATH variables |
| 87 wchar_t oldpath[4096]; | 87 wchar_t oldpath[4096]; |
| 88 if (GetEnvironmentVariable(kPythonPath, oldpath, arraysize(oldpath)) == 0) { | 88 if (GetEnvironmentVariable(kPythonPath, oldpath, arraysize(oldpath)) == 0) { |
| 89 SetEnvironmentVariableW(kPythonPath, dir.value().c_str()); | 89 SetEnvironmentVariableW(kPythonPath, dir.value().c_str()); |
| 90 } else if (!wcsstr(oldpath, dir.value().c_str())) { | 90 } else if (!wcsstr(oldpath, dir.value().c_str())) { |
| 91 std::wstring newpath(oldpath); | 91 std::wstring newpath(oldpath); |
| 92 newpath.append(L":"); | 92 newpath.append(L";"); |
| 93 newpath.append(dir.value()); | 93 newpath.append(dir.value()); |
| 94 SetEnvironmentVariableW(kPythonPath, newpath.c_str()); | 94 SetEnvironmentVariableW(kPythonPath, newpath.c_str()); |
| 95 } | 95 } |
| 96 #elif defined(OS_POSIX) | 96 #elif defined(OS_POSIX) |
| 97 const char kPythonPath[] = "PYTHONPATH"; | 97 const char kPythonPath[] = "PYTHONPATH"; |
| 98 const char* oldpath = getenv(kPythonPath); | 98 const char* oldpath = getenv(kPythonPath); |
| 99 // setenv() leaks memory intentionally on Mac | 99 // setenv() leaks memory intentionally on Mac |
| 100 if (!oldpath) { | 100 if (!oldpath) { |
| 101 setenv(kPythonPath, dir.value().c_str(), 1); | 101 setenv(kPythonPath, dir.value().c_str(), 1); |
| 102 } else if (!strstr(oldpath, dir.value().c_str())) { | 102 } else if (!strstr(oldpath, dir.value().c_str())) { |
| 103 std::string newpath(oldpath); | 103 std::string newpath(oldpath); |
| 104 newpath.append(":"); | 104 newpath.append(":"); |
| 105 newpath.append(dir.value()); | 105 newpath.append(dir.value()); |
| 106 setenv(kPythonPath, newpath.c_str(), 1); | 106 setenv(kPythonPath, newpath.c_str(), 1); |
| 107 } | 107 } |
| 108 #endif | 108 #endif |
| 109 } | 109 } |
| 110 | 110 |
| 111 } // end namespace | 111 } // end namespace |
| 112 | 112 |
| 113 void TestServerLauncher::SetPythonPath() { | 113 void TestServerLauncher::SetPythonPath() { |
| 114 FilePath third_party_dir; | 114 FilePath third_party_dir; |
| 115 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &third_party_dir)); | 115 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &third_party_dir)); |
| 116 third_party_dir = third_party_dir.Append(FILE_PATH_LITERAL("third_party")); | 116 third_party_dir = third_party_dir.Append(FILE_PATH_LITERAL("third_party")); |
| 117 | 117 |
| 118 AppendToPythonPath(third_party_dir.Append(FILE_PATH_LITERAL("tlslite"))); | 118 AppendToPythonPath(third_party_dir.Append(FILE_PATH_LITERAL("tlslite"))); |
| 119 AppendToPythonPath(third_party_dir.Append(FILE_PATH_LITERAL("pyftpdlib"))); | 119 AppendToPythonPath(third_party_dir.Append(FILE_PATH_LITERAL("pyftpdlib"))); |
| 120 |
| 121 // Locate the Python code generated by the protocol buffers compiler. |
| 122 FilePath generated_code_dir; |
| 123 CHECK(PathService::Get(base::DIR_EXE, &generated_code_dir)); |
| 124 generated_code_dir = generated_code_dir.Append(FILE_PATH_LITERAL("pyproto")); |
| 125 AppendToPythonPath(generated_code_dir); |
| 126 AppendToPythonPath(generated_code_dir.Append(FILE_PATH_LITERAL("sync_pb"))); |
| 120 } | 127 } |
| 121 | 128 |
| 122 bool TestServerLauncher::Start(Protocol protocol, | 129 bool TestServerLauncher::Start(Protocol protocol, |
| 123 const std::string& host_name, int port, | 130 const std::string& host_name, int port, |
| 124 const FilePath& document_root, | 131 const FilePath& document_root, |
| 125 const FilePath& cert_path, | 132 const FilePath& cert_path, |
| 126 const std::wstring& file_root_url) { | 133 const std::wstring& file_root_url) { |
| 127 if (!cert_path.value().empty()) { | 134 if (!cert_path.value().empty()) { |
| 128 if (!LoadTestRootCert()) | 135 if (!LoadTestRootCert()) |
| 129 return false; | 136 return false; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 "certificate to your trusted roots for this test to work. " | 347 "certificate to your trusted roots for this test to work. " |
| 341 "For more info visit:\n" | 348 "For more info visit:\n" |
| 342 "http://dev.chromium.org/developers/testing\n"; | 349 "http://dev.chromium.org/developers/testing\n"; |
| 343 return false; | 350 return false; |
| 344 } | 351 } |
| 345 #endif | 352 #endif |
| 346 return true; | 353 return true; |
| 347 } | 354 } |
| 348 | 355 |
| 349 } // namespace net | 356 } // namespace net |
| OLD | NEW |