[LTP] [PATCH v5 09/11] Add wqueue07 test
Andrea Cervesato
andrea.cervesato@suse.de
Thu Jan 27 10:24:29 CET 2022
This test is testing NOTIFY_KEY_SETATTR event
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.de>
---
runtest/watchqueue | 1 +
testcases/kernel/watchqueue/.gitignore | 1 +
testcases/kernel/watchqueue/wqueue07.c | 43 ++++++++++++++++++++++++++
3 files changed, 45 insertions(+)
create mode 100644 testcases/kernel/watchqueue/wqueue07.c
diff --git a/runtest/watchqueue b/runtest/watchqueue
index de086b6a7..bdb461018 100644
--- a/runtest/watchqueue
+++ b/runtest/watchqueue
@@ -4,3 +4,4 @@ wqueue03 wqueue03
wqueue04 wqueue04
wqueue05 wqueue05
wqueue06 wqueue06
+wqueue07 wqueue07
diff --git a/testcases/kernel/watchqueue/.gitignore b/testcases/kernel/watchqueue/.gitignore
index e167b500d..891b19775 100644
--- a/testcases/kernel/watchqueue/.gitignore
+++ b/testcases/kernel/watchqueue/.gitignore
@@ -4,3 +4,4 @@ wqueue03
wqueue04
wqueue05
wqueue06
+wqueue07
diff --git a/testcases/kernel/watchqueue/wqueue07.c b/testcases/kernel/watchqueue/wqueue07.c
new file mode 100644
index 000000000..b2bd98b6a
--- /dev/null
+++ b/testcases/kernel/watchqueue/wqueue07.c
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2021 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * Test if keyctl setperm is correctly recognized by watch queue.
+ */
+
+#define _GNU_SOURCE
+
+#include "tst_test.h"
+#include "lapi/keyctl.h"
+#include "common.h"
+
+static void saw_key_setattr(struct watch_notification *n, size_t len,
+ unsigned int wtype)
+{
+ if (wqueue_key_event(n, len, wtype, NOTIFY_KEY_SETATTR))
+ tst_res(TPASS, "keyctl setattr has been recognized");
+ else
+ tst_res(TFAIL, "keyctl setattr 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_SETPERM, key, KEY_POS_ALL | KEY_USR_ALL);
+ wqueue_consumer(fd, saw_key_setattr);
+
+ SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+ .test_all = run,
+};
--
2.34.1
More information about the ltp
mailing list