[PATCH 08/20] tools/testing/vma: add simple test for append_vma_flags()
Lorenzo Stoakes (Oracle)
ljs at kernel.org
Fri Mar 13 06:16:06 AEDT 2026
Add a simple test for append_vma_flags() to assert that it behaves as
expected.
Additionally, include the VMA_REMAP_FLAGS definition in the VMA tests to
allow us to use this value in the testing.
Signed-off-by: Lorenzo Stoakes (Oracle) <ljs at kernel.org>
---
tools/testing/vma/include/dup.h | 3 +++
tools/testing/vma/tests/vma.c | 25 +++++++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/tools/testing/vma/include/dup.h b/tools/testing/vma/include/dup.h
index 0d75ac23ac4d..c3be8a2381e1 100644
--- a/tools/testing/vma/include/dup.h
+++ b/tools/testing/vma/include/dup.h
@@ -345,6 +345,9 @@ enum {
*/
#define VM_SPECIAL (VM_IO | VM_DONTEXPAND | VM_PFNMAP | VM_MIXEDMAP)
+#define VMA_REMAP_FLAGS mk_vma_flags(VMA_IO_BIT, VMA_PFNMAP_BIT, \
+ VMA_DONTEXPAND_BIT, VMA_DONTDUMP_BIT)
+
#define DEFAULT_MAP_WINDOW ((1UL << 47) - PAGE_SIZE)
#define TASK_SIZE_LOW DEFAULT_MAP_WINDOW
#define TASK_SIZE_MAX DEFAULT_MAP_WINDOW
diff --git a/tools/testing/vma/tests/vma.c b/tools/testing/vma/tests/vma.c
index feea6d270233..98e465fb1bf2 100644
--- a/tools/testing/vma/tests/vma.c
+++ b/tools/testing/vma/tests/vma.c
@@ -555,6 +555,30 @@ static bool test_vma_flags_and(void)
return true;
}
+/* Ensure append_vma_flags() acts as expected. */
+static bool test_append_vma_flags(void)
+{
+ vma_flags_t flags = append_vma_flags(VMA_REMAP_FLAGS, VMA_READ_BIT,
+ VMA_WRITE_BIT
+#if NUM_VMA_FLAG_BITS > 64
+ , 64, 65
+#endif
+ );
+
+ ASSERT_FLAGS_SAME(&flags, VMA_IO_BIT, VMA_PFNMAP_BIT,
+ VMA_DONTEXPAND_BIT, VMA_DONTDUMP_BIT, VMA_READ_BIT,
+ VMA_WRITE_BIT
+#if NUM_VMA_FLAG_BITS > 64
+ , 64, 65
+#endif
+ );
+
+ flags = append_vma_flags(EMPTY_VMA_FLAGS, VMA_READ_BIT, VMA_WRITE_BIT);
+ ASSERT_FLAGS_SAME(&flags, VMA_READ_BIT, VMA_WRITE_BIT);
+
+ return true;
+}
+
static void run_vma_tests(int *num_tests, int *num_fail)
{
TEST(copy_vma);
@@ -569,4 +593,5 @@ static void run_vma_tests(int *num_tests, int *num_fail)
TEST(vma_flags_empty);
TEST(vma_flags_diff);
TEST(vma_flags_and);
+ TEST(append_vma_flags);
}
--
2.53.0
More information about the Linuxppc-dev
mailing list