Move Summary collector to test framework 96/28696/12
authorMarcin Niesluchowski <m.niesluchow@samsung.com>
Mon, 13 Oct 2014 16:39:53 +0000 (18:39 +0200)
committerMarcin Niesluchowski <m.niesluchow@samsung.com>
Mon, 1 Dec 2014 17:02:58 +0000 (18:02 +0100)
Change-Id: Ief5a3b837382651bd030642c262d3c69c408a4bb

17 files changed:
README
tests/common/CMakeLists.txt
tests/cynara-tests/cynara-test.cpp
tests/framework/config.cmake
tests/framework/include/dpl/test/test_results_collector_summary.h [moved from tests/common/summary_collector.h with 74% similarity]
tests/framework/src/test_results_collector.cpp
tests/framework/src/test_results_collector_summary.cpp [moved from tests/common/summary_collector.cpp with 62% similarity]
tests/libprivilege-control-tests/libprivilege-control-test.cpp
tests/libsmack-tests/libsmack-test.cpp
tests/security-manager-tests/security_manager_tests.cpp
tests/security-server-tests/security_server_measurer_API_speed.cpp
tests/security-server-tests/security_server_tests_client_smack.cpp
tests/security-server-tests/security_server_tests_password.cpp
tests/security-server-tests/security_server_tests_privilege.cpp
tests/security-server-tests/security_server_tests_stress.cpp
tests/security-server-tests/server.cpp
tests/smack-dbus-tests/smack_dbus_tests.cpp

diff --git a/README b/README
index 9caea47..c92cbb2 100644 (file)
--- a/README
+++ b/README
@@ -153,8 +153,8 @@ Collectors are classes which collect test results. Each class does it differentl
 Collectors can be registered by --output parameter (see HOW TO RUN section) but
 there is also another collector created to write summary.
 
-tests-common
-  summary_collector.h
+dpl-test-framework
+  test_results_collector_summary.h
     SummaryCollector
           Collector writing tests summary. Call SummaryCollector::Register() to
           register it
index 0fa8305..c595bf7 100644 (file)
@@ -17,7 +17,6 @@ SET(COMMON_TARGET_TEST_SOURCES
     ${PROJECT_SOURCE_DIR}/tests/common/tests_common.cpp
     ${PROJECT_SOURCE_DIR}/tests/common/access_provider.cpp
     ${PROJECT_SOURCE_DIR}/tests/common/smack_access.cpp
-    ${PROJECT_SOURCE_DIR}/tests/common/summary_collector.cpp
     ${PROJECT_SOURCE_DIR}/tests/common/dbus_access.cpp
     ${PROJECT_SOURCE_DIR}/tests/common/memory.cpp
     ${PROJECT_SOURCE_DIR}/tests/common/db_sqlite.cpp
index af98c77..2ff4084 100644 (file)
  */
 
 #include <dpl/test/test_runner.h>
-#include <summary_collector.h>
 
 int main (int argc, char *argv[])
 {
-    SummaryCollector::Register();
     int status = DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
     return status;
 }
index 2335298..a2cb0ff 100644 (file)
@@ -36,6 +36,7 @@ SET(DPL_FRAMEWORK_TEST_SOURCES
     ${PROJECT_SOURCE_DIR}/tests/framework/src/test_results_collector_commons.cpp
     ${PROJECT_SOURCE_DIR}/tests/framework/src/test_results_collector_console.cpp
     ${PROJECT_SOURCE_DIR}/tests/framework/src/test_results_collector_html.cpp
+    ${PROJECT_SOURCE_DIR}/tests/framework/src/test_results_collector_summary.cpp
     ${PROJECT_SOURCE_DIR}/tests/framework/src/test_results_collector_xml.cpp
     ${PROJECT_SOURCE_DIR}/tests/framework/src/test_runner_child.cpp
     ${PROJECT_SOURCE_DIR}/tests/framework/src/test_runner.cpp
  *    See the License for the specific language governing permissions and
  *    limitations under the License.
  */
-
 /*
- * @file        summary_collector.h
+ * @file        test_results_collector_summary.h
+ * @author      Marcin Niesluchowski (m.niesluchow@samsung.com)
  * @author      Michal Witanowski (m.witanowski@samsung.com)
  * @version     1.0
- * @brief       Implementation of custom test results collector needed by summary view.
+ * @brief       Header file containing SummaryCollector class declaration.
  */
 
-#ifndef _RAW_RESULTS_COLLECTOR_H_
-#define _RAW_RESULTS_COLLECTOR_H_
+#ifndef DPL_TEST_RESULTS_COLLECTOR_SUMMARY_H
+#define DPL_TEST_RESULTS_COLLECTOR_SUMMARY_H
 
 #include <dpl/test/test_results_collector.h>
-#include <chrono>
+
+namespace DPL {
+namespace Test {
 
 /*
  * Custom test runner results collector. The results (total test cases, failed, etc.) are
  * appended to a file, wihich is parsed after execution of all tests in oreder to
  * display summary view.
  */
-class SummaryCollector : public DPL::Test::TestResultsCollectorBase
+class SummaryCollector : public TestResultsCollectorBase
 {
     unsigned int m_total, m_succeeded, m_failed, m_ignored; // counters
 
@@ -48,14 +50,16 @@ class SummaryCollector : public DPL::Test::TestResultsCollectorBase
                        const FailStatus status,
                        const std::string& /*reason = ""*/,
                        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());
+                       const std::chrono::system_clock::duration& performanceTime
+                           = std::chrono::microseconds::zero(),
+                       const std::chrono::system_clock::duration& performanceMaxTime
+                           = std::chrono::microseconds::zero());
 
 public:
     static TestResultsCollectorBase* Constructor();
-    static void Register();
 };
 
-#endif
+} // namespace Test
+} // namespace DPL
+
+#endif // DPL_TEST_RESULTS_COLLECTOR_SUMMARY_H
index 48cc93b..a0eb74f 100644 (file)
@@ -23,6 +23,7 @@
 #include <dpl/test/test_results_collector.h>
 #include <dpl/test/test_results_collector_console.h>
 #include <dpl/test/test_results_collector_html.h>
+#include <dpl/test/test_results_collector_summary.h>
 #include <dpl/test/test_results_collector_xml.h>
 
 namespace DPL {
@@ -74,6 +75,9 @@ int RegisterCollectorConstructors()
         "html",
         &HtmlCollector::Constructor);
     TestResultsCollectorBase::RegisterCollectorConstructor(
+        "summary",
+        &SummaryCollector::Constructor);
+    TestResultsCollectorBase::RegisterCollectorConstructor(
         "xml",
         &XmlCollector::Constructor);
 
similarity index 62%
rename from tests/common/summary_collector.cpp
rename to tests/framework/src/test_results_collector_summary.cpp
index 3af8157..e478112 100644 (file)
  *    See the License for the specific language governing permissions and
  *    limitations under the License.
  */
-
 /*
- * @file        summary_collector.cpp
+ * @file        test_results_collector_summary.cpp
+ * @author      Marcin Niesluchowski (m.niesluchow@samsung.com)
  * @author      Michal Witanowski (m.witanowski@samsung.com)
  * @version     1.0
- * @brief       Implementation of custom test results collector needed by summary view.
+ * @brief       Source file containing SummaryCollector class definition.
  */
 
-#include <summary_collector.h>
 #include <fstream>
 
+#include "dpl/test/test_results_collector_summary.h"
+
+namespace DPL {
+namespace Test {
+
 namespace {
+
     const char* summaryFileName = "/tmp/security-tests-summary-file";
-    const char* summaryCollectorName =  "summary";
-};
+
+}
 
 SummaryCollector::SummaryCollector()
 {
@@ -35,7 +40,7 @@ SummaryCollector::SummaryCollector()
 }
 
 
-// Overrides DPL::Test::TestResultsCollectorBase::Start() virtual method.
+// Overrides TestResultsCollectorBase::Start() virtual method.
 void SummaryCollector::Start()
 {
     m_total = m_succeeded = m_failed = m_ignored = 0;
@@ -57,12 +62,12 @@ void SummaryCollector::Finish()
 }
 
 void SummaryCollector::CollectResult(const std::string& /*id*/,
-                                      const std::string& /*description*/,
-                                      const FailStatus status,
-                                      const std::string& /*reason = ""*/,
-                                      const bool& isPerformanceTest,
-                                      const std::chrono::system_clock::duration& performanceTime,
-                                      const std::chrono::system_clock::duration& performanceMaxTime)
+                                     const std::string& /*description*/,
+                                     const FailStatus status,
+                                     const std::string& /*reason = ""*/,
+                                     const bool& isPerformanceTest,
+                                     const std::chrono::system_clock::duration& performanceTime,
+                                     const std::chrono::system_clock::duration& performanceMaxTime)
 {
     (void)isPerformanceTest;
     (void)performanceTime;
@@ -76,9 +81,9 @@ void SummaryCollector::CollectResult(const std::string& /*id*/,
 }
 
 void SummaryCollector::CollectResult(const std::string& /*id*/,
-                                      const std::string& /*description*/,
-                                      const FailStatus status,
-                                      const std::string& /*reason = ""*/)
+                                     const std::string& /*description*/,
+                                     const FailStatus status,
+                                     const std::string& /*reason = ""*/)
 {
     switch (status) {
         case FailStatus::IGNORED: ++m_ignored; break;
@@ -88,14 +93,10 @@ void SummaryCollector::CollectResult(const std::string& /*id*/,
     ++m_total;
 }
 
-DPL::Test::TestResultsCollectorBase* SummaryCollector::Constructor()
+TestResultsCollectorBase* SummaryCollector::Constructor()
 {
     return new SummaryCollector();
 }
 
-void SummaryCollector::Register()
-{
-    //register custom results collector
-    DPL::Test::TestResultsCollectorBase::RegisterCollectorConstructor(summaryCollectorName,
-        &SummaryCollector::Constructor);
-}
+} // namespace Test
+} // namespace DPL
index 57e9780..dbec70c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
 
 #include <dpl/test/test_runner.h>
 #include <dpl/log/log.h>
-#include <summary_collector.h>
 
 int main (int argc, char *argv[])
 {
     LogInfo("Starting libprivilege-control tests");
 
-    SummaryCollector::Register();
     int status = DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
     return status;
 }
index 556e2a1..ccbb00e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
  * @brief       libsmack test runer
  */
 #include <dpl/test/test_runner.h>
-#include <summary_collector.h>
 
 int main (int argc, char *argv[])
 {
-    SummaryCollector::Register();
     int status = DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
     return status;
 }
index ab6c0cd..fe90f8e 100644 (file)
@@ -2,7 +2,6 @@
 #include <fcntl.h>
 #include <stdio.h>
 #include <memory.h>
-#include <summary_collector.h>
 #include <string>
 #include <unordered_set>
 #include <sys/capability.h>
@@ -619,6 +618,5 @@ RUNNER_CHILD_TEST(security_manager_05_drop_process_capabilities)
 
 int main(int argc, char *argv[])
 {
-    SummaryCollector::Register();
     return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
 }
index f9da513..213f9be 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Contact: Bumjin Im <bj.im@samsung.com>
  *
@@ -49,7 +49,6 @@
 #include <unistd.h>
 #include <memory.h>
 #include "security_server_mockup.h"
-#include <summary_collector.h>
 #include <smack_access.h>
 
 IMPLEMENT_SAFE_SINGLETON(DPL::Log::LogSystem);
@@ -723,7 +722,6 @@ RUNNER_TEST(m170_security_server_check_privilege_by_pid) {
 
 int main(int argc, char *argv[])
 {
-    SummaryCollector::Register();
     securityClientEnableLogSystem();
     DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
     return 0;
index 194584e..fa7c13b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
  */
 /*
  * @file    security_server_tests_client_smack.cpp
@@ -31,7 +31,6 @@
 #include <security-server.h>
 #include <access_provider.h>
 #include "tests_common.h"
-#include <summary_collector.h>
 #include <memory.h>
 
 #define PROPER_COOKIE_SIZE 20
@@ -545,6 +544,5 @@ RUNNER_TEST_NOSMACK(tc18_security_server_get_smacklabel_cookie_nosmack) {
 
 int main(int argc, char *argv[])
 {
-    SummaryCollector::Register();
     return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
 }
index d914e5d..b9f0584 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
  */
 /*
  * @file    security_server_tests_password.cpp
@@ -33,7 +33,6 @@
 #include <dlog.h>
 #include "security_server_clean_env.h"
 #include "security_server_tests_common.h"
-#include <summary_collector.h>
 
 
 // the maximum time (in seconds) passwords can expire in
@@ -1523,6 +1522,5 @@ RUNNER_TEST(tc53_security_server_is_pwd_valid)
 
 int main(int argc, char *argv[])
 {
-    SummaryCollector::Register();
     return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
 }
index 4b0ac72..c7e698f 100644 (file)
@@ -1,7 +1,5 @@
 #include <dpl/test/test_runner.h>
 
-#include <summary_collector.h>
-
 #include <libprivilege-control_test_common.h>
 
 #include <security-server.h>
@@ -123,6 +121,5 @@ RUNNER_TEST(sstp_01_security_server_app_has_privilege)
 
 int main(int argc, char *argv[])
 {
-    SummaryCollector::Register();
     return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
 }
index 9b74a62..b8f7e12 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
  */
 /*
  * @file    security_server_tests_stress.cpp
@@ -12,7 +12,6 @@
 #include <dpl/test/test_runner.h>
 #include <dpl/test/test_runner_multiprocess.h>
 #include <tests_common.h>
-#include <summary_collector.h>
 #include <iostream>
 #include <sys/smack.h>
 #include <cstddef>
@@ -185,7 +184,6 @@ RUNNER_CHILD_TEST_NOSMACK(tc_stress_cookie_api_no_smack)
 
 int main (int argc, char *argv[])
 {
-    SummaryCollector::Register();
     return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
 }
 
index d7929eb..e7d94b7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
  */
 /*
  * @file    security_server_tests_server.cpp
@@ -33,7 +33,6 @@
 #include "tests_common.h"
 #include <smack_access.h>
 #include <access_provider.h>
-#include <summary_collector.h>
 
 const char *TEST03_SUBJECT = "subject_0f09f7cc";
 const char *TEST04_SUBJECT = "subject_57dfbfc5";
@@ -429,6 +428,5 @@ int main(int argc, char *argv[]) {
         printf("Error: %s must be executed by root\n", argv[0]);
         exit(1);
     }
-    SummaryCollector::Register();
     return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
 }
index 080e5b0..233994e 100644 (file)
@@ -4,7 +4,6 @@
 #include <dpl/test/test_runner.h>
 #include <dpl/test/test_runner_multiprocess.h>
 #include <dbus/dbus.h>
-#include <summary_collector.h>
 #include "tests_common.h"
 
 #define DBUS_SERVER_NAME                        "test.method.server"
@@ -302,6 +301,5 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(tc01_smack_context_from_DBus_nosmack)
 
 int main(int argc, char *argv[])
 {
-    SummaryCollector::Register();
     return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
 }