Changeset 2225
- Timestamp:
- 07/08/2008 17:32:15 (5 months ago)
- Location:
- box/trunk/lib/common
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/lib/common/Test.cpp
r2205 r2225 155 155 int LaunchServer(const std::string& rCommandLine, const char *pidFile) 156 156 { 157 ::fprintf(stdout, "Starting server: %s\n", rCommandLine.c_str()); 158 157 159 #ifdef WIN32 158 160 … … 192 194 printf("Launch failed: %s: error %d\n", rCommandLine.c_str(), 193 195 (int)err); 196 TEST_FAIL_WITH_MESSAGE("Couldn't start server"); 194 197 return -1; 195 198 } … … 198 201 CloseHandle(procInfo.hThread); 199 202 203 return WaitForServerStart(pidFile, (int)procInfo.dwProcessId); 204 200 205 #else // !WIN32 201 206 202 207 if(RunCommand(rCommandLine) != 0) 203 208 { 204 printf("Server: %s\n", rCommandLine.c_str());205 209 TEST_FAIL_WITH_MESSAGE("Couldn't start server"); 206 210 return -1; 207 211 } 208 212 213 return WaitForServerStartup(pidFile, 0); 214 209 215 #endif // WIN32 210 216 } 217 218 int WaitForServerStartup(const char *pidFile, int pidIfKnown) 219 { 211 220 #ifdef WIN32 212 221 if (pidFile == NULL) 213 222 { 214 return (int)procInfo.dwProcessId;223 return pidIfKnown; 215 224 } 216 225 #else 217 226 // on other platforms there is no other way to get 218 227 // the PID, so a NULL pidFile doesn't make sense. 228 ASSERT(pidFile != NULL); 219 229 #endif 220 230 221 231 // time for it to start up 222 ::fprintf(stdout, "Starting server: %s\n", rCommandLine.c_str());223 232 ::fprintf(stdout, "Waiting for server to start: "); 224 233 … … 230 239 } 231 240 232 #ifdef WIN32 233 if (!ServerIsAlive((int)procInfo.dwProcessId)) 241 if (pidIfKnown && !ServerIsAlive(pidIfKnown)) 234 242 { 235 243 break; 236 244 } 237 #endif238 245 239 246 ::fprintf(stdout, "."); … … 242 249 } 243 250 244 #ifdef WIN32245 251 // on Win32 we can check whether the process is alive 246 252 // without even checking the PID file 247 253 248 if ( !ServerIsAlive((int)procInfo.dwProcessId))254 if (pidIfKnown && !ServerIsAlive(pidIfKnown)) 249 255 { 250 256 ::fprintf(stdout, " server died!\n"); … … 252 258 return -1; 253 259 } 254 #endif255 260 256 261 if (!TestFileNotEmpty(pidFile)) … … 269 274 int pid = ReadPidFile(pidFile); 270 275 271 #ifdef WIN32272 276 // On Win32 we can check whether the PID in the pidFile matches 273 277 // the one returned by the system, which it always should. 274 278 275 if (pid != (int)procInfo.dwProcessId)279 if (pidIfKnown && pid != pidIfKnown) 276 280 { 277 281 printf("Server wrote wrong pid to file (%s): expected %d " 278 "but found %d\n", pidFile, 279 (int)procInfo.dwProcessId, pid); 282 "but found %d\n", pidFile, pidIfKnown, pid); 280 283 TEST_FAIL_WITH_MESSAGE("Server wrote wrong pid to file"); 281 284 return -1; 282 285 } 283 #endif284 286 285 287 return pid; -
box/trunk/lib/common/Test.h
r2218 r2225 87 87 int ReadPidFile(const char *pidFile); 88 88 int LaunchServer(const std::string& rCommandLine, const char *pidFile); 89 int WaitForServerStartup(const char *pidFile, int pidIfKnown); 89 90 90 91 #define TestRemoteProcessMemLeaks(filename) \
