feedback: Add lcov exception code 38/298038/1 accepted/tizen/unified/20230831.081043
authorYunhee Seo <yuni.seo@samsung.com>
Wed, 30 Aug 2023 10:17:17 +0000 (19:17 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Wed, 30 Aug 2023 10:17:17 +0000 (19:17 +0900)
Add line coverage exception to below cases.
1. Internal API and functions used only in internal functions.
2. Profile specific functions that are not common profile.(ex - mobile/wearable)
3. Error handling code section.

Change-Id: If2efe1239e0738adaad09db2a2b2e8c479549709
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
src/check.c
src/devices.c
src/feedback.c
src/sound.c
src/util/feedback-privilege.c

index 1b5c67b..e0b5f30 100644 (file)
@@ -742,9 +742,9 @@ static int profile_get_num_of_standard(void)
 
        prof = get_profile();
 
+//LCOV_EXCL_START
        if (prof == PROFILE_MOBILE)
                size = ARR_SIZE(mobile_str_standard);
-//LCOV_EXCL_START
        else if (prof == PROFILE_WEARABLE)
                size = ARR_SIZE(wearable_str_standard);
        else
@@ -760,6 +760,7 @@ static const char *profile_str_pattern(int pattern)
 
        prof = get_profile();
 
+//LCOV_EXCL_START
        if (prof == PROFILE_MOBILE) {
                for (i = 0; i < profile_get_num_of_pattern(); i++) {
                        if (pattern == mobile_str_pattern[i].id)
@@ -769,7 +770,6 @@ static const char *profile_str_pattern(int pattern)
                        if (pattern == mobile_str_standard[i].id)
                                return mobile_str_standard[i].string;
                }
-//LCOV_EXCL_START
        } else if (prof == PROFILE_WEARABLE) {
                for (i = 0; i < profile_get_num_of_pattern(); i++) {
                        if (pattern == wearable_str_pattern[i].id)
@@ -780,12 +780,12 @@ static const char *profile_str_pattern(int pattern)
                                return wearable_str_standard[i].string;
                }
        } else {
+//LCOV_EXCL_STOP
                for (i = 0; i < profile_get_num_of_pattern(); i++) {
                        if (pattern == common_str_pattern[i].id)
                                return common_str_pattern[i].string;
                }
        }
-//LCOV_EXCL_STOP
        return "";
 
 }
@@ -799,12 +799,12 @@ static int profile_get_pattern_enum(char *pattern)
        prof = get_profile();
 
        len = strlen(pattern);
+//LCOV_EXCL_START
        if (prof == PROFILE_MOBILE) {
                for (i = 0; i < profile_get_num_of_pattern(); i++) {
                        if (!strncmp(pattern, mobile_str_pattern[i].string, len))
                                return mobile_str_pattern[i].id;
                }
-//LCOV_EXCL_START
                for (i = 0; i < profile_get_num_of_standard(); i++) {
                        if (!strncmp(pattern, mobile_str_standard[i].string, len))
                                return mobile_str_standard[i].id;
@@ -938,6 +938,7 @@ static void profile_init(void)
 
        if (prof == PROFILE_COMMON)
                return; //LCOV_EXCL_LINE
+       //LCOV_EXCL_START
        else if (prof == PROFILE_MOBILE) {
                if (vconf_get_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &lock_sndstatus) < 0)
                        _W("VCONFKEY_SETAPPL_SOUND_LOCK_BOOL ==> FAIL!!"); //LCOV_EXCL_LINE
@@ -1068,6 +1069,7 @@ static void profile_init(void)
        ret_val = vconf_notify_key_changed(VCONFKEY_SETAPPL_DISCONNECT_ALERT_TYPE_INT, feedback_disconnect_alert_mode_cb, NULL);
        if (ret_val != 0)
                _W("Add watch for VCONFKEY_SETAPPL_DISCONNECT_ALERT_TYPE_INT failed"); //LCOV_EXCL_LINE
+       //LCOV_EXCL_STOP
 }
 
 static void profile_exit(void)
@@ -1079,6 +1081,7 @@ static void profile_exit(void)
 
        if (prof == PROFILE_COMMON)
                return;
+       //LCOV_EXCL_START
        else if (prof == PROFILE_MOBILE) {
                ret_val = vconf_ignore_key_changed(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, feedback_lock_sndstatus_cb);
                if (ret_val != 0)
@@ -1131,6 +1134,7 @@ static void profile_exit(void)
        ret_val = vconf_ignore_key_changed(VCONFKEY_SETAPPL_DISCONNECT_ALERT_TYPE_INT, feedback_disconnect_alert_mode_cb);
        if (ret_val != 0)
                _W("Remove watch for VCONFKEY_SETAPPL_DISCONNECT_ALERT_TYPE_INT failed"); //LCOV_EXCL_LINE
+       //LCOV_EXCL_STOP
 }
 
 //LCOV_EXCL_START
@@ -1172,6 +1176,7 @@ static int wearable_get_switched_pattern(int pattern)
 }
 //LCOV_EXCL_STOP
 
+//LCOV_EXCL_START
 static int mobile_get_switched_pattern(int pattern)
 {
        int changed_pattern = pattern;
@@ -1209,7 +1214,7 @@ static int mobile_get_switched_pattern(int pattern)
 
        return changed_pattern;
 }
-
+//LCOV_EXCL_STOP
 
 static bool profile_get_switched_pattern(int pattern, int *switched)
 {
@@ -1222,7 +1227,6 @@ static bool profile_get_switched_pattern(int pattern, int *switched)
        //LCOV_EXCL_START
        if (prof == PROFILE_WEARABLE)
                changed_pattern = wearable_get_switched_pattern(changed_pattern);
-       //LCOV_EXCL_STOP
        else
                changed_pattern = mobile_get_switched_pattern(changed_pattern);
 
@@ -1230,9 +1234,11 @@ static bool profile_get_switched_pattern(int pattern, int *switched)
                *switched = changed_pattern;
                return true;
        }
+       //LCOV_EXCL_STOP
        return false;
 }
 
+//LCOV_EXCL_START
 static bool mobile_is_notification_type(int pattern)
 {
        switch (pattern) {
@@ -1253,6 +1259,7 @@ static bool mobile_is_notification_type(int pattern)
        }
        return false;
 }
+//LCOV_EXCL_STOP
 
 //LCOV_EXCL_START
 static bool wearable_is_notification_type(int pattern)
@@ -1298,9 +1305,9 @@ static bool profile_is_notification_type(int pattern)
 
        prof = get_profile();
 
+//LCOV_EXCL_START
        if (prof == PROFILE_MOBILE)
                return mobile_is_notification_type(pattern);
-//LCOV_EXCL_START
        else if (prof == PROFILE_WEARABLE)
                return wearable_is_notification_type(pattern);
        else
@@ -1308,6 +1315,7 @@ static bool profile_is_notification_type(int pattern)
 //LCOV_EXCL_STOP
 }
 
+//LCOV_EXCL_START
 static int mobile_get_priority(int pattern)
 {
        switch (pattern) {
@@ -1328,6 +1336,7 @@ static int mobile_get_priority(int pattern)
 
        return PRIORITY_MIDDLE;
 }
+//LCOV_EXCL_STOP
 
 //LCOV_EXCL_START
 static int wearable_get_priority(int pattern)
@@ -1366,9 +1375,9 @@ static int profile_get_priority(int pattern)
 
        prof = get_profile();
 
+//LCOV_EXCL_START
        if (prof == PROFILE_MOBILE)
                return mobile_get_priority(pattern);
-//LCOV_EXCL_START
        else if (prof == PROFILE_WEARABLE)
                return wearable_get_priority(pattern);
        else
@@ -1376,6 +1385,7 @@ static int profile_get_priority(int pattern)
 //LCOV_EXCL_STOP
 }
 
+//LCOV_EXCL_START
 static bool mobile_get_always_alert_case(int type, int pattern)
 {
        int ret_val;
@@ -1452,6 +1462,7 @@ static bool mobile_get_always_alert_case(int type, int pattern)
        }
        return false;
 }
+//LCOV_EXCL_STOP
 
 //LCOV_EXCL_START
 static bool wearable_is_system_type(int pattern)
@@ -1642,9 +1653,9 @@ static bool profile_get_always_alert_case(int type, int pattern)
 
        prof = get_profile();
 
+//LCOV_EXCL_START
        if (prof == PROFILE_MOBILE)
                return mobile_get_always_alert_case(type, pattern);
-//LCOV_EXCL_START
        else if (prof == PROFILE_WEARABLE)
                return wearable_get_always_alert_case(type, pattern);
        else
@@ -1652,6 +1663,7 @@ static bool profile_get_always_alert_case(int type, int pattern)
 //LCOV_EXCL_STOP
 }
 
+//LCOV_EXCL_START
 static bool mobile_get_always_off_case(int type, int pattern)
 {
        int ret_val;
@@ -1691,6 +1703,7 @@ static bool mobile_get_always_off_case(int type, int pattern)
        }
        return false;
 }
+//LCOV_EXCL_STOP
 
 //LCOV_EXCL_START
 static bool wearable_get_always_off_case(int type, int pattern)
@@ -1860,6 +1873,7 @@ static int profile_get_strong_buzz(int pattern)
        return pattern;
 }
 
+//LCOV_EXCL_START
 static int mobile_get_strength_type(int type, int pattern)
 {
        if (CHECK_SOUND(type)) {
@@ -1883,6 +1897,7 @@ static int mobile_get_strength_type(int type, int pattern)
 
        return -EINVAL;
 }
+//LCOV_EXCL_STOP
 
 //LCOV_EXCL_START
 static int wearable_get_strength_type(int type, int pattern)
index b6f9e75..4c5efd3 100644 (file)
@@ -97,6 +97,7 @@ int devices_play(int pattern, bool always)
        return prev;
 }
 
+//LCOV_EXCL_START
 int devices_play_soundpath(int pattern, const char *soundpath, bool always)
 {
        GList *elem;
@@ -128,6 +129,7 @@ int devices_play_soundpath(int pattern, const char *soundpath, bool always)
 
        return prev;
 }
+//LCOV_EXCL_STOP
 
 int devices_stop(void)
 {
index 8a3eda6..701c6ef 100644 (file)
@@ -154,9 +154,11 @@ API int feedback_play(feedback_pattern_e pattern)
        /* check initialize */
        pthread_mutex_lock(&fmutex);
        if (!init_cnt) {
-               _E("Not initialized"); //LCOV_EXCL_LINE
+               //LCOV_EXCL_START
+               _E("Not initialized");
                pthread_mutex_unlock(&fmutex);
                return FEEDBACK_ERROR_NOT_INITIALIZED;
+               //LCOV_EXCL_STOP
        }
        pthread_mutex_unlock(&fmutex);
 
@@ -174,10 +176,12 @@ API int feedback_play(feedback_pattern_e pattern)
         * It means if to play anything is successful,
         * this function regards as success.
         */
+       //LCOV_EXCL_START
        if (err == -ENOTSUP)
                return FEEDBACK_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
        else if (err < 0)
                return FEEDBACK_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+       //LCOV_EXCL_STOP
 
        return FEEDBACK_ERROR_NONE;
 }
@@ -306,6 +310,7 @@ API int feedback_is_supported_pattern(feedback_type_e type, feedback_pattern_e p
 }
 
 /* Internal APIs */
+//LCOV_EXCL_START
 API int feedback_play_type_by_name(char *type, char *pattern)
 {
        feedback_type_e etype;
@@ -342,7 +347,9 @@ API int feedback_play_type_by_name(char *type, char *pattern)
 
        return feedback_play_type(etype, epattern);
 }
+//LCOV_EXCL_STOP
 
+//LCOV_EXCL_START
 API int feedback_play_internal(feedback_pattern_internal_e internal_pattern)
 {
        int err;
@@ -378,7 +385,9 @@ API int feedback_play_internal(feedback_pattern_internal_e internal_pattern)
 
        return FEEDBACK_ERROR_NONE;
 }
+//LCOV_EXCL_STOP
 
+//LCOV_EXCL_START
 API int feedback_play_type_internal(feedback_type_e type, feedback_pattern_internal_e internal_pattern)
 {
        const struct device_ops *dev;
@@ -423,7 +432,9 @@ API int feedback_play_type_internal(feedback_type_e type, feedback_pattern_inter
 
        return FEEDBACK_ERROR_NONE;
 }
+//LCOV_EXCL_STOP
 
+//LCOV_EXCL_START
 API int feedback_play_soundpath_internal(feedback_pattern_internal_e internal_pattern, const char *soundpath)
 {
        int err;
@@ -464,7 +475,9 @@ API int feedback_play_soundpath_internal(feedback_pattern_internal_e internal_pa
 
        return FEEDBACK_ERROR_NONE;
 }
+//LCOV_EXCL_STOP
 
+//LCOV_EXCL_START
 API int feedback_play_type_soundpath_internal(feedback_type_e type, feedback_pattern_internal_e internal_pattern, const char *soundpath)
 {
        const struct device_ops *dev;
@@ -525,7 +538,9 @@ API int feedback_play_type_soundpath_internal(feedback_type_e type, feedback_pat
 
        return FEEDBACK_ERROR_NONE;
 }
+//LCOV_EXCL_STOP
 
+//LCOV_EXCL_START
 API int feedback_get_count_of_theme_internal(feedback_type_e feedback_type, unsigned int *count_of_theme)
 {
        const struct device_ops *dev = NULL;
@@ -559,7 +574,9 @@ API int feedback_get_count_of_theme_internal(feedback_type_e feedback_type, unsi
 
        return FEEDBACK_ERROR_NONE;
 }
+//LCOV_EXCL_STOP
 
+//LCOV_EXCL_START
 API int feedback_get_theme_index_internal(feedback_type_e feedback_type, unsigned int *index_of_theme)
 {
        const struct device_ops *dev = NULL;
@@ -587,7 +604,9 @@ API int feedback_get_theme_index_internal(feedback_type_e feedback_type, unsigne
 
        return FEEDBACK_ERROR_NONE;
 }
+//LCOV_EXCL_STOP
 
+//LCOV_EXCL_START
 API int feedback_set_theme_index_internal(feedback_type_e feedback_type, unsigned int index_of_theme)
 {
        const struct device_ops *dev = NULL;
@@ -618,3 +637,4 @@ API int feedback_set_theme_index_internal(feedback_type_e feedback_type, unsigne
 
        return FEEDBACK_ERROR_NONE;
 }
+//LCOV_EXCL_STOP
index 22ef313..80148a6 100644 (file)
@@ -117,6 +117,7 @@ static void feedback_keytone_sndstatus_cb(keynode_t *key, void* data)
 }
 //LCOV_EXCL_STOP
 
+//LCOV_EXCL_START
 static void feedback_sound_theme_changed_cb(keynode_t *key, void* data)
 {
        int vconf_sound_theme_index = vconf_keynode_get_int(key);
@@ -128,6 +129,7 @@ static void feedback_sound_theme_changed_cb(keynode_t *key, void* data)
 
        current_theme_index = vconf_keynode_get_int(key) - 1;
 }
+//LCOV_EXCL_STOP
 
 static int feedback_parse_sound_multi_theme_section(const struct parse_result *result, void *data)
 {
@@ -140,6 +142,7 @@ static int feedback_parse_sound_multi_theme_section(const struct parse_result *r
        if (!MATCH("SoundMultiTheme", result->section))
                return 0;
 
+       //LCOV_EXCL_START
        SYS_G_LIST_FOREACH(result->props, temp_glist, extracted_section_prop) {
                if (MATCH("number_of_theme", extracted_section_prop->key)) {
                        sscanf(extracted_section_prop->value, "%d", &number_of_theme);
@@ -158,6 +161,7 @@ static int feedback_parse_sound_multi_theme_section(const struct parse_result *r
                        default theme number cannot be greater then the number of theme");
                return -EINVAL;
        }
+       //LCOV_EXCL_STOP
 
        return 0;
 }
@@ -179,6 +183,7 @@ static bool feedback_is_multi_theme_support(const char *path)
        return false;
 }
 
+//LCOV_EXCL_START
 static int feedback_parse_multi_theme_conf_path_section(const struct parse_result *result, void *data)
 {
        struct section_property *extracted_section_prop = NULL;
@@ -218,7 +223,9 @@ static int feedback_parse_multi_theme_conf_path_section(const struct parse_resul
 
        return 0;
 }
+//LCOV_EXCL_STOP
 
+//LCOV_EXCL_START
 static int feedback_multi_theme_load_config(const char *path)
 {
        int ret = 0;
@@ -230,6 +237,7 @@ static int feedback_multi_theme_load_config(const char *path)
 
        return ret;
 }
+//LCOV_EXCL_STOP
 
 static int sound_get_config(void)
 {
@@ -241,8 +249,10 @@ static int sound_get_config(void)
 
        sound_info = (struct feedback_config_info*)calloc(number_of_theme, sizeof(struct feedback_config_info));
        if (!sound_info) {
+               //LCOV_EXCL_START
                _E("Failed to allocate memory for sound_info.");
                return -ENOMEM;
+               //LCOV_EXCL_STOP
        }
 
        for (int i = 0; i < number_of_theme; i++)
@@ -266,11 +276,11 @@ static void sound_init(void)
        current_theme_index = 0;
 
        if (vconf_get_int(VCONFKEY_SETAPPL_ACCESSIBILITY_SOUND_FEEDBACK_THEME, &current_theme_index) < 0)
-               _W("Failed to get VCONFKEY_SETAPPL_ACCESSIBILITY_SOUND_FEEDBACK_THEME");
+               _W("Failed to get VCONFKEY_SETAPPL_ACCESSIBILITY_SOUND_FEEDBACK_THEME"); //LCOV_EXCL_LINE
 
        ret = sound_get_config();
        if (ret < 0)
-               _W("Failed to load configuration file(%s): %d", SOUND_CONF_FILE, ret);
+               _W("Failed to load configuration file(%s): %d", SOUND_CONF_FILE, ret); //LCOV_EXCL_LINE
 
        /* check sound status */
        if (vconf_get_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &touch_sndstatus) < 0)
@@ -296,7 +306,7 @@ static void sound_init(void)
                _W("Add watch for VCONFKEY_SETAPPL_BUTTON_SOUNDS_BOOL failed"); //LCOV_EXCL_LINE
        ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_SOUND_FEEDBACK_THEME, feedback_sound_theme_changed_cb, NULL);
        if (ret != 0)
-               _W("Add watch for VCONFKEY_SETAPPL_ACCESSIBILITY_SOUND_FEEDBACK_THEME failed");
+               _W("Add watch for VCONFKEY_SETAPPL_ACCESSIBILITY_SOUND_FEEDBACK_THEME failed"); //LCOV_EXCL_LINE
 }
 
 static void sound_put_config(void)
@@ -328,7 +338,7 @@ static void sound_exit(void)
                _W("Remove watch for VCONFKEY_SETAPPL_BUTTON_SOUNDS_BOOL failed"); //LCOV_EXCL_LINE
        ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_SOUND_FEEDBACK_THEME, feedback_sound_theme_changed_cb);
        if (ret != 0)
-               _W("Remove watch for VCONFKEY_SETAPPL_ACCESSIBILITY_SOUND_FEEDBACK_THEME failed");
+               _W("Remove watch for VCONFKEY_SETAPPL_ACCESSIBILITY_SOUND_FEEDBACK_THEME failed"); //LCOV_EXCL_LINE
 
        sound_put_config();
 }
@@ -379,8 +389,10 @@ check_pattern:
        /* get sound file path */
        path = get_data(pattern);
        if (!path || stat(path, &buf)) {
+               //LCOV_EXCL_START
                _E("Not supported sound pattern(pattern %d)", pattern); //LCOV_EXCL_LINE
                return -ENOTSUP;
+               //LCOV_EXCL_STOP
        }
 
        /* play sound file */
@@ -388,8 +400,10 @@ check_pattern:
                ret = sound_manager_create_stream_information(SOUND_STREAM_TYPE_NOTIFICATION,
                 NULL, NULL, &stream_info);
                if (ret != SOUND_MANAGER_ERROR_NONE) {
-                       _E("Failed to set session to play sound(%d)", ret); //LCOV_EXCL_LINE
-                       return -ENOENT; //LCOV_EXCL_LINE
+                       //LCOV_EXCL_START
+                       _E("Failed to set session to play sound(%d)", ret);
+                       return -ENOENT;
+                       //LCOV_EXCL_STOP
                }
                do {
                        ret = wav_player_start_new(path, stream_info, play_completed, stream_info, NULL);
@@ -417,6 +431,7 @@ check_pattern:
        return -EPERM;
 }
 
+//LCOV_EXCL_START
 static int sound_play_path(feedback_pattern_e pattern, const char *soundpath, bool always)
 {
        struct stat buf;
@@ -488,6 +503,7 @@ check_pattern:
        }
        return -EPERM;
 }
+//LCOV_EXCL_STOP
 
 static int sound_is_supported(feedback_pattern_e pattern, bool *supported)
 {
@@ -614,6 +630,7 @@ static int sound_set_path(feedback_pattern_e pattern, char *path)
 }
 //LCOV_EXCL_STOP
 
+//LCOV_EXCL_START
 static int sound_get_count_of_theme(unsigned int *count_of_theme)
 {
        if (!count_of_theme)
@@ -623,7 +640,9 @@ static int sound_get_count_of_theme(unsigned int *count_of_theme)
 
        return 0;
 }
+//LCOV_EXCL_STOP
 
+//LCOV_EXCL_START
 static int sound_get_theme_index(unsigned int *index_of_theme)
 {
        if (!index_of_theme)
@@ -633,7 +652,9 @@ static int sound_get_theme_index(unsigned int *index_of_theme)
 
        return 0;
 }
+//LCOV_EXCL_STOP
 
+//LCOV_EXCL_START
 static int sound_set_theme_index(unsigned int index_of_theme)
 {
        int ret = 0;
@@ -651,6 +672,7 @@ static int sound_set_theme_index(unsigned int index_of_theme)
 
        return 0;
 }
+//LCOV_EXCL_STOP
 
 static const struct device_ops sound_device_ops = {
        .type = FEEDBACK_TYPE_SOUND,
index f47dc84..7bdf2de 100644 (file)
@@ -30,6 +30,7 @@
 
 extern char *program_invocation_name;
 
+//LCOV_EXCL_START
 bool is_privilege_supported(const char *privilege_name)
 {
        cynara *cynara = NULL;
@@ -73,3 +74,4 @@ bool is_privilege_supported(const char *privilege_name)
 
        return true;
 }
+//LCOV_EXCL_STOP
\ No newline at end of file