From nobody Tue Nov 26 03:49:31 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+62287+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+62287+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1594267541; cv=none; d=zohomail.com; s=zohoarc; b=jKYUQarG/ClXpHayfamDL2E5MbgDRXGtDeemQui5fB7eUqGqsAvMr3ewLIdRc8koqoLC6S9qB+k2JySxyAJH/T+Qbof1JEBfT86XDvB/tefixtAle3mWmpUB+WCp36M/eNLHoQ8/kVUIe9wvii1quK1yGa6tHNwH6AHMIaA0ifw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594267541; 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=tlQwcyYc9wWQtSErelKrd8ml5gN5LX5C9DivsWvvFgQ=; b=hQ+NX4nRlWF7fg1smjvWSQWb0JbC3955AKbZJVwomUeVbWpZH0PWObYImNDOvsxXYsdfWzU3EXKV1C7L4Bb8qLUXr93fKWrceXQZpNm5tlp6o6i69FO5OSznjDFrRHclpxae53/5iIDxC0f11V9mkePnxZplJkGOaK/t1nPbVAU= 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+62287+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 1594267541711412.2937225898381; Wed, 8 Jul 2020 21:05:41 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id weiTYY1788612xtpQv977Cmx; Wed, 08 Jul 2020 21:05:41 -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:39 -0700 IronPort-SDR: 72olhMYgJbMFt+OyqCItM0fOh9+EO2EWuJceH0fQiNdfLnsq3n2RODDk0cVlswWgizODuWnCwR lBy4gmEPB+yw== X-IronPort-AV: E=McAfee;i="6000,8403,9676"; a="212851108" X-IronPort-AV: E=Sophos;i="5.75,330,1589266800"; d="scan'208";a="212851108" 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:39 -0700 IronPort-SDR: ZLtppSh0GJQ7mCFHwkAcDKso1prlVrrk/UFwvYb+Dst4z5o75rvhCS5QuhenMuKPqoBVOVqPVZ 0lW549ZSLpKw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,330,1589266800"; d="scan'208";a="280163942" 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:38 -0700 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Sean Brogan , Bret Barkelew , Jiewen Yao Subject: [edk2-devel] [Patch v2 10/16] UnitTestFrameworkPkg/UnitTestLib: Move print log into cleanup Date: Wed, 8 Jul 2020 21:05:15 -0700 Message-Id: <20200709040521.3748-11-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: YbYsNGl3GX2ciVvTZkIKDwvYx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1594267541; bh=/1KINz3ejiVmknu4uH8YENdWEWBM0y4CST+ipCtkm1E=; h=Cc:Date:From:Reply-To:Subject:To; b=KtFKpfYiZSG1Bs6WvE5Lvuz4xwvd44J+w+FlW7WS/4rgx8GPkDxnzY4TGNza1O+cN9P MiDGHi3hDCuO+DCkRkfDD4N8MnZe35VMlygb/v5Ufagh+m9sgzOl8kRtplGI32LZIELB0 8+NGArNK1CYU8sFFyeCQ8ugCN8nb7QTPLvI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2805 If a unit test fails with an exception or an assert, then the CmockaUnitTestFunctionRunner() is terminated and the logic that follows the invocation of the unit test is skipped. This currently skips the logic that prints log messages. Move the print of log messages to the end of the function CmockaUnitTestTeardownFunctionRunner() that is guaranteed to be executed when a unit test completes normally or is terminated with an exception or an assert. Cc: Sean Brogan Cc: Bret Barkelew Cc: Jiewen Yao Signed-off-by: Michael D Kinney --- .../Library/UnitTestLib/RunTestsCmocka.c | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTestsCmocka.c b/Un= itTestFrameworkPkg/Library/UnitTestLib/RunTestsCmocka.c index fb81cc9658..96aa4d9b13 100644 --- a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTestsCmocka.c +++ b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTestsCmocka.c @@ -53,21 +53,9 @@ CmockaUnitTestFunctionRunner ( UnitTest->Result =3D UNIT_TEST_SKIPPED; } else { UnitTest->Result =3D UNIT_TEST_RUNNING; - Framework->CurrentTest =3D UnitTest; UnitTest->Result =3D UnitTest->RunTest (UnitTest->Context); Framework->CurrentTest =3D NULL; - - // Print out the log messages - This is a partial solution as it - // does not get the log into the XML. Need cmocka changes to support - // stdout and stderr in their xml format - // - if (UnitTest->Log !=3D NULL) { - print_message("UnitTest: %s - %s\n", UnitTest->Name, UnitTest->Descr= iption); - print_message("Log Output Start\n"); - print_message("%s", UnitTest->Log); - print_message("Log Output End\n"); - } } } =20 @@ -112,13 +100,24 @@ CmockaUnitTestTeardownFunctionRunner ( Suite =3D (UNIT_TEST_SUITE *)(UnitTest->ParentSuite); Framework =3D (UNIT_TEST_FRAMEWORK *)(Suite->ParentFramework); =20 - if (UnitTest->CleanUp =3D=3D NULL) { - return 0; + if (UnitTest->CleanUp !=3D NULL) { + Framework->CurrentTest =3D UnitTest; + UnitTest->CleanUp (UnitTest->Context); + Framework->CurrentTest =3D NULL; + } + + // + // Print out the log messages - This is a partial solution as it + // does not get the log into the XML. Need cmocka changes to support + // stdout and stderr in their xml format + // + if (UnitTest->Log !=3D NULL) { + print_message("UnitTest: %s - %s\n", UnitTest->Name, UnitTest->Descrip= tion); + print_message("Log Output Start\n"); + print_message("%s", UnitTest->Log); + print_message("Log Output End\n"); } =20 - Framework->CurrentTest =3D UnitTest; - UnitTest->CleanUp (UnitTest->Context); - Framework->CurrentTest =3D NULL; // // Return 0 for success. Non-zero for error. // --=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 (#62287): https://edk2.groups.io/g/devel/message/62287 Mute This Topic: https://groups.io/mt/75391617/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-