TianoCore EDK2 master
Loading...
Searching...
No Matches
SecureBootVariableLibUnitTest.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 <UefiSecureBoot.h>
#include <Guid/GlobalVariable.h>
#include <Guid/AuthenticatedVariableFormat.h>
#include <Guid/ImageAuthentication.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UnitTestLib.h>
#include <Library/SecureBootVariableLib.h>

Go to the source code of this file.

Macros

#define UNIT_TEST_APP_NAME   "SecureBootVariableLib Unit Tests"
 
#define UNIT_TEST_APP_VERSION   "1.0"
 
#define VAR_AUTH_DESC_SIZE   OFFSET_OF (EFI_VARIABLE_AUTHENTICATION_2, AuthInfo) + OFFSET_OF (WIN_CERTIFICATE_UEFI_GUID, CertData)
 

Functions

STATIC EFI_STATUS EFIAPI MockSetVariable (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, IN VOID *Data)
 
STATIC EFI_STATUS EFIAPI MockGetVariable (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT UINT32 *Attributes OPTIONAL, IN OUT UINTN *DataSize, OUT VOID *Data OPTIONAL)
 
UNIT_TEST_STATUS EFIAPI SetSecureBootModeShouldSetVar (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI GetSetupModeShouldGetVar (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI IsSecureBootEnableShouldGetVar (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI SecureBootCreateDataFromInputSimple (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI SecureBootCreateDataFromInputNull (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI SecureBootCreateDataFromInputMultiple (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI CreateTimeBasedPayloadShouldPopulateDescriptor (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI CreateTimeBasedPayloadShouldCheckInput (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI DeleteDbShouldDelete (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI DeleteDbxShouldDelete (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI DeleteDbtShouldDelete (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI DeleteKEKShouldDelete (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI DeletePKShouldDelete (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI DeleteSecureBootVariablesShouldDelete (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI DeleteSecureBootVariablesShouldCheckProtection (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI DeleteSecureBootVariablesShouldProceedWithNotFound (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI EnrollFromInputShouldComplete (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI SetSecureBootVariablesShouldComplete (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI SetSecureBootVariablesShouldStopWhenSecure (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI SetSecureBootVariablesShouldStopFailDBX (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI SetSecureBootVariablesShouldStopFailDB (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI SetSecureBootVariablesShouldStopFailDBT (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI SetSecureBootVariablesShouldStopFailKEK (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI SetSecureBootVariablesShouldStopFailPK (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI SetSecureBootVariablesDBTOptional (IN UNIT_TEST_CONTEXT Context)
 
STATIC EFI_STATUS EFIAPI UnitTestingEntry (VOID)
 
int main (int argc, char *argv[])
 

Variables

EFI_TIME mMaxTimestamp
 
EFI_TIME mDefaultPayloadTimestamp
 
EFI_RUNTIME_SERVICES gMockRuntime
 

Detailed Description

Unit tests of the implementation of SecureBootVariableLib.

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

Definition in file SecureBootVariableLibUnitTest.c.

Macro Definition Documentation

◆ UNIT_TEST_APP_NAME

#define UNIT_TEST_APP_NAME   "SecureBootVariableLib Unit Tests"

Definition at line 30 of file SecureBootVariableLibUnitTest.c.

◆ UNIT_TEST_APP_VERSION

#define UNIT_TEST_APP_VERSION   "1.0"

Definition at line 31 of file SecureBootVariableLibUnitTest.c.

◆ VAR_AUTH_DESC_SIZE

#define VAR_AUTH_DESC_SIZE   OFFSET_OF (EFI_VARIABLE_AUTHENTICATION_2, AuthInfo) + OFFSET_OF (WIN_CERTIFICATE_UEFI_GUID, CertData)

Definition at line 32 of file SecureBootVariableLibUnitTest.c.

Function Documentation

◆ CreateTimeBasedPayloadShouldCheckInput()

UNIT_TEST_STATUS EFIAPI CreateTimeBasedPayloadShouldCheckInput ( IN UNIT_TEST_CONTEXT  Context)

Unit test for CreateTimeBasedPayload () API of the SecureBootVariableLib.

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 556 of file SecureBootVariableLibUnitTest.c.

◆ CreateTimeBasedPayloadShouldPopulateDescriptor()

UNIT_TEST_STATUS EFIAPI CreateTimeBasedPayloadShouldPopulateDescriptor ( IN UNIT_TEST_CONTEXT  Context)

Unit test for CreateTimeBasedPayload () API of the SecureBootVariableLib.

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 493 of file SecureBootVariableLibUnitTest.c.

◆ DeleteDbShouldDelete()

UNIT_TEST_STATUS EFIAPI DeleteDbShouldDelete ( IN UNIT_TEST_CONTEXT  Context)

Unit test for DeleteDb () API of the SecureBootVariableLib.

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 594 of file SecureBootVariableLibUnitTest.c.

◆ DeleteDbtShouldDelete()

UNIT_TEST_STATUS EFIAPI DeleteDbtShouldDelete ( IN UNIT_TEST_CONTEXT  Context)

Unit test for DeleteDbt () API of the SecureBootVariableLib.

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 712 of file SecureBootVariableLibUnitTest.c.

◆ DeleteDbxShouldDelete()

UNIT_TEST_STATUS EFIAPI DeleteDbxShouldDelete ( IN UNIT_TEST_CONTEXT  Context)

Unit test for DeleteDbx () API of the SecureBootVariableLib.

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 653 of file SecureBootVariableLibUnitTest.c.

◆ DeleteKEKShouldDelete()

UNIT_TEST_STATUS EFIAPI DeleteKEKShouldDelete ( IN UNIT_TEST_CONTEXT  Context)

Unit test for DeleteKEK () API of the SecureBootVariableLib.

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 771 of file SecureBootVariableLibUnitTest.c.

◆ DeletePKShouldDelete()

UNIT_TEST_STATUS EFIAPI DeletePKShouldDelete ( IN UNIT_TEST_CONTEXT  Context)

Unit test for DeletePlatformKey () API of the SecureBootVariableLib.

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 830 of file SecureBootVariableLibUnitTest.c.

◆ DeleteSecureBootVariablesShouldCheckProtection()

UNIT_TEST_STATUS EFIAPI DeleteSecureBootVariablesShouldCheckProtection ( IN UNIT_TEST_CONTEXT  Context)

Unit test for DeleteSecureBootVariables () API of the SecureBootVariableLib.

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 1060 of file SecureBootVariableLibUnitTest.c.

◆ DeleteSecureBootVariablesShouldDelete()

UNIT_TEST_STATUS EFIAPI DeleteSecureBootVariablesShouldDelete ( IN UNIT_TEST_CONTEXT  Context)

Unit test for DeleteSecureBootVariables () API of the SecureBootVariableLib.

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 898 of file SecureBootVariableLibUnitTest.c.

◆ DeleteSecureBootVariablesShouldProceedWithNotFound()

UNIT_TEST_STATUS EFIAPI DeleteSecureBootVariablesShouldProceedWithNotFound ( IN UNIT_TEST_CONTEXT  Context)

Unit test for DeleteSecureBootVariables () API of the SecureBootVariableLib.

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 1091 of file SecureBootVariableLibUnitTest.c.

◆ EnrollFromInputShouldComplete()

UNIT_TEST_STATUS EFIAPI EnrollFromInputShouldComplete ( IN UNIT_TEST_CONTEXT  Context)

Unit test for DeleteSecureBootVariables () API of the SecureBootVariableLib.

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 1161 of file SecureBootVariableLibUnitTest.c.

◆ GetSetupModeShouldGetVar()

UNIT_TEST_STATUS EFIAPI GetSetupModeShouldGetVar ( IN UNIT_TEST_CONTEXT  Context)

Unit test for GetSetupMode () API of the SecureBootVariableLib.

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 256 of file SecureBootVariableLibUnitTest.c.

◆ IsSecureBootEnableShouldGetVar()

UNIT_TEST_STATUS EFIAPI IsSecureBootEnableShouldGetVar ( IN UNIT_TEST_CONTEXT  Context)

Unit test for GetSetupMode () API of the SecureBootVariableLib.

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 298 of file SecureBootVariableLibUnitTest.c.

◆ main()

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

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

Definition at line 2027 of file SecureBootVariableLibUnitTest.c.

◆ MockGetVariable()

STATIC EFI_STATUS EFIAPI MockGetVariable ( IN CHAR16 *  VariableName,
IN EFI_GUID VendorGuid,
OUT UINT32 *Attributes  OPTIONAL,
IN OUT UINTN DataSize,
OUT VOID *Data  OPTIONAL 
)

Returns the value of a variable.

Parameters
[in]VariableNameA Null-terminated string that is the name of the vendor's variable.
[in]VendorGuidA unique identifier for the vendor.
[out]AttributesIf not NULL, a pointer to the memory location to return the attributes bitmask for the variable.
[in,out]DataSizeOn input, the size in bytes of the return Data buffer. On output the size of data returned in Data.
[out]DataThe buffer to return the contents of the variable. May be NULL with a zero DataSize in order to determine the size buffer needed.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_NOT_FOUNDThe variable was not found.
EFI_BUFFER_TOO_SMALLThe DataSize is too small for the result.
EFI_INVALID_PARAMETERVariableName is NULL.
EFI_INVALID_PARAMETERVendorGuid is NULL.
EFI_INVALID_PARAMETERDataSize is NULL.
EFI_INVALID_PARAMETERThe DataSize is not too small and Data is NULL.
EFI_DEVICE_ERRORThe variable could not be retrieved due to a hardware error.
EFI_SECURITY_VIOLATIONThe variable could not be retrieved due to an authentication failure.

Definition at line 128 of file SecureBootVariableLibUnitTest.c.

◆ MockSetVariable()

STATIC EFI_STATUS EFIAPI MockSetVariable ( IN CHAR16 *  VariableName,
IN EFI_GUID VendorGuid,
IN UINT32  Attributes,
IN UINTN  DataSize,
IN VOID *  Data 
)

Sets the value of a variable.

Parameters
[in]VariableNameA Null-terminated string that is the name of the vendor's variable. Each VariableName is unique for each VendorGuid. VariableName must contain 1 or more characters. If VariableName is an empty string, then EFI_INVALID_PARAMETER is returned.
[in]VendorGuidA unique identifier for the vendor.
[in]AttributesAttributes bitmask to set for the variable.
[in]DataSizeThe size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute is set, a size of zero causes the variable to be deleted. When the EFI_VARIABLE_APPEND_WRITE attribute is set, then a SetVariable() call with a DataSize of zero will not cause any change to the variable value (the timestamp associated with the variable may be updated however even if no new data value is provided,see the description of the EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated).
[in]DataThe contents for the variable.
Return values
EFI_SUCCESSThe firmware has successfully stored the variable and its data as defined by the Attributes.
EFI_INVALID_PARAMETERAn invalid combination of attribute bits, name, and GUID was supplied, or the DataSize exceeds the maximum allowed.
EFI_INVALID_PARAMETERVariableName is an empty string.
EFI_OUT_OF_RESOURCESNot enough storage is available to hold the variable and its data.
EFI_DEVICE_ERRORThe variable could not be retrieved due to a hardware error.
EFI_WRITE_PROTECTEDThe variable in question is read-only.
EFI_WRITE_PROTECTEDThe variable in question cannot be deleted.
EFI_SECURITY_VIOLATIONThe variable could not be written due to EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS being set, but the AuthInfo does NOT pass the validation check carried out by the firmware.
EFI_NOT_FOUNDThe variable trying to be updated or deleted was not found.

Definition at line 74 of file SecureBootVariableLibUnitTest.c.

◆ SecureBootCreateDataFromInputMultiple()

UNIT_TEST_STATUS EFIAPI SecureBootCreateDataFromInputMultiple ( IN UNIT_TEST_CONTEXT  Context)

Unit test for SecureBootCreateDataFromInput () API of the SecureBootVariableLib.

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 432 of file SecureBootVariableLibUnitTest.c.

◆ SecureBootCreateDataFromInputNull()

UNIT_TEST_STATUS EFIAPI SecureBootCreateDataFromInputNull ( IN UNIT_TEST_CONTEXT  Context)

Unit test for SecureBootCreateDataFromInput () API of the SecureBootVariableLib.

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 394 of file SecureBootVariableLibUnitTest.c.

◆ SecureBootCreateDataFromInputSimple()

UNIT_TEST_STATUS EFIAPI SecureBootCreateDataFromInputSimple ( IN UNIT_TEST_CONTEXT  Context)

Unit test for SecureBootCreateDataFromInput () API of the SecureBootVariableLib.

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 345 of file SecureBootVariableLibUnitTest.c.

◆ SetSecureBootModeShouldSetVar()

UNIT_TEST_STATUS EFIAPI SetSecureBootModeShouldSetVar ( IN UNIT_TEST_CONTEXT  Context)

Unit test for SetSecureBootMode () API of the SecureBootVariableLib.

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 216 of file SecureBootVariableLibUnitTest.c.

◆ SetSecureBootVariablesDBTOptional()

UNIT_TEST_STATUS EFIAPI SetSecureBootVariablesDBTOptional ( IN UNIT_TEST_CONTEXT  Context)

Unit test for SetDefaultSecureBootVariables () API of the SecureBootVariableLib.

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 1829 of file SecureBootVariableLibUnitTest.c.

◆ SetSecureBootVariablesShouldComplete()

UNIT_TEST_STATUS EFIAPI SetSecureBootVariablesShouldComplete ( IN UNIT_TEST_CONTEXT  Context)

Unit test for SetDefaultSecureBootVariables () API of the SecureBootVariableLib.

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 1206 of file SecureBootVariableLibUnitTest.c.

◆ SetSecureBootVariablesShouldStopFailDB()

UNIT_TEST_STATUS EFIAPI SetSecureBootVariablesShouldStopFailDB ( IN UNIT_TEST_CONTEXT  Context)

Unit test for SetDefaultSecureBootVariables () API of the SecureBootVariableLib.

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 1432 of file SecureBootVariableLibUnitTest.c.

◆ SetSecureBootVariablesShouldStopFailDBT()

UNIT_TEST_STATUS EFIAPI SetSecureBootVariablesShouldStopFailDBT ( IN UNIT_TEST_CONTEXT  Context)

Unit test for SetDefaultSecureBootVariables () API of the SecureBootVariableLib.

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 1505 of file SecureBootVariableLibUnitTest.c.

◆ SetSecureBootVariablesShouldStopFailDBX()

UNIT_TEST_STATUS EFIAPI SetSecureBootVariablesShouldStopFailDBX ( IN UNIT_TEST_CONTEXT  Context)

Unit test for SetDefaultSecureBootVariables () API of the SecureBootVariableLib.

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 1376 of file SecureBootVariableLibUnitTest.c.

◆ SetSecureBootVariablesShouldStopFailKEK()

UNIT_TEST_STATUS EFIAPI SetSecureBootVariablesShouldStopFailKEK ( IN UNIT_TEST_CONTEXT  Context)

Unit test for SetDefaultSecureBootVariables () API of the SecureBootVariableLib.

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 1595 of file SecureBootVariableLibUnitTest.c.

◆ SetSecureBootVariablesShouldStopFailPK()

UNIT_TEST_STATUS EFIAPI SetSecureBootVariablesShouldStopFailPK ( IN UNIT_TEST_CONTEXT  Context)

Unit test for SetDefaultSecureBootVariables () API of the SecureBootVariableLib.

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 1705 of file SecureBootVariableLibUnitTest.c.

◆ SetSecureBootVariablesShouldStopWhenSecure()

UNIT_TEST_STATUS EFIAPI SetSecureBootVariablesShouldStopWhenSecure ( IN UNIT_TEST_CONTEXT  Context)

Unit test for SetDefaultSecureBootVariables () API of the SecureBootVariableLib.

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 1330 of file SecureBootVariableLibUnitTest.c.

◆ UnitTestingEntry()

STATIC EFI_STATUS EFIAPI UnitTestingEntry ( VOID  )

Initialze the unit test framework, suite, and unit tests for the SecureBootVariableLib and run the SecureBootVariableLib 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 1932 of file SecureBootVariableLibUnitTest.c.

Variable Documentation

◆ gMockRuntime

EFI_RUNTIME_SERVICES gMockRuntime
Initial value:
= {
{
EFI_RUNTIME_SERVICES_SIGNATURE,
EFI_RUNTIME_SERVICES_REVISION,
0,
0
},
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
}
#define NULL
Definition: Base.h:319
STATIC EFI_STATUS EFIAPI MockGetVariable(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT UINT32 *Attributes OPTIONAL, IN OUT UINTN *DataSize, OUT VOID *Data OPTIONAL)
STATIC EFI_STATUS EFIAPI MockSetVariable(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, IN VOID *Data)

Mock version of the UEFI Runtime Services Table

Definition at line 175 of file SecureBootVariableLibUnitTest.c.

◆ mDefaultPayloadTimestamp

EFI_TIME mDefaultPayloadTimestamp
extern

Definition at line 45 of file SecureBootVariableLib.c.

◆ mMaxTimestamp

EFI_TIME mMaxTimestamp
extern

Definition at line 27 of file SecureBootVariableLib.c.