diff options
author | Seonah Moon <seonah1.moon@samsung.com> | 2018-01-08 13:42:54 +0900 |
---|---|---|
committer | Seonah Moon <seonah1.moon@samsung.com> | 2018-01-08 13:43:31 +0900 |
commit | 9362752a471a5c892d679548fbf2828d5fc5684b (patch) | |
tree | 83c7d29a28556906938f5c2198d81e2d35f86f92 /tools | |
parent | 22633ced6225d294ce8483efbf2b39ea0c0c1b65 (diff) | |
download | connman-9362752a471a5c892d679548fbf2828d5fc5684b.tar.gz connman-9362752a471a5c892d679548fbf2828d5fc5684b.tar.bz2 connman-9362752a471a5c892d679548fbf2828d5fc5684b.zip |
Imported Upstream version 1.35upstream/1.35
Change-Id: I174854914d9fd06a813270b57d1f7bc2bac63c6a
Signed-off-by: Seonah Moon <seonah1.moon@samsung.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/iptables-unit.c | 94 | ||||
-rw-r--r-- | tools/session-test.h | 6 | ||||
-rw-r--r-- | tools/stats-tool.c | 9 |
3 files changed, 14 insertions, 95 deletions
diff --git a/tools/iptables-unit.c b/tools/iptables-unit.c index 7e427e21..426631a0 100644 --- a/tools/iptables-unit.c +++ b/tools/iptables-unit.c @@ -24,6 +24,7 @@ #endif #include <glib.h> +#include <errno.h> #include "../src/connman.h" @@ -32,6 +33,7 @@ static bool assert_rule(const char *table_name, const char *rule) char *cmd, *output, **lines; GError **error = NULL; int i; + bool ret = true; cmd = g_strdup_printf(IPTABLES_SAVE " -t %s", table_name); g_spawn_command_line_sync(cmd, &output, NULL, NULL, error); @@ -39,18 +41,20 @@ static bool assert_rule(const char *table_name, const char *rule) lines = g_strsplit(output, "\n", 0); g_free(output); + if (!lines) + return false; for (i = 0; lines[i]; i++) { DBG("lines[%02d]: %s\n", i, lines[i]); if (g_strcmp0(lines[i], rule) == 0) break; } - g_strfreev(lines); if (!lines[i]) - return false; + ret = false; - return true; + g_strfreev(lines); + return ret; } static void assert_rule_exists(const char *table_name, const char *rule) @@ -402,85 +406,6 @@ static void test_nat_basic1(void) g_free(service); } -static void test_firewall_basic0(void) -{ - struct firewall_context *ctx; - int err; - - ctx = __connman_firewall_create(); - g_assert(ctx); - - err = __connman_firewall_add_rule(ctx, "filter", "INPUT", - "-m mark --mark 999 -j LOG"); - g_assert(err == 0); - - err = __connman_firewall_enable(ctx); - g_assert(err == 0); - - assert_rule_exists("filter", ":connman-INPUT - [0:0]"); - assert_rule_exists("filter", "-A INPUT -j connman-INPUT"); - assert_rule_exists("filter", "-A connman-INPUT -m mark --mark 0x3e7 -j LOG"); - - err = __connman_firewall_disable(ctx); - g_assert(err == 0); - - assert_rule_not_exists("filter", ":connman-INPUT - [0:0]"); - assert_rule_not_exists("filter", "-A INPUT -j connman-INPUT"); - assert_rule_not_exists("filter", "-A connman-INPUT -m mark --mark 0x3e7 -j LOG"); - - __connman_firewall_destroy(ctx); -} - -static void test_firewall_basic1(void) -{ - struct firewall_context *ctx; - int err; - - ctx = __connman_firewall_create(); - g_assert(ctx); - - err = __connman_firewall_add_rule(ctx, "filter", "INPUT", - "-m mark --mark 999 -j LOG"); - g_assert(err == 0); - - err = __connman_firewall_add_rule(ctx, "filter", "OUTPUT", - "-m mark --mark 999 -j LOG"); - g_assert(err == 0); - - err = __connman_firewall_enable(ctx); - g_assert(err == 0); - - err = __connman_firewall_disable(ctx); - g_assert(err == 0); - - __connman_firewall_destroy(ctx); -} - -static void test_firewall_basic2(void) -{ - struct firewall_context *ctx; - int err; - - ctx = __connman_firewall_create(); - g_assert(ctx); - - err = __connman_firewall_add_rule(ctx, "mangle", "INPUT", - "-j CONNMARK --restore-mark"); - g_assert(err == 0); - - err = __connman_firewall_add_rule(ctx, "mangle", "POSTROUTING", - "-j CONNMARK --save-mark"); - g_assert(err == 0); - - err = __connman_firewall_enable(ctx); - g_assert(err == 0); - - err = __connman_firewall_disable(ctx); - g_assert(err == 0); - - __connman_firewall_destroy(ctx); -} - static gchar *option_debug = NULL; static bool parse_debug(const char *key, const char *value, @@ -527,7 +452,6 @@ int main(int argc, char *argv[]) "Unit Tests Connection Manager", VERSION); __connman_iptables_init(); - __connman_firewall_init(); __connman_nat_init(); g_test_add_func("/iptables/chain0", test_iptables_chain0); @@ -540,14 +464,10 @@ int main(int argc, char *argv[]) g_test_add_func("/iptables/target0", test_iptables_target0); g_test_add_func("/nat/basic0", test_nat_basic0); g_test_add_func("/nat/basic1", test_nat_basic1); - g_test_add_func("/firewall/basic0", test_firewall_basic0); - g_test_add_func("/firewall/basic1", test_firewall_basic1); - g_test_add_func("/firewall/basic2", test_firewall_basic2); err = g_test_run(); __connman_nat_cleanup(); - __connman_firewall_cleanup(); __connman_iptables_cleanup(); g_free(option_debug); diff --git a/tools/session-test.h b/tools/session-test.h index 5e6d196a..85129337 100644 --- a/tools/session-test.h +++ b/tools/session-test.h @@ -68,12 +68,6 @@ void util_session_cleanup(struct test_session *session); typedef void (* notify_func_t) (struct test_session *session); -enum connman_session_state { - CONNMAN_SESSION_STATE_DISCONNECTED = 0, - CONNMAN_SESSION_STATE_CONNECTED = 1, - CONNMAN_SESSION_STATE_ONLINE = 2, -}; - struct test_session_info { enum connman_session_state state; char *name; diff --git a/tools/stats-tool.c b/tools/stats-tool.c index 7d117fdc..efa39de2 100644 --- a/tools/stats-tool.c +++ b/tools/stats-tool.c @@ -794,7 +794,7 @@ static void swap_and_close_files(struct stats_file *history_file, munmap(history_file->addr, history_file->len); munmap(temp_file->addr, temp_file->len); - TFR(close(temp_file->fd)); + close(temp_file->fd); unlink(history_file->name); @@ -802,7 +802,7 @@ static void swap_and_close_files(struct stats_file *history_file, return; unlink(temp_file->name); - TFR(close(history_file->fd)); + close(history_file->fd); } static void history_file_update(struct stats_file *data_file, @@ -885,6 +885,11 @@ int main(int argc, char *argv[]) else start_ts = option_start_ts; + if (option_interval == 0) { + printf("interval cannot be zero, using the default value\n"); + option_interval = 3; + } + if (option_create > 0) stats_create(data_file, option_create, option_interval, start_ts, rec); |