-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AdvLoggerPkg: Generated Mock Libraries using external tool #461
Closed
apop5
wants to merge
2
commits into
microsoft:release/202311
from
apop5:personal/apop5/addlibrarymocks
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
AdvLoggerPkg/Test/Mock/Include/GoogleTest/Library/MockAdvancedLoggerAccessLib.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** @file | ||
Google Test mocks for AdvancedLoggerAccessLib | ||
|
||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#ifndef MOCK_ADVANCED_LOGGER_ACCESS_LIB_H_ | ||
#define MOCK_ADVANCED_LOGGER_ACCESS_LIB_H_ | ||
|
||
#include <Library/GoogleTestLib.h> | ||
#include <Library/FunctionMockLib.h> | ||
extern "C" { | ||
#include <PiPei.h> | ||
#include <PiDxe.h> | ||
#include <PiSmm.h> | ||
#include <PiMm.h> | ||
#include <Uefi.h> | ||
#include <Library/AdvancedLoggerAccessLib.h> | ||
} | ||
|
||
struct MockAdvancedLoggerAccessLib { | ||
MOCK_INTERFACE_DECLARATION (MockAdvancedLoggerAccessLib); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
AdvancedLoggerAccessLibGetNextMessageBlock, | ||
(IN ADVANCED_LOGGER_ACCESS_MESSAGE_BLOCK_ENTRY *BlockEntry) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
AdvancedLoggerAccessLibGetNextFormattedLine, | ||
(IN ADVANCED_LOGGER_ACCESS_MESSAGE_LINE_ENTRY *LineEntry) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
AdvancedLoggerAccessLibReset, | ||
(IN ADVANCED_LOGGER_ACCESS_MESSAGE_LINE_ENTRY *AccessEntry) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
AdvancedLoggerAccessLibUnitTestInitialize, | ||
(IN ADVANCED_LOGGER_PROTOCOL *TestProtocol OPTIONAL, | ||
IN UINT16 MaxMessageSize) | ||
); | ||
}; | ||
|
||
#endif |
40 changes: 40 additions & 0 deletions
40
AdvLoggerPkg/Test/Mock/Include/GoogleTest/Library/MockAdvancedLoggerHdwPortLib.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** @file | ||
Google Test mocks for AdvancedLoggerHdwPortLib | ||
|
||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#ifndef MOCK_ADVANCED_LOGGER_HDW_PORT_LIB_H_ | ||
#define MOCK_ADVANCED_LOGGER_HDW_PORT_LIB_H_ | ||
|
||
#include <Library/GoogleTestLib.h> | ||
#include <Library/FunctionMockLib.h> | ||
extern "C" { | ||
#include <PiPei.h> | ||
#include <PiDxe.h> | ||
#include <PiSmm.h> | ||
#include <PiMm.h> | ||
#include <Uefi.h> | ||
#include <Library/AdvancedLoggerHdwPortLib.h> | ||
} | ||
|
||
struct MockAdvancedLoggerHdwPortLib { | ||
MOCK_INTERFACE_DECLARATION (MockAdvancedLoggerHdwPortLib); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
AdvancedLoggerHdwPortInitialize, | ||
() | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
UINTN, | ||
AdvancedLoggerHdwPortWrite, | ||
(IN UINTN DebugLevel, | ||
IN UINT8 *Buffer, | ||
IN UINTN NumberOfBytes) | ||
); | ||
}; | ||
|
||
#endif |
34 changes: 34 additions & 0 deletions
34
AdvLoggerPkg/Test/Mock/Include/GoogleTest/Library/MockAdvancedLoggerLib.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** @file | ||
Google Test mocks for AdvancedLoggerLib | ||
|
||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#ifndef MOCK_ADVANCED_LOGGER_LIB_H_ | ||
#define MOCK_ADVANCED_LOGGER_LIB_H_ | ||
|
||
#include <Library/GoogleTestLib.h> | ||
#include <Library/FunctionMockLib.h> | ||
extern "C" { | ||
#include <PiPei.h> | ||
#include <PiDxe.h> | ||
#include <PiSmm.h> | ||
#include <PiMm.h> | ||
#include <Uefi.h> | ||
#include <Library/AdvancedLoggerLib.h> | ||
} | ||
|
||
struct MockAdvancedLoggerLib { | ||
MOCK_INTERFACE_DECLARATION (MockAdvancedLoggerLib); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
VOID, | ||
AdvancedLoggerWrite, | ||
(IN UINTN ErrorLevel, | ||
IN CONST CHAR8 *Buffer, | ||
IN UINTN NumberOfBytes) | ||
); | ||
}; | ||
|
||
#endif |
19 changes: 19 additions & 0 deletions
19
.../Test/Mock/Library/GoogleTest/MockAdvancedLoggerAccessLib/MockAdvancedLoggerAccessLib.cpp
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,19 @@ | ||
/** @file | ||
Google Test mocks for AdvancedLoggerAccessLib | ||
|
||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#include <GoogleTest/Library/MockAdvancedLoggerAccessLib.h> | ||
|
||
// | ||
// Global Variables that are not const | ||
// | ||
|
||
MOCK_INTERFACE_DEFINITION (MockAdvancedLoggerAccessLib); | ||
|
||
MOCK_FUNCTION_DEFINITION (MockAdvancedLoggerAccessLib, AdvancedLoggerAccessLibGetNextMessageBlock, 1, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockAdvancedLoggerAccessLib, AdvancedLoggerAccessLibGetNextFormattedLine, 1, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockAdvancedLoggerAccessLib, AdvancedLoggerAccessLibReset, 1, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockAdvancedLoggerAccessLib, AdvancedLoggerAccessLibUnitTestInitialize, 2, EFIAPI); |
34 changes: 34 additions & 0 deletions
34
.../Test/Mock/Library/GoogleTest/MockAdvancedLoggerAccessLib/MockAdvancedLoggerAccessLib.inf
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,34 @@ | ||
## @file | ||
# Google Test mocks for AdvancedLoggerAccessLib | ||
# | ||
# Copyright (c) Microsoft Corporation. | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
## | ||
|
||
[Defines] | ||
INF_VERSION = 0x00010005 | ||
BASE_NAME = MockAdvancedLoggerAccessLib | ||
FILE_GUID = 476554ce-578a-5a9d-87ad-52d1fa226108 | ||
MODULE_TYPE = HOST_APPLICATION | ||
VERSION_STRING = 1.0 | ||
LIBRARY_CLASS = AdvancedLoggerAccessLib | ||
|
||
# | ||
# The following information is for reference only and not required by the build tools. | ||
# | ||
# VALID_ARCHITECTURES = IA32 X64 | ||
# | ||
|
||
[Sources] | ||
MockAdvancedLoggerAccessLib.cpp | ||
|
||
[Packages] | ||
AdvLoggerPkg/AdvLoggerPkg.dec | ||
MdePkg/MdePkg.dec | ||
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec | ||
|
||
[LibraryClasses] | ||
GoogleTestLib | ||
|
||
[BuildOptions] | ||
MSFT:*_*_*_CC_FLAGS = /EHs /bigobj | ||
apop5 marked this conversation as resolved.
Show resolved
Hide resolved
|
17 changes: 17 additions & 0 deletions
17
...est/Mock/Library/GoogleTest/MockAdvancedLoggerHdwPortLib/MockAdvancedLoggerHdwPortLib.cpp
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,17 @@ | ||
/** @file | ||
Google Test mocks for AdvancedLoggerHdwPortLib | ||
|
||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#include <GoogleTest/Library/MockAdvancedLoggerHdwPortLib.h> | ||
|
||
// | ||
// Global Variables that are not const | ||
// | ||
|
||
MOCK_INTERFACE_DEFINITION (MockAdvancedLoggerHdwPortLib); | ||
|
||
MOCK_FUNCTION_DEFINITION (MockAdvancedLoggerHdwPortLib, AdvancedLoggerHdwPortInitialize, 0, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockAdvancedLoggerHdwPortLib, AdvancedLoggerHdwPortWrite, 3, EFIAPI); |
34 changes: 34 additions & 0 deletions
34
...est/Mock/Library/GoogleTest/MockAdvancedLoggerHdwPortLib/MockAdvancedLoggerHdwPortLib.inf
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,34 @@ | ||
## @file | ||
# Google Test mocks for AdvancedLoggerHdwPortLib | ||
# | ||
# Copyright (c) Microsoft Corporation. | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
## | ||
|
||
[Defines] | ||
INF_VERSION = 0x00010005 | ||
BASE_NAME = MockAdvancedLoggerHdwPortLib | ||
FILE_GUID = 88069e60-ae8b-5d10-a654-9aa6ce8b328c | ||
MODULE_TYPE = HOST_APPLICATION | ||
VERSION_STRING = 1.0 | ||
LIBRARY_CLASS = AdvancedLoggerHdwPortLib | ||
|
||
# | ||
# The following information is for reference only and not required by the build tools. | ||
# | ||
# VALID_ARCHITECTURES = IA32 X64 | ||
# | ||
|
||
[Sources] | ||
MockAdvancedLoggerHdwPortLib.cpp | ||
|
||
[Packages] | ||
AdvLoggerPkg/AdvLoggerPkg.dec | ||
MdePkg/MdePkg.dec | ||
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec | ||
|
||
[LibraryClasses] | ||
GoogleTestLib | ||
|
||
[BuildOptions] | ||
MSFT:*_*_*_CC_FLAGS = /EHs /bigobj |
16 changes: 16 additions & 0 deletions
16
AdvLoggerPkg/Test/Mock/Library/GoogleTest/MockAdvancedLoggerLib/MockAdvancedLoggerLib.cpp
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,16 @@ | ||
/** @file | ||
Google Test mocks for AdvancedLoggerLib | ||
|
||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#include <GoogleTest/Library/MockAdvancedLoggerLib.h> | ||
|
||
// | ||
// Global Variables that are not const | ||
// | ||
|
||
MOCK_INTERFACE_DEFINITION (MockAdvancedLoggerLib); | ||
|
||
MOCK_FUNCTION_DEFINITION (MockAdvancedLoggerLib, AdvancedLoggerWrite, 3, EFIAPI); |
34 changes: 34 additions & 0 deletions
34
AdvLoggerPkg/Test/Mock/Library/GoogleTest/MockAdvancedLoggerLib/MockAdvancedLoggerLib.inf
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,34 @@ | ||
## @file | ||
# Google Test mocks for AdvancedLoggerLib | ||
# | ||
# Copyright (c) Microsoft Corporation. | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
## | ||
|
||
[Defines] | ||
INF_VERSION = 0x00010005 | ||
BASE_NAME = MockAdvancedLoggerLib | ||
FILE_GUID = 068a7898-bd23-5155-b794-2343a7309f42 | ||
MODULE_TYPE = HOST_APPLICATION | ||
VERSION_STRING = 1.0 | ||
LIBRARY_CLASS = AdvancedLoggerLib | ||
|
||
# | ||
# The following information is for reference only and not required by the build tools. | ||
# | ||
# VALID_ARCHITECTURES = IA32 X64 | ||
# | ||
|
||
[Sources] | ||
MockAdvancedLoggerLib.cpp | ||
|
||
[Packages] | ||
AdvLoggerPkg/AdvLoggerPkg.dec | ||
MdePkg/MdePkg.dec | ||
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec | ||
|
||
[LibraryClasses] | ||
GoogleTestLib | ||
|
||
[BuildOptions] | ||
MSFT:*_*_*_CC_FLAGS = /EHs /bigobj |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the mocks can largely be auto generated by a tool now (I presume, haven't tried it yet), do you think there's much value to checking in the files until there's accompanying tests?
Main concern being that doing this at scale might invite dead code into the codebase which comes with those cons - bloat, prone to go stale, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the advanced logger case, waiting is fine because the package isn't really consumed by other packages.
In the case of packages that are externally consumed, it would be useful to get the mocked libraries/protocols created even before there are unit tests that consume them.
I will mark this as draft until some unit tests are created.