tests: lib: acpi: Add test verifying assert on devscope overflow
Add test verifying we catch assert() when subsctrucure is too big. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
parent
a7afc87527
commit
eef605d6cc
|
@ -164,7 +164,7 @@ ZTEST(lib_acpi, test_dmar_foreach_devscope_invalid_unit_size)
|
|||
zassert_unreachable("Missed assert catch");
|
||||
}
|
||||
|
||||
ZTEST(lib_acpi, test_dmar_foreach_devscope_invalid_devscope_size)
|
||||
ZTEST(lib_acpi, test_dmar_foreach_devscope_invalid_devscope_size_zero)
|
||||
{
|
||||
ACPI_DMAR_HARDWARE_UNIT *hu = &dmar0.unit0.header;
|
||||
ACPI_DMAR_DEVICE_SCOPE *devscope = &dmar0.unit0.ds0.header;
|
||||
|
@ -182,6 +182,24 @@ ZTEST(lib_acpi, test_dmar_foreach_devscope_invalid_devscope_size)
|
|||
zassert_unreachable("Missed assert catch");
|
||||
}
|
||||
|
||||
ZTEST(lib_acpi, test_dmar_foreach_devscope_invalid_devscope_size_big)
|
||||
{
|
||||
ACPI_DMAR_HARDWARE_UNIT *hu = &dmar0.unit1.header;
|
||||
ACPI_DMAR_DEVICE_SCOPE *devscope = &dmar0.unit1.ds1.header;
|
||||
|
||||
dmar_initialize(&dmar0);
|
||||
|
||||
/* Set invalid device scope size */
|
||||
devscope->Length = sizeof(dmar0.unit1.ds1) + 1;
|
||||
|
||||
expect_assert();
|
||||
|
||||
/* Expect assert, use fake void function as a callback */
|
||||
acpi_dmar_foreach_devscope(hu, devscope_nop, NULL);
|
||||
|
||||
zassert_unreachable("Missed assert catch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Redefine AcpiGetTable to provide our static table
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue