UefiCpuPkg/CpuPageTableLib/UnitTest: Add host based unit test

Add host based unit tests for the CpuPageTableLib services.

Unit test focuses on PageTableMap function, containing two kinds of test
cases: manual test case and random test case.
Manual test case creates some corner case to test function PageTableMap.
Random test case generates multiple random memory entries (with random
attribute) as the input of function PageTableMap to get the output
pagetable. Output pagetable will be validated and be parsed to get output
memory entries, and then the input and output memory entries will be
compared to verify the functionality.

The unit test is not perfect yet. There are options for random test, and
some of them control the test coverage, and some option are not ready.
Will enhance in the future.

Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
This commit is contained in:
Zhiguang Liu
2022-06-27 16:58:48 +08:00
committed by mergify[bot]
parent 809b5a3d2a
commit 2812668bfc
9 changed files with 7266 additions and 1 deletions

View File

@@ -20,6 +20,10 @@
[LibraryClasses]
MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
BaseCryptLib|CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf
RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
[PcdsPatchableInModule]
gUefiCpuPkgTokenSpaceGuid.PcdCpuNumberOfReservedVariableMtrrs|0
@@ -29,3 +33,8 @@
# Build HOST_APPLICATION that tests the MtrrLib
#
UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTestHost.inf
#
# Build HOST_APPLICATION that tests the CpuPageTableLib
#
UefiCpuPkg/Library/CpuPageTableLib/UnitTest/CpuPageTableLibUnitTestHost.inf