[Box Backup-commit] COMMIT r927 - box/chris/merge/lib/common
subversion@fluffy.co.uk
subversion@fluffy.co.uk
Sat, 02 Sep 2006 11:44:29 +0100
Author: chris
Date: 2006-09-02 11:44:29 +0100 (Sat, 02 Sep 2006)
New Revision: 927
Modified:
box/chris/merge/lib/common/Test.h
Log:
(refs #3)
Convert UNIX paths to native on Win32 (avoids #ifdefs in tests)
Modified: box/chris/merge/lib/common/Test.h
===================================================================
--- box/chris/merge/lib/common/Test.h 2006-09-01 10:20:43 UTC (rev 926)
+++ box/chris/merge/lib/common/Test.h 2006-09-02 10:44:29 UTC (rev 927)
@@ -79,11 +79,31 @@
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++)
{
- printf("Server: %s\n", CommandLine);
+ 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", command.c_str());
TEST_FAIL_WITH_MESSAGE("Couldn't start server");
return -1;
}
@@ -93,7 +113,7 @@
// 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 @@
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;
}