[LTP] [PATCH v4 06/11] Add wqueue04 test
Andrea Cervesato
andrea.cervesato@suse.de
Fri Jan 7 22:20:53 CET 2022
This test is testing NOTIFY_KEY_LINKED event
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.de>
---
testcases/kernel/watchqueue/wqueue04.c | 40 ++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
create mode 100644 testcases/kernel/watchqueue/wqueue04.c
diff --git a/testcases/kernel/watchqueue/wqueue04.c b/testcases/kernel/watchqueue/wqueue04.c
new file mode 100644
index 000000000..04e99e891
--- /dev/null
+++ b/testcases/kernel/watchqueue/wqueue04.c
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2021 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * Test if keyctl link is correctly recognized by watch queue.
+ */
+
+#include "tst_test.h"
+#include "lapi/keyctl.h"
+#include "common.h"
+
+static void saw_key_linked(struct watch_notification *n, size_t len, unsigned int wtype)
+{
+ if (wqueue_key_event(n, len, wtype, NOTIFY_KEY_LINKED))
+ tst_res(TPASS, "keyctl link has been recognized");
+ else
+ tst_res(TFAIL, "keyctl link has not been recognized");
+}
+
+static void run(void)
+{
+ int fd;
+ key_serial_t key;
+
+ fd = wqueue_watch(256, &wqueue_filter);
+ key = wqueue_add_key(fd);
+
+ keyctl(KEYCTL_LINK, key, KEY_SPEC_SESSION_KEYRING);
+ wqueue_consumer(fd, saw_key_linked);
+
+ SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+ .test_all = run,
+};
--
2.34.1
More information about the ltp
mailing list