static char g_rule_index[MENU_DATA_SIZE] = "0";
extern stc_h g_stc;
+extern int g_thread_test;
+extern int g_thread_log;
static stc_firewall_chain_h g_fw_chain_h = NULL;
static stc_firewall_rule_h g_fw_rule_h = NULL;
static GSList *g_chain_list = NULL;
return ret;
}
-static int _test_stc_fw_lock(MManager *mm, struct menu_data *menu)
+static int __test_stc_fw_lock_thread(gpointer data)
{
int ret = STC_ERROR_NONE;
+ char *buf = (char *)data;
+ THREAD_IN;
ret = stc_firewall_lock(g_stc);
+ THREAD_OUT;
+
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to lock firewall state" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to lock firewall state" LOG_END, buf[0]);
else
- msg("Fail to lock firewall state " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to lock firewall state " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
return ret;
}
-static int _test_stc_fw_unlock(MManager *mm, struct menu_data *menu)
+static int __test_stc_fw_unlock_thread(gpointer data)
{
int ret = STC_ERROR_NONE;
+ char *buf = (char *)data;
+ THREAD_IN;
ret = stc_firewall_unlock(g_stc);
+ THREAD_OUT;
+
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to unlock firewall state" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to unlock firewall state" LOG_END, buf[0]);
else
- msg("Fail to unlock firewall state " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to unlock firewall state " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
return ret;
}
-static int _test_stc_fw_get_lock(MManager *mm, struct menu_data *menu)
+static int __test_stc_fw_get_lock_thread(gpointer data)
{
int ret = STC_ERROR_NONE;
stc_firewall_lock_e state = STC_FIREWALL_UNKNOWN;
+ char *buf = (char *)data;
+ THREAD_IN;
ret = stc_firewall_get_lock(g_stc, &state);
+ THREAD_OUT;
+
if (ret == STC_ERROR_NONE) {
- msg("Firewall lock state " LOG_CYAN "[%s]" LOG_END,
- test_stc_convert_fw_lock_to_string(state));
- msg(LOG_GREEN "Success to get firewall state" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_END "Firewall lock state " LOG_CYAN "[%s]" LOG_END,
+ buf[0], test_stc_convert_fw_lock_to_string(state));
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to get firewall state" LOG_END, buf[0]);
} else
- msg("Fail to unlock firewall state " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to unlock firewall state " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
return ret;
}
+static int _test_stc_fw_lock(MManager *mm, struct menu_data *menu)
+{
+ return test_stc_new_thread(__test_stc_fw_lock_thread);
+}
+
+static int _test_stc_fw_unlock(MManager *mm, struct menu_data *menu)
+{
+ return test_stc_new_thread(__test_stc_fw_unlock_thread);
+}
+
+static int _test_stc_fw_get_lock(MManager *mm, struct menu_data *menu)
+{
+ return test_stc_new_thread(__test_stc_fw_get_lock_thread);
+}
+
static struct menu_data menu_firewall_rule_add[] = {
{ "1", "Chain", NULL, NULL, g_rule_chain},
{ "2", "Direction(0.None/1.IN/2.OUT)", NULL, NULL, g_rule_direction},
extern stc_h g_stc;
extern stc_h g_stc_sub;
+extern int g_thread_test;
+extern int g_thread_log;
static stc_restriction_rule_h g_restriction_rule_h = NULL;
static stc_restriction_list_h g_restriction_list_h = NULL;
static int g_restriction_rule_index = 0;
msg(HR_SINGLE);
}
-static int __test_stc_set_restriction_rule(MManager *mm, struct menu_data *menu)
+static int __test_stc_set_restriction_rule_thread(gpointer data)
{
stc_iface_type_e iface_type = (int)strtol(g_iface_type, NULL, 10);
stc_roaming_type_e roaming = (int)strtol(g_roaming, NULL, 10);
char *iface_name = NULL;
stc_restriction_type_e type = (int)strtol(g_rstn_type, NULL, 10);
int ret = STC_ERROR_NONE;
+ char *buf = (char *)data;
+ THREAD_IN;
ret = stc_restriction_rule_set_app_id(g_restriction_rule_h, g_app_id);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to set application ID" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to set application ID" LOG_END, buf[0]);
else {
- msg("Fail to set application ID " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to set application ID " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
return ret;
}
if (iface_type > STC_IFACE_UNKNOWN && iface_type <= STC_IFACE_ALL) {
+ THREAD_IN;
ret = stc_restriction_rule_set_iface_type(g_restriction_rule_h, iface_type);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to set interface type" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to set interface type" LOG_END, buf[0]);
else {
- msg("Fail to set interface type " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to set interface type " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
return ret;
}
}
+ THREAD_IN;
ret = stc_restriction_rule_set_iface_name(g_restriction_rule_h, g_iface_name);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to set interface name" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to set interface name" LOG_END, buf[0]);
else {
- msg("Fail to set interface name " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to set interface name " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
return ret;
}
if (roaming <= STC_ROAMING_ENABLED) {
+ THREAD_IN;
ret = stc_restriction_rule_set_roaming_type(g_restriction_rule_h, roaming);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to set roaming type" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to set roaming type" LOG_END, buf[0]);
else {
- msg("Fail to set roaming type " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to set roaming type " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
return ret;
}
}
+ THREAD_IN;
ret = stc_restriction_rule_set_subscriber_id(g_restriction_rule_h, g_subscriber_id);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to set subscriber ID" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to set subscriber ID" LOG_END, buf[0]);
else {
- msg("Fail to set subscriber ID " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to set subscriber ID " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
return ret;
}
if (data_limit >= 0 && data_limit < G_MAXINT64) {
+ THREAD_IN;
ret = stc_restriction_rule_set_limit(g_restriction_rule_h,
data_limit);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE) {
- msg(LOG_GREEN "Success to set limit" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to set limit" LOG_END, buf[0]);
} else {
- msg("Fail to set limit " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to set limit " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
return ret;
}
}
if (data_warn_limit >= 0 && data_warn_limit < G_MAXINT64) {
+ THREAD_IN;
ret = stc_restriction_rule_set_warning_limit(g_restriction_rule_h,
data_warn_limit);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE) {
- msg(LOG_GREEN "Success to set warning limit" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to set warning limit" LOG_END, buf[0]);
} else {
- msg("Fail to set warning limit " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to set warning limit " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
return ret;
}
}
if (monthly_limit >= 0 && monthly_limit < G_MAXINT64) {
+ THREAD_IN;
ret = stc_restriction_rule_set_monthly_limit(g_restriction_rule_h,
monthly_limit);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE) {
- msg(LOG_GREEN "Success to set monthly limit" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to set monthly limit" LOG_END, buf[0]);
} else {
- msg("Fail to set monthly limit " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to set monthly limit " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
return ret;
}
}
if (weekly_limit >= 0 && weekly_limit < G_MAXINT64) {
+ THREAD_IN;
ret = stc_restriction_rule_set_weekly_limit(g_restriction_rule_h,
weekly_limit);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE) {
- msg(LOG_GREEN "Success to set weekly limit" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to set weekly limit" LOG_END, buf[0]);
} else {
- msg("Fail to set weekly limit " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to set weekly limit " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
return ret;
}
}
if (daily_limit >= 0 && daily_limit < G_MAXINT64) {
+ THREAD_IN;
ret = stc_restriction_rule_set_daily_limit(g_restriction_rule_h,
daily_limit);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE) {
- msg(LOG_GREEN "Success to set daily limit" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to set daily limit" LOG_END, buf[0]);
} else {
- msg("Fail to set daily limit " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to set daily limit " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
return ret;
}
}
if (month_start_date >= 0 && month_start_date < 32) {
+ THREAD_IN;
ret = stc_restriction_rule_set_month_start_date(g_restriction_rule_h,
month_start_date);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE) {
- msg(LOG_GREEN "Success to set month start date" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to set month start date" LOG_END, buf[0]);
} else {
- msg("Fail to set month start date " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to set month start date " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
return ret;
}
}
if (type > STC_RSTN_TYPE_UNKNOWN && type < STC_RSTN_TYPE_LAST_ELEM) {
+ THREAD_IN;
ret = stc_restriction_rule_set_type(g_restriction_rule_h, type);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to set type" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to set type" LOG_END, buf[0]);
else {
- msg("Fail to set type " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to set type " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
return ret;
}
}
msg(HR_SINGLE);
+ THREAD_IN;
ret = stc_restriction_rule_get_app_id(g_restriction_rule_h, &app_id);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE) {
- msg("App_id: " LOG_CYAN "[%s]" LOG_END, app_id);
+ msg(LOG_CYAN "[%c] " LOG_END "App_id: " LOG_CYAN "[%s]" LOG_END, buf[0], app_id);
g_free(app_id);
}
+ THREAD_IN;
ret = stc_restriction_rule_get_subscriber_id(g_restriction_rule_h, &subscriber_id);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE) {
- msg("Sub_id: " LOG_CYAN "[%s]" LOG_END, subscriber_id);
+ msg(LOG_CYAN "[%c] " LOG_END "Sub_id: " LOG_CYAN "[%s]" LOG_END, buf[0], subscriber_id);
g_free(subscriber_id);
}
+ THREAD_IN;
ret = stc_restriction_rule_get_iface_type(g_restriction_rule_h, &iface_type);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg("Iftype: " LOG_CYAN "[%s]" LOG_END,
- test_stc_convert_iface_type_to_string(iface_type));
+ msg(LOG_CYAN "[%c] " LOG_END "Iftype: " LOG_CYAN "[%s]" LOG_END,
+ buf[0], test_stc_convert_iface_type_to_string(iface_type));
+ THREAD_IN;
ret = stc_restriction_rule_get_iface_name(g_restriction_rule_h, &iface_name);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE) {
- msg("Ifname: " LOG_CYAN "[%s]" LOG_END, iface_name);
+ msg(LOG_CYAN "[%c] " LOG_END "Ifname: " LOG_CYAN "[%s]" LOG_END, buf[0], iface_name);
g_free(iface_name);
}
+ THREAD_IN;
ret = stc_restriction_rule_get_roaming_type(g_restriction_rule_h, &roaming);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg("Roaming: " LOG_CYAN "[%s]" LOG_END,
- test_stc_convert_roaming_to_string(roaming));
+ msg(LOG_CYAN "[%c] " LOG_END "Roaming: " LOG_CYAN "[%s]" LOG_END,
+ buf[0], test_stc_convert_roaming_to_string(roaming));
+ THREAD_IN;
ret = stc_restriction_rule_get_type(g_restriction_rule_h, &type);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg("Type: " LOG_CYAN "[%s]" LOG_END,
- test_stc_convert_rstn_type_to_string(type));
+ msg(LOG_CYAN "[%c] " LOG_END "Type: " LOG_CYAN "[%s]" LOG_END,
+ buf[0], test_stc_convert_rstn_type_to_string(type));
data_limit = 0;
+ THREAD_IN;
ret = stc_restriction_rule_get_limit(g_restriction_rule_h, &data_limit);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg("Data limit: " LOG_CYAN "[%lld]" LOG_END, data_limit);
+ msg(LOG_CYAN "[%c] " LOG_END "Data limit: " LOG_CYAN "[%lld]" LOG_END, buf[0], data_limit);
data_warn_limit = 0;
+ THREAD_IN;
ret = stc_restriction_rule_get_warning_limit(g_restriction_rule_h,
&data_warn_limit);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg("Warn limit: " LOG_CYAN "[%lld]" LOG_END, data_warn_limit);
+ msg(LOG_CYAN "[%c] " LOG_END "Warn limit: " LOG_CYAN "[%lld]" LOG_END, buf[0], data_warn_limit);
monthly_limit = 0;
+ THREAD_IN;
ret = stc_restriction_rule_get_monthly_limit(g_restriction_rule_h, &monthly_limit);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg("Monthly limit: " LOG_CYAN "[%lld]" LOG_END, monthly_limit);
+ msg(LOG_CYAN "[%c] " LOG_END "Monthly limit: " LOG_CYAN "[%lld]" LOG_END, buf[0], monthly_limit);
weekly_limit = 0;
+ THREAD_IN;
ret = stc_restriction_rule_get_weekly_limit(g_restriction_rule_h, &weekly_limit);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg("Weekly limit: " LOG_CYAN "[%lld]" LOG_END, weekly_limit);
+ msg(LOG_CYAN "[%c] " LOG_END "Weekly limit: " LOG_CYAN "[%lld]" LOG_END, buf[0], weekly_limit);
daily_limit = 0;
+ THREAD_IN;
ret = stc_restriction_rule_get_daily_limit(g_restriction_rule_h, &daily_limit);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg("Daily limit: " LOG_CYAN "[%lld]" LOG_END, daily_limit);
+ msg(LOG_CYAN "[%c] " LOG_END "Daily limit: " LOG_CYAN "[%lld]" LOG_END, buf[0], daily_limit);
month_start_date = 0;
+ THREAD_IN;
ret = stc_restriction_rule_get_month_start_date(g_restriction_rule_h, &month_start_date);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg("Month start date: " LOG_CYAN "[%d]" LOG_END, month_start_date);
+ msg(LOG_CYAN "[%c] " LOG_END "Month start date: " LOG_CYAN "[%d]" LOG_END, buf[0], month_start_date);
msg(HR_SINGLE);
return STC_ERROR_NONE;
}
-static int __test_stc_restriction_set(MManager *mm, struct menu_data *menu)
+static int __test_stc_restriction_set_thread(gpointer data)
{
int ret = STC_ERROR_NONE;
+ char *buf = (char *)data;
+ THREAD_IN;
ret = stc_set_restriction(g_stc, g_restriction_rule_h);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to set restriction" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to set restriction" LOG_END, buf[0]);
else
- msg("Fail to set restriction " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to set restriction " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
return ret;
}
-static int __test_stc_restriction_get(MManager *mm, struct menu_data *menu)
+static int __test_stc_restriction_get_thread(gpointer data)
{
int ret = STC_ERROR_NONE;
+ char *buf = (char *)data;
g_restriction_rule_index = 0;
+ THREAD_IN;
ret = stc_get_restriction(g_stc,
g_restriction_rule_h,
__test_stc_restriction_rule_cb,
NULL);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to request restriction rule" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to request restriction rule" LOG_END, buf[0]);
else
- msg("Fail to request restriction rule " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to request restriction rule " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
return ret;
}
-static int __test_stc_restriction_get_all(MManager *mm, struct menu_data *menu)
+static int __test_stc_restriction_get_all_thread(gpointer data)
{
int ret = STC_ERROR_NONE;
+ char *buf = (char *)data;
g_restriction_rule_index = 0;
+ THREAD_IN;
ret = stc_foreach_restriction(g_stc,
g_restriction_rule_h,
__test_stc_restriction_rule_cb,
NULL);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to request restriction all rule" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to request restriction all rule" LOG_END, buf[0]);
else
- msg("Fail to request restriction all rule " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to request restriction all rule " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
return ret;
}
-static int __test_stc_restriction_get_type(MManager *mm, struct menu_data *menu)
+static int __test_stc_restriction_get_type_thread(gpointer data)
{
int ret = STC_ERROR_NONE;
stc_restriction_type_e rstn_type;
+ char *buf = (char *)data;
+ THREAD_IN;
ret = stc_get_restriction_type(g_stc, g_restriction_rule_h, &rstn_type);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE) {
- msg("Restriction type " LOG_CYAN "[%s]" LOG_END,
- test_stc_convert_rstn_type_to_string(rstn_type));
- msg(LOG_GREEN "Success to get restriction type" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_END "Restriction type " LOG_CYAN "[%s]" LOG_END,
+ buf[0], test_stc_convert_rstn_type_to_string(rstn_type));
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to get restriction type" LOG_END, buf[0]);
} else
- msg("Fail to get restriction type " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to get restriction type " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
return ret;
}
-static int __test_stc_restriction_unset(MManager *mm, struct menu_data *menu)
+static int __test_stc_restriction_unset_thread(gpointer data)
{
int ret = STC_ERROR_NONE;
+ char *buf = (char *)data;
+ THREAD_IN;
ret = stc_unset_restriction(g_stc,
g_restriction_rule_h);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to unset restriction" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to unset restriction" LOG_END, buf[0]);
else
- msg("Fail to unset restriction " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to unset restriction " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
return ret;
}
+static int __test_stc_set_restriction_rule(MManager *mm, struct menu_data *menu)
+{
+ return test_stc_new_thread(__test_stc_set_restriction_rule_thread);
+}
+
+static int __test_stc_restriction_get(MManager *mm, struct menu_data *menu)
+{
+ return test_stc_new_thread(__test_stc_restriction_get_thread);
+}
+
+static int __test_stc_restriction_get_all(MManager *mm, struct menu_data *menu)
+{
+ return test_stc_new_thread(__test_stc_restriction_get_all_thread);
+}
+
+static int __test_stc_restriction_get_type(MManager *mm, struct menu_data *menu)
+{
+ return test_stc_new_thread(__test_stc_restriction_get_type_thread);
+}
+
+static int __test_stc_restriction_set(MManager *mm, struct menu_data *menu)
+{
+ return test_stc_new_thread(__test_stc_restriction_set_thread);
+}
+
+static int __test_stc_restriction_unset(MManager *mm, struct menu_data *menu)
+{
+ return test_stc_new_thread(__test_stc_restriction_unset_thread);
+}
+
int test_stc_restriction_rule_create(void)
{
int ret = stc_restriction_rule_create(g_stc, &g_restriction_rule_h);
static char g_stats_time_period[MENU_DATA_SIZE] = "0";
extern stc_h g_stc;
+extern int g_thread_test;
+extern int g_thread_log;
static stc_reset_rule_h g_reset_rule = NULL;
static stc_stats_rule_h g_stats_rule = NULL;
return;
}
-static int __test_stc_set_reset_rule(MManager *mm, struct menu_data *menu)
+static int __test_stc_stats_reset_rule_thread(gpointer data)
{
int ret = STC_ERROR_NONE;
stc_iface_type_e iface_type = (int)strtol(g_reset_iface_type, NULL, 10);
char *app_id = NULL;
char *subscriber_id = NULL;
+ char *buf = (char *)data;
+ THREAD_IN;
ret = stc_reset_rule_set_app_id(g_reset_rule, g_reset_app_id);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to set application ID" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to set application ID" LOG_END, buf[0]);
else {
- msg("Fail to set application ID " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to set application ID " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
+ g_free(buf);
return ret;
}
+ THREAD_IN;
ret = stc_reset_rule_set_subscriber_id(g_reset_rule, g_reset_subscriber_id);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to set subscriber ID" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to set subscriber ID" LOG_END, buf[0]);
else {
- msg("Fail to set subscriber ID " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to set subscriber ID " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
+ g_free(buf);
return ret;
}
if (iface_type > STC_IFACE_UNKNOWN && iface_type <= STC_IFACE_ALL) {
+ THREAD_IN;
ret = stc_reset_rule_set_iface_type(g_reset_rule, iface_type);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to set interface type" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to set interface type" LOG_END, buf[0]);
else {
- msg("Fail to set interface type " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to set interface type " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
+ g_free(buf);
return ret;
}
}
msg(HR_SINGLE);
+ THREAD_IN;
ret = stc_reset_rule_get_app_id(g_reset_rule, &app_id);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE) {
- msg("App_id: " LOG_CYAN "[%s]" LOG_END, app_id);
+ msg(LOG_CYAN "[%c] " LOG_END "App_id: " LOG_CYAN "[%s]" LOG_END, buf[0], app_id);
g_free(app_id);
}
+ THREAD_IN;
ret = stc_reset_rule_get_subscriber_id(g_reset_rule, &subscriber_id);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE) {
- msg("Sub_id: " LOG_CYAN "[%s]" LOG_END, subscriber_id);
+ msg(LOG_CYAN "[%c] " LOG_END "Sub_id: " LOG_CYAN "[%s]" LOG_END, buf[0], subscriber_id);
g_free(subscriber_id);
}
+ THREAD_IN;
ret = stc_reset_rule_get_iface_type(g_reset_rule, &iface_type);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg("Iftype: " LOG_CYAN "[%s]" LOG_END,
- test_stc_convert_iface_type_to_string(iface_type));
+ msg(LOG_CYAN "[%c] " LOG_END "Iftype: " LOG_CYAN "[%s]" LOG_END,
+ buf[0], test_stc_convert_iface_type_to_string(iface_type));
msg(HR_SINGLE);
+ g_free(buf);
return STC_ERROR_NONE;
}
-static int __test_stc_stats_reset(MManager *mm, struct menu_data *menu)
+static int __test_stc_stats_reset_thread(gpointer data)
{
int ret = STC_ERROR_NONE;
time_t from = 0;
time_t to = 0;
+ char *buf = (char *)data;
from = __test_stc_make_time(2000, 1, 1, 1, 1);
time(&to);
+
+ THREAD_IN;
ret = stc_reset_rule_set_time_interval(g_reset_rule, from, to);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to set time interval" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to set time interval" LOG_END, buf[0]);
else
- msg("Fail to set time interval " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to set time interval " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
+ THREAD_IN;
ret = stc_reset_stats(g_stc, g_reset_rule);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to reset stats" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to reset stats" LOG_END, buf[0]);
else
- msg("Fail to reset stats " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to reset stats " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
return ret;
}
-static int __test_stc_set_stats_rule(MManager *mm, struct menu_data *menu)
+static int __test_stc_stats_set_rule_thread(gpointer data)
{
int ret = STC_ERROR_NONE;
stc_iface_type_e iface_type = (int)strtol(g_stats_iface_type, NULL, 10);
int time_period = (int)strtol(g_stats_time_period, NULL, 10);
char *app_id = NULL;
stc_time_period_e tm_period = STC_CONN_PERIOD_UNKNOWN;
+ char *buf = (char *)data;
+ THREAD_IN;
ret = stc_stats_rule_set_app_id(g_stats_rule, g_stats_app_id);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to set application ID" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to set application ID" LOG_END, buf[0]);
else {
- msg("Fail to set application ID " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to set application ID " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
+ g_free(buf);
return ret;
}
if (iface_type > STC_IFACE_UNKNOWN && iface_type <= STC_IFACE_ALL) {
+ THREAD_IN;
ret = stc_stats_rule_set_iface_type(g_stats_rule, iface_type);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to set interface type" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to set interface type" LOG_END, buf[0]);
else {
- msg("Fail to set interface type " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to set interface type " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
+ g_free(buf);
return ret;
}
}
default:
break;
}
+ THREAD_IN;
ret = stc_stats_rule_set_time_period(g_stats_rule, tm_period);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to set time period" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to set time period" LOG_END, buf[0]);
else {
- msg("Fail to set time period " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to set time period " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
+ g_free(buf);
return ret;
}
}
msg(HR_SINGLE);
+ THREAD_IN;
ret = stc_stats_rule_get_app_id(g_stats_rule, &app_id);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE) {
- msg("App_id: " LOG_CYAN "[%s]" LOG_END, app_id);
+ msg(LOG_CYAN "[%c] " LOG_END "App_id: " LOG_CYAN "[%s]" LOG_END, buf[0], app_id);
g_free(app_id);
}
+ THREAD_IN;
ret = stc_stats_rule_get_iface_type(g_stats_rule, &iface_type);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg("Iftype: " LOG_CYAN "[%s]" LOG_END,
- test_stc_convert_iface_type_to_string(iface_type));
+ msg(LOG_CYAN "[%c] " LOG_END "Iftype: " LOG_CYAN "[%s]" LOG_END,
+ buf[0], test_stc_convert_iface_type_to_string(iface_type));
+ THREAD_IN;
ret = stc_stats_rule_get_time_period(g_stats_rule, &tm_period);
+ THREAD_OUT;
if (ret == STC_ERROR_NONE)
- msg("Time period: " LOG_CYAN "[%s]" LOG_END,
- test_stc_convert_time_period_to_string(tm_period));
+ msg(LOG_CYAN "[%c] " LOG_END "Time period: " LOG_CYAN "[%s]" LOG_END,
+ buf[0], test_stc_convert_time_period_to_string(tm_period));
msg(HR_SINGLE);
+ g_free(buf);
return STC_ERROR_NONE;
}
-static int __test_stc_stats_get(MManager *mm, struct menu_data *menu)
+static int __test_stc_stats_get_thread(gpointer data)
{
int ret = STC_ERROR_NONE;
time_t from = 0;
time_t to = 0;
+ char *buf = (char *)data;
+
+ THREAD_IN;
from = __test_stc_make_time(2000, 1, 1, 1, 1);
time(&to);
ret = stc_stats_rule_set_time_interval(g_stats_rule, from, to);
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to set time interval" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to set time interval" LOG_END, buf[0]);
else
- msg("Fail to set time interval " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to set time interval " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
ret = stc_get_stats(g_stc,
g_stats_rule,
__test_stc_stats_info_cb,
NULL);
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to request stats info" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to request stats info" LOG_END, buf[0]);
else
- msg("Fail to request stats info " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to request stats info " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
+
+ THREAD_OUT;
+ g_free(buf);
return ret;
}
-static int __test_stc_stats_get_all(MManager *mm, struct menu_data *menu)
+static int __test_stc_stats_get_all_thread(gpointer data)
{
int ret = STC_ERROR_NONE;
time_t from = 0;
time_t to = 0;
+ char *buf = (char *)data;
+
+ THREAD_IN;
from = __test_stc_make_time(2000, 1, 1, 1, 1);
time(&to);
ret = stc_stats_rule_set_time_interval(g_stats_rule, from, to);
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to set time interval" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to set time interval" LOG_END, buf[0]);
else
- msg("Fail to set time interval " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to set time interval " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
ret = stc_get_all_stats(g_stc,
g_stats_rule,
__test_stc_get_stats_finished_cb,
NULL);
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to request stats all info" LOG_END);
+ msg(LOG_CYAN "[%c] " LOG_GREEN "Success to request stats all info" LOG_END, buf[0]);
else
- msg("Fail to request stats all info " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+ msg(LOG_CYAN "[%c] " LOG_END "Fail to request stats all info " LOG_RED "[%s]" LOG_END,
+ buf[0], test_stc_convert_error_type_to_string(ret));
+
+ THREAD_OUT;
+ g_free(buf);
return ret;
}
-static int __test_stc_stats_get_total(MManager *mm, struct menu_data *menu)
+static int __test_stc_set_reset_rule(MManager *mm, struct menu_data *menu)
{
- int ret = STC_ERROR_NONE;
- time_t from = 0;
- time_t to = 0;
+ return test_stc_new_thread(__test_stc_stats_reset_rule_thread);
+}
- from = __test_stc_make_time(2000, 1, 1, 1, 1);
- time(&to);
- ret = stc_stats_rule_set_time_interval(g_stats_rule, from, to);
- if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to set time interval" LOG_END);
- else
- msg("Fail to set time interval " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+static int __test_stc_stats_reset(MManager *mm, struct menu_data *menu)
+{
+ return test_stc_new_thread(__test_stc_stats_reset_thread);
+}
- ret = stc_get_total_stats(g_stc,
- g_stats_rule,
- __test_stc_stats_info_cb,
- NULL);
- if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to request stats total info" LOG_END);
- else
- msg("Fail to request stats total info " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
+static int __test_stc_set_stats_rule(MManager *mm, struct menu_data *menu)
+{
+ return test_stc_new_thread(__test_stc_stats_set_rule_thread);
+}
- return ret;
+static int __test_stc_stats_get(MManager *mm, struct menu_data *menu)
+{
+ return test_stc_new_thread(__test_stc_stats_get_thread);
+}
+
+static int __test_stc_stats_get_all(MManager *mm, struct menu_data *menu)
+{
+ return test_stc_new_thread(__test_stc_stats_get_all_thread);
}
int test_stc_reset_rule_create(void)
{ "1", LOG_LIGHTMAGENTA "[Set]" LOG_END " stats rule", menu_stats_rule, NULL, NULL},
{ "2", LOG_LIGHTBLUE "[Get]" LOG_END " stats", NULL, __test_stc_stats_get, NULL},
{ "3", LOG_LIGHTBLUE "[Get]" LOG_END " all stats", NULL, __test_stc_stats_get_all, NULL},
- { "4", LOG_LIGHTBLUE "[Get]" LOG_END " total stats", NULL, __test_stc_stats_get_total, NULL},
{ NULL, NULL, },
};
#define RET_SUCCESS 0
#define RET_FAILURE -1
+#define THREAD_IN \
+ do { \
+ if (g_thread_log) \
+ msg(LOG_CYAN "[%s]" LOG_END "+", buf); \
+ } while (0)
+
+#define THREAD_OUT \
+ do { \
+ if (g_thread_log) \
+ msg(LOG_CYAN "[%s]" LOG_END "-", buf); \
+ } while (0)
+
typedef struct menu_manager MManager;
struct menu_data {
#define STC_IFNAME_LEN 16
#define STC_SUBSCRIBER_ID_LEN 128
+static char g_multi_thread_test[MENU_DATA_SIZE] = "0";
+static char g_multi_thread_log[MENU_DATA_SIZE] = "0";
+
extern struct menu_data menu_statistics[];
extern struct menu_data menu_restriction[];
extern struct menu_data menu_firewall[];
stc_h g_stc = NULL;
stc_h g_stc_sub = NULL;
+GThread *g_stc_thread[5];
+int g_thread_test = 0;
+int g_thread_log = 0;
const char *test_stc_convert_error_type_to_string(stc_error_e err)
{
}
}
+int test_stc_new_thread(thread_func func)
+{
+ int i = 0;
+
+ if (g_thread_test) {
+ for (i = 0; i < 5; i++) {
+ char buf[16];
+ snprintf(buf, sizeof(buf), "%d_%s", i, "thread");
+ g_stc_thread[i] = g_thread_new(buf, (void *)func, g_strdup(buf));
+ }
+ } else {
+ char buf[2] = { '0', '\0' };
+ return func(g_strdup(buf));
+ }
+
+ return STC_ERROR_NONE;
+}
+
+static int __test_stc_set_multi_thread(MManager *mm, struct menu_data *menu)
+{
+ g_thread_test = (int)strtol(g_multi_thread_test, NULL, 10);
+ g_thread_log = (int)strtol(g_multi_thread_log, NULL, 10);
+
+ msg("Multi-thread : Test [%d] Log [%d]", g_thread_test, g_thread_log);
+
+ return STC_ERROR_NONE;
+}
+
+static struct menu_data menu_multi_thread[] = {
+ { "1", "[Test] multi-thread (0.Deactivation/1.Activation)", NULL, NULL, g_multi_thread_test},
+ { "2", "[Log] multi-thread (0.Deactivation/1.Activation)", NULL, NULL, g_multi_thread_log},
+ { "s", LOG_LIGHTMAGENTA "[Set]" LOG_END, NULL, __test_stc_set_multi_thread, NULL},
+ { NULL, NULL, },
+};
+
static struct menu_data menu_main[] = {
+ { "0", "[Multi-thread]" LOG_END, menu_multi_thread, NULL, NULL},
{ "1", LOG_LIGHTBLUE "[Statistics]" LOG_END, menu_statistics, NULL, NULL},
{ "2", LOG_LIGHTMAGENTA "[Restriction]" LOG_END, menu_restriction, NULL, NULL},
{ "3", LOG_LIGHTMAGENTA "[Firewall]" LOG_END, menu_firewall, NULL, NULL},
} \
} while (0)
+typedef int (*thread_func)(gpointer);
+
const char *test_stc_convert_error_type_to_string(stc_error_e err);
const char *test_stc_convert_iface_type_to_string(stc_iface_type_e type);
const char *test_stc_convert_roaming_to_string(stc_roaming_type_e type);
const char *test_stc_convert_fw_rule_target_to_string(
stc_firewall_rule_target_e target);
+int test_stc_new_thread(thread_func func);