[LTP] [PATCH v5 08/11] Add wqueue06 test

Andrea Cervesato andrea.cervesato@suse.de
Thu Jan 27 10:24:28 CET 2022


This test is testing NOTIFY_KEY_INVALIDATED event

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.de>
---
 runtest/watchqueue                     |  1 +
 testcases/kernel/watchqueue/.gitignore |  1 +
 testcases/kernel/watchqueue/wqueue06.c | 42 ++++++++++++++++++++++++++
 3 files changed, 44 insertions(+)
 create mode 100644 testcases/kernel/watchqueue/wqueue06.c

diff --git a/runtest/watchqueue b/runtest/watchqueue
index 596d45154..de086b6a7 100644
--- a/runtest/watchqueue
+++ b/runtest/watchqueue
@@ -3,3 +3,4 @@ wqueue02 wqueue02
 wqueue03 wqueue03
 wqueue04 wqueue04
 wqueue05 wqueue05
+wqueue06 wqueue06
diff --git a/testcases/kernel/watchqueue/.gitignore b/testcases/kernel/watchqueue/.gitignore
index 9f4ac81e7..e167b500d 100644
--- a/testcases/kernel/watchqueue/.gitignore
+++ b/testcases/kernel/watchqueue/.gitignore
@@ -3,3 +3,4 @@ wqueue02
 wqueue03
 wqueue04
 wqueue05
+wqueue06
diff --git a/testcases/kernel/watchqueue/wqueue06.c b/testcases/kernel/watchqueue/wqueue06.c
new file mode 100644
index 000000000..d7806998e
--- /dev/null
+++ b/testcases/kernel/watchqueue/wqueue06.c
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2021 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * Test if keyctl clear is correctly recognized by watch queue.
+ */
+
+#define _GNU_SOURCE
+
+#include "tst_test.h"
+#include "lapi/keyctl.h"
+#include "common.h"
+
+static void saw_key_cleared(struct watch_notification *n, size_t len,
+							unsigned int wtype)
+{
+	if (wqueue_key_event(n, len, wtype, NOTIFY_KEY_CLEARED))
+		tst_res(TPASS, "keyctl clear has been recognized");
+	else
+		tst_res(TFAIL, "keyctl clear has not been recognized");
+}
+
+static void run(void)
+{
+	int fd;
+
+	fd = wqueue_watch(256, &wqueue_filter);
+	wqueue_add_key(fd);
+
+	keyctl(KEYCTL_CLEAR, KEY_SPEC_SESSION_KEYRING);
+	wqueue_consumer(fd, saw_key_cleared);
+
+	SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+	.test_all = run,
+};
-- 
2.34.1



More information about the ltp mailing list