Add initial source codes for gtest
[platform/core/connectivity/stc-manager.git] / src / monitor / stc-monitor.c
index 268c5cf..62a2c5c 100755 (executable)
@@ -277,6 +277,7 @@ static void __rstns_tree_key_free(gpointer data)
        FREE(key);
 }
 
+//LCOV_EXCL_START
 static gboolean __processes_tree_foreach_print(gpointer key, gpointer value,
                                               gpointer data)
 {
@@ -314,6 +315,7 @@ static void __apps_tree_printall(void)
 {
        g_tree_foreach(g_system->apps, __apps_tree_foreach_print, NULL);
 }
+//LCOV_EXCL_STOP
 
 static gboolean __apps_tree_foreach_remove_pid(gpointer key, gpointer value,
                                               gpointer data)
@@ -323,7 +325,7 @@ static gboolean __apps_tree_foreach_remove_pid(gpointer key, gpointer value,
 
        if (!g_tree_remove(app_value->processes, context->proc_key)) {
                if (STC_DEBUG_LOG)
-                       STC_LOGD("key not found");
+                       STC_LOGD("key not found"); //LCOV_EXCL_LINE
                return FALSE;
        }
 
@@ -357,6 +359,7 @@ static stc_process_value_s * __process_lookup(GTree *processes,
        return lookup;
 }
 
+//LCOV_EXCL_START
 static gboolean __processes_tree_check_empty(gpointer key, gpointer value,
                                             gpointer data)
 {
@@ -364,6 +367,7 @@ static gboolean __processes_tree_check_empty(gpointer key, gpointer value,
        (*pid_count)++;
        return TRUE;
 }
+//LCOV_EXCL_STOP
 
 static gboolean __add_application_monitor(gpointer key, gpointer value,
                                          gpointer data)
@@ -381,11 +385,11 @@ static gboolean __add_application_monitor(gpointer key, gpointer value,
                struct nfacct_rule counter;
 
                if (!stc->carg) {
-                       stc->carg = MALLOC0(counter_arg_s, 1);
-                       if (stc->carg == NULL)
-                               return FALSE;
+                       stc->carg = MALLOC0(counter_arg_s, 1); //LCOV_EXCL_LINE
+                       if (stc->carg == NULL) //LCOV_EXCL_LINE
+                               return FALSE; //LCOV_EXCL_LINE
 
-                       stc->carg->sock = stc_monitor_get_counter_socket();
+                       stc->carg->sock = stc_monitor_get_counter_socket(); //LCOV_EXCL_LINE
                }
 
                memset(&counter, 0, sizeof(struct nfacct_rule));
@@ -424,11 +428,11 @@ static gboolean __remove_application_monitor(gpointer key, gpointer value,
                struct nfacct_rule counter;
 
                if (!stc->carg) {
-                       stc->carg = MALLOC0(counter_arg_s, 1);
-                       if (stc->carg == NULL)
-                               return FALSE;
+                       stc->carg = MALLOC0(counter_arg_s, 1); //LCOV_EXCL_LINE
+                       if (stc->carg == NULL) //LCOV_EXCL_LINE
+                               return FALSE; //LCOV_EXCL_LINE
 
-                       stc->carg->sock = stc_monitor_get_counter_socket();
+                       stc->carg->sock = stc_monitor_get_counter_socket(); //LCOV_EXCL_LINE
                }
 
                memset(&counter, 0, sizeof(struct nfacct_rule));
@@ -506,12 +510,12 @@ static void __process_restriction(enum traffic_restriction_type rst_type,
                effective_data_warn_limit -= info.data_counter;
 
                if (effective_data_limit < 0) {
-                       effective_data_limit = 0;
-                       rstn_value->data_limit_reached = TRUE;
+                       effective_data_limit = 0; //LCOV_EXCL_LINE
+                       rstn_value->data_limit_reached = TRUE; //LCOV_EXCL_LINE
                }
 
                if (effective_data_warn_limit < 0)
-                       effective_data_warn_limit = 0;
+                       effective_data_warn_limit = 0; //LCOV_EXCL_LINE
 
                STC_LOGD("datausage [%lld] bytes", info.data_counter);
        }
@@ -528,19 +532,18 @@ static void __process_restriction(enum traffic_restriction_type rst_type,
                        struct nfacct_rule counter;
                        stc_s *stc = stc_get_manager();
                        if (!stc) {
-                               g_free(default_ifname);
-                               return;
+                               g_free(default_ifname); //LCOV_EXCL_LINE
+                               return; //LCOV_EXCL_LINE
                        }
 
                        if (!stc->carg) {
-                               stc->carg = MALLOC0(counter_arg_s, 1);
-                               if (stc->carg == NULL) {
-                                       g_free(default_ifname);
-                                       return;
+                               stc->carg = MALLOC0(counter_arg_s, 1); //LCOV_EXCL_LINE
+                               if (stc->carg == NULL) { //LCOV_EXCL_LINE
+                                       g_free(default_ifname); //LCOV_EXCL_LINE
+                                       return; //LCOV_EXCL_LINE
                                }
 
-                               stc->carg->sock =
-                                       stc_monitor_get_counter_socket();
+                               stc->carg->sock = stc_monitor_get_counter_socket(); //LCOV_EXCL_LINE
                        }
 
                        counter.carg = stc->carg;
@@ -574,19 +577,18 @@ static void __process_restriction(enum traffic_restriction_type rst_type,
                        struct nfacct_rule counter;
                        stc_s *stc = stc_get_manager();
                        if (!stc) {
-                               g_free(default_ifname);
-                               return;
+                               g_free(default_ifname); //LCOV_EXCL_LINE
+                               return; //LCOV_EXCL_LINE
                        }
 
                        if (!stc->carg) {
-                               stc->carg = MALLOC0(counter_arg_s, 1);
-                               if (stc->carg == NULL) {
-                                       g_free(default_ifname);
-                                       return;
+                               stc->carg = MALLOC0(counter_arg_s, 1); //LCOV_EXCL_LINE
+                               if (stc->carg == NULL) { //LCOV_EXCL_LINE
+                                       g_free(default_ifname); //LCOV_EXCL_LINE
+                                       return; //LCOV_EXCL_LINE
                                }
 
-                               stc->carg->sock =
-                                       stc_monitor_get_counter_socket();
+                               stc->carg->sock = stc_monitor_get_counter_socket(); //LCOV_EXCL_LINE
                        }
 
                        counter.carg = stc->carg;
@@ -616,6 +618,7 @@ static void __process_restriction(enum traffic_restriction_type rst_type,
        }
 }
 
+//LCOV_EXCL_START
 static gboolean __remove_rstns_foreach_application(gpointer key,
                                                   gpointer value,
                                                   gpointer data)
@@ -643,6 +646,7 @@ static gboolean __remove_rstns_foreach_application(gpointer key,
 out:
        return FALSE;
 }
+//LCOV_EXCL_STOP
 
 static void __remove_rstns_for_application(gchar *app_id)
 {
@@ -660,8 +664,8 @@ static stc_error_e __application_remove_if_empty(const stc_app_key_s *app_key)
 
        lookup = __application_lookup(g_system->apps, app_key);
        if (!lookup) {
-               STC_LOGE("app_key not found");
-               return STC_ERROR_NO_DATA;
+               STC_LOGE("app_key not found"); //LCOV_EXCL_LINE
+               return STC_ERROR_NO_DATA; //LCOV_EXCL_LINE
        }
 
        g_tree_foreach(lookup->processes, __processes_tree_check_empty,
@@ -675,8 +679,8 @@ static stc_error_e __application_remove_if_empty(const stc_app_key_s *app_key)
        }
 
        if (!g_tree_remove(g_system->apps, app_key)) {
-               ret = STC_ERROR_NO_DATA;
-               STC_LOGE("key not found");
+               ret = STC_ERROR_NO_DATA; //LCOV_EXCL_LINE
+               STC_LOGE("key not found"); //LCOV_EXCL_LINE
        }
 
        return ret;
@@ -704,6 +708,7 @@ static gboolean __process_contr_reply(GIOChannel *source,
                                      GIOCondition condition,
                                      gpointer user_data);
 
+//LCOV_EXCL_START
 static stc_error_e __close_and_reopen_contr_sock(stc_system_s *system)
 {
        GIOChannel *gio = NULL;
@@ -854,8 +859,8 @@ static gboolean __rstn_counter_update_foreach_classid(gpointer key,
                goto try_next_callback;
 
        if (rstn_value->data_limit_reached == TRUE) {
-               context->data_limit_reached = TRUE;
-               goto try_next_callback;
+               context->data_limit_reached = TRUE; //LCOV_EXCL_LINE
+               goto try_next_callback; //LCOV_EXCL_LINE
        }
 
        classid = context->counter->classid;
@@ -870,6 +875,7 @@ static gboolean __rstn_counter_update_foreach_classid(gpointer key,
 try_next_callback:
        return rv;
 }
+//LCOV_EXCL_STOP
 
 static gboolean __update_app_statistics(gpointer key, gpointer value,
                                        gpointer data)
@@ -890,7 +896,7 @@ static gboolean __update_app_statistics(gpointer key, gpointer value,
        if (STC_IFACE_DATACALL == stat_key.iftype)
                stat_key.subscriber_id = g_strdup(default_connection->subscriber_id);
        else
-               stat_key.subscriber_id = g_strdup("none_subid");
+               stat_key.subscriber_id = g_strdup("none_subid"); //LCOV_EXCL_LINE
 
        g_strlcpy(stat_key.ifname, default_connection->ifname,
                  MAX_IFACE_LENGTH);
@@ -938,6 +944,7 @@ static gboolean __flush_apps_stats_to_database(gpointer user_data)
        return G_SOURCE_REMOVE;
 }
 
+//LCOV_EXCL_START
 static gboolean __update_counter_statistics(gpointer key, gpointer value,
                                            gpointer data)
 {
@@ -969,6 +976,7 @@ static gboolean __flush_rstns_counter_to_database(gpointer user_data)
        STC_LOGI("Flushed rstns counters to database");
        return G_SOURCE_REMOVE;
 }
+//LCOV_EXCL_STOP
 
 static void __app_counter_update(stc_app_key_s *app_key,
                                 stc_app_value_s *app_value,
@@ -981,7 +989,7 @@ static void __app_counter_update(stc_app_key_s *app_key,
                g_system->apps_tree_updated = TRUE;
 
                if (STC_DEBUG_LOG)
-                       __apps_tree_foreach_print(app_key, app_value, NULL);
+                       __apps_tree_foreach_print(app_key, app_value, NULL); //LCOV_EXCL_LINE
                break;
        case NFACCT_COUNTER_OUT:
                app_value->data_usage.out_bytes += context->bytes;
@@ -989,10 +997,10 @@ static void __app_counter_update(stc_app_key_s *app_key,
                g_system->apps_tree_updated = TRUE;
 
                if (STC_DEBUG_LOG)
-                       __apps_tree_foreach_print(app_key, app_value, NULL);
+                       __apps_tree_foreach_print(app_key, app_value, NULL); //LCOV_EXCL_LINE
                break;
        default:
-               STC_LOGE("unknown iotype");
+               STC_LOGE("unknown iotype"); //LCOV_EXCL_LINE
        }
 }
 
@@ -1049,11 +1057,11 @@ static void __fill_nfacct_result(char *cnt_name, int64_t bytes,
        };
 
        if (STC_DEBUG_LOG)
-               STC_LOGD("cnt_name %s", cnt_name);
+               STC_LOGD("cnt_name %s", cnt_name); //LCOV_EXCL_LINE
 
        if (!recreate_counter_by_name(cnt_name, &counter)) {
-               STC_LOGE("Can't parse counter name %s", cnt_name);
-               return;
+               STC_LOGE("Can't parse counter name %s", cnt_name); //LCOV_EXCL_LINE
+               return; //LCOV_EXCL_LINE
        }
 
        STC_LOGI("classid %lu, iftype %u, iotype %d, intend %d, ifname %s, bytes %lld",
@@ -1120,8 +1128,8 @@ static void __process_network_counter(struct genl *ans,
        netlink_serialization_command *netlink =
                netlink_create_command(&ser_params);
        if (!netlink) {
-               STC_LOGE("Can not create command");
-               return;
+               STC_LOGE("Can not create command"); //LCOV_EXCL_LINE
+               return; //LCOV_EXCL_LINE
        }
 
        netlink->deserialize_answer(&(netlink->params));
@@ -1136,27 +1144,32 @@ static gboolean __process_contr_reply(GIOChannel *source,
        int ret;
        stc_s *stc = stc_get_manager();
 
+#ifdef TIZEN_GTESTS
+       void __gcov_flush(void);
+       __gcov_flush();
+#endif
+
        if ((condition & G_IO_ERR) || (condition & G_IO_HUP) ||
            (condition & G_IO_NVAL)) {
                /* G_IO_ERR/G_IO_HUP/G_IO_NVAL received */
 
-               STC_LOGE("Counter socket received G_IO event, closing socket."
+               STC_LOGE("Counter socket received G_IO event, closing socket." //LCOV_EXCL_LINE
                         "G_IO_ERR [%d], G_IO_HUP [%d], G_IO_NVAL [%s]",
                         (condition & G_IO_ERR), (condition & G_IO_HUP),
                         (condition & G_IO_NVAL));
-               __close_and_reopen_contr_sock(g_system);
-               return FALSE;
+               __close_and_reopen_contr_sock(g_system); //LCOV_EXCL_LINE
+               return FALSE; //LCOV_EXCL_LINE
        }
 
        ans = MALLOC0(struct genl, 1);
        if (ans == NULL) {
-               STC_LOGE("Failed allocate memory to genl reply message");
-               return TRUE;
+               STC_LOGE("Failed allocate memory to genl reply message"); //LCOV_EXCL_LINE
+               return TRUE; //LCOV_EXCL_LINE
        }
 
        if (stc == NULL) {
-               STC_LOGE("Can't get stc data");
-               goto out;
+               STC_LOGE("Can't get stc data"); //LCOV_EXCL_LINE
+               goto out; //LCOV_EXCL_LINE
        }
 
        ret = read_netlink(sock, ans, sizeof(struct genl));
@@ -1170,6 +1183,7 @@ static gboolean __process_contr_reply(GIOChannel *source,
        g_idle_add(__flush_apps_stats_to_database, NULL);
        g_idle_add(__flush_rstns_counter_to_database, NULL);
 out:
+
        FREE(ans);
        return TRUE;
 }
@@ -1187,6 +1201,11 @@ static gboolean __update_contr_cb(void *user_data)
                stc->carg->sock = stc_monitor_get_counter_socket();
        }
 
+#ifdef TIZEN_GTESTS
+       void __gcov_flush(void);
+       __gcov_flush();
+#endif
+
        /* STC_LOGD("Get all counters"); */
        nfacct_send_get_all(stc->carg);
 
@@ -1256,6 +1275,7 @@ static gboolean __add_restriction_debug(gpointer key, gpointer value,
        return FALSE;
 }
 
+//LCOV_EXCL_START
 static gboolean __add_restriction(gpointer key, gpointer value, gpointer data)
 {
        stc_rstn_key_s *rstn_key = (stc_rstn_key_s *)key;
@@ -1272,6 +1292,7 @@ static gboolean __add_restriction(gpointer key, gpointer value, gpointer data)
 
        return FALSE;
 }
+//LCOV_EXCL_STOP
 
 static stc_error_e __rstn_tree_remove(stc_rstn_key_s *key)
 {
@@ -1281,8 +1302,8 @@ static stc_error_e __rstn_tree_remove(stc_rstn_key_s *key)
 
        lookup_value = __rstn_lookup(g_system->rstns, key);
        if (!lookup_value) {
-               STC_LOGE("key not found");
-               return STC_ERROR_NO_DATA;
+               STC_LOGE("key not found"); //LCOV_EXCL_LINE
+               return STC_ERROR_NO_DATA; //LCOV_EXCL_LINE
        }
 
        __remove_restriction(key, lookup_value, NULL);
@@ -1291,8 +1312,8 @@ static stc_error_e __rstn_tree_remove(stc_rstn_key_s *key)
        table_counters_delete(lookup_value->restriction_id);
 
        if (!g_tree_remove(g_system->rstns, key)) {
-               STC_LOGD("key not found");
-               return STC_ERROR_NO_DATA;
+               STC_LOGD("key not found"); //LCOV_EXCL_LINE
+               return STC_ERROR_NO_DATA; //LCOV_EXCL_LINE
        }
 
        return STC_ERROR_NONE;
@@ -1309,15 +1330,15 @@ static stc_error_e __rstn_tree_add(stc_rstn_key_s *key,
        if (!rstn_value) {
                stc_rstn_key_s *rstn_key = MALLOC0(stc_rstn_key_s, 1);
                if (!rstn_key) {
-                       STC_LOGE("rstn_key allocation failed");
-                       return STC_ERROR_OUT_OF_MEMORY;
+                       STC_LOGE("rstn_key allocation failed"); //LCOV_EXCL_LINE
+                       return STC_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
                }
 
                rstn_value = MALLOC0(stc_rstn_value_s, 1);
                if (!rstn_value) {
-                       STC_LOGE("rstn_value allocation failed");
-                       FREE(rstn_key);
-                       return STC_ERROR_OUT_OF_MEMORY;
+                       STC_LOGE("rstn_value allocation failed"); //LCOV_EXCL_LINE
+                       FREE(rstn_key); //LCOV_EXCL_LINE
+                       return STC_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
                }
 
                rstn_key->app_id = g_strdup(key->app_id);
@@ -1346,6 +1367,7 @@ static stc_error_e __rstn_tree_add(stc_rstn_key_s *key,
        return STC_ERROR_NONE;
 }
 
+//LCOV_EXCL_START
 static stc_cb_ret_e __insert_restriction_cb(const table_restrictions_info *info,
                                            void *user_data)
 {
@@ -1419,6 +1441,7 @@ static gboolean __add_rstn_foreach_application(gpointer key,
 out:
        return FALSE;
 }
+//LCOV_EXCL_STOP
 
 static void __add_rstns_for_application(gchar *app_id)
 {
@@ -1432,7 +1455,7 @@ static void __add_application_by_interface(const char *app_id)
        stc_app_value_s app_value;
 
        if (app_id == NULL)
-               return;
+               return; //LCOV_EXCL_LINE
 
        memset(&app_key, 0, sizeof(stc_app_key_s));
        memset(&app_value, 0, sizeof(stc_app_value_s));
@@ -1457,21 +1480,22 @@ static int __vconf_get_int(const char *key, int *value)
 
        ret = vconf_get_int(key, value);
        if (ret != VCONF_OK) {
-               STC_LOGE("Failed to get vconfkey [%s] value", key);
-               return -1;
+               STC_LOGE("Failed to get vconfkey [%s] value", key); //LCOV_EXCL_LINE
+               return -1; //LCOV_EXCL_LINE
        }
 
        return 0;
 }
 
+//LCOV_EXCL_START
 static int __vconf_set_int(const char *key, int value)
 {
        int ret = 0;
 
        ret = vconf_set_int(key, value);
        if (ret != VCONF_OK) {
-               STC_LOGE("Failed to set vconfkey [%s] value", key);
-               return -1;
+               STC_LOGE("Failed to set vconfkey [%s] value", key); //LCOV_EXCL_LINE
+               return -1; //LCOV_EXCL_LINE
        }
 
        return 0;
@@ -1523,6 +1547,7 @@ static stc_error_e __process_update_background(void)
 
        return STC_ERROR_NONE;
 }
+//LCOV_EXCL_STOP
 
 #if 0
 static void __excn_hash_foreach_print(gpointer key, gpointer value,
@@ -1542,6 +1567,7 @@ static void __excn_hash_printall(void)
 }
 #endif
 
+//LCOV_EXCL_START
 static gboolean __remove_exception_app(gpointer key, gpointer value,
                                        gpointer data)
 {
@@ -1552,10 +1578,11 @@ static gboolean __remove_exception_app(gpointer key, gpointer value,
 
        return FALSE;
 }
+//LCOV_EXCL_STOP
 
 static void __remove_exception_appall(void)
 {
-       g_hash_table_foreach_remove(g_system->excns_hash,
+       g_hash_table_foreach_remove(g_system->excns_hash, //LCOV_EXCL_LINE
                __remove_exception_app, NULL);
 }
 
@@ -1567,7 +1594,7 @@ static stc_cb_ret_e __insert_exception_cb(const stc_exceptions_info *info,
        if (g_hash_table_insert(g_system->excns_hash,
                        g_strdup(info->process_name),
                        g_strdup(info->exe_type)) != TRUE)
-               ret = STC_CANCEL;
+               ret = STC_CANCEL; //LCOV_EXCL_LINE
 
        return ret;
 }
@@ -1580,6 +1607,7 @@ static void __fill_exceptions_list(void)
        /* __excn_hash_printall(); */
 }
 
+//LCOV_EXCL_START
 static gboolean __update_exceptions_app_list(void *user_data)
 {
        __remove_exception_appall();
@@ -1589,6 +1617,7 @@ static gboolean __update_exceptions_app_list(void *user_data)
 
        return TRUE;
 }
+//LCOV_EXCL_STOP
 
 stc_error_e stc_monitor_init(void)
 {
@@ -1618,9 +1647,9 @@ stc_error_e stc_monitor_init(void)
        /* create netlink socket for updating kernel counters */
        system->contr_sock = create_netlink(NETLINK_NETFILTER, 0);
        if (system->contr_sock < 0) {
-               STC_LOGE("failed to open socket");
-               FREE(system);
-               return STC_ERROR_FAIL;
+               STC_LOGE("failed to open socket"); //LCOV_EXCL_LINE
+               FREE(system); //LCOV_EXCL_LINE
+               return STC_ERROR_FAIL; //LCOV_EXCL_LINE
        }
 
        gio = g_io_channel_unix_new(system->contr_sock);
@@ -1646,9 +1675,9 @@ stc_error_e stc_monitor_init(void)
                                                         __update_contr_cb,
                                                         NULL);
        if (g_system->contr_timer_id == 0) {
-               STC_LOGE("Failed to register kernel counters update timer");
-               __close_contr_sock(g_system);
-               return STC_ERROR_FAIL;
+               STC_LOGE("Failed to register kernel counters update timer"); //LCOV_EXCL_LINE
+               __close_contr_sock(g_system); //LCOV_EXCL_LINE
+               return STC_ERROR_FAIL; //LCOV_EXCL_LINE
        }
 
        __vconf_get_int(VCONFKEY_STC_BACKGROUND_STATE,
@@ -1712,21 +1741,21 @@ stc_error_e stc_monitor_application_add(const stc_app_key_s app_key,
 
        lookup = __application_lookup(g_system->apps, &app_key);
        if (lookup) {
-               STC_LOGD("app_key already present");
-               return STC_ERROR_NONE;
+               STC_LOGD("app_key already present"); //LCOV_EXCL_LINE
+               return STC_ERROR_NONE; //LCOV_EXCL_LINE
        }
 
        key = MALLOC0(stc_app_key_s, 1);
        if (!key) {
-               STC_LOGE("key allocation failed");
-               return STC_ERROR_OUT_OF_MEMORY;
+               STC_LOGE("key allocation failed"); //LCOV_EXCL_LINE
+               return STC_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
        }
 
        value = MALLOC0(stc_app_value_s, 1);
        if (!value) {
-               STC_LOGE("value allocation failed");
-               FREE(key);
-               return STC_ERROR_OUT_OF_MEMORY;
+               STC_LOGE("value allocation failed"); //LCOV_EXCL_LINE
+               FREE(key); //LCOV_EXCL_LINE
+               return STC_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
        }
 
        key->app_id = g_strdup(app_key.app_id);
@@ -1766,27 +1795,27 @@ stc_error_e stc_monitor_process_add(const stc_app_key_s app_key,
 
        app_lookup = __application_lookup(g_system->apps, &app_key);
        if (!app_lookup) {
-               STC_LOGD("app_key not found");
-               return STC_ERROR_FAIL;
+               STC_LOGD("app_key not found"); //LCOV_EXCL_LINE
+               return STC_ERROR_FAIL; //LCOV_EXCL_LINE
        }
 
        proc_lookup = __process_lookup(app_lookup->processes, &proc_key);
        if (proc_lookup) {
-               STC_LOGD("proc_key already present");
-               return STC_ERROR_NONE;
+               STC_LOGD("proc_key already present"); //LCOV_EXCL_LINE
+               return STC_ERROR_NONE; //LCOV_EXCL_LINE
        }
 
        key = MALLOC0(stc_process_key_s, 1);
        if (!key) {
-               STC_LOGE("key allocation failed");
-               return STC_ERROR_OUT_OF_MEMORY;
+               STC_LOGE("key allocation failed"); //LCOV_EXCL_LINE
+               return STC_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
        }
 
        value = MALLOC0(stc_process_value_s, 1);
        if (!value) {
-               STC_LOGE("value allocation failed");
-               FREE(key);
-               return STC_ERROR_OUT_OF_MEMORY;
+               STC_LOGE("value allocation failed"); //LCOV_EXCL_LINE
+               FREE(key); //LCOV_EXCL_LINE
+               return STC_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
        }
 
        key->pid = proc_key.pid;
@@ -1799,7 +1828,7 @@ stc_error_e stc_monitor_process_add(const stc_app_key_s app_key,
        place_pids_to_net_cgroup(proc_key.pid, app_key.app_id);
 
        if (STC_DEBUG_LOG)
-               __apps_tree_printall();
+               __apps_tree_printall(); //LCOV_EXCL_LINE
 
        return ret;
 }
@@ -1826,11 +1855,12 @@ stc_error_e stc_monitor_process_remove(pid_t pid)
                __application_remove_if_empty(context.app_key);
 
        if (STC_DEBUG_LOG)
-               __apps_tree_printall();
+               __apps_tree_printall(); //LCOV_EXCL_LINE
 
        return ret;
 }
 
+//LCOV_EXCL_START
 stc_error_e stc_monitor_process_update_ground(const stc_app_key_s app_key,
                                              const stc_process_key_s proc_key,
                                              stc_app_state_e ground)
@@ -1863,6 +1893,7 @@ stc_error_e stc_monitor_process_update_ground(const stc_app_key_s app_key,
 
        return ret;
 }
+//LCOV_EXCL_STOP
 
 void stc_monitor_update_rstn_by_default_connection(void *data)
 {
@@ -1870,6 +1901,7 @@ void stc_monitor_update_rstn_by_default_connection(void *data)
        default_connection_s *new_connection = (default_connection_s *)data;
 
        if (old_connection.path != NULL) {
+               //LCOV_EXCL_START
                if (g_system->apps)
                        g_tree_foreach(g_system->apps,
                                       __remove_application_monitor,
@@ -1881,6 +1913,7 @@ void stc_monitor_update_rstn_by_default_connection(void *data)
                                       (gpointer)&old_connection);
 
                iptables_flush_chains();
+               //LCOV_EXCL_STOP
        }
 
        FREE(old_connection.path);
@@ -1930,9 +1963,9 @@ stc_error_e stc_monitor_rstns_tree_add(const table_restrictions_info *info)
                value.classid = STC_UNKNOWN_CLASSID;
 
        if (value.classid == STC_BACKGROUND_APP_CLASSID) {
-               __set_background_state(TRUE);
-               __vconf_set_int(VCONFKEY_STC_BACKGROUND_STATE, g_system->background_state);
-               __process_update_background();
+               __set_background_state(TRUE); //LCOV_EXCL_LINE
+               __vconf_set_int(VCONFKEY_STC_BACKGROUND_STATE, g_system->background_state); //LCOV_EXCL_LINE
+               __process_update_background(); //LCOV_EXCL_LINE
        }
 
        value.data_limit = info->data_limit;
@@ -1959,9 +1992,9 @@ stc_error_e stc_monitor_rstns_tree_remove(const table_restrictions_info *info)
        };
 
        if (!strcmp(key.app_id, STC_BACKGROUND_APP_ID)) {
-               __set_background_state(FALSE);
-               __vconf_set_int(VCONFKEY_STC_BACKGROUND_STATE, g_system->background_state);
-               __process_update_background();
+               __set_background_state(FALSE); //LCOV_EXCL_LINE
+               __vconf_set_int(VCONFKEY_STC_BACKGROUND_STATE, g_system->background_state); //LCOV_EXCL_LINE
+               __process_update_background(); //LCOV_EXCL_LINE
        }
 
        ret = __rstn_tree_remove(&key);