public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: xuyang2018.jy@fujitsu.com <xuyang2018.jy@fujitsu.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2] syscalls/ipc: Check whether kernel supports *_STAT_ANY
Date: Tue, 30 Mar 2021 03:55:29 +0000	[thread overview]
Message-ID: <6062A136.9060705@fujitsu.com> (raw)
In-Reply-To: <20210330033020.27223-1-zhaogongyi@huawei.com>

Hi Gongyi
> SHM_STAT_ANY,SEM_STAT_ANY and MSG_STAT_ANY are imported to linux
> in v4.17, and some linux distribution such as centos7.8 has
> backported this feature, so we should call SHM_STAT_ANY directly
> to detect whether kernel supports *_STAT_ANY.
Also fix wrong TTERRNO usage.
>
> Signed-off-by: Zhao Gongyi<zhaogongyi@huawei.com>
> ---
> v1->v2:
> 	1) call SHM_STAT_ANY directly to detect whether kernel supports
> 	   SHM_STAT_ANY instead of using min_kver
> 	2) fix MSG_STAT_ANY,SEM_STAT_ANY similarly
>
>   testcases/kernel/syscalls/ipc/msgctl/msgctl06.c | 15 ++++++++++++++-
>   testcases/kernel/syscalls/ipc/semctl/semctl09.c | 14 +++++++++++++-
>   testcases/kernel/syscalls/ipc/shmctl/shmctl04.c | 12 ++++++++++++
>   3 files changed, 39 insertions(+), 2 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/ipc/msgctl/msgctl06.c b/testcases/kernel/syscalls/ipc/msgctl/msgctl06.c
> index 722a0cca0..d4ec4876a 100644
> --- a/testcases/kernel/syscalls/ipc/msgctl/msgctl06.c
> +++ b/testcases/kernel/syscalls/ipc/msgctl/msgctl06.c
> @@ -115,7 +115,7 @@ static void verify_msgctl(unsigned int n)
>   	msgid = msgctl(TST_RET, MSG_STAT_ANY,&buf);
>
>   	if (msgid == -1) {
> -		tst_res(TFAIL | TTERRNO, "MSG_INFO haven't returned a valid index");
> +		tst_res(TFAIL | TERRNO, "MSG_INFO haven't returned a valid index");
>   	} else {
>   		tst_res(TPASS, "MSG_INFO returned valid index %li to msgid %i",
>   			TST_RET, msgid);
> @@ -138,12 +138,25 @@ static void verify_msgctl(unsigned int n)
>
>   static void setup(void)
>   {
> +	struct msqid_ds temp_buf;
>   	ltpuser = SAFE_GETPWNAM("nobody");
>   	nobody_uid = ltpuser->pw_uid;
>   	root_uid = 0;
>
>   	msg_id = SAFE_MSGGET(IPC_PRIVATE, IPC_CREAT | MSG_RW);
>   	SAFE_MSGSND(msg_id, "abcd", 4, 0);
> +
> +	TEST(msgctl(msg_id, MSG_STAT_ANY,&temp_buf));
> +	if (TST_RET == -1) {
> +		if (TST_ERR == EINVAL)
> +			tst_brk(TCONF, "kernel doesn't support "
> +					"MSG_STAT_ANY");
It's better to have a single line message.
> +		else
> +			tst_brk(TBROK | TTERRNO,
> +					"Current environment doesn't permit "
> +					"MSG_STAT_ANY");
Here as well.
> +	}
> +
>   }
>
>   static void cleanup(void)
> diff --git a/testcases/kernel/syscalls/ipc/semctl/semctl09.c b/testcases/kernel/syscalls/ipc/semctl/semctl09.c
> index 5a81f778c..197696df7 100644
> --- a/testcases/kernel/syscalls/ipc/semctl/semctl09.c
> +++ b/testcases/kernel/syscalls/ipc/semctl/semctl09.c
> @@ -158,7 +158,7 @@ static void verify_semctl(unsigned int n)
>   				"specified by the caller to kernel");
>   		return;
>   	} else if (semid == -1) {
> -		tst_res(TFAIL | TTERRNO, "SEM_INFO haven't returned a valid index");
> +		tst_res(TFAIL | TERRNO, "SEM_INFO haven't returned a valid index");
>   	} else {
>   		tst_res(TPASS, "SEM_INFO returned valid index %li to semid %i",
>   			TST_RET, semid);
> @@ -193,6 +193,18 @@ static void setup(void)
>   #endif
>
>   	sem_id = SAFE_SEMGET(IPC_PRIVATE, 2, IPC_CREAT | 0600);
> +
> +	TEST(do_semctl(sem_id, 0, SEM_STAT_ANY));
> +	if (TST_RET == -1) {
Since here has a glibc bug, we should also report FAIL, so we can print 
glibc git url.
		if (errno == EFAULT)
                 	tst_brk(TFAIL, "SEM_STAT_ANY doesn't pass the buffer 
specified by the caller to kernel");

> +		if (TST_ERR == EINVAL)
> +			tst_brk(TCONF, "kernel doesn't support "
> +					"SEM_STAT_ANY");

> +		else
> +			tst_brk(TBROK | TTERRNO,
> +					"Current environment doesn't permit "
> +					"SEM_STAT_ANY");

> +	}
> +
>   }
>
>   static void cleanup(void)
> diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c b/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
> index 9e8ec4199..9a60c5170 100644
> --- a/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
> +++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
> @@ -155,10 +155,22 @@ static void verify_shminfo(unsigned int n)
>   static void setup(void)
>   {
>   	struct passwd *ltpuser = SAFE_GETPWNAM("nobody");
> +	struct shmid_ds temp_ds;
>   	nobody_uid = ltpuser->pw_uid;
>   	root_uid = 0;
>
>   	shm_id = SAFE_SHMGET(IPC_PRIVATE, SHM_SIZE, IPC_CREAT | SHM_RW);
> +
> +	TEST(shmctl(shm_id, SHM_STAT_ANY,&temp_ds));
> +	if (TST_RET == -1) {
> +		if (TST_ERR == EINVAL)
> +			tst_brk(TCONF, "kernel doesn't support "
> +					"SHM_STAT_ANY");

> +		else
> +			tst_brk(TBROK | TTERRNO,
> +					"Current environment doesn't permit "
> +					"SHM_STAT_ANY");

> +	}
>   }
>
>   static void cleanup(void)
> --
> 2.17.1
>
>

      reply	other threads:[~2021-03-30  3:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-30  3:30 [LTP] [PATCH v2] syscalls/ipc: Check whether kernel supports *_STAT_ANY Zhao Gongyi
2021-03-30  3:55 ` xuyang2018.jy [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=6062A136.9060705@fujitsu.com \
    --to=xuyang2018.jy@fujitsu.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