From e17f459af2594b6ccbb8d56064737b8a23414b76 Mon Sep 17 00:00:00 2001 From: Ray Ni Date: Wed, 20 May 2020 05:13:11 +0800 Subject: UefiCpuPkg/MtrrLib/UnitTest: Add host based unit test Add host based unit tests for the MtrrLib services. The BaseLib services AsmCpuid(), AsmReadMsr64(), and AsmWriteMsr64() are hooked and provide simple emulation of the CPUID leafs and MSRs required by the MtrrLib to run as a host based unit test. Test cases are developed for each of the API. For the most important APIs MtrrSetMemoryAttributesInMtrrSettings() and MtrrSetMemoryAttributeInMtrrSettings(), random inputs are generated and fed to the APIs to make sure the implementation is good. The test application accepts an optional parameter which specifies how many iterations of feeding random inputs to the two APIs. The overall number of test cases increases when the iteration increases. Default iteration is 10 when no parameter is specified. Signed-off-by: Ray Ni Signed-off-by: Michael D Kinney Signed-off-by: Ming Shao Cc: Michael D Kinney Cc: Eric Dong Cc: Laszlo Ersek Cc: Ming Shao Cc: Sean Brogan Cc: Bret Barkelew Cc: Jiewen Yao --- UefiCpuPkg/Test/UefiCpuPkgHostTest.dsc | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 UefiCpuPkg/Test/UefiCpuPkgHostTest.dsc (limited to 'UefiCpuPkg/Test') diff --git a/UefiCpuPkg/Test/UefiCpuPkgHostTest.dsc b/UefiCpuPkg/Test/UefiCpuPkgHostTest.dsc new file mode 100644 index 0000000..8a5c456 --- /dev/null +++ b/UefiCpuPkg/Test/UefiCpuPkgHostTest.dsc @@ -0,0 +1,31 @@ +## @file +# UefiCpuPkg DSC file used to build host-based unit tests. +# +# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + PLATFORM_NAME = UefiCpuPkgHostTest + PLATFORM_GUID = E00B9599-5B74-4FF7-AB9F-8183FB13B2F9 + PLATFORM_VERSION = 0.1 + DSC_SPECIFICATION = 0x00010005 + OUTPUT_DIRECTORY = Build/UefiCpuPkg/HostTest + SUPPORTED_ARCHITECTURES = IA32|X64 + BUILD_TARGETS = NOOPT + SKUID_IDENTIFIER = DEFAULT + +!include UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc + +[LibraryClasses] + MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf + +[PcdsPatchableInModule] + gUefiCpuPkgTokenSpaceGuid.PcdCpuNumberOfReservedVariableMtrrs|0 + +[Components] + # + # Build HOST_APPLICATION that tests the MtrrLib + # + UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTestHost.inf -- cgit v1.1