From: Sakar Arora <sakar.arora@arm.com>
To: edk2-devel@lists.01.org
Cc: prasanth.pulla@arm.com, John Powell <john.powell@arm.com>
Subject: [edk2-test][PATCH] uefi-sct/SctPkg: Fix issues with EfiCompliant test
Date: Tue, 6 Nov 2018 16:28:29 +0530 [thread overview]
Message-ID: <1541501909-16915-1-git-send-email-sakar.arora@arm.com> (raw)
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
reply other threads:[~2018-11-06 10:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1541501909-16915-1-git-send-email-sakar.arora@arm.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox