[ROSAUTOTEST]

Use "advanced C++ features" like default parameters to reduce the complexity of StringOut calls and fix a warning in the MSVC build :-)

svn path=/trunk/; revision=57076
This commit is contained in:
Colin Finck 2012-08-14 20:25:58 +00:00
parent f2f3bf80cc
commit 647486074a
7 changed files with 17 additions and 17 deletions

View file

@ -146,7 +146,7 @@ CJournaledTestList::WriteInitialJournalFile()
CTestInfo* TestInfo; CTestInfo* TestInfo;
DWORD BytesWritten; DWORD BytesWritten;
StringOut("Writing initial journal file...\n\n", TRUE); StringOut("Writing initial journal file...\n\n");
m_ListIterator = 0; m_ListIterator = 0;
@ -192,7 +192,7 @@ CJournaledTestList::LoadJournalFile()
DWORD BytesRead; DWORD BytesRead;
DWORD RemainingSize; DWORD RemainingSize;
StringOut("Loading journal file...\n\n", TRUE); StringOut("Loading journal file...\n\n");
OpenJournal(GENERIC_READ); OpenJournal(GENERIC_READ);
RemainingSize = GetFileSize(m_hJournal, NULL); RemainingSize = GetFileSize(m_hJournal, NULL);

View file

@ -207,7 +207,7 @@ CWebService::Submit(const char* TestType, CTestInfo* TestInfo)
Response.reset(DoRequest(Data)); Response.reset(DoRequest(Data));
ss << "The server responded:" << endl << Response << endl; ss << "The server responded:" << endl << Response << endl;
StringOut(ss.str(), TRUE); StringOut(ss.str());
if(strcmp(Response, "OK")) if(strcmp(Response, "OK"))
EXCEPTION("Aborted!\n"); EXCEPTION("Aborted!\n");

View file

@ -269,7 +269,7 @@ CWineTest::RunTest(CTestInfo* TestInfo)
string tailString; string tailString;
ss << "Running Wine Test, Module: " << TestInfo->Module << ", Test: " << TestInfo->Test << endl; ss << "Running Wine Test, Module: " << TestInfo->Module << ", Test: " << TestInfo->Test << endl;
StringOut(ss.str(), TRUE); StringOut(ss.str());
StartTime = GetTickCount(); StartTime = GetTickCount();
@ -302,7 +302,7 @@ CWineTest::RunTest(CTestInfo* TestInfo)
/* Output text through StringOut, even while the test is still running */ /* Output text through StringOut, even while the test is still running */
Buffer[BytesAvailable] = 0; Buffer[BytesAvailable] = 0;
tailString = StringOut(tailString.append(string(Buffer)), FALSE); tailString = StringOut(tailString.append(string(Buffer)), false);
if(Configuration.DoSubmit()) if(Configuration.DoSubmit())
TestInfo->Log += Buffer; TestInfo->Log += Buffer;
@ -313,12 +313,12 @@ CWineTest::RunTest(CTestInfo* TestInfo)
/* Print what's left */ /* Print what's left */
if(!tailString.empty()) if(!tailString.empty())
StringOut(tailString, TRUE); StringOut(tailString);
TotalTime = ((float)GetTickCount() - StartTime)/1000; TotalTime = ((float)GetTickCount() - StartTime)/1000;
ssFinish << "Test " << TestInfo->Test << " completed in "; ssFinish << "Test " << TestInfo->Test << " completed in ";
ssFinish << setprecision(2) << fixed << TotalTime << " seconds." << endl; ssFinish << setprecision(2) << fixed << TotalTime << " seconds." << endl;
StringOut(ssFinish.str(), TRUE); StringOut(ssFinish.str());
} }
/** /**
@ -375,6 +375,6 @@ CWineTest::Run()
if(Configuration.DoSubmit() && !TestInfo->Log.empty()) if(Configuration.DoSubmit() && !TestInfo->Log.empty())
WebService->Submit("wine", TestInfo); WebService->Submit("wine", TestInfo);
StringOut("\n\n", TRUE); StringOut("\n\n");
} }
} }

View file

@ -60,7 +60,7 @@ wmain(int argc, wchar_t* argv[])
ss << "\n\nSystem uptime " << setprecision(2) << fixed ; ss << "\n\nSystem uptime " << setprecision(2) << fixed ;
ss << ((float)GetTickCount()/1000) << " seconds\n"; ss << ((float)GetTickCount()/1000) << " seconds\n";
StringOut(ss.str(), TRUE); StringOut(ss.str());
/* Run the tests */ /* Run the tests */
WineTest.Run(); WineTest.Run();
@ -76,7 +76,7 @@ wmain(int argc, wchar_t* argv[])
} }
catch(CSimpleException& e) catch(CSimpleException& e)
{ {
StringOut(e.GetMessage(), TRUE); StringOut(e.GetMessage());
} }
catch(CFatalException& e) catch(CFatalException& e)
{ {
@ -87,7 +87,7 @@ wmain(int argc, wchar_t* argv[])
<< "File: " << e.GetFile() << endl << "File: " << e.GetFile() << endl
<< "Line: " << e.GetLine() << endl << "Line: " << e.GetLine() << endl
<< "Last Win32 Error: " << GetLastError() << endl; << "Last Win32 Error: " << GetLastError() << endl;
StringOut(ss.str(), TRUE); StringOut(ss.str());
} }
/* For sysreg2 to notice if rosautotest itself failed */ /* For sysreg2 to notice if rosautotest itself failed */

View file

@ -51,7 +51,7 @@ string EscapeString(const char* Input);
string EscapeString(const string& Input); string EscapeString(const string& Input);
string GetINIValue(PCWCH AppName, PCWCH KeyName, PCWCH FileName); string GetINIValue(PCWCH AppName, PCWCH KeyName, PCWCH FileName);
bool IsNumber(const char* Input); bool IsNumber(const char* Input);
string StringOut(const string& String, const BOOL forcePrint); string StringOut(const string& String, bool forcePrint = true);
string UnicodeToAscii(PCWSTR UnicodeString); string UnicodeToAscii(PCWSTR UnicodeString);
string UnicodeToAscii(const wstring& UnicodeString); string UnicodeToAscii(const wstring& UnicodeString);

View file

@ -20,14 +20,14 @@ bool ShutdownSystem()
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken)) if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken))
{ {
StringOut("OpenProcessToken failed\n", TRUE); StringOut("OpenProcessToken failed\n");
return false; return false;
} }
/* Get the LUID for the Shutdown privilege */ /* Get the LUID for the Shutdown privilege */
if (!LookupPrivilegeValueW(NULL, SE_SHUTDOWN_NAME, &Privileges.Privileges[0].Luid)) if (!LookupPrivilegeValueW(NULL, SE_SHUTDOWN_NAME, &Privileges.Privileges[0].Luid))
{ {
StringOut("LookupPrivilegeValue failed\n", TRUE); StringOut("LookupPrivilegeValue failed\n");
return false; return false;
} }
@ -37,14 +37,14 @@ bool ShutdownSystem()
if (!AdjustTokenPrivileges(hToken, FALSE, &Privileges, 0, NULL, NULL)) if (!AdjustTokenPrivileges(hToken, FALSE, &Privileges, 0, NULL, NULL))
{ {
StringOut("AdjustTokenPrivileges failed\n", TRUE); StringOut("AdjustTokenPrivileges failed\n");
return false; return false;
} }
/* Finally shut down the system */ /* Finally shut down the system */
if(!ExitWindowsEx(EWX_POWEROFF, SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER | SHTDN_REASON_FLAG_PLANNED)) if(!ExitWindowsEx(EWX_POWEROFF, SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER | SHTDN_REASON_FLAG_PLANNED))
{ {
StringOut("ExitWindowsEx failed\n", TRUE); StringOut("ExitWindowsEx failed\n");
return false; return false;
} }

View file

@ -93,7 +93,7 @@ IsNumber(const char* Input)
* The std::string to output * The std::string to output
*/ */
string string
StringOut(const string& String, const BOOL forcePrint) StringOut(const string& String, bool forcePrint)
{ {
char DbgString[DBGPRINT_BUFSIZE + 1]; char DbgString[DBGPRINT_BUFSIZE + 1];
size_t i, start = 0, last_newline = 0, size = 0, curr_pos = 0; size_t i, start = 0, last_newline = 0, size = 0, curr_pos = 0;