Add initial source codes for gtest
[platform/core/connectivity/stc-manager.git] / src / stc-manager.c
index 5e7ddd6..d9a4d80 100755 (executable)
@@ -59,6 +59,7 @@ static void __stc_manager_deinit(void)
        stc_deinit_db_guard();
        stc_db_deinitialize();
 
+       iptables_flush_chains();
        iptables_deinit();
        stc_manager_gdbus_deinit((gpointer)g_stc);
        stc_app_lifecycle_monitor_deinit();
@@ -77,8 +78,8 @@ static stc_s *__stc_manager_init(void)
 
        stc = MALLOC0(stc_s, 1);
        if (!stc) {
-               STC_LOGE("Failed to allocate memory for manager structure");
-               return NULL;
+               STC_LOGE("Failed to allocate memory for manager structure"); //LCOV_EXCL_LINE
+               return NULL; //LCOV_EXCL_LINE
        }
        g_stc = stc;
 
@@ -101,9 +102,9 @@ static stc_s *__stc_manager_init(void)
        return stc;
 
 handle_error:
-       STC_LOGD("Failed to initialize stc manager");
-       __stc_manager_deinit();
-       return NULL;
+       STC_LOGD("Failed to initialize stc manager"); //LCOV_EXCL_LINE
+       __stc_manager_deinit(); //LCOV_EXCL_LINE
+       return NULL; //LCOV_EXCL_LINE
 }
 
 stc_s *stc_get_manager(void)
@@ -111,6 +112,12 @@ stc_s *stc_get_manager(void)
        return g_stc;
 }
 
+void stc_stop_manager(void)
+{
+       if (g_stc && g_stc->main_loop)
+               g_main_loop_quit(g_stc->main_loop);
+}
+
 gint32 main(gint32 argc, gchar *argv[])
 {
        GMainLoop *main_loop = NULL;
@@ -118,8 +125,12 @@ gint32 main(gint32 argc, gchar *argv[])
 
        STC_LOGI("Smart Traffic Control Manager");
 
+#ifdef TIZEN_GTESTS
+       setenv("GCOV_PREFIX", "/tmp/daemon", 1);
+#endif
+
        if (daemon(0, 0) != 0)
-               STC_LOGE("Can't start daemon");
+               STC_LOGE("Can't start daemon"); //LCOV_EXCL_LINE
 
        /* Initialize required subsystems */
 #if !GLIB_CHECK_VERSION(2, 35, 0)