X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fframework%2Fsrc%2Ftest_runner.cpp;fp=src%2Fframework%2Fsrc%2Ftest_runner.cpp;h=726d4342399af1427f86e169e03e1b1692ef27b9;hb=89f2ab1b5f41c27e8b08dd27b4343778a991af0a;hp=0b4099c0752e892ed16bfd5cd27bf36cbd5185c7;hpb=80995bf6ca553e1c13800b7ab4eafbe14d932b29;p=platform%2Fcore%2Ftest%2Fsecurity-tests.git diff --git a/src/framework/src/test_runner.cpp b/src/framework/src/test_runner.cpp index 0b4099c..726d434 100644 --- a/src/framework/src/test_runner.cpp +++ b/src/framework/src/test_runner.cpp @@ -206,7 +206,7 @@ bool TestRunner::filterByXML(std::map & casesMap) return true; } -TestRunner::Status TestRunner::RunTestCase(const TestCaseStruct& testCase) +void TestRunner::RunTestCase(const TestCaseStruct& testCase) { setCurrentTestCase(&(const_cast(testCase))); m_deferDeepness = 0U; @@ -215,49 +215,41 @@ TestRunner::Status TestRunner::RunTestCase(const TestCaseStruct& testCase) } catch (const TestFailed &e) { // Simple test failure CollectResult(testCase.name, - TestResultsCollectorBase::FailStatus::FAILED, - getConcatedFailReason(e.GetMessage())); + TestResult(TestResult::FailStatus::FAILED, + getConcatedFailReason(e.GetMessage()))); setCurrentTestCase(nullptr); - return FAILED; + return; } catch (const TestIgnored &e) { if (m_runIgnored) { // Simple test have to be implemented CollectResult(testCase.name, - TestResultsCollectorBase::FailStatus::IGNORED, - e.GetMessage()); + TestResult(TestResult::FailStatus::IGNORED, e.GetMessage())); } setCurrentTestCase(nullptr); - return IGNORED; + return; } catch (const std::exception &) { // std exception failure CollectResult(testCase.name, - TestResultsCollectorBase::FailStatus::FAILED, - "std exception"); + TestResult(TestResult::FailStatus::FAILED, "std exception")); setCurrentTestCase(nullptr); - return FAILED; + return; } catch (...) { // Unknown exception failure CollectResult(testCase.name, - TestResultsCollectorBase::FailStatus::FAILED, - "unknown exception"); - + TestResult(TestResult::FailStatus::FAILED, "unknown exception")); setCurrentTestCase(nullptr); - return FAILED; + return; } + // Everything OK CollectResult(testCase.name, - TestResultsCollectorBase::FailStatus::NONE, - "", - testCase.m_isPerformanceTest, - testCase.m_performanceTestDurationTime, - testCase.m_performanceMaxTime); + TestResult(TestResult::FailStatus::NONE, + std::string(), + testCase.performance)); setCurrentTestCase(nullptr); - - // Everything OK - return PASS; } void TestRunner::RunTests() @@ -324,56 +316,41 @@ void TestRunner::setCurrentTestCase(TestCaseStruct* testCase) m_currentTestCase = testCase; } -void TestRunner::beginPerformanceTestTime(std::chrono::system_clock::duration maxTimeInMicroseconds) +void TestRunner::beginPerformance(std::chrono::system_clock::duration maxDurationInMicroseconds) { TestCaseStruct* testCase = getCurrentTestCase(); if (!testCase) return; - testCase->m_isPerformanceTest = true; - testCase->m_performanceMaxTime = maxTimeInMicroseconds; - testCase->m_performanceTestStartTime = std::chrono::system_clock::now(); - - // Set result to 0 microseconds. Display 0ms result when end macro is missing. - testCase->m_performanceTestDurationTime = std::chrono::microseconds::zero(); + if (!testCase->performance) + testCase->performance.reset(new PerformanceResult(maxDurationInMicroseconds)); } -void TestRunner::endPerformanceTestTime() +void TestRunner::endPerformance() { TestCaseStruct* testCase = getCurrentTestCase(); if (!testCase) return; - testCase->m_performanceTestDurationTime = std::chrono::system_clock::now() - - testCase->m_performanceTestStartTime; + testCase->performance->Finish(); } -void TestRunner::getCurrentTestCasePerformanceResult(bool& isPerformanceTest, - std::chrono::system_clock::duration& result, - std::chrono::system_clock::duration& resultMax) +ConstPerformanceResultPtr TestRunner::getCurrentTestCasePerformanceResult() { TestCaseStruct* testCase = getCurrentTestCase(); - if (!testCase || !(testCase->m_isPerformanceTest)){ - isPerformanceTest = false; - return; - } + if (!testCase) + return nullptr; - isPerformanceTest = testCase->m_isPerformanceTest; - result = testCase->m_performanceTestDurationTime; - resultMax = testCase->m_performanceMaxTime; + return testCase->performance; } -void TestRunner::setCurrentTestCasePerformanceResult(bool isPerformanceTest, - std::chrono::system_clock::duration result, - std::chrono::system_clock::duration resultMax) +void TestRunner::setCurrentTestCasePerformanceResult(const PerformanceResultPtr &performance) { TestCaseStruct* testCase = getCurrentTestCase(); if (!testCase) return; - testCase->m_isPerformanceTest = isPerformanceTest; - testCase->m_performanceTestDurationTime = result; - testCase->m_performanceMaxTime = resultMax; + testCase->performance = performance; } void TestRunner::addFailReason(const std::string &reason) @@ -392,24 +369,13 @@ std::string TestRunner::getConcatedFailReason(const std::string &reason) return reason + ret; } -void TestRunner::CollectResult( - const std::string& id, - const TestResultsCollectorBase::FailStatus status, - const std::string& reason, - const bool& isPerformanceTest, - const std::chrono::system_clock::duration& performanceTestDurationTime, - const std::chrono::system_clock::duration& performanceMaxTime) +void TestRunner::CollectResult(const std::string& id, const TestResult& result) { std::for_each(m_collectors.begin(), m_collectors.end(), [&](const TestResultsCollectors::value_type & collector) { - collector.second->CollectResult(id, - status, - reason, - isPerformanceTest, - performanceTestDurationTime, - performanceMaxTime); + collector.second->CollectResult(id, result); }); }