Skip to content

Commit 23b5c79

Browse files
remckeerppt
authored andcommitted
memblock tests: update style of comments for memblock_add_*() functions
Update comments in memblock_add_*() functions to match the style used in tests/alloc_*.c by rewording to make the expected outcome more apparent and, if more than one memblock is involved, adding a visual of the memory blocks. Reviewed-by: David Hildenbrand <[email protected]> Signed-off-by: Rebecca Mckeever <[email protected]> Signed-off-by: Mike Rapoport <[email protected]>
1 parent 672c0c5 commit 23b5c79

File tree

1 file changed

+59
-26
lines changed

1 file changed

+59
-26
lines changed

tools/testing/memblock/tests/basic_api.c

Lines changed: 59 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ static int memblock_initialization_check(void)
2626
/*
2727
* A simple test that adds a memory block of a specified base address
2828
* and size to the collection of available memory regions (memblock.memory).
29-
* It checks if a new entry was created and if region counter and total memory
30-
* were correctly updated.
29+
* Expect to create a new entry. The region counter and total memory get
30+
* updated.
3131
*/
3232
static int memblock_add_simple_check(void)
3333
{
@@ -53,10 +53,10 @@ static int memblock_add_simple_check(void)
5353
}
5454

5555
/*
56-
* A simple test that adds a memory block of a specified base address, size
56+
* A simple test that adds a memory block of a specified base address, size,
5757
* NUMA node and memory flags to the collection of available memory regions.
58-
* It checks if the new entry, region counter and total memory size have
59-
* expected values.
58+
* Expect to create a new entry. The region counter and total memory get
59+
* updated.
6060
*/
6161
static int memblock_add_node_simple_check(void)
6262
{
@@ -87,9 +87,15 @@ static int memblock_add_node_simple_check(void)
8787

8888
/*
8989
* A test that tries to add two memory blocks that don't overlap with one
90-
* another. It checks if two correctly initialized entries were added to the
91-
* collection of available memory regions (memblock.memory) and if this
92-
* change was reflected in memblock.memory's total size and region counter.
90+
* another:
91+
*
92+
* | +--------+ +--------+ |
93+
* | | r1 | | r2 | |
94+
* +--------+--------+--------+--------+--+
95+
*
96+
* Expect to add two correctly initialized entries to the collection of
97+
* available memory regions (memblock.memory). The total size and
98+
* region counter fields get updated.
9399
*/
94100
static int memblock_add_disjoint_check(void)
95101
{
@@ -124,11 +130,21 @@ static int memblock_add_disjoint_check(void)
124130
}
125131

126132
/*
127-
* A test that tries to add two memory blocks, where the second one overlaps
128-
* with the beginning of the first entry (that is r1.base < r2.base + r2.size).
129-
* After this, it checks if two entries are merged into one region that starts
130-
* at r2.base and has size of two regions minus their intersection. It also
131-
* verifies the reported total size of the available memory and region counter.
133+
* A test that tries to add two memory blocks r1 and r2, where r2 overlaps
134+
* with the beginning of r1 (that is r1.base < r2.base + r2.size):
135+
*
136+
* | +----+----+------------+ |
137+
* | | |r2 | r1 | |
138+
* +----+----+----+------------+----------+
139+
* ^ ^
140+
* | |
141+
* | r1.base
142+
* |
143+
* r2.base
144+
*
145+
* Expect to merge the two entries into one region that starts at r2.base
146+
* and has size of two regions minus their intersection. The total size of
147+
* the available memory is updated, and the region counter stays the same.
132148
*/
133149
static int memblock_add_overlap_top_check(void)
134150
{
@@ -162,12 +178,21 @@ static int memblock_add_overlap_top_check(void)
162178
}
163179

164180
/*
165-
* A test that tries to add two memory blocks, where the second one overlaps
166-
* with the end of the first entry (that is r2.base < r1.base + r1.size).
167-
* After this, it checks if two entries are merged into one region that starts
168-
* at r1.base and has size of two regions minus their intersection. It verifies
169-
* that memblock can still see only one entry and has a correct total size of
170-
* the available memory.
181+
* A test that tries to add two memory blocks r1 and r2, where r2 overlaps
182+
* with the end of r1 (that is r2.base < r1.base + r1.size):
183+
*
184+
* | +--+------+----------+ |
185+
* | | | r1 | r2 | |
186+
* +--+--+------+----------+--------------+
187+
* ^ ^
188+
* | |
189+
* | r2.base
190+
* |
191+
* r1.base
192+
*
193+
* Expect to merge the two entries into one region that starts at r1.base
194+
* and has size of two regions minus their intersection. The total size of
195+
* the available memory is updated, and the region counter stays the same.
171196
*/
172197
static int memblock_add_overlap_bottom_check(void)
173198
{
@@ -201,11 +226,19 @@ static int memblock_add_overlap_bottom_check(void)
201226
}
202227

203228
/*
204-
* A test that tries to add two memory blocks, where the second one is
205-
* within the range of the first entry (that is r1.base < r2.base &&
206-
* r2.base + r2.size < r1.base + r1.size). It checks if two entries are merged
207-
* into one region that stays the same. The counter and total size of available
208-
* memory are expected to not be updated.
229+
* A test that tries to add two memory blocks r1 and r2, where r2 is
230+
* within the range of r1 (that is r1.base < r2.base &&
231+
* r2.base + r2.size < r1.base + r1.size):
232+
*
233+
* | +-------+--+-----------------------+
234+
* | | |r2| r1 |
235+
* +---+-------+--+-----------------------+
236+
* ^
237+
* |
238+
* r1.base
239+
*
240+
* Expect to merge two entries into one region that stays the same.
241+
* The counter and total size of available memory are not updated.
209242
*/
210243
static int memblock_add_within_check(void)
211244
{
@@ -236,8 +269,8 @@ static int memblock_add_within_check(void)
236269
}
237270

238271
/*
239-
* A simple test that tries to add the same memory block twice. The counter
240-
* and total size of available memory are expected to not be updated.
272+
* A simple test that tries to add the same memory block twice. Expect
273+
* the counter and total size of available memory to not be updated.
241274
*/
242275
static int memblock_add_twice_check(void)
243276
{

0 commit comments

Comments
 (0)