From bf28b4538ebbe1278ae39db95ced07969e3ff6bc Mon Sep 17 00:00:00 2001 From: Doug Flick Date: Fri, 3 Nov 2023 14:52:11 -0400 Subject: [PATCH] MdePkg/GoogleTest: Add GetTime() RT service mock interface (#607) ## Description This change is required to allow test's that depend on the google test mock function gRT_GetTime to function. - [ ] Impacts functionality? - **Functionality** - Does the change ultimately impact how firmware functions? - Examples: Add a new library, publish a new PPI, update an algorithm, ... - [ ] Impacts security? - [ ] Breaking change? - [ ] Includes tests? - [ ] Includes documentation? ## How This Was Tested This was tested on a test that is currently not public. ## Integration Instructions N/A --- .../Library/MockUefiRuntimeServicesTableLib.h | 8 ++++++++ .../MockUefiRuntimeServicesTableLib.cpp | 16 ++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/MdePkg/Test/Mock/Include/GoogleTest/Library/MockUefiRuntimeServicesTableLib.h b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockUefiRuntimeServicesTableLib.h index afdfc6b855..9a39278fad 100644 --- a/MdePkg/Test/Mock/Include/GoogleTest/Library/MockUefiRuntimeServicesTableLib.h +++ b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockUefiRuntimeServicesTableLib.h @@ -10,6 +10,7 @@ #include #include + extern "C" { #include #include @@ -37,6 +38,13 @@ struct MockUefiRuntimeServicesTableLib { IN UINTN DataSize, IN VOID *Data) ); + + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + gRT_GetTime, + (OUT EFI_TIME *Time, + OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL) + ); }; #endif diff --git a/MdePkg/Test/Mock/Library/GoogleTest/MockUefiRuntimeServicesTableLib/MockUefiRuntimeServicesTableLib.cpp b/MdePkg/Test/Mock/Library/GoogleTest/MockUefiRuntimeServicesTableLib/MockUefiRuntimeServicesTableLib.cpp index ecd1ba8236..ba41e87220 100644 --- a/MdePkg/Test/Mock/Library/GoogleTest/MockUefiRuntimeServicesTableLib/MockUefiRuntimeServicesTableLib.cpp +++ b/MdePkg/Test/Mock/Library/GoogleTest/MockUefiRuntimeServicesTableLib/MockUefiRuntimeServicesTableLib.cpp @@ -6,15 +6,15 @@ **/ #include -MOCK_INTERFACE_DEFINITION(MockUefiRuntimeServicesTableLib); +MOCK_INTERFACE_DEFINITION (MockUefiRuntimeServicesTableLib); -MOCK_FUNCTION_DEFINITION(MockUefiRuntimeServicesTableLib, gRT_GetVariable, 5, EFIAPI); -MOCK_FUNCTION_DEFINITION(MockUefiRuntimeServicesTableLib, gRT_SetVariable, 5, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockUefiRuntimeServicesTableLib, gRT_GetVariable, 5, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockUefiRuntimeServicesTableLib, gRT_SetVariable, 5, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockUefiRuntimeServicesTableLib, gRT_GetTime, 2, EFIAPI); -static EFI_RUNTIME_SERVICES localRt = { - {0}, // EFI_TABLE_HEADER - - NULL, // EFI_GET_TIME +static EFI_RUNTIME_SERVICES localRt = { + { 0 }, // EFI_TABLE_HEADER + gRT_GetTime, // EFI_GET_TIME NULL, // EFI_SET_TIME NULL, // EFI_GET_WAKEUP_TIME NULL, // EFI_SET_WAKEUP_TIME @@ -36,5 +36,5 @@ static EFI_RUNTIME_SERVICES localRt = { }; extern "C" { - EFI_RUNTIME_SERVICES* gRT = &localRt; +EFI_RUNTIME_SERVICES *gRT = &localRt; }