TianoCore EDK2 master
Loading...
Searching...
No Matches
UnitTestPersistenceLibSimpleFileSystem.c File Reference

Go to the source code of this file.

Macros

#define CACHE_FILE_SUFFIX   L"_Cache.dat"
 

Functions

STATIC CHAR16 * GetCacheFileName (IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle)
 
BOOLEAN EFIAPI DoesCacheExist (IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle)
 
EFI_STATUS EFIAPI SaveUnitTestCache (IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle, IN VOID *SaveData, IN UINTN SaveStateSize)
 
EFI_STATUS EFIAPI LoadUnitTestCache (IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle, OUT VOID **SaveData, OUT UINTN *SaveStateSize)
 
EFI_STATUS EFIAPI UnitTestPersistenceLibConstructor (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

CHAR16 * mCachePath = NULL
 

Detailed Description

This is an instance of the Unit Test Persistence Lib that will utilize the filesystem that a test application is running from to save a serialized version of the internal test state in case the test needs to quit and restore.

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

Definition in file UnitTestPersistenceLibSimpleFileSystem.c.

Macro Definition Documentation

◆ CACHE_FILE_SUFFIX

#define CACHE_FILE_SUFFIX   L"_Cache.dat"

Definition at line 23 of file UnitTestPersistenceLibSimpleFileSystem.c.

Function Documentation

◆ DoesCacheExist()

BOOLEAN EFIAPI DoesCacheExist ( IN UNIT_TEST_FRAMEWORK_HANDLE  FrameworkHandle)

Determines whether a persistence cache already exists for the given framework.

Parameters
[in]FrameworkHandleA pointer to the framework that is being persisted.
Return values
TRUE
FALSECache doesn't exist or an error occurred.

Definition at line 193 of file UnitTestPersistenceLibSimpleFileSystem.c.

◆ GetCacheFileName()

STATIC CHAR16 * GetCacheFileName ( IN UNIT_TEST_FRAMEWORK_HANDLE  FrameworkHandle)

Generate the file name and path to the cache file.

Parameters
[in]FrameworkHandleA pointer to the framework that is being persisted.
Return values
!NULLA pointer to the EFI_FILE protocol instance for the filesystem.
NULLFilesystem could not be found or an error occurred.

Definition at line 38 of file UnitTestPersistenceLibSimpleFileSystem.c.

◆ LoadUnitTestCache()

EFI_STATUS EFIAPI LoadUnitTestCache ( IN UNIT_TEST_FRAMEWORK_HANDLE  FrameworkHandle,
OUT VOID **  SaveData,
OUT UINTN SaveStateSize 
)

Will retrieve any cached state associated with the given framework. Will allocate a buffer to hold the loaded data.

Parameters
[in]FrameworkHandleA pointer to the framework that is being persisted.
[out]SaveDataA pointer pointer that will be updated with the address of the loaded data buffer.
[out]SaveStateSizeReturn the size of SaveData in bytes.
Return values
EFI_SUCCESSData has been loaded successfully and SaveData is updated with a pointer to the buffer.
OthersAn error has occurred and no data has been loaded. SaveData is set to NULL.

Definition at line 356 of file UnitTestPersistenceLibSimpleFileSystem.c.

◆ SaveUnitTestCache()

EFI_STATUS EFIAPI SaveUnitTestCache ( IN UNIT_TEST_FRAMEWORK_HANDLE  FrameworkHandle,
IN VOID *  SaveData,
IN UINTN  SaveStateSize 
)

Will save the data associated with an internal Unit Test Framework state in a manner that can persist a Unit Test Application quit or even a system reboot.

Parameters
[in]FrameworkHandleA pointer to the framework that is being persisted.
[in]SaveDataA pointer to the buffer containing the serialized framework internal state.
[in]SaveStateSizeThe size of SaveData in bytes.
Return values
EFI_SUCCESSData is persisted and the test can be safely quit.
OthersData is not persisted and test cannot be resumed upon exit.

Definition at line 248 of file UnitTestPersistenceLibSimpleFileSystem.c.

◆ UnitTestPersistenceLibConstructor()

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

Shell based UnitTestPersistenceLib library constructor.

Parameters
[in]ImageHandleThe firmware allocated handle for the EFI image.
[in]SystemTableA pointer to the EFI System Table.
Return values
EFI_SUCCESSThe constructor finished successfully.
OthersError codes returned from gBS->HandleProtocol.

Definition at line 469 of file UnitTestPersistenceLibSimpleFileSystem.c.

Variable Documentation

◆ mCachePath

CHAR16* mCachePath = NULL

Definition at line 25 of file UnitTestPersistenceLibSimpleFileSystem.c.