public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.de>
To: Andrea Cervesato <andrea.cervesato@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1] Remove ltp_quick_clone from mountns testing suite
Date: Tue, 07 Mar 2023 12:26:38 +0000	[thread overview]
Message-ID: <87y1o87nkf.fsf@suse.de> (raw)
In-Reply-To: <20230216102942.11859-1-andrea.cervesato@suse.com>

Hello,

Andrea Cervesato via ltp <ltp@lists.linux.it> writes:

> ltp_quick_clone has been replaced by SAFE_CLONE in the mountns testing
> suite that now is independed from libclone and legacy API.
>
> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
> ---
>  testcases/kernel/containers/mountns/mountns.h  | 18 ------------------
>  .../kernel/containers/mountns/mountns01.c      | 16 ++++++++--------
>  .../kernel/containers/mountns/mountns02.c      | 16 ++++++++--------
>  .../kernel/containers/mountns/mountns03.c      | 16 ++++++++--------
>  .../kernel/containers/mountns/mountns04.c      |  2 +-
>  5 files changed, 25 insertions(+), 43 deletions(-)
>
> diff --git a/testcases/kernel/containers/mountns/mountns.h b/testcases/kernel/containers/mountns/mountns.h
> index 615f1a058..9bb854659 100644
> --- a/testcases/kernel/containers/mountns/mountns.h
> +++ b/testcases/kernel/containers/mountns/mountns.h
> @@ -8,28 +8,10 @@
>  #define COMMON_H
>  
>  #include "tst_test.h"
> -#include "lapi/sched.h"
>  
>  #define DIRA "LTP_DIR_A"
>  #define DIRB "LTP_DIR_B"
>  
> -static int dummy_child(void *v)
> -{
> -	(void)v;
> -	return 0;
> -}
> -
> -static void check_newns(void)
> -{
> -	int pid, status;
> -
> -	pid = ltp_clone_quick(CLONE_NEWNS | SIGCHLD, dummy_child, NULL);
> -	if (pid < 0)
> -		tst_brk(TCONF, "CLONE_NEWNS not supported");
> -
> -	SAFE_WAIT(&status);
> -}
> -

If we remove this then we need to check the kernel config for namespace
support. Which you were doing in other tests IIRC.

Otherwise looks good, but setting to changes requested.

>  static void umount_folders(void)
>  {
>  	if (tst_is_mounted(DIRA))
> diff --git a/testcases/kernel/containers/mountns/mountns01.c b/testcases/kernel/containers/mountns/mountns01.c
> index e8f176920..c5b6077f1 100644
> --- a/testcases/kernel/containers/mountns/mountns01.c
> +++ b/testcases/kernel/containers/mountns/mountns01.c
> @@ -33,8 +33,9 @@
>  #include <sys/mount.h>
>  #include "mountns.h"
>  #include "tst_test.h"
> +#include "lapi/sched.h"
>  
> -static int child_func(LTP_ATTRIBUTE_UNUSED void *arg)
> +static void child_func(void)
>  {
>  	TST_CHECKPOINT_WAIT(0);
>  
> @@ -51,13 +52,11 @@ static int child_func(LTP_ATTRIBUTE_UNUSED void *arg)
>  	TST_CHECKPOINT_WAKE_AND_WAIT(0);
>  
>  	SAFE_UMOUNT(DIRA);
> -
> -	return 0;
>  }
>  
>  static void run(void)
>  {
> -	int ret;
> +	const struct tst_clone_args args = { CLONE_NEWNS, SIGCHLD };
>  
>  	SAFE_UNSHARE(CLONE_NEWNS);
>  
> @@ -67,9 +66,10 @@ static void run(void)
>  	SAFE_MOUNT(DIRA, DIRA, "none", MS_BIND, NULL);
>  	SAFE_MOUNT("none", DIRA, "none", MS_SHARED, NULL);
>  
> -	ret = ltp_clone_quick(CLONE_NEWNS | SIGCHLD, child_func, NULL);
> -	if (ret < 0)
> -		tst_brk(TBROK, "clone failed");
> +	if (!SAFE_CLONE(&args)) {
> +		child_func();
> +		return;
> +	}
>  
>  	SAFE_MOUNT(DIRB, DIRA, "none", MS_BIND, NULL);
>  
> @@ -93,7 +93,6 @@ static void run(void)
>  
>  static void setup(void)
>  {
> -	check_newns();
>  	create_folders();
>  }
>  
> @@ -107,5 +106,6 @@ static struct tst_test test = {
>  	.cleanup = cleanup,
>  	.test_all = run,
>  	.needs_root = 1,
> +	.forks_child = 1,
>  	.needs_checkpoints = 1,
>  };
> diff --git a/testcases/kernel/containers/mountns/mountns02.c b/testcases/kernel/containers/mountns/mountns02.c
> index 4b85fa79b..c2260961e 100644
> --- a/testcases/kernel/containers/mountns/mountns02.c
> +++ b/testcases/kernel/containers/mountns/mountns02.c
> @@ -34,8 +34,9 @@
>  #include <sys/mount.h>
>  #include "mountns.h"
>  #include "tst_test.h"
> +#include "lapi/sched.h"
>  
> -static int child_func(LTP_ATTRIBUTE_UNUSED void *arg)
> +static void child_func(void)
>  {
>  	TST_CHECKPOINT_WAIT(0);
>  
> @@ -51,13 +52,11 @@ static int child_func(LTP_ATTRIBUTE_UNUSED void *arg)
>  	TST_CHECKPOINT_WAKE_AND_WAIT(0);
>  
>  	SAFE_UMOUNT(DIRA);
> -
> -	return 0;
>  }
>  
>  static void run(void)
>  {
> -	int ret;
> +	const struct tst_clone_args args = { CLONE_NEWNS, SIGCHLD };
>  
>  	SAFE_UNSHARE(CLONE_NEWNS);
>  
> @@ -68,9 +67,10 @@ static void run(void)
>  
>  	SAFE_MOUNT("none", DIRA, "none", MS_PRIVATE, NULL);
>  
> -	ret = ltp_clone_quick(CLONE_NEWNS | SIGCHLD, child_func, NULL);
> -	if (ret < 0)
> -		tst_brk(TBROK, "clone failed");
> +	if (!SAFE_CLONE(&args)) {
> +		child_func();
> +		return;
> +	}
>  
>  	SAFE_MOUNT(DIRB, DIRA, "none", MS_BIND, NULL);
>  
> @@ -94,7 +94,6 @@ static void run(void)
>  
>  static void setup(void)
>  {
> -	check_newns();
>  	create_folders();
>  }
>  
> @@ -108,5 +107,6 @@ static struct tst_test test = {
>  	.cleanup = cleanup,
>  	.test_all = run,
>  	.needs_root = 1,
> +	.forks_child = 1,
>  	.needs_checkpoints = 1,
>  };
> diff --git a/testcases/kernel/containers/mountns/mountns03.c b/testcases/kernel/containers/mountns/mountns03.c
> index 1d26a25d8..357a4f30b 100644
> --- a/testcases/kernel/containers/mountns/mountns03.c
> +++ b/testcases/kernel/containers/mountns/mountns03.c
> @@ -36,8 +36,9 @@
>  #include <sys/mount.h>
>  #include "mountns.h"
>  #include "tst_test.h"
> +#include "lapi/sched.h"
>  
> -static int child_func(LTP_ATTRIBUTE_UNUSED void *arg)
> +static void child_func(void)
>  {
>  	/*
>  	 * makes mount DIRA a slave of DIRA (all slave mounts have
> @@ -59,13 +60,11 @@ static int child_func(LTP_ATTRIBUTE_UNUSED void *arg)
>  	TST_CHECKPOINT_WAKE_AND_WAIT(0);
>  
>  	SAFE_UMOUNT(DIRA);
> -
> -	return 0;
>  }
>  
>  static void run(void)
>  {
> -	int ret;
> +	const struct tst_clone_args args = { CLONE_NEWNS, SIGCHLD };
>  
>  	SAFE_UNSHARE(CLONE_NEWNS);
>  
> @@ -76,9 +75,10 @@ static void run(void)
>  
>  	SAFE_MOUNT("none", DIRA, "none", MS_SHARED, NULL);
>  
> -	ret = ltp_clone_quick(CLONE_NEWNS | SIGCHLD, child_func, NULL);
> -	if (ret < 0)
> -		tst_brk(TBROK, "clone failed");
> +	if (!SAFE_CLONE(&args)) {
> +		child_func();
> +		return;
> +	}
>  
>  	TST_CHECKPOINT_WAIT(0);
>  
> @@ -104,7 +104,6 @@ static void run(void)
>  
>  static void setup(void)
>  {
> -	check_newns();
>  	create_folders();
>  }
>  
> @@ -118,5 +117,6 @@ static struct tst_test test = {
>  	.cleanup = cleanup,
>  	.test_all = run,
>  	.needs_root = 1,
> +	.forks_child = 1,
>  	.needs_checkpoints = 1,
>  };
> diff --git a/testcases/kernel/containers/mountns/mountns04.c b/testcases/kernel/containers/mountns/mountns04.c
> index fc392f1a7..6a64c2443 100644
> --- a/testcases/kernel/containers/mountns/mountns04.c
> +++ b/testcases/kernel/containers/mountns/mountns04.c
> @@ -22,6 +22,7 @@
>  #include <sys/mount.h>
>  #include "mountns.h"
>  #include "tst_test.h"
> +#include "lapi/sched.h"
>  
>  static void run(void)
>  {
> @@ -46,7 +47,6 @@ static void run(void)
>  
>  static void setup(void)
>  {
> -	check_newns();
>  	create_folders();
>  }
>  
> -- 
> 2.35.3


-- 
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

      parent reply	other threads:[~2023-03-07 12:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-16 10:29 [LTP] [PATCH v1] Remove ltp_quick_clone from mountns testing suite Andrea Cervesato via ltp
2023-02-16 10:33 ` Andrea Cervesato via ltp
2023-03-07 12:26 ` Richard Palethorpe [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=87y1o87nkf.fsf@suse.de \
    --to=rpalethorpe@suse.de \
    --cc=andrea.cervesato@suse.com \
    --cc=ltp@lists.linux.it \
    /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