public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Jiri Jaburek <jjaburek@redhat.com>
To: Matus Marhefka <mmarhefk@redhat.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH] containers/netns: added one more test case for netns_sysfs.sh
Date: Tue, 25 Aug 2015 17:36:40 +0200	[thread overview]
Message-ID: <55DC8B88.3050605@redhat.com> (raw)
In-Reply-To: <1440513962-10908-1-git-send-email-mmarhefk@redhat.com>

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

      reply	other threads:[~2015-08-25 15:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55DC8B88.3050605@redhat.com \
    --to=jjaburek@redhat.com \
    --cc=ltp-list@lists.sourceforge.net \
    --cc=mmarhefk@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox