TianoCore EDK2 master
Loading...
Searching...
No Matches
DxeResetSystemLibUnitTest.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <Uefi.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UnitTestLib.h>
#include <Library/ResetSystemLib.h>

Go to the source code of this file.

Macros

#define UNIT_TEST_APP_NAME   "DxeResetSystemLib Unit Tests"
 
#define UNIT_TEST_APP_VERSION   "1.0"
 

Functions

STATIC VOID EFIAPI MockResetSystem (IN EFI_RESET_TYPE ResetType, IN EFI_STATUS ResetStatus, IN UINTN DataSize, IN VOID *ResetData OPTIONAL)
 
UNIT_TEST_STATUS EFIAPI ResetColdShouldIssueAColdReset (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI ResetWarmShouldIssueAWarmReset (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI ResetShutdownShouldIssueAShutdown (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI ResetPlatformSpecificShouldIssueAPlatformSpecificReset (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI ResetSystemShouldPassTheParametersThrough (IN UNIT_TEST_CONTEXT Context)
 
STATIC EFI_STATUS EFIAPI UnitTestingEntry (VOID)
 
int main (int argc, char *argv[])
 

Variables

EFI_RUNTIME_SERVICES MockRuntime
 

Detailed Description

Unit tests of the DxeResetSystemLib instance of the ResetSystemLib class

Copyright (C) Microsoft Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file DxeResetSystemLibUnitTest.c.

Macro Definition Documentation

◆ UNIT_TEST_APP_NAME

#define UNIT_TEST_APP_NAME   "DxeResetSystemLib Unit Tests"

Definition at line 25 of file DxeResetSystemLibUnitTest.c.

◆ UNIT_TEST_APP_VERSION

#define UNIT_TEST_APP_VERSION   "1.0"

Definition at line 26 of file DxeResetSystemLibUnitTest.c.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Standard POSIX C entry point for host based unit test execution.

Definition at line 306 of file DxeResetSystemLibUnitTest.c.

◆ MockResetSystem()

STATIC VOID EFIAPI MockResetSystem ( IN EFI_RESET_TYPE  ResetType,
IN EFI_STATUS  ResetStatus,
IN UINTN  DataSize,
IN VOID *ResetData  OPTIONAL 
)

Resets the entire platform.

Parameters
[in]ResetTypeThe type of reset to perform.
[in]ResetStatusThe status code for the reset.
[in]DataSizeThe size, in bytes, of ResetData.
[in]ResetDataFor a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown the data buffer starts with a Null-terminated string, optionally followed by additional binary data. The string is a description that the caller may use to further indicate the reason for the system reset. For a ResetType of EfiResetPlatformSpecific the data buffer also starts with a Null-terminated string that is followed by an EFI_GUID that describes the specific type of reset to perform.

Definition at line 46 of file DxeResetSystemLibUnitTest.c.

◆ ResetColdShouldIssueAColdReset()

UNIT_TEST_STATUS EFIAPI ResetColdShouldIssueAColdReset ( IN UNIT_TEST_CONTEXT  Context)

Unit test for ColdReset () API of the ResetSystemLib.

Parameters
[in]Context[Optional] An optional parameter that enables: 1) test-case reuse with varied parameters and 2) test-case re-entry for Target tests that need a reboot. This parameter is a VOID* and it is the responsibility of the test author to ensure that the contents are well understood by all test cases that may consume it.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 105 of file DxeResetSystemLibUnitTest.c.

◆ ResetPlatformSpecificShouldIssueAPlatformSpecificReset()

UNIT_TEST_STATUS EFIAPI ResetPlatformSpecificShouldIssueAPlatformSpecificReset ( IN UNIT_TEST_CONTEXT  Context)

Unit test for ResetPlatformSpecific () API of the ResetSystemLib.

Parameters
[in]Context[Optional] An optional parameter that enables: 1) test-case reuse with varied parameters and 2) test-case re-entry for Target tests that need a reboot. This parameter is a VOID* and it is the responsibility of the test author to ensure that the contents are well understood by all test cases that may consume it.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 192 of file DxeResetSystemLibUnitTest.c.

◆ ResetShutdownShouldIssueAShutdown()

UNIT_TEST_STATUS EFIAPI ResetShutdownShouldIssueAShutdown ( IN UNIT_TEST_CONTEXT  Context)

Unit test for ResetShutdown () API of the ResetSystemLib.

Parameters
[in]Context[Optional] An optional parameter that enables: 1) test-case reuse with varied parameters and 2) test-case re-entry for Target tests that need a reboot. This parameter is a VOID* and it is the responsibility of the test author to ensure that the contents are well understood by all test cases that may consume it.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 163 of file DxeResetSystemLibUnitTest.c.

◆ ResetSystemShouldPassTheParametersThrough()

UNIT_TEST_STATUS EFIAPI ResetSystemShouldPassTheParametersThrough ( IN UNIT_TEST_CONTEXT  Context)

Unit test for ResetSystem () API of the ResetSystemLib.

Parameters
[in]Context[Optional] An optional parameter that enables: 1) test-case reuse with varied parameters and 2) test-case re-entry for Target tests that need a reboot. This parameter is a VOID* and it is the responsibility of the test author to ensure that the contents are well understood by all test cases that may consume it.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 221 of file DxeResetSystemLibUnitTest.c.

◆ ResetWarmShouldIssueAWarmReset()

UNIT_TEST_STATUS EFIAPI ResetWarmShouldIssueAWarmReset ( IN UNIT_TEST_CONTEXT  Context)

Unit test for WarmReset () API of the ResetSystemLib.

Parameters
[in]Context[Optional] An optional parameter that enables: 1) test-case reuse with varied parameters and 2) test-case re-entry for Target tests that need a reboot. This parameter is a VOID* and it is the responsibility of the test author to ensure that the contents are well understood by all test cases that may consume it.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 134 of file DxeResetSystemLibUnitTest.c.

◆ UnitTestingEntry()

STATIC EFI_STATUS EFIAPI UnitTestingEntry ( VOID  )

Initialze the unit test framework, suite, and unit tests for the ResetSystemLib and run the ResetSystemLib unit test.

Return values
EFI_SUCCESSAll test cases were dispatched.
EFI_OUT_OF_RESOURCESThere are not enough resources available to initialize the unit tests.

Definition at line 249 of file DxeResetSystemLibUnitTest.c.

Variable Documentation

◆ MockRuntime

EFI_RUNTIME_SERVICES MockRuntime
Initial value:
= {
{
EFI_RUNTIME_SERVICES_SIGNATURE,
EFI_RUNTIME_SERVICES_REVISION,
0,
0
},
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
}
STATIC VOID EFIAPI MockResetSystem(IN EFI_RESET_TYPE ResetType, IN EFI_STATUS ResetStatus, IN UINTN DataSize, IN VOID *ResetData OPTIONAL)
#define NULL
Definition: Base.h:319

Mock version of the UEFI Runtime Services Table

Definition at line 64 of file DxeResetSystemLibUnitTest.c.