comparison MySQL/UnitTests/UnitTestsMain.cpp @ 46:6a574d810b98

Compatibility with MySQL 8.0
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 18 Jul 2018 12:27:40 +0200
parents 4c3f767ead03
children 714c5d2bee76
comparison
equal deleted inserted replaced
44:95f0f57f8920 46:6a574d810b98
188 188
189 int main(int argc, char **argv) 189 int main(int argc, char **argv)
190 { 190 {
191 if (argc < 5) 191 if (argc < 5)
192 { 192 {
193 std::cerr << "Usage (UNIX): " << argv[0] << " <socket> <username> <password> <database>" 193 std::cerr
194 << std::endl 194 #if !defined(_WIN32)
195 << "Usage (Windows): " << argv[0] << " <host> <port> <username> <password> <database>" 195 << "Usage (UNIX socket): " << argv[0] << " <socket> <username> <password> <database>"
196 << std::endl << std::endl 196 << std::endl
197 << "Example (UNIX): " << argv[0] << " /var/run/mysqld/mysqld.sock root root orthanctest" 197 #endif
198 << std::endl 198 << "Usage (TCP connection): " << argv[0] << " <host> <port> <username> <password> <database>"
199 << "Example (Windows): " << argv[0] << " localhost 3306 root root orthanctest" 199 << std::endl << std::endl
200 << std::endl << std::endl; 200 #if !defined(_WIN32)
201 << "Example (UNIX socket): " << argv[0] << " /var/run/mysqld/mysqld.sock root root orthanctest"
202 << std::endl
203 #endif
204 << "Example (TCP connection): " << argv[0] << " localhost 3306 root root orthanctest"
205 << std::endl << std::endl;
201 return -1; 206 return -1;
202 } 207 }
203 208
204 std::vector<std::string> args; 209 std::vector<std::string> args;
205 for (int i = 1; i < argc; i++) 210 for (int i = 1; i < argc; i++)
220 Orthanc::Toolbox::InitializeOpenSsl(); 225 Orthanc::Toolbox::InitializeOpenSsl();
221 Orthanc::HttpClient::GlobalInitialize(); 226 Orthanc::HttpClient::GlobalInitialize();
222 227
223 if (args.size() == 4) 228 if (args.size() == 4)
224 { 229 {
225 // UNIX flavor 230 // UNIX socket flavor
231 globalParameters_.SetHost("");
226 globalParameters_.SetUnixSocket(args[0]); 232 globalParameters_.SetUnixSocket(args[0]);
227 globalParameters_.SetUsername(args[1]); 233 globalParameters_.SetUsername(args[1]);
228 globalParameters_.SetPassword(args[2]); 234 globalParameters_.SetPassword(args[2]);
229 globalParameters_.SetDatabase(args[3]); 235 globalParameters_.SetDatabase(args[3]);
230 } 236 }
231 else if (args.size() == 5) 237 else if (args.size() == 5)
232 { 238 {
233 // Windows flavor 239 // TCP connection flavor
234 globalParameters_.SetHost(args[0]); 240 globalParameters_.SetHost(args[0]);
235 globalParameters_.SetPort(boost::lexical_cast<unsigned int>(args[1])); 241 globalParameters_.SetPort(boost::lexical_cast<unsigned int>(args[1]));
236 globalParameters_.SetUsername(args[2]); 242 globalParameters_.SetUsername(args[2]);
237 globalParameters_.SetPassword(args[3]); 243 globalParameters_.SetPassword(args[3]);
238 globalParameters_.SetDatabase(args[4]); 244 globalParameters_.SetDatabase(args[4]);
245
246 // Force the use of TCP on localhost, even if UNIX sockets are available
247 globalParameters_.SetUnixSocket("");
239 } 248 }
240 else 249 else
241 { 250 {
242 LOG(ERROR) << "Bad number of arguments"; 251 LOG(ERROR) << "Bad number of arguments";
243 return -1; 252 return -1;