From: Dewal Agarwal Date: Mon, 17 Apr 2023 06:13:23 +0000 (+0530) Subject: [CAPI 0.4.23] Add LCOV statements in internal func. X-Git-Tag: accepted/tizen/unified/20230417.140307^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1fbed4df6d99d9c40434313175e002aef097cd87;p=platform%2Fcore%2Fapi%2Flibaccount-service.git [CAPI 0.4.23] Add LCOV statements in internal func. - Related to functions of DB operation (sqlite) - Some errors are not possible to attain using UTC Change-Id: I6929b5ee8e4fdeebb321bb0aebcd77b1aa3f05af --- diff --git a/packaging/libaccount-service.spec b/packaging/libaccount-service.spec index 9d502be..3d663e2 100644 --- a/packaging/libaccount-service.spec +++ b/packaging/libaccount-service.spec @@ -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 diff --git a/src/account_offline.c b/src/account_offline.c index 458fa76..dc94889 100644 --- a/src/account_offline.c +++ b/src/account_offline.c @@ -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();