mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
UnitTestFrameworkPkg: FunctionMockLib: Do not support AArch64
Current FunctionMockLib is relying on the subhoob module to support the backend operation by bitbanging the binary post-disassembly. However subhook module is a x64 centric module and does not support AArch64 usage. This change removes the mock function support for AArch64. The functionality will need other solutions to be properly supported. Signed-off-by: Kun Qin <kun.qin@microsoft.com>
This commit is contained in:
parent
26800658df
commit
56e1e04202
4 changed files with 34 additions and 18 deletions
|
|
@ -8,7 +8,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <Library/GoogleTestLib.h>
|
||||
#include <Library/SubhookLib.h>
|
||||
#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
|
||||
#include <Library/SubhookLib.h>
|
||||
#endif
|
||||
#include <type_traits>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -52,6 +54,7 @@
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
// The below macros are private and should not be used outside this file.
|
||||
|
||||
#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
|
||||
#define MOCK_FUNCTION_HOOK_DECLARATIONS(FUNC) \
|
||||
static subhook::Hook Hook##FUNC; \
|
||||
struct MockContainer_##FUNC { \
|
||||
|
|
@ -59,11 +62,15 @@
|
|||
~MockContainer_##FUNC (); \
|
||||
}; \
|
||||
MockContainer_##FUNC MockContainerInst_##FUNC;
|
||||
#else
|
||||
#define MOCK_FUNCTION_HOOK_DECLARATIONS(FUNC)
|
||||
#endif
|
||||
|
||||
// This definition implements a constructor and destructor inside a nested
|
||||
// class to enable automatic installation of the hooks to the associated
|
||||
// MOCK_FUNC() when the mock object is instantiated in scope and automatic
|
||||
// removal when the instantiated mock object goes out of scope.
|
||||
#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
|
||||
#define MOCK_FUNCTION_HOOK_DEFINITIONS(MOCK, FUNC) \
|
||||
subhook :: Hook MOCK :: Hook##FUNC; \
|
||||
MOCK :: MockContainer_##FUNC :: MockContainer_##FUNC () { \
|
||||
|
|
@ -83,6 +90,9 @@
|
|||
"different return type, arguments, or calling convention. See " \
|
||||
"associated 'MOCK_FUNCTION_INTERNAL_DECLARATION' macro invocation " \
|
||||
"for more details.");
|
||||
#else
|
||||
#define MOCK_FUNCTION_HOOK_DEFINITIONS(MOCK, FUNC)
|
||||
#endif
|
||||
|
||||
#define MOCK_FUNCTION_TYPE_DEFINITIONS(RET_TYPE, FUNC, ARGS) \
|
||||
using FUNC##_ret_type = RET_TYPE; \
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
[LibraryClasses]
|
||||
GoogleTestLib
|
||||
|
||||
[LibraryClasses.IA32, LibraryClasses.X64]
|
||||
SubhookLib
|
||||
|
||||
[Packages]
|
||||
|
|
|
|||
|
|
@ -32,10 +32,12 @@
|
|||
# Build HOST_APPLICATION Libraries
|
||||
#
|
||||
UnitTestFrameworkPkg/Library/CmockaLib/CmockaLib.inf
|
||||
UnitTestFrameworkPkg/Library/FunctionMockLib/FunctionMockLib.inf
|
||||
UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.inf
|
||||
UnitTestFrameworkPkg/Library/Posix/DebugLibPosix/DebugLibPosix.inf
|
||||
UnitTestFrameworkPkg/Library/Posix/MemoryAllocationLibPosix/MemoryAllocationLibPosix.inf
|
||||
UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.inf
|
||||
UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLibCmocka.inf
|
||||
UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/UnitTestDebugAssertLibHost.inf
|
||||
|
||||
[Components.IA32, Components.X64]
|
||||
UnitTestFrameworkPkg/Library/FunctionMockLib/FunctionMockLib.inf
|
||||
UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.inf
|
||||
|
|
|
|||
|
|
@ -37,8 +37,6 @@
|
|||
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLibNull/BaseCacheMaintenanceLibNull.inf
|
||||
CmockaLib|UnitTestFrameworkPkg/Library/CmockaLib/CmockaLib.inf
|
||||
GoogleTestLib|UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.inf
|
||||
SubhookLib|UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.inf
|
||||
FunctionMockLib|UnitTestFrameworkPkg/Library/FunctionMockLib/FunctionMockLib.inf
|
||||
UnitTestLib|UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLibCmocka.inf
|
||||
DebugLib|UnitTestFrameworkPkg/Library/Posix/DebugLibPosix/DebugLibPosix.inf
|
||||
MemoryAllocationLib|UnitTestFrameworkPkg/Library/Posix/MemoryAllocationLibPosix/MemoryAllocationLibPosix.inf
|
||||
|
|
@ -54,19 +52,19 @@
|
|||
# Operating System and Compiler Compatibility Matrix for Host-based unit tests
|
||||
# NOTE: Only NOOPT build target is supported for unit test builds
|
||||
#
|
||||
# +--------------------+--------+----------+------------+-----+----+--------+
|
||||
# | OS/Compiler | VS2019 | CLANGPDB | CLANGDWARF | GCC | XCODE5 |
|
||||
# | | VS2022 | | | GCCNOLTO | |
|
||||
# | | VS2026 | | | | |
|
||||
# +--------------------+--------+----------+------------+----------+--------+
|
||||
# | Windows/VS |IA32/X64| | | | |
|
||||
# | Windows/LLVM/VS | | IA32/X64 | | | |
|
||||
# | Windows/LLVM/MSYS2 | | | X64 | | |
|
||||
# | Windows/LLVM/MINGW | | | IA32/X64 | | |
|
||||
# | Linux/LLVM | | | IA32/X64 | | |
|
||||
# | Linux/GCC | | | | IA32/X64 | |
|
||||
# | macOS/XCODE5 | | | | |IA32/X64|
|
||||
# +--------------------+--------+----------+------------+----------+--------+
|
||||
# +--------------------+--------+----------+------------+------------------+--------+
|
||||
# | OS/Compiler | VS2019 | CLANGPDB | CLANGDWARF | GCC | XCODE5 |
|
||||
# | | VS2022 | | | GCCNOLTO | |
|
||||
# | | VS2026 | | | | |
|
||||
# +--------------------+--------+----------+------------+------------------+--------+
|
||||
# | Windows/VS |IA32/X64| | | | |
|
||||
# | Windows/LLVM/VS | | IA32/X64 | | | |
|
||||
# | Windows/LLVM/MSYS2 | | | X64 | | |
|
||||
# | Windows/LLVM/MINGW | | | IA32/X64 | | |
|
||||
# | Linux/LLVM | | | IA32/X64 | | |
|
||||
# | Linux/GCC | | | | IA32/X64/AARCH64 | |
|
||||
# | macOS/XCODE5 | | | | |IA32/X64|
|
||||
# +--------------------+--------+----------+------------+------------------+--------+
|
||||
#
|
||||
# * Windows/VS: Windows environment with Visual Studio installed
|
||||
# * Windows/LLVM/VS: Windows environment with Visual Studio and LLVM 20.1.8 or
|
||||
|
|
@ -125,6 +123,10 @@
|
|||
!endif
|
||||
!endif
|
||||
|
||||
[LibraryClasses.IA32.HOST_APPLICATION, LibraryClasses.X64.HOST_APPLICATION]
|
||||
SubhookLib|UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.inf
|
||||
FunctionMockLib|UnitTestFrameworkPkg/Library/FunctionMockLib/FunctionMockLib.inf
|
||||
|
||||
[BuildOptions]
|
||||
!if $(WIN_MINGW32_BUILD)
|
||||
GCC:*_CLANGDWARF_IA32_PP_FLAGS = -target i686-w64-mingw32
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue