[CRIU] [RFC PATCH] test: add processes tree restoring test

Andrew Vagin avagin at parallels.com
Wed Oct 31 10:58:00 EDT 2012


On Wed, Oct 31, 2012 at 06:35:23PM +0400, Kinsbursky Stanislav wrote:
> From: Stanislav Kinsbursky <skinsbursky at openvz.org>
> 
> This test makes sure, that processes tree is restored before opened files.

I think the name is not good. We already have a test case, which check
process tree, they are called session00 and session01.

proc_child_file looks better for me.

> 
> It was inspired by OpenVZ bug:
> http://bugzilla.openvz.org/show_bug.cgi?id=2404
> 
> IOW, OpenVZ can't restore container with such test inside.
> 
> Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
> ---
>  test/zdtm.sh                         |    1 +
>  test/zdtm/live/static/Makefile       |    1 +
>  test/zdtm/live/static/process_tree.c |   38 ++++++++++++++++++++++++++++++++++
>  3 files changed, 40 insertions(+), 0 deletions(-)
>  create mode 100644 test/zdtm/live/static/process_tree.c

> diff --git a/test/zdtm.sh b/test/zdtm.sh
> index e7d8128..3ab5a2a 100644
> --- a/test/zdtm.sh
> +++ b/test/zdtm.sh
> @@ -65,6 +65,7 @@ transition/fork
>  static/pty00
>  static/pty01
>  static/pty04
> +static/process_tree
>  "
>  # Duplicate list with ns/ prefix
>  TEST_LIST=$TEST_LIST$(echo $TEST_LIST | tr ' ' '\n' | sed 's#^#ns/#')
> diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
> index 03e40fe..e14b23a 100644
> --- a/test/zdtm/live/static/Makefile
> +++ b/test/zdtm/live/static/Makefile
> @@ -72,6 +72,7 @@ TST_NOFILE	=				\
>  		socket-ext			\
>  		unhashed_proc			\
>  		cow00				\
> +		process_tree			\
>  		posix_timers			\
>  #		jobctl00			\
>  
> diff --git a/test/zdtm/live/static/process_tree.c b/test/zdtm/live/static/process_tree.c
> new file mode 100644
> index 0000000..c9843a8
> --- /dev/null
> +++ b/test/zdtm/live/static/process_tree.c
> @@ -0,0 +1,38 @@
> +#include <errno.h>
> +#include <fcntl.h>
> +#include <stdlib.h>
> +#include <string.h>
> +
> +#include "zdtmtst.h"
> +
> +const char *test_doc	= "Check that tree prior to files opening";
> +const char *test_author	= "Stanislav Kinsbursky <kinsbursky at paralles.com";
wrong email address?
> +
> +int main(int argc, char ** argv)
> +{
> +	int pid;
> +
> +	test_init(argc, argv);
> +
> +	pid = test_fork();
> +	if (pid < 0) {
> +		err("Can't fork");
> +		exit(1);
> +	}
> +
> +	if (pid) {
> +		int proc_fd;
> +		char name[64];
> +
> +		sprintf(name, "/proc/%d/stat", pid);
> +		proc_fd = open(name, O_RDONLY);
> +		if (proc_fd == -1) {
> +			err("can't open %s: %m\n", name);
> +			exit(1);
> +		}
> +		test_daemon();
> +	}
> +	test_waitsig();
> +	pass();

Who will kill a child?
> +	return 0;
> +}

> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://openvz.org/mailman/listinfo/criu



More information about the CRIU mailing list