]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UnitTestFrameworkPkg/UnitTestLib: Update SaveFrameworkState() signature
authorMichael Kubacki <michael.kubacki@microsoft.com>
Thu, 16 Apr 2020 23:47:18 +0000 (16:47 -0700)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sun, 14 Jun 2020 23:56:05 +0000 (23:56 +0000)
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2612

Removes the FrameworkHandle parameter from SaveFrameworkState() in the
UnitTestLib library instance and updates callers of the function in the
library to use the new function signature.

Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c

index b053e04959120cf4a04d4d0b32e6a9bbe574ed44..793335fd0f05174212e939ab5b73f6b549c348c5 100644 (file)
@@ -162,7 +162,7 @@ RunAllTestSuites (
   //\r
   // Save current state so if test is started again it doesn't have to run.  It will just report\r
   //\r
-  SaveFrameworkState (FrameworkHandle, NULL, 0);\r
+  SaveFrameworkState (NULL, 0);\r
   OutputUnitTestFrameworkReport (FrameworkHandle);\r
 \r
   mFrameworkHandle = NULL;\r
index ba4b18568d5f2c31c507dd99f86277f44815b175..4a6bbd752c766ea71268bffc22e0cbe682b5cac2 100644 (file)
@@ -781,11 +781,9 @@ SerializeState (
   at least the current execution count) which will be saved by the framework and\r
   passed to the test case upon resume.\r
 \r
-  Generally called from within a test case prior to quitting or rebooting.\r
+  This should be called while the current test framework is valid and active. It is\r
+  generally called from within a test case prior to quitting or rebooting.\r
 \r
-  @param[in]  FrameworkHandle    A handle to the current running framework that\r
-                                 dispatched the test.  Necessary for recording\r
-                                 certain test events with the framework.\r
   @param[in]  ContextToSave      A buffer of test case-specific data to be saved\r
                                  along with framework state.  Will be passed as\r
                                  "Context" to the test case upon resume.  This\r
@@ -793,7 +791,7 @@ SerializeState (
   @param[in]  ContextToSaveSize  Size of the ContextToSave buffer.\r
 \r
   @retval  EFI_SUCCESS            The framework state and context were saved.\r
-  @retval  EFI_INVALID_PARAMETER  FrameworkHandle is NULL.\r
+  @retval  EFI_NOT_FOUND          An active framework handle was not found.\r
   @retval  EFI_INVALID_PARAMETER  ContextToSave is not NULL and\r
                                   ContextToSaveSize is 0.\r
   @retval  EFI_INVALID_PARAMETER  ContextToSave is >= 4GB.\r
@@ -806,21 +804,28 @@ SerializeState (
 EFI_STATUS\r
 EFIAPI\r
 SaveFrameworkState (\r
-  IN UNIT_TEST_FRAMEWORK_HANDLE  FrameworkHandle,\r
   IN UNIT_TEST_CONTEXT           ContextToSave     OPTIONAL,\r
   IN UINTN                       ContextToSaveSize\r
   )\r
 {\r
-  EFI_STATUS             Status;\r
-  UNIT_TEST_SAVE_HEADER  *Header;\r
+  EFI_STATUS                  Status;\r
+  UNIT_TEST_FRAMEWORK_HANDLE  FrameworkHandle;\r
+  UNIT_TEST_SAVE_HEADER       *Header;\r
 \r
   Header = NULL;\r
+  FrameworkHandle = GetActiveFrameworkHandle ();\r
+\r
+  //\r
+  // Return a unique error code if the framework is not set.\r
+  //\r
+  if (FrameworkHandle == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
 \r
   //\r
   // First, let's not make assumptions about the parameters.\r
   //\r
-  if (FrameworkHandle == NULL ||\r
-      (ContextToSave != NULL && ContextToSaveSize == 0) ||\r
+  if ((ContextToSave != NULL && ContextToSaveSize == 0) ||\r
       ContextToSaveSize > MAX_UINT32) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r