[LTP] [PATCH v2 30/31] testcases: sysfs: Add sys_swap01

Cyril Hrubis <[email protected]>
Newsgroups it.linux.lists.ltp
Message-ID <[email protected]>
A test for /sys/kernel/mm/swap/vma_ra_enabled file.

Signed-off-by: Cyril Hrubis <[email protected]>
---
 runtest/sysfs                                 |  1 +
 .../kernel/sysfs/kernel/mm/swap/.gitignore    |  1 +
 .../kernel/sysfs/kernel/mm/swap/Makefile      |  7 ++++
 .../sysfs/kernel/mm/swap/sys_mm_swap01.c      | 32 +++++++++++++++++++
 4 files changed, 41 insertions(+)
 create mode 100644 testcases/kernel/sysfs/kernel/mm/swap/.gitignore
 create mode 100644 testcases/kernel/sysfs/kernel/mm/swap/Makefile
 create mode 100644 testcases/kernel/sysfs/kernel/mm/swap/sys_mm_swap01.c

diff --git a/runtest/sysfs b/runtest/sysfs
index 08358ebc6..7d59ae701 100644
--- a/runtest/sysfs
+++ b/runtest/sysfs
@@ -25,3 +25,4 @@ sys_block_size01 sys_block_size01
 sys_hugepages01 sys_hugepages01
 sys_hugepages02 sys_hugepages02
 sys_ksm01 sys_ksm01
+sys_mm_swap01 sys_mm_swap01
diff --git a/testcases/kernel/sysfs/kernel/mm/swap/.gitignore b/testcases/kernel/sysfs/kernel/mm/swap/.gitignore
new file mode 100644
index 000000000..38895046b
--- /dev/null
+++ b/testcases/kernel/sysfs/kernel/mm/swap/.gitignore
@@ -0,0 +1 @@
+/sys_mm_swap01
diff --git a/testcases/kernel/sysfs/kernel/mm/swap/Makefile b/testcases/kernel/sysfs/kernel/mm/swap/Makefile
new file mode 100644
index 000000000..781865569
--- /dev/null
+++ b/testcases/kernel/sysfs/kernel/mm/swap/Makefile
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2026 Cyril Hrubis <[email protected]>
+
+top_srcdir		?= ../../../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/sysfs/kernel/mm/swap/sys_mm_swap01.c b/testcases/kernel/sysfs/kernel/mm/swap/sys_mm_swap01.c
new file mode 100644
index 000000000..1b5a622f5
--- /dev/null
+++ b/testcases/kernel/sysfs/kernel/mm/swap/sys_mm_swap01.c
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2026 Cyril Hrubis <[email protected]>
+ */
+
+/*\
+ * Sanity check for /sys/kernel/mm/swap/vma_ra_enabled.
+ *
+ * Unlike most other boolean sysfs tunables which use 0/1, this one is
+ * formatted as the strings "true" or "false", so it needs its own check
+ * rather than TST_SYSFS_ASSERT_BOOL().
+ *
+ * The test skips with TCONF when the attribute is not present.
+ */
+
+#include "tst_test.h"
+#include "tst_sysfs_assert.h"
+
+#define VMA_RA "/sys/kernel/mm/swap/vma_ra_enabled"
+
+static const char *const bool_str_allowed[] = {
+	"true", "false", NULL
+};
+
+static void do_test(void)
+{
+	TST_SYSFS_ASSERT_ONEOF(bool_str_allowed, VMA_RA);
+}
+
+static struct tst_test test = {
+	.test_all = do_test,
+};
-- 
2.54.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.