UnitTestPersistenceLib.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /** @file
  2. This header file describes a library that contains functions to save and
  3. restore unit test internal state, in case the test needs to pause and resume
  4. (eg. a reboot-based test).
  5. Copyright (c) Microsoft Corporation.<BR>
  6. Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.<BR>
  7. SPDX-License-Identifier: BSD-2-Clause-Patent
  8. **/
  9. #ifndef _UNIT_TEST_PERSISTENCE_LIB_H_
  10. #define _UNIT_TEST_PERSISTENCE_LIB_H_
  11. #include <Library/UnitTestLib.h>
  12. #define UNIT_TEST_PERSISTENCE_LIB_VERSION 1
  13. /**
  14. Determines whether a persistence cache already exists for
  15. the given framework.
  16. @param[in] FrameworkHandle A pointer to the framework that is being persisted.
  17. @retval TRUE
  18. @retval FALSE Cache doesn't exist or an error occurred.
  19. **/
  20. BOOLEAN
  21. EFIAPI
  22. DoesCacheExist (
  23. IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle
  24. );
  25. /**
  26. Will save the data associated with an internal Unit Test Framework
  27. state in a manner that can persist a Unit Test Application quit or
  28. even a system reboot.
  29. @param[in] FrameworkHandle A pointer to the framework that is being persisted.
  30. @param[in] SaveData A pointer to the buffer containing the serialized
  31. framework internal state.
  32. @param[in] SaveStateSize The size of SaveData in bytes.
  33. @retval EFI_SUCCESS Data is persisted and the test can be safely quit.
  34. @retval Others Data is not persisted and test cannot be resumed upon exit.
  35. **/
  36. EFI_STATUS
  37. EFIAPI
  38. SaveUnitTestCache (
  39. IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle,
  40. IN VOID *SaveData,
  41. IN UINTN SaveStateSize
  42. );
  43. /**
  44. Will retrieve any cached state associated with the given framework.
  45. Will allocate a buffer to hold the loaded data.
  46. @param[in] FrameworkHandle A pointer to the framework that is being persisted.
  47. @param[out] SaveData A pointer pointer that will be updated with the address
  48. of the loaded data buffer.
  49. @param[out] SaveStateSize Return the size of SaveData in bytes.
  50. @retval EFI_SUCCESS Data has been loaded successfully and SaveData is updated
  51. with a pointer to the buffer.
  52. @retval Others An error has occurred and no data has been loaded. SaveData
  53. is set to NULL.
  54. **/
  55. EFI_STATUS
  56. EFIAPI
  57. LoadUnitTestCache (
  58. IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle,
  59. OUT VOID **SaveData,
  60. OUT UINTN *SaveStateSize
  61. );
  62. #endif