From nobody Tue Nov 26 02:46:57 2024 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+62290+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+62290+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1594267543; cv=none; d=zohomail.com; s=zohoarc; b=JW5ksYFLcv5nS3Bb9862jEb61rVV1Dxj6xr79o6QbK3NVsmXi9pmnuQO3dZd9me0bOYWcrl91Zj9JcwUxmB8RR3aSFRf6P74INjqHodswbuiRH8zk+EJ2FSXV/LIk5X+HcsTgniRQ3CoO0BLq4HCEswJVaFujydIMWX2JrIES2w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594267543; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=/aDsAPJreBNlz2787ARC8jOqscLuWeqkS+JZ/cjrFUg=; b=A3UU82bv2MDfor/LfCBkTZ1H38jd9Un25jQLx5N+VoQJnDwPLkSQ9LczNZnfSHqLjMWWKq01f/p+CMIgSQElzinWVthnUojbhJki8oGd6qw+lMaBzOo43aDjiIMGXvGtmgRpY7vr0RkWYs/27I/IWuxLKkgQJWx86c7kc82Thcg= 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+62290+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 1594267543089463.5609997170834; Wed, 8 Jul 2020 21:05:43 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id S5vpYY1788612xmzkkNDscCX; Wed, 08 Jul 2020 21:05:42 -0700 X-Received: from mga07.intel.com (mga07.intel.com []) by mx.groups.io with SMTP id smtpd.web11.4378.1594267536731145998 for ; Wed, 08 Jul 2020 21:05:41 -0700 IronPort-SDR: s6lFKaHCDmICmAuBgIjYChlPfqW6bqHEM14iV6NsGrq8mfliBcJzrfbqM1KmBOwHSkhEG1MPa/ Xg4UnG8bz8uQ== X-IronPort-AV: E=McAfee;i="6000,8403,9676"; a="212851121" X-IronPort-AV: E=Sophos;i="5.75,330,1589266800"; d="scan'208";a="212851121" 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; 08 Jul 2020 21:05:41 -0700 IronPort-SDR: MRfoT/4exqnYfaGw130KUfX5hF9d+Ufmcr/YW6agTjYRUgVjNOE/GXU3cOwuNWovDcpDbi8PFW 8QTNkKJUGKOg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,330,1589266800"; d="scan'208";a="280163957" X-Received: from mdkinney-mobl2.amr.corp.intel.com ([10.255.230.8]) by orsmga003.jf.intel.com with ESMTP; 08 Jul 2020 21:05:40 -0700 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Liming Gao , Sean Brogan , Bret Barkelew , Jiewen Yao Subject: [edk2-devel] [Patch v2 13/16] MdePkg/Include: Hook DebugLib _ASSERT() for unit tests Date: Wed, 8 Jul 2020 21:05:18 -0700 Message-Id: <20200709040521.3748-14-michael.d.kinney@intel.com> In-Reply-To: <20200709040521.3748-1-michael.d.kinney@intel.com> References: <20200709040521.3748-1-michael.d.kinney@intel.com> MIME-Version: 1.0 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,michael.d.kinney@intel.com X-Gm-Message-State: jAgHpRoiZDRkQ2qH2p5VLPstx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1594267542; bh=K8Vh9m9SWQBp4d+Ll3mgLxFqn8uMDOehjWj3J82PWFY=; h=Cc:Date:From:Reply-To:Subject:To; b=xJSBNcIjkLKk4Pe47do8Z+QMjsEU4JMzE484RA4AhyH1ClC04oit3I1sLF+mGR7mj72 n5NrBqvPHoAmNyl6fvjYn5FpF5jHPPeGQic/bbtQoQ9A7xxwj8TC3nAwEcM0/4LjJrclW TApoDaChrIeXIsghUVjYql39gaK23RJ42fY= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2801 Update DebugLib.h _ASSERT() macro to check if unit testing is enabled and call UnitTestDebugAssert() instead of DebugAssert() so the an ASSERT() condition that is triggered by a function under test can be handled by the Unit Test Framework. If EDKII_UNIT_TEST_FRAMEWORK_ENABLED is not defined, then the existing DebugLib behavior is preserved. Cc: Liming Gao Cc: Sean Brogan Cc: Bret Barkelew Cc: Jiewen Yao Signed-off-by: Michael D Kinney --- MdePkg/Include/Library/DebugLib.h | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/Deb= ugLib.h index baab34bf05..4cacd4b8e2 100644 --- a/MdePkg/Include/Library/DebugLib.h +++ b/MdePkg/Include/Library/DebugLib.h @@ -289,12 +289,38 @@ DebugPrintLevelEnabled ( @param Expression Boolean expression that evaluated to FALSE =20 **/ +#if defined (EDKII_UNIT_TEST_FRAMEWORK_ENABLED) +/** + Unit test library replacement for DebugAssert() in DebugLib. + + If FileName is NULL, then a string of "(NULL) Filename" is pr= inted. + If Description is NULL, then a string of "(NULL) Descripti= on" is printed. + + @param FileName The pointer to the name of the source file that gen= erated the assert condition. + @param LineNumber The line number in the source file that generated t= he assert condition + @param Description The pointer to the description of the assert condit= ion. + +**/ +VOID +EFIAPI +UnitTestDebugAssert ( + IN CONST CHAR8 *FileName, + IN UINTN LineNumber, + IN CONST CHAR8 *Description + ); + +#if defined(__clang__) && defined(__FILE_NAME__) +#define _ASSERT(Expression) UnitTestDebugAssert (__FILE_NAME__, __LINE__,= #Expression) +#else +#define _ASSERT(Expression) UnitTestDebugAssert (__FILE__, __LINE__, #Exp= ression) +#endif +#else #if defined(__clang__) && defined(__FILE_NAME__) #define _ASSERT(Expression) DebugAssert (__FILE_NAME__, __LINE__, #Expres= sion) #else #define _ASSERT(Expression) DebugAssert (__FILE__, __LINE__, #Expression) #endif - +#endif =20 /** Internal worker macro that calls DebugPrint(). --=20 2.21.0.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 (#62290): https://edk2.groups.io/g/devel/message/62290 Mute This Topic: https://groups.io/mt/75391620/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-