UnitTestFrameworkPkg: Add subhook submodule required for gmock

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4389

Add subhook submodule that is required to hook internal functions
when using gmock.

    https://github.com/Zeex/subhook

Add SubhookLib library class and SubhookLib library instance.
Include the SUBHOOK_STATIC define in the SubhookLib INF file so
it builds as a static library. Also include the SUBHOOK_STATIC
define in SubhookLib.h so all modules using SubhookLib properly
link SubhookLib as a static library.

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Michael Kubacki <mikuback@linux.microsoft.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Chris Johnson <chris.n.johnson@intel.com>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Oliver Smith-Denny <osde@linux.microsoft.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
This commit is contained in:
Chris Johnson 2022-12-21 11:56:07 -08:00 committed by mergify[bot]
parent 6405cd0304
commit 0c6d851d25
9 changed files with 66 additions and 0 deletions

3
.gitmodules vendored
View File

@ -23,3 +23,6 @@
[submodule "UnitTestFrameworkPkg/Library/GoogleTestLib/googletest"]
path = UnitTestFrameworkPkg/Library/GoogleTestLib/googletest
url = https://github.com/google/googletest.git
[submodule "UnitTestFrameworkPkg/Library/SubhookLib/subhook"]
path = UnitTestFrameworkPkg/Library/SubhookLib/subhook
url = https://github.com/Zeex/subhook.git

View File

@ -94,6 +94,7 @@ that are covered by additional licenses.
- `MdeModulePkg/Universal/RegularExpressionDxe/oniguruma <https://github.com/kkos/oniguruma/blob/abfc8ff81df4067f309032467785e06975678f0d/COPYING>`__
- `UnitTestFrameworkPkg/Library/CmockaLib/cmocka <https://github.com/tianocore/edk2-cmocka/blob/f5e2cd77c88d9f792562888d2b70c5a396bfbf7a/COPYING>`__
- `UnitTestFrameworkPkg/Library/GoogleTestLib/googletest <https://github.com/google/googletest/blob/86add13493e5c881d7e4ba77fb91c1f57752b3a4/LICENSE>`__
- `UnitTestFrameworkPkg/Library/SubhookLib/subhook <https://github.com/Zeex/subhook/blob/83d4e1ebef3588fae48b69a7352cc21801cb70bc/LICENSE.txt>`__
- `RedfishPkg/Library/JsonLib/jansson <https://github.com/akheron/jansson/blob/2882ead5bb90cf12a01b07b2c2361e24960fae02/LICENSE>`__
The EDK II Project is composed of packages. The maintainers for each package

View File

@ -0,0 +1,15 @@
/** @file
SubhookLib class with APIs from the subhook project
Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef SUBHOOK_LIB_H_
#define SUBHOOK_LIB_H_
#define SUBHOOK_STATIC
#include <subhook.h>
#endif

View File

@ -0,0 +1,31 @@
## @file
# This module provides Subhook Library implementation.
#
# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
[Defines]
INF_VERSION = 0x00010018
BASE_NAME = SubhookLib
MODULE_UNI_FILE = SubhookLib.uni
FILE_GUID = 70E03378-E140-46A8-8E65-7719DA14A240
MODULE_TYPE = HOST_APPLICATION
VERSION_STRING = 0.1
LIBRARY_CLASS = SubhookLib
#
# VALID_ARCHITECTURES = IA32 X64
#
[Sources]
subhook/subhook.c
[Packages]
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
[BuildOptions]
MSFT:*_*_*_CC_FLAGS == /c /EHsc /Zi /DSUBHOOK_STATIC /Od
GCC:*_*_IA32_CC_FLAGS == -g -c -O0 -m32
GCC:*_*_X64_CC_FLAGS == -g -c -O0 -m64

View File

@ -0,0 +1,11 @@
// /** @file
// This module provides Subhook Library implementation.
//
// Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
// **/
#string STR_MODULE_ABSTRACT #language en-US "Subhook Library implementation"
#string STR_MODULE_DESCRIPTION #language en-US "This module provides Subhook Library implementation."

@ -0,0 +1 @@
Subproject commit 83d4e1ebef3588fae48b69a7352cc21801cb70bc

View File

@ -33,6 +33,7 @@
#
UnitTestFrameworkPkg/Library/CmockaLib/CmockaLib.inf
UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.inf
UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.inf
UnitTestFrameworkPkg/Library/Posix/DebugLibPosix/DebugLibPosix.inf
UnitTestFrameworkPkg/Library/Posix/MemoryAllocationLibPosix/MemoryAllocationLibPosix.inf
UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLibCmocka.inf

View File

@ -20,6 +20,7 @@
Library/CmockaLib/cmocka/include
Library/GoogleTestLib/googletest/googletest/include
Library/GoogleTestLib/googletest/googlemock/include
Library/SubhookLib/subhook
[Includes.Common.Private]
PrivateInclude
@ -34,6 +35,7 @@
## @libraryclass GoogleTest infrastructure
#
GoogleTestLib|Include/Library/GoogleTestLib.h
SubhookLib|Include/Library/SubhookLib.h
[LibraryClasses.Common.Private]
## @libraryclass Provides a unit test result report

View File

@ -15,6 +15,7 @@
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLibNull/BaseCacheMaintenanceLibNull.inf
CmockaLib|UnitTestFrameworkPkg/Library/CmockaLib/CmockaLib.inf
GoogleTestLib|UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.inf
SubhookLib|UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.inf
UnitTestLib|UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLibCmocka.inf
DebugLib|UnitTestFrameworkPkg/Library/Posix/DebugLibPosix/DebugLibPosix.inf
MemoryAllocationLib|UnitTestFrameworkPkg/Library/Posix/MemoryAllocationLibPosix/MemoryAllocationLibPosix.inf