-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding MockRNG to the Google Test Mock (#668)
# Preface Please ensure you have read the [contribution docs](https://github.com/microsoft/mu/blob/master/CONTRIBUTING.md) prior to submitting the pull request. In particular, [pull request guidelines](https://github.com/microsoft/mu/blob/master/CONTRIBUTING.md#pull-request-best-practices). ## Description Adds MockRNG to the Google Test Mock For each item, place an "x" in between `[` and `]` if true. Example: `[x]`. _(you can also check items in the GitHub UI)_ - [ ] Impacts functionality? - **Functionality** - No - [ ] Impacts security? - **Security** - No - [ ] Breaking change? - **Breaking change** - No - [ ] Includes tests? - **Tests** - No - [ ] Includes documentation? - **Documentation** - No ## How This Was Tested Local Tests ## Integration Instructions N/A
- Loading branch information
Showing
3 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** @file | ||
This file declares a mock of Rng Protocol. | ||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#ifndef MOCK_RNG_H | ||
#define MOCK_RNG_H | ||
|
||
#include <Library/GoogleTestLib.h> | ||
#include <Library/FunctionMockLib.h> | ||
|
||
extern "C" { | ||
#include <Uefi.h> | ||
#include <Protocol\Rng.h> | ||
} | ||
|
||
struct MockRng { | ||
MOCK_INTERFACE_DECLARATION (MockRng); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS | ||
GetInfo ( | ||
IN EFI_RNG_PROTOCOL *This, | ||
IN OUT UINTN *RNGAlgorithmListSize, | ||
OUT EFI_RNG_ALGORITHM *RNGAlgorithmList | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS | ||
GetRNG ( | ||
IN EFI_RNG_PROTOCOL *This, | ||
IN EFI_RNG_ALGORITHM *RNGAlgorithmList, | ||
IN UINTN RNGAlgorithmListSize, | ||
IN OUT UINT8 *RandomNumber, | ||
IN UINTN RandomNumberLength | ||
) | ||
); | ||
}; | ||
|
||
extern "C" { | ||
extern EFI_RNG_PROTOCOL *gRngProtocol; | ||
} | ||
|
||
#endif // MOCK_RNG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** @file MockRng.cpp | ||
Google Test mock for Rng Protocol | ||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#include <GoogleTest/Protocol/MockRng.h> | ||
|
||
MOCK_INTERFACE_DEFINITION (MockRng); | ||
MOCK_FUNCTION_DEFINITION (MockRng, GetInfo, 3, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockRng, GetRng, 5, EFIAPI); | ||
|
||
EFI_RNG_PROTOCOL RNG_PROTOCOL_INSTANCE = { | ||
GetInfo, // EFI_RNG_GET_INFO | ||
GetRng // EFI_RNG_GET_RNG | ||
}; | ||
|
||
extern "C" { | ||
EFI_RNG_PROTOCOL *gRngProtocol = &RNG_PROTOCOL_INSTANCE; | ||
} |