From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web10.2854.1680906059556530823 for ; Fri, 07 Apr 2023 15:20:59 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=DyqfJV3z; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: michael.d.kinney@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680906059; x=1712442059; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oPb5qRkr4/M4U2RNl7rnSnQu24OkKrZU/FSDFBg73TQ=; b=DyqfJV3zuuZ4ng7E3e/2R8rBa99WvGfb1oCE326txJicHR8ekBEZ1/L7 RSPNSQ3Pf1hxIqbIB/yC/eJ9Sbx9o4odLrV2WVvKSa/Blvu+MpPgWi4ZY Hh9lWSV26kk8PCZCCBx0KFcVbPgfhgWkuEHAkav1HrGTZjz0rs8p8+/G7 bOdYd7VZu10S6aBF8kZBs7ecp8s7RaooFbnw5AFgNFCTdoShbjez2Xai3 XFVjSJUq5ejkWAH9rY8Fmx+lXkvRUCeiyT9m0eMmoWXhiINWFWQatSM8w ZTa9sGrpF5MQlhSdBcyHwz5aLSRXmw/i4dGdh+YgzB2Ok7LhgDdHrzp3E w==; X-IronPort-AV: E=McAfee;i="6600,9927,10673"; a="343085636" X-IronPort-AV: E=Sophos;i="5.98,328,1673942400"; d="scan'208";a="343085636" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2023 15:20:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10673"; a="690177458" X-IronPort-AV: E=Sophos;i="5.98,328,1673942400"; d="scan'208";a="690177458" Received: from mdkinney-mobl2.amr.corp.intel.com ([10.209.18.108]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2023 15:20:59 -0700 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Chris Johnson , Andrew Fish , Leif Lindholm , Michael Kubacki , Sean Brogan , Michael Kubacki , Oliver Smith-Denny Subject: [Patch v3 01/12] UnitTestFrameworkPkg: Add subhook submodule required for gmock Date: Fri, 7 Apr 2023 15:20:39 -0700 Message-Id: <20230407222051.1095-2-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.39.1.windows.1 In-Reply-To: <20230407222051.1095-1-michael.d.kinney@intel.com> References: <20230407222051.1095-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Chris Johnson 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 Cc: Leif Lindholm Cc: Michael D Kinney Cc: Michael Kubacki Cc: Sean Brogan Signed-off-by: Chris Johnson Reviewed-by: Leif Lindholm Reviewed-by: Michael Kubacki Reviewed-by: Oliver Smith-Denny Reviewed-by: Michael D Kinney --- .gitmodules | 3 ++ ReadMe.rst | 1 + .../Include/Library/SubhookLib.h | 15 +++++++++ .../Library/SubhookLib/SubhookLib.inf | 31 +++++++++++++++++++ .../Library/SubhookLib/SubhookLib.uni | 11 +++++++ .../Library/SubhookLib/subhook | 1 + .../Test/UnitTestFrameworkPkgHostTest.dsc | 1 + UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec | 2 ++ .../UnitTestFrameworkPkgHost.dsc.inc | 1 + 9 files changed, 66 insertions(+) create mode 100644 UnitTestFrameworkPkg/Include/Library/SubhookLib.h create mode 100644 UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.inf create mode 100644 UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.uni create mode 160000 UnitTestFrameworkPkg/Library/SubhookLib/subhook diff --git a/.gitmodules b/.gitmodules index 8011a88d9d25..fe8a43be93ba 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/ReadMe.rst b/ReadMe.rst index 497d96355908..91b9cf3c5e50 100644 --- a/ReadMe.rst +++ b/ReadMe.rst @@ -94,6 +94,7 @@ that are covered by additional licenses. - `MdeModulePkg/Universal/RegularExpressionDxe/oniguruma `__ - `UnitTestFrameworkPkg/Library/CmockaLib/cmocka `__ - `UnitTestFrameworkPkg/Library/GoogleTestLib/googletest `__ +- `UnitTestFrameworkPkg/Library/SubhookLib/subhook `__ - `RedfishPkg/Library/JsonLib/jansson `__ The EDK II Project is composed of packages. The maintainers for each package diff --git a/UnitTestFrameworkPkg/Include/Library/SubhookLib.h b/UnitTestFrameworkPkg/Include/Library/SubhookLib.h new file mode 100644 index 000000000000..46783adfccfb --- /dev/null +++ b/UnitTestFrameworkPkg/Include/Library/SubhookLib.h @@ -0,0 +1,15 @@ +/** @file + SubhookLib class with APIs from the subhook project + + Copyright (c) 2022, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef SUBHOOK_LIB_H_ +#define SUBHOOK_LIB_H_ + +#define SUBHOOK_STATIC +#include + +#endif diff --git a/UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.inf b/UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.inf new file mode 100644 index 000000000000..a67be890d8cd --- /dev/null +++ b/UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.inf @@ -0,0 +1,31 @@ +## @file +# This module provides Subhook Library implementation. +# +# Copyright (c) 2022, Intel Corporation. All rights reserved.
+# 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 diff --git a/UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.uni b/UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.uni new file mode 100644 index 000000000000..eb61f034047e --- /dev/null +++ b/UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.uni @@ -0,0 +1,11 @@ +// /** @file +// This module provides Subhook Library implementation. +// +// Copyright (c) 2022, Intel Corporation. All rights reserved.
+// 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." diff --git a/UnitTestFrameworkPkg/Library/SubhookLib/subhook b/UnitTestFrameworkPkg/Library/SubhookLib/subhook new file mode 160000 index 000000000000..83d4e1ebef35 --- /dev/null +++ b/UnitTestFrameworkPkg/Library/SubhookLib/subhook @@ -0,0 +1 @@ +Subproject commit 83d4e1ebef3588fae48b69a7352cc21801cb70bc diff --git a/UnitTestFrameworkPkg/Test/UnitTestFrameworkPkgHostTest.dsc b/UnitTestFrameworkPkg/Test/UnitTestFrameworkPkgHostTest.dsc index 708ef7f9ab35..722509c8f26f 100644 --- a/UnitTestFrameworkPkg/Test/UnitTestFrameworkPkgHostTest.dsc +++ b/UnitTestFrameworkPkg/Test/UnitTestFrameworkPkgHostTest.dsc @@ -33,6 +33,7 @@ [Components] # 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 diff --git a/UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec b/UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec index 14e387d63a0f..30b489915d4a 100644 --- a/UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec +++ b/UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec @@ -20,6 +20,7 @@ [Includes] 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 @@ [LibraryClasses] ## @libraryclass GoogleTest infrastructure # GoogleTestLib|Include/Library/GoogleTestLib.h + SubhookLib|Include/Library/SubhookLib.h [LibraryClasses.Common.Private] ## @libraryclass Provides a unit test result report diff --git a/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc b/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc index 7f5dfa30ed60..e77897bd326f 100644 --- a/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc +++ b/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc @@ -15,6 +15,7 @@ [LibraryClasses.common.HOST_APPLICATION] 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 -- 2.39.1.windows.1