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