]> xenbits.xensource.com Git - ovmf.git/commitdiff
UnitTestFrameworkPkg: Add subhook submodule required for gmock
authorChris Johnson <chris.n.johnson@intel.com>
Wed, 21 Dec 2022 19:56:07 +0000 (11:56 -0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 10 Apr 2023 05:59:02 +0000 (05:59 +0000)
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>
.gitmodules
ReadMe.rst
UnitTestFrameworkPkg/Include/Library/SubhookLib.h [new file with mode: 0644]
UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.inf [new file with mode: 0644]
UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.uni [new file with mode: 0644]
UnitTestFrameworkPkg/Library/SubhookLib/subhook [new submodule]
UnitTestFrameworkPkg/Test/UnitTestFrameworkPkgHostTest.dsc
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc

index 8011a88d9d2551ba69a44008c686195fbfceffca..fe8a43be93bac3cd45e896d377500c1d8200d787 100644 (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
index 497d96355908f7abeeefe27544a0c704e38af26d..91b9cf3c5e50dc980859394bbd00365a32afdec9 100644 (file)
@@ -94,6 +94,7 @@ that are covered by additional licenses.
 -  `MdeModulePkg/Universal/RegularExpressionDxe/oniguruma <https://github.com/kkos/oniguruma/blob/abfc8ff81df4067f309032467785e06975678f0d/COPYING>`__\r
 -  `UnitTestFrameworkPkg/Library/CmockaLib/cmocka <https://github.com/tianocore/edk2-cmocka/blob/f5e2cd77c88d9f792562888d2b70c5a396bfbf7a/COPYING>`__\r
 -  `UnitTestFrameworkPkg/Library/GoogleTestLib/googletest <https://github.com/google/googletest/blob/86add13493e5c881d7e4ba77fb91c1f57752b3a4/LICENSE>`__\r
+-  `UnitTestFrameworkPkg/Library/SubhookLib/subhook <https://github.com/Zeex/subhook/blob/83d4e1ebef3588fae48b69a7352cc21801cb70bc/LICENSE.txt>`__\r
 -  `RedfishPkg/Library/JsonLib/jansson <https://github.com/akheron/jansson/blob/2882ead5bb90cf12a01b07b2c2361e24960fae02/LICENSE>`__\r
 \r
 The EDK II Project is composed of packages. The maintainers for each package\r
diff --git a/UnitTestFrameworkPkg/Include/Library/SubhookLib.h b/UnitTestFrameworkPkg/Include/Library/SubhookLib.h
new file mode 100644 (file)
index 0000000..46783ad
--- /dev/null
@@ -0,0 +1,15 @@
+/** @file\r
+  SubhookLib class with APIs from the subhook project\r
+\r
+  Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef SUBHOOK_LIB_H_\r
+#define SUBHOOK_LIB_H_\r
+\r
+#define SUBHOOK_STATIC\r
+#include <subhook.h>\r
+\r
+#endif\r
diff --git a/UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.inf b/UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.inf
new file mode 100644 (file)
index 0000000..a67be89
--- /dev/null
@@ -0,0 +1,31 @@
+## @file\r
+#  This module provides Subhook Library implementation.\r
+#\r
+#  Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r
+#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION     = 0x00010018\r
+  BASE_NAME       = SubhookLib\r
+  MODULE_UNI_FILE = SubhookLib.uni\r
+  FILE_GUID       = 70E03378-E140-46A8-8E65-7719DA14A240\r
+  MODULE_TYPE     = HOST_APPLICATION\r
+  VERSION_STRING  = 0.1\r
+  LIBRARY_CLASS   = SubhookLib\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
+#\r
+\r
+[Sources]\r
+  subhook/subhook.c\r
+\r
+[Packages]\r
+  UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec\r
+\r
+[BuildOptions]\r
+  MSFT:*_*_*_CC_FLAGS   == /c /EHsc /Zi /DSUBHOOK_STATIC /Od\r
+  GCC:*_*_IA32_CC_FLAGS == -g -c -O0 -m32\r
+  GCC:*_*_X64_CC_FLAGS  == -g -c -O0 -m64\r
diff --git a/UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.uni b/UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.uni
new file mode 100644 (file)
index 0000000..eb61f03
--- /dev/null
@@ -0,0 +1,11 @@
+// /** @file\r
+// This module provides Subhook Library implementation.\r
+//\r
+// Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r
+// SPDX-License-Identifier: BSD-2-Clause-Patent\r
+//\r
+// **/\r
+\r
+#string STR_MODULE_ABSTRACT             #language en-US "Subhook Library implementation"\r
+\r
+#string STR_MODULE_DESCRIPTION          #language en-US "This module provides Subhook Library implementation."\r
diff --git a/UnitTestFrameworkPkg/Library/SubhookLib/subhook b/UnitTestFrameworkPkg/Library/SubhookLib/subhook
new file mode 160000 (submodule)
index 0000000..83d4e1e
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit 83d4e1ebef3588fae48b69a7352cc21801cb70bc
index 708ef7f9ab3512a755bf1866cbc5492b42605131..722509c8f26f03ec92a24bb32ca668a1564be9d8 100644 (file)
@@ -33,6 +33,7 @@
   #\r
   UnitTestFrameworkPkg/Library/CmockaLib/CmockaLib.inf\r
   UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.inf\r
+  UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.inf\r
   UnitTestFrameworkPkg/Library/Posix/DebugLibPosix/DebugLibPosix.inf\r
   UnitTestFrameworkPkg/Library/Posix/MemoryAllocationLibPosix/MemoryAllocationLibPosix.inf\r
   UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLibCmocka.inf\r
index 14e387d63a0fa04150eecbdd016a61f797ef8f6c..30b489915d4a9bf5e516e371d2f11a56dd7a2e76 100644 (file)
@@ -20,6 +20,7 @@
   Library/CmockaLib/cmocka/include\r
   Library/GoogleTestLib/googletest/googletest/include\r
   Library/GoogleTestLib/googletest/googlemock/include\r
+  Library/SubhookLib/subhook\r
 \r
 [Includes.Common.Private]\r
   PrivateInclude\r
@@ -34,6 +35,7 @@
   ## @libraryclass GoogleTest infrastructure\r
   #\r
   GoogleTestLib|Include/Library/GoogleTestLib.h\r
+  SubhookLib|Include/Library/SubhookLib.h\r
 \r
 [LibraryClasses.Common.Private]\r
   ## @libraryclass Provides a unit test result report\r
index 7f5dfa30ed60461345b7812d6400bce4e7d3d2de..e77897bd326f1c7abcf1537f3d92e5054bf1ae83 100644 (file)
@@ -15,6 +15,7 @@
   CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLibNull/BaseCacheMaintenanceLibNull.inf\r
   CmockaLib|UnitTestFrameworkPkg/Library/CmockaLib/CmockaLib.inf\r
   GoogleTestLib|UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.inf\r
+  SubhookLib|UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.inf\r
   UnitTestLib|UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLibCmocka.inf\r
   DebugLib|UnitTestFrameworkPkg/Library/Posix/DebugLibPosix/DebugLibPosix.inf\r
   MemoryAllocationLib|UnitTestFrameworkPkg/Library/Posix/MemoryAllocationLibPosix/MemoryAllocationLibPosix.inf\r