Patch for debug mode 80/188880/2 accepted/tizen/unified/20180912.061646 accepted/tizen/unified/20180912.061738 accepted/tizen/unified/20180913.145221 submit/tizen/20180911.115509 submit/tizen/20180911.235256 submit/tizen/20180913.051211
authorSunmin Lee <sunm.lee@samsung.com>
Tue, 11 Sep 2018 09:06:59 +0000 (18:06 +0900)
committerSunmin Lee <sunm.lee@samsung.com>
Tue, 11 Sep 2018 10:21:16 +0000 (19:21 +0900)
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 <sunm.lee@samsung.com>
packaging/update-control.spec
src/plugin/CMakeLists.txt
src/plugin/plugin.c

index 834e57cd000ced587d24cb6bfc349feebba9be65..f31b9503b66205a4f8c7e27be5fc868a3c88de28 100644 (file)
@@ -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}
 
index b8426f04d1e57d29a98dfd849046c4b78ddbd366..de9f5abf3cf1a97df3d1bb82b9719f7f197444ee 100644 (file)
@@ -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}
index a68e7436a530f6cb4b1bdbf9bd8ab4f17e2abbf1..a3174370d92fdea3296be327bb46daf6ae340434 100644 (file)
 
 #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;