From 132f1d6803d1714b4ff44f07e331bf62bf9f5b5f Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Mon, 13 Feb 2012 15:51:42 +0100 Subject: test-nat: Add main table tests This test makes use of the iptables check command. --- unit/test-nat.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/unit/test-nat.c b/unit/test-nat.c index 98a7b7a4..578ff3eb 100644 --- a/unit/test-nat.c +++ b/unit/test-nat.c @@ -62,6 +62,37 @@ void connman_notifier_unregister(struct connman_notifier *notifier) nat_notifier = NULL; } + +static void test_iptables_basic0(void) +{ + int err; + + err = __connman_iptables_command("-C INPUT -i session-bridge -j ACCEPT"); + g_assert(err != 0); + err = __connman_iptables_commit("filter"); + g_assert(err == 0); + + err = __connman_iptables_command("-I INPUT -i session-bridge -j ACCEPT"); + g_assert(err == 0); + err = __connman_iptables_commit("filter"); + g_assert(err == 0); + + err = __connman_iptables_command("-C INPUT -i session-bridge -j ACCEPT"); + g_assert(err == 0); + err = __connman_iptables_commit("filter"); + g_assert(err == 0); + + err = __connman_iptables_command("-D INPUT -i session-bridge -j ACCEPT"); + g_assert(err == 0); + err = __connman_iptables_commit("filter"); + g_assert(err == 0); + + err = __connman_iptables_command("-C INPUT -i session-bridge -j ACCEPT"); + g_assert(err != 0); + err = __connman_iptables_commit("filter"); + g_assert(err == 0); +} + static void test_nat_basic0(void) { int err; @@ -120,8 +151,9 @@ int main(int argc, char *argv[]) __connman_iptables_init(); __connman_nat_init(); - g_test_add_func("/basic0", test_nat_basic0); - g_test_add_func("/basic1", test_nat_basic1); + g_test_add_func("/iptables/basic0", test_iptables_basic0); + g_test_add_func("/nat/basic0", test_nat_basic0); + g_test_add_func("/nat/basic1", test_nat_basic1); err = g_test_run(); -- cgit v1.2.3