coverage: Exclude unnecessary lines for line coverage 64/297964/1 accepted/tizen/8.0/unified/20231005.092854 accepted/tizen/unified/20230830.170557 tizen_8.0_m2_release
authorYoungjae Cho <y0.cho@samsung.com>
Tue, 29 Aug 2023 03:03:31 +0000 (12:03 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Tue, 29 Aug 2023 07:55:53 +0000 (16:55 +0900)
1. Exclude lines related to custom feature. It is because the
   whole system_info_external.c code already has been excluded from the
   line coverage.
2. Exclude system_info_get_platform_type()/system_info_get_custom_type()
   and its subroutine as they are not exported as public API.
3. Exclude the whole init_db related source code.

Change-Id: I6321bed4191cd5914a12c3e082a1981613d9a95b
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/init_db/system_info_db_init.c
src/system_info.c
src/system_info_file.c

index be203f0c7aba284574a0c40cd895613f013ebe81..94b9715c5803af6551fd787e98b42c9ce8333282 100644 (file)
@@ -50,6 +50,7 @@
 #define MODEL_CONFIG_TAG "model-config"
 #define KEY_PREFIX "http://"
 
+//LCOV_EXCL_START
 extern const struct runtime runtime[LANG_MAX];
 
 static int db_set_value(const char *db_path, char *tag, char *name, char *type, char *value, int val_len)
@@ -585,3 +586,4 @@ int main(int argc, char *argv[])
 
        return system_info_update_db(argc, argv);
 }
+//LCOV_EXCL_STOP
index 7b028c8a38756231f5935760560fa1c760d521fe..ec198258c5130b8361398309d55da6faac0e548b 100644 (file)
@@ -129,8 +129,8 @@ static int db_search_value(const char *db_path, char *key_internal, char *value,
 
        /* flock for writable database */
        if (strncmp(db_path, SYSTEM_INFO_DB_RW_PATH, strlen(db_path) + 1) == 0) {
-               if (flock(fileno(fp), LOCK_SH) < 0)
-                       _E("Failed to acquire shared flock, %m");
+               if (flock(fileno(fp), LOCK_SH) < 0) // LCOV_EXCL_LINE
+                       _E("Failed to acquire shared flock, %m"); // LCOV_EXCL_LINE
        }
 
        key_internal_len = strlen(key_internal);
@@ -205,10 +205,12 @@ static int db_get_value(enum tag_type tag, const char *key,
        buffer1 = (char *) calloc(len, sizeof(char));
        buffer2 = (char *) calloc(len, sizeof(char));
        if (!buffer1 || !buffer2) {
+               // LCOV_EXCL_START
                free(buffer1);
                free(buffer2);
                pthread_mutex_unlock(&fmutex);
                return SYSTEM_INFO_ERROR_OUT_OF_MEMORY;
+               // LCOV_EXCL_STOP
        }
 
        retval1 = db_search_value(SYSTEM_INFO_DB_RO_PATH, key_internal, buffer1, len);
@@ -220,8 +222,8 @@ static int db_get_value(enum tag_type tag, const char *key,
                ret = SYSTEM_INFO_ERROR_NONE;
                strncpy(value, buffer1, len);
        } else if (retval2 == SYSTEM_INFO_ERROR_NONE) {
-               ret = SYSTEM_INFO_ERROR_NONE;
-               strncpy(value, buffer2, len);
+               ret = SYSTEM_INFO_ERROR_NONE; // LCOV_EXCL_LINE Currently have no cases that only HAL fature exists
+               strncpy(value, buffer2, len); // LCOV_EXCL_LINE Currently have no cases that only HAL fature exists
        } else {
                ret = SYSTEM_INFO_ERROR_IO_ERROR;
        }
@@ -247,6 +249,7 @@ struct sysinfo_type {
        { SYSTEM_INFO_STRING, STR_TYPE  },
 };
 
+// LCOV_EXCL_START Not a public exported API
 static int system_info_get_type(enum tag_type tag, const char *key,
                system_info_type_e *type)
 {
@@ -266,6 +269,7 @@ static int system_info_get_type(enum tag_type tag, const char *key,
        else
                return SYSTEM_INFO_ERROR_INVALID_PARAMETER;
 }
+// LCOV_EXCL_STOP
 
 static int system_info_get_bool(enum tag_type tag, const char *key, bool *value)
 {
@@ -291,18 +295,19 @@ static int system_info_get_bool(enum tag_type tag, const char *key, bool *value)
                                        return SYSTEM_INFO_ERROR_NONE;
                                }
                        }
-                       _D("Unknown RUNTIME_TYPE, return default value");
+                       _D("Unknown RUNTIME_TYPE, return default value"); // LCOV_EXCL_LINE
                }
 
                *value = val[runtime[DEFAULT].lang] == 'T' ? true : false;
                return SYSTEM_INFO_ERROR_NONE;
        }
 
+       //LCOV_EXCL_START
        if (tag == TAG_TYPE_CUSTOM) {
                ret = external_get_value(TAG_TYPE_CUSTOM_STR, key, BOOL_TYPE, &valp);
                if (ret == SYSTEM_INFO_ERROR_NONE) {
-                       snprintf(val, sizeof(val), "%s", valp); //LCOV_EXCL_LINE
-                       free(valp); //LCOV_EXCL_LINE
+                       snprintf(val, sizeof(val), "%s", valp);
+                       free(valp);
 
                        len = strlen(val) + 0;
                        if (!strncmp(val, "true", len) || !strncmp(val, "TRUE", len))
@@ -313,6 +318,7 @@ static int system_info_get_bool(enum tag_type tag, const char *key, bool *value)
                        return SYSTEM_INFO_ERROR_NONE;
                }
        }
+       //LCOV_EXCL_STOP
 
        _E("Invalid key (%s), type:bool", key);
 
@@ -332,14 +338,16 @@ static int system_info_get_int(enum tag_type tag, const char *key, int *value)
        if (ret == SYSTEM_INFO_ERROR_NONE)
                goto out;
 
+       //LCOV_EXCL_START
        if (tag == TAG_TYPE_CUSTOM) {
                ret = external_get_value(TAG_TYPE_CUSTOM_STR, key, INT_TYPE, &valp);
                if (ret == SYSTEM_INFO_ERROR_NONE) {
-                       snprintf(val, sizeof(val), "%s", valp); //LCOV_EXCL_LINE
-                       free(valp); //LCOV_EXCL_LINE
-                       goto out; //LCOV_EXCL_LINE
+                       snprintf(val, sizeof(val), "%s", valp);
+                       free(valp);
+                       goto out;
                }
        }
+       //LCOV_EXCL_STOP
 
        _E("Invalid key (%s), type:integer", key);
 
@@ -364,14 +372,16 @@ static int system_info_get_double(enum tag_type tag, const char *key, double *va
        if (ret == SYSTEM_INFO_ERROR_NONE)
                goto out;
 
+       //LCOV_EXCL_START
        if (tag == TAG_TYPE_CUSTOM) {
                ret = external_get_value(TAG_TYPE_CUSTOM_STR, key, DBL_TYPE, &valp);
                if (ret == SYSTEM_INFO_ERROR_NONE) {
-                       snprintf(val, sizeof(val), "%s", valp); //LCOV_EXCL_LINE
-                       free(valp); //LCOV_EXCL_LINE
-                       goto out; //LCOV_EXCL_LINE
+                       snprintf(val, sizeof(val), "%s", valp);
+                       free(valp);
+                       goto out;
                }
        }
+       //LCOV_EXCL_STOP
 
        _E("Invalid key (%s), type:double", key);
 
@@ -403,14 +413,16 @@ static int system_info_get_string(enum tag_type tag, const char *key, char **val
                        goto out;
        }
 
+       //LCOV_EXCL_START
        if (tag == TAG_TYPE_CUSTOM) {
                ret = external_get_value(TAG_TYPE_CUSTOM_STR, key, STR_TYPE, &valp);
                if (ret == SYSTEM_INFO_ERROR_NONE) {
-                       snprintf(val, sizeof(val), "%s", valp); //LCOV_EXCL_LINE
-                       free(valp); //LCOV_EXCL_LINE
-                       goto out; //LCOV_EXCL_LINE
+                       snprintf(val, sizeof(val), "%s", valp);
+                       free(valp);
+                       goto out;
                }
        }
+       //LCOV_EXCL_STOP
 
        _E("Invalid key (%s) type:string", key);
 
@@ -448,6 +460,7 @@ API int system_info_get_platform_string(const char *key, char **value)
        return system_info_get_string(TAG_TYPE_PLATFORM, key, value);
 }
 
+//LCOV_EXCL_START
 API int system_info_get_custom_bool(const char *key, bool *value)
 {
        return system_info_get_bool(TAG_TYPE_CUSTOM, key, value);
@@ -467,12 +480,16 @@ API int system_info_get_custom_string(const char *key, char **value)
 {
        return system_info_get_string(TAG_TYPE_CUSTOM, key, value);
 }
+//LCOV_EXCL_STOP
 
+//LCOV_EXCL_START Not a pulbic exported API
 API int system_info_get_platform_type(const char *key, system_info_type_e *type)
 {
        return system_info_get_type(TAG_TYPE_PLATFORM, key, type);
 }
+//LCOV_EXCL_STOP
 
+//LCOV_EXCL_START Not a public exported API
 API int system_info_get_custom_type(const char *key, system_info_type_e *type)
 {
        int ret;
@@ -489,7 +506,6 @@ API int system_info_get_custom_type(const char *key, system_info_type_e *type)
                return SYSTEM_INFO_ERROR_INVALID_PARAMETER;
        }
 
-       //LCOV_EXCL_START
        len = strlen(val) + 1;
        if (!strncmp(BOOL_TYPE, val, len))
                *type = SYSTEM_INFO_BOOL;
@@ -507,5 +523,5 @@ API int system_info_get_custom_type(const char *key, system_info_type_e *type)
 
        free(val);
        return SYSTEM_INFO_ERROR_NONE;
-       //LCOV_EXCL_STOP
 }
+//LCOV_EXCL_STOP
index 8a83233ee114999b4f3b528f611b89e29da9a4a5..d6ee65d3dd75412bf735a20acde6f2b89cbe887e 100644 (file)
@@ -90,6 +90,7 @@ int system_info_get_file(const char *key, char *value, size_t len)
        return SYSTEM_INFO_ERROR_INVALID_PARAMETER;
 }
 
+// LCOV_EXCL_START Not a public exported API
 int system_info_get_type_file(const char *key, system_info_type_e *type)
 {
        char p_key[KEY_MAX];
@@ -113,3 +114,4 @@ int system_info_get_type_file(const char *key, system_info_type_e *type)
 
        return SYSTEM_INFO_ERROR_INVALID_PARAMETER;
 }
+//LCOV_EXCL_STOP