Add initial source codes for gtest
[platform/core/connectivity/stc-manager.git] / src / helper / helper-net-cls.c
index 6be717a..c1460dc 100755 (executable)
@@ -36,7 +36,7 @@ static uint32_t __produce_classid(check_classid_used_cb check_classid_cb)
        uint32_t classid = STC_RESERVED_CLASSID_MAX;
        int ret = fread_uint(CUR_CLASSID_PATH, &classid);
        if (ret < 0)
-               STC_LOGI("Can not read current classid");
+               STC_LOGI("Can not read current classid"); //LCOV_EXCL_LINE
 
        classid += 1;
 
@@ -51,7 +51,7 @@ static uint32_t __produce_classid(check_classid_used_cb check_classid_cb)
 
        ret = fwrite_uint(CUR_CLASSID_PATH, ++classid);
        if (ret < 0)
-               STC_LOGE("Can not write classid");
+               STC_LOGE("Can not write classid"); //LCOV_EXCL_LINE
 
        return classid;
 }
@@ -81,7 +81,7 @@ static uint32_t __get_classid_from_cgroup(const char *cgroup,
 
        int ret = cgroup_read_node_uint32(buf, CLASSID_FILE_NAME, &classid);
        if (ret < 0)
-               STC_LOGE("Can't read classid from cgroup %s", buf);
+               STC_LOGE("Can't read classid from cgroup %s", buf); //LCOV_EXCL_LINE
        return classid;
 }
 
@@ -94,8 +94,8 @@ stc_error_e init_current_classid(void)
                uint32_t classid = STC_RESERVED_CLASSID_MAX;
                ret = fwrite_uint(CUR_CLASSID_PATH, classid);
                if (ret < 0) {
-                       STC_LOGE("Can not init current classid");
-                       return STC_ERROR_FAIL;
+                       STC_LOGE("Can not init current classid"); //LCOV_EXCL_LINE
+                       return STC_ERROR_FAIL; //LCOV_EXCL_LINE
                }
        }
 
@@ -110,8 +110,8 @@ uint32_t get_classid_by_app_id(const char *app_id, int create)
        const char *path_to_net_cgroup_dir = NULL;
 
        if (app_id == NULL) {
-               STC_LOGE("app_id must be not empty");
-               return STC_UNKNOWN_CLASSID;
+               STC_LOGE("app_id must be not empty"); //LCOV_EXCL_LINE
+               return STC_UNKNOWN_CLASSID; //LCOV_EXCL_LINE
        }
 
        if (!strcmp(app_id, STC_BACKGROUND_APP_ID))
@@ -139,7 +139,7 @@ uint32_t get_classid_by_app_id(const char *app_id, int create)
 
        /* just read */
        if (!create)
-               classid = __get_classid_from_cgroup(path_to_net_cgroup_dir,
+               classid = __get_classid_from_cgroup(path_to_net_cgroup_dir, //LCOV_EXCL_LINE
                                                    app_id);
 
        if (classid != STC_UNKNOWN_CLASSID)
@@ -157,14 +157,14 @@ uint32_t get_classid_by_app_id(const char *app_id, int create)
                ret = __place_classid_to_cgroup(path_to_net_cgroup_dir,
                                                (char *)app_id, &classid, NULL);
        if (ret)
-               goto handle_error;
+               goto handle_error; //LCOV_EXCL_LINE
 
        return classid;
 
 handle_error:
 
-       STC_LOGE("error_code: [%d]", ret);
-       return STC_UNKNOWN_CLASSID;
+       STC_LOGE("error_code: [%d]", ret); //LCOV_EXCL_LINE
+       return STC_UNKNOWN_CLASSID; //LCOV_EXCL_LINE
 }
 
 stc_error_e place_pids_to_net_cgroup(const int pid, const char *app_id)
@@ -175,8 +175,8 @@ stc_error_e place_pids_to_net_cgroup(const int pid, const char *app_id)
        snprintf(child_buf, sizeof(child_buf), PROC_TASK_CHILDREN, pid, pid);
 
        if (app_id == NULL) {
-               STC_LOGE("package name must be not empty");
-               return STC_ERROR_INVALID_PARAMETER;
+               STC_LOGE("package name must be not empty"); //LCOV_EXCL_LINE
+               return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
        }
 
        if (!strcmp(app_id, STC_BACKGROUND_APP_ID))
@@ -184,13 +184,13 @@ stc_error_e place_pids_to_net_cgroup(const int pid, const char *app_id)
        else if (strstr(app_id, STC_BACKGROUND_APP_SUFFIX))
                path_to_net_cgroup_dir = BACKGROUND_CGROUP_NETWORK;
        else
-               path_to_net_cgroup_dir = FOREGROUND_CGROUP_NETWORK;
+               path_to_net_cgroup_dir = FOREGROUND_CGROUP_NETWORK; //LCOV_EXCL_LINE
 
        if (access(child_buf, F_OK)) {
                if (STC_DEBUG_LOG)
-                       STC_LOGD("%s of %s is not existed", child_buf, app_id);
+                       STC_LOGD("%s of %s is not existed", child_buf, app_id); //LCOV_EXCL_LINE
                return cgroup_write_pid(path_to_net_cgroup_dir, app_id, pid);
        }
 
-       return cgroup_write_pidtree(path_to_net_cgroup_dir, app_id, pid);
+       return cgroup_write_pidtree(path_to_net_cgroup_dir, app_id, pid); //LCOV_EXCL_LINE
 }