Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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
17int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
18
19/* Helper functions which utilise static kernel functions. */
20
21struct vm_area_struct *merge_existing(struct vma_merge_struct *vmg)
22{
23 struct vm_area_struct *vma;
24
25 vma = vma_merge_existing_range(vmg);
26 if (vma)
27 vma_assert_attached(vma);
28 return vma;
29}
30
31int attach_vma(struct mm_struct *mm, struct vm_area_struct *vma)
32{
33 int res;
34
35 res = vma_link(mm, vma);
36 if (!res)
37 vma_assert_attached(vma);
38 return res;
39}
40
41/* Main test running which invokes tests/ *.c runners. */
42int main(void)
43{
44 int num_tests = 0, num_fail = 0;
45
46 maple_tree_init();
47 vma_state_init();
48
49 run_merge_tests(&num_tests, &num_fail);
50 run_mmap_tests(&num_tests, &num_fail);
51 run_vma_tests(&num_tests, &num_fail);
52
53 printf("%d tests run, %d passed, %d failed.\n",
54 num_tests, num_tests - num_fail, num_fail);
55
56 return num_fail == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
57}