diff --git a/MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockRng.h b/MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockRng.h new file mode 100644 index 0000000000..b54f8a234b --- /dev/null +++ b/MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockRng.h @@ -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 +#include + +extern "C" { + #include + #include +} + +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_ diff --git a/MdePkg/Test/Mock/Library/GoogleTest/Protocol/MockRng.cpp b/MdePkg/Test/Mock/Library/GoogleTest/Protocol/MockRng.cpp new file mode 100644 index 0000000000..7d8b69cc86 --- /dev/null +++ b/MdePkg/Test/Mock/Library/GoogleTest/Protocol/MockRng.cpp @@ -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 + +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; +}