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.111]) by mx.groups.io with SMTP id smtpd.web11.231.1594786025150604282 for ; Tue, 14 Jul 2020 21:07:05 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=IIJPJdct; spf=pass (domain: microsoft.com, ip: 40.107.243.111, mailfrom: bret.barkelew@microsoft.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eXp4BE9dp6gO5bwgyuA5dozrm+8b0KsyB5TuiSaywagPXuQogzJ3byFXtLYAMSFGZblDTKwYPEbuNjxDnGNDqxCLgeA7m1DNvmcu6zvzYXymaliEQ66l0gr9rbqEQEIt0o28WYPotCZRGYDsVQlZDuuLD/KkpTZYD3DibJRVMLo45mUmYcIAzp9QBhL796O1HbnMFFbViovF0DWRSHJPGoCZsEukGH6tAknzHgAk8gJ1Ffam1NKpZ8mERfKoa1zzIWXLEKgClAwXBePXe7fHXkGAOux7QZoN8uGu9tfyVd48UqmbA5tpzH5WdyBjYEbE6qWrQWbKl7uNFbWysoyamA== 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=Jy2qFl+/kR0H/dbBXPyTr6Njm7QQVPQfaScxgDBW/xU=; b=lZvJyjyZix4d1zg9MXehN0W3NhtiRUjsihlYb2PuEj4hmlPf967d4sbglBj5hIk9aC+TpwEORXG5YmqYlvC4TRax+WE98mhyLxJuMe8ppWz//pbDEMEF2POM9PI34ycar5ThheC5BXaVlrItRL4jFd49I26ylAoquDRDYclr0Mt3EQdKWUkvvamA1D9Cy/lEcMQqv2Ndxj9fFU70rvWSQPgHW7F8kp1fe27uTYe7EdkR4MrFV1KHkUAHGuwrhJLKS+ESSTajF3Q/1fprm4+2Ef6qTldwaZNnRDv5EqzK9uA95/UPYLpEtPpNaVvZbEc+arXFxBq8PjzfL/NCwSKfiA== 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=Jy2qFl+/kR0H/dbBXPyTr6Njm7QQVPQfaScxgDBW/xU=; b=IIJPJdctjve5mDTpa+f/OIqEvFat1aCBNuA+AMjZd/fRWa3XoNgSXgJrm/g79x6CBFrLnViMH6cLHFIXmQwFFjmANQQ0iWlLBWFImDhiAkX8PVCKRkAHG2b6me1dZZNwNHmB5RpPunGiDr5bYo3YoASXmZQH51aK6C4t41eYy/s= 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:07:03 +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:07:03 +0000 From: "Bret Barkelew" To: "Kinney, Michael D" , "devel@edk2.groups.io" CC: Sean Brogan , "Yao, Jiewen" Subject: Re: [EXTERNAL] [Patch v3 10/16] UnitTestFrameworkPkg/UnitTestLib: Move print log into cleanup Thread-Topic: [EXTERNAL] [Patch v3 10/16] UnitTestFrameworkPkg/UnitTestLib: Move print log into cleanup Thread-Index: AQHWVyhKewTqs3nlL0qIDt43iLTR9akIDHUo Date: Wed, 15 Jul 2020 04:07:03 +0000 Message-ID: References: <20200711020904.24116-1-michael.d.kinney@intel.com>,<20200711020904.24116-11-michael.d.kinney@intel.com> In-Reply-To: <20200711020904.24116-11-michael.d.kinney@intel.com> 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:59.1602959Z;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Privileged authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; 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: a9ade3f4-0290-4805-4c03-08d828748824 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:1388; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 4Opvgwa8kKtmCb07yXzy5y08ae7BiOtOd3cA5gLtaUZ8IYZl/7qpjTqtdy5Fm7LZFwUZouc53ZGPPXhMrmBTxLt/LnnOoGUnqqFfT3zQuLC8Rm0R/6Wj9eY8aQIdr85DrP+zcHpTJKGy9Og5LFjSFZKknK1cwVOh9xwirGA07iRpDf3TOe7VXrvZ7AdQwKw89mw+6NQ8pAkuVDrlts22NP8RuqSAVNXTfxDPStQ5VVnB7AIWdFzW/DD5INyNXf26IrG9W1NQMl2sUZKFoDmh7cserGdW1qTL1Hc81qKbstWqzJLxwwAcCLj+MK+TRWTxVV9ze1uhv6qsAgt3nuIL2vX3SU9ZWpMokqvugqLe3W1C1M/3rKrRD3W+D3uqTnf6W8Ga4WeaZDoNQhd1JZ9IIQ== 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)(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);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: 1EaExq+3uJ7YyfvUiH3OeTz4PsTasYcE7W7KNPj79EGIU53JR/ScvXywAyegnQ5w3fy0IZrPHPAF4UTqTkIpmGWEV0bktTVS1kRNZLZgF7HIcAar3AaSU4EEwI2a57J7hgqBBaZmU2zknty48lu07z+scQTCiWKXqbwTvxQVjs05tEQzJd8v9lZKcimEx0Jyb8T78hutj33BCbfRpyBlcnDRgFoRv11lwr2VYUsfmQpGa7zEbFhmR0KjzeMZkyUoNq13kRLci2UFgMOn8LhWqowtIzeyoweRDd+T/rzVsYEe6g0GNF80oc8rsVGT0ksPn06E+NdjR9bKwJCXMNKUWlMhsXePKiDBE11QJ/vmnR7mxc5NANP6Hyj5EJjNO8+nx2LEWdPKdmRBtc+YIHYOPKjD/INp6ldZf8MA575lxLmuMH9thdSbWLL8IWWYTDxijps4McZ8HJyYtrT7w7zbAgyMEebHi5WAkfegfFu0xmw= 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: a9ade3f4-0290-4805-4c03-08d828748824 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jul 2020 04:07:03.6643 (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: hjEwnMPocBSk+puxvLhbr5GNcxMcMEL4bjyWb9H8r28Y0z3hT+654OFdB/PrtJxNhf3XiXRM1aSgNGro7XvNjA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR21MB0504 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_CY4PR21MB074399E01259AC013203EA39EF7E0CY4PR21MB0743namp_" --_000_CY4PR21MB074399E01259AC013203EA39EF7E0CY4PR21MB0743namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Bret Barkelew - Bret From: Michael D Kinney Sent: Friday, July 10, 2020 7:09 PM To: devel@edk2.groups.io Cc: Sean Brogan; Bret Barkelew; Yao, Jiewen Subject: [EXTERNAL] [Patch v3 10/16] UnitTestFrameworkPkg/UnitTestLib: Move= print log into cleanup REF: https://nam06.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fbu= gzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2805&data=3D02%7C01%7CBret.B= arkelew%40microsoft.com%7C0e54105ccc5b453f790508d8253f690e%7C72f988bf86f141= af91ab2d7cd011db47%7C1%7C0%7C637300301563150384&sdata=3DOY4xwl9Ecv%2F0S= JyzzqBUGNxTi1E%2F8Ax70I6jF2dA6cA%3D&reserved=3D0 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"); - } } } @@ -112,13 +100,24 @@ CmockaUnitTestTeardownFunctionRunner ( Suite =3D (UNIT_TEST_SUITE *)(UnitTest->ParentSuite); Framework =3D (UNIT_TEST_FRAMEWORK *)(Suite->ParentFramework); - 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"); } - Framework->CurrentTest =3D UnitTest; - UnitTest->CleanUp (UnitTest->Context); - Framework->CurrentTest =3D NULL; // // Return 0 for success. Non-zero for error. // -- 2.21.0.windows.1 --_000_CY4PR21MB074399E01259AC013203EA39EF7E0CY4PR21MB0743namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Reviewed-by: Bret Barkelew <bret.barkelew@microso= ft.com>

 

 

- Bret

 

From: Michael D Kinney
Sent: Friday, July 10, 2020 7:09 PM
To: devel@edk2.groups.io=
Cc: Sean Brogan; Bret Barkelew; Yao, Jiewen<= br> Subject: [EXTERNAL] [Patch v3 10/16] UnitTestFrameworkPkg/UnitTestLi= b: Move print log into cleanup

 

REF: https://nam06.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fbugzill= a.tianocore.org%2Fshow_bug.cgi%3Fid%3D2805&amp;data=3D02%7C01%7CBret.Ba= rkelew%40microsoft.com%7C0e54105ccc5b453f790508d8253f690e%7C72f988bf86f141a= f91ab2d7cd011db47%7C1%7C0%7C637300301563150384&amp;sdata=3DOY4xwl9Ecv%2= F0SJyzzqBUGNxTi1E%2F8Ax70I6jF2dA6cA%3D&amp;reserved=3D0

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 <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>
---
 .../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 (Unit= Test->Context);
     Framework->CurrentTest =3D NULL;
-
-    // Print out the log messages - This is a partial solut= ion 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&quo= t;, UnitTest->Name, UnitTest->Description);
-      print_message("Log Output Start\n"= ;);
-      print_message("%s", UnitTest->= Log);
-      print_message("Log Output End\n")= ;
-    }
   }
 }
 
@@ -112,13 +100,24 @@ CmockaUnitTestTeardownFunctionRunner (
   Suite     =3D (UNIT_TEST_SUITE *)(UnitTest= ->ParentSuite);
   Framework =3D (UNIT_TEST_FRAMEWORK *)(Suite->ParentFramewor= k);
 
-  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->Description);
+    print_message("Log Output Start\n");
+    print_message("%s", UnitTest->Log);
+    print_message("Log Output End\n");
   }
 
-  Framework->CurrentTest =3D UnitTest;
-  UnitTest->CleanUp (UnitTest->Context);
-  Framework->CurrentTest =3D NULL;
   //
   // Return 0 for success.  Non-zero for error.
   //
--
2.21.0.windows.1

 

--_000_CY4PR21MB074399E01259AC013203EA39EF7E0CY4PR21MB0743namp_--