xref: /openbsd/regress/sys/kern/extent/tests (revision d415bd75)
1# $OpenBSD: tests,v 1.6 2019/09/11 12:30:35 kettenis Exp $
2# $NetBSD: tests,v 1.9 2005/03/15 18:27:23 bouyer Exp $
3
4#fill up an extent, should coalesce into one allocation
5extent test1 0 0x4f
6alloc_region 0x00 0x10
7alloc_region 0x20 0x10
8alloc_region 0x40 0x10
9alloc_region 0x10 0x10
10alloc_subregion 0 0x4f 0x10
11print
12
13#check whether subregion is obeyed (PR kern/7539)
14extent test2 0 0x2f EX_NOCOALESCE
15alloc_region 0x00 0x10
16alloc_subregion 0x20 0x2f 0x10
17print
18
19#check overlap into subregion (fixed in 1.25)
20extent test3 0 0x3f EX_NOCOALESCE
21alloc_region 0x00 0x20
22alloc_region 0x30 0x10
23alloc_subregion 0x10 0x3f 0x10
24print
25
26#check overflow in boundary check, before an allocated region (fixed in 1.32)
27extent test4 0xf0000000 0xffffffff
28alloc_region 0xf1000000 0x1
29boundary 0x20000000
30alloc_subregion 0xf0000000 0xffffffff 0x1
31print
32
33#check overflow in boundary check, before the subregion end (fixed in 1.32)
34extent test5 0xf0000000 0xffffffff
35boundary 0x20000000
36alloc_subregion 0xf0000000 0xffffffff 0x1
37print
38
39#check allocation beyond last boundary line (to be fixed)
40# last two allocations should succeed without boundary "fixups"
41extent test6 0 11
42boundary 8
43alloc_subregion 0 11 8
44alloc_subregion 0 11 2
45alloc_subregion 0 11 2
46print
47
48#check allocation beyond last boundary line (to be fixed)
49# last allocation should be bumped to the next boundary and exactly fit
50# the remaining space
51extent test7 0 11
52boundary 8
53alloc_subregion 0 11 7
54alloc_subregion 0 11 4
55print
56
57#don't allocate a region pasts the end of subregion (i.e., the second
58#alloc_subregion should fail).  subr_extent.c prior to rev. 1.43 allocates
59#region starts from 0x10.
60extent test8 0 0x4f EX_NOCOALESCE
61alloc_region 0x30 0x10
62alloc_subregion 0 0xf 0x10
63alloc_subregion 0 0xf 0x10
64print
65
66#When allocating a region with a boundary constraint, check that we properly
67#detect overlaps once the candidate region has been aligned.
68#subr_extent.c prior 1.45 could corrupt the extent map in this situation
69extent test9 0 0x4f
70boundary 0
71alloc_subregion 0 0x10 4
72alloc_subregion 0xd 0x20 2
73boundary 8
74alloc_subregion 0 0x4f 8
75print
76
77#check that free works
78extent test10 0xc0002000 0xffffe000 EX_BOUNDZERO
79boundary 0x10000
80align 0x10000
81alloc_subregion 0xc0002000 0xffffe000 0x2000
82alloc_subregion 0xc0002000 0xffffe000 0x2000
83print
84free 0xc0020000 0x2000
85print
86alloc_subregion 0xc0002000 0xffffe000 0x10000
87print
88#If we have something like that in the EX_NOCOALESCE case:
89#extent `test11' (0x10 - 0x20), flags = 0x2
90#  0x10 - 0x13
91#  0x1e - 0x1f
92#  0x20 - 0x20
93#then a new extent of size 1 could be allocated at 0x20.
94# fixed in 1.51
95extent test11 0x10 0x20 EX_NOCOALESCE
96alloc_subregion 0x10 0x13 0x4
97alloc_subregion 0x1e 0x1f 0x2
98alloc_subregion 0x20 0x20 0x1
99alloc_subregion 0x20 0x20 0x1
100alloc_subregion 0x10 0x20 0x1
101print
102
103# Overlapping regions should result in a failure
104extent test12 0x00000000 0xffffffff
105alloc_region 0xfce00000 0x100
106alloc_region 0xfce00000 0x100000
107
108# But not if we specify EX_CONFLICTOK
109extent test13 0x00000000 0xffffffff
110alloc_region 0xfce00000 0x100
111alloc_region 0xfce00000 0x100000 EX_CONFLICTOK
112print
113
114# Check partial overlap
115extent test14 0x00000000 0xffffffff
116alloc_region 0xfce00000 0x1000
117alloc_region 0xfce00100 0x1000 EX_CONFLICTOK
118print
119
120# Check multiple overlaps
121extent test15 0x00000000 0xffffffff
122alloc_region 0xfce00000 0x100
123alloc_region 0xfee00000 0x100
124alloc_region 0xf8000000 0x8000000 EX_CONFLICTOK
125print
126
127# Check coallescing in combination with overlaps
128extent test16 0x00000000 0xffffffff
129alloc_region 0x0 0xa0000
130alloc_region 0xf0000 0x1ff10000
131alloc_region 0xa0000 0x60000 EX_CONFLICTOK
132print
133
134# Check allocation of a conflicting region in an otherwise filled
135# extent does not trigger an infinite loop
136extent test17 0x00000000 -1L EX_FILLED
137alloc_region 0 0x4000 EX_CONFLICTOK
138print
139
140# Check freeing overkapping regions from a filled extent
141extent test18 0x0000 0xffff EX_FILLED
142free 0x164e 0x2
143free 0x0d00 0xe300 EX_CONFLICTOK
144print
145
146extent test19 0x0000 0xffff EX_FILLED
147free 0x164e 0x2
148free 0x0d00 0xf300 EX_CONFLICTOK
149print
150
151extent test20 0x0000 0xffff EX_FILLED
152free 0x164e 0x2
153free 0x0000 0xf000 EX_CONFLICTOK
154print
155