From 30be8cd51c3a6406c617f9da97452a497324523e Mon Sep 17 00:00:00 2001 From: Hojun Jaygarl Date: Mon, 29 Apr 2013 15:41:05 +0900 Subject: [PATCH] To show FtApp logs on dlog. Change-Id: I83bf08bcbe4fe0d9aabeb7f84537f9af912c4a1e Signed-off-by: Hojun Jaygarl --- inc/TestUtils.h | 8 +++++--- src/FtConfParser.cpp | 35 +++++++++++++++++------------------ src/FtConfiguration.cpp | 9 ++++++--- src/FtDeviceCapability.cpp | 5 ++--- src/FtSoExecutor.cpp | 39 +++++++++++++++++++-------------------- src/TestUtils.cpp | 7 +++++++ src/TsTcInfo.cpp | 25 +++---------------------- 7 files changed, 59 insertions(+), 69 deletions(-) diff --git a/inc/TestUtils.h b/inc/TestUtils.h index 994ecd3..c2c009b 100644 --- a/inc/TestUtils.h +++ b/inc/TestUtils.h @@ -24,9 +24,6 @@ class TestUtils { public: - TestUtils(); - virtual ~TestUtils(); - /* IsSubStrEqual Compares up to num characters of the String Str1 to those of the String Str2 */ static bool IsSubStrEqual(const Tizen::Base::String& Str1, const Tizen::Base::String& Str2, int size); @@ -41,6 +38,11 @@ public: static bool IsMeaningfulToParse(Tizen::Base::String& strBuff); static bool IsModeToken(const Tizen::Base::String& strBuff); + static void Log(const Tizen::Base::String& msg); +private: + TestUtils(); + virtual ~TestUtils(); + }; #endif /* TESTUTILS_H_ */ diff --git a/src/FtConfParser.cpp b/src/FtConfParser.cpp index cada0e6..7ce5617 100644 --- a/src/FtConfParser.cpp +++ b/src/FtConfParser.cpp @@ -58,7 +58,7 @@ FtConfParser::FtConfParser(const String& confFilePath, const String& logPath, co , __mapExecutedTcBeforeCrashed(SingleObjectDeleter) , __customKeyValueMap(SingleObjectDeleter) { - printf("[FTAPP] FtConfParser - FtApp is executed as an app version [%ls]\n", versionString.GetPointer()); + TestUtils::Log(L"FtConfParser - FtApp is executed as an app version: " + versionString); if (versionString.Equals("2.0C", false)) { @@ -88,7 +88,7 @@ FtConfParser::ReadLogFile(String& logPath) result r = logFile.Construct(logPath, L"a+"); if (IsFailed(r)) { - printf("logFile construct Failed... \n"); + TestUtils::Log(L"logFile construct failed..."); return; } @@ -171,12 +171,12 @@ FtConfParser::ReadLogFile(String& logPath) } else { - printf("[FTAPP] Failed to load the crashed information and cannot continue the test"); + TestUtils::Log(L"Failed to load the crashed information and cannot continue the test."); } } } - printf("[FTAPP] #### previously crashed TC: %ls %ls %d %d\n" - , __crashedTsName.GetPointer(), __crashedTcName.GetPointer(), __crashedTsCount, __crashedTcCount); + TestUtils::Log(L"#### previously crashed TC: " + __crashedTsName + L" " + __crashedTcName + + __crashedTsCount + L" " + __crashedTcCount); } bool @@ -193,7 +193,8 @@ FtConfParser::LoadConf() } String tmpContents = L""; - printf("\n[FTAPP] FtConfParser - Load conf file: %ls \n", __confFilePath.GetPointer()); + TestUtils::Log(L" "); + TestUtils::Log(L"FtConfParser - Load conf file: " + __confFilePath); // read by line while (confFile.Read(buff) != E_END_OF_FILE) @@ -291,13 +292,13 @@ FtConfParser::ClearAndCreateLogFile() File logFile; if (!__crashedFlag) { - printf("[FTAPP] FtConfParser - Remove previous LogFile\n"); + TestUtils::Log(L"FtConfParser - Remove previous LogFile"); remove((char*) __logPath.GetPointer()); } result res = logFile.Construct(__logPath, L"a+"); if (IsFailed(res)) { - printf("[FTAPP] FtConfParser - Create LogFile error\n"); + TestUtils::Log(L"FtConfParser - Create LogFile error"); return false; } return true; @@ -332,6 +333,7 @@ FtConfParser::IsComment(const String& buff, const String& strBuff) { return true; } + // / <- the begin of comments if (buff.GetLength() >= COMMENT_LEN && buff.StartsWith(L"/", 0) && buff.StartsWith(L"/", 1)) @@ -349,7 +351,7 @@ FtConfParser::ParseConfig() { if (__confEachLineList.GetCount() <= 0) { - printf("[FTAPP] FtConfParser - Parse&Execute: confList size 0\n"); + TestUtils::Log(L"FtConfParser - Parse&Execute: confList size 0"); return true; } @@ -363,9 +365,8 @@ FtConfParser::ParseConfig() // DLL_START // move to the first node - printf("[FTAPP] CFtConfParser::ParseConfig: __confEachLineList->count = %d \n", - __confEachLineList.GetCount()); String count(__confEachLineList.GetCount()); + TestUtils::Log(L"CFtConfParser::ParseConfig: __confEachLineList->count = " + count); bool isFirstTcAfterCrash = false; unique_ptr< IEnumeratorT< String > > pEnumConfEachLine(__confEachLineList.GetEnumeratorN()); @@ -515,13 +516,11 @@ FtConfParser::FilterOutExecutedTcBeforeCrash() for (int i = 0; i < tsTobeDel.GetCount(); ++i) { TsInfo* pTsInfo = static_cast< TsInfo* >(tsTobeDel.GetAt(i)); - AppAssert(__tsInfoMap.Remove(*pTsInfo) == E_SUCCESS); } for (int i = 0; i < tcTobeDel.GetCount(); ++i) { TcInfo* pTcInfo = static_cast< TcInfo* >(tcTobeDel.GetAt(i)); - AppAssert(__tcInfoMap.Remove(*pTcInfo) == E_SUCCESS); } } @@ -678,7 +677,7 @@ FtConfParser::ParseConfigTestSuiteCase(String& strBuff, bool& isFirstTcAfterCras rtmp = strBuff.Remove(tmpMinusIndex, 1); if (rtmp != E_SUCCESS) { - printf("[FTAPP] TC name replace failed - to empty string \n"); + TestUtils::Log(L"TC name replace failed - to empty string."); } } @@ -705,8 +704,7 @@ FtConfParser::ParseConfigTestSuiteCase(String& strBuff, bool& isFirstTcAfterCras if (isFirstTcAfterCrash) { - printf("[FTAPP] FtConfParser - TS: %ls, TC: %ls\n", - curTsName.GetPointer(), strBuff.GetPointer()); + TestUtils::Log(L"FtConfParser - TS: " + curTsName + L" TC:" + strBuff); isFirstTcAfterCrash = false; __crashedTcCount += 1; if (curTsName.CompareTo(__crashedTsName) != 0) @@ -714,8 +712,8 @@ FtConfParser::ParseConfigTestSuiteCase(String& strBuff, bool& isFirstTcAfterCras __crashedTsCount += 1; __crashedTcCount = 0; } - printf("[FTAPP] #### Retry will be started from TC: %ls %ls %d %d\n" - , curTsName.GetPointer(), strBuff.GetPointer(), __crashedTsCount, __crashedTcCount); + TestUtils::Log(L"#### Retry will be started from TC: " + + curTsName + L" " + strBuff + L" " + __crashedTsCount + L" " + __crashedTcCount); } } @@ -744,6 +742,7 @@ FtConfParser::ParseConfigTestSuiteCase(String& strBuff, bool& isFirstTcAfterCras pTsInfo->tsName = strBuff; pTsInfo->repeatCount = loop; __tsInfoMap.Add(*pTsInfo, *(new Integer(0))); + } curTsName = strBuff; } diff --git a/src/FtConfiguration.cpp b/src/FtConfiguration.cpp index e055407..38908fe 100644 --- a/src/FtConfiguration.cpp +++ b/src/FtConfiguration.cpp @@ -43,8 +43,9 @@ FtConfiguration::LoadConfig() r = reg.Construct(configFile, REG_OPEN_READ_ONLY, 0); if (IsFailed(r)) - printf("REGISTRY CONSTRUCT FAILED\n"); - + { + TestUtils::Log(L"Registry construction failed."); + } } const String @@ -54,7 +55,9 @@ FtConfiguration::GetValue(const String& key) result r; r = reg.GetValue(L"global", key, keyValue); if (IsFailed(r)) - printf(" GetValue Failed \n"); + { + TestUtils::Log(L"Registry GetValue() failed."); + } return keyValue; } diff --git a/src/FtDeviceCapability.cpp b/src/FtDeviceCapability.cpp index 0a264af..87e0145 100644 --- a/src/FtDeviceCapability.cpp +++ b/src/FtDeviceCapability.cpp @@ -31,13 +31,12 @@ FtDeviceCapability::LoadConf(const String& confFilePath, ArrayList& capabilities if (IsFailed(res)) { - printf("\n[FTAPP] FtDeviceCapability - Cannot load the conf file %ls\n", confFilePath.GetPointer()); + TestUtils::Log(L"FtDeviceCapability - Cannot load the conf file: " + confFilePath); return false; } String tmpContents = L""; - printf("\n[FTAPP] FtDeviceCapability - Load a capability configuration file: %ls\n", - confFilePath.GetPointer()); + TestUtils::Log(L"FtDeviceCapability - Load a capability configuration file: " + confFilePath); //read by line while (confFile.Read(buff) != E_END_OF_FILE) diff --git a/src/FtSoExecutor.cpp b/src/FtSoExecutor.cpp index 957ef13..4b7967c 100644 --- a/src/FtSoExecutor.cpp +++ b/src/FtSoExecutor.cpp @@ -126,7 +126,7 @@ CFtSoExecutor::Start() { if (gRetryFlag) { - LogToUi("[FTAPP] Execution : '-r ' option Enabled \n"); + LogToUi(L"Execution : '-r ' option Enabled"); String logPath = __logPath + __logFileName; // pass the absolute path for log file __pParser->ReadLogFile(logPath); @@ -143,7 +143,7 @@ CFtSoExecutor::Start() // load ftapp uts configuration if (__pParser->LoadConf() == false) { - LogToUi("[FTAPP] CFtSoExecutor:: ##### Failed to load ftapputs.conf ####\n"); + LogToUi(L"CFtSoExecutor:: ##### Failed to load ftapputs.conf ####"); return; } @@ -162,12 +162,12 @@ CFtSoExecutor::Start() IEnumerator* pEnum = capabilities.GetEnumeratorN(); - printf("[FTAPP] ## Parsed feature list - START ##\n"); + TestUtils::Log(L"## Parsed feature list - START ##"); while (pEnum->MoveNext() == E_SUCCESS) { - printf("[%ls]\n", (static_cast< String* >(pEnum->GetCurrent()))->GetPointer()); + TestUtils::Log(*(static_cast< String* >(pEnum->GetCurrent()))); } - printf("[FTAPP] ## Parsed feature list - END ##\n"); + TestUtils::Log(L"## Parsed feature list - END ##"); if (loaded) { @@ -192,11 +192,11 @@ CFtSoExecutor::ExecuteTest() __bDllLoad = LoadSo(obj); if (__bDllLoad == false) { - LogToUi(L"[FTAPP] FtSoExecutor - failed load .so file \n"); - LogToUi(L"[FTAPP] FtSoExecutor - Testing finished abnormally\n"); + LogToUi(L"FtSoExecutor - failed load .so file"); + LogToUi(L"FtSoExecutor - Testing finished abnormally"); return; } - LogToUi(L"[FTAPP] FtSoExecutor - LoadSo done \n"); + LogToUi(L"FtSoExecutor - LoadSo done \n"); } // set TestSuite Loop Info @@ -264,11 +264,11 @@ CFtSoExecutor::RunTestSo() // start if (pFnStartTSMain_Drv()) { - LogToUi(L"[FTAPP] FtSoExecutor - StartTSMain - finished \n"); + LogToUi(L"FtSoExecutor - StartTSMain - finished"); } else { - LogToUi(L"[FTAPP] FtSoExecutor -StartTSMain - Fail \n"); + LogToUi(L"FtSoExecutor -StartTSMain - Fail"); } return UnloadSo(); } @@ -285,7 +285,7 @@ CFtSoExecutor::LoadSo(String fileName) String soPath = App::GetInstance()->GetAppRootPath() + L"data/" + fileName; soPath.Replace(L"mytestapp", L"ftapp"); - printf("[FTAPP] FtSoExecutor - About to load library: %ls \n", soPath.GetPointer()); + TestUtils::Log(L"FtSoExecutor - About to load library: " + soPath); // // // // // // // // // // // // // // // // // // // // // // // / // load SO __pLib = new Library(); @@ -307,23 +307,23 @@ CFtSoExecutor::LoadSo(String fileName) if (pFnStartTSMain_Drv == null || pFnSetLogFileName_Drv == null || pFnSetLoop_Drv == null || pFnSetTSLoop_Drv == null || pFnSetTCLoop_Drv == null || pFnSetShowLog_Drv == null) { - LogToUi(L"[FTAPP] FtSoExecutor - Failed to get symbol address.\n"); + LogToUi(L"FtSoExecutor - Failed to get symbol address."); return false; } pFnSetShowLog_Drv(__showLogFlag); - LogToUi(L"[FTAPP] Succeeded to load library\n"); + LogToUi(L"Succeeded to load library\n"); unique_ptr< char[] > pLogPathCStr(GetCStringN(__logPath)); if (!pFnSetLogFilePath_Drv(pLogPathCStr.get())) { - LogToUi("[FTAPP] FtSoExecutor - Failed to set log file path. \n"); + LogToUi(L"FtSoExecutor - Failed to set log file path."); return false; } unique_ptr< char[] > pLogFileNameCStr(GetCStringN(__logFileName)); if (!pFnSetLogFileName_Drv(pLogFileNameCStr.get())) { - LogToUi(L"[FTAPP] FtSoExecutor - Failed to set log file name. \n"); + LogToUi(L"FtSoExecutor - Failed to set log file name."); return false; } @@ -332,16 +332,16 @@ CFtSoExecutor::LoadSo(String fileName) break; case E_LIBRARY_NOT_FOUND: { - LogToUi(L"[FTAPP] FtSoExecutor - Failed to load library with E_LIBRARY_NOT_FOUND\n"); + LogToUi(L"FtSoExecutor - Failed to load library with E_LIBRARY_NOT_FOUND"); unique_ptr< char[] > pLibPath(GetCStringN(soPath)); dlopen(pLibPath.get(), RTLD_NOW); - printf("[FTAPP] FtSoExecutor - [E_LIBRARY_NOT_FOUND] %s\n", dlerror()); + TestUtils::Log(L"FtSoExecutor - [E_LIBRARY_NOT_FOUND] " + String(dlerror())); return false; } break; case E_PRIVILEGE_DENIED: { - LogToUi(L"[FTAPP] FtSoExecutor - Failed to load library with E_PRIVILEGE_DENIED\n"); + LogToUi(L"FtSoExecutor - Failed to load library with E_PRIVILEGE_DENIED"); return false; } break; @@ -373,8 +373,7 @@ CFtSoExecutor::LogToUi(const Tizen::Base::String& msg) { if (__showLogFlag) { - AppLog("%ls", msg.GetPointer()); - printf("%ls", msg.GetPointer()); + TestUtils::Log(msg); __pTextBox->AppendText(msg); __pTextBox->Draw(); __pTextBox->Show(); diff --git a/src/TestUtils.cpp b/src/TestUtils.cpp index 56bf0cb..acba013 100644 --- a/src/TestUtils.cpp +++ b/src/TestUtils.cpp @@ -155,3 +155,10 @@ TestUtils::IsModeToken(const String& strBuff) { return strBuff.StartsWith(L"[", 0) ? true : false; } + +void +TestUtils::Log(const Tizen::Base::String& msg) +{ + AppLog("%ls", msg.GetPointer()); + printf("[FTAPP] %ls\n", msg.GetPointer()); +} diff --git a/src/TsTcInfo.cpp b/src/TsTcInfo.cpp index 7d16044..95a5fa3 100644 --- a/src/TsTcInfo.cpp +++ b/src/TsTcInfo.cpp @@ -80,16 +80,8 @@ TcInfo::Equals(const Object& obj) const int TcInfo::GetHashCode() const { - String hashString = this->tsName + this->tcName; - int res = hashString.GetLength(); - wchar_t tmpch; - - for (int strLen = 0; strLen < hashString.GetLength(); strLen++) - { - hashString.GetCharAt(strLen, tmpch); - res += (tmpch * strLen); - } - res %= MAX_VALUE; + int len = this->tcName.GetLength(); + int res = (this->tsName.GetHashCode() + this->tcName.GetHashCode() * len) % MAX_VALUE; return res; } @@ -155,18 +147,7 @@ TsInfo::Equals(const Object& obj) const int TsInfo::GetHashCode() const { - String hashString = this->tsName; - int res = hashString.GetLength(); - wchar_t tmpch; - - for (int strLen = 0; strLen < hashString.GetLength(); strLen++) - { - hashString.GetCharAt(strLen, tmpch); - - res += (tmpch * strLen); - } - res %= MAX_VALUE; - return res; + return this->tsName.GetHashCode(); } TsInfo& -- 2.7.4