diff mbox series

[2/3] tools: test vmi.index would be restored on merge failure

Message ID 20241025031847.6274-3-richard.weiyang@gmail.com (mailing list archive)
State New
Headers show
Series mm/vma: miss to restore vmi.index on expansion failure | expand

Commit Message

Wei Yang Oct. 25, 2024, 3:18 a.m. UTC
Add an assertion on restoring the correct index on failure.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
---
 tools/testing/vma/vma.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/tools/testing/vma/vma.c b/tools/testing/vma/vma.c
index c53f220eb6cc..46e8989a90ae 100644
--- a/tools/testing/vma/vma.c
+++ b/tools/testing/vma/vma.c
@@ -243,6 +243,12 @@  static bool test_simple_merge(void)
 	ASSERT_FALSE(vma_link(&mm, vma_left));
 	ASSERT_FALSE(vma_link(&mm, vma_right));
 
+	fail_prealloc = true;
+	vma = merge_new(&vmg);
+	ASSERT_EQ(vma, NULL);
+	ASSERT_EQ(vmi.mas.index, 0x1000);
+
+	fail_prealloc = false;
 	vma = merge_new(&vmg);
 	ASSERT_NE(vma, NULL);