* [LTP] [PATCH] syscalls/shmctl04: Add kernel version requestions
@ 2021-03-29 13:46 Zhao Gongyi
2021-03-30 1:51 ` xuyang2018.jy
0 siblings, 1 reply; 4+ messages in thread
From: Zhao Gongyi @ 2021-03-29 13:46 UTC (permalink / raw)
To: ltp
SHM_STAT_ANY is imported to linux in v4.17.
Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
testcases/kernel/syscalls/ipc/shmctl/shmctl04.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c b/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
index 9e8ec4199..18ac8ba0a 100644
--- a/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
+++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
@@ -168,6 +168,7 @@ static void cleanup(void)
}
static struct tst_test test = {
+ .min_kver = "4.17",
.setup = setup,
.cleanup = cleanup,
.test = verify_shminfo,
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [PATCH] syscalls/shmctl04: Add kernel version requestions
2021-03-29 13:46 Zhao Gongyi
@ 2021-03-30 1:51 ` xuyang2018.jy
0 siblings, 0 replies; 4+ messages in thread
From: xuyang2018.jy @ 2021-03-30 1:51 UTC (permalink / raw)
To: ltp
Hi Gongyi
> SHM_STAT_ANY is imported to linux in v4.17.
>
> Signed-off-by: Zhao Gongyi<zhaogongyi@huawei.com>
> ---
> testcases/kernel/syscalls/ipc/shmctl/shmctl04.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c b/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
> index 9e8ec4199..18ac8ba0a 100644
> --- a/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
> +++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
> @@ -168,6 +168,7 @@ static void cleanup(void)
> }
>
> static struct tst_test test = {
> + .min_kver = "4.17",
Some linux distribution such as centos7.8 has backported this feature,
so we should call SHM_STAT_ANY directly to detect whether kernel
supports SHM_STAT_ANY instead of using min_kver.
code as below:
--- a/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
+++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
@@ -155,10 +155,19 @@ 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");
+ }
}
Also, On your environment, does semctl09.c/msgctl06.c have the same problem?
> .setup = setup,
> .cleanup = cleanup,
> .test = verify_shminfo,
> --
> 2.17.1
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [LTP] [PATCH] syscalls/shmctl04: Add kernel version requestions
@ 2021-03-30 1:58 zhaogongyi
2021-03-30 2:05 ` xuyang2018.jy
0 siblings, 1 reply; 4+ messages in thread
From: zhaogongyi @ 2021-03-30 1:58 UTC (permalink / raw)
To: ltp
Hi Xu,
It looks good to me.
On the other hand, msgctl06.c, semctl09.c have the same problem for MSG_STAT_ANY and SEM_STAT_ANY, we can also fix them similarly?
Thanks!
Best Regards,
Gongyi
>
> Hi Gongyi
> > SHM_STAT_ANY is imported to linux in v4.17.
> >
> > Signed-off-by: Zhao Gongyi<zhaogongyi@huawei.com>
> > ---
> > testcases/kernel/syscalls/ipc/shmctl/shmctl04.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
> > b/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
> > index 9e8ec4199..18ac8ba0a 100644
> > --- a/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
> > +++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
> > @@ -168,6 +168,7 @@ static void cleanup(void)
> > }
> >
> > static struct tst_test test = {
> > + .min_kver = "4.17",
> Some linux distribution such as centos7.8 has backported this feature, so
> we should call SHM_STAT_ANY directly to detect whether kernel supports
> SHM_STAT_ANY instead of using min_kver.
>
> code as below:
> --- a/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
> +++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
> @@ -155,10 +155,19 @@ 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");
> + }
> }
>
>
> Also, On your environment, does semctl09.c/msgctl06.c have the same
> problem?
>
> > .setup = setup,
> > .cleanup = cleanup,
> > .test = verify_shminfo,
> > --
> > 2.17.1
> >
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
* [LTP] [PATCH] syscalls/shmctl04: Add kernel version requestions
2021-03-30 1:58 [LTP] [PATCH] syscalls/shmctl04: Add kernel version requestions zhaogongyi
@ 2021-03-30 2:05 ` xuyang2018.jy
0 siblings, 0 replies; 4+ messages in thread
From: xuyang2018.jy @ 2021-03-30 2:05 UTC (permalink / raw)
To: ltp
Hi Gongyi
> Hi Xu,
>
> It looks good to me.
>
> On the other hand, msgctl06.c, semctl09.c have the same problem for MSG_STAT_ANY and SEM_STAT_ANY, we can also fix them similarly?
Yes. We can fix them similarly.
>
> Thanks!
>
> Best Regards,
> Gongyi
>
>>
>> Hi Gongyi
>>> SHM_STAT_ANY is imported to linux in v4.17.
>>>
>>> Signed-off-by: Zhao Gongyi<zhaogongyi@huawei.com>
>>> ---
>>> testcases/kernel/syscalls/ipc/shmctl/shmctl04.c | 1 +
>>> 1 file changed, 1 insertion(+)
>>>
>>> diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
>>> b/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
>>> index 9e8ec4199..18ac8ba0a 100644
>>> --- a/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
>>> +++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
>>> @@ -168,6 +168,7 @@ static void cleanup(void)
>>> }
>>>
>>> static struct tst_test test = {
>>> + .min_kver = "4.17",
>> Some linux distribution such as centos7.8 has backported this feature, so
>> we should call SHM_STAT_ANY directly to detect whether kernel supports
>> SHM_STAT_ANY instead of using min_kver.
>>
>> code as below:
>> --- a/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
>> +++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
>> @@ -155,10 +155,19 @@ 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");
>> + }
>> }
>>
>>
>> Also, On your environment, does semctl09.c/msgctl06.c have the same
>> problem?
>>
>>> .setup = setup,
>>> .cleanup = cleanup,
>>> .test = verify_shminfo,
>>> --
>>> 2.17.1
>>>
>>>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-03-30 2:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-30 1:58 [LTP] [PATCH] syscalls/shmctl04: Add kernel version requestions zhaogongyi
2021-03-30 2:05 ` xuyang2018.jy
-- strict thread matches above, loose matches on Subject: below --
2021-03-29 13:46 Zhao Gongyi
2021-03-30 1:51 ` xuyang2018.jy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox