main.c 1.3 KB

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