[edk2-devel] [PATCH] UnitTestFrameworkPkg/UnitTestLib: Remove FrameworkHandle parameter

Guomin Jiang posted 1 patch 4 years, 7 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/edk2 tags/patchew/20200414015345.2397-1-guomin.jiang@intel.com
MdePkg/Include/Library/UnitTestLib.h                |  4 ----
UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c |  2 +-
.../Library/UnitTestLib/UnitTestLib.c               | 13 +++++--------
3 files changed, 6 insertions(+), 13 deletions(-)
[edk2-devel] [PATCH] UnitTestFrameworkPkg/UnitTestLib: Remove FrameworkHandle parameter
Posted by Guomin Jiang 4 years, 7 months ago
From: Bret Barkelew <brbarkel@microsoft.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2612

Remove the FrameworkHandle parameter from the SaveFrameworkState interface
in UnitTestLib

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Signed-off-by: Guomin Jiang <guomin.jiang@intel.com>
---
 MdePkg/Include/Library/UnitTestLib.h                |  4 ----
 UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c |  2 +-
 .../Library/UnitTestLib/UnitTestLib.c               | 13 +++++--------
 3 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/MdePkg/Include/Library/UnitTestLib.h b/MdePkg/Include/Library/UnitTestLib.h
index c06c36bea5..38e4652959 100644
--- a/MdePkg/Include/Library/UnitTestLib.h
+++ b/MdePkg/Include/Library/UnitTestLib.h
@@ -315,9 +315,6 @@ FreeUnitTestFramework (
 
   Generally called from within a test case prior to quitting or rebooting.
 
-  @param[in]  FrameworkHandle    A handle to the current running framework that
-                                 dispatched the test.  Necessary for recording
-                                 certain test events with the framework.
   @param[in]  ContextToSave      A buffer of test case-specific data to be saved
                                  along with framework state.  Will be passed as
                                  "Context" to the test case upon resume.  This
@@ -338,7 +335,6 @@ FreeUnitTestFramework (
 EFI_STATUS
 EFIAPI
 SaveFrameworkState (
-  IN UNIT_TEST_FRAMEWORK_HANDLE  FrameworkHandle,
   IN UNIT_TEST_CONTEXT           ContextToSave     OPTIONAL,
   IN UINTN                       ContextToSaveSize
   );
diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
index b053e04959..793335fd0f 100644
--- a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
+++ b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
@@ -162,7 +162,7 @@ RunAllTestSuites (
   //
   // Save current state so if test is started again it doesn't have to run.  It will just report
   //
-  SaveFrameworkState (FrameworkHandle, NULL, 0);
+  SaveFrameworkState (NULL, 0);
   OutputUnitTestFrameworkReport (FrameworkHandle);
 
   mFrameworkHandle = NULL;
diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
index b136992d99..9a701d1047 100644
--- a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
+++ b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
@@ -785,9 +785,6 @@ SerializeState (
 
   Generally called from within a test case prior to quitting or rebooting.
 
-  @param[in]  FrameworkHandle    A handle to the current running framework that
-                                 dispatched the test.  Necessary for recording
-                                 certain test events with the framework.
   @param[in]  ContextToSave      A buffer of test case-specific data to be saved
                                  along with framework state.  Will be passed as
                                  "Context" to the test case upon resume.  This
@@ -808,21 +805,21 @@ SerializeState (
 EFI_STATUS
 EFIAPI
 SaveFrameworkState (
-  IN UNIT_TEST_FRAMEWORK_HANDLE  FrameworkHandle,
   IN UNIT_TEST_CONTEXT           ContextToSave     OPTIONAL,
   IN UINTN                       ContextToSaveSize
   )
 {
-  EFI_STATUS             Status;
-  UNIT_TEST_SAVE_HEADER  *Header;
+  EFI_STATUS                  Status;
+  UNIT_TEST_FRAMEWORK_HANDLE  FrameworkHandle;
+  UNIT_TEST_SAVE_HEADER       *Header;
 
   Header = NULL;
+  FrameworkHandle = GetActiveFrameworkHandle();
 
   //
   // First, let's not make assumptions about the parameters.
   //
-  if (FrameworkHandle == NULL ||
-      (ContextToSave != NULL && ContextToSaveSize == 0) ||
+  if ((ContextToSave != NULL && ContextToSaveSize == 0) ||
       ContextToSaveSize > MAX_UINT32) {
     return EFI_INVALID_PARAMETER;
   }
-- 
2.25.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#57289): https://edk2.groups.io/g/devel/message/57289
Mute This Topic: https://groups.io/mt/73002350/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [EXTERNAL] [PATCH] UnitTestFrameworkPkg/UnitTestLib: Remove FrameworkHandle parameter
Posted by Bret Barkelew via groups.io 4 years, 7 months ago
Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>

- Bret

From: Guomin Jiang<mailto:guomin.jiang@intel.com>
Sent: Monday, April 13, 2020 6:53 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>
Cc: Bret Barkelew<mailto:Bret.Barkelew@microsoft.com>; Kinney, Michael D<mailto:michael.d.kinney@intel.com>; Liming Gao<mailto:liming.gao@intel.com>; Sean Brogan<mailto:sean.brogan@microsoft.com>; Bret Barkelew<mailto:Bret.Barkelew@microsoft.com>
Subject: [EXTERNAL] [PATCH] UnitTestFrameworkPkg/UnitTestLib: Remove FrameworkHandle parameter

From: Bret Barkelew <brbarkel@microsoft.com>

REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2612&amp;data=02%7C01%7CBret.Barkelew%40microsoft.com%7Cffe40198dda04043796c08d7e016acfd%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637224260308125582&amp;sdata=Ilxdkaz%2BRcTdU6bvTRPB394PGKWZ0TQibcN4NaYDBEg%3D&amp;reserved=0

Remove the FrameworkHandle parameter from the SaveFrameworkState interface
in UnitTestLib

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Signed-off-by: Guomin Jiang <guomin.jiang@intel.com>
---
 MdePkg/Include/Library/UnitTestLib.h                |  4 ----
 UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c |  2 +-
 .../Library/UnitTestLib/UnitTestLib.c               | 13 +++++--------
 3 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/MdePkg/Include/Library/UnitTestLib.h b/MdePkg/Include/Library/UnitTestLib.h
index c06c36bea5..38e4652959 100644
--- a/MdePkg/Include/Library/UnitTestLib.h
+++ b/MdePkg/Include/Library/UnitTestLib.h
@@ -315,9 +315,6 @@ FreeUnitTestFramework (


   Generally called from within a test case prior to quitting or rebooting.



-  @param[in]  FrameworkHandle    A handle to the current running framework that

-                                 dispatched the test.  Necessary for recording

-                                 certain test events with the framework.

   @param[in]  ContextToSave      A buffer of test case-specific data to be saved

                                  along with framework state.  Will be passed as

                                  "Context" to the test case upon resume.  This

@@ -338,7 +335,6 @@ FreeUnitTestFramework (
 EFI_STATUS

 EFIAPI

 SaveFrameworkState (

-  IN UNIT_TEST_FRAMEWORK_HANDLE  FrameworkHandle,

   IN UNIT_TEST_CONTEXT           ContextToSave     OPTIONAL,

   IN UINTN                       ContextToSaveSize

   );

diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
index b053e04959..793335fd0f 100644
--- a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
+++ b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
@@ -162,7 +162,7 @@ RunAllTestSuites (
   //

   // Save current state so if test is started again it doesn't have to run.  It will just report

   //

-  SaveFrameworkState (FrameworkHandle, NULL, 0);

+  SaveFrameworkState (NULL, 0);

   OutputUnitTestFrameworkReport (FrameworkHandle);



   mFrameworkHandle = NULL;

diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
index b136992d99..9a701d1047 100644
--- a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
+++ b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
@@ -785,9 +785,6 @@ SerializeState (


   Generally called from within a test case prior to quitting or rebooting.



-  @param[in]  FrameworkHandle    A handle to the current running framework that

-                                 dispatched the test.  Necessary for recording

-                                 certain test events with the framework.

   @param[in]  ContextToSave      A buffer of test case-specific data to be saved

                                  along with framework state.  Will be passed as

                                  "Context" to the test case upon resume.  This

@@ -808,21 +805,21 @@ SerializeState (
 EFI_STATUS

 EFIAPI

 SaveFrameworkState (

-  IN UNIT_TEST_FRAMEWORK_HANDLE  FrameworkHandle,

   IN UNIT_TEST_CONTEXT           ContextToSave     OPTIONAL,

   IN UINTN                       ContextToSaveSize

   )

 {

-  EFI_STATUS             Status;

-  UNIT_TEST_SAVE_HEADER  *Header;

+  EFI_STATUS                  Status;

+  UNIT_TEST_FRAMEWORK_HANDLE  FrameworkHandle;

+  UNIT_TEST_SAVE_HEADER       *Header;



   Header = NULL;

+  FrameworkHandle = GetActiveFrameworkHandle();



   //

   // First, let's not make assumptions about the parameters.

   //

-  if (FrameworkHandle == NULL ||

-      (ContextToSave != NULL && ContextToSaveSize == 0) ||

+  if ((ContextToSave != NULL && ContextToSaveSize == 0) ||

       ContextToSaveSize > MAX_UINT32) {

     return EFI_INVALID_PARAMETER;

   }

--
2.25.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#57290): https://edk2.groups.io/g/devel/message/57290
Mute This Topic: https://groups.io/mt/73003006/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-