[PATCH v2 12/23] tools/testing/vma: test that legacy flag helpers work correctly

Lorenzo Stoakes (Oracle)
2026-03-16T13:10:29Z

Update the existing compare_legacy_flags() predicate function to assert
that legacy_to_vma_flags() and vma_flags_to_legacy() behave as expected.

Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
---
tools/testing/vma/tests/vma.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/tools/testing/vma/tests/vma.c b/tools/testing/vma/tests/vma.c
index 98e465fb1bf2..1fae25170ff7 100644
--- a/tools/testing/vma/tests/vma.c
+++ b/tools/testing/vma/tests/vma.c
@@ -5,6 +5,7 @@ static bool compare_legacy_flags(vm_flags_t legacy_flags, vma_flags_t flags)
const unsigned long legacy_val = legacy_flags;
/* The lower word should contain the precise same value. */
const unsigned long flags_lower = flags.__vma_flags[0];
+ vma_flags_t converted_flags;
#if NUM_VMA_FLAG_BITS > BITS_PER_LONG
int i;

@@ -17,6 +18,11 @@ static bool compare_legacy_flags(vm_flags_t legacy_flags, vma_flags_t flags)

static_assert(sizeof(legacy_flags) == sizeof(unsigned long));

+ /* Assert that legacy flag helpers work correctly. */
+ converted_flags = legacy_to_vma_flags(legacy_flags);
+ ASSERT_FLAGS_SAME_MASK(&converted_flags, flags);
+ ASSERT_EQ(vma_flags_to_legacy(flags), legacy_flags);
+
return legacy_val == flags_lower;
}

--
2.53.0