TianoCore EDK2 master
Loading...
Searching...
No Matches
SampleUnitTestGenerateException.c File Reference
#include <PiPei.h>
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/DebugLib.h>
#include <Library/UnitTestLib.h>
#include <Library/PrintLib.h>

Go to the source code of this file.

Macros

#define UNIT_TEST_NAME   "Sample Unit Test Generate Exception"
 
#define UNIT_TEST_VERSION   "0.1"
 

Functions

VOID EFIAPI TestSuiteEnableAsserts (VOID)
 
VOID EFIAPI TestSuiteDisableAsserts (VOID)
 
UINTN DivideWithNoParameterChecking (UINTN Dividend, UINTN Divisor)
 
UNIT_TEST_STATUS EFIAPI GenerateUnexpectedException (IN UNIT_TEST_CONTEXT Context)
 
EFI_STATUS EFIAPI UefiTestMain (VOID)
 
EFI_STATUS EFIAPI PeiEntryPoint (IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
 
EFI_STATUS EFIAPI DxeEntryPoint (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
int main (int argc, char *argv[])
 

Detailed Description

This is a sample to demonstrate the usage of the Unit Test Library that supports the PEI, DXE, SMM, UEFI Shell, and host execution environments. This test case generates an exception. For some host-based environments, this is a fatal condition that terminates the unit tests and no additional test cases are executed. On other environments, this condition may be report a unit test failure and continue with additional unit tests.

Copyright (c) 2024, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file SampleUnitTestGenerateException.c.

Macro Definition Documentation

◆ UNIT_TEST_NAME

#define UNIT_TEST_NAME   "Sample Unit Test Generate Exception"

Definition at line 20 of file SampleUnitTestGenerateException.c.

◆ UNIT_TEST_VERSION

#define UNIT_TEST_VERSION   "0.1"

Definition at line 21 of file SampleUnitTestGenerateException.c.

Function Documentation

◆ DivideWithNoParameterChecking()

UINTN DivideWithNoParameterChecking ( UINTN  Dividend,
UINTN  Divisor 
)

Definition at line 54 of file SampleUnitTestGenerateException.c.

◆ DxeEntryPoint()

EFI_STATUS EFIAPI DxeEntryPoint ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Standard UEFI entry point for target based unit test execution from DXE, SMM, UEFI Shell.

Definition at line 186 of file SampleUnitTestGenerateException.c.

◆ GenerateUnexpectedException()

UNIT_TEST_STATUS EFIAPI GenerateUnexpectedException ( IN UNIT_TEST_CONTEXT  Context)

Sample unit test the triggers an unexpected exception

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 82 of file SampleUnitTestGenerateException.c.

◆ main()

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

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

Definition at line 198 of file SampleUnitTestGenerateException.c.

◆ PeiEntryPoint()

EFI_STATUS EFIAPI PeiEntryPoint ( IN EFI_PEI_FILE_HANDLE  FileHandle,
IN CONST EFI_PEI_SERVICES **  PeiServices 
)

Standard PEIM entry point for target based unit test execution from PEI.

Definition at line 172 of file SampleUnitTestGenerateException.c.

◆ TestSuiteDisableAsserts()

VOID EFIAPI TestSuiteDisableAsserts ( VOID  )

Unit-Test Test Suite Setup (before) function that disables ASSERT() macros.

Definition at line 43 of file SampleUnitTestGenerateException.c.

◆ TestSuiteEnableAsserts()

VOID EFIAPI TestSuiteEnableAsserts ( VOID  )

Unit-Test Test Suite Setup (before) function that enables ASSERT() macros.

Definition at line 28 of file SampleUnitTestGenerateException.c.

◆ UefiTestMain()

EFI_STATUS EFIAPI UefiTestMain ( VOID  )

Initialize the unit test framework, suite, and unit tests for the sample unit tests and run the unit tests.

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 108 of file SampleUnitTestGenerateException.c.