From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: eric.jin@intel.com) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by groups.io with SMTP; Wed, 11 Sep 2019 00:49:02 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Sep 2019 00:49:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,492,1559545200"; d="scan'208";a="184413152" Received: from shwdeopenpsi175.ccr.corp.intel.com ([10.239.9.33]) by fmsmga008.fm.intel.com with ESMTP; 11 Sep 2019 00:49:01 -0700 From: "Eric Jin" To: devel@edk2.groups.io Cc: shrishail patil , Supreeth Venkatesh , Eric Jin Eric Jin Subject: [edk2-test][Patch 1/3] uefi-sct/SctPkg: Add FMP test source to IHVSCT Date: Wed, 11 Sep 2019 15:48:57 +0800 Message-Id: <20190911074857.15252-1-eric.jin@intel.com> X-Mailer: git-send-email 2.20.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: shrishail patil Adding Firmware Management Protocol to IHVSCT. This patch contains source code which is copied from UEFISCT and added into IHVSCT. Cc: Supreeth Venkatesh Cc: Eric Jin Eric Jin Signed-off-by: shrishail patil --- .../IhvFirmwareManagementBBTest.inf | 53 + .../FirmwareManagementBBTestMain.h | 206 + .../FirmwareManagement/BlackBoxTest/Guid.h | 154 + .../FirmwareManagementBBTestConformance.c | 3619 +++++++++++++++++ .../FirmwareManagementBBTestFunction.c | 879 ++++ .../FirmwareManagementBBTestMain.c | 169 + .../FirmwareManagement/BlackBoxTest/Guid.c | 85 + 7 files changed, 5165 insertions(+) create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/IhvFirmwareManagementBBTest.inf create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestMain.h create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/Guid.h create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestConformance.c create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestFunction.c create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestMain.c create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/Guid.c diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/IhvFirmwareManagementBBTest.inf b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/IhvFirmwareManagementBBTest.inf new file mode 100644 index 000000000000..8c9eb45be002 --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/IhvFirmwareManagementBBTest.inf @@ -0,0 +1,53 @@ +## @file +# +# Copyright 2006 - 2012 Unified EFI, Inc.
+# Copyright (c) 2010 - 2012, Dell Inc. All rights reserved.
+# Copyright (c) 2019,Microchip Technology Inc.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## +#/*++ +# +# Module Name: +# +# FirmwareManagementBBTest.inf +# +# Abstract: +# +# Component description file for IHV Firmware Management Protocol Black-Box Test. +# +#--*/ + +[defines] + INF_VERSION = 0x00010005 + BASE_NAME = IhvFirmwareManagementBBTest + FILE_GUID = DB0E842F-201B-4D47-BA74-88602A41C9D2 + MODULE_TYPE = UEFI_DRIVER + COMPONENT_TYPE = BS_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = InitializeFirmwareManagementBBTest + +[sources.common] + FirmwareManagementBBTestConformance.c + FirmwareManagementBBTestFunction.c + FirmwareManagementBBTestMain.c + Guid.c + +[Packages] + MdePkg/MdePkg.dec + SctPkg/SctPkg.dec + SctPkg/UEFI/UEFI.dec + +[LibraryClasses] + UefiDriverEntryPoint + SctLib + EfiTestLib + +[Protocols] diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestMain.h b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestMain.h new file mode 100644 index 000000000000..d9f048de90bb --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestMain.h @@ -0,0 +1,206 @@ +/** @file + + Copyright 2006 - 2017 Unified EFI, Inc.
+ Copyright (c) 2010 - 2017, Dell Inc. All rights reserved.
+ Copyright (c) 2019,Microchip Technology Inc.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +/*++ + +Module Name: + + FirmwareManagementBBTestMain.h + +Abstract: + + Header file for Firmware Management Protocol test driver. + +--*/ + +#ifndef _FIRMWARE_MANAGEMENT_BB_TEST_MAIN +#define _FIRMWARE_MANAGEMENT_BB_TEST_MAIN + +#include "Efi.h" +#include "Guid.h" +#include + +#include + +#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_REVISION 0x00010000 + +#define IHV_EFI_FIRMWARE_MANAGEMENT_PROTOCOL_GUID \ +{ 0x941d02a8, 0x49ad, 0x4bda, { 0x9f, 0xae, 0x0a, 0x69, 0x24, 0x54, 0x1c, 0x88 } } +// **************************************************************************** +// Entry GUIDs for Function Test +// **************************************************************************** + +#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0101 \ +{ 0x7ddddd57, 0x68ff, 0x460e, { 0x90, 0xad, 0xa9, 0xd5, 0xf1, 0xf0, 0xa0, 0x87 } } + +#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0102 \ +{ 0x5b4c24b2, 0x852d, 0x418a, { 0x82, 0x34, 0xc2, 0xc8, 0x63, 0x5e, 0x9a, 0x2a } } + +#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0103 \ +{ 0x84062e44, 0xdaee, 0x41a5, { 0x94, 0xf8, 0x6d, 0xe0, 0x72, 0x9b, 0xfa, 0xb4 } } + +#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0104 \ +{ 0xdeb26021, 0xca4e, 0x4876, { 0x90, 0x99, 0xca, 0x7d, 0x77, 0x2c, 0x90, 0x1d } } + +#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0105 \ +{ 0xaa160ecc, 0xfc2f, 0x4f05, { 0xac, 0x20, 0x4c, 0xed, 0x45, 0xde, 0xda, 0xab } } + +#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0106 \ +{ 0x7a9a2714, 0xf32b, 0x4083, { 0x90, 0xf2, 0x12, 0x51, 0x1a, 0x87, 0x48, 0x1a } } + +// **************************************************************************** +// Entry GUIDs for Conformance Test +// **************************************************************************** + +#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0201 \ +{ 0x54ee347c, 0x10a3, 0x4311, { 0x94, 0x27, 0xa8, 0x97, 0xbf, 0xdc, 0x98, 0x8 } } + +#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0202 \ +{ 0x68aba93c, 0x1d0c, 0x412f, { 0xb1, 0xe, 0xe3, 0xa4, 0x6, 0xbc, 0x42, 0xcf } } + +#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0203 \ +{ 0x12834a23, 0x6cef, 0x478e, { 0xaf, 0x48, 0x44, 0xe5, 0x93, 0x40, 0xab, 0xe8 } } + +#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0204 \ +{ 0xc6dc94b1, 0xb81b, 0x4b85, { 0x8b, 0x7d, 0x8f, 0xbf, 0xa6, 0x8e, 0xf3, 0xe5 } } + +#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0205 \ +{ 0x3d13f23d, 0x8306, 0x49d4, { 0xa0, 0xe0, 0x9a, 0x9b, 0xf6, 0x89, 0x40, 0x3c } } + +#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0206 \ +{ 0x24cf9ac2, 0x9abc, 0x4f5c, { 0x9c, 0x7a, 0xbc, 0x22, 0x29, 0xc3, 0x2, 0x7f } } + +// **************************************************************************** +// Initializaiton and Unload functions +// **************************************************************************** + +EFI_STATUS +EFIAPI +InitializeFirmwareManagementBBTest ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +EFI_STATUS +EFIAPI +UnloadFirmwareManagementBBTest ( + IN EFI_HANDLE ImageHandle + ); + +// +// Test Cases - Function +// + +EFI_STATUS +BBTestGetImageInfoFunctionTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ); + +EFI_STATUS +BBTestGetImageFunctionTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ); + +EFI_STATUS +BBTestSetImageFunctionTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ); + +EFI_STATUS +BBTestCheckImageFunctionTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ); + +EFI_STATUS +BBTestGetPackageInfoFunctionTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ); + +EFI_STATUS +BBTestSetPackageInfoFunctionTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ); + +// +// Test Cases - Conformance +// + +EFI_STATUS +BBTestGetImageInfoConformanceTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ); + +EFI_STATUS +BBTestGetImageConformanceTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ); + +EFI_STATUS +BBTestSetImageConformanceTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ); + +EFI_STATUS +BBTestCheckImageConformanceTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ); + +EFI_STATUS +BBTestGetPackageInfoConformanceTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ); + +EFI_STATUS +BBTestSetPackageInfoConformanceTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ); + +#endif diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/Guid.h new file mode 100644 index 000000000000..677d1f3e3b73 --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/Guid.h @@ -0,0 +1,154 @@ +/** @file + + Copyright 2006 - 2010 Unified EFI, Inc.
+ Copyright (c) 2010, Dell Inc. All rights reserved.
+ Copyright (c) 2019,Microchip Technology Inc.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +/*++ + + Module Name: + + Guid.h + + Abstract: + + GUIDs auto-generated for EFI test assertion. + +--*/ + +// **************************************************************************** +// Function +// **************************************************************************** + +#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTFUNCTION_ASSERTION_001_GUID \ +{ 0xd02b40ae, 0x62f, 0x4155, { 0xbb, 0xdd, 0x4, 0x29, 0x18, 0x94, 0xea, 0x31 } } + +extern EFI_GUID gFirmwareManagementBBTestFunctionAssertionGuid001; + +#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTFUNCTION_ASSERTION_002_GUID \ +{ 0xff704c46, 0x3999, 0x4a28, { 0xa3, 0x6e, 0x76, 0x8a, 0xb6, 0xad, 0x89, 0xd8 } } + +extern EFI_GUID gFirmwareManagementBBTestFunctionAssertionGuid002; + +#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTFUNCTION_ASSERTION_003_GUID \ +{ 0x70884539, 0x9a34, 0x4146, { 0x83, 0x3a, 0x4d, 0x89, 0x8b, 0x9c, 0x7e, 0xa4 } } + +extern EFI_GUID gFirmwareManagementBBTestFunctionAssertionGuid003; + +// **************************************************************************** +// Conformance - Function Support Check +// **************************************************************************** + +#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_SUPPORT_001_GUID \ +{ 0xd9c7d018, 0x60ba, 0x448d, { 0xb1, 0x3b, 0x88, 0x8b, 0x41, 0xd9, 0xdc, 0x9 } }; + +extern EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid001; + +#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_SUPPORT_002_GUID \ +{ 0x28310f16, 0x690e, 0x44a5, { 0x93, 0x98, 0xe1, 0xcd, 0x6a, 0xb3, 0xe1, 0x61 } }; + +extern EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid002; + +#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_SUPPORT_003_GUID \ +{ 0x92cc940a, 0xdcf8, 0x42a0, { 0x81, 0xa1, 0xd7, 0xdd, 0x43, 0x87, 0xbf, 0x6d } }; + +extern EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid003; + +#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_SUPPORT_004_GUID \ +{ 0x3f910041, 0xcd4d, 0x4b36, { 0xb2, 0x23, 0xfb, 0x16, 0x4e, 0x7e, 0x6a, 0x8c } }; + +extern EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid004; + +// **************************************************************************** +// Conformance - Assertion +// **************************************************************************** + +#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_001_GUID \ +{ 0x3789b80e, 0xab70, 0x4dc9, { 0xbb, 0xbd, 0x70, 0x63, 0x76, 0x36, 0xab, 0x52 } } + +extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid001; + +#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_002_GUID \ +{ 0xca1d7706, 0x256b, 0x464e, { 0xb6, 0xee, 0x50, 0x34, 0x1e, 0xec, 0x3c, 0x83 } } + +extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid002; + +#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_003_GUID \ +{ 0x3c8d87b2, 0x6a89, 0x4a6c, { 0xbc, 0x75, 0xe6, 0x86, 0xa1, 0x49, 0x13, 0xf0 } } + +extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid003; + +#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_004_GUID \ +{ 0x88031c96, 0x99bf, 0x4d2c, { 0x9f, 0x57, 0xa7, 0x2, 0x6a, 0xbc, 0xd3, 0x51 } } + +extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid004; + +#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_005_GUID \ +{ 0x7a386361, 0x3a5d, 0x4e58, { 0x8a, 0x51, 0x4d, 0x93, 0xb6, 0x55, 0x95, 0xf4 } } + +extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid005; + +#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_006_GUID \ +{ 0xd6a77629, 0x5afd, 0x4854, { 0x87, 0xc8, 0xee, 0x9f, 0xc5, 0x3d, 0xbe, 0x3d } } + +extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid006; + +#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_007_GUID \ +{ 0x4ea24764, 0xa6b1, 0x43b5, { 0xb8, 0xa0, 0xd3, 0x3f, 0xdc, 0x8b, 0xc6, 0xe4 } } + +extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid007; + +#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_008_GUID \ +{ 0x712ce1e9, 0x80d1, 0x4168, { 0xb8, 0xd0, 0x74, 0xd1, 0x72, 0x7a, 0x2f, 0x25 } } + +extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid008; + +#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_009_GUID \ +{ 0xc82d1373, 0x1f87, 0x45f4, { 0xaf, 0xfc, 0x10, 0xa7, 0xf7, 0xb0, 0x9c, 0xb0 } } + +extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid009; + +#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_010_GUID \ +{ 0x2410a859, 0xdf6f, 0x4857, { 0x92, 0x4a, 0x26, 0x37, 0x7, 0x11, 0xf, 0x1c } } + +extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid010; + +#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_011_GUID \ +{ 0x3987172c, 0xe6a0, 0x4099, { 0xb1, 0x2b, 0xd8, 0xef, 0xf2, 0x62, 0x75, 0x93 } } + +extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid011; + +#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_012_GUID \ +{ 0xd6dad28e, 0x7f0f, 0x4f56, { 0x9a, 0x93, 0x14, 0x7d, 0xb3, 0x74, 0x0, 0xc9 } } + +extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid012; + +#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_013_GUID \ +{ 0xb5288fc3, 0xe906, 0x4468, { 0x83, 0x3d, 0xd4, 0xa6, 0x58, 0xa5, 0x4f, 0xbd } } + +extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid013; + +#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_014_GUID \ +{ 0x57355301, 0x1343, 0x497f, { 0xbe, 0xe0, 0x8e, 0x5c, 0x27, 0xd2, 0x40, 0x25 } } + +extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid014; + +#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_015_GUID \ +{ 0xadeab82d, 0x7592, 0x40fe, { 0x87, 0xa8, 0x93, 0x2b, 0xad, 0x97, 0xff, 0x5e } } + +extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid015; + +#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_016_GUID \ +{ 0x9be658d2, 0x1312, 0x4254, { 0x91, 0x10, 0x59, 0x0, 0xd5, 0xfd, 0x6c, 0x6c } } + +extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid016; + diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestConformance.c new file mode 100644 index 000000000000..7a711224b6c0 --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestConformance.c @@ -0,0 +1,3619 @@ +/** @file + + Copyright 2006 - 2016 Unified EFI, Inc.
+ Copyright (c) 2010 - 2016, Dell Inc. All rights reserved.
+ Copyright (c) 2019,Microchip Technology Inc.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +/*++ + +Module Name: + FirmwareManagementBBTestConformance.c + +Abstract: + Firmware Management Protocol's conformance tests. + +--*/ + +#define DEBUG_ALL 0 +#define DEBUG_GET_IMAGE_INFO 0 +#define DEBUG_GET_IMAGE 0 +#define DEBUG_SET_IMAGE 0 +#define DEBUG_CHECK_IMAGE 0 +#define DEBUG_SET_PACKAGE_INFO 0 + +#include "SctLib.h" +#include "FirmwareManagementBBTestMain.h" + +// **************************************************************************** +// Support Routines +// **************************************************************************** + +EFI_STATUS +CheckForSupportGetImage ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ); + +EFI_STATUS +CheckForSupportSetImage ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ); + + +EFI_STATUS +CheckForSupportCheckImage ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ); + +EFI_STATUS +CheckForSupportSetPackageInfo ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ); + +// **************************************************************************** +// Check Points +// **************************************************************************** + +EFI_STATUS +BBTestGetImageInfoConformanceTestCheckpoint1 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ); + +EFI_STATUS +BBTestGetImageInfoConformanceTestCheckpoint2 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ); + +EFI_STATUS +BBTestGetImageConformanceTestCheckpoint1 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ); + +EFI_STATUS +BBTestGetImageConformanceTestCheckpoint2 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ); + +EFI_STATUS +BBTestGetImageConformanceTestCheckpoint3 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ); + +EFI_STATUS +BBTestGetImageConformanceTestCheckpoint4 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ); + +EFI_STATUS +BBTestSetImageConformanceTestCheckpoint1 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ); + +EFI_STATUS +BBTestSetImageConformanceTestCheckpoint2 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ); + +EFI_STATUS +BBTestSetImageConformanceTestCheckpoint3 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ); + +EFI_STATUS +BBTestSetImageConformanceTestCheckpoint4 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ); + +EFI_STATUS +BBTestCheckImageConformanceTestCheckpoint1 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ); + +EFI_STATUS +BBTestCheckImageConformanceTestCheckpoint2 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ); + +EFI_STATUS +BBTestSetPackageInfoConformanceTestCheckpoint1 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ); + +EFI_STATUS +BBTestSetPackageInfoConformanceTestCheckpoint2 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ); + +EFI_STATUS +BBTestSetPackageInfoConformanceTestCheckpoint3 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ); + +EFI_STATUS +BBTestSetPackageInfoConformanceTestCheckpoint4 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ); + +// **************************************************************************** +// Support Routines +// +// +// **************************************************************************** + +// **************************************************************************** +// Support Routine: Progress +// **************************************************************************** + +EFI_STATUS +Progress ( + IN UINTN Completion +) +{ + return EFI_SUCCESS; +} + +// **************************************************************************** +// Support Routine: CheckForSupportGetImage +// **************************************************************************** + +EFI_STATUS +CheckForSupportGetImage ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement +) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_GUID TestGuid; + CHAR16 *ResultMessageLabel; + CHAR16 *ResultMessageData; + + UINT8 ImageIndex; + VOID *Image; + UINTN ImageSize; + + // + // Init + // + + Status = EFI_SUCCESS; + AssertionType = EFI_TEST_ASSERTION_PASSED; + TestGuid = gFirmwareManagementBBTestConformanceSupportGuid001; + ResultMessageLabel = L"GetImage, function support check"; + + ImageIndex = 0; + Image = NULL; + ImageSize = 0; + + // + // Check if function is supported + // + + Status = FirmwareManagement->GetImage ( + FirmwareManagement, + ImageIndex, + Image, + &ImageSize + ); + + AssertionType = EFI_TEST_ASSERTION_PASSED; + if (Status == EFI_UNSUPPORTED) { + ResultMessageData = L"function is NOT supported"; + } else { + ResultMessageData = L"function is supported."; + } + + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + TestGuid, + ResultMessageLabel, + L"Result - %s\n%a:%d: Status - %r", + ResultMessageData, + __FILE__, + (UINTN)__LINE__, + Status + ); + + if (Image != NULL) { + gtBS->FreePool (Image); + } + + if (Status == EFI_UNSUPPORTED) { + return EFI_UNSUPPORTED; + } else { + return EFI_SUCCESS; + } +} + +// **************************************************************************** +// Support Routine: CheckForSupportSetImage +// **************************************************************************** + +EFI_STATUS +CheckForSupportSetImage ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement +) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_GUID TestGuid; + CHAR16 *ResultMessageLabel; + CHAR16 *ResultMessageData; + + UINT8 ImageIndex; + VOID *Image; + UINTN ImageSize; + CHAR16 *AbortReason; + + // + // Init + // + + Status = EFI_SUCCESS; + AssertionType = EFI_TEST_ASSERTION_PASSED; + TestGuid = gFirmwareManagementBBTestConformanceSupportGuid002; + ResultMessageLabel = L"SetImage, function support check"; + + ImageIndex = 0; + Image = NULL; + ImageSize = 0; + AbortReason = NULL; + + // + // Check if function is supported + // + + Status = FirmwareManagement->SetImage ( + FirmwareManagement, + ImageIndex, + Image, + ImageSize, + NULL, // VendorCode + Progress, + &AbortReason + ); + + AssertionType = EFI_TEST_ASSERTION_PASSED; + if (Status == EFI_UNSUPPORTED) { + ResultMessageData = L"function is NOT supported"; + } else { + ResultMessageData = L"function is supported."; + } + + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + TestGuid, + ResultMessageLabel, + L"Result - %s\n%a:%d: Status - %r", + ResultMessageData, + __FILE__, + (UINTN)__LINE__, + Status + ); + + if (AbortReason != NULL) { + gtBS->FreePool (AbortReason); + } + + if (Status == EFI_UNSUPPORTED) { + return EFI_UNSUPPORTED; + } else { + return EFI_SUCCESS; + } +} + +// **************************************************************************** +// Support Routine: CheckForSupportCheckImage +// **************************************************************************** + +EFI_STATUS +CheckForSupportCheckImage ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement +) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_GUID TestGuid; + CHAR16 *ResultMessageLabel; + CHAR16 *ResultMessageData; + + UINT8 ImageIndex; + VOID *Image; + UINTN ImageSize; + UINT32 ImageUpdatable; + + // + // Init + // + + Status = EFI_SUCCESS; + AssertionType = EFI_TEST_ASSERTION_PASSED; + TestGuid = gFirmwareManagementBBTestConformanceSupportGuid003; + ResultMessageLabel = L"CheckImage, function support check"; + + ImageIndex = 0; + Image = NULL; + ImageSize = 0; + + // + // Check if function is supported + // + + Status = FirmwareManagement->CheckImage ( + FirmwareManagement, + ImageIndex, + Image, + ImageSize, + &ImageUpdatable + ); + + AssertionType = EFI_TEST_ASSERTION_PASSED; + if (Status == EFI_UNSUPPORTED) { + ResultMessageData = L"function is NOT supported"; + } else { + ResultMessageData = L"function is supported."; + } + + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + TestGuid, + ResultMessageLabel, + L"Result - %s\n%a:%d: Status - %r", + ResultMessageData, + __FILE__, + (UINTN)__LINE__, + Status + ); + + if (Status == EFI_UNSUPPORTED) { + return EFI_UNSUPPORTED; + } else { + return EFI_SUCCESS; + } +} + +// **************************************************************************** +// Support Routine: CheckForSupportSetPackageInfo +// **************************************************************************** + +EFI_STATUS +CheckForSupportSetPackageInfo ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement +) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_GUID TestGuid; + CHAR16 *ResultMessageLabel; + CHAR16 *ResultMessageData; + + VOID *Image; + UINTN ImageSize; + VOID *VendorCode; + UINT32 PackageVersion; + CHAR16 *PackageVersionName; + + // + // Init + // + + Status = EFI_SUCCESS; + AssertionType = EFI_TEST_ASSERTION_PASSED; + TestGuid = gFirmwareManagementBBTestConformanceSupportGuid004; + ResultMessageLabel = L"SetPackageInfo, function support check"; + + Image = NULL; + ImageSize = 0; + VendorCode = NULL; + PackageVersion = 0; + PackageVersionName = NULL; + + // + // Check if function is supported + // + + Status = FirmwareManagement->SetPackageInfo ( + FirmwareManagement, + Image, + ImageSize, + VendorCode, + PackageVersion, + PackageVersionName + ); + + AssertionType = EFI_TEST_ASSERTION_PASSED; + if (Status == EFI_UNSUPPORTED) { + ResultMessageData = L"function is NOT supported"; + } else { + ResultMessageData = L"function is supported."; + } + + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + TestGuid, + ResultMessageLabel, + L"Result - %s\n%a:%d: Status - %r", + ResultMessageData, + __FILE__, + (UINTN)__LINE__, + Status + ); + + if (Status == EFI_UNSUPPORTED) { + return EFI_UNSUPPORTED; + } else { + return EFI_SUCCESS; + } +} + +// **************************************************************************** +// Test Cases +// +// +// **************************************************************************** + +// **************************************************************************** +// Test Case: GetImageInfo +// **************************************************************************** + +EFI_STATUS +BBTestGetImageInfoConformanceTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ) +{ + EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib; + EFI_STATUS Status; + EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement; + + // + // Init + // + + FirmwareManagement = (EFI_FIRMWARE_MANAGEMENT_PROTOCOL*)ClientInterface; + + Status = gtBS->HandleProtocol ( + SupportHandle, + &gEfiStandardTestLibraryGuid, + (VOID **) &StandardLib + ); + if (EFI_ERROR(Status)) { + return Status; + } + + // + // Call check point(s) + // + + BBTestGetImageInfoConformanceTestCheckpoint1 (StandardLib, FirmwareManagement); + BBTestGetImageInfoConformanceTestCheckpoint2 (StandardLib, FirmwareManagement); + + return EFI_SUCCESS; +} + +// **************************************************************************** +// Test Case: GetImage +// **************************************************************************** + +EFI_STATUS +BBTestGetImageConformanceTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ) +{ + EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib; + EFI_STATUS Status; + EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement; + + // + // Init + // + + FirmwareManagement = (EFI_FIRMWARE_MANAGEMENT_PROTOCOL*)ClientInterface; + + Status = gtBS->HandleProtocol ( + SupportHandle, + &gEfiStandardTestLibraryGuid, + (VOID **) &StandardLib + ); + if (EFI_ERROR(Status)) { + return Status; + } + + // + // Check if function is supported + // + + Status = CheckForSupportGetImage (StandardLib, FirmwareManagement); + if (Status == EFI_UNSUPPORTED) { + return Status; + } + + // + // Call check point(s) + // + + BBTestGetImageConformanceTestCheckpoint1 (StandardLib, FirmwareManagement); + BBTestGetImageConformanceTestCheckpoint2 (StandardLib, FirmwareManagement); + BBTestGetImageConformanceTestCheckpoint3 (StandardLib, FirmwareManagement); + BBTestGetImageConformanceTestCheckpoint4 (StandardLib, FirmwareManagement); + + return EFI_SUCCESS; +} + +// **************************************************************************** +// Test Case: SetImage +// **************************************************************************** + +EFI_STATUS +BBTestSetImageConformanceTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ) +{ + EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib; + EFI_STATUS Status; + EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement; + + // + // Init + // + + FirmwareManagement = (EFI_FIRMWARE_MANAGEMENT_PROTOCOL*)ClientInterface; + + Status = gtBS->HandleProtocol ( + SupportHandle, + &gEfiStandardTestLibraryGuid, + (VOID **) &StandardLib + ); + if (EFI_ERROR(Status)) { + return Status; + } + + // + // Check if function is supported + // + + Status = CheckForSupportSetImage (StandardLib, FirmwareManagement); + if (Status == EFI_UNSUPPORTED) { + return Status; + } + + // + // Call check point(s) + // + + BBTestSetImageConformanceTestCheckpoint1 (StandardLib, FirmwareManagement); + BBTestSetImageConformanceTestCheckpoint3 (StandardLib, FirmwareManagement); + BBTestSetImageConformanceTestCheckpoint4 (StandardLib, FirmwareManagement); + + return Status; +} + +// **************************************************************************** +// Test Case: CheckImage +// **************************************************************************** + +EFI_STATUS +BBTestCheckImageConformanceTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ) +{ + EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib; + EFI_STATUS Status; + EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement; + + // + // Init + // + + FirmwareManagement = (EFI_FIRMWARE_MANAGEMENT_PROTOCOL*)ClientInterface; + + Status = gtBS->HandleProtocol ( + SupportHandle, + &gEfiStandardTestLibraryGuid, + (VOID **) &StandardLib + ); + if (EFI_ERROR(Status)) { + return Status; + } + + // + // Check if function is supported + // + + Status = CheckForSupportCheckImage (StandardLib, FirmwareManagement); + if (Status == EFI_UNSUPPORTED) { + return Status; + } + + // + // Call check point(s) + // + + BBTestCheckImageConformanceTestCheckpoint1 (StandardLib, FirmwareManagement); + BBTestCheckImageConformanceTestCheckpoint2 (StandardLib, FirmwareManagement); + + return Status; +} + +// **************************************************************************** +// Test Case: SetPackageInfo +// **************************************************************************** + +EFI_STATUS +BBTestSetPackageInfoConformanceTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ) +{ + EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib; + EFI_STATUS Status; + EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement; + + // + // Init + // + + FirmwareManagement = (EFI_FIRMWARE_MANAGEMENT_PROTOCOL*)ClientInterface; + + Status = gtBS->HandleProtocol ( + SupportHandle, + &gEfiStandardTestLibraryGuid, + (VOID **) &StandardLib + ); + if (EFI_ERROR(Status)) { + return Status; + } + + // + // Check if function is supported + // + + Status = CheckForSupportSetPackageInfo (StandardLib, FirmwareManagement); + if (Status == EFI_UNSUPPORTED) { + return Status; + } + + // + // Call check point(s) + // + + BBTestSetPackageInfoConformanceTestCheckpoint1 (StandardLib, FirmwareManagement); + BBTestSetPackageInfoConformanceTestCheckpoint2 (StandardLib, FirmwareManagement); + BBTestSetPackageInfoConformanceTestCheckpoint3 (StandardLib, FirmwareManagement); + BBTestSetPackageInfoConformanceTestCheckpoint4 (StandardLib, FirmwareManagement); + + return Status; +} + +// **************************************************************************** +// Check Points +// +// +// **************************************************************************** + +// **************************************************************************** +// Checkpoint: GetImageInfo, 1 +// **************************************************************************** + +/** + This routine: + - Calls function with valid parameters, except ImageInfoSize = 1. + The function should return EFI_BUFFER_TOO_SMALL and ImageInfoSize > 1. +**/ + +EFI_STATUS +BBTestGetImageInfoConformanceTestCheckpoint1 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_GUID TestGuid; + CHAR16 *ResultMessageLabel; + CHAR16 *ResultMessageData; + + UINTN ImageInfoSize; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo; + UINT32 DescriptorVersion; + UINT8 DescriptorCount; + UINTN DescriptorSize; + UINT32 PackageVersion; + CHAR16 *PackageVersionName; + + // + // Init + // + + Status = EFI_SUCCESS; + AssertionType = EFI_TEST_ASSERTION_PASSED; + TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid001; + ResultMessageLabel = L"GetImageInfo, conformance checkpoint #1"; + ResultMessageData = L"correctly returned EFI_BUFFER_TOO_SMALL."; + + ImageInfo = NULL; + PackageVersionName = NULL; + + ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20; + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + ImageInfoSize = 1; + + // + // Check the data returned by the function + // + + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + + if (Status != EFI_BUFFER_TOO_SMALL) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"failed to return EFI_BUFFER_TOO_SMALL."; + goto Exit; + } + if (ImageInfoSize <= 1) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"failed to update *ImageInfoSize."; + } + + // + // Report the checkpoint result + // + +Exit: + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + TestGuid, + ResultMessageLabel, + L"Result - %s\n%a:%d: Status - %r", + ResultMessageData, + __FILE__, + (UINTN)__LINE__, + Status + ); + if (PackageVersionName != NULL) { + gtBS->FreePool (PackageVersionName); + } + if (ImageInfo != NULL) { + gtBS->FreePool (ImageInfo); + } + + return EFI_SUCCESS; +} + +// **************************************************************************** +// Checkpoint: GetImageInfo, 2 +// **************************************************************************** + +/** + This routine: + - Calls function with valid parameters, except &ImageInfoSize = NULL. + The function should return EFI_INVALID_PARAMETER. +**/ + +EFI_STATUS +BBTestGetImageInfoConformanceTestCheckpoint2 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_GUID TestGuid; + CHAR16 *ResultMessageLabel; + CHAR16 *ResultMessageData; + + UINTN ImageInfoSize; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo; + UINT32 DescriptorVersion; + UINT8 DescriptorCount; + UINTN DescriptorSize; + UINT32 PackageVersion; + CHAR16 *PackageVersionName; + + // + // Init + // + + Status = EFI_SUCCESS; + AssertionType = EFI_TEST_ASSERTION_PASSED; + TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid002; + ResultMessageLabel = L"GetImageInfo, conformance checkpoint #2"; + ResultMessageData = L"correctly returned EFI_INVALID_PARAMETER."; + + ImageInfo = NULL; + PackageVersionName = NULL; + + ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20; + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + + // + // Check the data returned by the function + // + + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + NULL, // &ImageInfoSize + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + + if (Status != EFI_INVALID_PARAMETER) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"failed to return EFI_INVALID_PARAMETER."; + } + + // + // Report the checkpoint result + // + +Exit: + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + TestGuid, + ResultMessageLabel, + L"Result - %s\n%a:%d: Status - %r", + ResultMessageData, + __FILE__, + (UINTN)__LINE__, + Status + ); + if (PackageVersionName != NULL) { + gtBS->FreePool (PackageVersionName); + } + if (ImageInfo != NULL) { + gtBS->FreePool (ImageInfo); + } + + return EFI_SUCCESS; +} + +// **************************************************************************** +// Checkpoint: GetImage, 1 +// **************************************************************************** + +/** + This routine: + - Calls function with valid parameters, except ImageSize = 1. + The function should return EFI_BUFFER_TOO_SMALL and ImageSize > 1. +**/ + +EFI_STATUS +BBTestGetImageConformanceTestCheckpoint1 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_GUID TestGuid; + CHAR16 *ResultMessageLabel; + CHAR16 *ResultMessageData; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo; + VOID *BufferImage; + + UINTN ImageInfoSize; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo; + UINT32 DescriptorVersion; + UINT8 DescriptorCount; + UINTN DescriptorSize; + UINT32 PackageVersion; + CHAR16 *PackageVersionName; + + VOID *Image; + UINTN ImageSize; + + UINTN i; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *p; + UINTN FunctionTested; + + // + // Init + // + + Status = EFI_SUCCESS; + AssertionType = EFI_TEST_ASSERTION_PASSED; + TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid003; + ResultMessageLabel = L"GetImage, conformance checkpoint #1"; + + BufferImageInfo = NULL; + BufferImage = NULL; + ImageInfo = NULL; + Image = NULL; + PackageVersionName = NULL; + FunctionTested = 0; + + // Use a sufficiently large buffer to obtain EFI_SUCCESS, + // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL. + // Check for EFI_BUFFER_TOO_SMALL in another conformance test. + + ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20; + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + if (Status == EFI_BUFFER_TOO_SMALL) { + gtBS->FreePool (ImageInfo); + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + if (Status != EFI_SUCCESS) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + BufferImageInfo = ImageInfo; + goto Exit; + } + } + BufferImageInfo = ImageInfo; + + if (DescriptorSize == 0) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"*DescriptorSize is 0."; + goto Exit; // Note the Status = EFI_SUCCESS + } + if ((DescriptorCount * DescriptorSize) > ImageInfoSize) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize."; + goto Exit; // Note the Status = EFI_SUCCESS + } + + // + // Check the data returned by the function + // + + for (i = 0; i < DescriptorCount; i++) { + p = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *) (((UINT8 *) ImageInfo) + (i * DescriptorSize)); + + if (((p->AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) == + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) && + ((p->AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) == + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED)) { + continue; + } + if (p->Size == 0) { + continue; + } + if ((p->AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) { + continue; + } + if ((p->AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) { + continue; + } + + ImageSize = p->Size; + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageSize, + (VOID **) &Image + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + BufferImage = Image; + + ImageSize = 1; + FunctionTested++; + Status = FirmwareManagement->GetImage ( + FirmwareManagement, + p->ImageIndex, + Image, + &ImageSize + ); + gtBS->FreePool (BufferImage); + BufferImage = NULL; + Image = NULL; + + // + // Report the checkpoint result + // + + if (Status != EFI_BUFFER_TOO_SMALL) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"failed to return EFI_BUFFER_TOO_SMALL."; + goto Exit; + } + if (ImageInfoSize <= 1) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"failed to update *ImageSize."; + goto Exit; + } + } + + if (FunctionTested == 0) { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"test skipped - test case does not apply."; + } else { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"correctly returned EFI_BUFFER_TOO_SMALL."; + } + +Exit: + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + TestGuid, + ResultMessageLabel, + L"Result - %s\n%a:%d: Status - %r", + ResultMessageData, + __FILE__, + (UINTN)__LINE__, + Status + ); + + if (PackageVersionName != NULL) { + gtBS->FreePool (PackageVersionName); + } + if (BufferImageInfo != NULL) { + gtBS->FreePool (BufferImageInfo); + } + if (BufferImage != NULL) { + gtBS->FreePool (BufferImage); + } + + return EFI_SUCCESS; +} + +// **************************************************************************** +// Checkpoint: GetImage, 2 +// **************************************************************************** + +/** + This routine: + - Calls function with valid parameters, except Image = NULL. + The function should return EFI_INVALID_PARAMETER. +**/ + +EFI_STATUS +BBTestGetImageConformanceTestCheckpoint2 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_GUID TestGuid; + CHAR16 *ResultMessageLabel; + CHAR16 *ResultMessageData; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo; + + UINTN ImageInfoSize; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo; + UINT32 DescriptorVersion; + UINT8 DescriptorCount; + UINTN DescriptorSize; + UINT32 PackageVersion; + CHAR16 *PackageVersionName; + + VOID *Image; + UINTN ImageSize; + + UINTN i; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *p; + UINTN FunctionTested; + + // + // Init + // + + Status = EFI_SUCCESS; + AssertionType = EFI_TEST_ASSERTION_PASSED; + TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid004; + ResultMessageLabel = L"GetImage, conformance checkpoint #2"; + + BufferImageInfo = NULL; + ImageInfo = NULL; + Image = NULL; + PackageVersionName = NULL; + FunctionTested = 0; + + // Use a sufficiently large buffer to obtain EFI_SUCCESS, + // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL. + // Check for EFI_BUFFER_TOO_SMALL in another conformance test. + + ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20; + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + if (Status == EFI_BUFFER_TOO_SMALL) { + gtBS->FreePool (ImageInfo); + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + if (Status != EFI_SUCCESS) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + BufferImageInfo = ImageInfo; + goto Exit; + } + } + BufferImageInfo = ImageInfo; + + if (DescriptorSize == 0) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"*DescriptorSize is 0."; + goto Exit; // Note the Status = EFI_SUCCESS + } + if ((DescriptorCount * DescriptorSize) > ImageInfoSize) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize."; + goto Exit; // Note the Status = EFI_SUCCESS + } + + // + // Check the data returned by the function + // + + for (i = 0; i < DescriptorCount; i++) { + p = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *) (((UINT8 *) ImageInfo) + (i * DescriptorSize)); + + if (((p->AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) == + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) && + ((p->AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) == + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED)) { + continue; + } + if (p->Size == 0) { + continue; + } + if ((p->AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) { + continue; + } + if ((p->AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) { + continue; + } + + // Use a sufficiently large buffer size to avoid EFI_BUFFER_TOO_SMALL. + ImageSize = p->Size * 2; + Image = NULL; + FunctionTested++; + Status = FirmwareManagement->GetImage ( + FirmwareManagement, + p->ImageIndex, + Image, + &ImageSize + ); + + // + // Report the checkpoint result + // + + if (Status != EFI_INVALID_PARAMETER) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"failed to return EFI_INVALID_PARAMETER."; + goto Exit; + } + } + + if (FunctionTested == 0) { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"test skipped - test case does not apply."; + } else { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"correctly returned EFI_INVALID_PARAMETER."; + } + +Exit: + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + TestGuid, + ResultMessageLabel, + L"Result - %s\n%a:%d: Status - %r", + ResultMessageData, + __FILE__, + (UINTN)__LINE__, + Status + ); + + if (PackageVersionName != NULL) { + gtBS->FreePool (PackageVersionName); + } + if (BufferImageInfo != NULL) { + gtBS->FreePool (BufferImageInfo); + } + + return EFI_SUCCESS; +} + +// **************************************************************************** +// Checkpoint: GetImage, 3 +// **************************************************************************** + +/** + This routine: + - Calls function with valid parameters, except ImageIndex = 0 or + ImageIndex = DescriptorCount + 1. + The function should return EFI_INVALID_PARAMETER or EFI_NOT_FOUND. +**/ + +EFI_STATUS +BBTestGetImageConformanceTestCheckpoint3 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_GUID TestGuid; + CHAR16 *ResultMessageLabel; + CHAR16 *ResultMessageData; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo; + VOID *BufferImage; + + UINTN ImageInfoSize; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo; + UINT32 DescriptorVersion; + UINT8 DescriptorCount; + UINTN DescriptorSize; + UINT32 PackageVersion; + CHAR16 *PackageVersionName; + + VOID *Image; + UINTN ImageSize; + UINT8 ImageIndex; + + // + // Init + // + + Status = EFI_SUCCESS; + AssertionType = EFI_TEST_ASSERTION_PASSED; + TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid005; + ResultMessageLabel = L"GetImage, conformance checkpoint #3"; + + BufferImageInfo = NULL; + BufferImage = NULL; + ImageInfo = NULL; + Image = NULL; + PackageVersionName = NULL; + + // Use a sufficiently large buffer to obtain EFI_SUCCESS, + // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL. + // Check for EFI_BUFFER_TOO_SMALL in another conformance test. + + ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20; + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + if (Status == EFI_BUFFER_TOO_SMALL) { + gtBS->FreePool (ImageInfo); + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + if (Status != EFI_SUCCESS) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + BufferImageInfo = ImageInfo; + goto Exit; + } + } + BufferImageInfo = ImageInfo; + + if (DescriptorSize == 0) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"*DescriptorSize is 0."; + goto Exit; // Note the Status = EFI_SUCCESS + } + if ((DescriptorCount * DescriptorSize) > ImageInfoSize) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize."; + goto Exit; // Note the Status = EFI_SUCCESS + } + + // + // Check the data returned by the function + // + + // Dummy image so as to fail on Image = NULL + // Any size since the function should check for index before size + ImageSize = 64; + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageSize, + (VOID **) &Image + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + BufferImage = Image; + + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"failed to return EFI_INVALID_PARAMETER or EFI_NOT_FOUND."; + + ImageIndex = 0; + Status = FirmwareManagement->GetImage ( + FirmwareManagement, + ImageIndex, + Image, + &ImageSize + ); + if ((Status != EFI_INVALID_PARAMETER) && (Status != EFI_NOT_FOUND)) { + goto Exit; + } + + if ((DescriptorCount + 1) != 0) { + ImageIndex = DescriptorCount + 1; + Status = FirmwareManagement->GetImage ( + FirmwareManagement, + ImageIndex, + Image, + &ImageSize + ); + if ((Status != EFI_INVALID_PARAMETER) && (Status != EFI_NOT_FOUND)) { + goto Exit; + } + } + + // + // Report the checkpoint result + // + + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"correctly returned EFI_INVALID_PARAMETER or EFI_NOT_FOUND."; + +Exit: + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + TestGuid, + ResultMessageLabel, + L"Result - %s\n%a:%d: Status - %r", + ResultMessageData, + __FILE__, + (UINTN)__LINE__, + Status + ); + + if (PackageVersionName != NULL) { + gtBS->FreePool (PackageVersionName); + } + if (BufferImageInfo != NULL) { + gtBS->FreePool (BufferImageInfo); + } + if (BufferImage != NULL) { + gtBS->FreePool (BufferImage); + } + + return EFI_SUCCESS; +} + +// **************************************************************************** +// Checkpoint: GetImage, 4 +// **************************************************************************** + +/** + This routine: + - The function requires authentication. + - Calls function with valid parameters, except Image has dummy + authentication data. + The function should return EFI_SECURITY_VIOLATION. +**/ + +EFI_STATUS +BBTestGetImageConformanceTestCheckpoint4 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_GUID TestGuid; + CHAR16 *ResultMessageLabel; + CHAR16 *ResultMessageData; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo; + VOID *BufferImage; + + UINTN ImageInfoSize; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo; + UINT32 DescriptorVersion; + UINT8 DescriptorCount; + UINTN DescriptorSize; + UINT32 PackageVersion; + CHAR16 *PackageVersionName; + + VOID *Image; + UINTN ImageSize; + + UINTN i; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *p; + UINTN FunctionTested; + + // + // Init + // + + Status = EFI_SUCCESS; + AssertionType = EFI_TEST_ASSERTION_PASSED; + TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid006; + ResultMessageLabel = L"GetImage, conformance checkpoint #4"; + + BufferImageInfo = NULL; + BufferImage = NULL; + ImageInfo = NULL; + Image = NULL; + PackageVersionName = NULL; + FunctionTested = 0; + + // Use a sufficiently large buffer to obtain EFI_SUCCESS, + // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL. + // Check for EFI_BUFFER_TOO_SMALL in another conformance test. + + ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20; + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + if (Status == EFI_BUFFER_TOO_SMALL) { + gtBS->FreePool (ImageInfo); + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + if (Status != EFI_SUCCESS) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + BufferImageInfo = ImageInfo; + goto Exit; + } + } + BufferImageInfo = ImageInfo; + + if (DescriptorSize == 0) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"*DescriptorSize is 0."; + goto Exit; // Note the Status = EFI_SUCCESS + } + if ((DescriptorCount * DescriptorSize) > ImageInfoSize) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize."; + goto Exit; // Note the Status = EFI_SUCCESS + } + + // + // Check the data returned by the function + // + + for (i = 0; i < DescriptorCount; i++) { + p = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *) (((UINT8 *) ImageInfo) + (i * DescriptorSize)); + + if ((p->AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) { + continue; + } + if ((p->AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) { + continue; + } + if (p->Size == 0) { + continue; + } + if ((p->AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) { + continue; + } + if ((p->AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) { + continue; + } + + // Use a sufficiently large buffer size to avoid EFI_BUFFER_TOO_SMALL. + ImageSize = p->Size * 2; + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageSize, + (VOID **) &Image + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + BufferImage = Image; + + FunctionTested++; + + Status = FirmwareManagement->GetImage ( + FirmwareManagement, + p->ImageIndex, + Image, + &ImageSize + ); + gtBS->FreePool (BufferImage); + BufferImage = NULL; + Image = NULL; + + // + // Report the checkpoint result + // + + if (Status != EFI_SECURITY_VIOLATION) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"failed to return EFI_SECURITY_VIOLATION."; + goto Exit; + } + } + + if (FunctionTested == 0) { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"test skipped - test case does not apply."; + } else { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"correctly returned EFI_SECURITY_VIOLATION"; + } + +Exit: + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + TestGuid, + ResultMessageLabel, + L"Result - %s\n%a:%d: Status - %r", + ResultMessageData, + __FILE__, + (UINTN)__LINE__, + Status + ); + + if (PackageVersionName != NULL) { + gtBS->FreePool (PackageVersionName); + } + if (BufferImageInfo != NULL) { + gtBS->FreePool (BufferImageInfo); + } + if (BufferImage != NULL) { + gtBS->FreePool (BufferImage); + } + + return EFI_SUCCESS; +} + +// **************************************************************************** +// Checkpoint: SetImage, 1 +// **************************************************************************** + +/** + This routine: + - Calls function with valid parameters, except Image = NULL. + The function should return EFI_INVALID_PARAMETER. +**/ + +EFI_STATUS +BBTestSetImageConformanceTestCheckpoint1 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_GUID TestGuid; + CHAR16 *ResultMessageLabel; + CHAR16 *ResultMessageData; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo; + + UINTN ImageInfoSize; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo; + UINT32 DescriptorVersion; + UINT8 DescriptorCount; + UINTN DescriptorSize; + UINT32 PackageVersion; + CHAR16 *PackageVersionName; + + CHAR16 *AbortReason; + + VOID *Image; + UINTN ImageSize; + + UINTN i; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *p; + UINTN FunctionTested; + + // + // Init + // + + Status = EFI_SUCCESS; + AssertionType = EFI_TEST_ASSERTION_PASSED; + TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid007; + ResultMessageLabel = L"SetImage, conformance checkpoint #1"; + + BufferImageInfo = NULL; + ImageInfo = NULL; + Image = NULL; + PackageVersionName = NULL; + AbortReason = NULL; + FunctionTested = 0; + + // Use a sufficiently large buffer to obtain EFI_SUCCESS, + // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL. + // Check for EFI_BUFFER_TOO_SMALL in another conformance test. + + ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20; + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + if (Status == EFI_BUFFER_TOO_SMALL) { + gtBS->FreePool (ImageInfo); + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + if (Status != EFI_SUCCESS) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + BufferImageInfo = ImageInfo; + goto Exit; + } + } + BufferImageInfo = ImageInfo; + + if (DescriptorSize == 0) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"*DescriptorSize is 0."; + goto Exit; // Note the Status = EFI_SUCCESS + } + if ((DescriptorCount * DescriptorSize) > ImageInfoSize) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize."; + goto Exit; // Note the Status = EFI_SUCCESS + } + + // + // Check the data returned by the function + // + + for (i = 0; i < DescriptorCount; i++) { + p = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *) (((UINT8 *) ImageInfo) + (i * DescriptorSize)); + + if (((p->AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) == + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) && + ((p->AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) == + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED)) { + continue; + } + if (p->Size == 0) { + continue; + } + if ((p->AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) { + continue; + } + if ((p->AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) { + continue; + } + + ImageSize = p->Size; + Image = NULL; + FunctionTested++; + Status = FirmwareManagement->SetImage ( + FirmwareManagement, + p->ImageIndex, + Image, + ImageSize, + NULL, // VendorCode + Progress, + &AbortReason + ); + + // + // Report the checkpoint result + // + + if (Status != EFI_INVALID_PARAMETER) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"failed to return EFI_INVALID_PARAMETER."; + goto Exit; + } + } + + if (FunctionTested == 0) { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"test skipped - test case does not apply."; + } else { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"correctly returned EFI_INVALID_PARAMETER."; + } + +Exit: + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + TestGuid, + ResultMessageLabel, + L"Result - %s\n%a:%d: Status - %r", + ResultMessageData, + __FILE__, + (UINTN)__LINE__, + Status + ); + + if (PackageVersionName != NULL) { + gtBS->FreePool (PackageVersionName); + } + if (BufferImageInfo != NULL) { + gtBS->FreePool (BufferImageInfo); + } + if (AbortReason != NULL) { + gtBS->FreePool (AbortReason); + } + + return EFI_SUCCESS; +} + +// **************************************************************************** +// Checkpoint: SetImage, 2 +// **************************************************************************** + +/** + This routine: + - Calls function with valid parameters, except Image is a dummy image. + The function should return EFI_INVALID_PARAMETER or EFI_ABORTED. +**/ + +EFI_STATUS +BBTestSetImageConformanceTestCheckpoint2 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_GUID TestGuid; + CHAR16 *ResultMessageLabel; + CHAR16 *ResultMessageData; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo; + VOID *BufferImage; + + UINTN ImageInfoSize; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo; + UINT32 DescriptorVersion; + UINT8 DescriptorCount; + UINTN DescriptorSize; + UINT32 PackageVersion; + CHAR16 *PackageVersionName; + + CHAR16 *AbortReason; + + VOID *Image; + UINTN ImageSize; + + UINTN i; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *p; + UINTN FunctionTested; + + // + // Init + // + + Status = EFI_SUCCESS; + AssertionType = EFI_TEST_ASSERTION_PASSED; + TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid008; + ResultMessageLabel = L"SetImage, conformance checkpoint #2"; + + BufferImageInfo = NULL; + BufferImage = NULL; + ImageInfo = NULL; + Image = NULL; + PackageVersionName = NULL; + AbortReason = NULL; + FunctionTested = 0; + + // Use a sufficiently large buffer to obtain EFI_SUCCESS, + // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL. + // Check for EFI_BUFFER_TOO_SMALL in another conformance test. + + ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20; + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + if (Status == EFI_BUFFER_TOO_SMALL) { + gtBS->FreePool (ImageInfo); + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + if (Status != EFI_SUCCESS) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + BufferImageInfo = ImageInfo; + goto Exit; + } + } + BufferImageInfo = ImageInfo; + + if (DescriptorSize == 0) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"*DescriptorSize is 0."; + goto Exit; // Note the Status = EFI_SUCCESS + } + if ((DescriptorCount * DescriptorSize) > ImageInfoSize) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize."; + goto Exit; // Note the Status = EFI_SUCCESS + } + + // + // Check the data returned by the function + // + + for (i = 0; i < DescriptorCount; i++) { + p = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *) (((UINT8 *) ImageInfo) + (i * DescriptorSize)); + + if (((p->AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) == + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) && + ((p->AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) == + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED)) { + continue; + } + if (p->Size == 0) { + continue; + } + if ((p->AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) { + continue; + } + if ((p->AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) { + continue; + } + + ImageSize = p->Size; + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageSize, + (VOID **) &Image + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + BufferImage = Image; + FunctionTested++; + Status = FirmwareManagement->SetImage ( + FirmwareManagement, + p->ImageIndex, + Image, + ImageSize, + NULL, // VendorCode + Progress, + &AbortReason + ); + gtBS->FreePool (BufferImage); + BufferImage = NULL; + Image = NULL; + + // + // Report the checkpoint result + // + + if ((Status != EFI_INVALID_PARAMETER) && (Status != EFI_ABORTED)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"failed to return EFI_INVALID_PARAMETER or EFI_ABORTED."; + goto Exit; + } + } + + if (FunctionTested == 0) { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"test skipped - test case does not apply."; + } else { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"correctly returned EFI_INVALID_PARAMETER or EFI_ABORTED."; + } + +Exit: + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + TestGuid, + ResultMessageLabel, + L"Result - %s\n%a:%d: Status - %r", + ResultMessageData, + __FILE__, + (UINTN)__LINE__, + Status + ); + + if (PackageVersionName != NULL) { + gtBS->FreePool (PackageVersionName); + } + if (BufferImageInfo != NULL) { + gtBS->FreePool (BufferImageInfo); + } + if (BufferImage != NULL) { + gtBS->FreePool (BufferImage); + } + if (AbortReason != NULL) { + gtBS->FreePool (AbortReason); + } + + return EFI_SUCCESS; +} + +// **************************************************************************** +// Checkpoint: SetImage, 3 +// **************************************************************************** + +/** + This routine: + - Calls function with valid parameters, except ImageIndex = 0 or + ImageIndex = DescriptorCount + 1. + The function should return EFI_INVALID_PARAMETER or EFI_ABORTED. +**/ + +EFI_STATUS +BBTestSetImageConformanceTestCheckpoint3 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_GUID TestGuid; + CHAR16 *ResultMessageLabel; + CHAR16 *ResultMessageData; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo; + VOID *BufferImage; + + UINTN ImageInfoSize; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo; + UINT32 DescriptorVersion; + UINT8 DescriptorCount; + UINTN DescriptorSize; + UINT32 PackageVersion; + CHAR16 *PackageVersionName; + + CHAR16 *AbortReason; + + VOID *Image; + UINTN ImageSize; + UINT8 ImageIndex; + + // + // Init + // + + Status = EFI_SUCCESS; + AssertionType = EFI_TEST_ASSERTION_PASSED; + TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid009; + ResultMessageLabel = L"SetImage, conformance checkpoint #3"; + + BufferImageInfo = NULL; + BufferImage=NULL; + ImageInfo = NULL; + Image = NULL; + PackageVersionName = NULL; + AbortReason = NULL; + + // Use a sufficiently large buffer to obtain EFI_SUCCESS, + // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL. + // Check for EFI_BUFFER_TOO_SMALL in another conformance test. + + ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20; + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + if (Status == EFI_BUFFER_TOO_SMALL) { + gtBS->FreePool (ImageInfo); + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + if (Status != EFI_SUCCESS) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + BufferImageInfo = ImageInfo; + goto Exit; + } + } + BufferImageInfo = ImageInfo; + + if (DescriptorSize == 0) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"*DescriptorSize is 0."; + goto Exit; // Note the Status = EFI_SUCCESS + } + if ((DescriptorCount * DescriptorSize) > ImageInfoSize) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize."; + goto Exit; // Note the Status = EFI_SUCCESS + } + + // + // Check the data returned by the function + // + + // Dummy image so as to fail on Image = NULL + // Any size since the function should check for index before size + ImageSize = 64; + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageSize, + (VOID **) &Image + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + BufferImage = Image; + + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"failed to return EFI_INVALID_PARAMETER or EFI_ABORTED."; + + ImageIndex = 0; + Status = FirmwareManagement->SetImage ( + FirmwareManagement, + ImageIndex, + Image, + ImageSize, + NULL, // VendorCode + Progress, + &AbortReason + ); + if ((Status != EFI_INVALID_PARAMETER) && (Status != EFI_ABORTED)) { + goto Exit; + } + + if ((DescriptorCount + 1) != 0) { + ImageIndex = DescriptorCount + 1; + Status = FirmwareManagement->SetImage ( + FirmwareManagement, + ImageIndex, + Image, + ImageSize, + NULL, // Vendorcode + Progress, + &AbortReason + ); + if ((Status != EFI_INVALID_PARAMETER) && (Status != EFI_ABORTED)) { + goto Exit; + } + } + + // + // Report the checkpoint result + // + + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"correctly returned EFI_INVALID_PARAMETER or EFI_ABORTED."; + +Exit: + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + TestGuid, + ResultMessageLabel, + L"Result - %s\n%a:%d: Status - %r", + ResultMessageData, + __FILE__, + (UINTN)__LINE__, + Status + ); + + if (PackageVersionName != NULL) { + gtBS->FreePool (PackageVersionName); + } + if (BufferImageInfo != NULL) { + gtBS->FreePool (BufferImageInfo); + } + if (BufferImage != NULL) { + gtBS->FreePool (BufferImage); + } + if (AbortReason != NULL) { + gtBS->FreePool (AbortReason); + } + + return EFI_SUCCESS; +} + +// **************************************************************************** +// Checkpoint: SetImage, 4 +// **************************************************************************** + +/** + This routine: + - The function requires authentication. + - Calls function with valid parameters, except Image has dummy + authentication data. + The function should return EFI_SECURITY_VIOLATION. +**/ + +EFI_STATUS +BBTestSetImageConformanceTestCheckpoint4 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_GUID TestGuid; + CHAR16 *ResultMessageLabel; + CHAR16 *ResultMessageData; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo; + VOID *BufferImage; + + UINTN ImageInfoSize; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo; + UINT32 DescriptorVersion; + UINT8 DescriptorCount; + UINTN DescriptorSize; + UINT32 PackageVersion; + CHAR16 *PackageVersionName; + + CHAR16 *AbortReason; + + VOID *Image; + UINTN ImageSize; + + UINTN i; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *p; + UINTN FunctionTested; + + // + // Init + // + + Status = EFI_SUCCESS; + AssertionType = EFI_TEST_ASSERTION_PASSED; + TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid010; + ResultMessageLabel = L"SetImage, conformance checkpoint #4"; + + BufferImageInfo = NULL; + BufferImage = NULL; + ImageInfo = NULL; + Image = NULL; + PackageVersionName = NULL; + AbortReason = NULL; + FunctionTested = 0; + + // Use a sufficiently large buffer to obtain EFI_SUCCESS, + // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL. + // Check for EFI_BUFFER_TOO_SMALL in another conformance test. + + ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20; + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + if (Status == EFI_BUFFER_TOO_SMALL) { + gtBS->FreePool (ImageInfo); + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + if (Status != EFI_SUCCESS) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + BufferImageInfo = ImageInfo; + goto Exit; + } + } + BufferImageInfo = ImageInfo; + + if (DescriptorSize == 0) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"*DescriptorSize is 0."; + goto Exit; // Note the Status = EFI_SUCCESS + } + if ((DescriptorCount * DescriptorSize) > ImageInfoSize) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize."; + goto Exit; // Note the Status = EFI_SUCCESS + } + + // + // Check the data returned by the function + // + + for (i = 0; i < DescriptorCount; i++) { + p = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *) (((UINT8 *) ImageInfo) + (i * DescriptorSize)); + + if ((p->AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) { + continue; + } + if ((p->AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) { + continue; + } + if (p->Size == 0) { + continue; + } + if ((p->AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) { + continue; + } + if ((p->AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) { + continue; + } + + ImageSize = p->Size; + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageSize, + (VOID **) &Image + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + BufferImage = Image; + FunctionTested++; + Status = FirmwareManagement->SetImage ( + FirmwareManagement, + p->ImageIndex, + Image, + ImageSize, + NULL, // VendorCode + Progress, + &AbortReason + ); + gtBS->FreePool (BufferImage); + BufferImage = NULL; + Image = NULL; + + // + // Report the checkpoint result + // + + if (Status != EFI_SECURITY_VIOLATION) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"failed to return EFI_SECURITY_VIOLATION."; + goto Exit; + } + } + + if (FunctionTested == 0) { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"test skipped - test case does not apply."; + } else { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"correctly returned EFI_SECURITY_VIOLATION"; + } + +Exit: + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + TestGuid, + ResultMessageLabel, + L"Result - %s\n%a:%d: Status - %r", + ResultMessageData, + __FILE__, + (UINTN)__LINE__, + Status + ); + + if (PackageVersionName != NULL) { + gtBS->FreePool (PackageVersionName); + } + if (BufferImageInfo != NULL) { + gtBS->FreePool (BufferImageInfo); + } + if (BufferImage != NULL) { + gtBS->FreePool (BufferImage); + } + if (AbortReason != NULL) { + gtBS->FreePool (AbortReason); + } + + return EFI_SUCCESS; +} + +// **************************************************************************** +// Checkpoint: CheckImage, 1 +// **************************************************************************** + +/** + This routine: + - Calls function with valid parameters, except Image = NULL. + The function should return EFI_INVALID_PARAMETER. +**/ + +EFI_STATUS +BBTestCheckImageConformanceTestCheckpoint1 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_GUID TestGuid; + CHAR16 *ResultMessageLabel; + CHAR16 *ResultMessageData; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo; + + UINTN ImageInfoSize; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo; + UINT32 DescriptorVersion; + UINT8 DescriptorCount; + UINTN DescriptorSize; + UINT32 PackageVersion; + CHAR16 *PackageVersionName; + + UINT32 ImageUpdatable; + + VOID *Image; + UINTN ImageSize; + + UINTN i; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *p; + UINTN FunctionTested; + + // + // Init + // + + Status = EFI_SUCCESS; + AssertionType = EFI_TEST_ASSERTION_PASSED; + TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid011; + ResultMessageLabel = L"CheckImage, conformance checkpoint #1"; + + BufferImageInfo = NULL; + ImageInfo = NULL; + Image = NULL; + PackageVersionName = NULL; + FunctionTested = 0; + + // Use a sufficiently large buffer to obtain EFI_SUCCESS, + // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL. + // Check for EFI_BUFFER_TOO_SMALL in another conformance test. + + ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20; + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + if (Status == EFI_BUFFER_TOO_SMALL) { + gtBS->FreePool (ImageInfo); + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + if (Status != EFI_SUCCESS) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + BufferImageInfo = ImageInfo; + goto Exit; + } + } + BufferImageInfo = ImageInfo; + + if (DescriptorSize == 0) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"*DescriptorSize is 0."; + goto Exit; // Note the Status = EFI_SUCCESS + } + if ((DescriptorCount * DescriptorSize) > ImageInfoSize) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize."; + goto Exit; // Note the Status = EFI_SUCCESS + } + + // + // Check the data returned by the function + // + + for (i = 0; i < DescriptorCount; i++) { + p = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *) (((UINT8 *) ImageInfo) + (i * DescriptorSize)); + + if (((p->AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) == + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) && + ((p->AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) == + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED)) { + continue; + } + if (p->Size == 0) { + continue; + } + if ((p->AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) { + continue; + } + if ((p->AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) { + continue; + } + + ImageSize = p->Size; + Image = NULL; + FunctionTested++; + Status = FirmwareManagement->CheckImage ( + FirmwareManagement, + p->ImageIndex, + Image, + ImageSize, + &ImageUpdatable + ); + + // + // Report the checkpoint result + // + + if (Status != EFI_INVALID_PARAMETER) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"failed to return EFI_INVALID_PARAMETER."; + goto Exit; + } + } + + if (FunctionTested == 0) { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"test skipped - test case does not apply."; + } else { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"correctly returned EFI_INVALID_PARAMETER."; + } + +Exit: + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + TestGuid, + ResultMessageLabel, + L"Result - %s\n%a:%d: Status - %r", + ResultMessageData, + __FILE__, + (UINTN)__LINE__, + Status + ); + + if (PackageVersionName != NULL) { + gtBS->FreePool (PackageVersionName); + } + if (BufferImageInfo != NULL) { + gtBS->FreePool (BufferImageInfo); + } + + return EFI_SUCCESS; +} + +// **************************************************************************** +// Checkpoint: CheckImage, 2 +// **************************************************************************** + +/** + This routine: + - The function requires authentication. + - Calls function with valid parameters, except Image has dummy + authentication data. + The function should return EFI_SECURITY_VIOLATION. +**/ + +EFI_STATUS +BBTestCheckImageConformanceTestCheckpoint2 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_GUID TestGuid; + CHAR16 *ResultMessageLabel; + CHAR16 *ResultMessageData; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo; + VOID *BufferImage; + + UINTN ImageInfoSize; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo; + UINT32 DescriptorVersion; + UINT8 DescriptorCount; + UINTN DescriptorSize; + UINT32 PackageVersion; + CHAR16 *PackageVersionName; + + UINT32 ImageUpdatable; + + VOID *Image; + UINTN ImageSize; + + UINTN i; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *p; + UINTN FunctionTested; + + // + // Init + // + + Status = EFI_SUCCESS; + AssertionType = EFI_TEST_ASSERTION_PASSED; + TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid012; + ResultMessageLabel = L"CheckImage, conformance checkpoint #2"; + + BufferImageInfo = NULL; + BufferImage = NULL; + ImageInfo = NULL; + Image = NULL; + PackageVersionName = NULL; + FunctionTested = 0; + + // Use a sufficiently large buffer to obtain EFI_SUCCESS, + // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL. + // Check for EFI_BUFFER_TOO_SMALL in another conformance test. + + ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20; + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + if (Status == EFI_BUFFER_TOO_SMALL) { + gtBS->FreePool (ImageInfo); + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + if (Status != EFI_SUCCESS) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + BufferImageInfo = ImageInfo; + goto Exit; + } + } + BufferImageInfo = ImageInfo; + + if (DescriptorSize == 0) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"*DescriptorSize is 0."; + goto Exit; // Note the Status = EFI_SUCCESS + } + if ((DescriptorCount * DescriptorSize) > ImageInfoSize) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize."; + goto Exit; // Note the Status = EFI_SUCCESS + } + + // + // Check the data returned by the function + // + + for (i = 0; i < DescriptorCount; i++) { + p = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *) (((UINT8 *) ImageInfo) + (i * DescriptorSize)); + + if ((p->AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) { + continue; + } + if ((p->AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) { + continue; + } + if (p->Size == 0) { + continue; + } + if ((p->AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) { + continue; + } + if ((p->AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) { + continue; + } + + ImageSize = p->Size; + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageSize, + (VOID **) &Image + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + BufferImage = Image; + FunctionTested++; + Status = FirmwareManagement->CheckImage ( + FirmwareManagement, + p->ImageIndex, + Image, + ImageSize, + &ImageUpdatable + ); + gtBS->FreePool (BufferImage); + BufferImage = NULL; + Image = NULL; + + // + // Report the checkpoint result + // + + if (Status != EFI_SECURITY_VIOLATION) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"failed to return EFI_SECURITY_VIOLATION."; + goto Exit; + } + } + + if (FunctionTested == 0) { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"test skipped - test case does not apply."; + } else { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"correctly returned EFI_SECURITY_VIOLATION"; + } + +Exit: + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + TestGuid, + ResultMessageLabel, + L"Result - %s\n%a:%d: Status - %r", + ResultMessageData, + __FILE__, + (UINTN)__LINE__, + Status + ); + + if (PackageVersionName != NULL) { + gtBS->FreePool (PackageVersionName); + } + if (BufferImageInfo != NULL) { + gtBS->FreePool (BufferImageInfo); + } + if (BufferImage != NULL) { + gtBS->FreePool (BufferImage); + } + + return EFI_SUCCESS; +} + +// **************************************************************************** +// Checkpoint: SetPackageInfo, 1 +// **************************************************************************** + +/** + This routine: + - Gets PackageVersionNameMaxLen. + - Calls function with valid parameters, except PackageVersionName is longer + than the value returned in PackageVersionNameLen. + The function should return EFI_INVALID_PARAMETER. +**/ + +EFI_STATUS +BBTestSetPackageInfoConformanceTestCheckpoint1 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_GUID TestGuid; + CHAR16 *ResultMessageLabel; + CHAR16 *ResultMessageData; + + UINT32 PackageVersion; + CHAR16 *PackageVersionName; + UINT32 PackageVersionNameMaxLen; + UINT64 AttributesSupported; + UINT64 AttributesSetting; + + CHAR16 *TestName; + UINT32 TestNameLength; + + UINTN i; + + // + // Init + // + + Status = EFI_SUCCESS; + AssertionType = EFI_TEST_ASSERTION_PASSED; + TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid013; + ResultMessageLabel = L"SetPackageInfo, function checkpoint #1"; + + PackageVersionName = NULL; + TestName = NULL; + + // + // Get PackageVersionNameMaxLen + // + + Status = FirmwareManagement->GetPackageInfo ( + FirmwareManagement, + &PackageVersion, + &PackageVersionName, + &PackageVersionNameMaxLen, + &AttributesSupported, + &AttributesSetting + ); + if (Status != EFI_SUCCESS) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"test skipped - test case does not apply."; + if (PackageVersionNameMaxLen == 0) { + goto Exit; + } + if (((AttributesSupported & PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) == + PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) && + ((AttributesSetting & PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) == + PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED)) { + goto Exit; + } + if ((AttributesSupported & PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) != + PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) { + goto Exit; + } + if ((AttributesSetting & PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) != + PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) { + goto Exit; + } + + // + // Check the data returned by the function + // + + gtBS->FreePool (PackageVersionName); + PackageVersionName = NULL; + TestNameLength = PackageVersionNameMaxLen + 1; + Status = gtBS->AllocatePool ( + EfiBootServicesData, + TestNameLength * 2, // Unicode + (VOID **) &TestName + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + for (i = 0; i < (TestNameLength - 1); i++) { + TestName[i] = L' '; + } + TestName[i] = L'\0'; + Status = FirmwareManagement->SetPackageInfo ( + FirmwareManagement, + NULL, // Image + 0, // ImageSize + NULL, // VendorCode + 0x01010101, // Dummy PackageVersion + TestName + ); + + if (Status == EFI_INVALID_PARAMETER) { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"correctly returned EFI_INVALID_PARAMETER."; + } else { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"failed to return EFI_INVALID_PARAMETER."; + } + + // + // Report the checkpoint result + // + +Exit: + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + TestGuid, + ResultMessageLabel, + L"Result - %s\n%a:%d: Status - %r", + ResultMessageData, + __FILE__, + (UINTN)__LINE__, + Status + ); + + if (PackageVersionName != NULL) { + gtBS->FreePool (PackageVersionName); + } + if (TestName != NULL) { + gtBS->FreePool (TestName); + } + + return EFI_SUCCESS; +} + +// **************************************************************************** +// Checkpoint: SetPackageInfo, 2 +// **************************************************************************** + +/** + This routine: + - The function requires authentication. + - Calls function with valid parameters, except Image is NULL. + The function should return EFI_SECURITY_VIOLATION. +**/ + +EFI_STATUS +BBTestSetPackageInfoConformanceTestCheckpoint2 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_GUID TestGuid; + CHAR16 *ResultMessageLabel; + CHAR16 *ResultMessageData; + + UINT32 PackageVersion; + CHAR16 *PackageVersionName; + UINT32 PackageVersionNameMaxLen; + UINT64 AttributesSupported; + UINT64 AttributesSetting; + + VOID *Image; + UINTN ImageSize; + + // + // Init + // + + Status = EFI_SUCCESS; + AssertionType = EFI_TEST_ASSERTION_PASSED; + TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid014; + ResultMessageLabel = L"SetPackageInfo, function checkpoint #2"; + + PackageVersionName = NULL; + + // + // Get PackageVersionNameMaxLen + // + + Status = FirmwareManagement->GetPackageInfo ( + FirmwareManagement, + &PackageVersion, + &PackageVersionName, + &PackageVersionNameMaxLen, + &AttributesSupported, + &AttributesSetting + ); + if (Status != EFI_SUCCESS) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"test skipped - test case does not apply."; + if ((AttributesSupported & PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) { + goto Exit; + } + if ((AttributesSetting & PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) { + goto Exit; + } + if ((AttributesSupported & PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) != + PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) { + goto Exit; + } + if ((AttributesSetting & PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) != + PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) { + goto Exit; + } + + // + // Check the data returned by the function + // + + Image = NULL; + ImageSize = 64; // Dummy + Status = FirmwareManagement->SetPackageInfo ( + FirmwareManagement, + Image, + ImageSize, + NULL, // VendorCode + PackageVersion, + PackageVersionName + ); + + if (Status == EFI_SECURITY_VIOLATION) { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"correctly returned EFI_SECURITY_VIOLATION."; + } else { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"failed to return EFI_SECURITY_VIOLATION."; + } + + // + // Report the checkpoint result + // + +Exit: + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + TestGuid, + ResultMessageLabel, + L"Result - %s\n%a:%d: Status - %r", + ResultMessageData, + __FILE__, + (UINTN)__LINE__, + Status + ); + + if (PackageVersionName != NULL) { + gtBS->FreePool (PackageVersionName); + } + + return EFI_SUCCESS; +} + +// **************************************************************************** +// Checkpoint: SetPackageInfo, 3 +// **************************************************************************** + +/** + This routine: + - The function requires authentication. + - Calls function with valid parameters, except ImageSize is 0. + The function should return EFI_SECURITY_VIOLATION. +**/ + +EFI_STATUS +BBTestSetPackageInfoConformanceTestCheckpoint3 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_GUID TestGuid; + CHAR16 *ResultMessageLabel; + CHAR16 *ResultMessageData; + + UINT32 PackageVersion; + CHAR16 *PackageVersionName; + UINT32 PackageVersionNameMaxLen; + UINT64 AttributesSupported; + UINT64 AttributesSetting; + + VOID *Image; + UINTN ImageSize; + + // + // Init + // + + Status = EFI_SUCCESS; + AssertionType = EFI_TEST_ASSERTION_PASSED; + TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid015; + ResultMessageLabel = L"SetPackageInfo, function checkpoint #3"; + + PackageVersionName = NULL; + Image = NULL; + + // + // Get PackageVersionNameMaxLen + // + + Status = FirmwareManagement->GetPackageInfo ( + FirmwareManagement, + &PackageVersion, + &PackageVersionName, + &PackageVersionNameMaxLen, + &AttributesSupported, + &AttributesSetting + ); + if (Status != EFI_SUCCESS) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"test skipped - test case does not apply."; + if ((AttributesSupported & PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) { + goto Exit; + } + if ((AttributesSetting & PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) { + goto Exit; + } + if ((AttributesSupported & PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) != + PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) { + goto Exit; + } + if ((AttributesSetting & PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) != + PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) { + goto Exit; + } + + // + // Check the data returned by the function + // + + Status = gtBS->AllocatePool ( + EfiBootServicesData, + 64, // Dummy + (VOID **) &Image + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + ImageSize = 0; + Status = FirmwareManagement->SetPackageInfo ( + FirmwareManagement, + Image, + ImageSize, + NULL, // VendorCode + PackageVersion, + PackageVersionName + ); + + if (Status == EFI_SECURITY_VIOLATION) { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"correctly returned EFI_SECURITY_VIOLATION."; + } else { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"failed to return EFI_SECURITY_VIOLATION."; + } + + // + // Report the checkpoint result + // + +Exit: + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + TestGuid, + ResultMessageLabel, + L"Result - %s\n%a:%d: Status - %r", + ResultMessageData, + __FILE__, + (UINTN)__LINE__, + Status + ); + + if (PackageVersionName != NULL) { + gtBS->FreePool (PackageVersionName); + } + if (Image != NULL) { + gtBS->FreePool (Image); + } + + return EFI_SUCCESS; +} + +// **************************************************************************** +// Checkpoint: SetPackageInfo, 4 +// **************************************************************************** + +/** + This routine: + - The function requires authentication. + - Calls function with valid parameters, except Image has a dummy + authentication data. + The function should return EFI_SECURITY_VIOLATION. +**/ + +EFI_STATUS +BBTestSetPackageInfoConformanceTestCheckpoint4 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_GUID TestGuid; + CHAR16 *ResultMessageLabel; + CHAR16 *ResultMessageData; + + UINT32 PackageVersion; + CHAR16 *PackageVersionName; + UINT32 PackageVersionNameMaxLen; + UINT64 AttributesSupported; + UINT64 AttributesSetting; + + VOID *Image; + UINTN ImageSize; + + // + // Init + // + + Status = EFI_SUCCESS; + AssertionType = EFI_TEST_ASSERTION_PASSED; + TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid016; + ResultMessageLabel = L"SetPackageInfo, function checkpoint #4"; + + PackageVersionName = NULL; + Image = NULL; + ImageSize = 64; + + // + // Get PackageVersionNameMaxLen + // + + Status = FirmwareManagement->GetPackageInfo ( + FirmwareManagement, + &PackageVersion, + &PackageVersionName, + &PackageVersionNameMaxLen, + &AttributesSupported, + &AttributesSetting + ); + if (Status != EFI_SUCCESS) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"test skipped - test case does not apply."; + if ((AttributesSupported & PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) { + goto Exit; + } + if ((AttributesSetting & PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) { + goto Exit; + } + if ((AttributesSupported & PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) != + PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) { + goto Exit; + } + if ((AttributesSetting & PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) != + PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) { + goto Exit; + } + + // + // Check the data returned by the function + // + + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageSize, + (VOID **) &Image + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + Status = FirmwareManagement->SetPackageInfo ( + FirmwareManagement, + Image, + ImageSize, + NULL, // VendorCode + PackageVersion, + PackageVersionName + ); + + if (Status == EFI_SECURITY_VIOLATION) { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"correctly returned EFI_SECURITY_VIOLATION."; + } else { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"failed to return EFI_SECURITY_VIOLATION."; + } + + // + // Report the checkpoint result + // + +Exit: + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + TestGuid, + ResultMessageLabel, + L"Result - %s\n%a:%d: Status - %r", + ResultMessageData, + __FILE__, + (UINTN)__LINE__, + Status + ); + + if (PackageVersionName != NULL) { + gtBS->FreePool (PackageVersionName); + } + if (Image != NULL) { + gtBS->FreePool (Image); + } + + return EFI_SUCCESS; +} + diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestFunction.c new file mode 100644 index 000000000000..b595c9ac5d05 --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestFunction.c @@ -0,0 +1,879 @@ +/** @file + + Copyright 2006 - 2016 Unified EFI, Inc.
+ Copyright (c) 2010 - 2016, Dell Inc. All rights reserved.
+ Copyright (c) 2019,Microchip Technology Inc.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +/*++ + +Module Name: + FirmwareManagementBBTestFunction.c + +Abstract: + Firmware Management Protocol's function tests. + +--*/ + +#define DEBUG_ALL 0 +#define DEBUG_GET_IMAGE_INFO 1 +#define DEBUG_GET_IMAGE 0 +#define DEBUG_GET_PACKAGE_INFO 1 + + +#include "SctLib.h" +#include "FirmwareManagementBBTestMain.h" + +// **************************************************************************** +// Check Points +// **************************************************************************** + +EFI_STATUS +BBTestGetImageInfoFunctionTestCheckpoint1 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ); + +EFI_STATUS +BBTestGetImageFunctionTestCheckpoint1 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ); + +EFI_STATUS +BBTestGetPackageInfoFunctionTestCheckpoint1 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ); + +// **************************************************************************** +// Test Cases +// +// +// **************************************************************************** + +// **************************************************************************** +// Test Case: GetImageInfo +// **************************************************************************** + +EFI_STATUS +BBTestGetImageInfoFunctionTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ) +{ + EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib; + EFI_STATUS Status; + EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement; + + // + // Init + // + + FirmwareManagement = (EFI_FIRMWARE_MANAGEMENT_PROTOCOL*)ClientInterface; + + Status = gtBS->HandleProtocol ( + SupportHandle, + &gEfiStandardTestLibraryGuid, + (VOID **) &StandardLib + ); + if (EFI_ERROR(Status)) { + return Status; + } + + // + // Call check point(s) + // + + BBTestGetImageInfoFunctionTestCheckpoint1 (StandardLib, FirmwareManagement); + + return EFI_SUCCESS; +} + +// **************************************************************************** +// Test Case: GetImage +// **************************************************************************** + +EFI_STATUS +BBTestGetImageFunctionTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ) +{ + EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib; + EFI_STATUS Status; + EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement; + + // + // Init + // + + FirmwareManagement = (EFI_FIRMWARE_MANAGEMENT_PROTOCOL*)ClientInterface; + + Status = gtBS->HandleProtocol ( + SupportHandle, + &gEfiStandardTestLibraryGuid, + (VOID **) &StandardLib + ); + if (EFI_ERROR(Status)) { + return Status; + } + + // + // Call check point(s) + // + + BBTestGetImageFunctionTestCheckpoint1 (StandardLib, FirmwareManagement); + + return EFI_SUCCESS; +} + +// **************************************************************************** +// Test Case: GetPackageInfo +// **************************************************************************** + +EFI_STATUS +BBTestGetPackageInfoFunctionTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ) +{ + EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib; + EFI_STATUS Status; + EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement; + + // + // Init + // + + FirmwareManagement = (EFI_FIRMWARE_MANAGEMENT_PROTOCOL*)ClientInterface; + + Status = gtBS->HandleProtocol ( + SupportHandle, + &gEfiStandardTestLibraryGuid, + (VOID **) &StandardLib + ); + if (EFI_ERROR(Status)) { + return Status; + } + + // + // Call check point(s) + // + + BBTestGetPackageInfoFunctionTestCheckpoint1 (StandardLib, FirmwareManagement); + + return EFI_SUCCESS; +} + +// **************************************************************************** +// Check Points +// +// +// **************************************************************************** + +// **************************************************************************** +// Checkpoint: GetImageInfo, 1 +// **************************************************************************** + +/** + This routine: + - Calls function with all valid parameters. + The function should return EFI_SUCCESS. + - Checks DescriptorSize is 0. + - Checks (DescriptorCount * DescriptorSize) is <= ImageInfoSize. + - Checks DescriptorVersion is == 1. + - Checks ImageIndex is between 1 and DescriptorCount. + - Checks AttributesSupported has no bits set beyond bit3. + - Checks AttribtuesSetting has no bits set beyond bit3. + - Checks Compatibilities bit1 thru bit15 are 0s. +**/ + +EFI_STATUS +BBTestGetImageInfoFunctionTestCheckpoint1 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_GUID TestGuid; + CHAR16 *ResultMessageLabel; + CHAR16 *ResultMessageData; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo; + + UINTN ImageInfoSize; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo; + UINT32 DescriptorVersion; + UINT8 DescriptorCount; + UINTN DescriptorSize; + UINT32 PackageVersion; + CHAR16 *PackageVersionName; + + CHAR16* Attribute[4]; + + UINTN i; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *p; + +#if (DEBUG_ALL || DEBUG_GET_IMAGE_INFO) + + CHAR16 *BitField; + CHAR16 *BitSetting; + + UINT64 j; + UINTN k; + +#endif + + // + // Init + // + + Status = EFI_SUCCESS; + AssertionType = EFI_TEST_ASSERTION_PASSED; + TestGuid = gFirmwareManagementBBTestFunctionAssertionGuid001; + ResultMessageLabel = L"GetImageInfo, function checkpoint #1"; + + BufferImageInfo = NULL; + ImageInfo = NULL; + PackageVersionName = NULL; + + Attribute[0] = L"Image Updatable"; + Attribute[1] = L"Reset Required"; + Attribute[2] = L"Authentication Required"; + Attribute[3] = L"In Use"; + + // Use a sufficiently large buffer to obtain EFI_SUCCESS, + // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL. + // Check for EFI_BUFFER_TOO_SMALL in another conformance test. + + ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20; + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + if (Status == EFI_BUFFER_TOO_SMALL) { + gtBS->FreePool (ImageInfo); + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + } + + // + // Check the data returned by the function + // + + BufferImageInfo = ImageInfo; + + if (Status == EFI_SUCCESS) { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"correctly returned EFI_SUCCESS."; + } else { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"failed to return EFI_SUCCESS."; + goto Exit; + } + + if (DescriptorSize == 0) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"*DescriptorSize is 0."; + goto Exit; // Note the Status = EFI_SUCCESS + } + + if ((DescriptorCount * DescriptorSize) > ImageInfoSize) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize."; + goto Exit; // Note the Status = EFI_SUCCESS + } + + if (DescriptorVersion != 1) { + AssertionType = EFI_TEST_ASSERTION_WARNING; + ResultMessageData = L"*DescriptorVersion != 1."; + goto Exit; + } + + for (i = 0; i < DescriptorCount; i++) { + p = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *) (((UINT8 *) ImageInfo) + (i * DescriptorSize)); + + if (p->ImageIndex > DescriptorCount) { + AssertionType = EFI_TEST_ASSERTION_WARNING; + ResultMessageData = L"ImageIndex is beyond DescriptorCount."; + goto Exit; + } + + if ((p->AttributesSupported & 0xFFFFFFFFFFFFFFF0) != 0) { + AssertionType = EFI_TEST_ASSERTION_WARNING; + ResultMessageData = L"AttributesSupported has bit(s) set beyond bit3."; + goto Exit; + } + + if ((p->AttributesSetting & 0xFFFFFFFFFFFFFFF0) != 0) { + AssertionType = EFI_TEST_ASSERTION_WARNING; + ResultMessageData = L"AttributesSetting has bit(s) set beyond bit3."; + goto Exit; + } + + if ((p->Compatibilities & 0x000000000000FFFE) !=0) { + AssertionType = EFI_TEST_ASSERTION_WARNING; + ResultMessageData = L"Compatibilities have bit(s) set between bit1 and bit15."; + goto Exit; + } + } + +#if (DEBUG_ALL || DEBUG_GET_IMAGE_INFO) + + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_QUIET, + L"Firmware Image Info Header: \n" + L" - *ImageInfoSize = %x\n" + L" - *DescriptorVersion = %x\n" + L" - *DescriptorCount = %x\n" + L" - *DescriptorSzie = %x\n" + L" - *PackageVersion = %08x\n" + L" - **PackageVersionName = %s\n", + ImageInfoSize, + DescriptorVersion, + DescriptorCount, + DescriptorSize, + PackageVersion, + PackageVersionName + ); + + for (i = 0; i < DescriptorCount; i++) { + p = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *) (((UINT8 *) ImageInfo) + (i * DescriptorSize)); + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_QUIET, + L"Descriptor Index = %x:\n" + L" - ImageTypeId = %08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x", + p->ImageIndex, + p->ImageTypeId.Data1, + p->ImageTypeId.Data2, + p->ImageTypeId.Data3, + p->ImageTypeId.Data4[0], + p->ImageTypeId.Data4[1], + p->ImageTypeId.Data4[2], + p->ImageTypeId.Data4[3], + p->ImageTypeId.Data4[4], + p->ImageTypeId.Data4[5], + p->ImageTypeId.Data4[6], + p->ImageTypeId.Data4[7] + ); + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_QUIET, + L" - ImageId = %016X\n" + L" - *ImageIdName = %s\n" + L" - Version = %08x\n" + L" - *VersionName = %s\n" + L" - Size = %x", + p->ImageId, + p->ImageIdName, + p->Version, + p->VersionName, + p->Size + ); + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_QUIET, + L" - AttributesSupported = %016x\n" + L" - AttributesSetting = %016x", + p->AttributesSupported, + p->AttributesSetting + ); + for (j = 1, k = 0; j <= IMAGE_ATTRIBUTE_IN_USE; j = SctLShiftU64(j, 1), k++) { + BitField = Attribute[k]; + if ((p->AttributesSupported & j) != j) { + BitSetting = L"Not Supported"; + } else if ((p->AttributesSetting & j) == j) { + BitSetting = L"Yes"; + } else { + BitSetting = L"No"; + } + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_QUIET, + L" - %s = %s", + BitField, + BitSetting + ); + } + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_QUIET, + L" - Compatibilities = %016x\n", + p->Compatibilities + ); + } + +#endif + + // + // Report the checkpoint result + // + + +Exit: + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + TestGuid, + ResultMessageLabel, + L"Result - %s\n%a:%d: Status - %r", + ResultMessageData, + __FILE__, + (UINTN)__LINE__, + Status + ); + if (PackageVersionName != NULL) { + gtBS->FreePool (PackageVersionName); + } + if (BufferImageInfo != NULL) { + gtBS->FreePool (BufferImageInfo); + } + + return EFI_SUCCESS; +} + +// **************************************************************************** +// Checkpoint: GetImage, 1 +// **************************************************************************** + +/** + This routine: + - Calls function with all valid parameters. + The function should return EFI_SUCCESS or EFI_UNSUPPORTED. +**/ + +EFI_STATUS +BBTestGetImageFunctionTestCheckpoint1 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_GUID TestGuid; + CHAR16 *ResultMessageLabel; + CHAR16 *ResultMessageData; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo; + VOID *BufferImage; + + UINTN ImageInfoSize; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo; + UINT32 DescriptorVersion; + UINT8 DescriptorCount; + UINTN DescriptorSize; + UINT32 PackageVersion; + CHAR16 *PackageVersionName; + + VOID *Image; + UINTN ImageSize; + + UINTN i; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *p; + UINTN FunctionTested; + + // + // Init + // + + Status = EFI_SUCCESS; + AssertionType = EFI_TEST_ASSERTION_PASSED; + TestGuid = gFirmwareManagementBBTestFunctionAssertionGuid002; + ResultMessageLabel = L"GetImage, function checkpoint #1"; + + BufferImageInfo = NULL; + BufferImage = NULL; + ImageInfo = NULL; + Image = NULL; + PackageVersionName = NULL; + FunctionTested = 0; + + // Use a sufficiently large buffer to obtain EFI_SUCCESS, + // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL. + // Check for EFI_BUFFER_TOO_SMALL in another conformance test. + + ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20; + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + if (Status == EFI_BUFFER_TOO_SMALL) { + gtBS->FreePool (ImageInfo); + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageInfoSize, + (VOID **) &ImageInfo + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + Status = FirmwareManagement->GetImageInfo ( + FirmwareManagement, + &ImageInfoSize, + ImageInfo, + &DescriptorVersion, + &DescriptorCount, + &DescriptorSize, + &PackageVersion, + &PackageVersionName + ); + if (Status != EFI_SUCCESS) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + BufferImageInfo = ImageInfo; + goto Exit; + } + } + BufferImageInfo = ImageInfo; + + if (DescriptorSize == 0) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"*DescriptorSize is 0."; + goto Exit; // Note the Status = EFI_SUCCESS + } + if ((DescriptorCount * DescriptorSize) > ImageInfoSize) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize."; + goto Exit; // Note the Status = EFI_SUCCESS + } + + // + // Check the data returned by the function + // + + for (i = 0; i < DescriptorCount; i++) { + p = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *) (((UINT8 *) ImageInfo) + (i * DescriptorSize)); + + if (((p->AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) == + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) && + ((p->AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) == + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED)) { + continue; + } + if (p->Size == 0) { + continue; + } + if ((p->AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) { + continue; + } + if ((p->AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) { + continue; + } + + ImageSize = p->Size; + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageSize, + (VOID **) &Image + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + BufferImage = Image; + + FunctionTested++; + Status = FirmwareManagement->GetImage ( + FirmwareManagement, + p->ImageIndex, + Image, + &ImageSize + ); + + if (Status == EFI_BUFFER_TOO_SMALL) { + gtBS->FreePool (Image); + Status = gtBS->AllocatePool ( + EfiBootServicesData, + ImageSize, + (VOID **) &Image + ); + if (EFI_ERROR (Status)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"test case initialization failure."; + goto Exit; + } + } + BufferImage = Image; + + Status = FirmwareManagement->GetImage ( + FirmwareManagement, + p->ImageIndex, + Image, + &ImageSize + ); + gtBS->FreePool (BufferImage); + BufferImage = NULL; + Image = NULL; + + // + // Report the checkpoint result + // + + if ((Status != EFI_SUCCESS) && (Status != EFI_UNSUPPORTED)) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"failed to return EFI_SUCCESS or EFI_UNSUPPORTED."; + goto Exit; + } + } + + if (FunctionTested == 0) { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"test skipped - test case does not apply."; + } else { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"correctly returned EFI_SUCCESS or EFI_UNSUPPORTED."; + } + +Exit: + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + TestGuid, + ResultMessageLabel, + L"Result - %s\n%a:%d: Status - %r", + ResultMessageData, + __FILE__, + (UINTN)__LINE__, + Status + ); + + if (PackageVersionName != NULL) { + gtBS->FreePool (PackageVersionName); + } + if (BufferImageInfo != NULL) { + gtBS->FreePool (BufferImageInfo); + } + if (BufferImage != NULL) { + gtBS->FreePool (BufferImage); + } + + return EFI_SUCCESS; +} + +// **************************************************************************** +// Checkpoint: GetPackageInfo, 1 +// **************************************************************************** + +/** + This routine: + - Calls function with all valid parameters. + The function should return EFI_SUCCESS or EFI_UNSUPPORTED. + - Checks AttributesSupported has no bits set beyond bit2. + - Checks AttributesSetting has no bits set beyond bit2. +**/ + +EFI_STATUS +BBTestGetPackageInfoFunctionTestCheckpoint1 ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement + ) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_GUID TestGuid; + CHAR16 *ResultMessageLabel; + CHAR16 *ResultMessageData; + + UINT32 PackageVersion; + CHAR16 *PackageVersionName; + UINT32 PackageVersionNameMaxLen; + UINT64 AttributesSupported; + UINT64 AttributesSetting; + + CHAR16* Attribute[3]; + +#if (DEBUG_ALL || DEBUG_GET_PACKAGE_INFO) + + CHAR16 *BitField; + CHAR16 *BitSetting; + + UINT64 j; + UINTN k; + +#endif + + // + // Init + // + + Status = EFI_SUCCESS; + AssertionType = EFI_TEST_ASSERTION_PASSED; + TestGuid = gFirmwareManagementBBTestFunctionAssertionGuid003; + ResultMessageLabel = L"GetPackageInfo, function checkpoint #1"; + + PackageVersionName = NULL; + + Attribute[0] = L"Version Updatable"; + Attribute[1] = L"Reset Required"; + Attribute[2] = L"Authentication Required"; + + // + // Check the data returned by the function + // + + Status = FirmwareManagement->GetPackageInfo ( + FirmwareManagement, + &PackageVersion, + &PackageVersionName, + &PackageVersionNameMaxLen, + &AttributesSupported, + &AttributesSetting + ); + + if ((Status == EFI_SUCCESS) || (Status == EFI_UNSUPPORTED)) { + AssertionType = EFI_TEST_ASSERTION_PASSED; + ResultMessageData = L"correctly returned EFI_SUCCESS or EFI_UNSUPPORTED."; + } else { + AssertionType = EFI_TEST_ASSERTION_FAILED; + ResultMessageData = L"failed to return EFI_SUCCESS or EFI_UNSUPPORTED."; + goto Exit; + } + +#if (DEBUG_ALL || DEBUG_GET_PACKAGE_INFO) + + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_QUIET, + L"Firmware Package Info: \n" + L" - *PackageVersion = %08x\n" + L" - **PackageVersionName = %s\n" + L" - *PackageVersionNameMaxLen = %08x", + PackageVersion, + PackageVersionName, + PackageVersionNameMaxLen + ); + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_QUIET, + L" - *AttributesSupported = %016x\n" + L" - *AttributesSetting = %016x", + AttributesSupported, + AttributesSetting + ); + for (j = 1, k = 0; j <= PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED; j = SctLShiftU64(j, 1), k++) { + BitField = Attribute[k]; + if ((AttributesSupported & j) != j) { + BitSetting = L"Not Supported"; + } else if ((AttributesSetting & j) == j) { + BitSetting = L"Yes"; + } else { + BitSetting = L"No"; + } + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_QUIET, + L" - %s = %s", + BitField, + BitSetting + ); + } + +#endif + + if ((AttributesSupported & 0xFFFFFFFFFFFFFFF8) != 0) { + AssertionType = EFI_TEST_ASSERTION_WARNING; + ResultMessageData = L"*AttributesSupported has bit(s) set beyond bit2."; + goto Exit; + } + + if ((AttributesSetting & 0xFFFFFFFFFFFFFFF8) != 0) { + AssertionType = EFI_TEST_ASSERTION_WARNING; + ResultMessageData = L"*AttributesSetting has bit(s) set beyond bit2."; + goto Exit; + } + + // + // Report the checkpoint result + // + +Exit: + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + TestGuid, + ResultMessageLabel, + L"Result - %s\n%a:%d: Status - %r", + ResultMessageData, + __FILE__, + (UINTN)__LINE__, + Status + ); + + if (PackageVersionName != NULL) { + gtBS->FreePool (PackageVersionName); + } + + return EFI_SUCCESS; +} + diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestMain.c new file mode 100644 index 000000000000..0c7f33733683 --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestMain.c @@ -0,0 +1,169 @@ +/** @file + + Copyright 2006 - 2017 Unified EFI, Inc.
+ Copyright (c) 2010 - 2017, Dell Inc. All rights reserved.
+ Copyright (c) 2019,Microchip Technology Inc.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +/*++ + +Module Name: + + FirmwareManagementBBTestMain.c + +Abstract: + + Firmware Management Protocol test driver. + +--*/ + +#include "SctLib.h" +#include "FirmwareManagementBBTestMain.h" + +// **************************************************************************** +// Variables +// **************************************************************************** + +EFI_HANDLE mImageHandle; + +EFI_BB_TEST_PROTOCOL *gBBTestProtocolInterface; + +EFI_BB_TEST_PROTOCOL_FIELD gBBTestProtocolField = { + EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_REVISION, + IHV_EFI_FIRMWARE_MANAGEMENT_PROTOCOL_GUID, + L"Firmware Management Protocol Test", + L"UEFI 2.3 Firmware Management Protocol Black-Box Test" +}; + +EFI_GUID gSupportProtocolGuid[] = { + EFI_STANDARD_TEST_LIBRARY_GUID, + EFI_NULL_GUID +}; + +EFI_BB_TEST_ENTRY_FIELD gBBTestEntryField[] = { + { + EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0101, + L"Function_Test-GetImageInfo", + L"Function auto test for Firmware Management Protocol GetImageInfo().", + EFI_TEST_LEVEL_MINIMAL, + gSupportProtocolGuid, + EFI_TEST_CASE_AUTO, + BBTestGetImageInfoFunctionTest + }, + { + EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0102, + L"Function_Test-GetImage", + L"Function auto test for Firmware Management Protocol GetImage().", + EFI_TEST_LEVEL_MINIMAL, + gSupportProtocolGuid, + EFI_TEST_CASE_AUTO, + BBTestGetImageFunctionTest + }, + { + EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0105, + L"Function_Test-GetPackageInfo", + L"Function auto test for Firmware Management Protocol GetPackageInfo().", + EFI_TEST_LEVEL_MINIMAL, + gSupportProtocolGuid, + EFI_TEST_CASE_AUTO, + BBTestGetPackageInfoFunctionTest + }, + { + EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0201, + L"Conformance_Test-GetImageInfo", + L"Conformance auto test for Firmware Management Protocol GetImageInfo().", + EFI_TEST_LEVEL_MINIMAL, + gSupportProtocolGuid, + EFI_TEST_CASE_AUTO, + BBTestGetImageInfoConformanceTest + }, + { + EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0202, + L"Conformance_Test-GetImage", + L"Conformance auto test for Firmware Management Protocol GetImage().", + EFI_TEST_LEVEL_MINIMAL, + gSupportProtocolGuid, + EFI_TEST_CASE_AUTO, + BBTestGetImageConformanceTest + }, + { + EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0203, + L"Conformance_Test-SetImage", + L"Conformance auto test for Firmware Management Protocol SetImage().", + EFI_TEST_LEVEL_MINIMAL, + gSupportProtocolGuid, + EFI_TEST_CASE_AUTO, + BBTestSetImageConformanceTest + }, + { + EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0204, + L"Conformance_Test-CheckImage", + L"Conformance auto test for Firmware Management Protocol CheckImage().", + EFI_TEST_LEVEL_MINIMAL, + gSupportProtocolGuid, + EFI_TEST_CASE_AUTO, + BBTestCheckImageConformanceTest + }, + { + EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0206, + L"Conformance_Test-SetPackageInfo", + L"Conformance auto test for Firmware Management Protocol SetPackageInfo().", + EFI_TEST_LEVEL_MINIMAL, + gSupportProtocolGuid, + EFI_TEST_CASE_AUTO, + BBTestSetPackageInfoConformanceTest + }, + 0 +}; + +// **************************************************************************** +// Initialization and Unload functions +// **************************************************************************** + + +EFI_STATUS +EFIAPI +InitializeFirmwareManagementBBTest ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EfiInitializeTestLib (ImageHandle, SystemTable); + + // + // initialize test utility lib + // + + SctInitializeLib (ImageHandle, SystemTable); + + mImageHandle = ImageHandle; + + return EfiInitAndInstallIHVBBTestInterface ( + &ImageHandle, + &gBBTestProtocolField, + gBBTestEntryField, + UnloadFirmwareManagementBBTest, + &gBBTestProtocolInterface + ); +} + +EFI_STATUS +EFIAPI +UnloadFirmwareManagementBBTest ( + IN EFI_HANDLE ImageHandle + ) +{ + return EfiUninstallAndFreeIHVBBTestInterface ( + ImageHandle, + gBBTestProtocolInterface + ); +} + diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/Guid.c new file mode 100644 index 000000000000..fde9c67e820d --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/Guid.c @@ -0,0 +1,85 @@ +/** @file + + Copyright 2006 - 2012 Unified EFI, Inc.
+ Copyright (c) 2010 - 2012, Dell Inc. All rights reserved.
+ Copyright (c) 2019,Microchip Technology Inc.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +/*++ + + Module Name: + + Guid.c + + Abstract: + + GUIDs auto-generated for EFI test assertion. + +--*/ + +#include "Efi.h" +#include "Guid.h" + +// **************************************************************************** +// Function +// **************************************************************************** + +EFI_GUID gFirmwareManagementBBTestFunctionAssertionGuid001=EFI_TEST_FIRMWAREMANAGEMENTBBTESTFUNCTION_ASSERTION_001_GUID; + +EFI_GUID gFirmwareManagementBBTestFunctionAssertionGuid002=EFI_TEST_FIRMWAREMANAGEMENTBBTESTFUNCTION_ASSERTION_002_GUID; + +EFI_GUID gFirmwareManagementBBTestFunctionAssertionGuid003=EFI_TEST_FIRMWAREMANAGEMENTBBTESTFUNCTION_ASSERTION_003_GUID; + + +// **************************************************************************** +// Conformance +// **************************************************************************** + +EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid001=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_SUPPORT_001_GUID; + +EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid002=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_SUPPORT_002_GUID; + +EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid003=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_SUPPORT_003_GUID; + +EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid004=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_SUPPORT_004_GUID; + +EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid001=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_001_GUID; + +EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid002=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_002_GUID; + +EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid003=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_003_GUID; + +EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid004=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_004_GUID; + +EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid005=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_005_GUID; + +EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid006=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_006_GUID; + +EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid007=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_007_GUID; + +EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid008=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_008_GUID; + +EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid009=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_009_GUID; + +EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid010=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_010_GUID; + +EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid011=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_011_GUID; + +EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid012=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_012_GUID; + +EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid013=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_013_GUID; + +EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid014=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_014_GUID; + +EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid015=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_015_GUID; + +EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid016=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_016_GUID; + -- 2.20.0.windows.1