TianoCore EDK2 master
Loading...
Searching...
No Matches
RunTestsCmocka.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 <UnitTestFrameworkTypes.h>
#include <Library/UnitTestLib.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/DebugLib.h>

Go to the source code of this file.

Functions

UNIT_TEST_FRAMEWORK_HANDLE GetActiveFrameworkHandle (VOID)
 
void CmockaUnitTestFunctionRunner (void **state)
 
int CmockaUnitTestSetupFunctionRunner (void **state)
 
int CmockaUnitTestTeardownFunctionRunner (void **state)
 
int CmockaUnitTestSuiteSetupFunctionRunner (void **state)
 
int CmockaUnitTestSuiteTeardownFunctionRunner (void **state)
 
STATIC EFI_STATUS RunTestSuite (IN UNIT_TEST_SUITE *Suite)
 
EFI_STATUS EFIAPI RunAllTestSuites (IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle)
 

Variables

STATIC UNIT_TEST_FRAMEWORK_HANDLE mFrameworkHandle = NULL
 
UNIT_TEST_SUITEmActiveUnitTestSuite = NULL
 

Detailed Description

UnitTestLib APIs to run unit tests using cmocka

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

Definition in file RunTestsCmocka.c.

Function Documentation

◆ CmockaUnitTestFunctionRunner()

void CmockaUnitTestFunctionRunner ( void **  state)

Definition at line 39 of file RunTestsCmocka.c.

◆ CmockaUnitTestSetupFunctionRunner()

int CmockaUnitTestSetupFunctionRunner ( void **  state)

Definition at line 62 of file RunTestsCmocka.c.

◆ CmockaUnitTestSuiteSetupFunctionRunner()

int CmockaUnitTestSuiteSetupFunctionRunner ( void **  state)

Definition at line 127 of file RunTestsCmocka.c.

◆ CmockaUnitTestSuiteTeardownFunctionRunner()

int CmockaUnitTestSuiteTeardownFunctionRunner ( void **  state)

Definition at line 147 of file RunTestsCmocka.c.

◆ CmockaUnitTestTeardownFunctionRunner()

int CmockaUnitTestTeardownFunctionRunner ( void **  state)

Definition at line 90 of file RunTestsCmocka.c.

◆ GetActiveFrameworkHandle()

UNIT_TEST_FRAMEWORK_HANDLE GetActiveFrameworkHandle ( VOID  )

Internal helper function to return a handle to the currently executing framework. This function is generally used for communication within the UnitTest framework, but is defined here so that it can be consumed by the Assertion and Logging macros.

There should be no need to consume as a test writer, but it's there if you need it.

Return values
Handleto the currently executing test framework.

Definition at line 26 of file RunTestsCmocka.c.

◆ RunAllTestSuites()

EFI_STATUS EFIAPI RunAllTestSuites ( IN UNIT_TEST_FRAMEWORK_HANDLE  FrameworkHandle)

Execute all unit test cases in all unit test suites added to a Framework.

Once a unit test framework is initialized and all unit test suites and unit test cases are registered, this function will cause the unit test framework to dispatch all unit test cases in sequence and record the results for reporting.

Parameters
[in]FrameworkHandleA handle to the current running framework that dispatched the test. Necessary for recording certain test events with the framework.
Return values
EFI_SUCCESSAll test cases were dispatched.
EFI_INVALID_PARAMETERFrameworkHandle is NULL.

Definition at line 245 of file RunTestsCmocka.c.

◆ RunTestSuite()

STATIC EFI_STATUS RunTestSuite ( IN UNIT_TEST_SUITE Suite)

Definition at line 168 of file RunTestsCmocka.c.

Variable Documentation

◆ mActiveUnitTestSuite

UNIT_TEST_SUITE* mActiveUnitTestSuite = NULL

Definition at line 36 of file RunTestsCmocka.c.

◆ mFrameworkHandle

STATIC UNIT_TEST_FRAMEWORK_HANDLE mFrameworkHandle = NULL

Definition at line 23 of file RunTestsCmocka.c.