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 5A35374003C for ; Fri, 9 Feb 2024 20:33:06 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=Q9kzfhJFeTKCSwVmqLHvYHfSIrLqIi8SH+SVHBGDTks=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1707510785; v=1; b=C3F0xbDkvU1pX6fMHpYwroDSo8+yzFBM45b/NlPIlKqttLUgprBul86a8i7GFX22cKWpaX+3 K8GSUP2fytrkGnAE4Dpx0rEzHgb3gFQGnuPxmNWf1JYWwfqJ7wjDdjLtiaWNPgojzlnNLCgmLlE XyZvXn0KovuLOuQb25w2GEG0= X-Received: by 127.0.0.2 with SMTP id T66eYY7687511xXy7L8Wtml1; Fri, 09 Feb 2024 12:33:05 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by mx.groups.io with SMTP id smtpd.web11.23458.1707510780426267029 for ; Fri, 09 Feb 2024 12:33:01 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10979"; a="1392556" X-IronPort-AV: E=Sophos;i="6.05,257,1701158400"; d="scan'208";a="1392556" X-Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2024 12:33:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,257,1701158400"; d="scan'208";a="6670660" X-Received: from mdkinney-mobl.amr.corp.intel.com ([10.209.59.192]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2024 12:33:00 -0800 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Michael Kubacki , Sean Brogan Subject: [edk2-devel] [edk2-stable202402][Patch V3 4/7] UnitTestFrameworkPkg/UnitTestLib: GetActiveFrameworkHandle() no ASSERT() Date: Fri, 9 Feb 2024 12:32:50 -0800 Message-Id: <20240209203253.488-5-michael.d.kinney@intel.com> In-Reply-To: <20240209203253.488-1-michael.d.kinney@intel.com> References: <20240209203253.488-1-michael.d.kinney@intel.com> MIME-Version: 1.0 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,michael.d.kinney@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: aoGxt3Hlm1Q8r5K25kNdli8jx7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=C3F0xbDk; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.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 Update GetActiveFrameworkHandle() to remove ASSERT() and require caller to check for NULL. 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. 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(-) diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/Assert.c b/UnitTestFrameworkPkg/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 = GetActiveFrameworkHandle (); + if (FrameworkHandle == NULL) { + DEBUG ((DEBUG_ERROR, "%a - FrameworkHandle not initialized\n", __func__)); + return; + } // // Convert the message to an ASCII String diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/Log.c b/UnitTestFrameworkPkg/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; FrameworkHandle = GetActiveFrameworkHandle (); + if (FrameworkHandle == NULL) { + DEBUG ((DEBUG_ERROR, "%a - FrameworkHandle not initialized\n", __func__)); + return; + } LogTypePrefix = NULL; diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c b/UnitTestFrameworkPkg/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 != NULL); return mFrameworkHandle; } 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 != NULL); return mFrameworkHandle; } diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c b/UnitTestFrameworkPkg/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 ( Header = NULL; FrameworkHandle = GetActiveFrameworkHandle (); + if (FrameworkHandle == NULL) { + DEBUG ((DEBUG_ERROR, "%a - Could not save state! FrameworkHandle not initialized\n", __func__)); + return EFI_DEVICE_ERROR; + } // // Return a unique error code if the framework is not set. -- 2.40.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#115327): https://edk2.groups.io/g/devel/message/115327 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] -=-=-=-=-=-=-=-=-=-=-=-