version of the internal test state in case the test needs to quit and restore.\r
\r
Copyright (c) Microsoft Corporation.<BR>\r
+ Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
**/\r
\r
#include <Library/DevicePathLib.h>\r
#include <Library/ShellLib.h>\r
#include <Protocol/LoadedImage.h>\r
+#include <UnitTestFrameworkTypes.h>\r
\r
#define CACHE_FILE_SUFFIX L"_Cache.dat"\r
\r
@param[in] FrameworkHandle A pointer to the framework that is being persisted.\r
@param[in] SaveData A pointer to the buffer containing the serialized\r
framework internal state.\r
+ @param[in] SaveStateSize The size of SaveData in bytes.\r
\r
@retval EFI_SUCCESS Data is persisted and the test can be safely quit.\r
@retval Others Data is not persisted and test cannot be resumed upon exit.\r
EFIAPI\r
SaveUnitTestCache (\r
IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle,\r
- IN UNIT_TEST_SAVE_HEADER *SaveData\r
+ IN VOID *SaveData,\r
+ IN UINTN SaveStateSize\r
)\r
{\r
EFI_DEVICE_PATH_PROTOCOL *FileDevicePath;\r
//\r
// Write the data to the file.\r
//\r
- WriteCount = SaveData->SaveStateSize;\r
+ WriteCount = SaveStateSize;\r
DEBUG ((DEBUG_INFO, "%a - Writing %d bytes to file...\n", __FUNCTION__, WriteCount));\r
Status = ShellWriteFile (\r
FileHandle,\r
SaveData\r
);\r
\r
- if (EFI_ERROR (Status) || (WriteCount != SaveData->SaveStateSize)) {\r
+ if (EFI_ERROR (Status) || (WriteCount != SaveStateSize)) {\r
DEBUG ((DEBUG_ERROR, "%a - Writing to file failed! %r\n", __FUNCTION__, Status));\r
} else {\r
DEBUG ((DEBUG_INFO, "%a - SUCCESS!\n", __FUNCTION__));\r
Will allocate a buffer to hold the loaded data.\r
\r
@param[in] FrameworkHandle A pointer to the framework that is being persisted.\r
- @param[in] SaveData A pointer pointer that will be updated with the address\r
+ @param[out] SaveData A pointer pointer that will be updated with the address\r
of the loaded data buffer.\r
+ @param[out] SaveStateSize Return the size of SaveData in bytes.\r
\r
@retval EFI_SUCCESS Data has been loaded successfully and SaveData is updated\r
with a pointer to the buffer.\r
EFIAPI\r
LoadUnitTestCache (\r
IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle,\r
- OUT UNIT_TEST_SAVE_HEADER **SaveData\r
+ OUT VOID **SaveData,\r
+ OUT UINTN *SaveStateSize\r
)\r
{\r
EFI_STATUS Status;\r
BOOLEAN IsFileOpened;\r
UINT64 LargeFileSize;\r
UINTN FileSize;\r
- UNIT_TEST_SAVE_HEADER *Buffer;\r
+ VOID *Buffer;\r
\r
IsFileOpened = FALSE;\r
Buffer = NULL;\r
//\r
// Now that we know the size, let's allocated a buffer to hold the contents.\r
//\r
- FileSize = (UINTN)LargeFileSize; // You know what... if it's too large, this lib don't care.\r
- Buffer = AllocatePool (FileSize);\r
+ FileSize = (UINTN)LargeFileSize; // You know what... if it's too large, this lib don't care.\r
+ *SaveStateSize = FileSize;\r
+ Buffer = AllocatePool (FileSize);\r
if (Buffer == NULL) {\r
DEBUG ((DEBUG_ERROR, "%a - Failed to allocate a pool to hold the file contents! %r\n", __FUNCTION__, Status));\r
Status = EFI_OUT_OF_RESOURCES;\r