[LTP] [PATCH 1/1] Skip wqueue testcases when KEY_NOTIFICATIONS not enabled.

simplemessager
2025-12-05T03:17:42Z

From: Mingyu Li <limy83@chinatelecom.cn>

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.

Reported-by: Meng Yang <yangm50@chinatelecom.cn>
Signed-off-by: Mingyu Li <limy83@chinatelecom.cn>
---
testcases/kernel/watchqueue/common.h | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/watchqueue/common.h b/testcases/kernel/watchqueue/common.h
index 92e8f079c..e9100ab52 100644
--- a/testcases/kernel/watchqueue/common.h
+++ b/testcases/kernel/watchqueue/common.h
@@ -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;
}
--
2.47.2