diff options
author | Chris Wilson <chris+github@qwirx.com> | 2006-09-02 10:44:29 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2006-09-02 10:44:29 +0000 |
commit | 59088c2f8881552e61338d28a659f53a8c5ae8f9 (patch) | |
tree | 4515cb24981674d6ea414dac530b5b1bc46cf2d3 /lib/common | |
parent | bb8f4cddf2aeddd8cb44d3b5ce13b66cce552198 (diff) |
(refs #3)
Convert UNIX paths to native on Win32 (avoids #ifdefs in tests)
Diffstat (limited to 'lib/common')
-rw-r--r-- | lib/common/Test.h | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/lib/common/Test.h b/lib/common/Test.h index 8bac6036..75ed93aa 100644 --- a/lib/common/Test.h +++ b/lib/common/Test.h @@ -79,11 +79,31 @@ inline int TestGetFileSize(const char *Filename) return -1; } -inline int LaunchServer(const char *CommandLine, const char *pidFile) +inline int LaunchServer(const char *pCommandLine, const char *pidFile) { - if(::system(CommandLine) != 0) +#ifdef WIN32 + // convert UNIX paths to native + + std::string command; + for (int i = 0; pCommandLine[i] != 0; i++) + { + if (pCommandLine[i] == '/') + { + command += '\\'; + } + else + { + command += pCommandLine[i]; + } + } + +#else // !WIN32 + std::string command = pCommandLine; +#endif + + if(::system(command.c_str()) != 0) { - printf("Server: %s\n", CommandLine); + printf("Server: %s\n", command.c_str()); TEST_FAIL_WITH_MESSAGE("Couldn't start server"); return -1; } @@ -93,7 +113,7 @@ inline int LaunchServer(const char *CommandLine, const char *pidFile) // read pid file if(!TestFileExists(pidFile)) { - printf("Server: %s\n", CommandLine); + printf("Server: %s\n", command.c_str()); TEST_FAIL_WITH_MESSAGE("Server didn't save PID file"); return -1; } @@ -102,7 +122,7 @@ inline int LaunchServer(const char *CommandLine, const char *pidFile) int pid = -1; if(f == NULL || fscanf(f, "%d", &pid) != 1) { - printf("Server: %s (pidfile %s)\n", CommandLine, pidFile); + printf("Server: %s (pidfile %s)\n", command.c_str(), pidFile); TEST_FAIL_WITH_MESSAGE("Couldn't read PID file"); return -1; } |