UnitTestMtrrGetFixedMtrr updated for the case that fixed MtrrLib is not always supported.
Signed-off-by: Yuanhao Xie <yuanhao....@intel.com> Cc: Eric Dong <eric.d...@intel.com> Cc: Rahul Kumar <rahul1.ku...@intel.com> Cc: Gerd Hoffmann <kra...@redhat.com> Cc: Ray Ni <ray...@intel.com> --- UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c b/UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c index de9db4fcb4..2905b091a5 100644 --- a/UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c +++ b/UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c @@ -650,6 +650,19 @@ UnitTestMtrrGetFixedMtrr ( UT_ASSERT_EQUAL ((UINTN)Result, (UINTN)&FixedSettings); UT_ASSERT_MEM_EQUAL (&ExpectedFixedSettings, &FixedSettings, sizeof (ExpectedFixedSettings)); + // + // Negative test case when Fixed MTRRs are not supported + // + SystemParameter.MtrrSupported = TRUE; + SystemParameter.FixedMtrrSupported = FALSE; + InitializeMtrrRegs (&SystemParameter); + + ZeroMem (&FixedSettings, sizeof (FixedSettings)); + ZeroMem (&ExpectedFixedSettings, sizeof (ExpectedFixedSettings)); + Result = MtrrGetFixedMtrr (&FixedSettings); + UT_ASSERT_EQUAL ((UINTN)Result, (UINTN)&FixedSettings); + UT_ASSERT_MEM_EQUAL (&ExpectedFixedSettings, &FixedSettings, sizeof (ExpectedFixedSettings)); + return UNIT_TEST_PASSED; } -- 2.36.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#108565): https://edk2.groups.io/g/devel/message/108565 Mute This Topic: https://groups.io/mt/101331027/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-