[PATCH v3 20/23] tools/testing/vma: update VMA tests to test vma_clear_flags[_mask]()

Lorenzo Stoakes (Oracle)
2026-03-18T15:53:11Z

The tests have existing flag clearing logic, so simply expand this to use
the new VMA-specific flag clearing helpers.

Also correct some trivial formatting issue in a macro define.

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

diff --git a/tools/testing/vma/tests/vma.c b/tools/testing/vma/tests/vma.c
index c73c3a565f1d..754a2da06321 100644
--- a/tools/testing/vma/tests/vma.c
+++ b/tools/testing/vma/tests/vma.c
@@ -347,19 +347,20 @@ static bool test_vma_flags_clear(void)
, 64
#endif
);
- struct vm_area_struct vma;
- struct vm_area_desc desc;
-
- vma.flags = flags;
- desc.vma_flags = flags;
+ struct vm_area_struct vma = {
+ .flags = flags,
+ };
+ struct vm_area_desc desc = {
+ .vma_flags = flags,
+ };

/* Cursory check of _mask() variant, as the helper macros imply. */
vma_flags_clear_mask(&flags, mask);
- vma_flags_clear_mask(&vma.flags, mask);
+ vma_clear_flags_mask(&vma, mask);
vma_desc_clear_flags_mask(&desc, mask);
#if NUM_VMA_FLAG_BITS > 64
ASSERT_FALSE(vma_flags_test_any(&flags, VMA_EXEC_BIT, 64));
- ASSERT_FALSE(vma_flags_test_any(&vma.flags, VMA_EXEC_BIT, 64));
+ ASSERT_FALSE(vma_test_any(&vma, VMA_EXEC_BIT, 64));
ASSERT_FALSE(vma_desc_test_any(&desc, VMA_EXEC_BIT, 64));
/* Reset. */
vma_flags_set(&flags, VMA_EXEC_BIT, 64);
@@ -371,15 +372,15 @@ static bool test_vma_flags_clear(void)
* Clear the flags and assert clear worked, then reset flags back to
* include specified flags.
*/
-#define do_test_and_reset(...) \
- vma_flags_clear(&flags, __VA_ARGS__); \
- vma_flags_clear(&vma.flags, __VA_ARGS__); \
- vma_desc_clear_flags(&desc, __VA_ARGS__); \
- ASSERT_FALSE(vma_flags_test_any(&flags, __VA_ARGS__)); \
- ASSERT_FALSE(vma_flags_test_any(&vma.flags, __VA_ARGS__)); \
- ASSERT_FALSE(vma_desc_test_any(&desc, __VA_ARGS__)); \
- vma_flags_set(&flags, __VA_ARGS__); \
- vma_set_flags(&vma, __VA_ARGS__); \
+#define do_test_and_reset(...) \
+ vma_flags_clear(&flags, __VA_ARGS__); \
+ vma_clear_flags(&vma, __VA_ARGS__); \
+ vma_desc_clear_flags(&desc, __VA_ARGS__); \
+ ASSERT_FALSE(vma_flags_test_any(&flags, __VA_ARGS__)); \
+ ASSERT_FALSE(vma_test_any(&vma, __VA_ARGS__)); \
+ ASSERT_FALSE(vma_desc_test_any(&desc, __VA_ARGS__)); \
+ vma_flags_set(&flags, __VA_ARGS__); \
+ vma_set_flags(&vma, __VA_ARGS__); \
vma_desc_set_flags(&desc, __VA_ARGS__)

/* Single flags. */
--
2.53.0