diff options
author | Michael D Kinney <michael.d.kinney@intel.com> | 2020-06-05 11:21:03 -0700 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2020-07-15 05:25:21 +0000 |
commit | 540fd45f755f1646e019099c90c9f59286604228 (patch) | |
tree | 64c7bb85ad93c8978cabf8c6e140d94459db59c5 /MdePkg/MdePkg.dec | |
parent | d3c9e40abcc839f59d56b7fca7787647533d96fe (diff) | |
download | edk2-540fd45f755f1646e019099c90c9f59286604228.tar.gz |
MdePkg/Library/BaseLib: Add BaseLib instance for host based unit tests
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2800
Add a new version of BaseLib that is safe for use from host based
unit test applications. Host based unit test applications may need
to provide implementations of some BaseLib functions that provide
simple emulation to exercise the code under test. The structure
UNIT_TEST_HOST_BASE_LIB is filled in with services that provide
default emulation for BaseLib APIs that would normally generate
exceptions in a host based unit test application. This structure
allows an individual unit test to replace the default emulation of
a BaseLib service with an alternate version that is required by a
specific unit test. A global variable of type UNIT_TEST_HOST_BASE_LIB
is provided through the new UnitTestHostBaseLib library class.
Normally cmocka would be used to mock services the code under
test calls. However, the BaseLib is used by the Unit Test
Framework itself, so using a mocked interface is not possible.
The use of a structure to provide hooks for unit test is not
expected to be a common feature. It should only be required
for libraries that are used by both the Unit Test Framework and
the code under test where the code under test requires a
different behavior than the Unit Test Framework.
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'MdePkg/MdePkg.dec')
-rw-r--r-- | MdePkg/MdePkg.dec | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index 682e61cb88..73f6c24073 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -4,7 +4,7 @@ # It also provides the definitions(including PPIs/PROTOCOLs/GUIDs) of
# EFI1.10/UEFI2.7/PI1.7 and some Industry Standards.
#
-# Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2020, Intel Corporation. All rights reserved.<BR>
# Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
# (C) Copyright 2016 - 2020 Hewlett Packard Enterprise Development LP<BR>
#
@@ -23,6 +23,7 @@ [Includes]
Include
+ Test/UnitTest/Include
[Includes.IA32]
Include/Ia32
@@ -251,6 +252,11 @@ #
UnitTestLib|Include/Library/UnitTestLib.h
+ ## @libraryclass Extension to BaseLib for host based unit tests that allows a
+ # subset of BaseLib services to be hooked for emulation.
+ #
+ UnitTestHostBaseLib|Test/UnitTest/Include/Library/UnitTestHostBaseLib.h
+
[LibraryClasses.IA32, LibraryClasses.X64]
## @libraryclass Abstracts both S/W SMI generation and detection.
##
|