public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-test][PATCH] uefi-sct/SctPkg: Fix issues with EfiCompliant test
@ 2018-11-06 10:58 Sakar Arora
  0 siblings, 0 replies; only message in thread
From: Sakar Arora @ 2018-11-06 10:58 UTC (permalink / raw)
  To: edk2-devel; +Cc: prasanth.pulla, John Powell

From: John Powell <john.powell@arm.com>

Fixed errors occurring when an unsupported protocol is under test, in
several places a call to LocateProtocol was assumed to be successful
and the results were used as such, which caused synchronous exceptions
when the calls failed and the code tried to use NULL pointers.

Change-Id: Iede062bc3da675dae72fa24ba167692914e7ded6
Signed-off-by: John Powell <john.powell@arm.com>
---
 .../BlackBoxTest/EfiCompliantBBTestPlatform_uefi.c | 273 ++++++++-------------
 1 file changed, 107 insertions(+), 166 deletions(-)

diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/EfiCompliant/BlackBoxTest/EfiCompliantBBTestPlatform_uefi.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/EfiCompliant/BlackBoxTest/EfiCompliantBBTestPlatform_uefi.c
index 17df564..fb8128e 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/EfiCompliant/BlackBoxTest/EfiCompliantBBTestPlatform_uefi.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/EfiCompliant/BlackBoxTest/EfiCompliantBBTestPlatform_uefi.c
@@ -1497,62 +1497,24 @@ CheckUefiNetworkApplication (
                        NULL,
                        (VOID **)&TempInterface
                        );
-      switch (Index) {
-        case 0:
-          TempInterface->CreateChild(TempInterface, &ChildHandle);
-          break;
-        case 1:
-          TempInterface->CreateChild(TempInterface, &ChildHandle);
-          break;
-        case 2:
-          TempInterface->CreateChild(TempInterface, &ChildHandle);
-          break;
-        case 3:
-          TempInterface->CreateChild(TempInterface, &ChildHandle);
-          break;
-        case 4:
-          TempInterface->CreateChild(TempInterface, &ChildHandle);
-          break;
-        default:
-          TempInterface->CreateChild(TempInterface, &ChildHandle);
-      }
-   
-      Status = gtBS->LocateProtocol (
-                       &Guid[Index+7],
-                       NULL,
-                       (VOID **)&Interface
-                       );
       if (!EFI_ERROR (Status)) {
-        Value[Index+7] = TRUE;
+        TempInterface->CreateChild (TempInterface, &ChildHandle);
+
+        Status = gtBS->LocateProtocol (
+                         &Guid[Index+7],
+                         NULL,
+                         (VOID **)&Interface
+                         );
+        if (!EFI_ERROR (Status)) {
+          Value[Index+7] = TRUE;
+        } else {
+          Value[Index+7] = FALSE;
+        }
+     
+        TempInterface->DestroyChild (TempInterface, ChildHandle);
       } else {
         Value[Index+7] = FALSE;
       }
-   
-      switch (Index) {
-        case 0:
-          TempInterface->DestroyChild(TempInterface, ChildHandle);
-          ChildHandle = NULL;
-          break;
-        case 1:
-          TempInterface->DestroyChild(TempInterface, ChildHandle);
-          ChildHandle = NULL;
-          break;
-        case 2:
-          TempInterface->DestroyChild(TempInterface, ChildHandle);
-          ChildHandle = NULL;
-          break;
-        case 3:
-          TempInterface->DestroyChild(TempInterface, ChildHandle);
-          ChildHandle = NULL;
-          break;
-        case 4:
-          TempInterface->DestroyChild(TempInterface, ChildHandle);
-          ChildHandle = NULL;
-          break;
-        default:
-          TempInterface->DestroyChild(TempInterface, ChildHandle);
-          ChildHandle = NULL;
-      }
     } 
 
     AssertionType = NeedOrWarning (13, Value);
@@ -1695,55 +1657,24 @@ CheckUefiV6NetworkApplication (
                        NULL,
                        (VOID **) &TempInterface
                        );
-      switch (Index) {
-        case 0:
-          TempInterface->CreateChild(TempInterface, &ChildHandle);
-          break;
-        case 1:
-          TempInterface->CreateChild(TempInterface, &ChildHandle);
-          break;
-        case 2:
-          TempInterface->CreateChild(TempInterface, &ChildHandle);
-          break;
-        case 3:
-          TempInterface->CreateChild(TempInterface, &ChildHandle);
-          break;
-        default:
-          TempInterface->CreateChild(TempInterface, &ChildHandle);
-      }
-
-      Status = gtBS->LocateProtocol (
-                       &Guid[Index+5],
-                       NULL,
-                       (VOID **) &Interface
-                       );
       if (!EFI_ERROR (Status)) {
-        Value[Index+5] = TRUE;
+        TempInterface->CreateChild (TempInterface, &ChildHandle);
+
+        Status = gtBS->LocateProtocol (
+                         &Guid[Index+5],
+                         NULL,
+                         (VOID **) &Interface
+                         );
+        if (!EFI_ERROR (Status)) {
+          Value[Index+5] = TRUE;
+        } else {
+          Value[Index+5] = FALSE;
+        }
+        
+        TempInterface->DestroyChild (TempInterface, ChildHandle);
       } else {
         Value[Index+5] = FALSE;
       }
-      
-      switch (Index) {
-        case 0:
-          TempInterface->DestroyChild(TempInterface, ChildHandle);
-          ChildHandle = NULL;
-          break;
-        case 1:
-          TempInterface->DestroyChild(TempInterface, ChildHandle);
-          ChildHandle = NULL;
-          break;
-        case 2:
-          TempInterface->DestroyChild(TempInterface, ChildHandle);
-          ChildHandle = NULL;
-          break;
-        case 3:
-          TempInterface->DestroyChild(TempInterface, ChildHandle);
-          ChildHandle = NULL;
-          break;
-        default:
-          TempInterface->DestroyChild(TempInterface, ChildHandle);
-          ChildHandle = NULL;
-      }
     } 
 
     AssertionType = NeedOrWarning (9, Value);
@@ -2969,24 +2900,26 @@ CheckDNS4Protocols (
                        NULL,
                        (VOID **) &TempInterface
                        );
-
-    TempInterface->CreateChild(TempInterface, &ChildHandle);
-
-
-    Status = gtBS->LocateProtocol (
-                     &gEfiDns4ProtocolGuid,
-                     NULL,
-                     (VOID **) &Interface
-                     );
-    if (!EFI_ERROR (Status)) {
-      ValueB = TRUE;
+    if (!EFI_ERROR (Status)) {
+      TempInterface->CreateChild (TempInterface, &ChildHandle);
+
+      Status = gtBS->LocateProtocol (
+                       &gEfiDns4ProtocolGuid,
+                       NULL,
+                       (VOID **) &Interface
+                       );
+      if (!EFI_ERROR (Status)) {
+        ValueB = TRUE;
+      } else {
+        ValueB = FALSE;
+      }
+
+      TempInterface->DestroyChild (TempInterface, ChildHandle);
+      ChildHandle = NULL;
     } else {
       ValueB = FALSE;
     }
 
-    TempInterface->DestroyChild(TempInterface, ChildHandle);
-    ChildHandle = NULL;
-
     AssertionType = NeedOneOrWarning (ValueB);
 
     if (AssertionType == EFI_TEST_ASSERTION_FAILED) {
@@ -3097,24 +3030,26 @@ CheckDNS6Protocols (
                        NULL,
                        (VOID **) &TempInterface
                        );
-
-    TempInterface->CreateChild(TempInterface, &ChildHandle);
-
-
-    Status = gtBS->LocateProtocol (
-                     &gEfiDns6ProtocolGuid,
-                     NULL,
-                     (VOID **) &Interface
-                     );
-    if (!EFI_ERROR (Status)) {
-      ValueB = TRUE;
+    if (!EFI_ERROR (Status)) {
+      TempInterface->CreateChild (TempInterface, &ChildHandle);
+
+      Status = gtBS->LocateProtocol (
+                       &gEfiDns6ProtocolGuid,
+                       NULL,
+                       (VOID **) &Interface
+                       );
+      if (!EFI_ERROR (Status)) {
+        ValueB = TRUE;
+      } else {
+        ValueB = FALSE;
+      }
+
+      TempInterface->DestroyChild (TempInterface, ChildHandle);
+      ChildHandle = NULL;
     } else {
       ValueB = FALSE;
     }
 
-    TempInterface->DestroyChild(TempInterface, ChildHandle);
-    ChildHandle = NULL;
-
     AssertionType = NeedOneOrWarning (ValueB);
 
     if (AssertionType == EFI_TEST_ASSERTION_FAILED) {
@@ -3238,24 +3173,26 @@ CheckTLSProtocols (
                        NULL,
                        (VOID **) &TempInterface
                        );
-
-    TempInterface->CreateChild(TempInterface, &ChildHandle);
-
-
-    Status = gtBS->LocateProtocol (
-                     &gEfiTlsProtocolGuid,
-                     NULL,
-                     (VOID **) &Interface
-                     );
-    if (!EFI_ERROR (Status)) {
-      ValueC = TRUE;
+    if (!EFI_ERROR (Status)) {
+      TempInterface->CreateChild (TempInterface, &ChildHandle);
+
+      Status = gtBS->LocateProtocol (
+                       &gEfiTlsProtocolGuid,
+                       NULL,
+                       (VOID **) &Interface
+                       );
+      if (!EFI_ERROR (Status)) {
+        ValueC = TRUE;
+      } else {
+        ValueC = FALSE;
+      }
+
+      TempInterface->DestroyChild (TempInterface, ChildHandle);
+      ChildHandle = NULL;
     } else {
       ValueC = FALSE;
     }
 
-    TempInterface->DestroyChild(TempInterface, ChildHandle);
-    ChildHandle = NULL;
-
     AssertionType = NeedOneOrWarning (ValueC);
 
     if (AssertionType == EFI_TEST_ASSERTION_FAILED) {
@@ -3381,24 +3318,26 @@ CheckHTTPProtocols (
                        NULL,
                        (VOID **) &TempInterface
                        );
-
-    TempInterface->CreateChild(TempInterface, &ChildHandle);
-
-
-    Status = gtBS->LocateProtocol (
-                     &gEfiHttpProtocolGuid,
-                     NULL,
-                     (VOID **) &Interface
-                     );
-    if (!EFI_ERROR (Status)) {
-      ValueC = TRUE;
+    if (!EFI_ERROR (Status)){
+      TempInterface->CreateChild (TempInterface, &ChildHandle);
+
+      Status = gtBS->LocateProtocol (
+                       &gEfiHttpProtocolGuid,
+                       NULL,
+                       (VOID **) &Interface
+                       );
+      if (!EFI_ERROR (Status)) {
+        ValueC = TRUE;
+      } else {
+        ValueC = FALSE;
+      }
+
+      TempInterface->DestroyChild (TempInterface, ChildHandle);
+      ChildHandle = NULL;
     } else {
       ValueC = FALSE;
     }
 
-    TempInterface->DestroyChild(TempInterface, ChildHandle);
-    ChildHandle = NULL;
-
     AssertionType = NeedOneOrWarning (ValueC);
 
     if (AssertionType == EFI_TEST_ASSERTION_FAILED) {
@@ -3632,23 +3571,25 @@ CheckBlueToothProtocols (
                        NULL,
                        (VOID **) &TempInterface
                        );
-
-    TempInterface->CreateChild(TempInterface, &ChildHandle);
-
-
-    Status = gtBS->LocateProtocol (
-                     &gEfiBlueToothIoProtocolGuid,
-                     NULL,
-                     (VOID **) &Interface
-                     );
     if (!EFI_ERROR (Status)) {
-      ValueD = TRUE;
+      TempInterface->CreateChild (TempInterface, &ChildHandle);
+
+      Status = gtBS->LocateProtocol (
+                       &gEfiBlueToothIoProtocolGuid,
+                       NULL,
+                       (VOID **) &Interface
+                       );
+      if (!EFI_ERROR (Status)) {
+        ValueD = TRUE;
+      } else {
+        ValueD = FALSE;
+      }
+      
+      TempInterface->DestroyChild (TempInterface, ChildHandle);
+      ChildHandle = NULL;
     } else {
       ValueD = FALSE;
     }
-    
-    TempInterface->DestroyChild(TempInterface, ChildHandle);
-    ChildHandle = NULL;
 
     AssertionType = NeedOneOrWarning (ValueD);
 
-- 
2.7.4



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-11-06 10:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-06 10:58 [edk2-test][PATCH] uefi-sct/SctPkg: Fix issues with EfiCompliant test Sakar Arora

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