mirror of https://github.com/acidanthera/audk.git
MdePkg: Adds Protocol for MockRng
This patch adds a protocol for MockRng. This protocol is used to mock the Rng protocol for testing purposes. Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Zhiguang Liu <zhiguang.liu@intel.com> Signed-off-by: Doug Flick [MSFT] <doug.edk2@gmail.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
parent
72a9ef1c8a
commit
4afb939531
|
@ -0,0 +1,48 @@
|
|||
/** @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 *RNGAlgorithm,
|
||||
IN UINTN RNGValueLength,
|
||||
OUT UINT8 *RNGValue
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
extern EFI_RNG_PROTOCOL *gRngProtocol;
|
||||
}
|
||||
|
||||
#endif // MOCK_RNG_H_
|
|
@ -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, 4, 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;
|
||||
}
|
Loading…
Reference in New Issue