From d12fd4fcdd3dd0d6b68e8d72a34dd1f23f884f84 Mon Sep 17 00:00:00 2001 From: TsunFeng Date: Wed, 18 Dec 2024 09:49:16 +0800 Subject: [PATCH] Create Mock for SafeIntLib (#1235) --- MdePkg/Test/MdePkgHostTest.dsc | 1 + .../GoogleTest/Library/MockSafeIntLib.h | 1001 +++++++++++++++++ .../MockSafeIntLib/MockSafeIntLib.cpp | 116 ++ .../MockSafeIntLib/MockSafeIntLib.inf | 33 + 4 files changed, 1151 insertions(+) create mode 100644 MdePkg/Test/Mock/Include/GoogleTest/Library/MockSafeIntLib.h create mode 100644 MdePkg/Test/Mock/Library/GoogleTest/MockSafeIntLib/MockSafeIntLib.cpp create mode 100644 MdePkg/Test/Mock/Library/GoogleTest/MockSafeIntLib/MockSafeIntLib.inf diff --git a/MdePkg/Test/MdePkgHostTest.dsc b/MdePkg/Test/MdePkgHostTest.dsc index 4e25b36fb4..dfcd17c166 100644 --- a/MdePkg/Test/MdePkgHostTest.dsc +++ b/MdePkg/Test/MdePkgHostTest.dsc @@ -71,4 +71,5 @@ MdePkg/Test/Mock/Library/GoogleTest/MockPciSegmentLib/MockPciSegmentLib.inf MdePkg/Test/Mock/Library/GoogleTest/MockReportStatusCodeLib/MockReportStatusCodeLib.inf MdePkg/Test/Mock/Library/GoogleTest/MockPostCodeLib/MockPostCodeLib.inf + MdePkg/Test/Mock/Library/GoogleTest/MockSafeIntLib/MockSafeIntLib.inf # MU_CHANGE [END] diff --git a/MdePkg/Test/Mock/Include/GoogleTest/Library/MockSafeIntLib.h b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockSafeIntLib.h new file mode 100644 index 0000000000..32cc85b718 --- /dev/null +++ b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockSafeIntLib.h @@ -0,0 +1,1001 @@ +/** @file MockSafeIntLib.h + Google Test mocks for the SafeInt Library + + Copyright (c) Microsoft Corporation. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef MOCK_INT_SAFE_LIB_H_ +#define MOCK_INT_SAFE_LIB_H_ + +#include +#include + +extern "C" { + #include + #include +} + +struct MockSafeIntLib { + MOCK_INTERFACE_DECLARATION (MockSafeIntLib); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt8ToUint8, + ( + IN INT8 Operand, + OUT UINT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt8ToChar8, + ( + IN INT8 Operand, + OUT CHAR8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt8ToUint16, + ( + IN INT8 Operand, + OUT UINT16 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt8ToUint32, + ( + IN INT8 Operand, + OUT UINT32 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt8ToUintn, + ( + IN INT8 Operand, + OUT UINTN *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt8ToUint64, + ( + IN INT8 Operand, + OUT UINT64 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint8ToInt8, + ( + IN UINT8 Operand, + OUT INT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint8ToChar8, + ( + IN UINT8 Operand, + OUT CHAR8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt16ToInt8, + ( + IN INT16 Operand, + OUT INT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt16ToChar8, + ( + IN INT16 Operand, + OUT CHAR8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt16ToUint8, + ( + IN INT16 Operand, + OUT UINT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt16ToUint16, + ( + IN INT16 Operand, + OUT UINT16 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt16ToUint32, + ( + IN INT16 Operand, + OUT UINT32 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt16ToUintn, + ( + IN INT16 Operand, + OUT UINTN *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt16ToUint64, + ( + IN INT16 Operand, + OUT UINT64 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint16ToInt8, + ( + IN UINT16 Operand, + OUT INT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint16ToChar8, + ( + IN UINT16 Operand, + OUT CHAR8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint16ToUint8, + ( + IN UINT16 Operand, + OUT UINT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint16ToInt16, + ( + IN UINT16 Operand, + OUT INT16 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt32ToInt8, + ( + IN INT32 Operand, + OUT INT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt32ToChar8, + ( + IN INT32 Operand, + OUT CHAR8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt32ToUint8, + ( + IN INT32 Operand, + OUT UINT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt32ToInt16, + ( + IN INT32 Operand, + OUT INT16 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt32ToUint16, + ( + IN INT32 Operand, + OUT UINT16 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt32ToUint32, + ( + IN INT32 Operand, + OUT UINT32 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt32ToUintn, + ( + IN INT32 Operand, + OUT UINTN *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt32ToUint64, + ( + IN INT32 Operand, + OUT UINT64 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint32ToInt8, + ( + IN UINT32 Operand, + OUT INT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint32ToChar8, + ( + IN UINT32 Operand, + OUT CHAR8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint32ToUint8, + ( + IN UINT32 Operand, + OUT UINT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint32ToInt16, + ( + IN UINT32 Operand, + OUT INT16 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint32ToUint16, + ( + IN UINT32 Operand, + OUT UINT16 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint32ToInt32, + ( + IN UINT32 Operand, + OUT INT32 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint32ToIntn, + ( + IN UINT32 Operand, + OUT INTN *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeIntnToInt8, + ( + IN INTN Operand, + OUT INT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeIntnToChar8, + ( + IN INTN Operand, + OUT CHAR8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeIntnToUint8, + ( + IN INTN Operand, + OUT UINT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeIntnToInt16, + ( + IN INTN Operand, + OUT INT16 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeIntnToUint16, + ( + IN INTN Operand, + OUT UINT16 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeIntnToInt32, + ( + IN INTN Operand, + OUT INT32 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeIntnToUint32, + ( + IN INTN Operand, + OUT UINT32 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeIntnToUintn, + ( + IN INTN Operand, + OUT UINTN *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeIntnToUint64, + ( + IN INTN Operand, + OUT UINT64 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUintnToInt8, + ( + IN UINTN Operand, + OUT INT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUintnToChar8, + ( + IN UINTN Operand, + OUT CHAR8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUintnToUint8, + ( + IN UINTN Operand, + OUT UINT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUintnToInt16, + ( + IN UINTN Operand, + OUT INT16 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUintnToUint16, + ( + IN UINTN Operand, + OUT UINT16 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUintnToInt32, + ( + IN UINTN Operand, + OUT INT32 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUintnToUint32, + ( + IN UINTN Operand, + OUT UINT32 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUintnToIntn, + ( + IN UINTN Operand, + OUT INTN *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUintnToInt64, + ( + IN UINTN Operand, + OUT INT64 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt64ToInt8, + ( + IN INT64 Operand, + OUT INT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt64ToChar8, + ( + IN INT64 Operand, + OUT CHAR8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt64ToUint8, + ( + IN INT64 Operand, + OUT UINT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt64ToInt16, + ( + IN INT64 Operand, + OUT INT16 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt64ToUint16, + ( + IN INT64 Operand, + OUT UINT16 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt64ToInt32, + ( + IN INT64 Operand, + OUT INT32 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt64ToUint32, + ( + IN INT64 Operand, + OUT UINT32 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt64ToIntn, + ( + IN INT64 Operand, + OUT INTN *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt64ToUintn, + ( + IN INT64 Operand, + OUT UINTN *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt64ToUint64, + ( + IN INT64 Operand, + OUT UINT64 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint64ToInt8, + ( + IN UINT64 Operand, + OUT INT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint64ToChar8, + ( + IN UINT64 Operand, + OUT CHAR8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint64ToUint8, + ( + IN UINT64 Operand, + OUT UINT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint64ToInt16, + ( + IN UINT64 Operand, + OUT INT16 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint64ToUint16, + ( + IN UINT64 Operand, + OUT UINT16 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint64ToInt32, + ( + IN UINT64 Operand, + OUT INT32 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint64ToUint32, + ( + IN UINT64 Operand, + OUT UINT32 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint64ToIntn, + ( + IN UINT64 Operand, + OUT INTN *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint64ToUintn, + ( + IN UINT64 Operand, + OUT UINTN *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint64ToInt64, + ( + IN UINT64 Operand, + OUT INT64 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint8Add, + ( + IN UINT8 Augend, + IN UINT8 Addend, + OUT UINT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint16Add, + ( + IN UINT16 Augend, + IN UINT16 Addend, + OUT UINT16 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint32Add, + ( + IN UINT32 Augend, + IN UINT32 Addend, + OUT UINT32 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUintnAdd, + ( + IN UINTN Augend, + IN UINTN Addend, + OUT UINTN *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint64Add, + ( + IN UINT64 Augend, + IN UINT64 Addend, + OUT UINT64 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint8Sub, + ( + IN UINT8 Minuend, + IN UINT8 Subtrahend, + OUT UINT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint16Sub, + ( + IN UINT16 Minuend, + IN UINT16 Subtrahend, + OUT UINT16 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint32Sub, + ( + IN UINT32 Minuend, + IN UINT32 Subtrahend, + OUT UINT32 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUintnSub, + ( + IN UINTN Minuend, + IN UINTN Subtrahend, + OUT UINTN *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint64Sub, + ( + IN UINT64 Minuend, + IN UINT64 Subtrahend, + OUT UINT64 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint8Mult, + ( + IN UINT8 Multiplicand, + IN UINT8 Multiplier, + OUT UINT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint16Mult, + ( + IN UINT16 Multiplicand, + IN UINT16 Multiplier, + OUT UINT16 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint32Mult, + ( + IN UINT32 Multiplicand, + IN UINT32 Multiplier, + OUT UINT32 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUintnMult, + ( + IN UINTN Multiplicand, + IN UINTN Multiplier, + OUT UINTN *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeUint64Mult, + ( + IN UINT64 Multiplicand, + IN UINT64 Multiplier, + OUT UINT64 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt8Add, + ( + IN INT8 Augend, + IN INT8 Addend, + OUT INT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeChar8Add, + ( + IN CHAR8 Augend, + IN CHAR8 Addend, + OUT CHAR8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt16Add, + ( + IN INT16 Augend, + IN INT16 Addend, + OUT INT16 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt32Add, + ( + IN INT32 Augend, + IN INT32 Addend, + OUT INT32 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeIntnAdd, + ( + IN INTN Augend, + IN INTN Addend, + OUT INTN *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt64Add, + ( + IN INT64 Augend, + IN INT64 Addend, + OUT INT64 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt8Sub, + ( + IN INT8 Minuend, + IN INT8 Subtrahend, + OUT INT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeChar8Sub, + ( + IN CHAR8 Minuend, + IN CHAR8 Subtrahend, + OUT CHAR8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt16Sub, + ( + IN INT16 Minuend, + IN INT16 Subtrahend, + OUT INT16 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt32Sub, + ( + IN INT32 Minuend, + IN INT32 Subtrahend, + OUT INT32 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeIntnSub, + ( + IN INTN Minuend, + IN INTN Subtrahend, + OUT INTN *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt64Sub, + ( + IN INT64 Minuend, + IN INT64 Subtrahend, + OUT INT64 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt8Mult, + ( + IN INT8 Multiplicand, + IN INT8 Multiplier, + OUT INT8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeChar8Mult, + ( + IN CHAR8 Multiplicand, + IN CHAR8 Multiplier, + OUT CHAR8 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt16Mult, + ( + IN INT16 Multiplicand, + IN INT16 Multiplier, + OUT INT16 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt32Mult, + ( + IN INT32 Multiplicand, + IN INT32 Multiplier, + OUT INT32 *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeIntnMult, + ( + IN INTN Multiplicand, + IN INTN Multiplier, + OUT INTN *Result + ) + ); + + MOCK_FUNCTION_DECLARATION ( + RETURN_STATUS, + SafeInt64Mult, + ( + IN INT64 Multiplicand, + IN INT64 Multiplier, + OUT INT64 *Result + ) + ); +}; + +#endif diff --git a/MdePkg/Test/Mock/Library/GoogleTest/MockSafeIntLib/MockSafeIntLib.cpp b/MdePkg/Test/Mock/Library/GoogleTest/MockSafeIntLib/MockSafeIntLib.cpp new file mode 100644 index 0000000000..07b34cf1f0 --- /dev/null +++ b/MdePkg/Test/Mock/Library/GoogleTest/MockSafeIntLib/MockSafeIntLib.cpp @@ -0,0 +1,116 @@ +/** @file MockSafeIntLib.cpp + Google Test mocks for SafeIntLib + + Copyright (c) Microsoft Corporation. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include + +MOCK_INTERFACE_DEFINITION (MockSafeIntLib); + +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt8ToUint8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt8ToChar8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt8ToUint16, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt8ToUint32, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt8ToUintn, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt8ToUint64, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint8ToInt8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint8ToChar8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt16ToInt8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt16ToChar8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt16ToUint8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt16ToUint16, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt16ToUint32, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt16ToUintn, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt16ToUint64, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint16ToInt8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint16ToChar8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint16ToUint8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint16ToInt16, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt32ToInt8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt32ToChar8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt32ToUint8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt32ToInt16, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt32ToUint16, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt32ToUint32, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt32ToUintn, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt32ToUint64, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint32ToInt8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint32ToChar8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint32ToUint8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint32ToInt16, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint32ToUint16, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint32ToInt32, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint32ToIntn, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeIntnToInt8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeIntnToChar8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeIntnToUint8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeIntnToInt16, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeIntnToUint16, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeIntnToInt32, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeIntnToUint32, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeIntnToUintn, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeIntnToUint64, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUintnToInt8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUintnToChar8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUintnToUint8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUintnToInt16, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUintnToUint16, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUintnToInt32, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUintnToUint32, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUintnToIntn, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUintnToInt64, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt64ToInt8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt64ToChar8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt64ToUint8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt64ToInt16, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt64ToUint16, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt64ToInt32, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt64ToUint32, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt64ToIntn, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt64ToUintn, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt64ToUint64, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint64ToInt8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint64ToChar8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint64ToUint8, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint64ToInt16, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint64ToUint16, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint64ToInt32, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint64ToUint32, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint64ToIntn, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint64ToUintn, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint64ToInt64, 2, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint8Add, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint16Add, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint32Add, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUintnAdd, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint64Add, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint8Sub, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint16Sub, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint32Sub, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUintnSub, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint64Sub, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint8Mult, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint16Mult, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint32Mult, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUintnMult, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeUint64Mult, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt8Add, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeChar8Add, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt16Add, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt32Add, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeIntnAdd, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt64Add, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt8Sub, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeChar8Sub, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt16Sub, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt32Sub, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeIntnSub, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt64Sub, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt8Mult, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeChar8Mult, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt16Mult, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt32Mult, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeIntnMult, 3, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockSafeIntLib, SafeInt64Mult, 3, EFIAPI); diff --git a/MdePkg/Test/Mock/Library/GoogleTest/MockSafeIntLib/MockSafeIntLib.inf b/MdePkg/Test/Mock/Library/GoogleTest/MockSafeIntLib/MockSafeIntLib.inf new file mode 100644 index 0000000000..345c005b8d --- /dev/null +++ b/MdePkg/Test/Mock/Library/GoogleTest/MockSafeIntLib/MockSafeIntLib.inf @@ -0,0 +1,33 @@ +## @file MockSafeIntLib.inf +# Mock implementation of the SafeInt library +# +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = MockSafeIntLib + FILE_GUID = 318369D7-D942-47FC-A4BC-F881DEE5085E + MODULE_TYPE = HOST_APPLICATION + VERSION_STRING = 1.0 + LIBRARY_CLASS = SafeIntLib + PI_SPECIFICATION_VERSION = 0x0001000A + +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + MockSafeIntLib.cpp + +[Packages] + MdePkg/MdePkg.dec + UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec + +[LibraryClasses] + GoogleTestLib + +[BuildOptions] + MSFT:*_*_*_CC_FLAGS = /EHsc