]> git.proxmox.com Git - mirror_edk2.git/commit - MdePkg/MdePkg.dec
MdePkg/Library/BaseLib: Add BaseLib instance for host based unit tests
authorMichael D Kinney <michael.d.kinney@intel.com>
Fri, 5 Jun 2020 18:21:03 +0000 (11:21 -0700)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 15 Jul 2020 05:25:21 +0000 (05:25 +0000)
commit540fd45f755f1646e019099c90c9f59286604228
tree64c7bb85ad93c8978cabf8c6e140d94459db59c5
parentd3c9e40abcc839f59d56b7fca7787647533d96fe
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>
MdePkg/Library/BaseLib/UnitTestHost.c [new file with mode: 0644]
MdePkg/Library/BaseLib/UnitTestHost.h [new file with mode: 0644]
MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf [new file with mode: 0644]
MdePkg/Library/BaseLib/UnitTestHostBaseLib.uni [new file with mode: 0644]
MdePkg/Library/BaseLib/X86UnitTestHost.c [new file with mode: 0644]
MdePkg/MdePkg.dec
MdePkg/Test/MdePkgHostTest.dsc
MdePkg/Test/UnitTest/Include/Library/UnitTestHostBaseLib.h [new file with mode: 0644]