Skip to content

Commit

Permalink
Added mock IpmiSelLib files (#263)
Browse files Browse the repository at this point in the history
## Description

Added mock IpmiSelLib for use in GoogleTests

For details on how to complete these options and their meaning refer to
[CONTRIBUTING.md](https://github.com/microsoft/mu/blob/HEAD/CONTRIBUTING.md).

- [ ] Impacts functionality?
- [ ] Impacts security?
- [ ] Breaking change?
- [ ] Includes tests?
- [ ] Includes documentation?

## How This Was Tested
Added to a GoogleTest and verified functionality

## Integration Instructions
N/A
  • Loading branch information
v-bhavanisu authored Oct 18, 2024
1 parent 62ed307 commit 1e925a3
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 0 deletions.
1 change: 1 addition & 0 deletions IpmiFeaturePkg/IpmiFeaturePkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

[Includes]
Include
Test/Mock/Include

[LibraryClasses]
IpmiBaseLib|Include/Library/IpmiBaseLib.h
Expand Down
5 changes: 5 additions & 0 deletions IpmiFeaturePkg/Test/IpmiFeaturePkgHostTest.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,8 @@
#

MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf

#
# Build HOST_APPLICATION Libraries With GoogleTest
#
IpmiFeaturePkg/Test/Mock/Library/GoogleTest/MockIpmiSelLib/MockIpmiSelLib.inf
109 changes: 109 additions & 0 deletions IpmiFeaturePkg/Test/Mock/Include/GoogleTest/Library/MockIpmiSelLib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/** @file MockIpmiSelLib.h
Google Test mocks for IpmiSelLib
Copyright (c) Microsoft Corporation
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#ifndef MOCK_IPMI_SEL_LIB_H_
#define MOCK_IPMI_SEL_LIB_H_

#include <Library/GoogleTestLib.h>
#include <Library/FunctionMockLib.h>
extern "C" {
#include <Uefi.h>
#include <Library/IpmiSelLib.h>
}

struct MockIpmiSelLib {
MOCK_INTERFACE_DECLARATION (MockIpmiSelLib);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
SelAddSystemEntry,
(
IN OUT UINT16 *RecordId OPTIONAL,
IN UINT8 SensorType,
IN UINT8 SensorNumber,
IN UINT8 EventDirType,
IN UINT8 Data0,
IN UINT8 Data1,
IN UINT8 Data2
)
);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
SelAddOemEntry,
(
IN OUT UINT16 *RecordId OPTIONAL,
IN UINT8 RecordType,
IN UINT8 Data[6]
)
);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
SelAddOemEntryEx,
(
IN OUT UINT16 *RecordId OPTIONAL,
IN UINT8 RecordType,
IN UINT8 ManufacturerId[3],
IN UINT8 Data[6]
)
);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
SelAddOemEntryNoTimestamp,
(
IN OUT UINT16 *RecordId OPTIONAL,
IN UINT8 RecordType,
IN UINT8 Data[13]
)
);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
SelClear,
(
BOOLEAN AwaitClear
)
);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
SelGetTime,
(
OUT UINT32 *Time
)
);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
SelSetTime,
(
IN UINT32 Time
)
);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
SelGetInfo,
(
OUT SEL_INFO *SelInfo
)
);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
SelGetEntry,
(
IN UINT16 RecordId,
OUT SEL_RECORD *Record,
OUT UINT16 *NextRecordId OPTIONAL
)
);
};

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/** @file MockIpmiSelLib.cpp
Google Test mocks for IpmiSelLib
Copyright (c) Microsoft Corporation
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#include <GoogleTest/Library/MockIpmiSelLib.h>

MOCK_INTERFACE_DEFINITION (MockIpmiSelLib);
MOCK_FUNCTION_DEFINITION (MockIpmiSelLib, SelAddSystemEntry, 7, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockIpmiSelLib, SelAddOemEntry, 3, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockIpmiSelLib, SelAddOemEntryEx, 4, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockIpmiSelLib, SelAddOemEntryNoTimestamp, 3, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockIpmiSelLib, SelClear, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockIpmiSelLib, SelGetTime, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockIpmiSelLib, SelSetTime, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockIpmiSelLib, SelGetInfo, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockIpmiSelLib, SelGetEntry, 3, EFIAPI);
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## @file MockIpmiSelLib.inf
# Google Test mocks for IpmiSelLib
#
# Copyright (c) Microsoft Corporation
# SPDX-License-Identifier: BSD-2-Clause-Patent
##

[Defines]
INF_VERSION = 0x00010005
BASE_NAME = MockIpmiSelLib
FILE_GUID = DA4D1EA2-79FE-459A-94A5-1F4750C50BD7
MODULE_TYPE = HOST_APPLICATION
VERSION_STRING = 1.0
LIBRARY_CLASS = IpmiSelLib
PI_SPECIFICATION_VERSION = 0x0001000A

#
# VALID_ARCHITECTURES = IA32 X64
#

[Sources]
MockIpmiSelLib.cpp

[Packages]
MdePkg/MdePkg.dec
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
IpmiFeaturePkg/IpmiFeaturePkg.dec

[LibraryClasses]
GoogleTestLib

[BuildOptions]
MSFT:*_*_*_CC_FLAGS = /EHsc

0 comments on commit 1e925a3

Please sign in to comment.