* [LTP] [PATCH] containers/netns: added one more test case for netns_sysfs.sh
@ 2015-08-25 14:46 Matus Marhefka
2015-08-25 15:36 ` Jiri Jaburek
0 siblings, 1 reply; 2+ messages in thread
From: Matus Marhefka @ 2015-08-25 14:46 UTC (permalink / raw)
To: ltp-list
* renamed "dummy0" to "dummy_test0" to not collide with existing
interfaces
* added test case which checks that only "localhost" and "dummy"
interfaces are seen in /sys/class/net/ after mounting sysfs
in a new namespace
Signed-off-by: Matus Marhefka <mmarhefk@redhat.com>
---
testcases/kernel/containers/netns/netns_sysfs.sh | 39 +++++++++++++++++++-----
1 file changed, 31 insertions(+), 8 deletions(-)
diff --git a/testcases/kernel/containers/netns/netns_sysfs.sh b/testcases/kernel/containers/netns/netns_sysfs.sh
index c10fa36..a58495e 100755
--- a/testcases/kernel/containers/netns/netns_sysfs.sh
+++ b/testcases/kernel/containers/netns/netns_sysfs.sh
@@ -23,13 +23,14 @@
#==============================================================================
TCID="netns_sysfs"
-TST_TOTAL=2
+TST_TOTAL=3
+DUMMYDEV="dummy_test0"
. test.sh
cleanup()
{
tst_rmdir
- ip link del dummy0 2>/dev/null
+ ip link del $DUMMYDEV 2>/dev/null
kill -9 $NS_HANDLE 2>/dev/null
}
@@ -43,23 +44,45 @@ TST_CLEANUP=cleanup
ls /sys/class/net >sysfs_before
-ns_exec $NS_HANDLE ip link add dummy0 type dummy || \
+ns_exec $NS_HANDLE ip link add $DUMMYDEV type dummy || \
tst_brkm TBROK "failed to add a new dummy device"
ns_exec $NS_HANDLE mount -t sysfs none /sys 2>/dev/null
-ns_exec $NS_HANDLE test -d /sys/class/net/dummy0
+
+# TEST CASE #1
+ns_exec $NS_HANDLE test -d "/sys/class/net/$DUMMYDEV"
if [ $? -eq 0 ]; then
- tst_resm TPASS "sysfs in new namespace has dummy0 interface"
+ tst_resm TPASS "sysfs in new namespace has $DUMMYDEV interface"
+else
+ tst_resm TFAIL "sysfs in new namespace does not have $DUMMYDEV interface"
+fi
+
+
+# TEST CASE #2
+res=0
+classnet=$(ns_exec $NS_HANDLE ls /sys/class/net/)
+for d in $classnet; do
+ if [ "$d" != "lo" ]; then
+ if [ "$d" != $DUMMYDEV ]; then
+ tst_resm TINFO "sysfs in new namespace should not contain: $d"
+ res=1
+ fi
+ fi
+done
+if [ $res -eq 0 ]; then
+ tst_resm TPASS "sysfs in new namespace has only lo and $DUMMYDEV interfaces"
else
- tst_resm TFAIL "sysfs in new namespace does not have dummy0 interface"
+ tst_resm TFAIL "sysfs in new namespace has more than lo and $DUMMYDEV interfaces"
fi
+
+# TEST CASE #3
ls /sys/class/net >sysfs_after
diff sysfs_before sysfs_after
if [ $? -eq 0 ]; then
- tst_resm TPASS "sysfs not affected by a separate namespace"
+ tst_resm TPASS "main sysfs not affected by a separate namespace"
else
- tst_resm TFAIL "sysfs affected by a separate namespace"
+ tst_resm TFAIL "main sysfs affected by a separate namespace"
fi
tst_exit
--
1.8.3.1
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [LTP] [PATCH] containers/netns: added one more test case for netns_sysfs.sh
2015-08-25 14:46 [LTP] [PATCH] containers/netns: added one more test case for netns_sysfs.sh Matus Marhefka
@ 2015-08-25 15:36 ` Jiri Jaburek
0 siblings, 0 replies; 2+ messages in thread
From: Jiri Jaburek @ 2015-08-25 15:36 UTC (permalink / raw)
To: Matus Marhefka; +Cc: ltp-list
On 08/25/2015 04:46 PM, Matus Marhefka wrote:
> * renamed "dummy0" to "dummy_test0" to not collide with existing
> interfaces
> * added test case which checks that only "localhost" and "dummy"
> interfaces are seen in /sys/class/net/ after mounting sysfs
> in a new namespace
>
> Signed-off-by: Matus Marhefka <mmarhefk@redhat.com>
> ---
> testcases/kernel/containers/netns/netns_sysfs.sh | 39 +++++++++++++++++++-----
> 1 file changed, 31 insertions(+), 8 deletions(-)
>
> diff --git a/testcases/kernel/containers/netns/netns_sysfs.sh b/testcases/kernel/containers/netns/netns_sysfs.sh
> index c10fa36..a58495e 100755
> --- a/testcases/kernel/containers/netns/netns_sysfs.sh
> +++ b/testcases/kernel/containers/netns/netns_sysfs.sh
> @@ -23,13 +23,14 @@
> #==============================================================================
>
> TCID="netns_sysfs"
> -TST_TOTAL=2
> +TST_TOTAL=3
> +DUMMYDEV="dummy_test0"
> . test.sh
>
> cleanup()
> {
> tst_rmdir
> - ip link del dummy0 2>/dev/null
> + ip link del $DUMMYDEV 2>/dev/null
> kill -9 $NS_HANDLE 2>/dev/null
> }
>
> @@ -43,23 +44,45 @@ TST_CLEANUP=cleanup
> ls /sys/class/net >sysfs_before
>
>
> -ns_exec $NS_HANDLE ip link add dummy0 type dummy || \
> +ns_exec $NS_HANDLE ip link add $DUMMYDEV type dummy || \
> tst_brkm TBROK "failed to add a new dummy device"
> ns_exec $NS_HANDLE mount -t sysfs none /sys 2>/dev/null
>
> -ns_exec $NS_HANDLE test -d /sys/class/net/dummy0
> +
> +# TEST CASE #1
> +ns_exec $NS_HANDLE test -d "/sys/class/net/$DUMMYDEV"
> if [ $? -eq 0 ]; then
> - tst_resm TPASS "sysfs in new namespace has dummy0 interface"
> + tst_resm TPASS "sysfs in new namespace has $DUMMYDEV interface"
> +else
> + tst_resm TFAIL "sysfs in new namespace does not have $DUMMYDEV interface"
> +fi
> +
> +
> +# TEST CASE #2
> +res=0
> +classnet=$(ns_exec $NS_HANDLE ls /sys/class/net/)
> +for d in $classnet; do
> + if [ "$d" != "lo" ]; then
> + if [ "$d" != $DUMMYDEV ]; then
> + tst_resm TINFO "sysfs in new namespace should not contain: $d"
> + res=1
> + fi
> + fi
> +done
What about
for d in $(ns_exec $NS_HANDLE ls /sys/class/net/); do
case "$d" in
lo|$DUMMYDEV)
;;
*)
tst_resm TINFO "sysfs in new namespace should not contain: $d"
res=1
;;
esac
done
?
> +if [ $res -eq 0 ]; then
> + tst_resm TPASS "sysfs in new namespace has only lo and $DUMMYDEV interfaces"
> else
> - tst_resm TFAIL "sysfs in new namespace does not have dummy0 interface"
> + tst_resm TFAIL "sysfs in new namespace has more than lo and $DUMMYDEV interfaces"
> fi
>
> +
> +# TEST CASE #3
> ls /sys/class/net >sysfs_after
> diff sysfs_before sysfs_after
> if [ $? -eq 0 ]; then
> - tst_resm TPASS "sysfs not affected by a separate namespace"
> + tst_resm TPASS "main sysfs not affected by a separate namespace"
> else
> - tst_resm TFAIL "sysfs affected by a separate namespace"
> + tst_resm TFAIL "main sysfs affected by a separate namespace"
> fi
>
> tst_exit
>
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-08-25 15:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-25 14:46 [LTP] [PATCH] containers/netns: added one more test case for netns_sysfs.sh Matus Marhefka
2015-08-25 15:36 ` Jiri Jaburek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox