Adjust line exclusion from code coverage 39/297939/2
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 29 Aug 2023 03:31:41 +0000 (12:31 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 29 Aug 2023 04:01:57 +0000 (13:01 +0900)
Tizen uses RPI4 device for Common(IoT) profile. The functions are not
worked propelry. Because, this feature is for mobile and wearable profile.
This API will be deprecated.

Change-Id: Ia48135652c6ad7a16bf7c727faf5bec4c8054e12
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
CMakeLists.txt
src/CMakeLists.txt
src/job_error.c
src/job_info.c
src/job_scheduler.c

index 085faf4cf86af4f5f6d82b6a69258b26d9a7441e..2ce8011934df64191a5e0dedf1f9b85341dbd3a5 100644 (file)
@@ -1,4 +1,6 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
+
+PROJECT(capi-appfw-job-scheduler)
 
 SET(INC_DIR include)
 
index a03f03ef48fbc884998f7f946e64565da64ec828..9b721ea6a34b97e22c78356773e2aaf1752369df 100644 (file)
@@ -1,4 +1,4 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
 SET(fw_name "capi-appfw-job-scheduler")
 
 PROJECT(${fw_name})
index f3661cbcea22cbe54d8e1ce4dda6344429eaaa40..0c700c975fdeb0162406a9220d2752798a1b8396 100644 (file)
@@ -30,9 +30,9 @@ static const char *__job_error_to_string(job_error_e error)
                return "None";
        case JOB_ERROR_INVALID_PARAMETER:
                return "Invalid parameter";
-       case JOB_ERROR_OUT_OF_MEMORY:
-               return "Out of memory"; /* LCOV_EXCL_LINE */
-       case JOB_ERROR_IO_ERROR:
+       case JOB_ERROR_OUT_OF_MEMORY:  /* LCOV_EXCL_LINE */
+               return "Out of memory";  /* LCOV_EXCL_LINE */
+       case JOB_ERROR_IO_ERROR:  /* LCOV_EXCL_LINE */
                return "IO error"; /* LCOV_EXCL_LINE */
        case JOB_ERROR_NOT_INITIALIZED:
                return "Not initialized";
@@ -40,9 +40,9 @@ static const char *__job_error_to_string(job_error_e error)
                return "No such job";
        case JOB_ERROR_ALREADY_EXIST:
                return "Already exist";
-       case JOB_ERROR_PERMISSION_DENIED:
+       case JOB_ERROR_PERMISSION_DENIED:  /* LCOV_EXCL_LINE */
                return "Permission denied"; /* LCOV_EXCL_LINE */
-       default:
+       default:  /* LCOV_EXCL_LINE */
                return "Unknown"; /* LCOV_EXCL_LINE */
        }
 }
index 534e39cafbaa65d5c022bc8f2a15ecc7ee589a7e..8699e2f7cc3fe63feb5f8a1c94fac8226bedb745 100644 (file)
@@ -254,9 +254,9 @@ API int job_info_set_requires_battery_not_low(job_info_h job_info,
        if (r != JOB_ERROR_NONE)
                return job_error(r, __FUNCTION__, __LINE__, NULL);
 
-       job_info->battery_not_low = battery_not_low;
+       job_info->battery_not_low = battery_not_low;  /* LCOV_EXCL_LINE */
 
-       return JOB_ERROR_NONE;
+       return JOB_ERROR_NONE;  /* LCOV_EXCL_LINE */
 }
 
 int job_info_is_requires_battery_not_low(job_info_h job_info,
@@ -287,9 +287,9 @@ API int job_info_set_requires_charging(job_info_h job_info, bool charging)
        if (r != JOB_ERROR_NONE)
                return job_error(r, __FUNCTION__, __LINE__, NULL);
 
-       job_info->charging = charging;
+       job_info->charging = charging;  /* LCOV_EXCL_LINE */
 
-       return JOB_ERROR_NONE;
+       return JOB_ERROR_NONE;  /* LCOV_EXCL_LINE */
 }
 
 int job_info_is_requires_charging(job_info_h job_info, int *charging)
@@ -415,14 +415,14 @@ API int job_info_clone(job_info_h job_info, job_info_h *clone)
        }
 
        if (job_info->job_id) {
+               /* LCOV_EXCL_START */
                info->job_id = strdup(job_info->job_id);
                if (info->job_id == NULL) {
-                       /* LCOV_EXCL_START */
                        free(info);
                        return job_error(JOB_ERROR_OUT_OF_MEMORY, __FUNCTION__,
                                        __LINE__, NULL);
-                       /* LCOV_EXCL_STOP */
                }
+               /* LCOV_EXCL_STOP */
        }
 
        info->interval = job_info->interval;
@@ -441,19 +441,19 @@ API int job_info_clone(job_info_h job_info, job_info_h *clone)
        return JOB_ERROR_NONE;
 }
 
+/* LCOV_EXCL_START */
 int job_info_get_trigger_list(job_info_h job_info, bool **trigger_list)
 {
        if (job_info == NULL || trigger_list == NULL) {
-               /* LCOV_EXCL_START */
                return job_error(JOB_ERROR_INVALID_PARAMETER, __FUNCTION__,
                                __LINE__, NULL);
-               /* LCOV_EXCL_STOP */
        }
 
        *trigger_list = job_info->trigger_list;
 
        return JOB_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
 int job_info_set_job_id(job_info_h job_info, const char *job_id)
 {
@@ -499,9 +499,9 @@ API int job_info_get_job_id(job_info_h job_info, char **job_id)
 static void __set_requires_value(const char *str, int *value)
 {
        if (str && strcmp(str, "true") == 0)
-               *value = true;
+               *value = true;  /* LCOV_EXCL_LINE */
        else if (str && strcmp(str, "false") == 0)
-               *value = false;
+               *value = false;  /* LCOV_EXCL_LINE */
        else
                *value = -1;
 }
@@ -561,15 +561,15 @@ static void __set_job_info(job_info_h job_info, bundle *b)
 
        val = bundle_get_val(b, AUL_K_JOB_PERSISTENT);
        if (val)
-               job_info->persistent = true;
+               job_info->persistent = true;  /* LCOV_EXCL_LINE */
 
        val = bundle_get_val(b, AUL_K_JOB_IS_ONCE);
        if (val)
-               job_info->once = true;
+               job_info->once = true;  /* LCOV_EXCL_LINE */
 
        val = bundle_get_val(b, AUL_K_JOB_REQ_TIMEOUT);
        if (val && isdigit(*val))
-               job_info->timeout = strtoul(val, NULL, 10);
+               job_info->timeout = strtoul(val, NULL, 10);  /* LCOV_EXCL_LINE */
 
        val = bundle_get_val(b, AUL_K_JOB_REQ_BATTERY_NOT_LOW);
        __set_requires_value(val, &job_info->battery_not_low);
@@ -583,7 +583,7 @@ static void __set_job_info(job_info_h job_info, bundle *b)
        for (i = 0; i < ARRAY_SIZE(key_list); ++i) {
                val = bundle_get_val(b, key_list[i]);
                if (val)
-                       job_info->trigger_list[i] = true;
+                       job_info->trigger_list[i] = true;  /* LCOV_EXCL_LINE */
        }
 }
 
index c67feacdbef171b0cc62e94c2453705543ec2696..7071a6982ecf961195b41cad250d7abccdec186a 100644 (file)
@@ -246,8 +246,10 @@ static bundle *__get_bundle_from_job(ctx_sched_job_h job)
 
        r = ctx_sched_job_get_user_data(job, (char **)&b_raw, &len);
        if (r != 0) {
+               /* LCOV_EXCL_START */
                _E("Failed to get user data");
                return NULL;
+               /* LCOV_EXCL_STOP */
        }
 
        b = bundle_decode(b_raw, len);
@@ -259,6 +261,7 @@ static bundle *__get_bundle_from_job(ctx_sched_job_h job)
        return b;
 }
 
+/* LCOV_EXCL_START */
 static void __add_job(ctx_sched_job_h job)
 {
        bundle *b = NULL;
@@ -314,19 +317,15 @@ static void __start_job_cb(ctx_sched_h scheduler, ctx_sched_job_h job,
 
        b = __get_bundle_from_job(job);
        if (b == NULL) {
-               /* LCOV_EXCL_START */
                ctx_sched_job_destroy(job);
                return;
-               /* LCOV_EXCL_STOP */
        }
 
        job_id = bundle_get_val(b, AUL_K_JOB_ID);
        if (job_id == NULL) {
-               /* LCOV_EXCL_START */
                ctx_sched_job_destroy(job);
                bundle_free(b);
                return;
-               /* LCOV_EXCL_STOP */
        }
 
        if (!g_hash_table_contains(__handle.job_id_table, job_id))
@@ -347,25 +346,22 @@ static void __stop_job_cb(ctx_sched_h scheduler, ctx_sched_job_h job,
 
        b = __get_bundle_from_job(job);
        if (b == NULL) {
-               /* LCOV_EXCL_START */
                ctx_sched_job_destroy(job);
                return;
-               /* LCOV_EXCL_STOP */
        }
 
        job_id = bundle_get_val(b, AUL_K_JOB_ID);
        if (job_id == NULL) {
-               /* LCOV_EXCL_START */
                ctx_sched_job_destroy(job);
                bundle_free(b);
                return;
-               /* LCOV_EXCL_STOP */
        }
 
        service_app_job_raise(SERVICE_APP_JOB_STATUS_STOP, job_id, b);
        ctx_sched_job_destroy(job);
        bundle_free(b);
 }
+/* LCOV_EXCL_STOP */
 
 static int __init_scheduler(ctx_sched_h *scheduler)
 {
@@ -514,8 +510,10 @@ static int __job_add_user_data(ctx_sched_job_h job, job_info_h job_info,
 
        r = bundle_encode(b, &b_raw, &len);
        if (r != BUNDLE_ERROR_NONE) {
+               /* LCOV_EXCL_START */
                _E("Failed to encode bundle");
                return JOB_ERROR_IO_ERROR;
+               /* LCOV_EXCL_STOP */
        }
 
        r = ctx_sched_job_set_user_data(job, (const char *)b_raw, len);
@@ -554,8 +552,10 @@ static bool __exist_job(const char *job_id)
 
        r = ctx_sched_get_job(__handle.scheduler, id, &job);
        if (r != 0) {
+               /* LCOV_EXCL_START */
                g_hash_table_remove(__handle.job_id_table, job_id);
                return false;
+               /* LCOV_EXCL_STOP */
        }
 
        ctx_sched_job_destroy(job);
@@ -583,7 +583,7 @@ static int __job_add_persistent(ctx_sched_job_h job, job_info_h job_info,
        }
 
        if (persistent)
-               bundle_add(b, AUL_K_JOB_PERSISTENT, "true");
+               bundle_add(b, AUL_K_JOB_PERSISTENT, "true");  /* LCOV_EXCL_LINE */
 
        return JOB_ERROR_NONE;
 }
@@ -608,7 +608,7 @@ static int __job_add_one_time(ctx_sched_job_h job, job_info_h job_info,
        }
 
        if (once)
-               bundle_add(b, AUL_K_JOB_IS_ONCE, "true");
+               bundle_add(b, AUL_K_JOB_IS_ONCE, "true");  /* LCOV_EXCL_LINE */
 
        return JOB_ERROR_NONE;
 }
@@ -634,13 +634,16 @@ static int __job_add_requirement_timeout(ctx_sched_job_h job,
        }
 
        if (timeout) {
+               /* LCOV_EXCL_START */
                snprintf(buf, sizeof(buf), "%u", timeout);
                bundle_add(b, AUL_K_JOB_REQ_TIMEOUT, buf);
+               /* LCOV_EXCL_STOP */
        }
 
        return JOB_ERROR_NONE;
 }
 
+/* LCOV_EXCL_START */
 static int __add_str_attr_ne(ctx_sched_job_context_h context,
                const char *name, const char *value)
 {
@@ -648,18 +651,14 @@ static int __add_str_attr_ne(ctx_sched_job_context_h context,
 
        r = ctx_sched_job_context_prepare_attribute_str(context, name);
        if (r != 0) {
-               /* LCOV_EXCL_START */
                _E("Failed to prepare string attribute(%s) - %d", name, r);
                return r;
-               /* LCOV_EXCL_STOP */
        }
 
        r = ctx_sched_job_context_attribute_add_ne_str(context, name, value);
        if (r != 0) {
-               /* LCOV_EXCL_START */
                _E("Failed to add string value(%s) - %d", value, r);
                return r;
-               /* LCOV_EXCL_STOP */
        }
 
        return JOB_ERROR_NONE;
@@ -672,18 +671,14 @@ static int __add_str_attr_eq(ctx_sched_job_context_h context,
 
        r = ctx_sched_job_context_prepare_attribute_str(context, name);
        if (r != 0) {
-               /* LCOV_EXCL_START */
                _E("Failed to prepare string attribute(%s) - %d", name, r);
                return r;
-               /* LCOV_EXCL_STOP */
        }
 
        r = ctx_sched_job_context_attribute_add_eq_str(context, name, value);
        if (r != 0) {
-               /* LCOV_EXCL_START */
                _E("Failed to add string value(%s) - %d", value, r);
                return r;
-               /* LCOV_EXCL_STOP */
        }
 
        return JOB_ERROR_NONE;
@@ -696,22 +691,19 @@ static int __add_int_attr_eq(ctx_sched_job_context_h context,
 
        r = ctx_sched_job_context_prepare_attribute_int(context, name);
        if (r != 0) {
-               /* LCOV_EXCL_START */
                _E("Failed to prepare integer attribute(%s) - %d", name, r);
                return r;
-               /* LCOV_EXCL_STOP */
        }
 
        r = ctx_sched_job_context_attribute_add_eq_int(context, name, value);
        if (r != 0) {
-               /* LCOV_EXCL_START */
                _E("Failed to add integer value(%d) - %d", value, r);
                return r;
-               /* LCOV_EXCL_STOP */
        }
 
        return JOB_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
 static int __job_add_requires_battery_not_low(ctx_sched_job_h job,
                job_info_h job_info, void *data)
@@ -728,13 +720,12 @@ static int __job_add_requires_battery_not_low(ctx_sched_job_h job,
        if (battery_not_low == -1)
                return JOB_ERROR_NONE;
 
+       /* LCOV_EXCL_START */
        r = ctx_sched_job_requirement_create(CTX_SCHED_URI_BATTERY, false,
                        &requirement);
        if (r != 0) {
-               /* LCOV_EXCL_START */
                _E("Failed to create requirement (%d)", r);
                return r;
-               /* LCOV_EXCL_STOP */
        }
 
        if (battery_not_low) {
@@ -744,20 +735,17 @@ static int __job_add_requires_battery_not_low(ctx_sched_job_h job,
                r = __add_str_attr_ne(requirement, CTX_SCHED_ATTR_NAME_LEVEL,
                                CTX_SCHED_ATTR_VALUE_HIGH);
        }
+
        if (r != JOB_ERROR_NONE) {
-               /* LCOV_EXCL_START */
                ctx_sched_job_context_destroy(requirement);
                return r;
-               /* LCOV_EXCL_STOP */
        }
 
        r = ctx_sched_job_add_requirement(job, requirement);
        if (r != 0) {
-               /* LCOV_EXCL_START */
                _E("Failed to add requirement (%d)", r);
                ctx_sched_job_context_destroy(requirement);
                return r;
-               /* LCOV_EXCL_STOP */
        }
 
        if (battery_not_low)
@@ -766,6 +754,7 @@ static int __job_add_requires_battery_not_low(ctx_sched_job_h job,
                bundle_add(b, AUL_K_JOB_REQ_BATTERY_NOT_LOW, "false");
 
        return JOB_ERROR_NONE;
+       /* LCOV_EXCL_STOP */
 }
 
 static int __job_add_requires_charging(ctx_sched_job_h job,
@@ -783,31 +772,26 @@ static int __job_add_requires_charging(ctx_sched_job_h job,
        if (charging == -1)
                return JOB_ERROR_NONE;
 
+       /* LCOV_EXCL_START */
        r = ctx_sched_job_requirement_create(CTX_SCHED_URI_BATTERY, false,
                        &requirement);
        if (r != 0) {
-               /* LCOV_EXCL_START */
                _E("Failed to create requirement (%d)", r);
                return r;
-               /* LCOV_EXCL_STOP */
        }
 
        r = __add_int_attr_eq(requirement, CTX_SCHED_ATTR_NAME_IS_CHARGING,
                        charging);
        if (r != JOB_ERROR_NONE) {
-               /* LCOV_EXCL_START */
                ctx_sched_job_context_destroy(requirement);
                return r;
-               /* LCOV_EXCL_STOP */
        }
 
        r = ctx_sched_job_add_requirement(job, requirement);
        if (r != 0) {
-               /* LCOV_EXCL_START */
                _E("Failed to add requirement (%d)", r);
                ctx_sched_job_context_destroy(requirement);
                return r;
-               /* LCOV_EXCL_STOP */
        }
 
        if (charging)
@@ -816,6 +800,7 @@ static int __job_add_requires_charging(ctx_sched_job_h job,
                bundle_add(b, AUL_K_JOB_REQ_CHARGING, "false");
 
        return JOB_ERROR_NONE;
+       /* LCOV_EXCL_STOP */
 }
 
 static int __job_add_requires_wifi_connection(ctx_sched_job_h job,
@@ -833,13 +818,12 @@ static int __job_add_requires_wifi_connection(ctx_sched_job_h job,
        if (wifi_connection == -1)
                return JOB_ERROR_NONE;
 
+       /* LCOV_EXCL_START */
        r = ctx_sched_job_requirement_create(CTX_SCHED_URI_WIFI, false,
                        &requirement);
        if (r != 0) {
-               /* LCOV_EXCL_START */
                _E("Failed to create requirement (%d)", r);
                return r;
-               /* LCOV_EXCL_STOP */
        }
 
        if (wifi_connection) {
@@ -849,20 +833,17 @@ static int __job_add_requires_wifi_connection(ctx_sched_job_h job,
                r = __add_str_attr_ne(requirement, CTX_SCHED_ATTR_NAME_STATE,
                                CTX_SCHED_ATTR_VALUE_CONNECTED);
        }
+
        if (r != JOB_ERROR_NONE) {
-               /* LCOV_EXCL_START */
                ctx_sched_job_context_destroy(requirement);
                return r;
-               /* LCOV_EXCL_STOP */
        }
 
        r = ctx_sched_job_add_requirement(job, requirement);
        if (r != 0) {
-               /* LCOV_EXCL_START */
                _E("Failed to add requirement (%d)", r);
                ctx_sched_job_context_destroy(requirement);
                return r;
-               /* LCOV_EXCL_STOP */
        }
 
        if (wifi_connection)
@@ -871,8 +852,10 @@ static int __job_add_requires_wifi_connection(ctx_sched_job_h job,
                bundle_add(b, AUL_K_JOB_REQ_WIFI_CONNECTION, "false");
 
        return JOB_ERROR_NONE;
+               /* LCOV_EXCL_STOP */
 }
 
+/* LCOV_EXCL_START */
 static int __add_trigger_event(ctx_sched_job_h job, job_trigger_event_e event,
                bundle *b)
 {
@@ -882,10 +865,8 @@ static int __add_trigger_event(ctx_sched_job_h job, job_trigger_event_e event,
        r = ctx_sched_job_trigger_create(job_trigger_map[event].uri,
                        &trigger);
        if (r != 0) {
-               /* LCOV_EXCL_START */
                _E("Failed to create trigger (%d)", r);
                return r;
-               /* LCOV_EXCL_STOP */
        }
 
        if (job_trigger_map[event].attr_type == ATTR_TYPE_INTEGER) {
@@ -902,17 +883,16 @@ static int __add_trigger_event(ctx_sched_job_h job, job_trigger_event_e event,
 
        r = ctx_sched_job_add_trigger(job, trigger);
        if (r != 0) {
-               /* LCOV_EXCL_START */
                _E("Failed to add trigger (%d)", r);
                ctx_sched_job_context_destroy(trigger);
                return r;
-               /* LCOV_EXCL_STOP */
        }
 
        bundle_add(b, job_trigger_map[event].key, "true");
 
        return JOB_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
 static int __job_add_trigger_events(ctx_sched_job_h job,
                job_info_h job_info, void *data)
@@ -927,6 +907,7 @@ static int __job_add_trigger_events(ctx_sched_job_h job,
        if (interval != 0)
                return JOB_ERROR_NONE;
 
+       /* LCOV_EXCL_START */
        r = job_info_get_trigger_list(job_info, &trigger_list);
        if (r != JOB_ERROR_NONE)
                return r;
@@ -941,6 +922,7 @@ static int __job_add_trigger_events(ctx_sched_job_h job,
        }
 
        return JOB_ERROR_NONE;
+       /* LCOV_EXCL_STOP */
 }
 
 static job_add_cb job_constructor[] = {
@@ -983,7 +965,7 @@ static ctx_sched_job_h __create_job(job_info_h job_info, const char *job_id)
 
        job_info_get_periodic(job_info, &interval);
        if (interval == 0) {
-               r = ctx_sched_job_create_on_demand(&job);
+               r = ctx_sched_job_create_on_demand(&job);  /* LCOV_EXCL_LINE */
        } else {
                snprintf(buf, sizeof(buf), "%u", interval);
                bundle_add(b, AUL_K_JOB_PERIODIC, buf);
@@ -1252,6 +1234,7 @@ API int job_scheduler_foreach_job(job_scheduler_foreach_job_cb callback,
        return JOB_ERROR_NONE;
 }
 
+/* LCOV_EXCL_START*/
 static int __job_service_cb(int event, const char *job_id, bundle *job_data,
                void *user_data)
 {
@@ -1278,6 +1261,7 @@ static int __job_service_cb(int event, const char *job_id, bundle *job_data,
 
        return 0;
 }
+/* LCOV_EXCL_STOP */
 
 static struct job_service_s *__create_job_service(const char *job_id,
                job_service_callback_s *callback, void *user_data)
@@ -1390,8 +1374,10 @@ int job_scheduler_verify_requirement(const char *uri)
        int r;
 
        if (uri == NULL) {
+               /* LCOV_EXCL_START */
                return job_error(JOB_ERROR_INVALID_PARAMETER, __FUNCTION__,
                                __LINE__, NULL);
+               /* LCOV_EXCL_STOP */
        }
 
        if (!__handle.initialized) {
@@ -1424,8 +1410,10 @@ int job_scheduler_verify_trigger(const char *uri)
        int r;
 
        if (uri == NULL) {
+               /* LCOV_EXCL_START */
                return job_error(JOB_ERROR_INVALID_PARAMETER, __FUNCTION__,
                                __LINE__, NULL);
+               /* LCOV_EXCL_STOP */
        }
 
        if (!__handle.initialized) {
@@ -1516,8 +1504,9 @@ static int __init_cynara(void)
        _I("Cynara initialized");
 
        return 0;
-err:
+
        /* LCOV_EXCL_START */
+err:
        if (conf)
                cynara_configuration_destroy(conf);