From: Sunmin Lee Date: Tue, 11 Sep 2018 09:06:59 +0000 (+0900) Subject: Patch for debug mode X-Git-Tag: submit/tizen/20180911.115509^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8f42e8c98d3cc88bf745b8516316ef04f3231a02;p=platform%2Fcore%2Fsystem%2Fupdate-control.git Patch for debug mode Debug mode is for test without actual actions which is not proper during automated test: such as downloading, rebooting. Change-Id: I480878b4ba37ca14f279c82ef67bdd0f9c81649c Signed-off-by: Sunmin Lee --- diff --git a/packaging/update-control.spec b/packaging/update-control.spec index 834e57c..f31b950 100644 --- a/packaging/update-control.spec +++ b/packaging/update-control.spec @@ -43,7 +43,8 @@ cp %{SOURCE1001} . MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` %cmake . -DMAJORVER=${MAJORVER} \ - -DFULLVER=%{version} + -DFULLVER=%{version} \ + -DDEBUG_MODE=on %__make %{?jobs:-j%jobs} diff --git a/src/plugin/CMakeLists.txt b/src/plugin/CMakeLists.txt index b8426f0..de9f5ab 100644 --- a/src/plugin/CMakeLists.txt +++ b/src/plugin/CMakeLists.txt @@ -33,6 +33,10 @@ ENDFOREACH(flag) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -fvisibility=hidden") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") +IF(DEBUG_MODE STREQUAL on) + ADD_DEFINITIONS(-DDEBUG_MODE) +ENDIF() + ADD_LIBRARY(${fw_name} SHARED ${SOURCES}) TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS}) SET_TARGET_PROPERTIES(${fw_name} diff --git a/src/plugin/plugin.c b/src/plugin/plugin.c index a68e743..a317437 100644 --- a/src/plugin/plugin.c +++ b/src/plugin/plugin.c @@ -49,6 +49,10 @@ #define FIRMWARE_FILE_NAME "delta.tar.gz" +#ifdef DEBUG_MODE +#define DEBUG_FLAG "/opt/etc/.debugupdate" +#endif + static struct _cloud_account { const char *access_token; const char *user_id; @@ -69,6 +73,10 @@ static bool package_downloaded = false; static alarm_id_t polling_alarm_id = -1; #endif // SET_POLLING +#ifdef DEBUG_MODE +static bool debug_mode = false; +#endif + static void message_port_cb(int local_port_id, const char *remote_app_id, const char *remote_port, @@ -411,6 +419,17 @@ exit: API int update_control_initialize(void) { + _D("FN CALLED>>>>>>>>>>>>>>>>>>"); + +#ifdef DEBUG_MODE + if (access(DEBUG_FLAG, F_OK) == 0) { + debug_mode = true; + _D("DEBUG_MODE: Calling test"); + + return UPDATE_CONTROL_ERROR_NONE; + } +#endif + update_info = (struct _update_info *)malloc(sizeof(*update_info)); update_info->new_version = NULL; update_info->package_uri = NULL; @@ -431,6 +450,15 @@ API int update_control_initialize(void) API int update_control_deinitialize(void) { + _D("FN CALLED>>>>>>>>>>>>>>>>>>"); + +#ifdef DEBUG_MODE + if (debug_mode) { + _D("DEBUG_MODE: Calling test"); + return UPDATE_CONTROL_ERROR_NONE; + } +#endif + int ret; if (update_info->new_version) @@ -461,14 +489,21 @@ API int update_control_deinitialize(void) API int update_control_check_new_version(void) { + _D("FN CALLED>>>>>>>>>>>>>>>>>>"); + +#ifdef DEBUG_MODE + if (debug_mode) { + _D("DEBUG_MODE: Calling test"); + return UPDATE_CONTROL_ERROR_NONE; + } +#endif + int ret; char *device_type = NULL; char *version = NULL; char *res_header = NULL; char *res_body = NULL; - _D("FN CALLED>>>>>>>>>>>>>>>>>>"); - retvm_if(!update_info, UPDATE_CONTROL_ERROR_SYSTEM_ERROR, "update controller not initialized"); update_info->updatable = 0; @@ -520,6 +555,12 @@ API int update_control_check_new_version(void) API int update_control_download_package(void) { _D("FN CALLED>>>>>>>>>>>>>>>>>>"); +#ifdef DEBUG_MODE + if (debug_mode) { + _D("DEBUG_MODE: Calling test"); + return UPDATE_CONTROL_ERROR_NONE; + } +#endif int ret = 0; char *download_url = NULL; @@ -561,6 +602,13 @@ API int update_control_do_update(void) { _D("FN CALLED>>>>>>>>>>>>>>>>>>"); +#ifdef DEBUG_MODE + if (debug_mode) { + _D("DEBUG_MODE: Calling test"); + return UPDATE_CONTROL_ERROR_NONE; + } +#endif + char *path = NULL; if (!package_downloaded) { @@ -590,13 +638,22 @@ API int update_control_do_update(void) API int update_control_make_reservation(struct tm *reservation_time) { - int ret; - alarm_date_t alarm_time; - alarm_entry_t *alarm_info = NULL; + _D("FN CALLED>>>>>>>>>>>>>>>>>>"); retvm_if(!reservation_time, UPDATE_CONTROL_ERROR_INVALID_PARAMETER, "reservation_time is NULL"); +#ifdef DEBUG_MODE + if (debug_mode) { + _D("DEBUG_MODE: Calling test"); + return UPDATE_CONTROL_ERROR_NONE; + } +#endif + + int ret; + alarm_date_t alarm_time; + alarm_entry_t *alarm_info = NULL; + alarm_info = alarmmgr_create_alarm(); if (alarm_info == NULL) { _E("alarmmgr_create_alarm failed"); @@ -642,6 +699,15 @@ out: API int update_control_cancel_reservation(void) { + _D("FN CALLED>>>>>>>>>>>>>>>>>>"); + +#ifdef DEBUG_MODE + if (debug_mode) { + _D("DEBUG_MODE: Calling test"); + return UPDATE_CONTROL_ERROR_NONE; + } +#endif + int ret = 0; if (reserved_update_alarm_id == -1) { @@ -662,6 +728,24 @@ API int update_control_cancel_reservation(void) API int update_control_get_property(update_control_property_e property, void **value) { _D("FN CALLED>>>>>>>>>>>>>>>>>>"); + +#ifdef DEBUG_MODE + if (debug_mode) + switch (property) { + case UPDATE_CONTROL_PROPERTY_NEW_VERSION: + case UPDATE_CONTROL_PROPERTY_PACKAGE_URI: + case UPDATE_CONTROL_PROPERTY_RESULT: + case UPDATE_CONTROL_PROPERTY_PACKAGE_SIZE: + case UPDATE_CONTROL_PROPERTY_DESCRIPTION: + case UPDATE_CONTROL_PROPERTY_UPDATE_AVAILABLE: + _D("DEBUG_MODE: Calling test"); + return UPDATE_CONTROL_ERROR_NONE; + default: + _E("Not supported property key: %d", property); + return UPDATE_CONTROL_ERROR_KEY_NOT_FOUND; + } +#endif + int *int_val; int ret = UPDATE_CONTROL_ERROR_NONE;