[CRIU] [PATCH] zdtm: Delete static/proc_self test

Andrei Vagin avagin at virtuozzo.com
Thu Mar 23 17:22:23 PDT 2017


On Thu, Mar 23, 2017 at 02:20:33PM +0300, Kirill Tkhai wrote:
> This test checks, that "/proc/self/ns/net" after restore
> points to the same inode as before. I.e.:

No, it doesn't. Both readlinks are called after test_waitsig().

> 
> Before dump: /proc/self/ns/net -> net:[4026531957]
> 
> After restore:  /proc/self/ns/net -> net:[4026531957]
> 
> But it's simply wrong. We can't do any assumption about
> after-restore inode of a namespace.
> 
> So, let's kill this test.

Nack

this test checks that fd_sels points to /proc/self/ns/net.

        fd_self = open(nspath, O_RDONLY);
	...
        test_waitsig();

        if (read_fd_link(fd_self, path_orig, sizeof(path_orig))) {
	...

        fd_new = open(nspath, O_RDONLY);
        if (read_fd_link(fd_new, path_new, sizeof(path_new))) {
	...

        if (memcmp(path_orig, path_new, sizeof(path_orig))) {

> 
> Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
> ---
>  test/zdtm/static/Makefile    |    1 -
>  test/zdtm/static/proc-self.c |   79 ------------------------------------------
>  2 files changed, 80 deletions(-)
>  delete mode 100644 test/zdtm/static/proc-self.c
> 
> diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
> index 02bf54d3..17449bab 100644
> --- a/test/zdtm/static/Makefile
> +++ b/test/zdtm/static/Makefile
> @@ -106,7 +106,6 @@ TST_NOFILE	:=				\
>  		groups				\
>  		pdeath_sig			\
>  		file_fown			\
> -		proc-self			\
>  		eventfs00			\
>  		signalfd00			\
>  		inotify_irmap			\
> diff --git a/test/zdtm/static/proc-self.c b/test/zdtm/static/proc-self.c
> deleted file mode 100644
> index 54cc5f1f..00000000
> --- a/test/zdtm/static/proc-self.c
> +++ /dev/null
> @@ -1,79 +0,0 @@
> -#define _GNU_SOURCE         /* See feature_test_macros(7) */
> -#include <unistd.h>
> -
> -#include <errno.h>
> -#include <fcntl.h>
> -#include <stdlib.h>
> -#include <signal.h>
> -#include <string.h>
> -#include <utime.h>
> -
> -#include <sys/stat.h>
> -#include <sys/types.h>
> -
> -#include "zdtmtst.h"
> -
> -const char *test_doc	= "Check for /proc/self/ns path restore";
> -const char *test_author	= "Cyrill Gorcunov <gorcunov at openvz.org>";
> -
> -const char nspath[] = "/proc/self/ns/net";
> -
> -int read_fd_link(int lfd, char *buf, size_t size)
> -{
> -	ssize_t ret;
> -	char t[32];
> -
> -	snprintf(t, sizeof(t), "/proc/self/fd/%d", lfd);
> -	ret = readlink(t, buf, size - 1);
> -	if (ret < 0) {
> -		pr_perror("Can't read link of fd %d", lfd);
> -		return -1;
> -	}
> -	buf[ret] = 0;
> -
> -	return 0;
> -}
> -
> -int main(int argc, char *argv[])
> -{
> -	char path_orig[64], path_new[64];
> -	int fd_self, fd_new;
> -
> -	test_init(argc, argv);
> -
> -	memset(path_orig, 0, sizeof(path_orig));
> -	memset(path_new, 0, sizeof(path_new));
> -
> -	fd_self = open(nspath, O_RDONLY);
> -	if (fd_self < 0) {
> -		pr_perror("Can't open %s", nspath);
> -		return -1;
> -	}
> -
> -	test_daemon();
> -	test_waitsig();
> -
> -	if (read_fd_link(fd_self, path_orig, sizeof(path_orig))) {
> -		pr_perror("Can't fill original path");
> -		return -1;
> -	}
> -
> -	fd_new = open(nspath, O_RDONLY);
> -	if (fd_new < 0) {
> -		pr_perror("Can't open %s", nspath);
> -		return -1;
> -	}
> -
> -	if (read_fd_link(fd_new, path_new, sizeof(path_new))) {
> -		pr_perror("Can't fill new path");
> -		return -1;
> -	}
> -
> -	if (memcmp(path_orig, path_new, sizeof(path_orig))) {
> -		fail("Paths mismatch %s %s\n", path_orig, path_new);
> -		return -1;
> -	}
> -
> -	pass();
> -	return 0;
> -}
> 


More information about the CRIU mailing list