1 // SPDX-License-Identifier: GPL-2.0-or-later 2 3 #include "shared.h" 4 /* 5 * Directly import the VMA implementation here. Our vma_internal.h wrapper 6 * provides userland-equivalent functionality for everything vma.c uses. 7 */ 8 #include "../../../mm/vma_init.c" 9 #include "../../../mm/vma_exec.c" 10 #include "../../../mm/vma.c" 11 12 /* Tests are included directly so they can test static functions in mm/vma.c. */ 13 #include "tests/merge.c" 14 #include "tests/mmap.c" 15 #include "tests/vma.c" 16 17 /* Helper functions which utilise static kernel functions. */ 18 19 struct vm_area_struct *merge_existing(struct vma_merge_struct *vmg) 20 { 21 struct vm_area_struct *vma; 22 23 vma = vma_merge_existing_range(vmg); 24 if (vma) 25 vma_assert_attached(vma); 26 return vma; 27 } 28 29 int attach_vma(struct mm_struct *mm, struct vm_area_struct *vma) 30 { 31 int res; 32 33 res = vma_link(mm, vma); 34 if (!res) 35 vma_assert_attached(vma); 36 return res; 37 } 38 39 /* Main test running which invokes tests/ *.c runners. */ 40 int main(void) 41 { 42 int num_tests = 0, num_fail = 0; 43 44 maple_tree_init(); 45 vma_state_init(); 46 47 run_merge_tests(&num_tests, &num_fail); 48 run_mmap_tests(&num_tests, &num_fail); 49 run_vma_tests(&num_tests, &num_fail); 50 51 printf("%d tests run, %d passed, %d failed.\n", 52 num_tests, num_tests - num_fail, num_fail); 53 54 return num_fail == 0 ? EXIT_SUCCESS : EXIT_FAILURE; 55 } 56