Re: [edk2-devel] [PATCH] Check return status on calls to GetTime()

2020-08-11 Thread G Edhaya Chandran
Upstreamed by Commit ID: cf364d100690e635897f48ade769583d19a78ed0

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

View/Reply Online (#64013): https://edk2.groups.io/g/devel/message/64013
Mute This Topic: https://groups.io/mt/75912028/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH] Check return status on calls to GetTime()

2020-08-11 Thread G Edhaya Chandran
Reviewed-by: G Edhaya Chandran

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

View/Reply Online (#64012): https://edk2.groups.io/g/devel/message/64012
Mute This Topic: https://groups.io/mt/75912028/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH] Check return status on calls to GetTime()

2020-08-06 Thread Heinrich Schuchardt
On 06.08.20 15:31, Samer El-Haj-Mahmoud wrote:
> One issue here is that UEFI 2.8 spec language around allowing runtime 
> services (like GetTime() ) to return EFI_UNSUPPORTED is a bit vague:
>
> ""
> EFI_UNSUPPORTED
> This call is not supported by this platform at the time the call is made. The 
> platform should describe this runtime service as unsupported at runtime via 
> an EFI_RT_PROPERTIES_TABLE configuration table.
> ""
>
> The "at the time the call is made" language may be interpreted as the service 
> is allowed to return EFI_UNSUPPORTED anytime (before or after 
> ExitBootServices() ). But the next sentence (about declaring the unsupported 
> at runtime) make it sounds like this is restricted to only being at runtime. 
> While the use case makes sense, we may need some clarification in the UEFI 
> spec language to make this clear. Otherwise, callers (like SCT) may assume 
> the function is always supported.

Some systems do not have a real time clock. So these system have to
return EFI_UNSUPPORTED before as well as after ExitBootServices().

Due to possible conflicts with the access by the operating system many
systems with RTC will opt not to implement GetTime() at runtime but may
implement GetTime() before ExitBootServices(). This is what we do in U-Boot.

But of cause it is allowable to provide the service at all times if
feasible.

An implementation supplying GetTime() only after ExitBootServices()
would not make much sense to me but is not explicitly forbidden by the spec.

A clearer wording for the spec might be:

"If the service is available at runtime or not, has to be marked in the
EFI_RT_PROPROPERTIES_TABLE."

Best regards

Heinrich

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

View/Reply Online (#63784): https://edk2.groups.io/g/devel/message/63784
Mute This Topic: https://groups.io/mt/75912028/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH] Check return status on calls to GetTime()

2020-08-06 Thread Samer El-Haj-Mahmoud
One issue here is that UEFI 2.8 spec language around allowing runtime services 
(like GetTime() ) to return EFI_UNSUPPORTED is a bit vague:

""
EFI_UNSUPPORTED
This call is not supported by this platform at the time the call is made. The 
platform should describe this runtime service as unsupported at runtime via an 
EFI_RT_PROPERTIES_TABLE configuration table.
""

The "at the time the call is made" language may be interpreted as the service 
is allowed to return EFI_UNSUPPORTED anytime (before or after 
ExitBootServices() ). But the next sentence (about declaring the unsupported at 
runtime) make it sounds like this is restricted to only being at runtime. While 
the use case makes sense, we may need some clarification in the UEFI spec 
language to make this clear. Otherwise, callers (like SCT) may assume the 
function is always supported.

> -Original Message-
> From: Samer El-Haj-Mahmoud 
> Sent: Tuesday, August 4, 2020 7:27 AM
> To: Grant Likely ; devel@edk2.groups.io
> Cc: nd ; G Edhaya Chandran ;
> Heinrich Schuchardt ; Samer El-Haj-Mahmoud
> 
> Subject: RE: [PATCH] Check return status on calls to GetTime()
> 
> Reviewed-by: Samer El-Haj-Mahmoud 
> 
> > -Original Message-
> > From: Grant Likely 
> > Sent: Friday, July 31, 2020 1:20 PM
> > To: devel@edk2.groups.io
> > Cc: nd ; Grant Likely ; G Edhaya
> > Chandran ; Heinrich Schuchardt
> > ; Samer El-Haj-Mahmoud  > mahm...@arm.com>
> > Subject: [PATCH] Check return status on calls to GetTime()
> >
> > Not all platforms implement GetTime(), but the SCT just assumes calls
> > to GetTime will be successful. If GetTime() doesn't return
> > EFI_SUCCESS, then the EFI_TIME value will be uninitialized data.
> >
> > Fix by checking the GetTime() return code. If it doesn't return
> > EFI_SUCCESS, then use the traditional 1/1/1970 epoch so that the test
> > report at least looks sane, but it is obvious that we don't have a valid
> timestamp.
> >
> > Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=2870
> >
> > Cc: G Edhaya Chandran 
> > Cc: Heinrich Schuchardt 
> > Cc: Samer El-Haj-Mahmoud 
> > Signed-off-by: Grant Likely 
> > ---
> >  .../SimpleNetwork/SimpleNetworkENTSTestCase.c | 26 +
> > --
> >  .../MiscBootServicesBBTestFunction.c  |  8 --
> >  .../DriverBindingBBTestFunction.c |  5 +++-
> >  .../SCT/Drivers/StandardTest/StandardTest.c   | 11 +---
> >  .../Framework/ENTS/EasDispatcher/Core/Eas.c   |  9 +--
> >  .../ENTS/EasDispatcher/Exec/EasCmdDisp.c  | 20 +-
> >  6 files changed, 57 insertions(+), 22 deletions(-)
> >
> > diff --git a/uefi-
> > sct/SctPkg/TestCase/RIVL/Protocol/SimpleNetwork/SimpleNetworkENTSTes
> > tCase.c b/uefi-
> > sct/SctPkg/TestCase/RIVL/Protocol/SimpleNetwork/SimpleNetworkENTSTes
> > tCase.c
> > index 9c8d2a70..5579be7e 100644
> > --- a/uefi-
> > sct/SctPkg/TestCase/RIVL/Protocol/SimpleNetwork/SimpleNetworkENTSTes
> > tCase.c
> > +++ b/uefi-
> > sct/SctPkg/TestCase/RIVL/Protocol/SimpleNetwork/SimpleNetwork
> > +++ ENTSTestCase.c
> > @@ -24,6 +24,8 @@ Abstract:
> >
> >  #include "SimpleNetworkENTSTestCase.h"
> >
> > +static EFI_TIME Epoch = { .Year = 1970, .Month = 1, .Day = 1 };
> > +
> >  //
> >  // SimpleNetwork.Start
> >  //
> > @@ -928,7 +930,8 @@ Returns:
> >Status  = EFI_SUCCESS;
> >tBS->Stall (5000);
> >
> > -  tRT->GetTime (, NULL);
> > +  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
> > +BeginTime = Epoch;
> >for (Index = 0; Index < 1;) {
> >  Status = SimpleNetwork->Transmit (
> >SimpleNetwork, @@ -964,7 +967,8 @@ Returns:
> >  }
> >}
> >
> > -  tRT->GetTime (, NULL);
> > +  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
> > +BeginTime = Epoch;
> >
> >for (Index = 1; Index < TransmitPattern1Number;) {
> >  Status = SimpleNetwork->Transmit ( @@ -1002,7 +1006,8 @@ Returns:
> >}
> >
> >  End:
> > -  tRT->GetTime (, NULL);
> > +  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
> > +EndTime = Epoch;
> >
> >*TransmitPattern1Status = Status;
> >
> > @@ -1125,7 +1130,8 @@ Returns:
> >Status  = EFI_SUCCESS;
> >tBS->Stall (5000);
> >
> > -  tRT->GetTime (, NULL);
> > +  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
> > +BeginTime = Epoch;
> >for (Index = 0; Index < 1;) {
> >  Status = SimpleNetwork->Transmit (
> >SimpleNetwork, @@ -1161,7 +1167,8 @@ Returns:
> >  }
> >}
> >
> > -  tRT->GetTime (, NULL);
> > +  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
> > +BeginTime = Epoch;
> >
> >for (Index = 1; Index < TransmitPattern2Number;) {
> >  Status = SimpleNetwork->Transmit ( @@ -1199,7 +1206,8 @@ Returns:
> >}
> >
> >  End:
> > -  tRT->GetTime (, NULL);
> > +  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
> > +EndTime = Epoch;
> >
> >*TransmitPattern1Status = Status;
> >
> > @@ -1326,7 +1334,8 @@ Returns:
> >  }
> >}
> >
> > -  tRT->GetTime (, NULL);
> > +  if (tRT->GetTime (, NULL) != 

Re: [edk2-devel] [PATCH] Check return status on calls to GetTime()

2020-08-04 Thread Grant Likely




On 01/08/2020 14:54, Heinrich Schuchardt wrote:

On 7/31/20 7:19 PM, Grant Likely wrote:
[...]>> diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/MiscBootServicesBBTestFunction.c 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/MiscBootServicesBBTestFunction.c

index 1d231d8c..3a530282 100644
--- 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/MiscBootServicesBBTestFunction.c
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/MiscBootServicesBBTestFunction.c
@@ -27,6 +27,8 @@ Abstract:
  #include "SctLib.h"


I tried to apply your patch with 'git am --keep-cr'. This chunk has a
problem.

While all other lines in the file have CR LF line endings this very line
has only LF in EDK2 master. But your patch has CR LF for the line.

Did you use Windows and not Linux to create the patch?


Hahaha! No, I did not use Windows. From what I can tell, that file 
already had inconsisten line endings. Most of the file is crlf, but the 
"#include "SctLib.h" line is lf only. This confuses vim which interprets 
it as a unix file and shows the ^M on every line, which in turn allowed 
me to add additional lines with unix line endings.



I could apply your patch after removing the extraneous CR.

With your patch applied if GetTime() returns EFI_UNSUPPORTED, the test
log is not garbled anymore:

SetVariable_Conf:
Test Finished: 01/01/70  12:00a
Elapsed Time: 00 Days 00:00:00

If GetTime() is available:

SetVariable_Conf:
Test Finished: 08/01/20  01:52p
Elapsed Time: 00 Days 00:00:04

Except for the line-endings:

Reviewed-by: Heinrich Schuchardt 


Ace! Thanks.

g.


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

View/Reply Online (#63705): https://edk2.groups.io/g/devel/message/63705
Mute This Topic: https://groups.io/mt/75912028/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH] Check return status on calls to GetTime()

2020-08-04 Thread Samer El-Haj-Mahmoud
Reviewed-by: Samer El-Haj-Mahmoud 

> -Original Message-
> From: Grant Likely 
> Sent: Friday, July 31, 2020 1:20 PM
> To: devel@edk2.groups.io
> Cc: nd ; Grant Likely ; G Edhaya
> Chandran ; Heinrich Schuchardt
> ; Samer El-Haj-Mahmoud  mahm...@arm.com>
> Subject: [PATCH] Check return status on calls to GetTime()
> 
> Not all platforms implement GetTime(), but the SCT just assumes calls to
> GetTime will be successful. If GetTime() doesn't return EFI_SUCCESS, then
> the EFI_TIME value will be uninitialized data.
> 
> Fix by checking the GetTime() return code. If it doesn't return EFI_SUCCESS,
> then use the traditional 1/1/1970 epoch so that the test report at least looks
> sane, but it is obvious that we don't have a valid timestamp.
> 
> Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=2870
> 
> Cc: G Edhaya Chandran 
> Cc: Heinrich Schuchardt 
> Cc: Samer El-Haj-Mahmoud 
> Signed-off-by: Grant Likely 
> ---
>  .../SimpleNetwork/SimpleNetworkENTSTestCase.c | 26 +
> --
>  .../MiscBootServicesBBTestFunction.c  |  8 --
>  .../DriverBindingBBTestFunction.c |  5 +++-
>  .../SCT/Drivers/StandardTest/StandardTest.c   | 11 +---
>  .../Framework/ENTS/EasDispatcher/Core/Eas.c   |  9 +--
>  .../ENTS/EasDispatcher/Exec/EasCmdDisp.c  | 20 +-
>  6 files changed, 57 insertions(+), 22 deletions(-)
> 
> diff --git a/uefi-
> sct/SctPkg/TestCase/RIVL/Protocol/SimpleNetwork/SimpleNetworkENTSTes
> tCase.c b/uefi-
> sct/SctPkg/TestCase/RIVL/Protocol/SimpleNetwork/SimpleNetworkENTSTes
> tCase.c
> index 9c8d2a70..5579be7e 100644
> --- a/uefi-
> sct/SctPkg/TestCase/RIVL/Protocol/SimpleNetwork/SimpleNetworkENTSTes
> tCase.c
> +++ b/uefi-
> sct/SctPkg/TestCase/RIVL/Protocol/SimpleNetwork/SimpleNetwork
> +++ ENTSTestCase.c
> @@ -24,6 +24,8 @@ Abstract:
> 
>  #include "SimpleNetworkENTSTestCase.h"
> 
> +static EFI_TIME Epoch = { .Year = 1970, .Month = 1, .Day = 1 };
> +
>  //
>  // SimpleNetwork.Start
>  //
> @@ -928,7 +930,8 @@ Returns:
>Status  = EFI_SUCCESS;
>tBS->Stall (5000);
> 
> -  tRT->GetTime (, NULL);
> +  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
> +BeginTime = Epoch;
>for (Index = 0; Index < 1;) {
>  Status = SimpleNetwork->Transmit (
>SimpleNetwork, @@ -964,7 +967,8 @@ Returns:
>  }
>}
> 
> -  tRT->GetTime (, NULL);
> +  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
> +BeginTime = Epoch;
> 
>for (Index = 1; Index < TransmitPattern1Number;) {
>  Status = SimpleNetwork->Transmit (
> @@ -1002,7 +1006,8 @@ Returns:
>}
> 
>  End:
> -  tRT->GetTime (, NULL);
> +  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
> +EndTime = Epoch;
> 
>*TransmitPattern1Status = Status;
> 
> @@ -1125,7 +1130,8 @@ Returns:
>Status  = EFI_SUCCESS;
>tBS->Stall (5000);
> 
> -  tRT->GetTime (, NULL);
> +  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
> +BeginTime = Epoch;
>for (Index = 0; Index < 1;) {
>  Status = SimpleNetwork->Transmit (
>SimpleNetwork, @@ -1161,7 +1167,8 @@ Returns:
>  }
>}
> 
> -  tRT->GetTime (, NULL);
> +  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
> +BeginTime = Epoch;
> 
>for (Index = 1; Index < TransmitPattern2Number;) {
>  Status = SimpleNetwork->Transmit (
> @@ -1199,7 +1206,8 @@ Returns:
>}
> 
>  End:
> -  tRT->GetTime (, NULL);
> +  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
> +EndTime = Epoch;
> 
>*TransmitPattern1Status = Status;
> 
> @@ -1326,7 +1334,8 @@ Returns:
>  }
>}
> 
> -  tRT->GetTime (, NULL);
> +  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
> +BeginTime = Epoch;
> 
>for (Index = 1; Index < ReceivePattern1Number;) {
>  *ReceivePattern1BufferSize = BufferSizeOrg; @@ -1346,7 +1355,8 @@
> Returns:
>  }
>}
> 
> -  tRT->GetTime (, NULL);
> +  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
> +EndTime = Epoch;
> 
>*ReceivePattern1Status = Status;
> 
> diff --git a/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest
> /MiscBootServicesBBTestFunction.c b/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest
> /MiscBootServicesBBTestFunction.c
> index 1d231d8c..3a530282 100644
> --- a/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest
> /MiscBootServicesBBTestFunction.c
> +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/Bl
> +++ ackBoxTest/MiscBootServicesBBTestFunction.c
> @@ -27,6 +27,8 @@ Abstract:
>  #include "SctLib.h"
>  #include "MiscBootServicesBBTestMain.h"
> 
> +static EFI_TIME Epoch = { .Year = 1970, .Month = 1, .Day = 1 };
> +
>  /**
>   *  Entrypoint for gtBS->SetWatchdogTimer() Interface Test.
>   *  @param This a pointer of EFI_BB_TEST_PROTOCOL.
> @@ -821,13 +823,15 @@ BBTestStallInterfaceTest (
>  //
>  // 4.2.2.1  Stall must succeed.
>  //
> -gtRT->GetTime (, NULL);
> +if (gtRT->GetTime (, NULL) != 

Re: [edk2-devel] [PATCH] Check return status on calls to GetTime()

2020-08-01 Thread Heinrich Schuchardt
On 7/31/20 7:19 PM, Grant Likely wrote:
> Not all platforms implement GetTime(), but the SCT just assumes calls to
> GetTime will be successful. If GetTime() doesn't return EFI_SUCCESS,
> then the EFI_TIME value will be uninitialized data.
>
> Fix by checking the GetTime() return code. If it doesn't return
> EFI_SUCCESS, then use the traditional 1/1/1970 epoch so that the test
> report at least looks sane, but it is obvious that we don't have a valid
> timestamp.
>
> Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=2870
>
> Cc: G Edhaya Chandran 
> Cc: Heinrich Schuchardt 
> Cc: Samer El-Haj-Mahmoud 
> Signed-off-by: Grant Likely 
> ---
>  .../SimpleNetwork/SimpleNetworkENTSTestCase.c | 26 +--
>  .../MiscBootServicesBBTestFunction.c  |  8 --
>  .../DriverBindingBBTestFunction.c |  5 +++-
>  .../SCT/Drivers/StandardTest/StandardTest.c   | 11 +---
>  .../Framework/ENTS/EasDispatcher/Core/Eas.c   |  9 +--
>  .../ENTS/EasDispatcher/Exec/EasCmdDisp.c  | 20 +-
>  6 files changed, 57 insertions(+), 22 deletions(-)
>
> diff --git 
> a/uefi-sct/SctPkg/TestCase/RIVL/Protocol/SimpleNetwork/SimpleNetworkENTSTestCase.c
>  
> b/uefi-sct/SctPkg/TestCase/RIVL/Protocol/SimpleNetwork/SimpleNetworkENTSTestCase.c
> index 9c8d2a70..5579be7e 100644
> --- 
> a/uefi-sct/SctPkg/TestCase/RIVL/Protocol/SimpleNetwork/SimpleNetworkENTSTestCase.c
> +++ 
> b/uefi-sct/SctPkg/TestCase/RIVL/Protocol/SimpleNetwork/SimpleNetworkENTSTestCase.c
> @@ -24,6 +24,8 @@ Abstract:
>
>  #include "SimpleNetworkENTSTestCase.h"
>
> +static EFI_TIME Epoch = { .Year = 1970, .Month = 1, .Day = 1 };
> +
>  //
>  // SimpleNetwork.Start
>  //
> @@ -928,7 +930,8 @@ Returns:
>Status  = EFI_SUCCESS;
>tBS->Stall (5000);
>
> -  tRT->GetTime (, NULL);
> +  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
> +BeginTime = Epoch;
>for (Index = 0; Index < 1;) {
>  Status = SimpleNetwork->Transmit (
>SimpleNetwork,
> @@ -964,7 +967,8 @@ Returns:
>  }
>}
>
> -  tRT->GetTime (, NULL);
> +  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
> +BeginTime = Epoch;
>
>for (Index = 1; Index < TransmitPattern1Number;) {
>  Status = SimpleNetwork->Transmit (
> @@ -1002,7 +1006,8 @@ Returns:
>}
>
>  End:
> -  tRT->GetTime (, NULL);
> +  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
> +EndTime = Epoch;
>
>*TransmitPattern1Status = Status;
>
> @@ -1125,7 +1130,8 @@ Returns:
>Status  = EFI_SUCCESS;
>tBS->Stall (5000);
>
> -  tRT->GetTime (, NULL);
> +  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
> +BeginTime = Epoch;
>for (Index = 0; Index < 1;) {
>  Status = SimpleNetwork->Transmit (
>SimpleNetwork,
> @@ -1161,7 +1167,8 @@ Returns:
>  }
>}
>
> -  tRT->GetTime (, NULL);
> +  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
> +BeginTime = Epoch;
>
>for (Index = 1; Index < TransmitPattern2Number;) {
>  Status = SimpleNetwork->Transmit (
> @@ -1199,7 +1206,8 @@ Returns:
>}
>
>  End:
> -  tRT->GetTime (, NULL);
> +  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
> +EndTime = Epoch;
>
>*TransmitPattern1Status = Status;
>
> @@ -1326,7 +1334,8 @@ Returns:
>  }
>}
>
> -  tRT->GetTime (, NULL);
> +  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
> +BeginTime = Epoch;
>
>for (Index = 1; Index < ReceivePattern1Number;) {
>  *ReceivePattern1BufferSize = BufferSizeOrg;
> @@ -1346,7 +1355,8 @@ Returns:
>  }
>}
>
> -  tRT->GetTime (, NULL);
> +  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
> +EndTime = Epoch;
>
>*ReceivePattern1Status = Status;
>
> diff --git 
> a/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/MiscBootServicesBBTestFunction.c
>  
> b/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/MiscBootServicesBBTestFunction.c
> index 1d231d8c..3a530282 100644
> --- 
> a/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/MiscBootServicesBBTestFunction.c
> +++ 
> b/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/MiscBootServicesBBTestFunction.c
> @@ -27,6 +27,8 @@ Abstract:
>  #include "SctLib.h"

I tried to apply your patch with 'git am --keep-cr'. This chunk has a
problem.

While all other lines in the file have CR LF line endings this very line
has only LF in EDK2 master. But your patch has CR LF for the line.

Did you use Windows and not Linux to create the patch?

I could apply your patch after removing the extraneous CR.

With your patch applied if GetTime() returns EFI_UNSUPPORTED, the test
log is not garbled anymore:

SetVariable_Conf:
Test Finished: 01/01/70  12:00a
Elapsed Time: 00 Days 00:00:00

If GetTime() is available:

SetVariable_Conf:
Test Finished: 08/01/20  01:52p
Elapsed Time: 00 Days 00:00:04

Except for the line-endings:

Reviewed-by: Heinrich Schuchardt 

>  #include "MiscBootServicesBBTestMain.h"
>
> +static EFI_TIME 

[edk2-devel] [PATCH] Check return status on calls to GetTime()

2020-07-31 Thread Grant Likely
Not all platforms implement GetTime(), but the SCT just assumes calls to
GetTime will be successful. If GetTime() doesn't return EFI_SUCCESS,
then the EFI_TIME value will be uninitialized data.

Fix by checking the GetTime() return code. If it doesn't return
EFI_SUCCESS, then use the traditional 1/1/1970 epoch so that the test
report at least looks sane, but it is obvious that we don't have a valid
timestamp.

Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=2870

Cc: G Edhaya Chandran 
Cc: Heinrich Schuchardt 
Cc: Samer El-Haj-Mahmoud 
Signed-off-by: Grant Likely 
---
 .../SimpleNetwork/SimpleNetworkENTSTestCase.c | 26 +--
 .../MiscBootServicesBBTestFunction.c  |  8 --
 .../DriverBindingBBTestFunction.c |  5 +++-
 .../SCT/Drivers/StandardTest/StandardTest.c   | 11 +---
 .../Framework/ENTS/EasDispatcher/Core/Eas.c   |  9 +--
 .../ENTS/EasDispatcher/Exec/EasCmdDisp.c  | 20 +-
 6 files changed, 57 insertions(+), 22 deletions(-)

diff --git 
a/uefi-sct/SctPkg/TestCase/RIVL/Protocol/SimpleNetwork/SimpleNetworkENTSTestCase.c
 
b/uefi-sct/SctPkg/TestCase/RIVL/Protocol/SimpleNetwork/SimpleNetworkENTSTestCase.c
index 9c8d2a70..5579be7e 100644
--- 
a/uefi-sct/SctPkg/TestCase/RIVL/Protocol/SimpleNetwork/SimpleNetworkENTSTestCase.c
+++ 
b/uefi-sct/SctPkg/TestCase/RIVL/Protocol/SimpleNetwork/SimpleNetworkENTSTestCase.c
@@ -24,6 +24,8 @@ Abstract:
 
 #include "SimpleNetworkENTSTestCase.h"
 
+static EFI_TIME Epoch = { .Year = 1970, .Month = 1, .Day = 1 };
+
 //
 // SimpleNetwork.Start
 //
@@ -928,7 +930,8 @@ Returns:
   Status  = EFI_SUCCESS;
   tBS->Stall (5000);
 
-  tRT->GetTime (, NULL);
+  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
+BeginTime = Epoch;
   for (Index = 0; Index < 1;) {
 Status = SimpleNetwork->Transmit (
   SimpleNetwork,
@@ -964,7 +967,8 @@ Returns:
 }
   }
 
-  tRT->GetTime (, NULL);
+  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
+BeginTime = Epoch;
 
   for (Index = 1; Index < TransmitPattern1Number;) {
 Status = SimpleNetwork->Transmit (
@@ -1002,7 +1006,8 @@ Returns:
   }
 
 End:
-  tRT->GetTime (, NULL);
+  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
+EndTime = Epoch;
 
   *TransmitPattern1Status = Status;
 
@@ -1125,7 +1130,8 @@ Returns:
   Status  = EFI_SUCCESS;
   tBS->Stall (5000);
 
-  tRT->GetTime (, NULL);
+  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
+BeginTime = Epoch;
   for (Index = 0; Index < 1;) {
 Status = SimpleNetwork->Transmit (
   SimpleNetwork,
@@ -1161,7 +1167,8 @@ Returns:
 }
   }
 
-  tRT->GetTime (, NULL);
+  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
+BeginTime = Epoch;
 
   for (Index = 1; Index < TransmitPattern2Number;) {
 Status = SimpleNetwork->Transmit (
@@ -1199,7 +1206,8 @@ Returns:
   }
 
 End:
-  tRT->GetTime (, NULL);
+  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
+EndTime = Epoch;
 
   *TransmitPattern1Status = Status;
 
@@ -1326,7 +1334,8 @@ Returns:
 }
   }
 
-  tRT->GetTime (, NULL);
+  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
+BeginTime = Epoch;
 
   for (Index = 1; Index < ReceivePattern1Number;) {
 *ReceivePattern1BufferSize = BufferSizeOrg;
@@ -1346,7 +1355,8 @@ Returns:
 }
   }
 
-  tRT->GetTime (, NULL);
+  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
+EndTime = Epoch;
 
   *ReceivePattern1Status = Status;
 
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/MiscBootServicesBBTestFunction.c
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/MiscBootServicesBBTestFunction.c
index 1d231d8c..3a530282 100644
--- 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/MiscBootServicesBBTestFunction.c
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/MiscBootServicesBBTestFunction.c
@@ -27,6 +27,8 @@ Abstract:
 #include "SctLib.h"
 #include "MiscBootServicesBBTestMain.h"
 
+static EFI_TIME Epoch = { .Year = 1970, .Month = 1, .Day = 1 };
+
 /**
  *  Entrypoint for gtBS->SetWatchdogTimer() Interface Test.
  *  @param This a pointer of EFI_BB_TEST_PROTOCOL.
@@ -821,13 +823,15 @@ BBTestStallInterfaceTest (
 //
 // 4.2.2.1  Stall must succeed.
 //
-gtRT->GetTime (, NULL);
+if (gtRT->GetTime (, NULL) != EFI_SUCCESS)
+  StartTime = Epoch;
 OldTpl = gtBS->RaiseTPL (TplArray[Index]);
 Status = gtBS->Stall (
  1000
  );
 gtBS->RestoreTPL (OldTpl);
-gtRT->GetTime (, NULL);
+if (gtRT->GetTime (, NULL) != EFI_SUCCESS)
+  EndTime = Epoch;
 if (Status == EFI_SUCCESS) {
   AssertionType = EFI_TEST_ASSERTION_PASSED;
 } else {
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/DriverBinding/BlackBoxTest/DriverBindingBBTestFunction.c
 
b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/DriverBinding/BlackBoxTest/DriverBindingBBTestFunction.c
index