[CAPI 0.4.23] Add LCOV statements in internal func. 53/291453/1 accepted/tizen/8.0/unified/20231005.092713 accepted/tizen/unified/20230417.140307 tizen_8.0_m2_release
authorDewal Agarwal <d1.agarwal@samsung.com>
Mon, 17 Apr 2023 06:13:23 +0000 (11:43 +0530)
committerDewal Agarwal <d1.agarwal@samsung.com>
Mon, 17 Apr 2023 06:13:23 +0000 (11:43 +0530)
- Related to functions of DB operation (sqlite)
- Some errors are not possible to attain using UTC

Change-Id: I6929b5ee8e4fdeebb321bb0aebcd77b1aa3f05af

packaging/libaccount-service.spec
src/account_offline.c

index 9d502be17e7e3bd78466dd572f47c7d38e32115a..3d663e2d0f4b0a274b8b2e94b085d8bb9df043cb 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libaccount-service
 Summary:    Account DB library
-Version:    0.4.22
+Version:    0.4.23
 Release:    1
 Group:      Social & Content/API
 License:    Apache-2.0
index 458fa76abc7436dca72bec6c2c79dc8df6297d13..dc94889c60160f1e489d2b85563131b1134febf9 100644 (file)
@@ -60,11 +60,15 @@ static int _account_user_db_close(sqlite3 *hAccountDB)
        if (hAccountDB) {
                rc = db_util_close(hAccountDB);
                if (rc == SQLITE_PERM) {
+               /* LCOV_EXCL_START */
                        ACCOUNT_ERROR("Access failed(SQLITE_PERM)");
                        return ACCOUNT_ERROR_PERMISSION_DENIED;
+               /* LCOV_EXCL_STOP */
                } else if (rc == SQLITE_BUSY) {
+               /* LCOV_EXCL_START */
                        ACCOUNT_ERROR("database busy");
                        return ACCOUNT_ERROR_DATABASE_BUSY;
+               /* LCOV_EXCL_STOP */
                }
                ACCOUNT_RETURN_VAL((rc == SQLITE_OK), {}, ACCOUNT_ERROR_DB_FAILED, ("The database isn't connected. rc : %d", rc));
                hAccountDB = NULL;
@@ -74,7 +78,6 @@ static int _account_user_db_close(sqlite3 *hAccountDB)
        return ret;
 }
 
-
 static int _account_user_db_open(sqlite3 **p_hAccountDB, int mode, uid_t uid)
 {
        int  rc = 0;
@@ -91,6 +94,7 @@ static int _account_user_db_open(sqlite3 **p_hAccountDB, int mode, uid_t uid)
 
        ACCOUNT_GET_USER_DB_DIR(account_db_dir, sizeof(account_db_dir), uid);
        if ((-1 == access(account_db_dir, F_OK)) && uid != OWNER_ROOT) {
+               /* LCOV_EXCL_START */
                int ret;
 
                ret = mkdir(account_db_dir, 0755);
@@ -110,6 +114,7 @@ static int _account_user_db_open(sqlite3 **p_hAccountDB, int mode, uid_t uid)
                ACCOUNT_DEBUG("chown result = [%d]", ret);
                ret = chmod(account_db_jn_path, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
                ACCOUNT_DEBUG("chmod result = [%d]", ret);
+               /* LCOV_EXCL_STOP */
        } else {
                if (mode == ACCOUNT_DB_OPEN_READWRITE)
                        rc = db_util_open(account_db_path, p_hAccountDB, DB_UTIL_REGISTER_HOOK_METHOD);
@@ -118,13 +123,17 @@ static int _account_user_db_open(sqlite3 **p_hAccountDB, int mode, uid_t uid)
        }
 
        if (_account_db_err_code(*p_hAccountDB) == SQLITE_PERM) {
+               /* LCOV_EXCL_START */
                ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(*p_hAccountDB));
                return ACCOUNT_ERROR_PERMISSION_DENIED;
+               /* LCOV_EXCL_STOP */
        }
 
        if (rc == SQLITE_BUSY) {
+               /* LCOV_EXCL_START */
                ACCOUNT_ERROR("busy handler fail.");
                return ACCOUNT_ERROR_DATABASE_BUSY;
+               /* LCOV_EXCL_STOP */
        }
 
        ACCOUNT_RETURN_VAL((rc != SQLITE_PERM), {}, ACCOUNT_ERROR_PERMISSION_DENIED, ("Account permission denied rc : %d", rc));
@@ -172,8 +181,10 @@ static int _account_global_db_open(int mode)
                uid = getuid();
 
        if (uid != OWNER_ROOT && uid != GLOBAL_USER) {
+               /* LCOV_EXCL_START */
                ACCOUNT_ERROR("global db open fail. user not both root or global user");
                return ACCOUNT_ERROR_PERMISSION_DENIED;
+               /* LCOV_EXCL_STOP */
        }
 
        ACCOUNT_GET_GLOBAL_DB_PATH(account_db_path, sizeof(account_db_path));
@@ -210,13 +221,17 @@ static int _account_global_db_open(int mode)
                }
 
                if (_account_db_err_code(g_hAccountGlobalDB) == SQLITE_PERM) {
+                       /* LCOV_EXCL_START */
                        ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountGlobalDB));
                        return ACCOUNT_ERROR_PERMISSION_DENIED;
+                       /* LCOV_EXCL_STOP */
                }
 
                if (rc == SQLITE_BUSY) {
+                       /* LCOV_EXCL_START */
                        ACCOUNT_ERROR("busy handler fail.");
                        return ACCOUNT_ERROR_DATABASE_BUSY;
+                       /* LCOV_EXCL_STOP */
                }
 
                ACCOUNT_RETURN_VAL((rc != SQLITE_PERM), {}, ACCOUNT_ERROR_PERMISSION_DENIED, ("Account permission denied rc : %d", rc));
@@ -256,11 +271,15 @@ static int _account_global_db_close(void)
                if (g_refCntDB == 0) {
                        rc = db_util_close(g_hAccountGlobalDB);
                        if (rc == SQLITE_PERM) {
+                               /* LCOV_EXCL_START */
                                ACCOUNT_ERROR("Access failed(SQLITE_PERM)");
                                return ACCOUNT_ERROR_PERMISSION_DENIED;
+                               /* LCOV_EXCL_STOP */
                        } else if (rc == SQLITE_BUSY) {
+                               /* LCOV_EXCL_START */
                                ACCOUNT_ERROR("database busy");
                                return ACCOUNT_ERROR_DATABASE_BUSY;
+                               /* LCOV_EXCL_STOP */
                        }
                        ACCOUNT_RETURN_VAL((rc == SQLITE_OK), {}, ACCOUNT_ERROR_DB_FAILED, ("The database isn't connected. rc : %d", rc));
                        g_hAccountGlobalDB = NULL;
@@ -415,9 +434,11 @@ ACCOUNT_INTERNAL_API int account_delete_from_db_by_package_name_offline(const ch
        }
 
        if (uid != OWNER_ROOT && uid != GLOBAL_USER) {
+               /* LCOV_EXCL_START */
                _ERR("current process user is not root, uid=%d", uid);
                return_code = ACCOUNT_ERROR_PERMISSION_DENIED;
                goto RETURN;
+               /* LCOV_EXCL_STOP */
        }
 
        setpwent();