From: Eric Jin <eric.jin@intel.com>
To: edk2-devel@lists.01.org
Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>,
Jiaxin Wu <jiaxin.wu@intel.com>
Subject: [edk2-test][Patch] uefi-sct\SctPkg:Add two checkpoints of GetNextVariable()
Date: Fri, 12 Oct 2018 13:22:24 +0800 [thread overview]
Message-ID: <20181012052224.12860-1-eric.jin@intel.com> (raw)
If a VariableName buffer on input is not a Null-terminated
string, EFI_INVALID_PARAMETER is returned.
If input values of VariableName and VendorGuid are not a
name and GUID of an existing variable,
EFI_INVALID_PARAMETER is returned.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Jin <eric.jin@intel.com>
Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
---
.../VariableServicesBBTestConformance.c | 388 ++++++++++++++++++++-
1 file changed, 387 insertions(+), 1 deletion(-)
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/VariableServices/BlackBoxTest/VariableServicesBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/VariableServices/BlackBoxTest/VariableServicesBBTestConformance.c
index 46dcc72..e2182c5 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/VariableServices/BlackBoxTest/VariableServicesBBTestConformance.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/VariableServices/BlackBoxTest/VariableServicesBBTestConformance.c
@@ -1,7 +1,7 @@
/** @file
Copyright 2006 - 2016 Unified EFI, Inc.<BR>
- Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -148,6 +148,20 @@ GetNextVariableNameConfTestSub5 (
);
EFI_STATUS
+GetNextVariableNameConfTestSub6 (
+ IN EFI_RUNTIME_SERVICES *RT,
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib
+ );
+
+EFI_STATUS
+GetNextVariableNameConfTestSub7 (
+ IN EFI_RUNTIME_SERVICES *RT,
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib
+ );
+
+EFI_STATUS
SetVariableConfTestSub1 (
IN EFI_RUNTIME_SERVICES *RT,
IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
@@ -393,6 +407,15 @@ GetNextVariableNameConfTest (
Status = GetNextVariableNameConfTestSub5 (RT, StandardLib, LoggingLib);
//
+ // GetNextVariableName when a VariableName buffer on input is not a Null-terminated string
+ //
+ Status = GetNextVariableNameConfTestSub6 (RT, StandardLib, LoggingLib);
+
+ //
+ // GetNextVariableName when input values of VariableName and VendorGuid are not a name and GUID of an existing variable
+ //
+ Status = GetNextVariableNameConfTestSub7 (RT, StandardLib, LoggingLib);
+ //
// Done
//
return EFI_SUCCESS;
@@ -2035,6 +2058,369 @@ GetNextVariableNameConfTestSub5 (
/**
+ * GetNextVariableName when a VariableName buffer on input is not a Null-terminated string.
+ * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL
+ * instance.
+ * @param LoggingLib A pointer to EFI_TEST_LOGGING_LIBRARY_PROTOCOL
+ * instance.
+ * @return EFI_SUCCESS Successfully.
+ * @return Other value Something failed.
+ */
+EFI_STATUS
+GetNextVariableNameConfTestSub6 (
+ IN EFI_RUNTIME_SERVICES *RT,
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION Result;
+ UINTN DataIndex;
+ UINT8 Data[MAX_BUFFER_SIZE];
+ UINTN VariableNameSize;
+ CHAR16 VariableName[MAX_BUFFER_SIZE];
+ EFI_GUID VendorGuid;
+
+ //
+ // Trace ...
+ //
+ if (LoggingLib != NULL) {
+ LoggingLib->EnterFunction (
+ LoggingLib,
+ L"GetNextVariableNameConfTestSub6",
+ L"TDS"
+ );
+ }
+
+ //
+ // Insert a variable
+ //
+ for (DataIndex = 0; DataIndex < 10; DataIndex++) {
+ Data[DataIndex] = (UINT8)DataIndex;
+ }
+
+ Status = RT->SetVariable (
+ L"TestVariable", // VariableName
+ &gTestVendor1Guid, // VendorGuid
+ EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ 10, // DataSize
+ Data // Data
+ );
+ if (EFI_ERROR(Status)) {
+ StandardLib->RecordAssertion (
+ StandardLib,
+ EFI_TEST_ASSERTION_WARNING,
+ gTestGenericFailureGuid,
+ L"RT.GetNextVariableName - Cannot insert a variable",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (LoggingLib != NULL) {
+ LoggingLib->ExitFunction (
+ LoggingLib,
+ L"GetNextVariableNameConfTestSub6",
+ L"TDS - Cannot insert a variable"
+ );
+ }
+
+ return Status;
+ }
+
+ //
+ // Walk through all variables
+ //
+ VariableName[0] = L'\0';
+ VariableNameSize = MAX_BUFFER_SIZE * sizeof (CHAR16);
+ Result = EFI_TEST_ASSERTION_PASSED;
+
+ while (TRUE) {
+ Status = RT->GetNextVariableName (
+ &VariableNameSize, // VariableNameSize
+ VariableName, // VariableName
+ &VendorGuid // VendorGuid
+ );
+ if (EFI_ERROR(Status)) {
+ if (Status != EFI_INVALID_PARAMETER) {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ }
+ break;
+ }
+
+ if ((SctStrCmp (VariableName, L"TestVariable") == 0) &&
+ (SctCompareGuid (&VendorGuid, &gTestVendor1Guid) == 0)) {
+ VariableNameSize = 8;
+ } else {
+ VariableNameSize = MAX_BUFFER_SIZE * sizeof (CHAR16);
+ }
+ }
+
+ //
+ // Record assertion
+ //
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gVariableServicesBbTestConformanceAssertionGuid019,
+ L"RT.GetNextVariableName - when a VariableName buffer on input is not a Null-terminated string",
+ L"%a:%d:Status - %r, Expected - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status, EFI_INVALID_PARAMETER
+ );
+
+ Status = RT->SetVariable (
+ L"TestVariable", // VariableName
+ &gTestVendor1Guid, // VendorGuid
+ EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ 0, // DataSize
+ Data // Data
+ );
+
+ if (EFI_ERROR(Status)) {
+ StandardLib->RecordAssertion (
+ StandardLib,
+ EFI_TEST_ASSERTION_WARNING,
+ gTestGenericFailureGuid,
+ L"RT.GetNextVariableName - Cannot delete a variable",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (LoggingLib != NULL) {
+ LoggingLib->ExitFunction (
+ LoggingLib,
+ L"GetNextVariableNameConfTestSub6",
+ L"TDS - Cannot delete a variable"
+ );
+ }
+
+ return Status;
+ }
+ //
+ // Trace ...
+ //
+ if (LoggingLib != NULL) {
+ LoggingLib->ExitFunction (
+ LoggingLib,
+ L"GetNextVariableNameConfTestSub6",
+ L"TDS"
+ );
+ }
+
+ //
+ // Done
+ //
+ return EFI_SUCCESS;
+}
+
+/**
+ * GetNextVariableName when input values of VariableName and VendorGuid are not a name and GUID of an existing variable.
+ * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL
+ * instance.
+ * @param LoggingLib A pointer to EFI_TEST_LOGGING_LIBRARY_PROTOCOL
+ * instance.
+ * @return EFI_SUCCESS Successfully.
+ * @return Other value Something failed.
+ */
+EFI_STATUS
+GetNextVariableNameConfTestSub7 (
+ IN EFI_RUNTIME_SERVICES *RT,
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION Result;
+ UINTN DataIndex;
+ UINT8 Data[MAX_BUFFER_SIZE];
+ UINTN VariableNameSize;
+ CHAR16 VariableName[MAX_BUFFER_SIZE];
+ EFI_GUID VendorGuid;
+
+ //
+ // Trace ...
+ //
+ if (LoggingLib != NULL) {
+ LoggingLib->EnterFunction (
+ LoggingLib,
+ L"GetNextVariableNameConfTestSub7",
+ L"TDS"
+ );
+ }
+
+ //
+ // Insert a variable
+ //
+ for (DataIndex = 0; DataIndex < 10; DataIndex++) {
+ Data[DataIndex] = (UINT8)DataIndex;
+ }
+
+ Status = RT->SetVariable (
+ L"TestVariable", // VariableName
+ &gTestVendor1Guid, // VendorGuid
+ EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ 10, // DataSize
+ Data // Data
+ );
+ if (EFI_ERROR(Status)) {
+ StandardLib->RecordAssertion (
+ StandardLib,
+ EFI_TEST_ASSERTION_WARNING,
+ gTestGenericFailureGuid,
+ L"RT.GetNextVariableName - Cannot insert a variable",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (LoggingLib != NULL) {
+ LoggingLib->ExitFunction (
+ LoggingLib,
+ L"GetNextVariableNameConfTestSub7",
+ L"TDS - Cannot insert a variable"
+ );
+ }
+
+ return Status;
+ }
+
+ //
+ // Walk through all variables
+ //
+ VariableName[0] = L'\0';
+
+ Result = EFI_TEST_ASSERTION_PASSED;
+
+ while (TRUE) {
+ VariableNameSize = MAX_BUFFER_SIZE * sizeof (CHAR16);
+ Status = RT->GetNextVariableName (
+ &VariableNameSize, // VariableNameSize
+ VariableName, // VariableName
+ &VendorGuid // VendorGuid
+ );
+ if (EFI_ERROR(Status)) {
+ if (Status != EFI_INVALID_PARAMETER) {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ }
+ break;
+ }
+
+ if ((SctStrCmp (VariableName, L"TestVariable") == 0) &&
+ (SctCompareGuid (&VendorGuid, &gTestVendor1Guid) == 0)) {
+ VariableName[8] = L'e';
+ }
+ }
+
+ //
+ // Record assertion
+ //
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gVariableServicesBbTestConformanceAssertionGuid020,
+ L"RT.GetNextVariableName - when input values of VariableName and VendorGuid are not a name and GUID of an existing variable",
+ L"%a:%d:Status - %r, Expected - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status, EFI_INVALID_PARAMETER
+ );
+
+ //
+ // Walk through all variables
+ //
+ VariableName[0] = L'\0';
+
+ Result = EFI_TEST_ASSERTION_PASSED;
+
+ while (TRUE) {
+ VariableNameSize = MAX_BUFFER_SIZE * sizeof (CHAR16);
+ Status = RT->GetNextVariableName (
+ &VariableNameSize, // VariableNameSize
+ VariableName, // VariableName
+ &VendorGuid // VendorGuid
+ );
+ if (EFI_ERROR(Status)) {
+ if (Status != EFI_INVALID_PARAMETER) {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ }
+ break;
+ }
+
+ if ((SctStrCmp (VariableName, L"TestVariable") == 0) &&
+ (SctCompareGuid (&VendorGuid, &gTestVendor1Guid) == 0)) {
+ VendorGuid = gTestVendor2Guid;
+ }
+ }
+
+ //
+ // Record assertion
+ //
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gVariableServicesBbTestConformanceAssertionGuid020,
+ L"RT.GetNextVariableName - when input values of VariableName and VendorGuid are not a name and GUID of an existing variable",
+ L"%a:%d:Status - %r, Expected - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status, EFI_INVALID_PARAMETER
+ );
+
+ Status = RT->SetVariable (
+ L"TestVariable", // VariableName
+ &gTestVendor1Guid, // VendorGuid
+ EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ 0, // DataSize
+ Data // Data
+ );
+
+ if (EFI_ERROR(Status)) {
+ StandardLib->RecordAssertion (
+ StandardLib,
+ EFI_TEST_ASSERTION_WARNING,
+ gTestGenericFailureGuid,
+ L"RT.GetNextVariableName - Cannot delete a variable",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (LoggingLib != NULL) {
+ LoggingLib->ExitFunction (
+ LoggingLib,
+ L"GetNextVariableNameConfTestSub6",
+ L"TDS - Cannot delete a variable"
+ );
+ }
+
+ return Status;
+ }
+ //
+ // Trace ...
+ //
+ if (LoggingLib != NULL) {
+ LoggingLib->ExitFunction (
+ LoggingLib,
+ L"GetNextVariableNameConfTestSub6",
+ L"TDS"
+ );
+ }
+
+ //
+ // Done
+ //
+ return EFI_SUCCESS;
+}
+
+
+/**
* SetVariable when VariableName is an empty string.
* @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL
* instance.
--
2.9.0.windows.1
next reply other threads:[~2018-10-12 5:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-12 5:22 Eric Jin [this message]
2018-10-12 8:48 ` [edk2-test][Patch] uefi-sct\SctPkg:Add two checkpoints of GetNextVariable() Supreeth Venkatesh
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=20181012052224.12860-1-eric.jin@intel.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