FREE(key);
}
+//LCOV_EXCL_START
static gboolean __processes_tree_foreach_print(gpointer key, gpointer value,
gpointer data)
{
{
g_tree_foreach(g_system->apps, __apps_tree_foreach_print, NULL);
}
+//LCOV_EXCL_STOP
static gboolean __apps_tree_foreach_remove_pid(gpointer key, gpointer value,
gpointer data)
if (!g_tree_remove(app_value->processes, context->proc_key)) {
if (STC_DEBUG_LOG)
- STC_LOGD("key not found");
+ STC_LOGD("key not found"); //LCOV_EXCL_LINE
return FALSE;
}
return lookup;
}
+//LCOV_EXCL_START
static gboolean __processes_tree_check_empty(gpointer key, gpointer value,
gpointer data)
{
(*pid_count)++;
return TRUE;
}
+//LCOV_EXCL_STOP
static gboolean __add_application_monitor(gpointer key, gpointer value,
gpointer data)
struct nfacct_rule counter;
if (!stc->carg) {
- stc->carg = MALLOC0(counter_arg_s, 1);
- if (stc->carg == NULL)
- return FALSE;
+ stc->carg = MALLOC0(counter_arg_s, 1); //LCOV_EXCL_LINE
+ if (stc->carg == NULL) //LCOV_EXCL_LINE
+ return FALSE; //LCOV_EXCL_LINE
- stc->carg->sock = stc_monitor_get_counter_socket();
+ stc->carg->sock = stc_monitor_get_counter_socket(); //LCOV_EXCL_LINE
}
memset(&counter, 0, sizeof(struct nfacct_rule));
struct nfacct_rule counter;
if (!stc->carg) {
- stc->carg = MALLOC0(counter_arg_s, 1);
- if (stc->carg == NULL)
- return FALSE;
+ stc->carg = MALLOC0(counter_arg_s, 1); //LCOV_EXCL_LINE
+ if (stc->carg == NULL) //LCOV_EXCL_LINE
+ return FALSE; //LCOV_EXCL_LINE
- stc->carg->sock = stc_monitor_get_counter_socket();
+ stc->carg->sock = stc_monitor_get_counter_socket(); //LCOV_EXCL_LINE
}
memset(&counter, 0, sizeof(struct nfacct_rule));
effective_data_warn_limit -= info.data_counter;
if (effective_data_limit < 0) {
- effective_data_limit = 0;
- rstn_value->data_limit_reached = TRUE;
+ effective_data_limit = 0; //LCOV_EXCL_LINE
+ rstn_value->data_limit_reached = TRUE; //LCOV_EXCL_LINE
}
if (effective_data_warn_limit < 0)
- effective_data_warn_limit = 0;
+ effective_data_warn_limit = 0; //LCOV_EXCL_LINE
STC_LOGD("datausage [%lld] bytes", info.data_counter);
}
struct nfacct_rule counter;
stc_s *stc = stc_get_manager();
if (!stc) {
- g_free(default_ifname);
- return;
+ g_free(default_ifname); //LCOV_EXCL_LINE
+ return; //LCOV_EXCL_LINE
}
if (!stc->carg) {
- stc->carg = MALLOC0(counter_arg_s, 1);
- if (stc->carg == NULL) {
- g_free(default_ifname);
- return;
+ stc->carg = MALLOC0(counter_arg_s, 1); //LCOV_EXCL_LINE
+ if (stc->carg == NULL) { //LCOV_EXCL_LINE
+ g_free(default_ifname); //LCOV_EXCL_LINE
+ return; //LCOV_EXCL_LINE
}
- stc->carg->sock =
- stc_monitor_get_counter_socket();
+ stc->carg->sock = stc_monitor_get_counter_socket(); //LCOV_EXCL_LINE
}
counter.carg = stc->carg;
struct nfacct_rule counter;
stc_s *stc = stc_get_manager();
if (!stc) {
- g_free(default_ifname);
- return;
+ g_free(default_ifname); //LCOV_EXCL_LINE
+ return; //LCOV_EXCL_LINE
}
if (!stc->carg) {
- stc->carg = MALLOC0(counter_arg_s, 1);
- if (stc->carg == NULL) {
- g_free(default_ifname);
- return;
+ stc->carg = MALLOC0(counter_arg_s, 1); //LCOV_EXCL_LINE
+ if (stc->carg == NULL) { //LCOV_EXCL_LINE
+ g_free(default_ifname); //LCOV_EXCL_LINE
+ return; //LCOV_EXCL_LINE
}
- stc->carg->sock =
- stc_monitor_get_counter_socket();
+ stc->carg->sock = stc_monitor_get_counter_socket(); //LCOV_EXCL_LINE
}
counter.carg = stc->carg;
}
}
+//LCOV_EXCL_START
static gboolean __remove_rstns_foreach_application(gpointer key,
gpointer value,
gpointer data)
out:
return FALSE;
}
+//LCOV_EXCL_STOP
static void __remove_rstns_for_application(gchar *app_id)
{
lookup = __application_lookup(g_system->apps, app_key);
if (!lookup) {
- STC_LOGE("app_key not found");
- return STC_ERROR_NO_DATA;
+ STC_LOGE("app_key not found"); //LCOV_EXCL_LINE
+ return STC_ERROR_NO_DATA; //LCOV_EXCL_LINE
}
g_tree_foreach(lookup->processes, __processes_tree_check_empty,
}
if (!g_tree_remove(g_system->apps, app_key)) {
- ret = STC_ERROR_NO_DATA;
- STC_LOGE("key not found");
+ ret = STC_ERROR_NO_DATA; //LCOV_EXCL_LINE
+ STC_LOGE("key not found"); //LCOV_EXCL_LINE
}
return ret;
GIOCondition condition,
gpointer user_data);
+//LCOV_EXCL_START
static stc_error_e __close_and_reopen_contr_sock(stc_system_s *system)
{
GIOChannel *gio = NULL;
goto try_next_callback;
if (rstn_value->data_limit_reached == TRUE) {
- context->data_limit_reached = TRUE;
- goto try_next_callback;
+ context->data_limit_reached = TRUE; //LCOV_EXCL_LINE
+ goto try_next_callback; //LCOV_EXCL_LINE
}
classid = context->counter->classid;
try_next_callback:
return rv;
}
+//LCOV_EXCL_STOP
static gboolean __update_app_statistics(gpointer key, gpointer value,
gpointer data)
if (STC_IFACE_DATACALL == stat_key.iftype)
stat_key.subscriber_id = g_strdup(default_connection->subscriber_id);
else
- stat_key.subscriber_id = g_strdup("none_subid");
+ stat_key.subscriber_id = g_strdup("none_subid"); //LCOV_EXCL_LINE
g_strlcpy(stat_key.ifname, default_connection->ifname,
MAX_IFACE_LENGTH);
return G_SOURCE_REMOVE;
}
+//LCOV_EXCL_START
static gboolean __update_counter_statistics(gpointer key, gpointer value,
gpointer data)
{
STC_LOGI("Flushed rstns counters to database");
return G_SOURCE_REMOVE;
}
+//LCOV_EXCL_STOP
static void __app_counter_update(stc_app_key_s *app_key,
stc_app_value_s *app_value,
g_system->apps_tree_updated = TRUE;
if (STC_DEBUG_LOG)
- __apps_tree_foreach_print(app_key, app_value, NULL);
+ __apps_tree_foreach_print(app_key, app_value, NULL); //LCOV_EXCL_LINE
break;
case NFACCT_COUNTER_OUT:
app_value->data_usage.out_bytes += context->bytes;
g_system->apps_tree_updated = TRUE;
if (STC_DEBUG_LOG)
- __apps_tree_foreach_print(app_key, app_value, NULL);
+ __apps_tree_foreach_print(app_key, app_value, NULL); //LCOV_EXCL_LINE
break;
default:
- STC_LOGE("unknown iotype");
+ STC_LOGE("unknown iotype"); //LCOV_EXCL_LINE
}
}
};
if (STC_DEBUG_LOG)
- STC_LOGD("cnt_name %s", cnt_name);
+ STC_LOGD("cnt_name %s", cnt_name); //LCOV_EXCL_LINE
if (!recreate_counter_by_name(cnt_name, &counter)) {
- STC_LOGE("Can't parse counter name %s", cnt_name);
- return;
+ STC_LOGE("Can't parse counter name %s", cnt_name); //LCOV_EXCL_LINE
+ return; //LCOV_EXCL_LINE
}
STC_LOGI("classid %lu, iftype %u, iotype %d, intend %d, ifname %s, bytes %lld",
netlink_serialization_command *netlink =
netlink_create_command(&ser_params);
if (!netlink) {
- STC_LOGE("Can not create command");
- return;
+ STC_LOGE("Can not create command"); //LCOV_EXCL_LINE
+ return; //LCOV_EXCL_LINE
}
netlink->deserialize_answer(&(netlink->params));
int ret;
stc_s *stc = stc_get_manager();
+#ifdef TIZEN_GTESTS
+ void __gcov_flush(void);
+ __gcov_flush();
+#endif
+
if ((condition & G_IO_ERR) || (condition & G_IO_HUP) ||
(condition & G_IO_NVAL)) {
/* G_IO_ERR/G_IO_HUP/G_IO_NVAL received */
- STC_LOGE("Counter socket received G_IO event, closing socket."
+ STC_LOGE("Counter socket received G_IO event, closing socket." //LCOV_EXCL_LINE
"G_IO_ERR [%d], G_IO_HUP [%d], G_IO_NVAL [%s]",
(condition & G_IO_ERR), (condition & G_IO_HUP),
(condition & G_IO_NVAL));
- __close_and_reopen_contr_sock(g_system);
- return FALSE;
+ __close_and_reopen_contr_sock(g_system); //LCOV_EXCL_LINE
+ return FALSE; //LCOV_EXCL_LINE
}
ans = MALLOC0(struct genl, 1);
if (ans == NULL) {
- STC_LOGE("Failed allocate memory to genl reply message");
- return TRUE;
+ STC_LOGE("Failed allocate memory to genl reply message"); //LCOV_EXCL_LINE
+ return TRUE; //LCOV_EXCL_LINE
}
if (stc == NULL) {
- STC_LOGE("Can't get stc data");
- goto out;
+ STC_LOGE("Can't get stc data"); //LCOV_EXCL_LINE
+ goto out; //LCOV_EXCL_LINE
}
ret = read_netlink(sock, ans, sizeof(struct genl));
g_idle_add(__flush_apps_stats_to_database, NULL);
g_idle_add(__flush_rstns_counter_to_database, NULL);
out:
+
FREE(ans);
return TRUE;
}
stc->carg->sock = stc_monitor_get_counter_socket();
}
+#ifdef TIZEN_GTESTS
+ void __gcov_flush(void);
+ __gcov_flush();
+#endif
+
/* STC_LOGD("Get all counters"); */
nfacct_send_get_all(stc->carg);
return FALSE;
}
+//LCOV_EXCL_START
static gboolean __add_restriction(gpointer key, gpointer value, gpointer data)
{
stc_rstn_key_s *rstn_key = (stc_rstn_key_s *)key;
return FALSE;
}
+//LCOV_EXCL_STOP
static stc_error_e __rstn_tree_remove(stc_rstn_key_s *key)
{
lookup_value = __rstn_lookup(g_system->rstns, key);
if (!lookup_value) {
- STC_LOGE("key not found");
- return STC_ERROR_NO_DATA;
+ STC_LOGE("key not found"); //LCOV_EXCL_LINE
+ return STC_ERROR_NO_DATA; //LCOV_EXCL_LINE
}
__remove_restriction(key, lookup_value, NULL);
table_counters_delete(lookup_value->restriction_id);
if (!g_tree_remove(g_system->rstns, key)) {
- STC_LOGD("key not found");
- return STC_ERROR_NO_DATA;
+ STC_LOGD("key not found"); //LCOV_EXCL_LINE
+ return STC_ERROR_NO_DATA; //LCOV_EXCL_LINE
}
return STC_ERROR_NONE;
if (!rstn_value) {
stc_rstn_key_s *rstn_key = MALLOC0(stc_rstn_key_s, 1);
if (!rstn_key) {
- STC_LOGE("rstn_key allocation failed");
- return STC_ERROR_OUT_OF_MEMORY;
+ STC_LOGE("rstn_key allocation failed"); //LCOV_EXCL_LINE
+ return STC_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
}
rstn_value = MALLOC0(stc_rstn_value_s, 1);
if (!rstn_value) {
- STC_LOGE("rstn_value allocation failed");
- FREE(rstn_key);
- return STC_ERROR_OUT_OF_MEMORY;
+ STC_LOGE("rstn_value allocation failed"); //LCOV_EXCL_LINE
+ FREE(rstn_key); //LCOV_EXCL_LINE
+ return STC_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
}
rstn_key->app_id = g_strdup(key->app_id);
return STC_ERROR_NONE;
}
+//LCOV_EXCL_START
static stc_cb_ret_e __insert_restriction_cb(const table_restrictions_info *info,
void *user_data)
{
out:
return FALSE;
}
+//LCOV_EXCL_STOP
static void __add_rstns_for_application(gchar *app_id)
{
stc_app_value_s app_value;
if (app_id == NULL)
- return;
+ return; //LCOV_EXCL_LINE
memset(&app_key, 0, sizeof(stc_app_key_s));
memset(&app_value, 0, sizeof(stc_app_value_s));
ret = vconf_get_int(key, value);
if (ret != VCONF_OK) {
- STC_LOGE("Failed to get vconfkey [%s] value", key);
- return -1;
+ STC_LOGE("Failed to get vconfkey [%s] value", key); //LCOV_EXCL_LINE
+ return -1; //LCOV_EXCL_LINE
}
return 0;
}
+//LCOV_EXCL_START
static int __vconf_set_int(const char *key, int value)
{
int ret = 0;
ret = vconf_set_int(key, value);
if (ret != VCONF_OK) {
- STC_LOGE("Failed to set vconfkey [%s] value", key);
- return -1;
+ STC_LOGE("Failed to set vconfkey [%s] value", key); //LCOV_EXCL_LINE
+ return -1; //LCOV_EXCL_LINE
}
return 0;
return STC_ERROR_NONE;
}
+//LCOV_EXCL_STOP
#if 0
static void __excn_hash_foreach_print(gpointer key, gpointer value,
}
#endif
+//LCOV_EXCL_START
static gboolean __remove_exception_app(gpointer key, gpointer value,
gpointer data)
{
return FALSE;
}
+//LCOV_EXCL_STOP
static void __remove_exception_appall(void)
{
- g_hash_table_foreach_remove(g_system->excns_hash,
+ g_hash_table_foreach_remove(g_system->excns_hash, //LCOV_EXCL_LINE
__remove_exception_app, NULL);
}
if (g_hash_table_insert(g_system->excns_hash,
g_strdup(info->process_name),
g_strdup(info->exe_type)) != TRUE)
- ret = STC_CANCEL;
+ ret = STC_CANCEL; //LCOV_EXCL_LINE
return ret;
}
/* __excn_hash_printall(); */
}
+//LCOV_EXCL_START
static gboolean __update_exceptions_app_list(void *user_data)
{
__remove_exception_appall();
return TRUE;
}
+//LCOV_EXCL_STOP
stc_error_e stc_monitor_init(void)
{
/* create netlink socket for updating kernel counters */
system->contr_sock = create_netlink(NETLINK_NETFILTER, 0);
if (system->contr_sock < 0) {
- STC_LOGE("failed to open socket");
- FREE(system);
- return STC_ERROR_FAIL;
+ STC_LOGE("failed to open socket"); //LCOV_EXCL_LINE
+ FREE(system); //LCOV_EXCL_LINE
+ return STC_ERROR_FAIL; //LCOV_EXCL_LINE
}
gio = g_io_channel_unix_new(system->contr_sock);
__update_contr_cb,
NULL);
if (g_system->contr_timer_id == 0) {
- STC_LOGE("Failed to register kernel counters update timer");
- __close_contr_sock(g_system);
- return STC_ERROR_FAIL;
+ STC_LOGE("Failed to register kernel counters update timer"); //LCOV_EXCL_LINE
+ __close_contr_sock(g_system); //LCOV_EXCL_LINE
+ return STC_ERROR_FAIL; //LCOV_EXCL_LINE
}
__vconf_get_int(VCONFKEY_STC_BACKGROUND_STATE,
lookup = __application_lookup(g_system->apps, &app_key);
if (lookup) {
- STC_LOGD("app_key already present");
- return STC_ERROR_NONE;
+ STC_LOGD("app_key already present"); //LCOV_EXCL_LINE
+ return STC_ERROR_NONE; //LCOV_EXCL_LINE
}
key = MALLOC0(stc_app_key_s, 1);
if (!key) {
- STC_LOGE("key allocation failed");
- return STC_ERROR_OUT_OF_MEMORY;
+ STC_LOGE("key allocation failed"); //LCOV_EXCL_LINE
+ return STC_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
}
value = MALLOC0(stc_app_value_s, 1);
if (!value) {
- STC_LOGE("value allocation failed");
- FREE(key);
- return STC_ERROR_OUT_OF_MEMORY;
+ STC_LOGE("value allocation failed"); //LCOV_EXCL_LINE
+ FREE(key); //LCOV_EXCL_LINE
+ return STC_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
}
key->app_id = g_strdup(app_key.app_id);
app_lookup = __application_lookup(g_system->apps, &app_key);
if (!app_lookup) {
- STC_LOGD("app_key not found");
- return STC_ERROR_FAIL;
+ STC_LOGD("app_key not found"); //LCOV_EXCL_LINE
+ return STC_ERROR_FAIL; //LCOV_EXCL_LINE
}
proc_lookup = __process_lookup(app_lookup->processes, &proc_key);
if (proc_lookup) {
- STC_LOGD("proc_key already present");
- return STC_ERROR_NONE;
+ STC_LOGD("proc_key already present"); //LCOV_EXCL_LINE
+ return STC_ERROR_NONE; //LCOV_EXCL_LINE
}
key = MALLOC0(stc_process_key_s, 1);
if (!key) {
- STC_LOGE("key allocation failed");
- return STC_ERROR_OUT_OF_MEMORY;
+ STC_LOGE("key allocation failed"); //LCOV_EXCL_LINE
+ return STC_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
}
value = MALLOC0(stc_process_value_s, 1);
if (!value) {
- STC_LOGE("value allocation failed");
- FREE(key);
- return STC_ERROR_OUT_OF_MEMORY;
+ STC_LOGE("value allocation failed"); //LCOV_EXCL_LINE
+ FREE(key); //LCOV_EXCL_LINE
+ return STC_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
}
key->pid = proc_key.pid;
place_pids_to_net_cgroup(proc_key.pid, app_key.app_id);
if (STC_DEBUG_LOG)
- __apps_tree_printall();
+ __apps_tree_printall(); //LCOV_EXCL_LINE
return ret;
}
__application_remove_if_empty(context.app_key);
if (STC_DEBUG_LOG)
- __apps_tree_printall();
+ __apps_tree_printall(); //LCOV_EXCL_LINE
return ret;
}
+//LCOV_EXCL_START
stc_error_e stc_monitor_process_update_ground(const stc_app_key_s app_key,
const stc_process_key_s proc_key,
stc_app_state_e ground)
return ret;
}
+//LCOV_EXCL_STOP
void stc_monitor_update_rstn_by_default_connection(void *data)
{
default_connection_s *new_connection = (default_connection_s *)data;
if (old_connection.path != NULL) {
+ //LCOV_EXCL_START
if (g_system->apps)
g_tree_foreach(g_system->apps,
__remove_application_monitor,
(gpointer)&old_connection);
iptables_flush_chains();
+ //LCOV_EXCL_STOP
}
FREE(old_connection.path);
value.classid = STC_UNKNOWN_CLASSID;
if (value.classid == STC_BACKGROUND_APP_CLASSID) {
- __set_background_state(TRUE);
- __vconf_set_int(VCONFKEY_STC_BACKGROUND_STATE, g_system->background_state);
- __process_update_background();
+ __set_background_state(TRUE); //LCOV_EXCL_LINE
+ __vconf_set_int(VCONFKEY_STC_BACKGROUND_STATE, g_system->background_state); //LCOV_EXCL_LINE
+ __process_update_background(); //LCOV_EXCL_LINE
}
value.data_limit = info->data_limit;
};
if (!strcmp(key.app_id, STC_BACKGROUND_APP_ID)) {
- __set_background_state(FALSE);
- __vconf_set_int(VCONFKEY_STC_BACKGROUND_STATE, g_system->background_state);
- __process_update_background();
+ __set_background_state(FALSE); //LCOV_EXCL_LINE
+ __vconf_set_int(VCONFKEY_STC_BACKGROUND_STATE, g_system->background_state); //LCOV_EXCL_LINE
+ __process_update_background(); //LCOV_EXCL_LINE
}
ret = __rstn_tree_remove(&key);