All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/semctl09: Skip libc test if SEM_STAT_ANY not defined
@ 2021-03-18 16:24 Martin Doucha
  2021-03-18 18:30 ` Petr Vorel
  0 siblings, 1 reply; 7+ messages in thread
From: Martin Doucha @ 2021-03-18 16:24 UTC (permalink / raw)
  To: ltp

The libc test variant should run only if system headers define SEM_STAT_ANY.
Skip it if we're falling back to the LAPI definition.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 configure.ac                                    | 1 +
 testcases/kernel/syscalls/ipc/semctl/semctl09.c | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/configure.ac b/configure.ac
index 37bafb93d..136d82d09 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,6 +38,7 @@ AC_PREFIX_DEFAULT(/opt/ltp)
 AC_CHECK_DECLS([IFLA_NET_NS_PID],,,[#include <linux/if_link.h>])
 AC_CHECK_DECLS([MADV_MERGEABLE],,,[#include <sys/mman.h>])
 AC_CHECK_DECLS([PR_CAPBSET_DROP, PR_CAPBSET_READ],,,[#include <sys/prctl.h>])
+AC_CHECK_DECLS([SEM_STAT_ANY],,,[#include <sys/sem.h>])
 
 AC_CHECK_HEADERS_ONCE([ \
     asm/ldt.h \
diff --git a/testcases/kernel/syscalls/ipc/semctl/semctl09.c b/testcases/kernel/syscalls/ipc/semctl/semctl09.c
index a933cff0e..fb7d49f3d 100644
--- a/testcases/kernel/syscalls/ipc/semctl/semctl09.c
+++ b/testcases/kernel/syscalls/ipc/semctl/semctl09.c
@@ -186,6 +186,11 @@ static void setup(void)
 	nobody_uid = ltpuser->pw_uid;
 	root_uid = 0;
 
+#if !HAVE_DECL_SEM_STAT_ANY
+	if (tst_variant == 1)
+		tst_brk(TCONF, "libc does not support semctl(SEM_STAT_ANY)");
+#endif
+
 	sem_id = SAFE_SEMGET(IPC_PRIVATE, 2, IPC_CREAT | 0600);
 	test_info();
 }
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [LTP] [PATCH] syscalls/semctl09: Skip libc test if SEM_STAT_ANY not defined
  2021-03-18 16:24 [LTP] [PATCH] syscalls/semctl09: Skip libc test if SEM_STAT_ANY not defined Martin Doucha
@ 2021-03-18 18:30 ` Petr Vorel
  2021-03-19  2:56   ` Yang Xu
  2021-03-19  9:49   ` Martin Doucha
  0 siblings, 2 replies; 7+ messages in thread
From: Petr Vorel @ 2021-03-18 18:30 UTC (permalink / raw)
  To: ltp

Hi Martin,

> The libc test variant should run only if system headers define SEM_STAT_ANY.
> Skip it if we're falling back to the LAPI definition.

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Thanks!

...
> +#if !HAVE_DECL_SEM_STAT_ANY
nit: I'd prefer
#ifndef HAVE_DECL_SEM_STAT_ANY

> +	if (tst_variant == 1)
> +		tst_brk(TCONF, "libc does not support semctl(SEM_STAT_ANY)");
> +#endif
Although I understand why you want to quit only tests with root
(only these fail), it's a bit confusing to test with user nobody
and then quit the same testing with root.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [LTP] [PATCH] syscalls/semctl09: Skip libc test if SEM_STAT_ANY not defined
  2021-03-18 18:30 ` Petr Vorel
@ 2021-03-19  2:56   ` Yang Xu
  2021-03-19  8:29     ` Petr Vorel
  2021-03-19  9:49   ` Martin Doucha
  1 sibling, 1 reply; 7+ messages in thread
From: Yang Xu @ 2021-03-19  2:56 UTC (permalink / raw)
  To: ltp

Hi Petr
> Hi Martin,
>
>> The libc test variant should run only if system headers define SEM_STAT_ANY.
>> Skip it if we're falling back to the LAPI definition.
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
>
> Thanks!
>
> ...
>> +#if !HAVE_DECL_SEM_STAT_ANY
> nit: I'd prefer
> #ifndef HAVE_DECL_SEM_STAT_ANY
+1
>> +	if (tst_variant == 1)
>> +		tst_brk(TCONF, "libc does not support semctl(SEM_STAT_ANY)");
>> +#endif
> Although I understand why you want to quit only tests with root
> (only these fail), it's a bit confusing to test with user nobody
> and then quit the same testing with root.

I don't get this.? Martin only wants to skip libc test when undefined 
and it doesn't matter which user we use.


> Kind regards,
> Petr
>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [LTP] [PATCH] syscalls/semctl09: Skip libc test if SEM_STAT_ANY not defined
  2021-03-19  2:56   ` Yang Xu
@ 2021-03-19  8:29     ` Petr Vorel
  2021-03-19  8:44       ` xuyang2018.jy
  0 siblings, 1 reply; 7+ messages in thread
From: Petr Vorel @ 2021-03-19  8:29 UTC (permalink / raw)
  To: ltp

Hi Xu,

> > > +	if (tst_variant == 1)
> > > +		tst_brk(TCONF, "libc does not support semctl(SEM_STAT_ANY)");
> > > +#endif
> > Although I understand why you want to quit only tests with root
> > (only these fail), it's a bit confusing to test with user nobody
> > and then quit the same testing with root.

> I don't get this.? Martin only wants to skip libc test when undefined and it
> doesn't matter which user we use.

if (tst_variant == 1)
	tst_brk(TCONF, "libc does not support semctl(SEM_STAT_ANY)");

means:

# /semctl09
tst_test.c:1289: TINFO: Timeout per run is 0h 05m 00s
semctl09.c:76: TINFO: Test SYS_semctl syscall
semctl09.c:141: TINFO: Test SEM_STAT_ANY with nobody user
semctl09.c:163: TPASS: SEM_INFO returned valid index 19 to semid 19
semctl09.c:173: TPASS: Counted used = 1
semctl09.c:121: TPASS: semset_cnt = 1
semctl09.c:128: TPASS: sen_cnt = 2
semctl09.c:141: TINFO: Test SEM_STAT_ANY with root user
semctl09.c:163: TPASS: SEM_INFO returned valid index 19 to semid 19
semctl09.c:173: TPASS: Counted used = 1
semctl09.c:121: TPASS: semset_cnt = 1
semctl09.c:128: TPASS: sen_cnt = 2
tst_test.c:1289: TINFO: Timeout per run is 0h 05m 00s
semctl09.c:191: TCONF: libc does not support semctl(SEM_STAT_ANY)

i.e. run first test with user nobody and skip the second.
It's a bit confusing to test anything with SEM_STAT_ANY and then state
TCONF: libc does not support semctl(SEM_STAT_ANY) :)

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [LTP] [PATCH] syscalls/semctl09: Skip libc test if SEM_STAT_ANY not defined
  2021-03-19  8:29     ` Petr Vorel
@ 2021-03-19  8:44       ` xuyang2018.jy
  0 siblings, 0 replies; 7+ messages in thread
From: xuyang2018.jy @ 2021-03-19  8:44 UTC (permalink / raw)
  To: ltp

Hi Petr
> Hi Xu,
>
>>>> +	if (tst_variant == 1)
>>>> +		tst_brk(TCONF, "libc does not support semctl(SEM_STAT_ANY)");
>>>> +#endif
>>> Although I understand why you want to quit only tests with root
>>> (only these fail), it's a bit confusing to test with user nobody
>>> and then quit the same testing with root.
>
>> I don't get this.  Martin only wants to skip libc test when undefined and it
>> doesn't matter which user we use.
>
> if (tst_variant == 1)
> 	tst_brk(TCONF, "libc does not support semctl(SEM_STAT_ANY)");
>
> means:
>
> # /semctl09
> tst_test.c:1289: TINFO: Timeout per run is 0h 05m 00s
> semctl09.c:76: TINFO: Test SYS_semctl syscall
> semctl09.c:141: TINFO: Test SEM_STAT_ANY with nobody user
> semctl09.c:163: TPASS: SEM_INFO returned valid index 19 to semid 19
> semctl09.c:173: TPASS: Counted used = 1
> semctl09.c:121: TPASS: semset_cnt = 1
> semctl09.c:128: TPASS: sen_cnt = 2
> semctl09.c:141: TINFO: Test SEM_STAT_ANY with root user
> semctl09.c:163: TPASS: SEM_INFO returned valid index 19 to semid 19
> semctl09.c:173: TPASS: Counted used = 1
> semctl09.c:121: TPASS: semset_cnt = 1
> semctl09.c:128: TPASS: sen_cnt = 2
> tst_test.c:1289: TINFO: Timeout per run is 0h 05m 00s
> semctl09.c:191: TCONF: libc does not support semctl(SEM_STAT_ANY)
>
> i.e. run first test with user nobody and skip the second.
> It's a bit confusing to test anything with SEM_STAT_ANY and then state
> TCONF: libc does not support semctl(SEM_STAT_ANY) :)
Thanks. I got it.
I guess we can move this check into test_info as below:

--- a/testcases/kernel/syscalls/ipc/semctl/semctl09.c
+++ b/testcases/kernel/syscalls/ipc/semctl/semctl09.c
@@ -77,6 +77,9 @@ static void test_info(void)
         break;
         case 1:
                 tst_res(TINFO, "Test libc semctl()");
+#ifndef HAVE_DECL_SEM_STAT_ANY
+               tst_brk(TCONF, "libc does not support 
semctl(SEM_STAT_ANY)");
+#endif
         break;

Then output as below:
# ./semctl09
tst_test.c:1291: TINFO: Timeout per run is 0h 05m 00s
semctl09.c:76: TINFO: Test SYS_semctl syscall
semctl09.c:144: TINFO: Test SEM_STAT_ANY with nobody user
semctl09.c:167: TPASS: SEM_INFO returned valid index 34 to semid 34
semctl09.c:176: TPASS: Counted used = 1
semctl09.c:124: TPASS: semset_cnt = 1
semctl09.c:131: TPASS: sen_cnt = 2
semctl09.c:144: TINFO: Test SEM_STAT_ANY with root user
semctl09.c:167: TPASS: SEM_INFO returned valid index 34 to semid 34
semctl09.c:176: TPASS: Counted used = 1
semctl09.c:124: TPASS: semset_cnt = 1
semctl09.c:131: TPASS: sen_cnt = 2
tst_test.c:1291: TINFO: Timeout per run is 0h 05m 00s
semctl09.c:79: TINFO: Test libc semctl()
semctl09.c:81: TCONF: libc does not support semctl(SEM_STAT_ANY)


>
> Kind regards,
> Petr
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [LTP] [PATCH] syscalls/semctl09: Skip libc test if SEM_STAT_ANY not defined
  2021-03-18 18:30 ` Petr Vorel
  2021-03-19  2:56   ` Yang Xu
@ 2021-03-19  9:49   ` Martin Doucha
  2021-03-19 11:22     ` Petr Vorel
  1 sibling, 1 reply; 7+ messages in thread
From: Martin Doucha @ 2021-03-19  9:49 UTC (permalink / raw)
  To: ltp

On 18. 03. 21 19:30, Petr Vorel wrote:
> Hi Martin,
> 
>> The libc test variant should run only if system headers define SEM_STAT_ANY.
>> Skip it if we're falling back to the LAPI definition.
> 
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
> 
> Thanks!
> 
> ...
>> +#if !HAVE_DECL_SEM_STAT_ANY
> nit: I'd prefer
> #ifndef HAVE_DECL_SEM_STAT_ANY

That will not work. AC_CHECK_DECLS() will always define
HAVE_DECL_SEM_STAT_ANY, either with the value of 0 (macro not defined)
or 1 (defined).

>> +	if (tst_variant == 1)
>> +		tst_brk(TCONF, "libc does not support semctl(SEM_STAT_ANY)");
>> +#endif
> Although I understand why you want to quit only tests with root
> (only these fail), it's a bit confusing to test with user nobody
> and then quit the same testing with root.

tst_variant has nothing to do with UID.
tst_variant == 0 => run the test using tst_syscall(__NR_semctl)
tst_variant == 1 => run the test again using libc semctl()

But if you want to make the test output a little more clear, I could
move the test_info() call at the end of setup() a few lines up before
the new #if.

-- 
Martin Doucha   mdoucha@suse.cz
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [LTP] [PATCH] syscalls/semctl09: Skip libc test if SEM_STAT_ANY not defined
  2021-03-19  9:49   ` Martin Doucha
@ 2021-03-19 11:22     ` Petr Vorel
  0 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2021-03-19 11:22 UTC (permalink / raw)
  To: ltp

Hi Martin,

> >> +#if !HAVE_DECL_SEM_STAT_ANY
> > nit: I'd prefer
> > #ifndef HAVE_DECL_SEM_STAT_ANY

> That will not work. AC_CHECK_DECLS() will always define
> HAVE_DECL_SEM_STAT_ANY, either with the value of 0 (macro not defined)
> or 1 (defined).
Correct, I'm sorry, thanks for catching my error.

> >> +	if (tst_variant == 1)
> >> +		tst_brk(TCONF, "libc does not support semctl(SEM_STAT_ANY)");
> >> +#endif
> > Although I understand why you want to quit only tests with root
> > (only these fail), it's a bit confusing to test with user nobody
> > and then quit the same testing with root.

> tst_variant has nothing to do with UID.
> tst_variant == 0 => run the test using tst_syscall(__NR_semctl)
> tst_variant == 1 => run the test again using libc semctl()
Again, correct, sorry for wrong report.

> But if you want to make the test output a little more clear, I could
> move the test_info() call at the end of setup() a few lines up before
> the new #if.
+1

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-03-19 11:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-18 16:24 [LTP] [PATCH] syscalls/semctl09: Skip libc test if SEM_STAT_ANY not defined Martin Doucha
2021-03-18 18:30 ` Petr Vorel
2021-03-19  2:56   ` Yang Xu
2021-03-19  8:29     ` Petr Vorel
2021-03-19  8:44       ` xuyang2018.jy
2021-03-19  9:49   ` Martin Doucha
2021-03-19 11:22     ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.