[LTP] [PATCH v2 09/10] Add wqueue08 test
Andrea Cervesato
andrea.cervesato@suse.com
Fri Jan 7 11:59:12 CET 2022
This test is testing WATCH_META_REMOVAL_NOTIFICATION event
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/watchqueue | 1 +
testcases/kernel/watchqueue/.gitignore | 3 +-
testcases/kernel/watchqueue/wqueue08.c | 45 ++++++++++++++++++++++++++
3 files changed, 48 insertions(+), 1 deletion(-)
create mode 100644 testcases/kernel/watchqueue/wqueue08.c
diff --git a/runtest/watchqueue b/runtest/watchqueue
index bdb461018..badf7afb0 100644
--- a/runtest/watchqueue
+++ b/runtest/watchqueue
@@ -5,3 +5,4 @@ wqueue04 wqueue04
wqueue05 wqueue05
wqueue06 wqueue06
wqueue07 wqueue07
+wqueue08 wqueue08
diff --git a/testcases/kernel/watchqueue/.gitignore b/testcases/kernel/watchqueue/.gitignore
index 0d64c110c..56ede9fc5 100644
--- a/testcases/kernel/watchqueue/.gitignore
+++ b/testcases/kernel/watchqueue/.gitignore
@@ -4,4 +4,5 @@ wqueue03
wqueue04
wqueue05
wqueue06
-wqueue07
\ No newline at end of file
+wqueue07
+wqueue08
\ No newline at end of file
diff --git a/testcases/kernel/watchqueue/wqueue08.c b/testcases/kernel/watchqueue/wqueue08.c
new file mode 100644
index 000000000..3e286e2ab
--- /dev/null
+++ b/testcases/kernel/watchqueue/wqueue08.c
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2021 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * Test if key watch removal is correctly recognized by watch queue.
+ */
+
+#include "tst_test.h"
+#include "lapi/keyctl.h"
+#include "common.h"
+
+static void saw_watch_removal(struct watch_notification *n, LTP_ATTRIBUTE_UNUSED size_t len, unsigned int wtype)
+{
+ if (wtype != WATCH_TYPE_META)
+ return;
+
+ if (n->subtype == WATCH_META_REMOVAL_NOTIFICATION)
+ tst_res(TPASS, "Meta removal notification received");
+ else
+ tst_res(TFAIL, "Event not recognized");
+}
+
+static void run(void)
+{
+ int fd;
+ key_serial_t key;
+
+ fd = wqueue_watch(256, &wqueue_filter);
+ key = wqueue_add_key(fd);
+
+ /* if watch_id = -1 key is removed from the watch queue */
+ keyctl(KEYCTL_WATCH_KEY, key, fd, -1);
+ wqueue_consumer(fd, saw_watch_removal);
+
+ SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .needs_root = 1,
+};
--
2.34.1
More information about the ltp
mailing list