[CRIU] [PATCH] zdtm: pty00 -- Count for SIGHUP, v3

Andrew Vagin avagin at parallels.com
Fri Aug 15 06:51:04 PDT 2014


On Fri, Aug 15, 2014 at 05:46:46PM +0400, Cyrill Gorcunov wrote:
> On Fri, Aug 15, 2014 at 05:19:29PM +0400, Pavel Emelyanov wrote:
> > 
> > No. Just set up at test start and check for the counter in
> > all the "interesting" places.
> 
> As you wish. Attached.

Acked-by: Andrey Vagin <avagin at openvz.org>
> From 6fcaf0f1c2936141ed395aa981bee9da7af733e1 Mon Sep 17 00:00:00 2001
> From: Cyrill Gorcunov <gorcunov at openvz.org>
> Date: Fri, 15 Aug 2014 17:07:15 +0400
> Subject: [PATCH] zdtm: pty00 -- Count for SIGHUP
> 
> Just to make sure we're not loosing signals
> after restore.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  test/zdtm/live/static/pty00.c | 34 +++++++++++++++++++++++++++++++---
>  1 file changed, 31 insertions(+), 3 deletions(-)
> 
> diff --git a/test/zdtm/live/static/pty00.c b/test/zdtm/live/static/pty00.c
> index 260fa407b0a5..b8553223abd8 100644
> --- a/test/zdtm/live/static/pty00.c
> +++ b/test/zdtm/live/static/pty00.c
> @@ -12,6 +12,13 @@
>  const char *test_doc	= "Check, that pseudoterminals are restored";
>  const char *test_author	= "Andrey Vagin <avagin at openvz.org>";
>  
> +static unsigned int nr_sighups;
> +
> +static void signal_handler_sighup(int signum)
> +{
> +	nr_sighups++;
> +}
> +
>  int main(int argc, char ** argv)
>  {
>  	int fdm, fds, ret;
> @@ -19,8 +26,22 @@ int main(int argc, char ** argv)
>  	char buf[10];
>  	const char teststr[] = "hello\n";
>  
> +	struct sigaction sa = {
> +		.sa_handler = signal_handler_sighup,
> +		.sa_flags = 0,
> +	};
> +
>  	test_init(argc, argv);
>  
> +	/*
> +	 * On closing control terminal we're expecting to
> +	 * receive SIGHUP, so make sure it's delivered.
> +	 */
> +	if (sigaction(SIGHUP, &sa, 0)) {
> +		fail("sigaction failed\n");
> +		return 1;
> +	}
> +
>  	fdm = open("/dev/ptmx", O_RDWR);
>  	if (fdm == -1) {
>  		err("open(%s) failed", "/dev/ptmx");
> @@ -54,8 +75,6 @@ int main(int argc, char ** argv)
>  
>  	test_waitsig();
>  
> -	signal(SIGHUP, SIG_IGN);
> -
>  	/* Check connectivity */
>  	ret = write(fdm, teststr, sizeof(teststr) - 1);
>  	if (ret != sizeof(teststr) - 1) {
> @@ -74,10 +93,19 @@ int main(int argc, char ** argv)
>  		return 1;
>  	}
>  
> +	if (nr_sighups != 0) {
> +		fail("Expected 0 SIGHUP before closing control terminal but got %d", nr_sighups);
> +		return 1;
> +	}
> +
>  	close(fdm);
>  	close(fds);
>  
> -	pass();
> +	if (nr_sighups != 1) {
> +		fail("Expected 1 SIGHUP after closing control terminal but got %d", nr_sighups);
> +		return 1;
> +	} else
> +		pass();
>  
>  	return 0;
>  }
> -- 
> 1.9.3
> 



More information about the CRIU mailing list