public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v1 1/2] MdePkg/UnitTestLib.h: Drop FrameworkHandle param from SaveFrameworkState()
       [not found] <20200421183502.39876-1-michael.kubacki@outlook.com>
@ 2020-04-21 18:35 ` Michael Kubacki
  2020-06-05  8:13   ` [edk2-devel] " Zhiguang Liu
  2020-04-21 18:35 ` [PATCH v1 2/2] UnitTestFrameworkPkg/UnitTestLib: Update SaveFrameworkState() signature Michael Kubacki
  1 sibling, 1 reply; 4+ messages in thread
From: Michael Kubacki @ 2020-04-21 18:35 UTC (permalink / raw)
  To: devel; +Cc: Bret Barkelew, Liming Gao, Michael D Kinney

From: Michael Kubacki <michael.kubacki@microsoft.com>

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

The framework handle can be retrieved from GetActiveFrameworkHandle()
internal to SaveFrameworkState() so this change removes the parameter
from the function signature.

Cc: Bret Barkelew <brbarkel@microsoft.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
---
 MdePkg/Include/Library/UnitTestLib.h | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/MdePkg/Include/Library/UnitTestLib.h b/MdePkg/Include/Library/UnitTestLib.h
index c06c36bea5aa..a4374580a8d5 100644
--- a/MdePkg/Include/Library/UnitTestLib.h
+++ b/MdePkg/Include/Library/UnitTestLib.h
@@ -313,11 +313,9 @@ FreeUnitTestFramework (
   at least the current execution count) which will be saved by the framework and
   passed to the test case upon resume.
 
-  Generally called from within a test case prior to quitting or rebooting.
+  This should be called while the current test framework is valid and active. It is
+  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
@@ -325,7 +323,7 @@ FreeUnitTestFramework (
   @param[in]  ContextToSaveSize  Size of the ContextToSave buffer.
 
   @retval  EFI_SUCCESS            The framework state and context were saved.
-  @retval  EFI_INVALID_PARAMETER  FrameworkHandle is NULL.
+  @retval  EFI_NOT_FOUND          An active framework handle was not found.
   @retval  EFI_INVALID_PARAMETER  ContextToSave is not NULL and
                                   ContextToSaveSize is 0.
   @retval  EFI_INVALID_PARAMETER  ContextToSave is >= 4GB.
@@ -338,7 +336,6 @@ FreeUnitTestFramework (
 EFI_STATUS
 EFIAPI
 SaveFrameworkState (
-  IN UNIT_TEST_FRAMEWORK_HANDLE  FrameworkHandle,
   IN UNIT_TEST_CONTEXT           ContextToSave     OPTIONAL,
   IN UINTN                       ContextToSaveSize
   );
-- 
2.16.3.windows.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v1 2/2] UnitTestFrameworkPkg/UnitTestLib: Update SaveFrameworkState() signature
       [not found] <20200421183502.39876-1-michael.kubacki@outlook.com>
  2020-04-21 18:35 ` [PATCH v1 1/2] MdePkg/UnitTestLib.h: Drop FrameworkHandle param from SaveFrameworkState() Michael Kubacki
@ 2020-04-21 18:35 ` Michael Kubacki
  2020-05-15  1:12   ` Michael D Kinney
  1 sibling, 1 reply; 4+ messages in thread
From: Michael Kubacki @ 2020-04-21 18:35 UTC (permalink / raw)
  To: devel; +Cc: Bret Barkelew, Sean Brogan, Michael D Kinney

From: Michael Kubacki <michael.kubacki@microsoft.com>

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>
---
 UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c    |  2 +-
 UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c | 25 ++++++++++++--------
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
index b053e0495912..793335fd0f05 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 b136992d99a0..e2405251f0f4 100644
--- a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
+++ b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
@@ -783,11 +783,9 @@ SerializeState (
   at least the current execution count) which will be saved by the framework and
   passed to the test case upon resume.
 
-  Generally called from within a test case prior to quitting or rebooting.
+  This should be called while the current test framework is valid and active. It is
+  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
@@ -795,7 +793,7 @@ SerializeState (
   @param[in]  ContextToSaveSize  Size of the ContextToSave buffer.
 
   @retval  EFI_SUCCESS            The framework state and context were saved.
-  @retval  EFI_INVALID_PARAMETER  FrameworkHandle is NULL.
+  @retval  EFI_NOT_FOUND          An active framework handle was not found.
   @retval  EFI_INVALID_PARAMETER  ContextToSave is not NULL and
                                   ContextToSaveSize is 0.
   @retval  EFI_INVALID_PARAMETER  ContextToSave is >= 4GB.
@@ -808,21 +806,28 @@ 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 ();
+
+  //
+  // Return a unique error code if the framework is not set.
+  //
+  if (FrameworkHandle == NULL) {
+    return EFI_NOT_FOUND;
+  }
 
   //
   // 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.16.3.windows.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 2/2] UnitTestFrameworkPkg/UnitTestLib: Update SaveFrameworkState() signature
  2020-04-21 18:35 ` [PATCH v1 2/2] UnitTestFrameworkPkg/UnitTestLib: Update SaveFrameworkState() signature Michael Kubacki
@ 2020-05-15  1:12   ` Michael D Kinney
  0 siblings, 0 replies; 4+ messages in thread
From: Michael D Kinney @ 2020-05-15  1:12 UTC (permalink / raw)
  To: michael.kubacki@outlook.com, devel@edk2.groups.io,
	Kinney, Michael D
  Cc: Bret Barkelew, Sean Brogan

Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>

Mike

> -----Original Message-----
> From: michael.kubacki@outlook.com
> <michael.kubacki@outlook.com>
> Sent: Tuesday, April 21, 2020 11:35 AM
> To: devel@edk2.groups.io
> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>; Sean
> Brogan <sean.brogan@microsoft.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>
> Subject: [PATCH v1 2/2]
> UnitTestFrameworkPkg/UnitTestLib: Update
> SaveFrameworkState() signature
> 
> From: Michael Kubacki <michael.kubacki@microsoft.com>
> 
> 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>
> ---
>  UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> |  2 +-
>  UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
> | 25 ++++++++++++--------
>  2 files changed, 16 insertions(+), 11 deletions(-)
> 
> diff --git
> a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> index b053e0495912..793335fd0f05 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 b136992d99a0..e2405251f0f4 100644
> ---
> a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.
> c
> +++
> b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.
> c
> @@ -783,11 +783,9 @@ SerializeState (
>    at least the current execution count) which will be
> saved by the framework and
>    passed to the test case upon resume.
> 
> -  Generally called from within a test case prior to
> quitting or rebooting.
> +  This should be called while the current test
> framework is valid and active. It is
> +  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
> @@ -795,7 +793,7 @@ SerializeState (
>    @param[in]  ContextToSaveSize  Size of the
> ContextToSave buffer.
> 
>    @retval  EFI_SUCCESS            The framework state
> and context were saved.
> -  @retval  EFI_INVALID_PARAMETER  FrameworkHandle is
> NULL.
> +  @retval  EFI_NOT_FOUND          An active framework
> handle was not found.
>    @retval  EFI_INVALID_PARAMETER  ContextToSave is not
> NULL and
>                                    ContextToSaveSize is
> 0.
>    @retval  EFI_INVALID_PARAMETER  ContextToSave is >=
> 4GB.
> @@ -808,21 +806,28 @@ 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 ();
> +
> +  //
> +  // Return a unique error code if the framework is
> not set.
> +  //
> +  if (FrameworkHandle == NULL) {
> +    return EFI_NOT_FOUND;
> +  }
> 
>    //
>    // 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.16.3.windows.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [edk2-devel] [PATCH v1 1/2] MdePkg/UnitTestLib.h: Drop FrameworkHandle param from SaveFrameworkState()
  2020-04-21 18:35 ` [PATCH v1 1/2] MdePkg/UnitTestLib.h: Drop FrameworkHandle param from SaveFrameworkState() Michael Kubacki
@ 2020-06-05  8:13   ` Zhiguang Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Zhiguang Liu @ 2020-06-05  8:13 UTC (permalink / raw)
  To: devel@edk2.groups.io, michael.kubacki@outlook.com
  Cc: Bret Barkelew, Gao, Liming, Kinney, Michael D

Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael
> Kubacki
> Sent: Wednesday, April 22, 2020 2:35 AM
> To: devel@edk2.groups.io
> Cc: Bret Barkelew <brbarkel@microsoft.com>; Gao, Liming
> <liming.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: [edk2-devel] [PATCH v1 1/2] MdePkg/UnitTestLib.h: Drop
> FrameworkHandle param from SaveFrameworkState()
> 
> From: Michael Kubacki <michael.kubacki@microsoft.com>
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2612
> 
> The framework handle can be retrieved from GetActiveFrameworkHandle()
> internal to SaveFrameworkState() so this change removes the parameter
> from the function signature.
> 
> Cc: Bret Barkelew <brbarkel@microsoft.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
> ---
>  MdePkg/Include/Library/UnitTestLib.h | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/MdePkg/Include/Library/UnitTestLib.h
> b/MdePkg/Include/Library/UnitTestLib.h
> index c06c36bea5aa..a4374580a8d5 100644
> --- a/MdePkg/Include/Library/UnitTestLib.h
> +++ b/MdePkg/Include/Library/UnitTestLib.h
> @@ -313,11 +313,9 @@ FreeUnitTestFramework (
>    at least the current execution count) which will be saved by the framework
> and
>    passed to the test case upon resume.
> 
> -  Generally called from within a test case prior to quitting or rebooting.
> +  This should be called while the current test framework is valid and active. It
> is
> +  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
> @@ -325,7 +323,7 @@ FreeUnitTestFramework (
>    @param[in]  ContextToSaveSize  Size of the ContextToSave buffer.
> 
>    @retval  EFI_SUCCESS            The framework state and context were saved.
> -  @retval  EFI_INVALID_PARAMETER  FrameworkHandle is NULL.
> +  @retval  EFI_NOT_FOUND          An active framework handle was not found.
>    @retval  EFI_INVALID_PARAMETER  ContextToSave is not NULL and
>                                    ContextToSaveSize is 0.
>    @retval  EFI_INVALID_PARAMETER  ContextToSave is >= 4GB.
> @@ -338,7 +336,6 @@ FreeUnitTestFramework (
>  EFI_STATUS
>  EFIAPI
>  SaveFrameworkState (
> -  IN UNIT_TEST_FRAMEWORK_HANDLE  FrameworkHandle,
>    IN UNIT_TEST_CONTEXT           ContextToSave     OPTIONAL,
>    IN UINTN                       ContextToSaveSize
>    );
> --
> 2.16.3.windows.1
> 
> 
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-06-05  8:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20200421183502.39876-1-michael.kubacki@outlook.com>
2020-04-21 18:35 ` [PATCH v1 1/2] MdePkg/UnitTestLib.h: Drop FrameworkHandle param from SaveFrameworkState() Michael Kubacki
2020-06-05  8:13   ` [edk2-devel] " Zhiguang Liu
2020-04-21 18:35 ` [PATCH v1 2/2] UnitTestFrameworkPkg/UnitTestLib: Update SaveFrameworkState() signature Michael Kubacki
2020-05-15  1:12   ` Michael D Kinney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox