Fixed up command line parsing for unit tests in linux that caused crash on startup

master
Lodle 2013-10-24 09:28:56 -07:00
parent e562cb1f2d
commit 0cdeada452
2 changed files with 11 additions and 4 deletions

View File

@ -5,7 +5,6 @@ compiler:
env:
- CFLAGS=--coverage CXXFLAGS=--coverage
before_install:
- ls -la /proc/self/
- sudo apt-get update
- sudo apt-get install gcc-multilib libnotify-dev libv8-dev libboost1.48-dev libboost-date-time1.48-dev libboost-filesystem1.48-dev libboost-thread1.48-dev libboost-system1.48-dev libboost-test1.48-dev libgtest-dev
- wget "http://ppa.launchpad.net/fransschreuder1/usbpicprog-stable/ubuntu/pool/main/w/wxwidgets2.9/libwxgtk2.9-dev_2.9.3-1_amd64.deb"

View File

@ -117,11 +117,19 @@ static gcUnitTestWatcher* SetupTestWatcher()
#ifdef WIN32
UTIL::MISC::CMDArgs args(GetCommandLineA());
#else
char* szCmdLine = NULL;
UTIL::FS::readWholeFile("/proc/self/cmdline", &szCmdLine);
char szCmdLine[255] = {0};
FILE* fh = fopen("/proc/self/cmdline", "r");
int nRead = fread(szCmdLine, 1, 255, fh);
for (int x = 0; x < nRead; ++x)
{
if (szCmdLine[x] == '\0')
szCmdLine[x] = ' ';
}
fclose(fh);
UTIL::MISC::CMDArgs args(szCmdLine);
safe_delete(szCmdLine);
#endif
int argc = args.getArgc();