mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-11-07 04:36:52 -10:00
subr_physmem_test: add tests for two edge-cases
Help validate my assertion that "physmem will never report empty ranges". Part of this is covered by the existing tests, which check the merging of adjacent/overlapping regions. The other part is to ensure that addition of zero-sized ranges is ignored. The physmem implementation also includes logic to ignore the first physical page of memory (physical addresses 0 to PAGE_SIZE-1). Add a second test case for this. Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D45914
This commit is contained in:
1 parent
185039d272
commit
1b5ec2e466
1 file changed
+43
@@ -160,11 +160,54 @@ ATF_TC_BODY(hwregion_unordered, tc)
|
||||
ATF_CHECK_EQ(avail[1], 3 * PAGE_SIZE);
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(hwregion_ignore_empty);
|
||||
ATF_TC_BODY(hwregion_ignore_empty, tc)
|
||||
{
|
||||
vm_paddr_t avail[4];
|
||||
size_t len;
|
||||
|
||||
/* Add a region. */
|
||||
physmem_hardware_region(PAGE_SIZE, 2 * PAGE_SIZE);
|
||||
|
||||
/* Add full zero range (ignored) */
|
||||
physmem_hardware_region(0, 0);
|
||||
|
||||
/* Add a zero-sized range (ignored) */
|
||||
physmem_hardware_region(4 * PAGE_SIZE, 0);
|
||||
|
||||
len = physmem_avail(avail, nitems(avail));
|
||||
ATF_CHECK_EQ(len, 2);
|
||||
ATF_CHECK_EQ(avail[0], PAGE_SIZE);
|
||||
ATF_CHECK_EQ(avail[1], 3 * PAGE_SIZE);
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(hwregion_ignore_page0);
|
||||
ATF_TC_BODY(hwregion_ignore_page0, tc)
|
||||
{
|
||||
vm_paddr_t avail[4];
|
||||
size_t len;
|
||||
|
||||
/*
|
||||
* Physical addresses [0, PAGE_SIZE) are unusable in the VM layer.
|
||||
*
|
||||
* physmem will truncate this from the beginning of an otherwise valid
|
||||
* memory range; test that this is the case.
|
||||
*/
|
||||
physmem_hardware_region(0, 2 * PAGE_SIZE);
|
||||
|
||||
len = physmem_avail(avail, 4);
|
||||
ATF_CHECK_EQ(len, 2);
|
||||
ATF_CHECK_EQ(avail[0], PAGE_SIZE);
|
||||
ATF_CHECK_EQ(avail[1], 2 * PAGE_SIZE);
|
||||
}
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
|
||||
ATF_TP_ADD_TC(tp, hwregion);
|
||||
ATF_TP_ADD_TC(tp, hwregion_exclude);
|
||||
ATF_TP_ADD_TC(tp, hwregion_unordered);
|
||||
ATF_TP_ADD_TC(tp, hwregion_ignore_empty);
|
||||
ATF_TP_ADD_TC(tp, hwregion_ignore_page0);
|
||||
return (atf_no_error());
|
||||
}
|
||||
Reference in new issue
Block a user