From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.108]) by mx.groups.io with SMTP id smtpd.web10.215.1594786010243402674 for ; Tue, 14 Jul 2020 21:06:50 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=i2nyyGcP; spf=pass (domain: microsoft.com, ip: 40.107.243.108, mailfrom: bret.barkelew@microsoft.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Az+g6db9Mf5RBzHd1gVnan4i/DvCPExdkT4cdIfp0LaP24Rgf+HhN9ltjETnoWvyVHWMBdzGOZKxIQ4UQmy6GDy0dApgKNIJDYRPa8FdyQFab+d4FTY/dX/gFIou9ijiysBLdXQ3eT3o89kSaZGdRybhsKX71OTBnlQMPI/LXLDtqUIiAMg1rYmi5vC72M6d6v95E9PiAOwh8WsxQ6OKvgopipsimrlIf9omxPHMJ2BUHxxGWFULwFiom87VHWV3MagIFiuz8zTPtWRjIpXzzenNxPdMzDnXc4fon+50FK7S1Z8lC1gAiJp+K0VOjY8MOOVfrmOYn6fxYpuIbQ27xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dKuKiNuGI7j7BA6MMTaQpxcbPHQ4+pS82zpDVSyurFw=; b=i+4FzrkPFjnbCP/aRoDP0Hwpk7kVuqOdAmYVAnov6C5RPl6CHy031Xna6PAevDUYCSM0Sd4Mv9B42F5faNykWq4B7aKJAJeNPS9x5cLV709WbK6YiADZFr8TcbdXNOBa0G0QBOl/bmWiyNva9hCdgaJP1OQBPD/nB0wCiEgyud/cvZ2bC9JNEwo4hSLBWmG28lxEoGUXRL1Kujv3H+8LT9PuoYZlyezbXyaEUv8m1wtAMdOgop44CWcPNa02xJHvkTEAIVVu54iNitgQ0FVVB0uwaeF75IpcIMmsGqs4WtACZhvw+d2Ka9q+viX5xckkmWKxlfbIjd2bpZ9sljUnRA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dKuKiNuGI7j7BA6MMTaQpxcbPHQ4+pS82zpDVSyurFw=; b=i2nyyGcPVOVwigdoM4rUCEWe7doE6/i8bv7/uPMARJoEzO7RcsLO+y+/BoKL3WoB5UdSvPUbdYAiHNNVwSfc5keXshuibX9L4q6VvYdBEeW1vACNiFBx2m9UZgRW2b5NFsAegae4ckxmZCd4aT6rT+x6g/r5WtX3aGQm4AAmVFU= Received: from CY4PR21MB0743.namprd21.prod.outlook.com (2603:10b6:903:b2::9) by CY4PR21MB0504.namprd21.prod.outlook.com (2603:10b6:903:dc::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.7; Wed, 15 Jul 2020 04:06:47 +0000 Received: from CY4PR21MB0743.namprd21.prod.outlook.com ([fe80::f112:82fb:d4fd:f7dd]) by CY4PR21MB0743.namprd21.prod.outlook.com ([fe80::f112:82fb:d4fd:f7dd%10]) with mapi id 15.20.3216.008; Wed, 15 Jul 2020 04:06:47 +0000 From: "Bret Barkelew" To: "devel@edk2.groups.io" , "Kinney, Michael D" , liming.gao CC: Sean Brogan , "Yao, Jiewen" Subject: Re: [edk2-devel] [Patch v3 12/16] UnitTestFrameworkPkg/UnitTestLib: Add checks for ASSERT() Thread-Topic: [edk2-devel] [Patch v3 12/16] UnitTestFrameworkPkg/UnitTestLib: Add checks for ASSERT() Thread-Index: AQHWWavtPEhjs+Vb6UGdUhFM2Wd+3qkHQ50AgADDvL8= Date: Wed, 15 Jul 2020 04:06:47 +0000 Message-ID: References: <20200711020904.24116-1-michael.d.kinney@intel.com> <20200711020904.24116-13-michael.d.kinney@intel.com> , In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2020-07-15T04:06:41.8607946Z;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Privileged authentication-results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=microsoft.com; x-originating-ip: [174.21.66.92] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 1db50efa-caef-475e-e831-08d828747e59 x-ms-traffictypediagnostic: CY4PR21MB0504: x-ms-exchange-transport-forked: True x-ld-processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 8EWlXLewCTRkFwEl0s5b8Fhug628ddfgqUVX2ecDMm7FtaaHw+lSHZVOQ03t1eD1WMZr1szLAODJCFjsOuSR4bFHNchU9M/trPslT/jZXreoojezsFocGScjwA++gMUyiQ/c0bnPNwHjfn8rmcN1yx3ZwvLJSJqhs6nCioAKqCwASWU1T6Du5o+tfDD2MjcBOzkdzm9NMRuA/kUqZ0oCdjR6NnX5vRkWT+gbOfc+f13fAndYFdTFjtkJ9sysUquS4nuN75FYpGNRZMk1+Pi1TCxON4sAUk0anbDPkNK9NfNMOUm56Gp3bWzTufr4uBGe+HHTbWK3ddsSI9qKym9OUAdc37QTbAKGK9PhiAK+ySRXIz8VGFXM5fIga5ICNSrTce0UzAiaFT6o6fOI63s9iA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR21MB0743.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(346002)(136003)(376002)(396003)(366004)(39860400002)(186003)(4326008)(91956017)(316002)(66476007)(82950400001)(6506007)(30864003)(82960400001)(76116006)(52536014)(66556008)(2906002)(64756008)(110136005)(54906003)(66946007)(8990500004)(166002)(55016002)(53546011)(9686003)(7696005)(86362001)(8676002)(5660300002)(966005)(26005)(83380400001)(10290500003)(71200400001)(478600001)(66446008)(33656002)(8936002)(559001)(579004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: QKcw7E3mF9DZSp5JivL2YXEOIKAUxja4l+ABjPMFMayydIiR2n0GwD1HxW/iWyQp1mKWZiwbg81PQQREfdJ+Vv8wdhejueHaAClK+Hwy0gbQ2MCUQY1t7PXPBJ72ahP+tqjr85LnodT6Mcvg0rIPrdCw8LxLZ76bwMUf68jKHbiTqoHCmu2eTwtW9PVHifouzLVxEUF7f4YYxHqjJDvvVtzFKex5Y9VznaSMPk5lrWi06p7jZDxIXhNgPwZz9XcOKnRNVc7F+5b9+m4B16a/tKqRN/yLhQwk2GfqTpyPKnjbQAdo97Ub3z8cJwJlWAiypy4qWvhVTLVh4Zg+tm4Sd2TIgqp/1zbltx/18pdxiPRhngsLa2aErCvVoDvk8b8GfxeKNWbsgMxCW25sSQGm/m+Ufc3X94XVbGxu+ii1b+mzvBztHzHdKweOq3sWOUz6LdbovILVnOL0WZyarppA8nG3ocPdG8oIotaFvT84cc8= MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CY4PR21MB0743.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1db50efa-caef-475e-e831-08d828747e59 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jul 2020 04:06:47.2814 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: xOzuq4BC8Q1MMf2+0jbiwCJbYfp/9Z1tGS8xicK+ng3AuEauomRJWITg8JhFOULPePOaOZv/NrdRSW4vX0SQtQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR21MB0504 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_CY4PR21MB07435EFDDF21A2668654F201EF7E0CY4PR21MB0743namp_" --_000_CY4PR21MB07435EFDDF21A2668654F201EF7E0CY4PR21MB0743namp_ Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable Reviewed-by: Bret Barkelew - Bret From: Michael D Kinney via groups.io Sent: Tuesday, July 14, 2020 9:26 AM To: liming.gao; devel@edk2.groups.io; Kinney, Michael D Cc: Sean Brogan; Bret Barkelew; Yao, Jiewen Subject: [EXTERNAL] Re: [edk2-devel] [Patch v3 12/16] UnitTestFrameworkPkg= /UnitTestLib: Add checks for ASSERT() Liming, I will fix that one issue in the INF comment block when I push the commits. Thanks, Mike > -----Original Message----- > From: Gao, Liming > Sent: Monday, July 13, 2020 11:57 PM > To: devel@edk2.groups.io; Kinney, Michael D > > Cc: Sean Brogan ; Bret > Barkelew ; Yao, Jiewen > > Subject: RE: [edk2-devel] [Patch v3 12/16] > UnitTestFrameworkPkg/UnitTestLib: Add checks for > ASSERT() > > Mike: > > -----Original Message----- > From: devel@edk2.groups.io On > Behalf Of Michael D Kinney > Sent: 2020=1B$BG/=1B(B7=1B$B7n=1B(B11=1B$BF|=1B(B 10:09 > To: devel@edk2.groups.io > Cc: Sean Brogan ; Bret > Barkelew ; Yao, Jiewen > > Subject: [edk2-devel] [Patch v3 12/16] > UnitTestFrameworkPkg/UnitTestLib: Add checks for > ASSERT() > > REF: REF: > https://nam06.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fbugz= illa.tianocore.org%2Fshow_bug.cgi%3Fid%3D2801&data=3D02%7C01%7Cbret.bar= kelew%40microsoft.com%7C3b85c7dd72af42d6295508d82812a84a%7C72f988bf86f141af= 91ab2d7cd011db47%7C1%7C0%7C637303407889843281&sdata=3D5fA35uRcosAAp0%2B= 1RVFoCLsGzAaqvc92dmxSVrwDJsY%3D&reserved=3D0 > > Add UnitTestDebugAssertLib that provides the > UnitTestDebugAssert() service and the > gUnitTestExpectAssertFailureJumpBuffer global variable. > This NULL library is linked against all host and target > unit test builds. This guarantees that the > UnitTestDebugAssert() service is available to link > against all libraries and modules that use the DebugLib > class. > > EDKII_UNIT_TEST_FRAMEWORK_ENABLED must always be defined > when building unit tests so the behavior of the DebugLib > ASSERT() macros can be adjusted to allow the unit test > framework to catch an ASSERT() if it is triggered by a > function under test. > > Cc: Sean Brogan > Cc: Bret Barkelew > Cc: Jiewen Yao > Signed-off-by: Michael D Kinney > > --- > .../UnitTestDebugAssertLib.c | 49 > +++++ > .../UnitTestDebugAssertLib.inf | 31 +++ > .../UnitTestDebugAssertLib.uni | 11 + > .../Library/UnitTestLib/Assert.c | 203 > ++++++++++++------ > .../Library/UnitTestLib/AssertCmocka.c | 68 > ++++++ > .../Library/UnitTestLib/RunTests.c | 23 +- > .../UnitTestResultReportLib.c | 3 +- > .../PrivateInclude/UnitTestFrameworkTypes.h | 1 + > .../Test/UnitTestFrameworkPkgHostTest.dsc | 2 +- > UnitTestFrameworkPkg/UnitTestFrameworkPkg.dsc | 1 + > .../UnitTestFrameworkPkgTarget.dsc.inc | 6 +- > 11 files changed, 328 insertions(+), 70 deletions(-) > create mode 100644 > UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Unit > TestDebugAssertLib.c > create mode 100644 > UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Unit > TestDebugAssertLib.inf > create mode 100644 > UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Unit > TestDebugAssertLib.uni > > diff --git > a/UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Un > itTestDebugAssertLib.c > b/UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Un > itTestDebugAssertLib.c > new file mode 100644 > index 0000000000..0a4001e182 > --- /dev/null > +++ > b/UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Un > itTestDebugA > +++ ssertLib.c > @@ -0,0 +1,49 @@ > +/** @file > + Unit Test Debug Assert Library > + > + Copyright (c) 2020, Intel Corporation. All rights > reserved.
> + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#include > +#include > + > +/// > +/// Point to jump buffer used with SetJump()/LongJump() > to test if a > +function /// under test generates an expected ASSERT() > condition. > +/// > +BASE_LIBRARY_JUMP_BUFFER > *gUnitTestExpectAssertFailureJumpBuffer =3D > +NULL; > + > +/** > + Unit test library replacement for DebugAssert() in > DebugLib. > + > + If FileName is NULL, then a string of > "(NULL) Filename" is printed. > + If Description is NULL, then a string > of "(NULL) Description" is printed. > + > + @param FileName The pointer to the name of the > source file that generated the assert condition. > + @param LineNumber The line number in the source > file that generated the assert condition > + @param Description The pointer to the description > of the assert condition. > + > +**/ > +VOID > +EFIAPI > +UnitTestDebugAssert ( > + IN CONST CHAR8 *FileName, > + IN UINTN LineNumber, > + IN CONST CHAR8 *Description > + ) > +{ > + CHAR8 Message[256]; > + > + if (gUnitTestExpectAssertFailureJumpBuffer !=3D NULL) { > + UT_LOG_INFO ("Detected expected ASSERT: %a(%d): > %a\n", FileName, LineNumber, Description); > + LongJump (gUnitTestExpectAssertFailureJumpBuffer, > 1); > + } else { > + AsciiStrCpyS (Message, sizeof(Message), "Detected > unexpected ASSERT("); > + AsciiStrCatS (Message, sizeof(Message), > Description); > + AsciiStrCatS (Message, sizeof(Message), ")"); > + UnitTestAssertTrue (FALSE, "", LineNumber, > FileName, Message); > + } > +} > diff --git > a/UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Un > itTestDebugAssertLib.inf > b/UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Un > itTestDebugAssertLib.inf > new file mode 100644 > index 0000000000..e6ccab0dd9 > --- /dev/null > +++ > b/UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Un > itTestDebugA > +++ ssertLib.inf > @@ -0,0 +1,31 @@ > +## @file > +# Unit Test Debug Assert Library > +# > +# Copyright (c) 2020, Intel Corporation. All rights > reserved.
# > +SPDX-License-Identifier: BSD-2-Clause-Patent # ## > + > +[Defines] > + INF_VERSION =3D 0x00010005 > + BASE_NAME =3D > UnitTestDebugAssertLib > + MODULE_UNI_FILE =3D > UnitTestDebugAssertLib.uni > + FILE_GUID =3D 9D53AD0D-5416-451F- > A5BF-E5420051A99B > + MODULE_TYPE =3D BASE > + VERSION_STRING =3D 1.0 > + LIBRARY_CLASS =3D NULL > + > +# > +# VALID_ARCHITECTURES =3D ARM AARCH64 > +# > > Seemly, this comment is incorrect. Valid arch should > include IA32 and X64. Right? > > Thanks > Liming > > + > +[Sources] > + UnitTestDebugAssertLib.c > + > +[Packages] > + MdePkg/MdePkg.dec > + UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec > + > +[LibraryClasses] > + BaseLib > + UnitTestLib > diff --git > a/UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Un > itTestDebugAssertLib.uni > b/UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Un > itTestDebugAssertLib.uni > new file mode 100644 > index 0000000000..9b794aa205 > --- /dev/null > +++ > b/UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Un > itTestDebugA > +++ ssertLib.uni > @@ -0,0 +1,11 @@ > +// /** @file > +// Unit Test Debug Assert Library > +// > +// Copyright (c) 2020, Intel Corporation. All rights > reserved.
// > +SPDX-License-Identifier: BSD-2-Clause-Patent // // **/ > + > +#string STR_MODULE_ABSTRACT #language en-US > "Unit Test Debug Assert Library" > + > +#string STR_MODULE_DESCRIPTION #language en-US > "Unit Test Debug Assert Library" > diff --git > a/UnitTestFrameworkPkg/Library/UnitTestLib/Assert.c > b/UnitTestFrameworkPkg/Library/UnitTestLib/Assert.c > index 8a131fab2b..3669d63701 100644 > --- a/UnitTestFrameworkPkg/Library/UnitTestLib/Assert.c > +++ b/UnitTestFrameworkPkg/Library/UnitTestLib/Assert.c > @@ -13,6 +13,8 @@ > #include > #include > > +extern BASE_LIBRARY_JUMP_BUFFER gUnitTestJumpBuffer; > + > STATIC > EFI_STATUS > AddUnitTestFailure ( > @@ -71,7 +73,7 @@ UnitTestLogFailure ( > FailureType > ); > > - return; > + LongJump (&gUnitTestJumpBuffer, 1); > } > > /** > @@ -103,6 +105,12 @@ UnitTestAssertTrue ( > ) > { > if (!Expression) { > + UT_LOG_ERROR ( > + "[ASSERT FAIL] %a:%d: Expression (%a) is not > TRUE!\n", > + FileName, > + LineNumber, > + Description > + ); > UnitTestLogFailure ( > FAILURETYPE_ASSERTTRUE, > "%a:%d: Expression (%a) is not TRUE!\n", @@ - > 110,12 +118,6 @@ UnitTestAssertTrue ( > LineNumber, > Description > ); > - UT_LOG_ERROR ( > - "[ASSERT FAIL] %a:%d: Expression (%a) is not > TRUE!\n", > - FileName, > - LineNumber, > - Description > - ); > } > return Expression; > } > @@ -149,6 +151,12 @@ UnitTestAssertFalse ( > ) > { > if (Expression) { > + UT_LOG_ERROR ( > + "[ASSERT FAIL] %a:%d: Expression (%a) is not > FALSE!\n", > + FileName, > + LineNumber, > + Description > + ); > UnitTestLogFailure ( > FAILURETYPE_ASSERTFALSE, > "%a:%d: Expression(%a) is not FALSE!\n", @@ - > 156,12 +164,6 @@ UnitTestAssertFalse ( > LineNumber, > Description > ); > - UT_LOG_ERROR ( > - "[ASSERT FAIL] %a:%d: Expression (%a) is not > FALSE!\n", > - FileName, > - LineNumber, > - Description > - ); > } > return !Expression; > } > @@ -195,6 +197,13 @@ UnitTestAssertNotEfiError ( > ) > { > if (EFI_ERROR (Status)) { > + UT_LOG_ERROR ( > + "[ASSERT FAIL] %a:%d: Status '%a' is EFI_ERROR > (%r)!\n", > + FileName, > + LineNumber, > + Description, > + Status > + ); > UnitTestLogFailure ( > FAILURETYPE_ASSERTNOTEFIERROR, > "%a:%d: Status '%a' is EFI_ERROR (%r)!\n", @@ - > 203,13 +212,6 @@ UnitTestAssertNotEfiError ( > Description, > Status > ); > - UT_LOG_ERROR ( > - "[ASSERT FAIL] %a:%d: Status '%a' is EFI_ERROR > (%r)!\n", > - FileName, > - LineNumber, > - Description, > - Status > - ); > } > return !EFI_ERROR( Status ); > } > @@ -248,16 +250,6 @@ UnitTestAssertEqual ( > ) > { > if (ValueA !=3D ValueB) { > - UnitTestLogFailure ( > - FAILURETYPE_ASSERTEQUAL, > - "%a:%d: Value %a !=3D %a (%d !=3D %d)!\n", > - FileName, > - LineNumber, > - DescriptionA, > - DescriptionB, > - ValueA, > - ValueB > - ); > UT_LOG_ERROR ( > "[ASSERT FAIL] %a:%d: Value %a !=3D %a (%d !=3D > %d)!\n", > FileName, > @@ -267,6 +259,16 @@ UnitTestAssertEqual ( > ValueA, > ValueB > ); > + UnitTestLogFailure ( > + FAILURETYPE_ASSERTEQUAL, > + "%a:%d: Value %a !=3D %a (%d !=3D %d)!\n", > + FileName, > + LineNumber, > + DescriptionA, > + DescriptionB, > + ValueA, > + ValueB > + ); > } > return (ValueA =3D=3D ValueB); > } > @@ -310,15 +312,6 @@ UnitTestAssertMemEqual ( > ) > { > if (CompareMem(BufferA, BufferB, Length) !=3D 0) { > - UnitTestLogFailure ( > - FAILURETYPE_ASSERTEQUAL, > - "%a:%d: Memory at %a !=3D %a for length %d > bytes!\n", > - FileName, > - LineNumber, > - DescriptionA, > - DescriptionB, > - Length > - ); > UT_LOG_ERROR ( > "[ASSERT FAIL] %a:%d: Value %a !=3D %a for length > %d bytes!\n", > FileName, > @@ -327,6 +320,15 @@ UnitTestAssertMemEqual ( > DescriptionB, > Length > ); > + UnitTestLogFailure ( > + FAILURETYPE_ASSERTEQUAL, > + "%a:%d: Memory at %a !=3D %a for length %d > bytes!\n", > + FileName, > + LineNumber, > + DescriptionA, > + DescriptionB, > + Length > + ); > return FALSE; > } > return TRUE; > @@ -366,6 +368,15 @@ UnitTestAssertNotEqual ( > ) > { > if (ValueA =3D=3D ValueB) { > + UT_LOG_ERROR ( > + "[ASSERT FAIL] %a:%d: Value %a =3D=3D %a (%d =3D=3D > %d)!\n", > + FileName, > + LineNumber, > + DescriptionA, > + DescriptionB, > + ValueA, > + ValueB > + ); > UnitTestLogFailure ( > FAILURETYPE_ASSERTNOTEQUAL, > "%a:%d: Value %a =3D=3D %a (%d =3D=3D %d)!\n", @@ -376,15 > +387,6 @@ UnitTestAssertNotEqual ( > ValueA, > ValueB > ); > - UT_LOG_ERROR ( > - "[ASSERT FAIL] %a:%d: Value %a =3D=3D %a (%d =3D=3D > %d)!\n", > - FileName, > - LineNumber, > - DescriptionA, > - DescriptionB, > - ValueA, > - ValueB > - ); > } > return (ValueA !=3D ValueB); > } > @@ -421,6 +423,14 @@ UnitTestAssertStatusEqual ( > ) > { > if (Status !=3D Expected) { > + UT_LOG_ERROR ( > + "[ASSERT FAIL] %a:%d: Status '%a' is %r, should > be %r!\n", > + FileName, > + LineNumber, > + Description, > + Status, > + Expected > + ); > UnitTestLogFailure ( > FAILURETYPE_ASSERTSTATUSEQUAL, > "%a:%d: Status '%a' is %r, should be %r!\n", @@ - > 430,14 +440,6 @@ UnitTestAssertStatusEqual ( > Status, > Expected > ); > - UT_LOG_ERROR ( > - "[ASSERT FAIL] %a:%d: Status '%a' is %r, should > be %r!\n", > - FileName, > - LineNumber, > - Description, > - Status, > - Expected > - ); > } > return (Status =3D=3D Expected); > } > @@ -473,6 +475,12 @@ UnitTestAssertNotNull ( > ) > { > if (Pointer =3D=3D NULL) { > + UT_LOG_ERROR ( > + "[ASSERT FAIL] %a:%d: Pointer (%a) is NULL!\n", > + FileName, > + LineNumber, > + PointerName > + ); > UnitTestLogFailure ( > FAILURETYPE_ASSERTNOTNULL, > "%a:%d: Pointer (%a) is NULL!\n", @@ -480,12 > +488,83 @@ UnitTestAssertNotNull ( > LineNumber, > PointerName > ); > - UT_LOG_ERROR ( > - "[ASSERT FAIL] %a:%d: Pointer (%a) is NULL!\n", > - FileName, > - LineNumber, > - PointerName > - ); > } > return (Pointer !=3D NULL); > } > + > +/** > + If UnitTestStatus is UNIT_TEST_PASSED, then log an > info message and > +return > + TRUE because an ASSERT() was expected when > FunctionCall was executed > +and an > + ASSERT() was triggered. If UnitTestStatus is > UNIT_TEST_SKIPPED, then > +log a > + warning message and return TRUE because ASSERT() > macros are disabled. > +If > + UnitTestStatus is UNIT_TEST_ERROR_TEST_FAILED, then > log an error > +message and > + return FALSE because an ASSERT() was expected when > FunctionCall was > +executed, > + but no ASSERT() conditions were triggered. The log > messages contain > + FunctionName, LineNumber, and FileName strings to > provide the > +location of the > + UT_EXPECT_ASSERT_FAILURE() macro. > + > + @param[in] UnitTestStatus The status from > UT_EXPECT_ASSERT_FAILURE() that > + is either pass, skipped, > or failed. > + @param[in] FunctionName Null-terminated ASCII > string of the function > + executing the > UT_EXPECT_ASSERT_FAILURE() macro. > + @param[in] LineNumber The source file line > number of the the function > + executing the > UT_EXPECT_ASSERT_FAILURE() macro. > + @param[in] FileName Null-terminated ASCII > string of the filename > + executing the > UT_EXPECT_ASSERT_FAILURE() macro. > + @param[in] FunctionCall Null-terminated ASCII > string of the function call > + executed by the > UT_EXPECT_ASSERT_FAILURE() macro. > + @param[out] ResultStatus Used to return the > UnitTestStatus value to the > + caller of > UT_EXPECT_ASSERT_FAILURE(). This is > + optional parameter that > may be NULL. > + > + @retval TRUE UnitTestStatus is UNIT_TEST_PASSED. > + @retval TRUE UnitTestStatus is UNIT_TEST_SKIPPED. > + @retval FALSE UnitTestStatus is > UNIT_TEST_ERROR_TEST_FAILED. > +**/ > +BOOLEAN > +EFIAPI > +UnitTestExpectAssertFailure ( > + IN UNIT_TEST_STATUS UnitTestStatus, > + IN CONST CHAR8 *FunctionName, > + IN UINTN LineNumber, > + IN CONST CHAR8 *FileName, > + IN CONST CHAR8 *FunctionCall, > + OUT UNIT_TEST_STATUS *ResultStatus OPTIONAL > + ) > +{ > + if (ResultStatus !=3D NULL) { > + *ResultStatus =3D UnitTestStatus; > + } > + if (UnitTestStatus =3D=3D UNIT_TEST_PASSED) { > + UT_LOG_INFO ( > + "[ASSERT PASS] %a:%d: > UT_EXPECT_ASSERT_FAILURE(%a) detected expected > assert\n", > + FileName, > + LineNumber, > + FunctionCall > + ); > + } > + if (UnitTestStatus =3D=3D UNIT_TEST_SKIPPED) { > + UT_LOG_WARNING ( > + "[ASSERT WARN] %a:%d: > UT_EXPECT_ASSERT_FAILURE(%a) disabled\n", > + FileName, > + LineNumber, > + FunctionCall > + ); > + } > + if (UnitTestStatus =3D=3D UNIT_TEST_ERROR_TEST_FAILED) { > + UT_LOG_ERROR ( > + "[ASSERT FAIL] %a:%d: Function call (%a) did not > ASSERT()!\n", > + FileName, > + LineNumber, > + FunctionCall > + ); > + UnitTestLogFailure ( > + FAILURETYPE_EXPECTASSERT, > + "%a:%d: Function call (%a) did not ASSERT()!\n", > + FileName, > + LineNumber, > + FunctionCall > + ); > + } > + return (UnitTestStatus !=3D > UNIT_TEST_ERROR_TEST_FAILED); } > diff --git > a/UnitTestFrameworkPkg/Library/UnitTestLib/AssertCmocka. > c > b/UnitTestFrameworkPkg/Library/UnitTestLib/AssertCmocka. > c > index e48d614976..687c6243ab 100644 > --- > a/UnitTestFrameworkPkg/Library/UnitTestLib/AssertCmocka. > c > +++ > b/UnitTestFrameworkPkg/Library/UnitTestLib/AssertCmocka. > c > @@ -333,3 +333,71 @@ UnitTestAssertNotNull ( > > return (Pointer !=3D NULL); > } > + > +/** > + If UnitTestStatus is UNIT_TEST_PASSED, then log an > info message and > +return > + TRUE because an ASSERT() was expected when > FunctionCall was executed > +and an > + ASSERT() was triggered. If UnitTestStatus is > UNIT_TEST_SKIPPED, then > +log a > + warning message and return TRUE because ASSERT() > macros are disabled. > +If > + UnitTestStatus is UNIT_TEST_ERROR_TEST_FAILED, then > log an error > +message and > + return FALSE because an ASSERT() was expected when > FunctionCall was > +executed, > + but no ASSERT() conditions were triggered. The log > messages contain > + FunctionName, LineNumber, and FileName strings to > provide the > +location of the > + UT_EXPECT_ASSERT_FAILURE() macro. > + > + @param[in] UnitTestStatus The status from > UT_EXPECT_ASSERT_FAILURE() that > + is either pass, skipped, > or failed. > + @param[in] FunctionName Null-terminated ASCII > string of the function > + executing the > UT_EXPECT_ASSERT_FAILURE() macro. > + @param[in] LineNumber The source file line > number of the the function > + executing the > UT_EXPECT_ASSERT_FAILURE() macro. > + @param[in] FileName Null-terminated ASCII > string of the filename > + executing the > UT_EXPECT_ASSERT_FAILURE() macro. > + @param[in] FunctionCall Null-terminated ASCII > string of the function call > + executed by the > UT_EXPECT_ASSERT_FAILURE() macro. > + @param[out] ResultStatus Used to return the > UnitTestStatus value to the > + caller of > UT_EXPECT_ASSERT_FAILURE(). This is > + optional parameter that > may be NULL. > + > + @retval TRUE UnitTestStatus is UNIT_TEST_PASSED. > + @retval TRUE UnitTestStatus is UNIT_TEST_SKIPPED. > + @retval FALSE UnitTestStatus is > UNIT_TEST_ERROR_TEST_FAILED. > +**/ > +BOOLEAN > +EFIAPI > +UnitTestExpectAssertFailure ( > + IN UNIT_TEST_STATUS UnitTestStatus, > + IN CONST CHAR8 *FunctionName, > + IN UINTN LineNumber, > + IN CONST CHAR8 *FileName, > + IN CONST CHAR8 *FunctionCall, > + OUT UNIT_TEST_STATUS *ResultStatus OPTIONAL > + ) > +{ > + CHAR8 TempStr[MAX_STRING_SIZE]; > + > + if (ResultStatus !=3D NULL) { > + *ResultStatus =3D UnitTestStatus; > + } > + if (UnitTestStatus =3D=3D UNIT_TEST_PASSED) { > + UT_LOG_INFO ( > + "[ASSERT PASS] %a:%d: > UT_EXPECT_ASSERT_FAILURE(%a) detected expected > assert\n", > + FileName, > + LineNumber, > + FunctionCall > + ); > + } > + if (UnitTestStatus =3D=3D UNIT_TEST_SKIPPED) { > + UT_LOG_WARNING ( > + "[ASSERT WARN] %a:%d: > UT_EXPECT_ASSERT_FAILURE(%a) disabled\n", > + FileName, > + LineNumber, > + FunctionCall > + ); > + } > + if (UnitTestStatus =3D=3D UNIT_TEST_ERROR_TEST_FAILED) { > + snprintf (TempStr, sizeof(TempStr), > "UT_EXPECT_ASSERT_FAILURE(%s) did not trigger ASSERT()", > FunctionCall); > + _assert_true (FALSE, TempStr, FileName, > (INT32)LineNumber); > + } > + return (UnitTestStatus !=3D > UNIT_TEST_ERROR_TEST_FAILED); } > diff --git > a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c > b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c > index 793335fd0f..2dc1d159d5 100644 > --- > a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c > +++ > b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c > @@ -14,6 +14,8 @@ > > STATIC UNIT_TEST_FRAMEWORK_HANDLE mFrameworkHandle =3D > NULL; > > +BASE_LIBRARY_JUMP_BUFFER gUnitTestJumpBuffer; > + > UNIT_TEST_FRAMEWORK_HANDLE > GetActiveFrameworkHandle ( > VOID > @@ -75,7 +77,14 @@ RunTestSuite ( > // Next, if we're still running, make sure that our > test prerequisites are in place. > if (Test->Result =3D=3D UNIT_TEST_PENDING && Test- > >Prerequisite !=3D NULL) { > DEBUG ((DEBUG_VERBOSE, "PREREQ\n")); > - if (Test->Prerequisite (Test->Context) !=3D > UNIT_TEST_PASSED) { > + if (SetJump (&gUnitTestJumpBuffer) =3D=3D 0) { > + if (Test->Prerequisite (Test->Context) !=3D > UNIT_TEST_PASSED) { > + DEBUG ((DEBUG_ERROR, "Prerequisite Not > Met\n")); > + Test->Result =3D > UNIT_TEST_ERROR_PREREQUISITE_NOT_MET; > + ParentFramework->CurrentTest =3D NULL; > + continue; > + } > + } else { > DEBUG ((DEBUG_ERROR, "Prerequisite Not > Met\n")); > Test->Result =3D > UNIT_TEST_ERROR_PREREQUISITE_NOT_MET; > ParentFramework->CurrentTest =3D NULL; @@ -88,14 > +97,20 @@ RunTestSuite ( > // We set the status to UNIT_TEST_RUNNING in case > the test needs to reboot > // or quit. The UNIT_TEST_RUNNING state will allow > the test to resume > // but will prevent the Prerequisite from being > dispatched a second time. > - Test->Result =3D UNIT_TEST_RUNNING; > - Test->Result =3D Test->RunTest (Test->Context); > + if (SetJump (&gUnitTestJumpBuffer) =3D=3D 0) { > + Test->Result =3D UNIT_TEST_RUNNING; > + Test->Result =3D Test->RunTest (Test->Context); > + } else { > + Test->Result =3D UNIT_TEST_ERROR_TEST_FAILED; > + } > > // > // Finally, clean everything up, if need be. > if (Test->CleanUp !=3D NULL) { > DEBUG ((DEBUG_VERBOSE, "CLEANUP\n")); > - Test->CleanUp (Test->Context); > + if (SetJump (&gUnitTestJumpBuffer) =3D=3D 0) { > + Test->CleanUp (Test->Context); > + } > } > > // > diff --git > a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/U > nitTestResultReportLib.c > b/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/U > nitTestResultReportLib.c > index eba68e330c..66c9db457d 100644 > --- > a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/U > nitTestResultReportLib.c > +++ > b/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/U > nitTestResul > +++ tReportLib.c > @@ -49,7 +49,8 @@ struct _UNIT_TEST_FAILURE_TYPE_STRING > mFailureTypeStrings[] =3D { > { FAILURETYPE_ASSERTNOTEQUAL, "ASSERT_NOTEQUAL > FAILURE"}, > { FAILURETYPE_ASSERTNOTEFIERROR, "ASSERT_NOTEFIERROR > FAILURE"}, > { FAILURETYPE_ASSERTSTATUSEQUAL, "ASSERT_STATUSEQUAL > FAILURE"}, > - { FAILURETYPE_ASSERTNOTNULL , "ASSERT_NOTNULL > FAILURE"}, > + { FAILURETYPE_ASSERTNOTNULL, "ASSERT_NOTNULL > FAILURE"}, > + { FAILURETYPE_EXPECTASSERT, "EXPECT_ASSERT > FAILURE"}, > { 0, "*UNKNOWN* Failure"} > }; > > diff --git > a/UnitTestFrameworkPkg/PrivateInclude/UnitTestFrameworkT > ypes.h > b/UnitTestFrameworkPkg/PrivateInclude/UnitTestFrameworkT > ypes.h > index e58b30093e..b0e2f61bbf 100644 > --- > a/UnitTestFrameworkPkg/PrivateInclude/UnitTestFrameworkT > ypes.h > +++ > b/UnitTestFrameworkPkg/PrivateInclude/UnitTestFrameworkT > ypes.h > @@ -44,6 +44,7 @@ typedef UINT32 FAILURE_TYPE; > #define FAILURETYPE_ASSERTNOTEFIERROR (6) > #define FAILURETYPE_ASSERTSTATUSEQUAL (7) > #define FAILURETYPE_ASSERTNOTNULL (8) > +#define FAILURETYPE_EXPECTASSERT (9) > > /// > /// Unit Test context structure tracked by the unit > test framework. > diff --git > a/UnitTestFrameworkPkg/Test/UnitTestFrameworkPkgHostTest > .dsc > b/UnitTestFrameworkPkg/Test/UnitTestFrameworkPkgHostTest > .dsc > index 701e7299d7..70affddead 100644 > --- > a/UnitTestFrameworkPkg/Test/UnitTestFrameworkPkgHostTest > .dsc > +++ > b/UnitTestFrameworkPkg/Test/UnitTestFrameworkPkgHostTest > .dsc > @@ -25,7 +25,7 @@ [Components] > > UnitTestFrameworkPkg/Test/UnitTest/Sample/SampleUnitTest > /SampleUnitTestHost.inf > > # > - # Build Libraries > + # Build HOST_APPLICATION Libraries > # > UnitTestFrameworkPkg/Library/CmockaLib/CmockaLib.inf > > UnitTestFrameworkPkg/Library/Posix/DebugLibPosix/DebugLi > bPosix.inf > diff --git > a/UnitTestFrameworkPkg/UnitTestFrameworkPkg.dsc > b/UnitTestFrameworkPkg/UnitTestFrameworkPkg.dsc > index 2d84691bf1..0dfd98f2a8 100644 > --- a/UnitTestFrameworkPkg/UnitTestFrameworkPkg.dsc > +++ b/UnitTestFrameworkPkg/UnitTestFrameworkPkg.dsc > @@ -28,6 +28,7 @@ [Components] > > UnitTestFrameworkPkg/Library/UnitTestResultReportLib/Uni > tTestResultReportLibConOut.inf > > UnitTestFrameworkPkg/Library/UnitTestBootLibUsbClass/Uni > tTestBootLibUsbClass.inf > > UnitTestFrameworkPkg/Library/UnitTestPersistenceLibSimpl > eFileSystem/UnitTestPersistenceLibSimpleFileSystem.inf > + > + > UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Unit > TestDebugAsser > + tLib.inf > > > UnitTestFrameworkPkg/Test/UnitTest/Sample/SampleUnitTest > /SampleUnitTestDxe.inf > > UnitTestFrameworkPkg/Test/UnitTest/Sample/SampleUnitTest > /SampleUnitTestPei.inf > diff --git > a/UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.in > c > b/UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.in > c > index 0881278ab0..8adf690098 100644 > --- > a/UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.in > c > +++ > b/UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.in > c > @@ -29,6 +29,7 @@ [LibraryClasses] > > UnitTestLib|UnitTestFrameworkPkg/Library/UnitTestLib/Uni > tTestLib.inf > > UnitTestPersistenceLib|UnitTestFrameworkPkg/Library/Unit > TestPersistenceLibNull/UnitTestPersistenceLibNull.inf > > UnitTestResultReportLib|UnitTestFrameworkPkg/Library/Uni > tTestResultReportLib/UnitTestResultReportLibDebugLib.inf > + > + > NULL|UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib > /UnitTestDebug > + AssertLib.inf > > [LibraryClasses.ARM, LibraryClasses.AARCH64] > # > @@ -56,5 +57,6 @@ [PcdsFixedAtBuild] > gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17 > > [BuildOptions] > - MSFT:*_*_*_CC_FLAGS =3D -D > DISABLE_NEW_DEPRECATED_INTERFACES > - GCC:*_*_*_CC_FLAGS =3D -D > DISABLE_NEW_DEPRECATED_INTERFACES > + MSFT:*_*_*_CC_FLAGS =3D -D > DISABLE_NEW_DEPRECATED_INTERFACES -D > EDKII_UNIT_TEST_FRAMEWORK_ENABLED > + GCC:*_*_*_CC_FLAGS =3D -D > DISABLE_NEW_DEPRECATED_INTERFACES -D > EDKII_UNIT_TEST_FRAMEWORK_ENABLED > + XCODE:*_*_*_CC_FLAGS =3D -D > DISABLE_NEW_DEPRECATED_INTERFACES -D > + EDKII_UNIT_TEST_FRAMEWORK_ENABLED > -- > 2.21.0.windows.1 > > > --_000_CY4PR21MB07435EFDDF21A2668654F201EF7E0CY4PR21MB0743namp_ Content-Type: text/html; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable

Reviewed-by: Bret Barkelew <bret.barkelew@micros= oft.com>

 

 

- Bret

 

From: Michael D Kinney via = groups.io
Sent: Tuesday, July 14, 2020 9:26 AM
To: liming.gao; devel@edk2.groups.io; Ki= nney, Michael D
Cc: Sean Brogan; <= a href=3D"mailto:Bret.Barkelew@microsoft.com"> Bret Barkelew; Yao, Jiewen=
Subject: [EXTERNAL] Re: [edk2-devel] [Patch v3 12/16] UnitTestFrame= workPkg/UnitTestLib: Add checks for ASSERT()

 

Liming,

I will fix that one issue in the INF comment block
when I push the commits.

Thanks,

Mike

> -----Original Message-----
> From: Gao, Liming <liming.gao@intel.com>
> Sent: Monday, July 13, 2020 11:57 PM
> To: devel@edk2.groups.io; Kinney, Michael D
> <michael.d.kinney@intel.com>
> Cc: Sean Brogan <sean.brogan@microsoft.com>; Bret
> Barkelew <Bret.Barkelew@microsoft.com>; Yao, Jiewen
> <jiewen.yao@intel.com>
> Subject: RE: [edk2-devel] [Patch v3 12/16]
> UnitTestFrameworkPkg/UnitTestLib: Add checks for
> ASSERT()
>
> Mike:
>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On
> Behalf Of Michael D Kinney
> Sent: 2020=1B$BG/=1B(B7=1B$B7n=1B(B11=1B$BF|=1B(B 10:09
> To: devel@edk2.groups.io
> Cc: Sean Brogan <sean.brogan@microsoft.com>; Bret
> Barkelew <Bret.Barkelew@microsoft.com>; Yao, Jiewen
> <jiewen.yao@intel.com>
> Subject: [edk2-devel] [Patch v3 12/16]
> UnitTestFrameworkPkg/UnitTestLib: Add checks for
> ASSERT()
>
> REF: REF:
> https://nam06.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fbugzil= la.tianocore.org%2Fshow_bug.cgi%3Fid%3D2801&amp;data=3D02%7C01%7Cbret.b= arkelew%40microsoft.com%7C3b85c7dd72af42d6295508d82812a84a%7C72f988bf86f141= af91ab2d7cd011db47%7C1%7C0%7C637303407889843281&amp;sdata=3D5fA35uRcosA= Ap0%2B1RVFoCLsGzAaqvc92dmxSVrwDJsY%3D&amp;reserved=3D0
>
> Add UnitTestDebugAssertLib that provides the
> UnitTestDebugAssert() service and the
> gUnitTestExpectAssertFailureJumpBuffer global variable.
> This NULL library is linked against all host and target
> unit test builds.  This guarantees that the
> UnitTestDebugAssert() service is available to link
> against all libraries and modules that use the DebugLib
> class.
>
> EDKII_UNIT_TEST_FRAMEWORK_ENABLED must always be defined
> when building unit tests so the behavior of the DebugLib
> ASSERT() macros can be adjusted to allow the unit test
> framework to catch an ASSERT() if it is triggered by a
> function under test.
>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Signed-off-by: Michael D Kinney
> <michael.d.kinney@intel.com>
> ---
>  .../UnitTestDebugAssertLib.c      = ;            | = 49
> +++++
>  .../UnitTestDebugAssertLib.inf     &nb= sp;          |  31 +++ >  .../UnitTestDebugAssertLib.uni     &nb= sp;          |  11 +
>  .../Library/UnitTestLib/Assert.c     &= nbsp;        | 203
> ++++++++++++------
>  .../Library/UnitTestLib/AssertCmocka.c    &= nbsp;   |  68
> ++++++
>  .../Library/UnitTestLib/RunTests.c     = ;       |  23 +-
>  .../UnitTestResultReportLib.c     &nbs= p;           |  = ; 3 +-
>  .../PrivateInclude/UnitTestFrameworkTypes.h   | =   1 +
>  .../Test/UnitTestFrameworkPkgHostTest.dsc   &nbs= p; |   2 +-
>  UnitTestFrameworkPkg/UnitTestFrameworkPkg.dsc |   1 +=
>  .../UnitTestFrameworkPkgTarget.dsc.inc    &= nbsp;   |   6 +-
>  11 files changed, 328 insertions(+), 70 deletions(-)
> create mode 100644
> UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Unit
> TestDebugAssertLib.c
>  create mode 100644
> UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Unit
> TestDebugAssertLib.inf
>  create mode 100644
> UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Unit
> TestDebugAssertLib.uni
>
> diff --git
> a/UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Un
> itTestDebugAssertLib.c
> b/UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Un
> itTestDebugAssertLib.c
> new file mode 100644
> index 0000000000..0a4001e182
> --- /dev/null
> +++
> b/UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Un
> itTestDebugA
> +++ ssertLib.c
> @@ -0,0 +1,49 @@
> +/** @file
> +  Unit Test Debug Assert Library
> +
> +  Copyright (c) 2020, Intel Corporation. All rights
> reserved.<BR>
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Uefi.h>
> +#include <Library/BaseLib.h>
> +#include <Library/UnitTestLib.h>
> +
> +///
> +/// Point to jump buffer used with SetJump()/LongJump()
> to test if a
> +function /// under test generates an expected ASSERT()
> condition.
> +///
> +BASE_LIBRARY_JUMP_BUFFER
> *gUnitTestExpectAssertFailureJumpBuffer =3D
> +NULL;
> +
> +/**
> +  Unit test library replacement for DebugAssert() in
> DebugLib.
> +
> +  If FileName is NULL, then a <FileName> string of
> "(NULL) Filename" is printed.
> +  If Description is NULL, then a <Description> string
> of "(NULL) Description" is printed.
> +
> +  @param  FileName     The pointer to = the name of the
> source file that generated the assert condition.
> +  @param  LineNumber   The line number in the so= urce
> file that generated the assert condition
> +  @param  Description  The pointer to the description=
> of the assert condition.
> +
> +**/
> +VOID
> +EFIAPI
> +UnitTestDebugAssert (
> +  IN CONST CHAR8  *FileName,
> +  IN UINTN        LineNumber= ,
> +  IN CONST CHAR8  *Description
> +  )
> +{
> +  CHAR8  Message[256];
> +
> +  if (gUnitTestExpectAssertFailureJumpBuffer !=3D NULL) {
> +    UT_LOG_INFO ("Detected expected ASSERT: %a(%= d):
> %a\n", FileName, LineNumber, Description);
> +    LongJump (gUnitTestExpectAssertFailureJumpBuffer,=
> 1);
> +  } else {
> +    AsciiStrCpyS (Message, sizeof(Message), "Det= ected
> unexpected ASSERT(");
> +    AsciiStrCatS (Message, sizeof(Message),
> Description);
> +    AsciiStrCatS (Message, sizeof(Message), ")&q= uot;);
> +    UnitTestAssertTrue (FALSE, "", LineNumb= er,
> FileName, Message);
> +  }
> +}
> diff --git
> a/UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Un
> itTestDebugAssertLib.inf
> b/UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Un
> itTestDebugAssertLib.inf
> new file mode 100644
> index 0000000000..e6ccab0dd9
> --- /dev/null
> +++
> b/UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Un
> itTestDebugA
> +++ ssertLib.inf
> @@ -0,0 +1,31 @@
> +## @file
> +#  Unit Test Debug Assert Library
> +#
> +#  Copyright (c) 2020, Intel Corporation. All rights
> reserved.<BR> #
> +SPDX-License-Identifier: BSD-2-Clause-Patent # ##
> +
> +[Defines]
> +  INF_VERSION        &n= bsp;           =3D 0x0001= 0005
> +  BASE_NAME        &nbs= p;             = = =3D
> UnitTestDebugAssertLib
> +  MODULE_UNI_FILE       &nbs= p;        =3D
> UnitTestDebugAssertLib.uni
> +  FILE_GUID        &nbs= p;             = = =3D 9D53AD0D-5416-451F-
> A5BF-E5420051A99B
> +  MODULE_TYPE        &n= bsp;           =3D BASE > +  VERSION_STRING        = ;         =3D 1.0
> +  LIBRARY_CLASS        =           =3D NULL
> +
> +#
> +#  VALID_ARCHITECTURES       = ;    =3D ARM AARCH64
> +#
>
> Seemly, this comment is incorrect. Valid arch should
> include IA32 and X64. Right?
>
> Thanks
> Liming
>
> +
> +[Sources]
> +  UnitTestDebugAssertLib.c
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +  UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
> +
> +[LibraryClasses]
> +  BaseLib
> +  UnitTestLib
> diff --git
> a/UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Un
> itTestDebugAssertLib.uni
> b/UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Un
> itTestDebugAssertLib.uni
> new file mode 100644
> index 0000000000..9b794aa205
> --- /dev/null
> +++
> b/UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Un
> itTestDebugA
> +++ ssertLib.uni
> @@ -0,0 +1,11 @@
> +// /** @file
> +// Unit Test Debug Assert Library
> +//
> +// Copyright (c) 2020, Intel Corporation. All rights
> reserved.<BR> //
> +SPDX-License-Identifier: BSD-2-Clause-Patent // // **/
> +
> +#string STR_MODULE_ABSTRACT       = ;      #language en-US
> "Unit Test Debug Assert Library"
> +
> +#string STR_MODULE_DESCRIPTION      &n= bsp;   #language en-US
> "Unit Test Debug Assert Library"
> diff --git
> a/UnitTestFrameworkPkg/Library/UnitTestLib/Assert.c
> b/UnitTestFrameworkPkg/Library/UnitTestLib/Assert.c
> index 8a131fab2b..3669d63701 100644
> --- a/UnitTestFrameworkPkg/Library/UnitTestLib/Assert.c
> +++ b/UnitTestFrameworkPkg/Library/UnitTestLib/Assert.c
> @@ -13,6 +13,8 @@
>  #include <Library/DebugLib.h>
>  #include <Library/PrintLib.h>
>
> +extern BASE_LIBRARY_JUMP_BUFFER  gUnitTestJumpBuffer;
> +
>  STATIC
>  EFI_STATUS
>  AddUnitTestFailure (
> @@ -71,7 +73,7 @@ UnitTestLogFailure (
>      FailureType
>      );
>
> -  return;
> +  LongJump (&gUnitTestJumpBuffer, 1);
>  }
>
>  /**
> @@ -103,6 +105,12 @@ UnitTestAssertTrue (
>    )
>  {
>    if (!Expression) {
> +    UT_LOG_ERROR (
> +      "[ASSERT FAIL] %a:%d: Expression= (%a) is not
> TRUE!\n",
> +      FileName,
> +      LineNumber,
> +      Description
> +      );
>      UnitTestLogFailure (
>        FAILURETYPE_ASSERTTRUE,
>        "%a:%d: Expression (%a= ) is not TRUE!\n", @@ -
> 110,12 +118,6 @@ UnitTestAssertTrue (
>        LineNumber,
>        Description
>        );
> -    UT_LOG_ERROR (
> -      "[ASSERT FAIL] %a:%d: Expression= (%a) is not
> TRUE!\n",
> -      FileName,
> -      LineNumber,
> -      Description
> -      );
>    }
>    return Expression;
>  }
> @@ -149,6 +151,12 @@ UnitTestAssertFalse (
>    )
>  {
>    if (Expression) {
> +    UT_LOG_ERROR (
> +      "[ASSERT FAIL] %a:%d: Expression= (%a) is not
> FALSE!\n",
> +      FileName,
> +      LineNumber,
> +      Description
> +      );
>      UnitTestLogFailure (
>        FAILURETYPE_ASSERTFALSE, >        "%a:%d: Expression(%a)= is not FALSE!\n", @@ -
> 156,12 +164,6 @@ UnitTestAssertFalse (
>        LineNumber,
>        Description
>        );
> -    UT_LOG_ERROR (
> -      "[ASSERT FAIL] %a:%d: Expression= (%a) is not
> FALSE!\n",
> -      FileName,
> -      LineNumber,
> -      Description
> -      );
>    }
>    return !Expression;
>  }
> @@ -195,6 +197,13 @@ UnitTestAssertNotEfiError (
>    )
>  {
>    if (EFI_ERROR (Status)) {
> +    UT_LOG_ERROR (
> +      "[ASSERT FAIL] %a:%d: Status '%a= ' is EFI_ERROR
> (%r)!\n",
> +      FileName,
> +      LineNumber,
> +      Description,
> +      Status
> +      );
>      UnitTestLogFailure (
>        FAILURETYPE_ASSERTNOTEFIERR= OR,
>        "%a:%d: Status '%a' is= EFI_ERROR (%r)!\n", @@ -
> 203,13 +212,6 @@ UnitTestAssertNotEfiError (
>        Description,
>        Status
>        );
> -    UT_LOG_ERROR (
> -      "[ASSERT FAIL] %a:%d: Status '%a= ' is EFI_ERROR
> (%r)!\n",
> -      FileName,
> -      LineNumber,
> -      Description,
> -      Status
> -      );
>    }
>    return !EFI_ERROR( Status );
>  }
> @@ -248,16 +250,6 @@ UnitTestAssertEqual (
>    )
>  {
>    if (ValueA !=3D ValueB) {
> -    UnitTestLogFailure (
> -      FAILURETYPE_ASSERTEQUAL,
> -      "%a:%d: Value %a !=3D %a (%d != =3D %d)!\n",
> -      FileName,
> -      LineNumber,
> -      DescriptionA,
> -      DescriptionB,
> -      ValueA,
> -      ValueB
> -      );
>      UT_LOG_ERROR (
>        "[ASSERT FAIL] %a:%d: = Value %a !=3D %a (%d !=3D
> %d)!\n",
>        FileName,
> @@ -267,6 +259,16 @@ UnitTestAssertEqual (
>        ValueA,
>        ValueB
>        );
> +    UnitTestLogFailure (
> +      FAILURETYPE_ASSERTEQUAL,
> +      "%a:%d: Value %a !=3D %a (%d != =3D %d)!\n",
> +      FileName,
> +      LineNumber,
> +      DescriptionA,
> +      DescriptionB,
> +      ValueA,
> +      ValueB
> +      );
>    }
>    return (ValueA =3D=3D ValueB);
>  }
> @@ -310,15 +312,6 @@ UnitTestAssertMemEqual (
>    )
>  {
>    if (CompareMem(BufferA, BufferB, Length) !=3D 0) {<= br> > -    UnitTestLogFailure (
> -      FAILURETYPE_ASSERTEQUAL,
> -      "%a:%d: Memory at %a !=3D %a for= length %d
> bytes!\n",
> -      FileName,
> -      LineNumber,
> -      DescriptionA,
> -      DescriptionB,
> -      Length
> -      );
>      UT_LOG_ERROR (
>        "[ASSERT FAIL] %a:%d: = Value %a !=3D %a for length
> %d bytes!\n",
>        FileName,
> @@ -327,6 +320,15 @@ UnitTestAssertMemEqual (
>        DescriptionB,
>        Length
>        );
> +    UnitTestLogFailure (
> +      FAILURETYPE_ASSERTEQUAL,
> +      "%a:%d: Memory at %a !=3D %a for= length %d
> bytes!\n",
> +      FileName,
> +      LineNumber,
> +      DescriptionA,
> +      DescriptionB,
> +      Length
> +      );
>      return FALSE;
>    }
>    return TRUE;
> @@ -366,6 +368,15 @@ UnitTestAssertNotEqual (
>    )
>  {
>    if (ValueA =3D=3D ValueB) {
> +    UT_LOG_ERROR (
> +      "[ASSERT FAIL] %a:%d: Value %a = =3D=3D %a (%d =3D=3D
> %d)!\n",
> +      FileName,
> +      LineNumber,
> +      DescriptionA,
> +      DescriptionB,
> +      ValueA,
> +      ValueB
> +      );
>      UnitTestLogFailure (
>        FAILURETYPE_ASSERTNOTEQUAL,=
>        "%a:%d: Value %a =3D= =3D %a (%d =3D=3D %d)!\n", @@ -376,15
> +387,6 @@ UnitTestAssertNotEqual (
>        ValueA,
>        ValueB
>        );
> -    UT_LOG_ERROR (
> -      "[ASSERT FAIL] %a:%d: Value %a = =3D=3D %a (%d =3D=3D
> %d)!\n",
> -      FileName,
> -      LineNumber,
> -      DescriptionA,
> -      DescriptionB,
> -      ValueA,
> -      ValueB
> -      );
>    }
>    return (ValueA !=3D ValueB);
>  }
> @@ -421,6 +423,14 @@ UnitTestAssertStatusEqual (
>    )
>  {
>    if (Status !=3D Expected) {
> +    UT_LOG_ERROR (
> +      "[ASSERT FAIL] %a:%d: Status '%a= ' is %r, should
> be %r!\n",
> +      FileName,
> +      LineNumber,
> +      Description,
> +      Status,
> +      Expected
> +      );
>      UnitTestLogFailure (
>        FAILURETYPE_ASSERTSTATUSEQU= AL,
>        "%a:%d: Status '%a' is= %r, should be %r!\n", @@ -
> 430,14 +440,6 @@ UnitTestAssertStatusEqual (
>        Status,
>        Expected
>        );
> -    UT_LOG_ERROR (
> -      "[ASSERT FAIL] %a:%d: Status '%a= ' is %r, should
> be %r!\n",
> -      FileName,
> -      LineNumber,
> -      Description,
> -      Status,
> -      Expected
> -      );
>    }
>    return (Status =3D=3D Expected);
>  }
> @@ -473,6 +475,12 @@ UnitTestAssertNotNull (
>    )
>  {
>    if (Pointer =3D=3D NULL) {
> +    UT_LOG_ERROR (
> +      "[ASSERT FAIL] %a:%d: Pointer (%= a) is NULL!\n",
> +      FileName,
> +      LineNumber,
> +      PointerName
> +      );
>      UnitTestLogFailure (
>        FAILURETYPE_ASSERTNOTNULL,<= br> >        "%a:%d: Pointer (%a) i= s NULL!\n", @@ -480,12
> +488,83 @@ UnitTestAssertNotNull (
>        LineNumber,
>        PointerName
>        );
> -    UT_LOG_ERROR (
> -      "[ASSERT FAIL] %a:%d: Pointer (%= a) is NULL!\n",
> -      FileName,
> -      LineNumber,
> -      PointerName
> -      );
>    }
>    return (Pointer !=3D NULL);
>  }
> +
> +/**
> +  If UnitTestStatus is UNIT_TEST_PASSED, then log an
> info message and
> +return
> +  TRUE because an ASSERT() was expected when
> FunctionCall was executed
> +and an
> +  ASSERT() was triggered. If UnitTestStatus is
> UNIT_TEST_SKIPPED, then
> +log a
> +  warning message and return TRUE because ASSERT()
> macros are disabled.
> +If
> +  UnitTestStatus is UNIT_TEST_ERROR_TEST_FAILED, then
> log an error
> +message and
> +  return FALSE because an ASSERT() was expected when
> FunctionCall was
> +executed,
> +  but no ASSERT() conditions were triggered.  The log
> messages contain
> +  FunctionName, LineNumber, and FileName strings to
> provide the
> +location of the
> +  UT_EXPECT_ASSERT_FAILURE() macro.
> +
> +  @param[in]  UnitTestStatus  The status from
> UT_EXPECT_ASSERT_FAILURE() that
> +           &n= bsp;            = ;      is either pass, skipped,
> or failed.
> +  @param[in]  FunctionName    Null-terminat= ed ASCII
> string of the function
> +           &n= bsp;            = ;      executing the
> UT_EXPECT_ASSERT_FAILURE() macro.
> +  @param[in]  LineNumber      The= source file line
> number of the the function
> +           &n= bsp;            = ;      executing the
> UT_EXPECT_ASSERT_FAILURE() macro.
> +  @param[in]  FileName      =   Null-terminated ASCII
> string of the filename
> +           &n= bsp;            = ;      executing the
> UT_EXPECT_ASSERT_FAILURE() macro.
> +  @param[in]  FunctionCall    Null-terminat= ed ASCII
> string of the function call
> +           &n= bsp;            = ;      executed by the
> UT_EXPECT_ASSERT_FAILURE() macro.
> +  @param[out] ResultStatus    Used to return the=
> UnitTestStatus value to the
> +           &n= bsp;            = ;      caller of
> UT_EXPECT_ASSERT_FAILURE().  This is
> +           &n= bsp;            = ;      optional parameter that
> may be NULL.
> +
> +  @retval  TRUE   UnitTestStatus is UNIT_TEST_PA= SSED.
> +  @retval  TRUE   UnitTestStatus is UNIT_TEST_SK= IPPED.
> +  @retval  FALSE  UnitTestStatus is
> UNIT_TEST_ERROR_TEST_FAILED.
> +**/
> +BOOLEAN
> +EFIAPI
> +UnitTestExpectAssertFailure (
> +  IN  UNIT_TEST_STATUS  UnitTestStatus,
> +  IN  CONST CHAR8       *Fun= ctionName,
> +  IN  UINTN        = ;     LineNumber,
> +  IN  CONST CHAR8       *Fil= eName,
> +  IN  CONST CHAR8       *Fun= ctionCall,
> +  OUT UNIT_TEST_STATUS  *ResultStatus  OPTIONAL
> +  )
> +{
> +  if (ResultStatus !=3D NULL) {
> +    *ResultStatus =3D UnitTestStatus;
> +  }
> +  if (UnitTestStatus =3D=3D UNIT_TEST_PASSED) {
> +    UT_LOG_INFO (
> +      "[ASSERT PASS] %a:%d:
> UT_EXPECT_ASSERT_FAILURE(%a) detected expected
> assert\n",
> +      FileName,
> +      LineNumber,
> +      FunctionCall
> +      );
> +  }
> +  if (UnitTestStatus =3D=3D UNIT_TEST_SKIPPED) {
> +    UT_LOG_WARNING (
> +      "[ASSERT WARN] %a:%d:
> UT_EXPECT_ASSERT_FAILURE(%a) disabled\n",
> +      FileName,
> +      LineNumber,
> +      FunctionCall
> +      );
> +  }
> +  if (UnitTestStatus =3D=3D UNIT_TEST_ERROR_TEST_FAILED) {
> +    UT_LOG_ERROR (
> +      "[ASSERT FAIL] %a:%d: Function c= all (%a) did not
> ASSERT()!\n",
> +      FileName,
> +      LineNumber,
> +      FunctionCall
> +      );
> +    UnitTestLogFailure (
> +      FAILURETYPE_EXPECTASSERT,
> +      "%a:%d: Function call (%a) did n= ot ASSERT()!\n",
> +      FileName,
> +      LineNumber,
> +      FunctionCall
> +      );
> +  }
> +  return (UnitTestStatus !=3D
> UNIT_TEST_ERROR_TEST_FAILED); }
> diff --git
> a/UnitTestFrameworkPkg/Library/UnitTestLib/AssertCmocka.
> c
> b/UnitTestFrameworkPkg/Library/UnitTestLib/AssertCmocka.
> c
> index e48d614976..687c6243ab 100644
> ---
> a/UnitTestFrameworkPkg/Library/UnitTestLib/AssertCmocka.
> c
> +++
> b/UnitTestFrameworkPkg/Library/UnitTestLib/AssertCmocka.
> c
> @@ -333,3 +333,71 @@ UnitTestAssertNotNull (
>
>    return (Pointer !=3D NULL);
>  }
> +
> +/**
> +  If UnitTestStatus is UNIT_TEST_PASSED, then log an
> info message and
> +return
> +  TRUE because an ASSERT() was expected when
> FunctionCall was executed
> +and an
> +  ASSERT() was triggered. If UnitTestStatus is
> UNIT_TEST_SKIPPED, then
> +log a
> +  warning message and return TRUE because ASSERT()
> macros are disabled.
> +If
> +  UnitTestStatus is UNIT_TEST_ERROR_TEST_FAILED, then
> log an error
> +message and
> +  return FALSE because an ASSERT() was expected when
> FunctionCall was
> +executed,
> +  but no ASSERT() conditions were triggered.  The log
> messages contain
> +  FunctionName, LineNumber, and FileName strings to
> provide the
> +location of the
> +  UT_EXPECT_ASSERT_FAILURE() macro.
> +
> +  @param[in]  UnitTestStatus  The status from
> UT_EXPECT_ASSERT_FAILURE() that
> +           &n= bsp;            = ;      is either pass, skipped,
> or failed.
> +  @param[in]  FunctionName    Null-terminat= ed ASCII
> string of the function
> +           &n= bsp;            = ;      executing the
> UT_EXPECT_ASSERT_FAILURE() macro.
> +  @param[in]  LineNumber      The= source file line
> number of the the function
> +           &n= bsp;            = ;      executing the
> UT_EXPECT_ASSERT_FAILURE() macro.
> +  @param[in]  FileName      =   Null-terminated ASCII
> string of the filename
> +           &n= bsp;            = ;      executing the
> UT_EXPECT_ASSERT_FAILURE() macro.
> +  @param[in]  FunctionCall    Null-terminat= ed ASCII
> string of the function call
> +           &n= bsp;            = ;      executed by the
> UT_EXPECT_ASSERT_FAILURE() macro.
> +  @param[out] ResultStatus    Used to return the=
> UnitTestStatus value to the
> +           &n= bsp;            = ;      caller of
> UT_EXPECT_ASSERT_FAILURE().  This is
> +           &n= bsp;            = ;      optional parameter that
> may be NULL.
> +
> +  @retval  TRUE   UnitTestStatus is UNIT_TEST_PA= SSED.
> +  @retval  TRUE   UnitTestStatus is UNIT_TEST_SK= IPPED.
> +  @retval  FALSE  UnitTestStatus is
> UNIT_TEST_ERROR_TEST_FAILED.
> +**/
> +BOOLEAN
> +EFIAPI
> +UnitTestExpectAssertFailure (
> +  IN  UNIT_TEST_STATUS  UnitTestStatus,
> +  IN  CONST CHAR8       *Fun= ctionName,
> +  IN  UINTN        = ;     LineNumber,
> +  IN  CONST CHAR8       *Fil= eName,
> +  IN  CONST CHAR8       *Fun= ctionCall,
> +  OUT UNIT_TEST_STATUS  *ResultStatus  OPTIONAL
> +  )
> +{
> +  CHAR8  TempStr[MAX_STRING_SIZE];
> +
> +  if (ResultStatus !=3D NULL) {
> +    *ResultStatus =3D UnitTestStatus;
> +  }
> +  if (UnitTestStatus =3D=3D UNIT_TEST_PASSED) {
> +    UT_LOG_INFO (
> +      "[ASSERT PASS] %a:%d:
> UT_EXPECT_ASSERT_FAILURE(%a) detected expected
> assert\n",
> +      FileName,
> +      LineNumber,
> +      FunctionCall
> +      );
> +  }
> +  if (UnitTestStatus =3D=3D UNIT_TEST_SKIPPED) {
> +    UT_LOG_WARNING (
> +      "[ASSERT WARN] %a:%d:
> UT_EXPECT_ASSERT_FAILURE(%a) disabled\n",
> +      FileName,
> +      LineNumber,
> +      FunctionCall
> +      );
> +  }
> +  if (UnitTestStatus =3D=3D UNIT_TEST_ERROR_TEST_FAILED) {
> +    snprintf (TempStr, sizeof(TempStr),
> "UT_EXPECT_ASSERT_FAILURE(%s) did not trigger ASSERT()", > FunctionCall);
> +    _assert_true (FALSE, TempStr, FileName,
> (INT32)LineNumber);
> +  }
> +  return (UnitTestStatus !=3D
> UNIT_TEST_ERROR_TEST_FAILED); }
> diff --git
> a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> index 793335fd0f..2dc1d159d5 100644
> ---
> a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> +++
> b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> @@ -14,6 +14,8 @@
>
>  STATIC UNIT_TEST_FRAMEWORK_HANDLE  mFrameworkHandle =3D > NULL;
>
> +BASE_LIBRARY_JUMP_BUFFER  gUnitTestJumpBuffer;
> +
>  UNIT_TEST_FRAMEWORK_HANDLE
>  GetActiveFrameworkHandle (
>    VOID
> @@ -75,7 +77,14 @@ RunTestSuite (
>      // Next, if we're still running, make s= ure that our
> test prerequisites are in place.
>      if (Test->Result =3D=3D UNIT_TEST_PE= NDING && Test-
> >Prerequisite !=3D NULL) {
>        DEBUG ((DEBUG_VERBOSE, &quo= t;PREREQ\n"));
> -      if (Test->Prerequisite (Test->C= ontext) !=3D
> UNIT_TEST_PASSED) {
> +      if (SetJump (&gUnitTestJumpBuffer= ) =3D=3D 0) {
> +        if (Test->Prerequisite= (Test->Context) !=3D
> UNIT_TEST_PASSED) {
> +          DEBUG ((DEBUG= _ERROR, "Prerequisite Not
> Met\n"));
> +          Test->Resu= lt =3D
> UNIT_TEST_ERROR_PREREQUISITE_NOT_MET;
> +          ParentFramewo= rk->CurrentTest  =3D NULL;
> +          continue;
> +        }
> +      } else {
>          DEBUG ((DEBUG_E= RROR, "Prerequisite Not
> Met\n"));
>          Test->Result= =3D
> UNIT_TEST_ERROR_PREREQUISITE_NOT_MET;
>          ParentFramework= ->CurrentTest  =3D NULL; @@ -88,14
> +97,20 @@ RunTestSuite (
>      // We set the status to UNIT_TEST_RUNNI= NG in case
> the test needs to reboot
>      // or quit. The UNIT_TEST_RUNNING state= will allow
> the test to resume
>      // but will prevent the Prerequisite fr= om being
> dispatched a second time.
> -    Test->Result =3D UNIT_TEST_RUNNING;
> -    Test->Result =3D Test->RunTest (Test->Co= ntext);
> +    if (SetJump (&gUnitTestJumpBuffer) =3D=3D 0) = {
> +      Test->Result =3D UNIT_TEST_RUNNING= ;
> +      Test->Result =3D Test->RunTest = (Test->Context);
> +    } else {
> +      Test->Result =3D UNIT_TEST_ERROR_T= EST_FAILED;
> +    }
>
>      //
>      // Finally, clean everything up, if nee= d be.
>      if (Test->CleanUp !=3D NULL) {
>        DEBUG ((DEBUG_VERBOSE, &quo= t;CLEANUP\n"));
> -      Test->CleanUp (Test->Context);<= br> > +      if (SetJump (&gUnitTestJumpBuffer= ) =3D=3D 0) {
> +        Test->CleanUp (Test-&g= t;Context);
> +      }
>      }
>
>      //
> diff --git
> a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/U
> nitTestResultReportLib.c
> b/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/U
> nitTestResultReportLib.c
> index eba68e330c..66c9db457d 100644
> ---
> a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/U
> nitTestResultReportLib.c
> +++
> b/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/U
> nitTestResul
> +++ tReportLib.c
> @@ -49,7 +49,8 @@ struct _UNIT_TEST_FAILURE_TYPE_STRING
> mFailureTypeStrings[] =3D {
>    { FAILURETYPE_ASSERTNOTEQUAL,    &qu= ot;ASSERT_NOTEQUAL
> FAILURE"},
>    { FAILURETYPE_ASSERTNOTEFIERROR, "ASSERT_NOTEF= IERROR
> FAILURE"},
>    { FAILURETYPE_ASSERTSTATUSEQUAL, "ASSERT_STATU= SEQUAL
> FAILURE"},
> -  { FAILURETYPE_ASSERTNOTNULL ,    "ASSERT_= NOTNULL
> FAILURE"},
> +  { FAILURETYPE_ASSERTNOTNULL,     "AS= SERT_NOTNULL
> FAILURE"},
> +  { FAILURETYPE_EXPECTASSERT,      &qu= ot;EXPECT_ASSERT
> FAILURE"},
>    { 0,        = ;            &n= bsp;        "*UNKNOWN* Failure"= ;}
>  };
>
> diff --git
> a/UnitTestFrameworkPkg/PrivateInclude/UnitTestFrameworkT
> ypes.h
> b/UnitTestFrameworkPkg/PrivateInclude/UnitTestFrameworkT
> ypes.h
> index e58b30093e..b0e2f61bbf 100644
> ---
> a/UnitTestFrameworkPkg/PrivateInclude/UnitTestFrameworkT
> ypes.h
> +++
> b/UnitTestFrameworkPkg/PrivateInclude/UnitTestFrameworkT
> ypes.h
> @@ -44,6 +44,7 @@ typedef UINT32 FAILURE_TYPE;
>  #define FAILURETYPE_ASSERTNOTEFIERROR    (6)
>  #define FAILURETYPE_ASSERTSTATUSEQUAL    (7)
>  #define FAILURETYPE_ASSERTNOTNULL     =    (8)
> +#define FAILURETYPE_EXPECTASSERT      =    (9)
>
>  ///
>  /// Unit Test context structure tracked by the unit
> test framework.
> diff --git
> a/UnitTestFrameworkPkg/Test/UnitTestFrameworkPkgHostTest
> .dsc
> b/UnitTestFrameworkPkg/Test/UnitTestFrameworkPkgHostTest
> .dsc
> index 701e7299d7..70affddead 100644
> ---
> a/UnitTestFrameworkPkg/Test/UnitTestFrameworkPkgHostTest
> .dsc
> +++
> b/UnitTestFrameworkPkg/Test/UnitTestFrameworkPkgHostTest
> .dsc
> @@ -25,7 +25,7 @@ [Components]
>
> UnitTestFrameworkPkg/Test/UnitTest/Sample/SampleUnitTest
> /SampleUnitTestHost.inf
>
>    #
> -  # Build Libraries
> +  # Build HOST_APPLICATION Libraries
>    #
>    UnitTestFrameworkPkg/Library/CmockaLib/CmockaLib.in= f
>
> UnitTestFrameworkPkg/Library/Posix/DebugLibPosix/DebugLi
> bPosix.inf
> diff --git
> a/UnitTestFrameworkPkg/UnitTestFrameworkPkg.dsc
> b/UnitTestFrameworkPkg/UnitTestFrameworkPkg.dsc
> index 2d84691bf1..0dfd98f2a8 100644
> --- a/UnitTestFrameworkPkg/UnitTestFrameworkPkg.dsc
> +++ b/UnitTestFrameworkPkg/UnitTestFrameworkPkg.dsc
> @@ -28,6 +28,7 @@ [Components]
>
> UnitTestFrameworkPkg/Library/UnitTestResultReportLib/Uni
> tTestResultReportLibConOut.inf
>
> UnitTestFrameworkPkg/Library/UnitTestBootLibUsbClass/Uni
> tTestBootLibUsbClass.inf
>
> UnitTestFrameworkPkg/Library/UnitTestPersistenceLibSimpl
> eFileSystem/UnitTestPersistenceLibSimpleFileSystem.inf
> +
> +
> UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/Unit
> TestDebugAsser
> + tLib.inf
>
>
> UnitTestFrameworkPkg/Test/UnitTest/Sample/SampleUnitTest
> /SampleUnitTestDxe.inf
>
> UnitTestFrameworkPkg/Test/UnitTest/Sample/SampleUnitTest
> /SampleUnitTestPei.inf
> diff --git
> a/UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.in
> c
> b/UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.in
> c
> index 0881278ab0..8adf690098 100644
> ---
> a/UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.in
> c
> +++
> b/UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.in
> c
> @@ -29,6 +29,7 @@ [LibraryClasses]
>
> UnitTestLib|UnitTestFrameworkPkg/Library/UnitTestLib/Uni
> tTestLib.inf
>
> UnitTestPersistenceLib|UnitTestFrameworkPkg/Library/Unit
> TestPersistenceLibNull/UnitTestPersistenceLibNull.inf
>
> UnitTestResultReportLib|UnitTestFrameworkPkg/Library/Uni
> tTestResultReportLib/UnitTestResultReportLibDebugLib.inf
> +
> +
> NULL|UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib
> /UnitTestDebug
> + AssertLib.inf
>
>  [LibraryClasses.ARM, LibraryClasses.AARCH64]
>    #
> @@ -56,5 +57,6 @@ [PcdsFixedAtBuild]
>    gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17<= br> >
>  [BuildOptions]
> -  MSFT:*_*_*_CC_FLAGS =3D -D
> DISABLE_NEW_DEPRECATED_INTERFACES
> -  GCC:*_*_*_CC_FLAGS  =3D -D
> DISABLE_NEW_DEPRECATED_INTERFACES
> +  MSFT:*_*_*_CC_FLAGS  =3D -D
> DISABLE_NEW_DEPRECATED_INTERFACES -D
> EDKII_UNIT_TEST_FRAMEWORK_ENABLED
> +  GCC:*_*_*_CC_FLAGS   =3D -D
> DISABLE_NEW_DEPRECATED_INTERFACES -D
> EDKII_UNIT_TEST_FRAMEWORK_ENABLED
> +  XCODE:*_*_*_CC_FLAGS =3D -D
> DISABLE_NEW_DEPRECATED_INTERFACES -D
> + EDKII_UNIT_TEST_FRAMEWORK_ENABLED
> --
> 2.21.0.windows.1
>
>
>


 

--_000_CY4PR21MB07435EFDDF21A2668654F201EF7E0CY4PR21MB0743namp_--