Hi,

mounting sysfs in a separate (net + mnt) namespace will cause that
inside that namespace in /sys/class/net/ we will see only network
devices local to the separated namespace including dummy device
created by the test (without mounting sysfs we would see all the devices
from main namespace). Now back in the main namespace we check that this
mount had no influence on the main namespace (ls /sys/class/net >sysfs_after).
I thought that test description says it clear.

To the namespace destroying: as NS_HANDLE is a pid of a process, which keeps
namespace alive (see ns_create.c for details), we can destroy namespace
by killing this process.

Anyway, one thing you can do before pushing the patch is to remove
kill -9 $NS_HANDLE
command from the test code, as this is done inside cleanup function.

Thanks,
Matus Marhefka


----- Original Message -----
From: "Cyril Hrubis" <chru...@suse.cz>
To: "Matus Marhefka" <mmarh...@redhat.com>
Cc: ltp-list@lists.sourceforge.net
Sent: Wednesday, August 19, 2015 3:44:38 PM
Subject: Re: [PATCH 2/2 v3] containers/netns tests rewritten

Hi!
> +cleanup()
> +{
> +     tst_rmdir
> +     ip link del dummy0 2>/dev/null
> +     kill -9 $NS_HANDLE 2>/dev/null
> +}
> +
> +tst_tmpdir
> +NS_HANDLE=$(ns_create net mnt)
> +if [ $? -eq 1 ]; then
> +     tst_resm TINFO "$NS_HANDLE"
> +     tst_brkm TBROK "unable to create a new network namespace"
> +fi
> +TST_CLEANUP=cleanup
> +ls /sys/class/net >sysfs_before
> +
> +
> +ns_exec $NS_HANDLE ip link add dummy0 type dummy || \
> +     tst_brkm TBROK "failed to add a new dummy device"
> +ns_exec $NS_HANDLE mount -t sysfs none /sys 2>/dev/null
> +kill -9 $NS_HANDLE

I'm a bit puzzled here. Why do we have to mount the sysfs in the
namespace if we aren't doing anything with it?

Also shouldn't we destroy the namespace after we save the sysfs_after?

> +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"
> +else
> +     tst_resm TFAIL "sysfs affected by a separate namespace"
> +fi
> +
> +tst_exit

Otherwise I'm ready to push these two patches (I did minor fixes in the
first one to silence compiler warnings though).

-- 
Cyril Hrubis
chru...@suse.cz

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

Reply via email to