diff options
author | hyunuk.tak <hyunuk.tak@samsung.com> | 2024-04-05 11:53:55 +0900 |
---|---|---|
committer | hyunuk.tak <hyunuk.tak@samsung.com> | 2024-04-05 11:54:03 +0900 |
commit | 6c951c4e680544a79f3b02a7f3a518ebe8b72df6 (patch) | |
tree | 9844e53f059e56d67f9299ecb8c14d926986fa86 | |
parent | 30a322ccb6ae260590962d232f07ebab0206f590 (diff) | |
download | user-awareness-accepted/tizen_unified_dev.tar.gz user-awareness-accepted/tizen_unified_dev.tar.bz2 user-awareness-accepted/tizen_unified_dev.zip |
Exclude internal APIs for lcovtizen_9.0_m2_releaseaccepted/tizen/unified/x/20240412.023941accepted/tizen/unified/dev/20240620.004648accepted/tizen/unified/20240411.142605accepted/tizen/9.0/unified/20241030.232404tizen_9.0accepted/tizen_unified_xaccepted/tizen_unified_devaccepted/tizen_unifiedaccepted/tizen_9.0_unified
Change-Id: Ic42931a31513d9b0a802c77564279eaba0d17d13
Signed-off-by: hyunuk.tak <hyunuk.tak@samsung.com>
-rwxr-xr-x | src/user-awareness-device.c | 46 | ||||
-rwxr-xr-x | src/user-awareness-event-handler.c | 2 | ||||
-rwxr-xr-x | src/user-awareness-monitors.c | 28 | ||||
-rwxr-xr-x | src/user-awareness-payload.c | 17 | ||||
-rwxr-xr-x | src/user-awareness-service.c | 26 | ||||
-rwxr-xr-x | src/user-awareness-users.c | 40 | ||||
-rwxr-xr-x | src/user-awareness-util.c | 22 | ||||
-rwxr-xr-x | tests/unittest/tct-user-awareness-core.h | 12 | ||||
-rwxr-xr-x | tests/unittest/utc-user-awareness-location.c | 128 |
9 files changed, 255 insertions, 66 deletions
diff --git a/src/user-awareness-device.c b/src/user-awareness-device.c index a251963..6a56b3b 100755 --- a/src/user-awareness-device.c +++ b/src/user-awareness-device.c @@ -26,6 +26,7 @@ static GSList *ua_devices_list = NULL; static ua_callback_s user_callbacks[UA_USER_EVENT_MAX][UA_SENSOR_MAX] = {{{NULL, NULL, 0},},}; +/* LCOV_EXCL_START */ static void __ua_remove_device_info_from_list(uam_device_info_s *uam_info) { FUNC_ENTRY; @@ -57,6 +58,7 @@ static void __ua_remove_device_info_from_list(uam_device_info_s *uam_info) FUNC_EXIT; } +/* LCOV_EXCL_STOP */ static ua_dev_info_s* __ua_add_device_info_to_list(uam_device_info_s *uam_info) { @@ -139,8 +141,10 @@ ua_dev_info_s* _ua_get_device_info_from_uam(uam_device_info_s *uam_info) { ua_dev_info_s *dev = g_malloc0(sizeof(ua_dev_info_s)); if (!dev) { + /* LCOV_EXCL_START */ UA_ERR("g_malloc0 failed"); return NULL; + /* LCOV_EXCL_STOP */ } dev->user = NULL; dev->bssid = NULL; @@ -148,23 +152,29 @@ ua_dev_info_s* _ua_get_device_info_from_uam(uam_device_info_s *uam_info) dev->mac = g_strdup(uam_info->mac); if (dev->mac == NULL) { + /* LCOV_EXCL_START */ UA_ERR("g_malloc0 failed"); _ua_free_ua_device_info_t((gpointer)dev); return NULL; + /* LCOV_EXCL_STOP */ } dev->ipv4 = g_strdup(uam_info->ipv4_addr); if (dev->ipv4 == NULL) { + /* LCOV_EXCL_START */ UA_ERR("g_malloc0 failed"); _ua_free_ua_device_info_t((gpointer)dev); return NULL; + /* LCOV_EXCL_STOP */ } dev->device_id = g_strdup(uam_info->device_id); if (dev->device_id == NULL) { + /* LCOV_EXCL_START */ UA_ERR("g_malloc0 failed"); _ua_free_ua_device_info_t((gpointer)dev); return NULL; + /* LCOV_EXCL_STOP */ } dev->type = _to_ua_mac_type(uam_info->type); @@ -202,6 +212,7 @@ void _ua_clear_device_list(void) ua_devices_list = NULL; } +/* LCOV_EXCL_START */ int _ua_is_device_exist(char *device_id, char *mac, ua_mac_type_e type, gboolean *is_exist) { @@ -215,23 +226,20 @@ int _ua_is_device_exist(char *device_id, char *mac, ua_mac_type_e type, if ((int)type == (int)dev->type) { if (device_id && !g_strcmp0(device_id, dev->device_id)) { - /* LCOV_EXCL_START */ UA_INFO("Device found, device id[%s]", dev->device_id); *is_exist = true; - /* LCOV_EXCL_STOP */ } if (mac && !g_strcmp0(mac, dev->mac)) { - /* LCOV_EXCL_START */ UA_INFO("Device found, mac address[%s]", dev->mac); *is_exist = true; - /* LCOV_EXCL_STOP */ } } } return UA_ERROR_NONE; } +/* LCOV_EXCL_STOP */ int _ua_device_add_info_to_list(ua_dev_info_s* dev_info) { @@ -268,6 +276,7 @@ void _ua_add_user_callback(ua_user_event_e event, ua_mac_type_e type, user_callbacks[event][type].count += 1; } +/* LCOV_EXCL_START */ void _ua_handle_device_added(int result, uam_device_info_s *uam_info) { FUNC_ENTRY; @@ -317,6 +326,7 @@ void _ua_handle_device_added(int result, uam_device_info_s *uam_info) FUNC_EXIT; } +/* LCOV_EXCL_STOP */ void _ua_handle_device_removed(int result, uam_device_info_s *uam_info) { @@ -473,6 +483,7 @@ int ua_device_destroy(ua_device_h device_handle) return UA_ERROR_NONE; } +/* LCOV_EXCL_START */ int ua_device_set_mac_type(ua_device_h handle, ua_mac_type_e mac_type) { FUNC_ENTRY; @@ -491,6 +502,7 @@ int ua_device_set_mac_type(ua_device_h handle, ua_mac_type_e mac_type) FUNC_EXIT; return UA_ERROR_NONE; } +/* LCOV_EXCL_STOP */ int ua_device_get_mac_type(ua_device_h handle, ua_mac_type_e *mac_type) { @@ -511,6 +523,7 @@ int ua_device_get_mac_type(ua_device_h handle, ua_mac_type_e *mac_type) return UA_ERROR_NONE; } +/* LCOV_EXCL_START */ int ua_device_set_mac_address( ua_device_h handle, const char *mac_address) @@ -554,6 +567,7 @@ int ua_device_set_mac_address( FUNC_EXIT; return UA_ERROR_NONE; } +/* LCOV_EXCL_STOP */ int ua_device_set_os_info( ua_device_h handle, @@ -580,6 +594,7 @@ int ua_device_set_os_info( return UA_ERROR_NONE; } +/* LCOV_EXCL_START */ int ua_device_set_device_id( ua_device_h handle, const char *device_id) @@ -612,6 +627,7 @@ int ua_device_set_device_id( FUNC_EXIT; return UA_ERROR_NONE; } +/* LCOV_EXCL_STOP */ int ua_device_set_wifi_bssid( ua_device_h handle, @@ -633,8 +649,10 @@ int ua_device_set_wifi_bssid( if (device->bssid) { g_strlcpy(device->bssid, bssid, UA_MAC_ADDRESS_STRING_LEN); } else { + /* LCOV_EXCL_START */ UA_ERR("Failed to allocated memory"); return UA_ERROR_OUT_OF_MEMORY; + /* LCOV_EXCL_STOP */ } FUNC_EXIT; @@ -661,14 +679,17 @@ int ua_device_set_wifi_ipv4_address( if (device->ipv4) { g_strlcpy(device->ipv4, ipv4_address, UA_IPV4_ADDRESS_STRING_LEN); } else { + /* LCOV_EXCL_START */ UA_ERR("Failed to allocated memory"); return UA_ERROR_OUT_OF_MEMORY; + /* LCOV_EXCL_STOP */ } FUNC_EXIT; return UA_ERROR_NONE; } +/* LCOV_EXCL_START */ int ua_device_set_discriminant( ua_device_h device_handle, bool discriminant) @@ -686,6 +707,7 @@ int ua_device_set_discriminant( FUNC_EXIT; return UA_ERROR_NONE; } +/* LCOV_EXCL_STOP */ int ua_device_get_mac_address( ua_device_h device_handle, @@ -985,15 +1007,15 @@ int ua_device_update(ua_device_h device_handle) /* LCOV_EXCL_START */ UA_ERR("Failed with error: %s(0x%X)", _ua_get_error_string(ret), ret); - /* LCOV_EXCL_STOP */ return ret; + /* LCOV_EXCL_STOP */ } if (!is_registered) { /* LCOV_EXCL_START */ UA_ERR("No registerd device"); - /* LCOV_EXCL_STOP */ return UA_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ } ret = _ua_get_error_code(_uam_request_update_device(&uam_device)); @@ -1001,14 +1023,15 @@ int ua_device_update(ua_device_h device_handle) /* LCOV_EXCL_START */ UA_ERR("_uam_request_set_device_update returned %s", _ua_get_error_string(ret)); - /* LCOV_EXCL_STOP */ return ret; + /* LCOV_EXCL_STOP */ } FUNC_EXIT; return UA_ERROR_NONE; } +/* LCOV_EXCL_START */ int ua_device_clone(ua_device_h *cloned, ua_device_h origin) { @@ -1020,7 +1043,6 @@ int ua_device_clone(ua_device_h *cloned, UA_DEPRECATED_LOG(__FUNCTION__, ""); UA_CHECK_INIT_STATUS(); - /* LCOV_EXCL_START */ UA_VALIDATE_INPUT_PARAMETER(cloned); UA_VALIDATE_INPUT_PARAMETER(origin); ua_dev_info_s *org_device = (ua_dev_info_s *)origin; @@ -1088,9 +1110,9 @@ int ua_device_clone(ua_device_h *cloned, device->create_by_app = true; FUNC_EXIT; - /* LCOV_EXCL_STOP */ return UA_ERROR_NONE; } +/* LCOV_EXCL_STOP */ int ua_foreach_devices( ua_registered_device_cb foreach_cb, @@ -1115,8 +1137,8 @@ int ua_foreach_devices( UA_ERR("Failed with error: %s(0x%X)", _ua_get_error_string(ret), ret); g_ptr_array_free(devices_list, TRUE); - /* LCOV_EXCL_STOP */ return ret; + /* LCOV_EXCL_STOP */ } for (i = 0; i < devices_list->len; i++) { @@ -1156,6 +1178,7 @@ done: return ret; } +/* LCOV_EXCL_START */ int ua_device_foreach_added_by_user( ua_user_h user_handle, ua_registered_device_cb foreach_cb, @@ -1172,6 +1195,7 @@ int ua_device_foreach_added_by_user( FUNC_EXIT; return ret; } +/* LCOV_EXCL_STOP */ int ua_device_get_pairing_required( ua_device_h handle, @@ -1214,8 +1238,8 @@ int ua_device_get_pairing_required( /* LCOV_EXCL_START */ UA_ERR("Failed with error: %s(0x%X)", _ua_get_error_string(ret), ret); - /* LCOV_EXCL_STOP */ return ret; + /* LCOV_EXCL_STOP */ } *pairing_required = is_registered ? false : true; diff --git a/src/user-awareness-event-handler.c b/src/user-awareness-event-handler.c index a67c351..c899d75 100755 --- a/src/user-awareness-event-handler.c +++ b/src/user-awareness-event-handler.c @@ -353,9 +353,11 @@ int ua_initialize(void) ret = _ua_get_error_code(_uam_init(__ua_event_handler, NULL)); if (UA_ERROR_NONE != ret && ret != UA_ERROR_ALREADY_DONE) { + /* LCOV_EXCL_START */ UA_ERR("Failed with error: %s(0x%X)", _ua_get_error_string(ret), ret); return ret; + /* LCOV_EXCL_STOP */ } is_initialized = TRUE; diff --git a/src/user-awareness-monitors.c b/src/user-awareness-monitors.c index 5bafc98..101f4f2 100755 --- a/src/user-awareness-monitors.c +++ b/src/user-awareness-monitors.c @@ -30,12 +30,14 @@ static GSList *ua_monitor_list; static ua_monitor_h scanning_monitor = NULL; static guint location_cb_timer = 0; +/* LCOV_EXCL_START */ static gboolean __ua_monitor_is_only_env_in_conditions( ua_monitor_s *monitor) { return !((monitor->presence_bitmask_and | monitor->presence_bitmask_or) & (UA_SENSOR_WIFI | UA_SENSOR_BLE | UA_SENSOR_BT)); } +/* LCOV_EXCL_STOP */ static int __ua_stop_monitoring(unsigned int bitmask, char *service, ua_detection_type_e detect) @@ -175,6 +177,7 @@ static unsigned int __ua_sensor_type_to_bitmask(int sensor_type) return bitmask; } +/* LCOV_EXCL_START */ static void __ua_free_user_state_info_t(gpointer data) { FUNC_ENTRY; @@ -1130,6 +1133,7 @@ void _ua_monitor_handle_sensor_status_changed(uam_sensor_info_s *info) FUNC_EXIT; } +/* LCOV_EXCL_STOP */ void _ua_free_ua_monitor_t(gpointer data) { @@ -1187,6 +1191,7 @@ int ua_monitor_is_sensor_available( return UA_ERROR_NONE; } +/* LCOV_EXCL_START */ int ua_set_app_info(const char *app_id, unsigned short uid) { FUNC_ENTRY; @@ -1196,10 +1201,8 @@ int ua_set_app_info(const char *app_id, unsigned short uid) int ret = _ua_get_error_code(_uam_register_app(app_id, uid)); if (UA_ERROR_NONE != ret) { - /* LCOV_EXCL_START */ UA_ERR("_uam_register_app failed"); return ret; - /* LCOV_EXCL_STOP */ } FUNC_EXIT; @@ -1215,15 +1218,14 @@ int ua_unset_app_info(const char *app_id, unsigned short uid) int ret = _ua_get_error_code(_uam_deregister_app(app_id, uid)); if (UA_ERROR_NONE != ret) { - /* LCOV_EXCL_START */ UA_ERR("_uam_deregister_app failed"); return ret; - /* LCOV_EXCL_STOP */ } FUNC_EXIT; return UA_ERROR_NONE; } +/* LCOV_EXCL_STOP */ int ua_monitor_create(ua_monitor_h *handle) { @@ -1280,6 +1282,7 @@ int ua_monitor_destroy(ua_monitor_h handle) return UA_ERROR_NONE; } +/* LCOV_EXCL_START */ int ua_monitor_set_user_presence_condition( ua_monitor_h handle, unsigned int bitmask_and, @@ -1373,6 +1376,7 @@ int ua_monitor_set_user_absence_condition( FUNC_EXIT; return UA_ERROR_NONE; } +/* LCOV_EXCL_STOP */ int ua_monitor_set_sensor_status_changed_cb(ua_monitor_h handle, ua_sensor_status_changed_cb callback, void *user_data) @@ -1612,17 +1616,23 @@ int ua_monitor_start_presence_detection( if (monitor->service) if ((service && g_strcmp0(monitor->service, service)) || (!service && g_strcmp0(monitor->service, UA_SERVICE_DEFAULT))) { + /* LCOV_EXCL_START */ g_free(service); return UA_ERROR_NOT_PERMITTED; + /* LCOV_EXCL_STOP */ } if (UA_DETECT_MODE_INVALID <= mode) { + /* LCOV_EXCL_START */ g_free(service); return UA_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ } if (0 == monitor->sensor_bitmask) { + /* LCOV_EXCL_START */ g_free(service); return UA_ERROR_NO_DATA; + /* LCOV_EXCL_STOP */ } if (!monitor->service) { @@ -2041,6 +2051,7 @@ int ua_monitor_set_location_period( return UA_ERROR_NONE; } +/* LCOV_EXCL_START */ int ua_monitor_set_brightness_threshold(ua_monitor_h handle, int presence_threshold, int absence_threshold) { @@ -2074,10 +2085,8 @@ int ua_enable_low_power_mode(void) ret = _ua_get_error_code(_uam_set_low_power_mode(UA_SENSOR_ALL, true)); if (UA_ERROR_NONE != ret) { - /* LCOV_EXCL_START */ UA_ERR("_uam_set_low_power_mode failed"); return ret; - /* LCOV_EXCL_STOP */ } FUNC_EXIT; @@ -2093,10 +2102,8 @@ int ua_disable_low_power_mode(void) ret = _ua_get_error_code(_uam_set_low_power_mode(UA_SENSOR_ALL, false)); if (UA_ERROR_NONE != ret) { - /* LCOV_EXCL_START */ UA_ERR("_uam_set_low_power_mode failed"); return ret; - /* LCOV_EXCL_STOP */ } FUNC_EXIT; @@ -2112,10 +2119,8 @@ int ua_set_low_power_mode(unsigned int bitmask, bool on_off) ret = _ua_get_error_code(_uam_set_low_power_mode(bitmask, on_off)); if (UA_ERROR_NONE != ret) { - /* LCOV_EXCL_START */ UA_ERR("_uam_set_low_power_mode failed"); return ret; - /* LCOV_EXCL_STOP */ } FUNC_EXIT; @@ -2224,4 +2229,5 @@ int ua_reset_database(void) FUNC_EXIT; return UA_ERROR_NONE; -}
\ No newline at end of file +} +/* LCOV_EXCL_STOP */
\ No newline at end of file diff --git a/src/user-awareness-payload.c b/src/user-awareness-payload.c index 03e4ded..30d8d45 100755 --- a/src/user-awareness-payload.c +++ b/src/user-awareness-payload.c @@ -24,6 +24,7 @@ #include <user-awareness-private.h> #include <user-awareness-util.h> +// LCOV_EXCL_START static GSList *ua_payloads_list; int ua_payload_create(ua_payload_h *payload_handle) @@ -36,10 +37,8 @@ int ua_payload_create(ua_payload_h *payload_handle) payload = g_malloc0(sizeof(ua_payload_info_s)); if (!payload) { - /* LCOV_EXCL_START */ UA_ERR("g_malloc0 failed"); return UA_ERROR_OUT_OF_MEMORY; - /* LCOV_EXCL_STOP */ } /* default values */ @@ -91,11 +90,8 @@ int ua_payload_destroy(ua_payload_h handle) UA_VALIDATE_HANDLE(handle, ua_payloads_list); /* Do not remove from list if payload is added to database */ - if (payload->isadded) { - /* LCOV_EXCL_START */ + if (payload->isadded) return UA_ERROR_NONE; - /* LCOV_EXCL_STOP */ - } ua_payloads_list = g_slist_remove(ua_payloads_list, payload); _ua_free_ua_payload_info_s(payload); @@ -337,11 +333,9 @@ int _ua_foreach_added_payload(ua_added_payload_cb foreach_cb, ret = _ua_get_error_code(_uam_get_added_payloads(&payload_list)); if (UA_ERROR_NONE != ret) { - /* LCOV_EXCL_START */ UA_ERR("Failed with error: %s(0x%X)", _ua_get_error_string(ret), ret); g_ptr_array_free(payload_list, TRUE); - /* LCOV_EXCL_STOP */ return ret; } @@ -361,11 +355,9 @@ int _ua_foreach_added_payload(ua_added_payload_cb foreach_cb, ua_payloads_list = g_slist_append(ua_payloads_list, payload_info); } else { - /* LCOV_EXCL_START */ UA_ERR("OPERATION_FAILED(0x%08x)", UA_ERROR_OPERATION_FAILED); ret = UA_ERROR_OPERATION_FAILED; - /* LCOV_EXCL_STOP */ goto done; } } @@ -541,10 +533,8 @@ int ua_payload_get_device_uid( UA_DBG("payload(device_uid_len) [%d]", payload->device_uid_len); *device_uid = g_memdup2(payload->device_uid, payload->device_uid_len); if (*device_uid == NULL) { - // LCOV_EXCL_START UA_ERR("g_memdup failed"); return UA_ERROR_OUT_OF_MEMORY; - // LCOV_EXCL_STOP } done: @@ -590,13 +580,12 @@ int ua_payload_get_user_data( user_data_len = UA_BLE_PAYLOAD_DEVICE_UID_MAX_LEN - 1 - payload->device_uid_len; *user_data = g_memdup2(payload->user_data, user_data_len); if (*user_data == NULL) { - // LCOV_EXCL_START UA_ERR("g_memdup failed"); return UA_ERROR_OUT_OF_MEMORY; - // LCOV_EXCL_STOP } done: FUNC_EXIT; return UA_ERROR_NONE; } +// LCOV_EXCL_STOP
\ No newline at end of file diff --git a/src/user-awareness-service.c b/src/user-awareness-service.c index d537f26..38b0152 100755 --- a/src/user-awareness-service.c +++ b/src/user-awareness-service.c @@ -96,8 +96,8 @@ int _ua_intr_get_default_service(void) /* LCOV_EXCL_START */ UA_ERR("Failed with error: %s(0x%X)", _ua_get_error_string(ret), ret); - /* LCOV_EXCL_STOP */ return ret; + /* LCOV_EXCL_STOP */ } for (l = ua_services_list; l; l = g_slist_next(l)) { @@ -175,6 +175,7 @@ int _ua_service_add_info_to_list(ua_service_info_s* ua_info) return UA_ERROR_NONE; } +/* LCOV_EXCL_START */ int _ua_service_add_info_to_list_from_uam_data(uam_service_info_s *uam_info) { FUNC_ENTRY; @@ -236,6 +237,7 @@ int _ua_service_remove_info_from_list(uam_service_info_s *uam_info) FUNC_EXIT; return ret; } +/* LCOV_EXCL_STOP */ int _ua_foreach_registered_services(ua_service_cb foreach_cb, void *user_data) @@ -257,8 +259,8 @@ int _ua_foreach_registered_services(ua_service_cb foreach_cb, UA_ERR("Failed with error: %s(0x%X)", _ua_get_error_string(ret), ret); g_ptr_array_free(service_list, TRUE); - /* LCOV_EXCL_STOP */ return ret; + /* LCOV_EXCL_STOP */ } for (i = 0; i < service_list->len; i++) { @@ -271,8 +273,8 @@ int _ua_foreach_registered_services(ua_service_cb foreach_cb, /* LCOV_EXCL_START */ UA_ERR("g_malloc0 failed"); ret = UA_ERROR_OUT_OF_MEMORY; - /* LCOV_EXCL_STOP */ goto done; + /* LCOV_EXCL_STOP */ } service_info->name = g_strndup(ptr->name, UAM_SERVICE_MAX_STRING_LEN); @@ -287,8 +289,8 @@ int _ua_foreach_registered_services(ua_service_cb foreach_cb, UA_ERR("g_malloc0 failed"); ret = UA_ERROR_OUT_OF_MEMORY; _ua_free_ua_service_info_s(service_info); - /* LCOV_EXCL_STOP */ goto done; + /* LCOV_EXCL_STOP */ } service_info->isadded = true; @@ -303,8 +305,8 @@ int _ua_foreach_registered_services(ua_service_cb foreach_cb, UA_ERR("OPERATION_FAILED(0x%08x)", UA_ERROR_OPERATION_FAILED); ret = UA_ERROR_OPERATION_FAILED; - /* LCOV_EXCL_STOP */ goto done; + /* LCOV_EXCL_STOP */ } } @@ -475,6 +477,7 @@ int ua_service_remove(ua_service_h service_handle) return UA_ERROR_NONE; } +/* LCOV_EXCL_START */ int ua_service_set_name(ua_service_h service_handle, const char *name) { FUNC_ENTRY; @@ -497,6 +500,7 @@ int ua_service_set_name(ua_service_h service_handle, const char *name) FUNC_EXIT; return UA_ERROR_NONE; } +/* LCOV_EXCL_STOP */ int ua_service_set_detection_threshold(ua_service_h service_handle, unsigned int presence_threshold, unsigned int absence_threshold) @@ -623,15 +627,18 @@ int ua_get_service_by_name(const char *name, } if (l == NULL) { + /* LCOV_EXCL_START */ UA_ERR("Service [%s] is not found", name); FUNC_EXIT; return UA_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ } FUNC_EXIT; return UA_ERROR_NONE; } +/* LCOV_EXCL_START */ int ua_service_get_by_name(const char *name, ua_service_h *service_handle) { FUNC_ENTRY; @@ -663,6 +670,7 @@ int ua_service_get_by_name(const char *name, ua_service_h *service_handle) FUNC_EXIT; return UA_ERROR_NONE; } +/* LCOV_EXCL_STOP */ int ua_service_add_user(ua_service_h service_handle, ua_user_h user_handle) { @@ -731,6 +739,7 @@ int ua_service_remove_user(ua_service_h service_handle, ua_user_h user_handle) return UA_ERROR_NONE; } +/* LCOV_EXCL_START */ int ua_service_add_device(ua_service_h service_handle, ua_device_h device_handle) { FUNC_ENTRY; @@ -885,6 +894,7 @@ int ua_service_get_device_discriminant(ua_service_h service_handle, FUNC_EXIT; return UA_ERROR_NONE; } +/* LCOV_EXCL_STOP */ int ua_foreach_service(ua_service_cb foreach_cb, void *user_data) @@ -994,6 +1004,7 @@ done: return ret; } +/* LCOV_EXCL_START */ int ua_service_foreach_added_devices( ua_service_h service_handle, ua_service_added_device_cb foreach_cb, @@ -1024,7 +1035,6 @@ int ua_service_foreach_added_devices( } for (i = 0; i < devices_list->len; i++) { - /* LCOV_EXCL_START */ ptr = g_ptr_array_index(devices_list, i); if (ptr) { ua_dev_info_s* device_info; @@ -1079,7 +1089,6 @@ int ua_service_foreach_added_devices( ret = UA_ERROR_OPERATION_FAILED; goto done; } - /* LCOV_EXCL_STOP */ } done: @@ -1089,6 +1098,7 @@ done: FUNC_EXIT; return ret; } +/* LCOV_EXCL_STOP */ int ua_service_get_user_by_account(ua_service_h service_handle, const char* account, ua_user_h *user_handle) @@ -1103,8 +1113,10 @@ int ua_service_get_user_by_account(ua_service_h service_handle, *user_handle = _ua_get_user_handle_by_account(account); if (*user_handle == NULL) { + /* LCOV_EXCL_START */ UA_ERR("Failed to get user_handle for given account %s)", account); return UA_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ } /* TODO: verify if user is part of the service */ diff --git a/src/user-awareness-users.c b/src/user-awareness-users.c index 013a4d5..3422da7 100755 --- a/src/user-awareness-users.c +++ b/src/user-awareness-users.c @@ -135,31 +135,37 @@ int _ua_user_add_info_to_list_from_uapi_data(uam_user_info_s *uam_info) UA_VALIDATE_INPUT_PARAMETER(uam_info); if (NULL != _ua_get_user_from_list(uam_info->account)) { - UA_INFO("User already in list [%s]", uam_info->account); - return UA_ERROR_NONE; + UA_INFO("User already in list [%s]", uam_info->account); + return UA_ERROR_NONE; } user_info = g_malloc0(sizeof(ua_user_info_s)); if (!user_info) { + /* LCOV_EXCL_START */ UA_ERR("g_malloc0 failed"); return UA_ERROR_OUT_OF_MEMORY; + /* LCOV_EXCL_STOP */ } user_info->account = g_strdup(uam_info->account); if (user_info->account == NULL) { + /* LCOV_EXCL_START */ UA_ERR("g_malloc0 failed"); _ua_free_ua_user_info_t(user_info); return UA_ERROR_OUT_OF_MEMORY; + /* LCOV_EXCL_STOP */ } user_info->name = g_strdup(uam_info->name); if (user_info->name == NULL) { + /* LCOV_EXCL_START */ UA_ERR("g_malloc0 failed"); _ua_free_ua_user_info_t(user_info); return UA_ERROR_OUT_OF_MEMORY; + /* LCOV_EXCL_STOP */ } user_info->isadded = true; @@ -230,6 +236,7 @@ int _ua_user_add_info_to_list(ua_user_info_s* ua_info) return UA_ERROR_NONE; } +/* LCOV_EXCL_START */ int _ua_remove_user_info_from_list(char *account) { FUNC_ENTRY; @@ -264,6 +271,7 @@ int _ua_remove_user_info_from_list(char *account) FUNC_EXIT; return ret; } +/* LCOV_EXCL_STOP */ ua_user_h _ua_get_user_handle_by_account(const char *account) { @@ -272,8 +280,10 @@ ua_user_h _ua_get_user_handle_by_account(const char *account) ua_user_info_s *u; if (account == NULL) { + /* LCOV_EXCL_START */ UA_INFO("Account is NULL"); return NULL; + /* LCOV_EXCL_STOP */ } for (l = ua_users_list; l; l = g_slist_next(l)) { @@ -327,8 +337,8 @@ int _ua_intr_get_default_user(ua_user_h *user_handle) /* LCOV_EXCL_START */ UA_ERR("Failed with error: %s(0x%X)", _ua_get_error_string(ret), ret); - /* LCOV_EXCL_STOP */ goto done; + /* LCOV_EXCL_STOP */ } for (l = ua_users_list; l; l = g_slist_next(l)) { @@ -477,6 +487,7 @@ int ua_user_create(const char *account, return UA_ERROR_NONE; } +/* LCOV_EXCL_START */ int ua_user_clone(ua_user_h *cloned, ua_user_h origin) { FUNC_ENTRY; @@ -491,10 +502,8 @@ int ua_user_clone(ua_user_h *cloned, ua_user_h origin) user_dst = g_malloc0(sizeof(ua_user_info_s)); if (!user_dst) { - /* LCOV_EXCL_START */ UA_ERR("g_malloc0 failed"); return UA_ERROR_OUT_OF_MEMORY; - /* LCOV_EXCL_STOP */ } user_dst->state = user_src->state; user_dst->sensor_bitmask = user_src->sensor_bitmask; @@ -504,20 +513,16 @@ int ua_user_clone(ua_user_h *cloned, ua_user_h origin) user_dst->name = g_strdup(user_src->name); if (!user_dst->name) { - /* LCOV_EXCL_START */ g_free(user_dst); UA_ERR("g_malloc0 failed"); return UA_ERROR_OUT_OF_MEMORY; - /* LCOV_EXCL_STOP */ } user_dst->account = g_strdup(user_src->account); if (!user_dst->account) { - /* LCOV_EXCL_START */ g_free(user_dst->name); g_free(user_dst); UA_ERR("g_malloc0 failed"); return UA_ERROR_OUT_OF_MEMORY; - /* LCOV_EXCL_STOP */ } /* Add user to list of users*/ @@ -527,6 +532,7 @@ int ua_user_clone(ua_user_h *cloned, ua_user_h origin) FUNC_EXIT; return UA_ERROR_NONE; } +/* LCOV_EXCL_STOP */ int ua_user_add(ua_user_h user_handle) { @@ -597,6 +603,7 @@ int ua_user_remove(ua_user_h user_handle) return UA_ERROR_NONE; } +/* LCOV_EXCL_START */ int ua_user_get_default_user(ua_user_h *user_handle) { FUNC_ENTRY; @@ -645,16 +652,15 @@ int ua_user_set_account(ua_user_h user_handle, const char *account) UA_ERROR_INVALID_PARAMETER); if (user->account) { - /* LCOV_EXCL_START */ g_free(user->account); user->account = NULL; - /* LCOV_EXCL_STOP */ } user->account = g_strdup(account); FUNC_EXIT; return UA_ERROR_NONE; } +/* LCOV_EXCL_STOP */ int ua_user_get_account(ua_user_h user_handle, char **account) { @@ -683,6 +689,7 @@ int ua_user_get_account(ua_user_h user_handle, char **account) return UA_ERROR_NONE; } +/* LCOV_EXCL_START */ int ua_user_set_name(ua_user_h user_handle, const char *name) { FUNC_ENTRY; @@ -725,6 +732,7 @@ int ua_user_get_handle_by_account(const char* account, FUNC_EXIT; return UA_ERROR_NONE; } +/* LCOV_EXCL_STOP */ int ua_user_destroy(ua_user_h user_handle) { @@ -754,6 +762,7 @@ int ua_user_destroy(ua_user_h user_handle) return UA_ERROR_NONE; } +/* LCOV_EXCL_START */ int ua_user_foreach_added(ua_registered_user_cb foreach_cb, void *user_data) { FUNC_ENTRY; @@ -783,6 +792,7 @@ int ua_foreach_users( FUNC_EXIT; return ret; } +/* LCOV_EXCL_STOP */ int ua_user_add_device(ua_user_h user_handle, ua_device_h device_handle, ua_user_device_added_cb callback, void *user_data) @@ -807,8 +817,10 @@ int ua_user_add_device(ua_user_h user_handle, ua_device_h device_handle, user_callback = _ua_get_user_callback(UA_USER_EVENT_DEVICE_ADDED, device->type); if (user_callback && user_callback != callback) { /* For same device type, allow if same callback is registered */ + /* LCOV_EXCL_START */ UA_INFO("Different callback is registered"); return UA_ERROR_NOW_IN_PROGRESS; + /* LCOV_EXCL_STOP */ } temp_handle = device->user; @@ -909,9 +921,11 @@ int ua_user_remove_device(ua_user_h user_handle, ua_device_h device_handle) ret = _ua_get_error_code(_uam_request_remove_device(user->account, &uam_device)); if (UA_ERROR_NONE != ret) { + /* LCOV_EXCL_START */ UA_ERR("Failed with error: %s(0x%X)", _ua_get_error_string(ret), ret); return ret; + /* LCOV_EXCL_STOP */ } device->isadded = false; @@ -920,6 +934,7 @@ int ua_user_remove_device(ua_user_h user_handle, ua_device_h device_handle) return UA_ERROR_NONE; } +/* LCOV_EXCL_START */ int ua_user_remove_device_by_device_id( const char *device_id, ua_mac_type_e mac_type) { @@ -937,16 +952,15 @@ int ua_user_remove_device_by_device_id( device_id, mac_type)); if (UA_ERROR_NONE != ret) { - /* LCOV_EXCL_START */ UA_ERR("Failed with error: %s(0x%X)", _ua_get_error_string(ret), ret); - /* LCOV_EXCL_STOP */ return ret; } FUNC_EXIT; return UA_ERROR_NONE; } +/* LCOV_EXCL_STOP */ int ua_user_foreach_devices( ua_user_h user_handle, diff --git a/src/user-awareness-util.c b/src/user-awareness-util.c index acb4dc2..03c9095 100755 --- a/src/user-awareness-util.c +++ b/src/user-awareness-util.c @@ -36,8 +36,10 @@ int _ua_check_supported_feature(ua_feature_t feature, bool *supported) int ret; if (feature < UA_FEATURE_BASE || feature >= UA_FEATURE_MAX) { + /* LCOV_EXCL_START */ UA_ERR("Invalid parameter. feature [%d]", feature); return UA_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ } if (TRUE == feature_table[feature].is_check) { @@ -47,8 +49,10 @@ int _ua_check_supported_feature(ua_feature_t feature, bool *supported) ret = system_info_get_platform_bool(feature_table[feature].name, supported); if (SYSTEM_INFO_ERROR_NONE != ret) { + /* LCOV_EXCL_START */ UA_ERR("fail to get %s", feature_table[feature].name); return UA_ERROR_OPERATION_FAILED; + /* LCOV_EXCL_STOP */ } feature_table[feature].is_check = TRUE; @@ -77,6 +81,7 @@ ua_mac_type_e _to_ua_mac_type(int tech_type) } } +/* LCOV_EXCL_START */ int _ua_get_error_code(int ua_error) { switch (ua_error) { @@ -84,7 +89,6 @@ int _ua_get_error_code(int ua_error) return UA_ERROR_NONE; case UAM_ERROR_INVALID_PARAMETER: return UA_ERROR_INVALID_PARAMETER; - /* LCOV_EXCL_START */ case UAM_ERROR_RESOURCE_BUSY: return UA_ERROR_RESOURCE_BUSY; case UAM_ERROR_PERMISSION_DENIED: @@ -103,17 +107,14 @@ int _ua_get_error_code(int ua_error) return UA_ERROR_ALREADY_DONE; case UAM_ERROR_INTERNAL: return UA_ERROR_OPERATION_FAILED; - /* LCOV_EXCL_STOP */ case UAM_ERROR_NOT_FOUND: return UA_ERROR_NOT_FOUND; - /* LCOV_EXCL_START */ case UAM_ERROR_ALREADY_REGISTERED: return UA_ERROR_ALREADY_REGISTERED; case UAM_ERROR_DB_FAILED: return UA_ERROR_DB_FAILED; case UAM_ERROR_NOT_REGISTERED: return UA_ERROR_NOT_REGISTERED; - /* LCOV_EXCL_STOP */ default: return UA_ERROR_OPERATION_FAILED; } @@ -127,15 +128,12 @@ const char *_ua_get_error_string(ua_error_e err) case UA_ERROR_NONE: err_str = "UA_ERROR_NONE"; break; - /* LCOV_EXCL_START */ case UA_ERROR_NOT_PERMITTED: err_str = "UA_ERROR_NOT_PERMITTED"; break; - /* LCOV_EXCL_STOP */ case UA_ERROR_INVALID_PARAMETER: err_str = "UA_ERROR_INVALID_PARAMETER"; break; - /* LCOV_EXCL_START */ case UA_ERROR_OUT_OF_MEMORY: err_str = "UA_ERROR_OUT_OF_MEMORY"; break; @@ -169,14 +167,12 @@ const char *_ua_get_error_string(ua_error_e err) case UA_ERROR_ALREADY_DONE: err_str = "UA_ERROR_ALREADY_DONE"; break; - /* LCOV_EXCL_STOP */ case UA_ERROR_OPERATION_FAILED: err_str = "UA_ERROR_OPERATION_FAILED"; break; case UA_ERROR_NOT_FOUND: err_str = "UA_ERROR_NOT_FOUND"; break; - /* LCOV_EXCL_START */ case UA_ERROR_ALREADY_REGISTERED: err_str = "UA_ERROR_ALREADY_REGISTERED"; break; @@ -189,11 +185,11 @@ const char *_ua_get_error_string(ua_error_e err) default: err_str = "NOT Defined"; break; - /* LCOV_EXCL_STOP */ } return err_str; } +/* LCOV_EXCL_STOP */ uam_tech_type_e _ua_to_uam_tech_type(int type) { @@ -215,6 +211,7 @@ uam_tech_type_e _ua_to_uam_tech_type(int type) } } +/* LCOV_EXCL_START */ ua_sensor_type_e _ua_dev_type_to_sensor(int type) { FUNC_ENTRY; @@ -298,6 +295,7 @@ static void __ua_free_ua_sensor_info_s(gpointer data) g_free(sensor_info); FUNC_EXIT; } +/* LCOV_EXCL_STOP */ void _ua_clear_sensor_list(void) { @@ -305,6 +303,7 @@ void _ua_clear_sensor_list(void) ua_sensors_list = NULL; } +/* LCOV_EXCL_START */ static ua_sensor_info_s* __ua_allocate_ua_sensor_info() { ua_sensor_info_s *sensor_info; @@ -446,6 +445,7 @@ GSList *_ua_sensor_get_sensor_handle_list( FUNC_EXIT; return sensors; } +/* LCOV_EXCL_STOP */ int ua_sensor_get_status( ua_sensor_h sensor_handle, @@ -504,6 +504,7 @@ int ua_sensor_get_type( return UA_ERROR_NONE; } +/* LCOV_EXCL_START */ static ua_location_info_s* __ua_allocate_ua_location_info() { ua_location_info_s *location_info; @@ -655,6 +656,7 @@ static void __ua_free_ua_location_info_s(gpointer data) g_free(location_info); FUNC_EXIT; } +/* LCOV_EXCL_STOP */ void _ua_clear_location_list(void) { diff --git a/tests/unittest/tct-user-awareness-core.h b/tests/unittest/tct-user-awareness-core.h index eadeeba..22745ce 100755 --- a/tests/unittest/tct-user-awareness-core.h +++ b/tests/unittest/tct-user-awareness-core.h @@ -61,6 +61,12 @@ extern int utc_ua_monitor_start_absence_detection_p(void); extern int utc_ua_monitor_start_absence_detection_n(void); extern int utc_ua_monitor_stop_absence_detection_p(void); extern int utc_ua_monitor_stop_absence_detection_n(void); +extern int utc_ua_monitor_set_location_period_p(void); +extern int utc_ua_monitor_set_location_period_n(void); +extern int utc_ua_location_get_distance_n(void); +extern int utc_ua_location_get_position_n(void); +extern int utc_ua_monitor_start_location_detection_n(void); +extern int utc_ua_monitor_stop_location_detection_n(void); /* User Awareness User APIs */ extern int utc_ua_user_create_p(void); @@ -185,6 +191,12 @@ testcase tc_array[] = { {"utc_ua_monitor_start_absence_detection_n", utc_ua_monitor_start_absence_detection_n, utc_startup, utc_cleanup}, {"utc_ua_monitor_stop_absence_detection_p", utc_ua_monitor_stop_absence_detection_p, utc_startup, utc_cleanup}, {"utc_ua_monitor_stop_absence_detection_n", utc_ua_monitor_stop_absence_detection_n, utc_startup, utc_cleanup}, + {"utc_ua_monitor_set_location_period_p", utc_ua_monitor_set_location_period_p, utc_startup, utc_cleanup}, + {"utc_ua_monitor_set_location_period_n", utc_ua_monitor_set_location_period_n, utc_startup, utc_cleanup}, + {"utc_ua_location_get_distance_n", utc_ua_location_get_distance_n, utc_startup, utc_cleanup}, + {"utc_ua_location_get_position_n", utc_ua_location_get_position_n, utc_startup, utc_cleanup}, + {"utc_ua_monitor_start_location_detection_n", utc_ua_monitor_start_location_detection_n, utc_startup, utc_cleanup}, + {"utc_ua_monitor_stop_location_detection_n", utc_ua_monitor_stop_location_detection_n, utc_startup, utc_cleanup}, /* User Awareness User APIs */ {"utc_ua_user_create_p", utc_ua_user_create_p, utc_startup, utc_cleanup}, {"utc_ua_user_create_n", utc_ua_user_create_n, utc_startup, utc_cleanup}, diff --git a/tests/unittest/utc-user-awareness-location.c b/tests/unittest/utc-user-awareness-location.c new file mode 100755 index 0000000..228a807 --- /dev/null +++ b/tests/unittest/utc-user-awareness-location.c @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <system_info.h> +#include <glib.h> +#include <dlog.h> +#include <user-awareness.h> + +#include "utc-user-awareness-common.h" + +int utc_ua_monitor_set_location_period_p(void) +{ + int ret = UA_ERROR_NONE; + ua_monitor_h ua_mon_h = NULL; + + CHECK_INIT_RETURN(g_bInitialized); + + if (!g_bFeatureUA) { + ret = ua_monitor_set_location_period(NULL, 0); + CHECK_RETURN("ua_monitor_set_location_period", ret, UA_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = ua_monitor_create(&ua_mon_h); + CHECK_RETURN("ua_monitor_create", ret, UA_ERROR_NONE); + + ret = ua_monitor_set_location_period(ua_mon_h, 500); + CHECK_RETURN("ua_monitor_set_location_period", ret, UA_ERROR_NONE); + + ret = ua_monitor_destroy(ua_mon_h); + CHECK_RETURN("ua_monitor_destroy", ret, UA_ERROR_NONE); + + return 0; +} + +int utc_ua_monitor_set_location_period_n(void) +{ + int ret = UA_ERROR_NONE; + + CHECK_INIT_RETURN(g_bInitialized); + + ret = ua_monitor_set_location_period(NULL, 0); + if (!g_bFeatureUA) { + CHECK_RETURN("ua_monitor_set_location_period", ret, UA_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("ua_monitor_set_location_period", ret, UA_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +int utc_ua_location_get_distance_n(void) +{ + int ret = UA_ERROR_NONE; + + CHECK_INIT_RETURN(g_bInitialized); + + ret = ua_location_get_distance(NULL, NULL); + if (!g_bFeatureUA) { + CHECK_RETURN("ua_location_get_distance", ret, UA_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("ua_location_get_distance", ret, UA_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +int utc_ua_location_get_position_n(void) +{ + int ret = UA_ERROR_NONE; + + CHECK_INIT_RETURN(g_bInitialized); + + ret = ua_location_get_position(NULL, NULL, NULL, NULL); + if (!g_bFeatureUA) { + CHECK_RETURN("ua_location_get_position", ret, UA_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("ua_location_get_position", ret, UA_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +int utc_ua_monitor_start_location_detection_n(void) +{ + int ret = UA_ERROR_NONE; + + CHECK_INIT_RETURN(g_bInitialized); + + ret = ua_monitor_start_location_detection(NULL, NULL, NULL, NULL); + if (!g_bFeatureUA) { + CHECK_RETURN("ua_monitor_start_location_detection", ret, UA_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("ua_monitor_start_location_detection", ret, UA_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +int utc_ua_monitor_stop_location_detection_n(void) +{ + int ret = UA_ERROR_NONE; + + CHECK_INIT_RETURN(g_bInitialized); + + ret = ua_monitor_stop_location_detection(NULL); + if (!g_bFeatureUA) { + CHECK_RETURN("ua_monitor_stop_location_detection", ret, UA_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("ua_monitor_stop_location_detection", ret, UA_ERROR_INVALID_PARAMETER); + } + + return 0; +} |