Skip to content

Commit

Permalink
Added mock functions for TimerLib
Browse files Browse the repository at this point in the history
  • Loading branch information
v-bhavanisu authored and os-d committed Jun 20, 2024
1 parent 87b10e6 commit 5a22ca6
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
29 changes: 29 additions & 0 deletions UefiCpuPkg/Test/Mock/Include/GoogleTest/Library/MockTimerLib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/** @file MockTimerLib.h
Google Test mocks for TimerLib
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#ifndef MOCK_TIMER_LIB_H_
#define MOCK_TIMER_LIB_H_

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

struct MockTimerLib {
MOCK_INTERFACE_DECLARATION (MockTimerLib);

MOCK_FUNCTION_DECLARATION (
UINTN,
MicroSecondDelay,
(
IN UINTN MicroSeconds
)
);
};

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

#include <GoogleTest/Library/MockTimerLib.h>

MOCK_INTERFACE_DEFINITION (MockTimerLib);
MOCK_FUNCTION_DEFINITION (MockTimerLib, MicroSecondDelay, 1, EFIAPI);
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## @file MockTimerLib.inf
# Google Test mocks for TimerLib
#
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: BSD-2-Clause-Patent
##

[Defines]
INF_VERSION = 0x00010005
BASE_NAME = MockTimerLib
FILE_GUID = CF06C23E-5B46-4CC9-A5AE-794E0E58A564
MODULE_TYPE = HOST_APPLICATION
VERSION_STRING = 1.0
LIBRARY_CLASS = TimerLib

#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64
#

[Sources]
MockTimerLib.cpp

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

[LibraryClasses]
GoogleTestLib

[BuildOptions]
MSFT:*_*_*_CC_FLAGS = /EHsc
1 change: 1 addition & 0 deletions UefiCpuPkg/Test/UefiCpuPkgHostTest.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@
# Build HOST_APPLICATION Libraries for GoogleTests
#
UefiCpuPkg/Test/Mock/Library/GoogleTest/MockLocalApicLib/MockLocalApicLib.inf
UefiCpuPkg/Test/Mock/Library/GoogleTest/MockTimerLib/MockTimerLib.inf

0 comments on commit 5a22ca6

Please sign in to comment.