diff options
| author | Alexander Gryanko <xpahos@gmail.com> | 2025-06-22 07:29:41 +0300 |
|---|---|---|
| committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2025-08-07 01:18:26 +0000 |
| commit | 1c3a22059b2da70832d4097141281d309a025c37 (patch) | |
| tree | e00a0ad3a3158aac158f56a00379bd3354d5042c | |
| parent | 3f453cd7aa6419b8743d18b62415bcb8c54b1bfd (diff) | |
| download | edk2-1c3a22059b2da70832d4097141281d309a025c37.tar.gz edk2-1c3a22059b2da70832d4097141281d309a025c37.zip | |
MdeModulePkg: added SecurityManagementLib mock
Added Google Mock test support for SecurityManagementLib
Signed-off-by: Alexander Gryanko <xpahos@gmail.com>
4 files changed, 104 insertions, 0 deletions
diff --git a/MdeModulePkg/Test/MdeModulePkgHostTest.dsc b/MdeModulePkg/Test/MdeModulePkgHostTest.dsc index 0643e38c48..236137470a 100644 --- a/MdeModulePkg/Test/MdeModulePkgHostTest.dsc +++ b/MdeModulePkg/Test/MdeModulePkgHostTest.dsc @@ -71,3 +71,4 @@ MdeModulePkg/Test/Mock/Library/GoogleTest/MockHiiLib/MockHiiLib.inf
MdeModulePkg/Test/Mock/Library/GoogleTest/MockPciHostBridgeLib/MockPciHostBridgeLib.inf
MdeModulePkg/Test/Mock/Library/GoogleTest/MockVariablePolicyHelperLib/MockVariablePolicyHelperLib.inf
+ MdeModulePkg/Test/Mock/Library/GoogleTest/MockSecurityManagementLib/MockSecurityManagementLib.inf
diff --git a/MdeModulePkg/Test/Mock/Include/GoogleTest/Library/MockSecurityManagementLib.h b/MdeModulePkg/Test/Mock/Include/GoogleTest/Library/MockSecurityManagementLib.h new file mode 100644 index 0000000000..59ec205186 --- /dev/null +++ b/MdeModulePkg/Test/Mock/Include/GoogleTest/Library/MockSecurityManagementLib.h @@ -0,0 +1,54 @@ +/** @file
+ Google Test mocks for DevicePathLib
+
+ Copyright (c) 2025, Yandex. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef MOCK_SECURITY_MANAGEMENT_LIB_H_
+#define MOCK_SECURITY_MANAGEMENT_LIB_LIB_H_
+
+#include <Library/GoogleTestLib.h>
+#include <Library/FunctionMockLib.h>
+extern "C" {
+ #include <Uefi.h>
+ #include <Library/SecurityManagementLib.h>
+}
+
+struct MockSecurityManagementLib {
+ MOCK_INTERFACE_DECLARATION (MockSecurityManagementLib);
+
+ MOCK_FUNCTION_DECLARATION (
+ EFI_STATUS,
+ RegisterSecurityHandler,
+ (IN SECURITY_FILE_AUTHENTICATION_STATE_HANDLER SecurityHandler,
+ IN UINT32 AuthenticationOperation)
+ );
+
+ MOCK_FUNCTION_DECLARATION (
+ EFI_STATUS,
+ ExecuteSecurityHandlers,
+ (IN UINT32 AuthenticationStatus,
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *FilePath)
+ );
+
+ MOCK_FUNCTION_DECLARATION (
+ EFI_STATUS,
+ RegisterSecurity2Handler,
+ (IN SECURITY2_FILE_AUTHENTICATION_HANDLER Security2Handler,
+ IN UINT32 AuthenticationOperation)
+ );
+
+ MOCK_FUNCTION_DECLARATION (
+ EFI_STATUS,
+ ExecuteSecurity2Handlers,
+ (IN UINT32 AuthenticationOperation,
+ IN UINT32 AuthenticationStatus,
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *File OPTIONAL,
+ IN VOID *FileBuffer,
+ IN UINTN FileSize,
+ IN BOOLEAN BootPolicy)
+ );
+};
+
+#endif // MOCK_SECURITY_MANAGEMENT_LIB_H_
diff --git a/MdeModulePkg/Test/Mock/Library/GoogleTest/MockSecurityManagementLib/MockSecurityManagementLib.cpp b/MdeModulePkg/Test/Mock/Library/GoogleTest/MockSecurityManagementLib/MockSecurityManagementLib.cpp new file mode 100644 index 0000000000..fa3b24bca5 --- /dev/null +++ b/MdeModulePkg/Test/Mock/Library/GoogleTest/MockSecurityManagementLib/MockSecurityManagementLib.cpp @@ -0,0 +1,15 @@ +/** @file
+ Google Test mocks for SecurityManagementLib
+
+ Copyright (c) 2025, Yandex. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <GoogleTest/Library/MockSecurityManagementLib.h>
+
+MOCK_INTERFACE_DEFINITION (MockSecurityManagementLib);
+
+MOCK_FUNCTION_DEFINITION (MockSecurityManagementLib, RegisterSecurityHandler, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockSecurityManagementLib, ExecuteSecurityHandlers, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockSecurityManagementLib, RegisterSecurity2Handler, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockSecurityManagementLib, ExecuteSecurity2Handlers, 6, EFIAPI);
diff --git a/MdeModulePkg/Test/Mock/Library/GoogleTest/MockSecurityManagementLib/MockSecurityManagementLib.inf b/MdeModulePkg/Test/Mock/Library/GoogleTest/MockSecurityManagementLib/MockSecurityManagementLib.inf new file mode 100644 index 0000000000..d64e28c5c4 --- /dev/null +++ b/MdeModulePkg/Test/Mock/Library/GoogleTest/MockSecurityManagementLib/MockSecurityManagementLib.inf @@ -0,0 +1,34 @@ +## @file
+# Google Test mocks for SecurityManagementLib
+#
+# Copyright (c) 2025, Yandex. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = MockSecurityManagementLib
+ FILE_GUID = 22FF8498-3FE9-495B-81B7-6595145F5832
+ MODULE_TYPE = HOST_APPLICATION
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = SecurityManagementLib
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ MockSecurityManagementLib.cpp
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
+
+[LibraryClasses]
+ GoogleTestLib
+
+[BuildOptions]
+ MSFT:*_*_*_CC_FLAGS = /EHsc
|
