Skip wqueue testcases when KEY_NOTIFICATIONS not enabled.
PATCH 1/1 Skip wqueue testcases when KEY_NOTIFICATIONS not enabled.
From: Mingyu Li <[email protected]>
Skip wqueue testcases when KEY_NOTIFICATIONS not enabled.
wqueue testcases relys on both CONFIG_WATCH_QUEUE and CONFIG_KEY_NOTIFICATIONS. keyctl will return EOPNOTSUPP when CONFIG_KEY_NOTIFICATIONS is not enabled and the wqueue testcases will failed when timeout. So we should skip testcases when we got EOPNOTSUPP from keyctl.
--- testcases/kernel/watchqueue/common.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
testcases/kernel/watchqueue/common.h +20 -2
@@ -85,8 +85,26 @@ static inline key_serial_t wqueue_add_key(int fd)if (key ==-1 )tst_brk (TBROK ,"add_key error: %s" ,tst_strerrno (errno)); -keyctl (KEYCTL_WATCH_KEY , key, fd,0x01 ); -keyctl (KEYCTL_WATCH_KEY ,KEY_SPEC_SESSION_KEYRING , fd,0x02 ); +TEST (keyctl (KEYCTL_WATCH_KEY , key, fd,0x01 )); +if (TST_RET ) { +switch (TST_ERR ) { +case EOPNOTSUPP : +tst_brk (TCONF |TTERRNO ,"CONFIG_KEY_NOTIFICATION is not set!" ); +break ; +default : +tst_res (TINFO ,"CONFIG_KEY_NOTIFICATION is set." ); + } + } +TEST (keyctl (KEYCTL_WATCH_KEY ,KEY_SPEC_SESSION_KEYRING , fd,0x02 )); +if (TST_RET ) { +switch (TST_ERR ) { +case EOPNOTSUPP : +tst_brk (TCONF |TTERRNO ,"CONFIG_KEY_NOTIFICATION is not set!" ); +break ; +default : +tst_res (TINFO ,"CONFIG_KEY_NOTIFICATION is set." ); + } + }return key; }
Signature · 5 lines
2.47.2 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Mingyu, Meng,
I sent an alternative approach for this. Could you please retest it.
https://lore.kernel.org/ltp/[email protected]/T/#t
https://patchwork.ozlabs.org/project/ltp/list/?series=484779&state=*
Quoted 21 lines
From: Mingyu Li <[email protected]>
Skip wqueue testcases when
KEY_NOTIFICATIONSnot enabled.wqueue testcases relys on both
CONFIG_WATCH_QUEUEandCONFIG_KEY_NOTIFICATIONS. keyctl will return EOPNOTSUPP whenCONFIG_KEY_NOTIFICATIONSis not enabled and the wqueue testcases will failed when timeout. So we should skip testcases when we got EOPNOTSUPP from keyctl.Reported-by Meng Yang <[email protected]>Signed-off-by Mingyu Li <[email protected]>--- testcases/kernel/watchqueue/common.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)testcases/kernel/watchqueue/common.h +0
-0
testcases/kernel/watchqueue/common.h static inline key_serial_t wqueue_add_key(int fd) · line 92
Quoted 10 lines
testcases/kernel/watchqueue/common.h +5
-2@@ -85,8 +85,26 @@ static inline key_serial_t wqueue_add_key(int fd)if (key ==-1 )tst_brk (TBROK ,"add_key error: %s" ,tst_strerrno (errno)); -keyctl (KEYCTL_WATCH_KEY , key, fd,0x01 ); -keyctl (KEYCTL_WATCH_KEY ,KEY_SPEC_SESSION_KEYRING , fd,0x02 ); +TEST (keyctl (KEYCTL_WATCH_KEY , key, fd,0x01 )); +if (TST_RET ) { +switch (TST_ERR ) { +case EOPNOTSUPP : +tst_brk (TCONF |TTERRNO ,"CONFIG_KEY_NOTIFICATION is not set!" );
nit: "| TTERRNO" is not needed, because we know the content of errno:
EOPNOTSUPP.
testcases/kernel/watchqueue/common.h static inline key_serial_t wqueue_add_key(int fd) · line 96
Quoted 4 lines
testcases/kernel/watchqueue/common.h +4
-0+break ; +default : +tst_res (TINFO ,"CONFIG_KEY_NOTIFICATION is set." ); + }
If your approach is taken, I would simplify it (we don't need TINFO)
if (keyctl(KEYCTL_WATCH_KEY, key, fd, 0x01) && errno == EOPNOTSUPP) tst_brk(TCONF, "CONFIG_KEY_NOTIFICATION is not set!"); if (keyctl(KEYCTL_WATCH_KEY, KEY_SPEC_SESSION_KEYRING, fd, 0x02) && errno == EOPNOTSUPP) tst_brk(TCONF, "CONFIG_KEY_NOTIFICATION is not set!");
Kind regards,
Petr
Quoted 14 lines
testcases/kernel/watchqueue/common.h +11
-0+ } +TEST (keyctl (KEYCTL_WATCH_KEY ,KEY_SPEC_SESSION_KEYRING , fd,0x02 )); +if (TST_RET ) { +switch (TST_ERR ) { +case EOPNOTSUPP : +tst_brk (TCONF |TTERRNO ,"CONFIG_KEY_NOTIFICATION is not set!" ); +break ; +default : +tst_res (TINFO ,"CONFIG_KEY_NOTIFICATION is set." ); + } + }return key; }
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp