Merge branch 'cynara' into tizen 38/37338/1
authorLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Tue, 24 Mar 2015 19:32:02 +0000 (20:32 +0100)
committerLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Tue, 24 Mar 2015 19:55:06 +0000 (20:55 +0100)
Conflicts:
src/framework/include/dpl/test/test_runner.h
src/framework/src/test_runner.cpp

Change-Id: I7186c1d1e8f60e453ea5ffe4f7cfd1e1eca3a3bb

1  2 
src/framework/include/dpl/test/test_runner.h
src/framework/src/test_runner.cpp
src/framework/src/test_runner_child.cpp

  #include <dpl/colors.h>
  #include <dpl/gdbbacktrace.h>
  #include <dpl/singleton.h>
 +#include <dpl/test/performance_result.h>
+ #include <dpl/test/test_exception.h>
+ #include <dpl/test/test_failed.h>
+ #include <dpl/test/test_ignored.h>
 +#include <dpl/test/test_result.h>
  #include <dpl/test/test_results_collector.h>
  
  namespace DPL {
@@@ -63,12 -65,18 +67,14 @@@ class TestRunne
          m_currentTestCase(nullptr)
        , m_terminate(false)
        , m_allowChildLogs(false)
+       , m_deferDeepness(0U)
+       , m_firstDeferredExceptionType(DeferredExceptionType::DEFERRED_FAILED)
      {}
  
 -    void beginPerformanceTestTime(std::chrono::system_clock::duration maxTimeInMicroseconds);
 -    void endPerformanceTestTime();
 -    void getCurrentTestCasePerformanceResult(bool& isPerformanceTest,
 -                                             std::chrono::system_clock::duration& result,
 -                                             std::chrono::system_clock::duration& resultMax);
 -    void setCurrentTestCasePerformanceResult(bool isPerformanceTest,
 -                                             std::chrono::system_clock::duration result,
 -                                             std::chrono::system_clock::duration resultMax);
 +    void beginPerformance(std::chrono::system_clock::duration maxDurationInMicroseconds);
 +    void endPerformance();
 +    void setCurrentTestCasePerformanceResult(const PerformanceResultPtr &performance);
 +    ConstPerformanceResultPtr getCurrentTestCasePerformanceResult();
  
      void addFailReason(const std::string &reason);
  
  
      std::string getConcatedFailReason(const std::string &reason);
  
 -    void CollectResult(const std::string& id,
 -                       const TestResultsCollectorBase::FailStatus status
 -                           = TestResultsCollectorBase::FailStatus::NONE,
 -                       const std::string& reason = std::string(),
 -                       const bool& isPerformanceTest = false,
 -                       const std::chrono::system_clock::duration& performanceTime = std::chrono::microseconds::zero(),
 -                       const std::chrono::system_clock::duration& performanceMaxTime = std::chrono::microseconds::zero());
 +    void CollectResult(const std::string& id, const TestResult &result);
  
    public:
-     class TestFailed
-     {
-       private:
-         std::string m_message;
-       public:
-         TestFailed()
-         {}
-         //! \brief Failed test message creator
-         //!
-         //! \param[in] aTest string for tested expression
-         //! \param[in] aFile source file name
-         //! \param[in] aLine source file line
-         //! \param[in] aMessage error message
-         TestFailed(const char* aTest,
-                    const char* aFile,
-                    int aLine,
-                    const std::string &aMessage);
-         TestFailed(const std::string &message);
-         std::string GetMessage() const
-         {
-             return m_message;
-         }
-     };
-     class Ignored
-     {
-       private:
-         std::string m_message;
-       public:
-         Ignored()
-         {}
-         Ignored(const std::string &message) :
-             m_message(message)
-         {}
-         std::string GetMessage() const
-         {
-             return m_message;
-         }
-     };
      void MarkAssertion();
  
      void RegisterTest(const char *testName, TestCase proc);
@@@ -243,20 -206,21 +206,21 @@@ bool TestRunner::filterByXML(std::map<s
      return true;
  }
  
 -TestRunner::Status TestRunner::RunTestCase(const TestCaseStruct& testCase)
 +void TestRunner::RunTestCase(const TestCaseStruct& testCase)
  {
      setCurrentTestCase(&(const_cast<TestCaseStruct &>(testCase)));
+     m_deferDeepness = 0U;
      try {
          testCase.proc();
      } 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 Ignored &e) {
+     } catch (const TestIgnored &e) {
          if (m_runIgnored) {
              // Simple test have to be implemented
              CollectResult(testCase.name,
@@@ -321,15 -333,19 +323,15 @@@ void RunChildProc(TestRunner::TestCase 
          }
  
          if (pipeReturn == PipeWrapper::ERROR) {
-             throw TestRunner::TestFailed("Reading pipe error");
+             throw TestFailed("Reading pipe error");
          }
  
 -        if (code == CHILD_TEST_PASS && msgType == MSG_TYPE_PERF_TIME) {
 -            DPL::Test::TestRunnerSingleton::Instance().setCurrentTestCasePerformanceResult(true,
 -                                                                                           time_m,
 -                                                                                           timeMax_m);
 -        }
 +        TestRunnerSingleton::Instance().setCurrentTestCasePerformanceResult(performance);
  
          if (code == CHILD_TEST_FAIL) {
-             throw TestRunner::TestFailed(message);
+             throw TestFailed(message);
          } else if (code == CHILD_TEST_IGNORED) {
-             throw TestRunner::Ignored(message);
+             throw TestIgnored(message);
          }
      } else {
          // child code