enable gcov 90/243890/1 accepted/tizen/unified/20200914.131420 submit/tizen/20200911.075444
authorJunkyeong Kim <jk0430.kim@samsung.com>
Fri, 11 Sep 2020 03:11:53 +0000 (12:11 +0900)
committerJunkyeong Kim <jk0430.kim@samsung.com>
Fri, 11 Sep 2020 03:12:20 +0000 (12:12 +0900)
execute __gcov_flush() function by e_info_client.
have to change USE_GCOV define to '1' in spec file to make gcov gcno files.

Change-Id: Idef9c6f76150c56eed98c999b361cd554ac75919
Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
packaging/enlightenment.spec
src/bin/e_info_client.c
src/bin/e_info_server.c
src/bin/e_main.c
src/bin/e_main.h

index c936a7bb95f249c9fc9ca0fd7a5d5ba5dec58248..731bb7550cc3f04919be03957fc72b0794690004 100644 (file)
@@ -1,3 +1,5 @@
+%define USE_GCOV 0
+
 Name:           enlightenment
 Version:        0.20.0
 Release:        0
@@ -89,6 +91,10 @@ export CFLAGS+=" -Wno-stringop-overflow -Wno-stringop-truncation"
 export CFLAGS+=" -fPIE -DUSE_E_APPINFO"
 export LDFLAGS+=" -pie "
 %endif
+%if "%{USE_GCOV}" == "1"
+export CFLAGS+=" -fprofile-arcs -ftest-coverage -DTIZEN_TEST_GCOV "
+export LDFLAGS+=" -lgcov "
+%endif
 %autogen \
       TIZEN_REL_VERSION="%{release}-%{TIZEN_REL_VERSION}" \
       --enable-function-trace \
index 5fc10c9f348cadc889d361ee1574d5f084521dc7..b8887be5bf31365b154ed6ba7b29e048910db2ae 100644 (file)
@@ -6144,6 +6144,35 @@ usage:
    printf("Usage: %s", USAGE_FILTER);
 }
 
+static void
+_e_info_client_proc_gcov(int argc, char **argv)
+{
+   int mode = 0;
+
+   if (argc == 3)
+     {
+        if ((argv[2][0] < '0' || argv[2][0] > '1'))
+          {
+             printf("Error: invalid argument\n");
+             return;
+          }
+
+        mode = atoi(argv[2]);
+        if (!_e_info_client_eldbus_message_with_args("gcov", NULL, "i", mode))
+          {
+             printf("_e_info_client_proc_gcov fail (%d)\n", mode);
+             return;
+          }
+     }
+   else
+     {
+        printf("Error: invalid argument\n");
+        return;
+     }
+
+   return;
+}
+
 typedef struct _ProcInfo
 {
    const char *option;
@@ -6493,6 +6522,12 @@ static ProcInfo procs_to_execute[] =
       "Get information or Enable/Disable functionality for desk group",
       _e_info_client_proc_desk_group
    },
+   {
+      "gcov",
+      NULL,
+      "execute gcov flush",
+      _e_info_client_proc_gcov
+   },
 };
 
 ProcInfo procs_to_input[] =
index d47f74c6b388bf934c5917f5aae977b26c0a6d38..71112184b6358d8f0c75ae9d7279b4997b67949b 100644 (file)
@@ -6895,6 +6895,25 @@ reply:
    return reply;
 }
 
+static Eldbus_Message *
+_e_info_server_cb_gcov(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+   int mode;
+
+   if (!eldbus_message_arguments_get(msg, "i", &mode))
+     {
+        ERR("Error getting arguments.");
+        return reply;
+     }
+
+#ifdef TIZEN_TEST_GCOV
+   __gcov_flush();
+#endif
+
+   return reply;
+}
+
 //{ "method_name", arguments_from_client, return_values_to_client, _method_cb, ELDBUS_METHOD_FLAG },
 static const Eldbus_Method methods[] = {
    { "get_window_info", NULL, ELDBUS_ARGS({"iiiiisiiiiia("VALUE_TYPE_FOR_TOPVWINS")", "array of ec"}), _e_info_server_cb_window_info_get, 0 },
@@ -6983,6 +7002,7 @@ static const Eldbus_Method methods[] = {
    { "touchgen", ELDBUS_ARGS({"iiii", "touch information"}), ELDBUS_ARGS({"s", "result message"}), _e_info_server_cb_touchgen, 0},
    { "mousegen", ELDBUS_ARGS({"iiii", "mouse information"}), ELDBUS_ARGS({"s", "result message"}), _e_info_server_cb_mousegen, 0},
    { "filter", ELDBUS_ARGS({"sis", "win_id, on(1)/off(0), filter name"}), ELDBUS_ARGS({"s", "result of request"}), _e_info_server_cb_filter, 0},
+   { "gcov", ELDBUS_ARGS({"i", "option"}), NULL, _e_info_server_cb_gcov, 0},
    { NULL, NULL, NULL, NULL, 0 }
 };
 
index e8f94be1f6991ac7ebb8c216e2e1bd5dc6989074..6c4ab3d658799e7889ec4761741185dd49c84897 100644 (file)
@@ -329,6 +329,10 @@ main(int argc, char **argv)
 # endif
 #endif
 
+#ifdef TIZEN_TEST_GCOV
+   setenv("GCOV_PREFIX", "/tmp", 1);
+#endif
+
    /* for debugging by redirecting stdout & stderr of e to a log file to tail */
    setvbuf(stdout, NULL, _IONBF, 0);
    setvbuf(stderr, NULL, _IONBF, 0);
index c590874516c08c98933140e2eed3df922f8c8808..fa4fe7ac7ed6a0ce362607c141a44e25e9783102 100644 (file)
@@ -27,5 +27,10 @@ E_API E_Main_Hook *e_main_hook_add(E_Main_Hook_Point hookpoint, E_Main_Hook_Cb f
 E_API void e_main_hook_del(E_Main_Hook *ph);
 
 E_API void e_main_hook_call(E_Main_Hook_Point hookpoint);
+
+#ifdef TIZEN_TEST_GCOV
+extern void __gcov_flush(void);
+#endif
+
 #endif
 #endif