From 04fc17182365d0c250bc379803136b13920a4289 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Fri, 11 Sep 2020 12:11:53 +0900 Subject: [PATCH] enable gcov 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 --- packaging/enlightenment.spec | 6 ++++++ src/bin/e_info_client.c | 35 +++++++++++++++++++++++++++++++++++ src/bin/e_info_server.c | 20 ++++++++++++++++++++ src/bin/e_main.c | 4 ++++ src/bin/e_main.h | 5 +++++ 5 files changed, 70 insertions(+) diff --git a/packaging/enlightenment.spec b/packaging/enlightenment.spec index c936a7bb95..731bb7550c 100644 --- a/packaging/enlightenment.spec +++ b/packaging/enlightenment.spec @@ -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 \ diff --git a/src/bin/e_info_client.c b/src/bin/e_info_client.c index 5fc10c9f34..b8887be5bf 100644 --- a/src/bin/e_info_client.c +++ b/src/bin/e_info_client.c @@ -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[] = diff --git a/src/bin/e_info_server.c b/src/bin/e_info_server.c index d47f74c6b3..71112184b6 100644 --- a/src/bin/e_info_server.c +++ b/src/bin/e_info_server.c @@ -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 } }; diff --git a/src/bin/e_main.c b/src/bin/e_main.c index e8f94be1f6..6c4ab3d658 100644 --- a/src/bin/e_main.c +++ b/src/bin/e_main.c @@ -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); diff --git a/src/bin/e_main.h b/src/bin/e_main.h index c590874516..fa4fe7ac7e 100644 --- a/src/bin/e_main.h +++ b/src/bin/e_main.h @@ -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 -- 2.34.1