OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stdint.h> | 5 #include <stdint.h> |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 | 7 |
8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/process/launch.h" | 13 #include "base/process/launch.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/test/test_timeouts.h" | 15 #include "base/test/test_timeouts.h" |
16 #include "net/test/python_utils.h" | 16 #include "net/test/python_utils.h" |
17 #include "sync/test/local_sync_test_server.h" | 17 #include "sync/test/local_sync_test_server.h" |
18 | 18 |
19 static void PrintUsage() { | 19 static void PrintUsage() { |
20 printf("run_sync_testserver [--port=<port>] [--xmpp-port=<xmpp_port>]\n"); | 20 printf("run_sync_testserver [--port=<port>] [--xmpp-port=<xmpp_port>]\n"); |
21 } | 21 } |
22 | 22 |
23 // Launches the chromiumsync_test.py or xmppserver_test.py scripts, which test | 23 // Launches the chromiumsync_test.py or xmppserver_test.py scripts, which test |
24 // the sync HTTP and XMPP sever functionality respectively. | 24 // the sync HTTP and XMPP sever functionality respectively. |
25 static bool RunSyncTest( | 25 static bool RunSyncTest( |
26 const base::FilePath::StringType& sync_test_script_name) { | 26 const base::FilePath::StringType& sync_test_script_name) { |
27 scoped_ptr<syncer::LocalSyncTestServer> test_server( | 27 std::unique_ptr<syncer::LocalSyncTestServer> test_server( |
28 new syncer::LocalSyncTestServer()); | 28 new syncer::LocalSyncTestServer()); |
29 if (!test_server->SetPythonPath()) { | 29 if (!test_server->SetPythonPath()) { |
30 LOG(ERROR) << "Error trying to set python path. Exiting."; | 30 LOG(ERROR) << "Error trying to set python path. Exiting."; |
31 return false; | 31 return false; |
32 } | 32 } |
33 | 33 |
34 base::FilePath sync_test_script_path; | 34 base::FilePath sync_test_script_path; |
35 if (!test_server->GetTestScriptPath(sync_test_script_name, | 35 if (!test_server->GetTestScriptPath(sync_test_script_name, |
36 &sync_test_script_path)) { | 36 &sync_test_script_path)) { |
37 LOG(ERROR) << "Error trying to get path for test script " | 37 LOG(ERROR) << "Error trying to get path for test script " |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 if (command_line->HasSwitch("xmpp-test")) { | 99 if (command_line->HasSwitch("xmpp-test")) { |
100 return RunSyncTest(FILE_PATH_LITERAL("xmppserver_test.py")) ? 0 : -1; | 100 return RunSyncTest(FILE_PATH_LITERAL("xmppserver_test.py")) ? 0 : -1; |
101 } | 101 } |
102 | 102 |
103 uint16_t port = 0; | 103 uint16_t port = 0; |
104 GetPortFromSwitch("port", &port); | 104 GetPortFromSwitch("port", &port); |
105 | 105 |
106 uint16_t xmpp_port = 0; | 106 uint16_t xmpp_port = 0; |
107 GetPortFromSwitch("xmpp-port", &xmpp_port); | 107 GetPortFromSwitch("xmpp-port", &xmpp_port); |
108 | 108 |
109 scoped_ptr<syncer::LocalSyncTestServer> test_server( | 109 std::unique_ptr<syncer::LocalSyncTestServer> test_server( |
110 new syncer::LocalSyncTestServer(port, xmpp_port)); | 110 new syncer::LocalSyncTestServer(port, xmpp_port)); |
111 if (!test_server->Start()) { | 111 if (!test_server->Start()) { |
112 printf("Error: failed to start python sync test server. Exiting.\n"); | 112 printf("Error: failed to start python sync test server. Exiting.\n"); |
113 return -1; | 113 return -1; |
114 } | 114 } |
115 | 115 |
116 printf("Python sync test server running at %s (type ctrl+c to exit)\n", | 116 printf("Python sync test server running at %s (type ctrl+c to exit)\n", |
117 test_server->host_port_pair().ToString().c_str()); | 117 test_server->host_port_pair().ToString().c_str()); |
118 | 118 |
119 message_loop.Run(); | 119 message_loop.Run(); |
120 return 0; | 120 return 0; |
121 } | 121 } |
OLD | NEW |