From nobody Sat Feb 7 09:46:41 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+59624+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+59624+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1589507501; cv=none; d=zohomail.com; s=zohoarc; b=GcTKZe2vXsWzrXmTz/EtC3/6eqFZzc39AIKStDc7zACUabWKLcnRX6I5ptBfxm/ulC/v4+3deW08jOliMDfmWOgt7FAI/liUospmM7jOJ7j7iwBliSAVDmklh12XF9hEFtfnwey2sg7ttlA2c4bLR4Cf74Wq2emaPqbGEFnq1FI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589507501; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=DBdEt6e+XbKa1mZBYCsb1W7eg1j1ReDXzYh+hX+15Ec=; b=NJCTTVQag2ljLPySzhuN2ULhnBu2NWvvPcSoCiNTxVbyE0k8rrC11THDtmoriz+eQZHG9U7jQwjA356wnpXfclsxVV5vdKqvGBGeM4Fm5gXo+qoXy2uSWE5Zygt/zvLiO+GNfl2yjjO6WOwq6kAJP/gmBUZVuWxJNE4x5uLRt2w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+59624+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1589507501032978.9070465824407; Thu, 14 May 2020 18:51:41 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id wyf2YY1788612xKZIRk7qy5G; Thu, 14 May 2020 18:51:40 -0700 X-Received: from mga07.intel.com (mga07.intel.com []) by mx.groups.io with SMTP id smtpd.web12.5790.1589507494847076587 for ; Thu, 14 May 2020 18:51:39 -0700 IronPort-SDR: ie6ytlGgvD6wOwhFxahvwulU0KIacwYCmX9KmGxvBhZs8LlI9kmFeZ3RdCGZpRiuFRUvM6zAbF e/NutT9P3YGw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2020 18:51:39 -0700 IronPort-SDR: z148y9QTneymjgHq7mupDsZU5sGMNlhxU498pu1V1UbWF4nydbWh4VP+faeAMejqMFE1+Y4uGx iC0iovZfV7Ng== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,393,1583222400"; d="scan'208";a="263038465" X-Received: from shwdeopenpsi174.ccr.corp.intel.com ([10.239.157.39]) by orsmga003.jf.intel.com with ESMTP; 14 May 2020 18:51:37 -0700 From: "Xu, Wei6" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Sean Brogan Subject: [edk2-devel] [PATCH V4 2/5] FmpDevicePkg/Test: Add FmpDependencyLib unit test Date: Fri, 15 May 2020 09:51:20 +0800 Message-Id: <20200515015123.11484-3-wei6.xu@intel.com> In-Reply-To: <20200515015123.11484-1-wei6.xu@intel.com> References: <20200515015123.11484-1-wei6.xu@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,wei6.xu@intel.com X-Gm-Message-State: u0ahEDkLEFhqWgAnHeVirsiUx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1589507500; bh=1pQ9AjbtOrMBdvvctgVV/NkbgtiqUDFnr3RRZTp3zxU=; h=Cc:Date:From:Reply-To:Subject:To; b=BnLPOG2AOCrTn2W5ujzdl+66/tSwou+BPutzueZH8pti/Y89rSo69s38DWWRVU/YjPL nLD/eZbOQldJQ3XUpChKN8N7pgsoTtokeLM5XlygOP8qVwGIzxSnmuVw1in1ODW8fBLA/ w8DVV4x8yweEHhSr9vVydF4Z5PZXlyJ5jRE= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2696 * Add unit tests for EvaluateDependency API in FmpDependencyLib. * Add Test/FmpDeviceHostPkgTest.dsc to build host based unit test. * Update FmpDevicePkg.dsc to build target based unit test. * Update FmpDevicePkg.ci.yaml to build and run host based test. Cc: Michael D Kinney Cc: Liming Gao Cc: Sean Brogan Signed-off-by: Wei6 Xu Reviewed-by: Sean Brogan --- FmpDevicePkg/FmpDevicePkg.ci.yaml | 10 + FmpDevicePkg/FmpDevicePkg.dsc | 7 + FmpDevicePkg/Test/FmpDeviceHostPkgTest.dsc | 28 +++ .../FmpDependencyLib/EvaluateDependencyUnitTest.c | 270 +++++++++++++++++= ++++ .../FmpDependencyLibUnitTestsHost.inf | 34 +++ .../FmpDependencyLibUnitTestsUefi.inf | 35 +++ 6 files changed, 384 insertions(+) create mode 100644 FmpDevicePkg/Test/FmpDeviceHostPkgTest.dsc create mode 100644 FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/Eva= luateDependencyUnitTest.c create mode 100644 FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/Fmp= DependencyLibUnitTestsHost.inf create mode 100644 FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/Fmp= DependencyLibUnitTestsUefi.inf diff --git a/FmpDevicePkg/FmpDevicePkg.ci.yaml b/FmpDevicePkg/FmpDevicePkg.= ci.yaml index c17b355d42..74a0aefe8e 100644 --- a/FmpDevicePkg/FmpDevicePkg.ci.yaml +++ b/FmpDevicePkg/FmpDevicePkg.ci.yaml @@ -6,26 +6,36 @@ ## { "CompilerPlugin": { "DscPath": "FmpDevicePkg.dsc" }, + "HostUnitTestCompilerPlugin": { + "DscPath": "Test/FmpDeviceHostPkgTest.dsc" + }, "CharEncodingCheck": { "IgnoreFiles": [] }, "DependencyCheck": { "AcceptableDependencies": [ "MdePkg/MdePkg.dec", "MdeModulePkg/MdeModulePkg.dec", "FmpDevicePkg/FmpDevicePkg.dec", "CryptoPkg/CryptoPkg.dec" ], + "AcceptableDependencies-HOST_APPLICATION":[ + "UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec" + ], "IgnoreInf": [] }, "DscCompleteCheck": { "DscPath": "FmpDevicePkg.dsc", "IgnoreInf": [] }, + "HostUnitTestDscCompleteCheck": { + "IgnoreInf": [], + "DscPath": "Test/FmpDeviceHostPkgTest.dsc" + }, "GuidCheck": { "IgnoreGuidName": [], "IgnoreGuidValue": [], "IgnoreFoldersAndFiles": [] }, diff --git a/FmpDevicePkg/FmpDevicePkg.dsc b/FmpDevicePkg/FmpDevicePkg.dsc index dfb3c1a141..49c6ff3a30 100644 --- a/FmpDevicePkg/FmpDevicePkg.dsc +++ b/FmpDevicePkg/FmpDevicePkg.dsc @@ -34,10 +34,12 @@ # TRUE - Build FmpDxe module for with storage access enabled # FALSE - Build FmpDxe module for with storage access disabled # DEFINE DEVICE_FMP_STORAGE_ACCESS_ENABLE =3D TRUE =20 +!include UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.inc + [LibraryClasses] UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntry= Point.inf UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBoo= tServicesTableLib.inf UefiLib|MdePkg/Library/UefiLib/UefiLib.inf UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/U= efiRuntimeServicesTableLib.inf @@ -161,7 +163,12 @@ # in a system firmware image. # CapsuleUpdatePolicyLib|FmpDevicePkg/Library/CapsuleUpdatePolicyLibNu= ll/CapsuleUpdatePolicyLibNull.inf } =20 + # + # Add UEFI Target Based Unit Tests + # + FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/FmpDependencyLibUnit= TestsUefi.inf + [BuildOptions] *_*_*_CC_FLAGS =3D -D DISABLE_NEW_DEPRECATED_INTERFACES diff --git a/FmpDevicePkg/Test/FmpDeviceHostPkgTest.dsc b/FmpDevicePkg/Test= /FmpDeviceHostPkgTest.dsc new file mode 100644 index 0000000000..83574399be --- /dev/null +++ b/FmpDevicePkg/Test/FmpDeviceHostPkgTest.dsc @@ -0,0 +1,28 @@ +## @file +# FmpDevicePkg DSC file used to build host-based unit tests. +# +# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + PLATFORM_NAME =3D FmpDevicePkgHostTest + PLATFORM_GUID =3D 80B12646-9A30-4516-AABF-DE1919B573E3 + PLATFORM_VERSION =3D 0.1 + DSC_SPECIFICATION =3D 0x00010005 + OUTPUT_DIRECTORY =3D Build/FmpDevicePkg/HostTest + SUPPORTED_ARCHITECTURES =3D IA32|X64 + BUILD_TARGETS =3D NOOPT + SKUID_IDENTIFIER =3D DEFAULT + +!include UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc + +[LibraryClasses] + FmpDependencyLib|FmpDevicePkg/Library/FmpDependencyLib/FmpDependencyLib.= inf + +[Components] + # + # Build HOST_APPLICATION that tests the FmpDependencyLib + # + FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/FmpDependencyLibUnit= TestsHost.inf diff --git a/FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/EvaluateDe= pendencyUnitTest.c b/FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/Ev= aluateDependencyUnitTest.c new file mode 100644 index 0000000000..f8ccdd906f --- /dev/null +++ b/FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/EvaluateDependenc= yUnitTest.c @@ -0,0 +1,270 @@ +/** @file + Unit tests of EvaluateDependency API in FmpDependencyLib. + + Copyright (c) 2020, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include + +#define UNIT_TEST_APP_NAME "FmpDependencyLib Unit Test Application" +#define UNIT_TEST_APP_VERSION "1.0" + +typedef struct { + UINT8 *Dependencies; + UINTN DependenciesSize; + BOOLEAN ExpectedResult; +} BASIC_TEST_CONTEXT; + +// +// Image Type ID of FMP device A +// +#define IMAGE_TYPE_ID_1 { 0x97144DFA, 0xEB8E, 0xD14D, {0x8B, 0x4D, 0x39,= 0x88, 0x24, 0x96, 0x56, 0x42}} + +// +// Image Type ID of FMP device B +// +#define IMAGE_TYPE_ID_2 { 0xA42A7370, 0x433A, 0x684D, {0x9A, 0xA1, 0xDE,= 0x62, 0x23, 0x30, 0x6C, 0xF3}} + +// +// Device A's version is 0x00000002 +// Device B's version is 0x00000003 +// +static FMP_DEPEX_CHECK_VERSION_DATA mFmpVersions[] =3D { + {IMAGE_TYPE_ID_1, 0x00000002}, + {IMAGE_TYPE_ID_2, 0x00000003} +}; + +// Valid Dependency Expression 1: (Version(A) > 0x00000001) && (Version(B)= >=3D 0x00000003) +static UINT8 mExpression1[] =3D { + EFI_FMP_DEP_PUSH_VERSION, 0x01, 0x00, 0x00, 0x00, + EFI_FMP_DEP_PUSH_GUID, 0xFA, 0x4D, 0x14, 0x97, 0x8E, 0xEB, 0x4D, 0xD1, 0= x8B, 0x4D, 0x39, 0x88, 0x24, 0x96, 0x56, 0x42, + EFI_FMP_DEP_GT, + EFI_FMP_DEP_PUSH_VERSION, 0x03, 0x00, 0x00, 0x00, + EFI_FMP_DEP_PUSH_GUID, 0x70, 0x73, 0x2A, 0xA4, 0x3A, 0x43, 0x4D, 0x68, 0= x9A, 0xA1, 0xDE, 0x62, 0x23, 0x30, 0x6C, 0xF3, + EFI_FMP_DEP_GTE, + EFI_FMP_DEP_AND, + EFI_FMP_DEP_END +}; + +// Valid Dependency Expression 2: (Version(A) < 0x00000002) || (Version(B)= <=3D 0x00000003) +static UINT8 mExpression2[] =3D { + EFI_FMP_DEP_PUSH_VERSION, 0x02, 0x00, 0x00, 0x00, + EFI_FMP_DEP_PUSH_GUID, 0xFA, 0x4D, 0x14, 0x97, 0x8E, 0xEB, 0x4D, 0xD1, 0= x8B, 0x4D, 0x39, 0x88, 0x24, 0x96, 0x56, 0x42, + EFI_FMP_DEP_LT, + EFI_FMP_DEP_PUSH_VERSION, 0x03, 0x00, 0x00, 0x00, + EFI_FMP_DEP_PUSH_GUID, 0x70, 0x73, 0x2A, 0xA4, 0x3A, 0x43, 0x4D, 0x68, 0= x9A, 0xA1, 0xDE, 0x62, 0x23, 0x30, 0x6C, 0xF3, + EFI_FMP_DEP_LTE, + EFI_FMP_DEP_OR, + EFI_FMP_DEP_END +}; + +// Valid Dependency Expression 3: !(Version(A) =3D=3D 0x0000002) +static UINT8 mExpression3[] =3D { + EFI_FMP_DEP_PUSH_VERSION, 0x02, 0x00, 0x00, 0x00, + EFI_FMP_DEP_PUSH_GUID, 0xFA, 0x4D, 0x14, 0x97, 0x8E, 0xEB, 0x4D, 0xD1, 0= x8B, 0x4D, 0x39, 0x88, 0x24, 0x96, 0x56, 0x42, + EFI_FMP_DEP_EQ, + EFI_FMP_DEP_NOT, + EFI_FMP_DEP_END +}; + +// Valid Dependency Expression 4: "Test" TRUE && FALSE +static UINT8 mExpression4[] =3D { + EFI_FMP_DEP_VERSION_STR, 'T', 'e', 's', 't', '\0', + EFI_FMP_DEP_TRUE, + EFI_FMP_DEP_FALSE, + EFI_FMP_DEP_AND, + EFI_FMP_DEP_END +}; + +// Invalid Dependency Expression 1: Invalid Op-code +static UINT8 mExpression5[] =3D {EFI_FMP_DEP_TRUE, 0xAA, EFI_FMP_DEP_END}; + +// Invalid Dependency Expression 2: String doesn't end with '\0' +static UINT8 mExpression6[] =3D {EFI_FMP_DEP_VERSION_STR, 'T', 'e', 's', '= t', EFI_FMP_DEP_TRUE, EFI_FMP_DEP_END}; + +// Invalid Dependency Expression 3: GUID is in invalid size +static UINT8 mExpression7[] =3D { + EFI_FMP_DEP_PUSH_VERSION, 0x02, 0x00, 0x00, 0x00, + EFI_FMP_DEP_PUSH_GUID, 0xAA, 0xBB, 0xCC, 0xDD, + EFI_FMP_DEP_GTE, + EFI_FMP_DEP_END +}; + +// Invalid Dependency Expression 4: Version is in invalid size +static UINT8 mExpression8[] =3D { + EFI_FMP_DEP_PUSH_VERSION, 0x02, 0x00, + EFI_FMP_DEP_PUSH_GUID, 0xDA, 0xCB, 0x25, 0xAC, 0x9E, 0xCD, 0x5E, 0xE2, 0= x9C, 0x5E, 0x4A, 0x99, 0x35, 0xA7, 0x67, 0x53, + EFI_FMP_DEP_GTE, + EFI_FMP_DEP_END +}; + +// Invalid Dependency Expression 5: Operand and operator mismatch +static UINT8 mExpression9[] =3D {EFI_FMP_DEP_TRUE, EFI_FMP_DEP_FALSE, EFI_= FMP_DEP_GTE, EFI_FMP_DEP_END}; + +// Invalid Dependency Expression 6: GUID is NOT FOUND +static UINT8 mExpression10[] =3D { + EFI_FMP_DEP_PUSH_VERSION, 0x02, 0x00, 0x00, 0x00, + EFI_FMP_DEP_PUSH_GUID, 0xDA, 0xCB, 0x25, 0xAC, 0x9E, 0xCD, 0x5E, 0xE2, 0= x9C, 0x5E, 0x4A, 0x99, 0x35, 0xA7, 0x67, 0x53, + EFI_FMP_DEP_GT, + EFI_FMP_DEP_END +}; + +// Invalid Dependency Expression 7: Stack underflow +static UINT8 mExpression11[] =3D { + EFI_FMP_DEP_PUSH_VERSION, 0x02, 0x00, 0x00, 0x00, + EFI_FMP_DEP_GT, + EFI_FMP_DEP_END +}; + +// ------------------------------------------------Test Depex------Depex S= ize----------------Expected Result +static BASIC_TEST_CONTEXT mBasicTestTrue1 =3D {mExpression1, sizeo= f(mExpression1), TRUE}; +static BASIC_TEST_CONTEXT mBasicTestTrue2 =3D {mExpression2, sizeo= f(mExpression2), TRUE}; +static BASIC_TEST_CONTEXT mBasicTestFalse1 =3D {mExpression3, sizeo= f(mExpression3), FALSE}; +static BASIC_TEST_CONTEXT mBasicTestFalse2 =3D {mExpression4, sizeo= f(mExpression4), FALSE}; +static BASIC_TEST_CONTEXT mBasicTestInvalid1 =3D {mExpression1, sizeo= f(mExpression1) - 1, FALSE}; +static BASIC_TEST_CONTEXT mBasicTestInvalid2 =3D {mExpression5, sizeo= f(mExpression5), FALSE}; +static BASIC_TEST_CONTEXT mBasicTestInvalid3 =3D {mExpression6, sizeo= f(mExpression6), FALSE}; +static BASIC_TEST_CONTEXT mBasicTestInvalid4 =3D {mExpression7, sizeo= f(mExpression7), FALSE}; +static BASIC_TEST_CONTEXT mBasicTestInvalid5 =3D {mExpression8, sizeo= f(mExpression8), FALSE}; +static BASIC_TEST_CONTEXT mBasicTestInvalid6 =3D {mExpression9, sizeo= f(mExpression9), FALSE}; +static BASIC_TEST_CONTEXT mBasicTestInvalid7 =3D {mExpression10, sizeo= f(mExpression10), FALSE}; +static BASIC_TEST_CONTEXT mBasicTestInvalid8 =3D {mExpression11, sizeo= f(mExpression11), FALSE}; + +/** + Unit test for EvaluateDependency() API of the FmpDependencyLib. + + @param[in] Context [Optional] An optional parameter that enables: + 1) test-case reuse with varied parameters and + 2) test-case re-entry for Target tests that need a + reboot. This parameter is a VOID* and it is the + responsibility of the test author to ensure that = the + contents are well understood by all test cases th= at may + consume it. + + @retval UNIT_TEST_PASSED The Unit test has completed and th= e test + case was successful. + @retval UNIT_TEST_ERROR_TEST_FAILED A test case assertion has failed. +**/ +STATIC +UNIT_TEST_STATUS +EFIAPI +EvaluateDependencyTest ( + IN UNIT_TEST_CONTEXT Context + ) +{ + BASIC_TEST_CONTEXT *TestContext; + BOOLEAN EvaluationResult; + + TestContext =3D (BASIC_TEST_CONTEXT *)Context; + + EvaluationResult =3D EvaluateDependency ( + (EFI_FIRMWARE_IMAGE_DEP *)TestContext->Dependencies, + TestContext->DependenciesSize, + mFmpVersions, + sizeof(mFmpVersions)/sizeof(FMP_DEPEX_CHECK_VERSION= _DATA) + ); + + UT_ASSERT_EQUAL (EvaluationResult, TestContext->ExpectedResult); + + return UNIT_TEST_PASSED; +} + +/** + Initialize the unit test framework, suite, and unit tests for the + EvaluateDependency API in FmpDependencyLib and run the unit tests. + + @retval EFI_SUCCESS All test cases were dispatched. + @retval EFI_OUT_OF_RESOURCES There are not enough resources available = to + initialize the unit tests. +**/ +STATIC +EFI_STATUS +EFIAPI +UnitTestingEntry ( + VOID + ) +{ + EFI_STATUS Status; + UNIT_TEST_FRAMEWORK_HANDLE Fw; + UNIT_TEST_SUITE_HANDLE DepexEvalTests; + + Fw =3D NULL; + + DEBUG ((DEBUG_INFO, "%a v%a\n", UNIT_TEST_APP_NAME, UNIT_TEST_APP_VERSIO= N)); + + // + // Start setting up the test framework for running the tests. + // + Status =3D InitUnitTestFramework (&Fw, UNIT_TEST_APP_NAME, gEfiCallerBas= eName, UNIT_TEST_APP_VERSION); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed in InitUnitTestFramework. Status =3D %r= \n", Status)); + goto EXIT; + } + + // + // Populate the Unit Test Suite. + // + Status =3D CreateUnitTestSuite (&DepexEvalTests, Fw, "Evaluate Dependenc= y Test", "FmpDependencyLib.EvaluateDependency", NULL, NULL); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed in CreateUnitTestSuite for DepexEvalTests= \n")); + goto EXIT; + } + + AddTestCase (DepexEvalTests, "Evaluate to True - 1", "Test1", EvaluateDe= pendencyTest, NULL, NULL, &mBasicTestTrue1); + AddTestCase (DepexEvalTests, "Evaluate to True - 2", "Test2", EvaluateDe= pendencyTest, NULL, NULL, &mBasicTestTrue2); + AddTestCase (DepexEvalTests, "Evaluate to False - 1", "Test3", EvaluateD= ependencyTest, NULL, NULL, &mBasicTestFalse1); + AddTestCase (DepexEvalTests, "Evaluate to False - 2", "Test4", EvaluateD= ependencyTest, NULL, NULL, &mBasicTestFalse2); + AddTestCase (DepexEvalTests, "Error: Non-END-terminated expression", "Te= st5", EvaluateDependencyTest, NULL, NULL, &mBasicTestInvalid1); + AddTestCase (DepexEvalTests, "Error: UNKNOWN Op-Code", "Test6", Evaluate= DependencyTest, NULL, NULL, &mBasicTestInvalid2); + AddTestCase (DepexEvalTests, "Error: Non-Null-terminated string", "Test7= ", EvaluateDependencyTest, NULL, NULL, &mBasicTestInvalid3); + AddTestCase (DepexEvalTests, "Error: GUID size is not 16", "Test8", Eval= uateDependencyTest, NULL, NULL, &mBasicTestInvalid4); + AddTestCase (DepexEvalTests, "Error: Version size is not 4", "Test9", Ev= aluateDependencyTest, NULL, NULL, &mBasicTestInvalid5); + AddTestCase (DepexEvalTests, "Error: Operand and operator mismatch", "Te= st10", EvaluateDependencyTest, NULL, NULL, &mBasicTestInvalid6); + AddTestCase (DepexEvalTests, "Error: GUID is NOT FOUND", "Test11", Evalu= ateDependencyTest, NULL, NULL, &mBasicTestInvalid7); + AddTestCase (DepexEvalTests, "Error: Stack Underflow", "Test12", Evaluat= eDependencyTest, NULL, NULL, &mBasicTestInvalid8); + + // + // Execute the tests. + // + Status =3D RunAllTestSuites (Fw); + +EXIT: + if (Fw) { + FreeUnitTestFramework (Fw); + } + + return Status; +} + +/** + Standard UEFI entry point for target based unit test execution from UEFI= Shell. +**/ +EFI_STATUS +EFIAPI +FmpDependencyLibUnitTestAppEntry ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + return UnitTestingEntry (); +} + +/** + Standard POSIX C entry point for host based unit test execution. +**/ +int +main ( + int argc, + char *argv[] + ) +{ + return UnitTestingEntry (); +} diff --git a/FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/FmpDepende= ncyLibUnitTestsHost.inf b/FmpDevicePkg/Test/UnitTest/Library/FmpDependencyL= ib/FmpDependencyLibUnitTestsHost.inf new file mode 100644 index 0000000000..93ae635da5 --- /dev/null +++ b/FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/FmpDependencyLibU= nitTestsHost.inf @@ -0,0 +1,34 @@ +## @file +# Unit tests of EvaluateDependency API in FmpDependencyLib that are run fr= om host +# environment. +# +# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D FmpDependencyLibUnitTestsHost + FILE_GUID =3D CE32C647-CAD7-4099-9463-653B932C1691 + MODULE_TYPE =3D HOST_APPLICATION + VERSION_STRING =3D 1.0 + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources] + EvaluateDependencyUnitTest.c + +[Packages] + MdePkg/MdePkg.dec + FmpDevicePkg/FmpDevicePkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + UnitTestLib + FmpDependencyLib diff --git a/FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/FmpDepende= ncyLibUnitTestsUefi.inf b/FmpDevicePkg/Test/UnitTest/Library/FmpDependencyL= ib/FmpDependencyLibUnitTestsUefi.inf new file mode 100644 index 0000000000..a2ca369171 --- /dev/null +++ b/FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/FmpDependencyLibU= nitTestsUefi.inf @@ -0,0 +1,35 @@ +## @file +# Unit tests of EvaluateDependency API in FmpDependencyLib that are run fr= om UEFI Shell. +# +# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D FmpDependencyLibUnitTestsUefi + FILE_GUID =3D 8FF4C129-C2EF-445D-8658-9A342A1FCC4D + MODULE_TYPE =3D UEFI_APPLICATION + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D FmpDependencyLibUnitTestAppEntry + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources] + EvaluateDependencyUnitTest.c + +[Packages] + MdePkg/MdePkg.dec + FmpDevicePkg/FmpDevicePkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + UefiApplicationEntryPoint + DebugLib + UnitTestLib + FmpDependencyLib --=20 2.16.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#59624): https://edk2.groups.io/g/devel/message/59624 Mute This Topic: https://groups.io/mt/74219542/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-