Add new testcase for testing 'iptables -R'

Signed-off-by: Cui Bixuan <cuibix...@huawei.com>
---
 testcases/network/iptables/iptables_tests.sh |   41 +++++++++++++++++++++++++-
 1 files changed, 40 insertions(+), 1 deletions(-)

diff --git a/testcases/network/iptables/iptables_tests.sh 
b/testcases/network/iptables/iptables_tests.sh
index 886475e..583fb41 100755
--- a/testcases/network/iptables/iptables_tests.sh
+++ b/testcases/network/iptables/iptables_tests.sh
@@ -22,7 +22,7 @@
 #                                     <hubertnospa...@symbio.com.tw>

 export TCID="iptables"
-export TST_TOTAL=9
+export TST_TOTAL=10

 . test.sh

@@ -454,6 +454,44 @@ test09()
        tst_resm TPASS "iptables -N/E test succeed."
 }

+test10()
+{
+       tst_resm TINFO "iptables -R test."
+       iptables -A INPUT -s 127.0.0.1 -j DROP > tst_iptables.out 2>&1
+       if [ $? -ne 0 ]; then
+               tst_resm TFAIL "iptables command failed to append new rule."
+               cat tst_iptables.out
+               return
+       fi
+
+       tst_resm TINFO "Pinging 127.0.0.1"
+       ping 127.0.0.1 -c 2 > tst_iptables.out 2>&1
+       if [ $? -eq 0 ]; then
+               tst_resm TFAIL "Ping 127.0.0.1 succeed,test failed."
+               cat tst_iptables.out
+               return
+       fi
+
+       tst_resm TINFO "Use iptable -R to reset the rule."
+       iptables -R INPUT 1 -s 127.0.0.1 -j ACCEPT > tst_iptables.out 2>&1
+       if [ $? -ne 0 ]; then
+               tst_resm TFAIL "iptables -R can't reset the rule."
+               cat tst_iptables.out
+               return
+       fi
+
+       tst_resm TINFO "Pinging 127.0.0.1 again"
+       ping 127.0.0.1 -c 2 > tst_iptables.out 2>&1
+       if [ $? -ne 0 ]; then
+               tst_resm TFAIL "Ping 127.0.0.1 failed"
+               cat tst_iptables.out
+               return
+       fi
+
+       tst_resm TPASS "iptables -R test succeed."
+}
+
+
 setup
 TST_CLEANUP=cleanup

@@ -466,5 +504,6 @@ test06
 test07
 test08
 test09
+test10

 tst_exit
-- 
1.6.0.2 .


------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to