From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id E3FAA7803DE for ; Mon, 12 Feb 2024 16:25:34 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=SxZS9+Uz2Z15wQ/d0BWOras3lMOXgzPW3SkSraHTsfU=; c=relaxed/simple; d=groups.io; h=DKIM-Filter:Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1707755133; v=1; b=WBM1uBENQpdovtT3UfttZOX0dJgEK0KNrK6loCZAa1q53rjIHL1RcqJcfl0aOh/1osS/lDAb UOPTMtj9n/Cfqp4AQI8dTHRk4N0f8IkNTpVjwGlxQxBUgj9Z8wz+ho6OzVPzQDtKFFR48oRWzba H3B3dfv6zvCVbjj58l5zivyQ= X-Received: by 127.0.0.2 with SMTP id l18sYY7687511xVmp35xP62Z; Mon, 12 Feb 2024 08:25:33 -0800 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web10.10583.1707755133179124060 for ; Mon, 12 Feb 2024 08:25:33 -0800 X-Received: from [10.0.0.154] (unknown [20.39.63.12]) by linux.microsoft.com (Postfix) with ESMTPSA id 82D5B20B2000; Mon, 12 Feb 2024 08:25:32 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 82D5B20B2000 Message-ID: <27f5ef37-069c-48dc-be7d-14f1236b2483@linux.microsoft.com> Date: Mon, 12 Feb 2024 11:25:32 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [edk2-stable202402][Patch V3 4/7] UnitTestFrameworkPkg/UnitTestLib: GetActiveFrameworkHandle() no ASSERT() To: devel@edk2.groups.io, michael.d.kinney@intel.com Cc: Sean Brogan References: <20240209203253.488-1-michael.d.kinney@intel.com> <20240209203253.488-5-michael.d.kinney@intel.com> From: "Michael Kubacki" In-Reply-To: <20240209203253.488-5-michael.d.kinney@intel.com> Precedence: Bulk List-Subscribe: List-Help: 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,mikuback@linux.microsoft.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: TMvX7liCIMrlCGJ8rhRu8HE2x7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=WBM1uBEN; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=linux.microsoft.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Reviewed-by: Michael Kubacki On 2/9/2024 3:32 PM, Michael D Kinney wrote: > Update GetActiveFrameworkHandle() to remove ASSERT() and require > caller to check for NULL. >=20 > This allows GetActiveFrameworkHandle() to be used to determine if the > current host-based test environment is framework/cmocka or gtest. In > the framework/cmocka host-based environment GetActiveFrameworkHandle() > returns non-NULL. In the gtest host-based environment > GetActiveFrameworkHandle() returns NULL. >=20 > Cc: Michael Kubacki > Cc: Sean Brogan > Signed-off-by: Michael D Kinney > --- > UnitTestFrameworkPkg/Library/UnitTestLib/Assert.c | 4 ++++ > UnitTestFrameworkPkg/Library/UnitTestLib/Log.c | 4 ++++ > UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c | 1 - > UnitTestFrameworkPkg/Library/UnitTestLib/RunTestsCmocka.c | 1 - > UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c | 4 ++++ > 5 files changed, 12 insertions(+), 2 deletions(-) >=20 > diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/Assert.c b/UnitTest= FrameworkPkg/Library/UnitTestLib/Assert.c > index 35636565b783..53cb71f61065 100644 > --- a/UnitTestFrameworkPkg/Library/UnitTestLib/Assert.c > +++ b/UnitTestFrameworkPkg/Library/UnitTestLib/Assert.c > @@ -57,6 +57,10 @@ UnitTestLogFailure ( > // Get active Framework handle > // > FrameworkHandle =3D GetActiveFrameworkHandle (); > + if (FrameworkHandle =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a - FrameworkHandle not initialized\n", __fun= c__)); > + return; > + } > =20 > // > // Convert the message to an ASCII String > diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/Log.c b/UnitTestFra= meworkPkg/Library/UnitTestLib/Log.c > index 19eb8ee0db6e..f61b9d57b10a 100644 > --- a/UnitTestFrameworkPkg/Library/UnitTestLib/Log.c > +++ b/UnitTestFrameworkPkg/Library/UnitTestLib/Log.c > @@ -166,6 +166,10 @@ UnitTestLog ( > VA_LIST Marker; > =20 > FrameworkHandle =3D GetActiveFrameworkHandle (); > + if (FrameworkHandle =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a - FrameworkHandle not initialized\n", __fun= c__)); > + return; > + } > =20 > LogTypePrefix =3D NULL; > =20 > diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c b/UnitTe= stFrameworkPkg/Library/UnitTestLib/RunTests.c > index 9bc743ca8ec0..dc1b6147d2f4 100644 > --- a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c > +++ b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c > @@ -21,7 +21,6 @@ GetActiveFrameworkHandle ( > VOID > ) > { > - ASSERT (mFrameworkHandle !=3D NULL); > return mFrameworkHandle; > } > =20 > diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTestsCmocka.c b/= UnitTestFrameworkPkg/Library/UnitTestLib/RunTestsCmocka.c > index ca4dae120690..f24b65174c5c 100644 > --- a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTestsCmocka.c > +++ b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTestsCmocka.c > @@ -27,7 +27,6 @@ GetActiveFrameworkHandle ( > VOID > ) > { > - ASSERT (mFrameworkHandle !=3D NULL); > return mFrameworkHandle; > } > =20 > diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c b/Uni= tTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c > index 322ea15b1575..3e3a850af125 100644 > --- a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c > +++ b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c > @@ -826,6 +826,10 @@ SaveFrameworkState ( > =20 > Header =3D NULL; > FrameworkHandle =3D GetActiveFrameworkHandle (); > + if (FrameworkHandle =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a - Could not save state! FrameworkHandle not= initialized\n", __func__)); > + return EFI_DEVICE_ERROR; > + } > =20 > // > // Return a unique error code if the framework is not set. -=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 (#115356): https://edk2.groups.io/g/devel/message/115356 Mute This Topic: https://groups.io/mt/104267259/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-