Skip to content

Add Gmocks #11014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Add Gmocks #11014

wants to merge 4 commits into from

Conversation

VivianNK
Copy link
Contributor

@VivianNK VivianNK commented Apr 25, 2025

Description

Re-opened from #5950
Waiting on #10608

  1. Add mock functions to existing mocks
  2. Remove cpp files for existing protocol mocks MockHash2 and MockRng.
  3. Adds gmocks for the following libraries and protocols:

Libraries

MdeModulePkg

  • PlatformHookLib

MdePkg

  • IoLib
  • MemoryAllocationLib
  • MmServicesTableLib
  • SmmServicesTableLib
  • UefiRuntimeLib
  • SmmCpu

UefiCpuPkg

  • LocalApicLib
  • TimerLib

Protocols

MdeModulePkg

  • SmmVarCheck

MdePkg

  • DebugPort
  • IsaHsc
  • NvmeExpressPassthru
  • PciIoProtocol
  • ServiceBinding
  • SmBios
  • SmmBase2
  • SmmCpu
  • UsbIo

  • Breaking change?
  • Impacts security?
  • Includes tests?

How This Was Tested

CI and Unit test execution

Integration Instructions

  • The cpp files for mock protocols MockHash2 and MockRng were removed and the logic was moved to the header files. Any test consuming these mock protocols will need to update their inf to remove the cpp file as a source.
  • The instantiation of mocks for all protocols and PPIs have been removed from their header file and now need to be instantiated using the new macro found in the mock header file. Please see PxeBcDhcp6GoogleTest.cpp with an example for MockEfiRngProtocol

@VivianNK VivianNK changed the title 2405 gmocks Add Gmocks for unit tests Apr 25, 2025
@github-actions github-actions bot added the impact:breaking-change This change breaks existing APIs impacting build or boot. label Apr 25, 2025
v-bhavanisu and others added 4 commits April 28, 2025 13:12
Added a gmocks for GoogleTests

Signed-off-by: Vivian Nowka-Keane <[email protected]>
Co-authored-by: Vivian Nowka-Keane <[email protected]>
Various libraries and protocols mocked. Including:
- PcdLib
- PciIo
- SmmBase2
- Smbio
- UsbIo
- NvmExpressPassthru
- IsaHc
- ServiceBinding
- DebugPort
- MockUefiDevicePathLib
- PcdLib

Additionally, existing mocks had more functions added.

The cpp files for mock protocols MockHash2 and MockRng were removed and
the logic was moved to the header files. Any test consuming these mock
protocols will need to update their inf to remove the cpp file as a
source.

Co-authored-by: Aaron Pop <[email protected]>
Co-authored-by: Bhavani Subramanian <[email protected]>
Co-authored-by: Oliver Smith-Denny <[email protected]>
Co-authored-by: TsunFeng <[email protected]>
Co-authored-by: Vivian Nowka-Keane <[email protected]>
Co-authored-by: yhsu3 <[email protected]>
Signed-off-by: Vivian Nowka-Keane <[email protected]>
Use new mock protocol instantiator

Signed-off-by: Vivian Nowka-Keane <[email protected]>
@VivianNK VivianNK changed the title Add Gmocks for unit tests Add Gmocks May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact:breaking-change This change breaks existing APIs impacting build or boot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants