* [LTP] [PATCH 2/5] iptables/iptables_tests.sh: Add new testcases for iptables -c
2015-05-27 0:59 [LTP] [PATCH 1/5] iptables/iptables_tests.sh: Add test cases for iptables -L Cui Bixuan
@ 2015-05-27 1:01 ` Cui Bixuan
2015-06-09 14:01 ` Cyril Hrubis
2015-05-27 1:02 ` [LTP] [PATCH 3/5] iptables/iptables_tests.sh: Add new testcases for iptables -o Cui Bixuan
` (4 subsequent siblings)
5 siblings, 1 reply; 10+ messages in thread
From: Cui Bixuan @ 2015-05-27 1:01 UTC (permalink / raw)
To: Cui Bixuan; +Cc: ltp-list, zhanyongming, zhuyanpeng
Add new testcase for testing 'iptables -c'
Signed-off-by: Cui Bixuan <cuibixuan@huawei.com>
---
testcases/network/iptables/iptables_tests.sh | 43 +++++++++++++++++++++++++-
1 files changed, 42 insertions(+), 1 deletions(-)
diff --git a/testcases/network/iptables/iptables_tests.sh b/testcases/network/iptables/iptables_tests.sh
index f8a7981..387cdfa 100755
--- a/testcases/network/iptables/iptables_tests.sh
+++ b/testcases/network/iptables/iptables_tests.sh
@@ -22,7 +22,7 @@
# <hubertNOSPAAAM@symbio.com.tw>
export TCID="iptables"
-export TST_TOTAL=6
+export TST_TOTAL=7
. test.sh
@@ -410,6 +410,46 @@ test06()
tst_resm TPASS "iptables can log packets with limited rate."
}
+test07()
+{
+ local logcnt=0
+ tst_resm TINFO "iptables -c test."
+
+ iptables -A INPUT -s 127.0.0.1 -j DROP -c 10 500 \
+ > 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
+
+ logcnt=`iptables -L -v |grep localhost |awk '{print $2}'` \
+ > tst_iptables.out 2>&1
+ if [ $logcnt -ne 500 ]; then
+ tst_resm TFAIL "iptables -c 10 500 failed."
+ cat tst_iptables.err
+ return
+ fi
+
+ logcnt=`iptables -L -v |grep localhost |awk '{print $1}'` \
+ > tst_iptables.out 2>&1
+ if [ $logcnt -ne 10 ]; then
+ tst_resm TFAIL "iptables -c 10 500 failed."
+ cat tst_iptables.err
+ return
+ fi
+
+ tst_resm TINFO "Deleting rule."
+ iptables -D INPUT 1 > tst_iptables.out 2>&1
+ if [ $? -ne 0 ]; then
+ tst_resm TFAIL "iptables did not remove the rule."
+ cat tst_iptables.out
+ return
+ fi
+
+ tst_resm TPASS "iptables -c test succeed."
+}
+
init
TST_CLEANUP=cleanup
@@ -419,5 +459,6 @@ test03
test04
test05
test06
+test07
tst_exit
--
1.6.0.2 .
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [LTP] [PATCH 2/5] iptables/iptables_tests.sh: Add new testcases for iptables -c
2015-05-27 1:01 ` [LTP] [PATCH 2/5] iptables/iptables_tests.sh: Add new testcases for iptables -c Cui Bixuan
@ 2015-06-09 14:01 ` Cyril Hrubis
0 siblings, 0 replies; 10+ messages in thread
From: Cyril Hrubis @ 2015-06-09 14:01 UTC (permalink / raw)
To: Cui Bixuan; +Cc: zhuyanpeng, ltp-list, zhanyongming
Hi!
> +test07()
> +{
> + local logcnt=0
> + tst_resm TINFO "iptables -c test."
> +
> + iptables -A INPUT -s 127.0.0.1 -j DROP -c 10 500 \
> + > 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
> +
> + logcnt=`iptables -L -v |grep localhost |awk '{print $2}'` \
> + > tst_iptables.out 2>&1
grep can do regular expressions as well, why can't we
match this with single grep command?
i.e.
if iptables -L -v |grep -q ".*10.*500.*localhost.*"; then
PASSED
else
FAILED
fi
> + if [ $logcnt -ne 500 ]; then
> + tst_resm TFAIL "iptables -c 10 500 failed."
> + cat tst_iptables.err
^
Where is this file created?
> + return
> + fi
> +
> + logcnt=`iptables -L -v |grep localhost |awk '{print $1}'` \
> + > tst_iptables.out 2>&1
> + if [ $logcnt -ne 10 ]; then
> + tst_resm TFAIL "iptables -c 10 500 failed."
> + cat tst_iptables.err
> + return
> + fi
> +
> + tst_resm TINFO "Deleting rule."
> + iptables -D INPUT 1 > tst_iptables.out 2>&1
> + if [ $? -ne 0 ]; then
> + tst_resm TFAIL "iptables did not remove the rule."
This should rather be TBROK, but that is minor.
> + cat tst_iptables.out
> + return
> + fi
> +
> + tst_resm TPASS "iptables -c test succeed."
> +}
> +
> init
> TST_CLEANUP=cleanup
>
> @@ -419,5 +459,6 @@ test03
> test04
> test05
> test06
> +test07
>
> tst_exit
> --
> 1.6.0.2 .
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 10+ messages in thread
* [LTP] [PATCH 3/5] iptables/iptables_tests.sh: Add new testcases for iptables -o
2015-05-27 0:59 [LTP] [PATCH 1/5] iptables/iptables_tests.sh: Add test cases for iptables -L Cui Bixuan
2015-05-27 1:01 ` [LTP] [PATCH 2/5] iptables/iptables_tests.sh: Add new testcases for iptables -c Cui Bixuan
@ 2015-05-27 1:02 ` Cui Bixuan
2015-06-09 14:13 ` Cyril Hrubis
2015-06-09 14:17 ` Cyril Hrubis
2015-05-27 1:03 ` [LTP] [PATCH 4/5] iptables/iptables_tests.sh: Add new testcases for iptables -N/E Cui Bixuan
` (3 subsequent siblings)
5 siblings, 2 replies; 10+ messages in thread
From: Cui Bixuan @ 2015-05-27 1:02 UTC (permalink / raw)
To: Cui Bixuan; +Cc: ltp-list, zhanyongming, zhuyanpeng
Add new testcase for testing 'iptables -o'
Signed-off-by: Cui Bixuan <cuibixuan@huawei.com>
---
testcases/network/iptables/iptables_tests.sh | 54 +++++++++++++++++++++++++-
1 files changed, 53 insertions(+), 1 deletions(-)
diff --git a/testcases/network/iptables/iptables_tests.sh b/testcases/network/iptables/iptables_tests.sh
index 387cdfa..a464240 100755
--- a/testcases/network/iptables/iptables_tests.sh
+++ b/testcases/network/iptables/iptables_tests.sh
@@ -22,7 +22,7 @@
# <hubertNOSPAAAM@symbio.com.tw>
export TCID="iptables"
-export TST_TOTAL=7
+export TST_TOTAL=8
. test.sh
@@ -450,6 +450,57 @@ test07()
tst_resm TPASS "iptables -c test succeed."
}
+test08()
+{
+ tst_resm TINFO "Use iptables to DROP packets from particular" \
+ "network card"
+ tst_resm TINFO "Rule to block icmp from 127.0.0.1"
+
+ iptables -A OUTPUT -o lo -p icmp -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 -c 2 127.0.0.1 > tst_iptables.out 2>&1
+ if [ $? -ne 0 ]; then
+ grep "100% packet loss" tst_iptables.out > tst_iptables.err 2>&1
+ if [ $? -ne 0 ]; then
+ tst_resm TFAIL \
+ "iptables did not block packets from loopback"
+ cat tst_iptables.err
+ return
+ else
+ tst_resm TINFO "Ping 127.0.0.1 not successful."
+ fi
+ else
+ tst_resm TFAIL "iptables did not block icmp from 127.0.0.1"
+ cat tst_iptables.out
+ return
+ fi
+
+ tst_resm TINFO "Deleting icmp DROP from lo rule."
+ iptables -D OUTPUT 1 > tst_iptables.out 2>&1
+ if [ $? -ne 0 ]; then
+ tst_resm TFAIL "iptables did not remove the rule."
+ cat tst_iptables.out
+ return
+ fi
+ tst_resm TINFO "Pinging 127.0.0.1 again"
+ ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
+ if [ $? -ne 0 ]; then
+ tst_resm TFAIL "iptables blocking loopback. This is expected" \
+ "behaviour on certain distributions where" \
+ "enabling firewall drops all packets by default."
+ cat tst_iptables.out
+ return
+ fi
+ tst_resm TINFO "Ping succsess"
+ tst_resm TPASS "iptables can DROP packets from particular network card."
+}
+
init
TST_CLEANUP=cleanup
@@ -460,5 +511,6 @@ test04
test05
test06
test07
+test08
tst_exit
--
1.6.0.2 .
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [LTP] [PATCH 3/5] iptables/iptables_tests.sh: Add new testcases for iptables -o
2015-05-27 1:02 ` [LTP] [PATCH 3/5] iptables/iptables_tests.sh: Add new testcases for iptables -o Cui Bixuan
@ 2015-06-09 14:13 ` Cyril Hrubis
2015-06-09 14:17 ` Cyril Hrubis
1 sibling, 0 replies; 10+ messages in thread
From: Cyril Hrubis @ 2015-06-09 14:13 UTC (permalink / raw)
To: Cui Bixuan; +Cc: zhuyanpeng, ltp-list, zhanyongming
Hi!
> + tst_resm TINFO "Pinging 127.0.0.1"
> + ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
Why -c 2 ?
> + if [ $? -ne 0 ]; then
> + grep "100% packet loss" tst_iptables.out > tst_iptables.err 2>&1
Eh, if ping failed, non-zero is returned, no need to grep the ping
output as well.
> + if [ $? -ne 0 ]; then
> + tst_resm TFAIL \
> + "iptables did not block packets from loopback"
> + cat tst_iptables.err
> + return
> + else
> + tst_resm TINFO "Ping 127.0.0.1 not successful."
> + fi
> + else
> + tst_resm TFAIL "iptables did not block icmp from 127.0.0.1"
> + cat tst_iptables.out
> + return
> + fi
> +
> + tst_resm TINFO "Deleting icmp DROP from lo rule."
> + iptables -D OUTPUT 1 > tst_iptables.out 2>&1
> + if [ $? -ne 0 ]; then
> + tst_resm TFAIL "iptables did not remove the rule."
Again TBROK rather than TFAIL
> + cat tst_iptables.out
> + return
> + fi
> + tst_resm TINFO "Pinging 127.0.0.1 again"
> + ping -c 2 127.0.0.1 > tst_iptables.out 2>&1
> + if [ $? -ne 0 ]; then
> + tst_resm TFAIL "iptables blocking loopback. This is expected" \
> + "behaviour on certain distributions where" \
> + "enabling firewall drops all packets by default."
> + cat tst_iptables.out
> + return
> + fi
We should save and reset the iptables before the testcase and restore it
after it. Otherwise we will not get consistent results. Also the test
for working ping should be at the start of the testcase and we should
skip it with TCONF if we cannot reach localhost.
before testcase:
iptables-save > saved_iptables
iptables -F
after testcase:
iptables-restore < saved_iptables
> + tst_resm TINFO "Ping succsess"
> + tst_resm TPASS "iptables can DROP packets from particular network card."
> +}
> +
> init
> TST_CLEANUP=cleanup
>
> @@ -460,5 +511,6 @@ test04
> test05
> test06
> test07
> +test08
>
> tst_exit
> --
> 1.6.0.2 .
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [LTP] [PATCH 3/5] iptables/iptables_tests.sh: Add new testcases for iptables -o
2015-05-27 1:02 ` [LTP] [PATCH 3/5] iptables/iptables_tests.sh: Add new testcases for iptables -o Cui Bixuan
2015-06-09 14:13 ` Cyril Hrubis
@ 2015-06-09 14:17 ` Cyril Hrubis
1 sibling, 0 replies; 10+ messages in thread
From: Cyril Hrubis @ 2015-06-09 14:17 UTC (permalink / raw)
To: Cui Bixuan; +Cc: zhuyanpeng, ltp-list, zhanyongming
Hi!
> + iptables -A OUTPUT -o lo -p icmp -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
Also the indentation is inconsitent, it mixes tabs and spaces. Choose
one and use them exclusively, if there were spaces in the original file
use spaces if there were tabs use tabs.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 10+ messages in thread
* [LTP] [PATCH 4/5] iptables/iptables_tests.sh: Add new testcases for iptables -N/E
2015-05-27 0:59 [LTP] [PATCH 1/5] iptables/iptables_tests.sh: Add test cases for iptables -L Cui Bixuan
2015-05-27 1:01 ` [LTP] [PATCH 2/5] iptables/iptables_tests.sh: Add new testcases for iptables -c Cui Bixuan
2015-05-27 1:02 ` [LTP] [PATCH 3/5] iptables/iptables_tests.sh: Add new testcases for iptables -o Cui Bixuan
@ 2015-05-27 1:03 ` Cui Bixuan
2015-05-27 1:04 ` [LTP] [PATCH 5/5] iptables/iptables_tests.sh: Add new testcases for iptables -R Cui Bixuan
` (2 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Cui Bixuan @ 2015-05-27 1:03 UTC (permalink / raw)
To: Cui Bixuan; +Cc: ltp-list, zhanyongming, zhuyanpeng
Add new testcase for testing 'iptables -N/E'
Signed-off-by: Cui Bixuan <cuibixuan@huawei.com>
---
testcases/network/iptables/iptables_tests.sh | 46 +++++++++++++++++++++++++-
1 files changed, 45 insertions(+), 1 deletions(-)
diff --git a/testcases/network/iptables/iptables_tests.sh b/testcases/network/iptables/iptables_tests.sh
index a464240..a2128c2 100755
--- a/testcases/network/iptables/iptables_tests.sh
+++ b/testcases/network/iptables/iptables_tests.sh
@@ -22,7 +22,7 @@
# <hubertNOSPAAAM@symbio.com.tw>
export TCID="iptables"
-export TST_TOTAL=8
+export TST_TOTAL=9
. test.sh
@@ -501,6 +501,49 @@ test08()
tst_resm TPASS "iptables can DROP packets from particular network card."
}
+test09()
+{
+ tst_resm TINFO "iptables -N/E test."
+
+ iptables -N chains > tst_iptables.out 2>&1
+ if [ $? -ne 0 ]; then
+ tst_resm TFAIL "iptables command failed to append new chains."
+ cat tst_iptables.out
+ return
+ fi
+
+ iptables -L -v |grep chains > tst_iptables.out 2>&1
+ if [ $? -ne 0 ]; then
+ tst_resm TFAIL "iptables append new chains failed."
+ cat tst_iptables.err
+ return
+ fi
+
+ iptables -E chains newchains > tst_iptables.out 2>&1
+ if [ $? -ne 0 ]; then
+ tst_resm TFAIL "iptables command failed to change chains to" \
+ "newchains."
+ cat tst_iptables.out
+ return
+ fi
+
+ iptables -L -v |grep newchains > tst_iptables.out 2>&1
+ if [ $? -ne 0 ]; then
+ tst_resm TFAIL "iptables change chains failed."
+ cat tst_iptables.err
+ return
+ fi
+
+ iptables -X > tst_iptables.out 2>&1
+ if [ $? -ne 0 ]; then
+ tst_resm TFAIL "iptables did not remove the rule."
+ cat tst_iptables.out
+ return
+ fi
+
+ tst_resm TPASS "iptables -N/E test succeed."
+}
+
init
TST_CLEANUP=cleanup
@@ -512,5 +555,6 @@ test05
test06
test07
test08
+test09
tst_exit
--
1.6.0.2 .
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 10+ messages in thread* [LTP] [PATCH 5/5] iptables/iptables_tests.sh: Add new testcases for iptables -R
2015-05-27 0:59 [LTP] [PATCH 1/5] iptables/iptables_tests.sh: Add test cases for iptables -L Cui Bixuan
` (2 preceding siblings ...)
2015-05-27 1:03 ` [LTP] [PATCH 4/5] iptables/iptables_tests.sh: Add new testcases for iptables -N/E Cui Bixuan
@ 2015-05-27 1:04 ` Cui Bixuan
2015-06-09 13:33 ` [LTP] [PATCH 1/5] iptables/iptables_tests.sh: Add test cases for iptables -L Cyril Hrubis
2015-06-09 13:38 ` Cyril Hrubis
5 siblings, 0 replies; 10+ messages in thread
From: Cui Bixuan @ 2015-05-27 1:04 UTC (permalink / raw)
To: Cui Bixuan; +Cc: ltp-list, zhanyongming, zhuyanpeng
Add new testcase for testing 'iptables -R'
Signed-off-by: Cui Bixuan <cuibixuan@huawei.com>
---
testcases/network/iptables/iptables_tests.sh | 40 +++++++++++++++++++++++++-
1 files changed, 39 insertions(+), 1 deletions(-)
diff --git a/testcases/network/iptables/iptables_tests.sh b/testcases/network/iptables/iptables_tests.sh
index a2128c2..1f1d72c 100755
--- a/testcases/network/iptables/iptables_tests.sh
+++ b/testcases/network/iptables/iptables_tests.sh
@@ -22,7 +22,7 @@
# <hubertNOSPAAAM@symbio.com.tw>
export TCID="iptables"
-export TST_TOTAL=9
+export TST_TOTAL=10
. test.sh
@@ -544,6 +544,43 @@ 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 -c 2 127.0.0.1 > 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 -c 2 127.0.0.1 > 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."
+}
+
init
TST_CLEANUP=cleanup
@@ -556,5 +593,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
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [LTP] [PATCH 1/5] iptables/iptables_tests.sh: Add test cases for iptables -L
2015-05-27 0:59 [LTP] [PATCH 1/5] iptables/iptables_tests.sh: Add test cases for iptables -L Cui Bixuan
` (3 preceding siblings ...)
2015-05-27 1:04 ` [LTP] [PATCH 5/5] iptables/iptables_tests.sh: Add new testcases for iptables -R Cui Bixuan
@ 2015-06-09 13:33 ` Cyril Hrubis
2015-06-09 13:38 ` Cyril Hrubis
5 siblings, 0 replies; 10+ messages in thread
From: Cyril Hrubis @ 2015-06-09 13:33 UTC (permalink / raw)
To: Cui Bixuan; +Cc: zhuyanpeng, ltp-list, zhanyongming
Hi!
I would rather see these being added one test per file with some shared
code in sourced library.
If there is a simple script that executes a lot of testcases it harder
to debug and the results are binary (FAIL/PASS for a group of test)
instead of actual testcases.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [LTP] [PATCH 1/5] iptables/iptables_tests.sh: Add test cases for iptables -L
2015-05-27 0:59 [LTP] [PATCH 1/5] iptables/iptables_tests.sh: Add test cases for iptables -L Cui Bixuan
` (4 preceding siblings ...)
2015-06-09 13:33 ` [LTP] [PATCH 1/5] iptables/iptables_tests.sh: Add test cases for iptables -L Cyril Hrubis
@ 2015-06-09 13:38 ` Cyril Hrubis
5 siblings, 0 replies; 10+ messages in thread
From: Cyril Hrubis @ 2015-06-09 13:38 UTC (permalink / raw)
To: Cui Bixuan; +Cc: zhuyanpeng, ltp-list, zhanyongming
> + local cmd="iptables -L -t raw"
> + tst_resm TINFO "$cmd will list all rules in table raw."
> + $cmd > tst_iptables.out 2>&1
Why do we do this indirectly via the cmd variable?
> + if [ $? -ne 0 ]; then
> + tst_resm TFAIL "$cmd failed to list rules."
> + cat tst_iptables.out
> + return
> + else
You do return before the else so there is no need for the else branch.
> + chaincnt=$(grep -c Chain tst_iptables.out)
> + if [ $chaincnt -lt 2 ]; then
> + tst_resm TFAIL "$cmd failed to list rules."
> + cat tst_iptables.out
> + else
> + tst_resm TINFO "$cmd lists rules."
It would be better to print PASS here.
> + fi
> + fi
> +
> + local cmd="iptables -L -t security"
> + tst_resm TINFO "$cmd will list all rules in table security."
> + $cmd > tst_iptables.out 2>&1
> + if [ $? -ne 0 ]; then
> + tst_resm TFAIL "$cmd failed to list rules."
> + cat tst_iptables.out
> + return
> + else
> + chaincnt=$(grep -c Chain tst_iptables.out)
> + if [ $chaincnt -lt 3 ]; then
> + tst_resm TFAIL "$cmd failed to list rules."
> + cat tst_iptables.out
> + else
> + tst_resm TINFO "$cmd lists rules."
And to print PASS here.
> + fi
> + fi
> +
> tst_resm TPASS "iptables -L lists rules."
And remove this line.
> }
>
> --
> 1.6.0.2
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 10+ messages in thread