From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web10.7414.1670569391401302318 for ; Thu, 08 Dec 2022 23:03:11 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=Apnj/0c1; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: jiewen.yao@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670569391; x=1702105391; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=s8TdoFAMDRRmJGmju/cAL+KDlKx3Y0eE2U88loOqwj8=; b=Apnj/0c1Qi/QJr725IFN5z7ha0XqKYJOyjeXrmMaNCQZWg4K2zoN5Fgw mdJgculq1DSpx6HrC9DR+KS1ducxmdRL9p62SBy1rV1VO+9Covi93zKBp B2OSMx+jT452up4otYdnk9WDlSqTJiY7uIJcUhdCaDMjzYZ7yYfalTavv UBgKGK4CNJhvUn0XTIfZVgLCJPpI6dn8CMaF07k9elZnnfkh7DkY+Xezd Q+eKVXFuwT5Qav5gH8JYSYu//uxz1txd08+yOaG8lsnUccPsJMSQNz7zA PdCCJLpRw87qRTlJFxuWrgBqQ0j59S168eNYqHPtQc1+X09yPCVdiUup2 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10555"; a="315034165" X-IronPort-AV: E=Sophos;i="5.96,230,1665471600"; d="scan'208";a="315034165" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2022 23:03:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10555"; a="821639439" X-IronPort-AV: E=Sophos;i="5.96,230,1665471600"; d="scan'208";a="821639439" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga005.jf.intel.com with ESMTP; 08 Dec 2022 23:03:10 -0800 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 8 Dec 2022 23:03:10 -0800 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16 via Frontend Transport; Thu, 8 Dec 2022 23:03:10 -0800 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.169) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.16; Thu, 8 Dec 2022 23:03:10 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LwRCyUOTqTfB4/ah4kb7KBOWLmzZUxK2RITX8v0ebKfUgXQoTNl7Nv/3sosElHLkSEVhovkwpE4YgSvJogxaMdgAO6mclRR0796MMFw+bAWfpZUI2D3j8o6hvOEYONNwkLlUI6y2DdqmBgDRH4YPwAg1iQYfjo2+YD7cf64ByPJ8nsLHLhy5jDtn+CjAnbpYxESrxdUbwGnyP7iaYrpCP3VkHT528C5V33+vyLN1Jubx5918SYXCN6MokY40cU4lvd7jbGM2K0f17UZY2YygRiom6scVBzqV/CnCCCzlMwF6Ok8MrKBDuMSfkWn6j9/XzbVI+b/mWIKAtMJFPLi8Qw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Wmc/9TjUhWnWfwdS10Y8ULhzBa5IcVjn0JrnSUdJpV4=; b=NX/Q7CwlUsk3ffI23WaZIJRgxThU2Ja1raAVtGLvWI5mQebBFVloQrimyj/JAX/9LhiqQnRYebBkrLpf15ht2Y3XNGDgKFHNDYFS15lyfAOvjSe8TMxWJ+IXqYsG8iKNj/9fXBDnYxMffIUSFwM/+KEzEYNBmISn0Ltgtvw5rCBttl1bUaY8tVO2Wx2prEDrP3pESZt9aPZY6khUsnOZ818hNkHVlmgLcQqlpY8mOuGJpyJIevAyLl0xqRwZbBr8nGKuodU/aDNCfipvPRLMdOqKLLGbkIoeXbnxdgeJPcvcEy+SAYjTE2PQcL8hx0ZdmOmml6/qNHXFdabpnUm6QA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from MW4PR11MB5872.namprd11.prod.outlook.com (2603:10b6:303:169::14) by DM4PR11MB5344.namprd11.prod.outlook.com (2603:10b6:5:393::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.16; Fri, 9 Dec 2022 07:03:07 +0000 Received: from MW4PR11MB5872.namprd11.prod.outlook.com ([fe80::5f56:1bdc:2eae:c041]) by MW4PR11MB5872.namprd11.prod.outlook.com ([fe80::5f56:1bdc:2eae:c041%7]) with mapi id 15.20.5880.014; Fri, 9 Dec 2022 07:03:07 +0000 From: "Yao, Jiewen" To: "Tan, Dun" , "devel@edk2.groups.io" CC: Ard Biesheuvel , "Justen, Jordan L" , Gerd Hoffmann , "Ni, Ray" , Sean Brogan , "Kinney, Michael D" Subject: Re: [edk2-devel] [PATCH 1/3] OvmfPkg/PlatformCI: Expand Ovmf PlatformCI for Shell UnitTest Thread-Topic: [edk2-devel] [PATCH 1/3] OvmfPkg/PlatformCI: Expand Ovmf PlatformCI for Shell UnitTest Thread-Index: AQHY/mhUjTU/B98SM02Ddp8TdwXJ865UGptggAqiAgCABn6tcA== Date: Fri, 9 Dec 2022 07:03:07 +0000 Message-ID: References: <20221122114737.393-1-dun.tan@intel.com> <1729E5AF924ED134.5511@groups.io> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MW4PR11MB5872:EE_|DM4PR11MB5344:EE_ x-ms-office365-filtering-correlation-id: 00f09a51-ca66-426f-b67d-08dad9b36cb4 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: a6FDgPXSbcsnVZPqP5loA+9KAorOWtEYWRgCe2blY+W6GjvHupeWfeJZmIUdFEU9oUCVYDf2+sAAHUSgujbHSV+OlU5FBaLY3/jruHZBc7g0AltJ9yZrooVYDCGzb1G42aJOMYetOVU3psdRcvpLseH/Pq3a3TuHyNiCbOcv9jkj5wujX5gm3WJ/8i9wc+LL/5ZseOcpM5Blg6j4NpnHiPFyFyE6bUolyV944xdARZAPUhfnTW9DJHmrQkObQvnCeryPESAGUt9ihhudihxzkuaeq9VwV6D5L4LhHEsDCRA8YrdjEtdlsnwZeP85VSAaVPvZleRMiZ4EsAJdGHrI6qCDs9/bxItcDQMICGoKkHPSGXni2NkdULEMvUXW9BhmwNuyRMRQG2ff0arr5Rd2HrYENfRnuP1VeZBaPyVsvqikbbQ08VdcGp15rI+5B1RJJ/PEwSkYd2ph1zF2C2sq06W+rRfmDpJSUkYofMC5DrYo5iyCcmlC/Pzk5wcbjkyoX9WyJLjuAUtbS81PbUKT10O59F5LXvMTBIubNoGlSOiT9kQM7Qy82HHc3JMQhpYK0C5OmzxH/h6Rkfoaj9B/mmhQ5IHiImN5c3ZCye4t7FIz6ARuUGLnFcpK7PQdJX9WCHa7MwXuIt8gxwuhgFHekrklLoNG3eNNoiculfCwCYBUU9GGeGBIqtwiUiEhxqW4fSqlGwiYXlBfatpCXHLzYU9HM6tSFlVt/GboUZfnGTwIR5wogVZIZb/ZoC+wg56zG7/KQUb9HA6YoLv/gKLrVg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR11MB5872.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(346002)(39860400002)(396003)(376002)(136003)(451199015)(33656002)(38100700002)(2906002)(122000001)(8936002)(5660300002)(30864003)(52536014)(186003)(86362001)(83380400001)(82960400001)(38070700005)(54906003)(316002)(66899015)(478600001)(71200400001)(966005)(9686003)(55016003)(41300700001)(26005)(7696005)(110136005)(8676002)(64756008)(4326008)(66446008)(107886003)(6506007)(66946007)(76116006)(66476007)(66556008)(53546011);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?fQJaqtK1nCrSKOh9yyisobGzoKCNZB/ytpZ9FdrbrziE5/QYZsYnBos4Mo94?= =?us-ascii?Q?yuLsSdXtJPxvqOAVZuyXn6HAAleLC6b9O0eRD2yKV4n2wj8Ws8MgHbKyjhU1?= =?us-ascii?Q?FcR5DOMt7ltfTvCUyrnLuSiQp8kkxhPOxfbL4s020J1rr2uowJfZwLM1IHdO?= =?us-ascii?Q?/jXxXN3UH52pIjYn+w8Jz2wUcS2vL6y3lXrqM38IXhPrKc/AU+OlMP7zaOPv?= =?us-ascii?Q?Miq9Dnz9ei4hRFJrR7obg9w7AC36G7dNWguLONYy3dUhCXI06G92T+vCTP5z?= =?us-ascii?Q?mcLJ61xZsGBAVvyTPfrhv0uVFSzLsT0FocGI0iNwV6XhPXv5gbhv9gIDXVPk?= =?us-ascii?Q?uriheUri1MpGFDFwRyHws2dBqaN2OqMPakH2Cyh7DZ1x6BCKEvHJSGLWj6vs?= =?us-ascii?Q?0z/HNiEyu6W7iXWgQcejmhIteJ1lfX4pZY5+No+nqCYeiGrpq61GKTL7XNbK?= =?us-ascii?Q?ezjwfd8Q3RhGpTUvw1SFAOXWjXJ2SjLCRDBgF6bX4a/oTqWWlmZkCTLfvAHc?= =?us-ascii?Q?9CJlAD5KHi02pW4aE7s7rUlmGtYPstgpirpPp4Q/o+h082kFa+Mat2yF0UoI?= =?us-ascii?Q?3Fisvg5fuCO3dEVcHazj8kIxT6AMIca8Yf6F8EPiT0UgDyCx943sEdSX8qIM?= =?us-ascii?Q?p3Vl6Pdfyr3GAIFwtKj/REeq/ekhS3Wja6ozJNoH6CRB+eGyb66nhjXi7dr4?= =?us-ascii?Q?HNnDCNlnkHY0LGP9oDMNH4O9Tfs3q6KwU5inAzYjM9s9ljKG2NPtDTwyv0RN?= =?us-ascii?Q?2tYYxZh/mnG5krIhFd4rbrr7Yssz1c/0qLfxBmdbe3IebETMAHT3IgytU07D?= =?us-ascii?Q?vIgwqDNICaCBow8IR0hgGocQTDRckIFr6JsGeQy1lEutotexj8hJ066mbRoH?= =?us-ascii?Q?kHdyDgK2M9ZYNkBmb4xu/UfQnivNdhwUyOhS2RXkx9Zlb3PhA0vY9jYvkpUJ?= =?us-ascii?Q?RkK/XNuND0tUM6fETNL49RxvOhuTAtHFfLB7Pdae9EO65HgBuUgsOQaEiqBW?= =?us-ascii?Q?bX00VlcrkAJqtf6aIqNOJbj7igxYc+ORGkoca9jrO7ZKj3aoCPJRMJbk9p3/?= =?us-ascii?Q?Rf+VcxOvPFMdp7/vc8RxacdUhKq8RsoeUbDnfqtMXM44SwxBJ0hwxl9qffay?= =?us-ascii?Q?0nfaFpghCCJqs+6hISU6Sd/6H2O1hrDJAqLpB+i17QUArkxX41ke5DFNEOU7?= =?us-ascii?Q?85bLReJMbwHD+mKEeIy1PIxBqwagWhA7tLoy0VU0tJ8TkL+cfXklRgyq0u2M?= =?us-ascii?Q?9DGMAv6UUdlrbn73XrC4UUakVOhvsEXOWvEAYWzNNmnlzr3/TA/MSzFUVWqU?= =?us-ascii?Q?XL7WaOgpHd8ke0d+YiSY+P+UqTYG2SUInTBe0Z5nSw3GGHqwv8NkOQO8ZfJI?= =?us-ascii?Q?U+QCqWZMm0VFIfX9TSG2ak7PpgqMwsBrMLge7q04oz4oXcefLKDvp7y1yTua?= =?us-ascii?Q?0YzkTzrH857kg/y8zO2gmbm9HK70NuK54WClDr4YPRh+DaDW7+BsJO70sjvk?= =?us-ascii?Q?kg6qd2ZldJxErXOLC8ietKvKkJq+xAaI3F64lmPrdcDgsuQVvTlwm0yt4HgR?= =?us-ascii?Q?yWk2noxLRFBwxAtTZECNecj1wOnwVgxf5xwgZiC8?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR11MB5872.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 00f09a51-ca66-426f-b67d-08dad9b36cb4 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Dec 2022 07:03:07.2033 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: zvYVu1hEhBJIzmYVIc3MRLp4lbdnF1PUT4BOv4jNMYyQzbcPvL3QhEai2OrSsSVxiBvHzMY36THW28hyW9tMWg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB5344 Return-Path: jiewen.yao@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thanks. I think this is good addition. Acked-by: Jiewen Yao Need CI expert to give reviewed-by. > -----Original Message----- > From: Tan, Dun > Sent: Monday, December 5, 2022 11:57 AM > To: devel@edk2.groups.io > Cc: Ard Biesheuvel ; Yao, Jiewen > ; Justen, Jordan L ; > Gerd Hoffmann ; Ni, Ray ; Sean > Brogan ; Kinney, Michael D > > Subject: RE: [edk2-devel] [PATCH 1/3] OvmfPkg/PlatformCI: Expand Ovmf > PlatformCI for Shell UnitTest >=20 > Hi all, > Is there anything else I can do to speed up the review process for this p= atch > set? Looking forward to your reply. >=20 > Thanks, > Dun >=20 > -----Original Message----- > From: Tan, Dun > Sent: Monday, November 28, 2022 5:34 PM > To: devel@edk2.groups.io; Tan, Dun > Cc: Ard Biesheuvel ; Yao, Jiewen > ; Justen, Jordan L ; > Gerd Hoffmann ; Ni, Ray > Subject: RE: [edk2-devel] [PATCH 1/3] OvmfPkg/PlatformCI: Expand Ovmf > PlatformCI for Shell UnitTest >=20 > Hi all, > Could you please help to review this patch? Thanks a lot! >=20 > Thanks, > Dun >=20 > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of duntan > Sent: Tuesday, November 22, 2022 7:48 PM > To: devel@edk2.groups.io > Cc: Ard Biesheuvel ; Yao, Jiewen > ; Justen, Jordan L ; > Gerd Hoffmann ; Ni, Ray > Subject: [edk2-devel] [PATCH 1/3] OvmfPkg/PlatformCI: Expand Ovmf > PlatformCI for Shell UnitTest >=20 > Expand Ovmf PlatformBuild.py and PlatformBuildLib.py to support building > and running specific Shell target UnitTest modules. > In the new CommonPlatform class: > It provides new class attributes and new methods to support build and run > specific Shell Unit Test modules. >=20 > In the new SettingsManager class for stuart_pr_eval: > It calls new API in CommonPlatform to updates PackagesSupported based > on -u ShellUnitTestList input from cmd. The package which contains the > module in ShellUnitTestList will be added into PackagesSupported for > further evaluation. >=20 > In the new PlatformBuilder class for stuart_build: > 1.In PlatformPostBuild(), it conditionally calls new API in CommonPlatfor= m > to build -u ShellUnitTestList in -p PkgsToBuild and copy them to VirtualD= rive > folder. If no -p option, all the modules in -u ShellUnitTestList will be = built. > 2.In FlashRomImage(), it conditionally calls the new API in CommonPlatfor= m > to write all efi files name in VirtualDrive into startup.nsh and output > UnitTest log into ShellUnitTestLog. > 3. After the boot process, it conditionally calls new API in CommonPlatfo= rm > to check the UnitTest boot log. >=20 > Signed-off-by: Dun Tan > Cc: Ard Biesheuvel > Cc: Jiewen Yao > Cc: Jordan Justen > Cc: Gerd Hoffmann > Cc: Ray Ni > --- > OvmfPkg/PlatformCI/PlatformBuild.py | 112 > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > ++++++++++++++++++++++++++++++++++++++++++++++++++++++ > OvmfPkg/PlatformCI/PlatformBuildLib.py | 51 > +++++++++++++++++++++++++++++++++++++++++++++------ > 2 files changed, 157 insertions(+), 6 deletions(-) >=20 > diff --git a/OvmfPkg/PlatformCI/PlatformBuild.py > b/OvmfPkg/PlatformCI/PlatformBuild.py > index 6c541cdea4..72cb7e0e9e 100644 > --- a/OvmfPkg/PlatformCI/PlatformBuild.py > +++ b/OvmfPkg/PlatformCI/PlatformBuild.py > @@ -6,6 +6,11 @@ > ## > import os > import sys > +import shutil > +import logging > +import re > +from edk2toolext.environment import shell_environment from > +edk2toolext.environment.multiple_workspace import MultipleWorkspace >=20 > sys.path.append(os.path.dirname(os.path.abspath(__file__))) > from PlatformBuildLib import SettingsManager @@ -24,6 +29,10 @@ > class CommonPlatform(): > Scopes =3D ('ovmf', 'edk2-build') > WorkspaceRoot =3D os.path.realpath(os.path.join( > os.path.dirname(os.path.abspath(__file__)), "..", "..")) > + # Support build and run Shell Unit Test modules > + UnitTestModuleList =3D {} > + RunShellUnitTest =3D False > + ShellUnitTestLog =3D '' >=20 > @classmethod > def GetDscName(cls, ArchCsv: str) -> str: > @@ -39,5 +48,108 @@ class CommonPlatform(): > dsc +=3D ".dsc" > return dsc >=20 > + @classmethod > + def UpdatePackagesSupported(cls, ShellUnitTestListArg): > + ''' Update PackagesSupported by -u ShellUnitTestList from cmd li= ne. ''' > + UnitTestModuleListStr =3D ','.join(ShellUnitTestListArg) > + if not re.search(r'.+.inf:.+.dsc', UnitTestModuleListStr): > + raise Exception('No valid ModulePath:DscPath in the -u > {}'.format(UnitTestModuleListStr)) > + UnitTestModuleList =3D UnitTestModuleListStr.split(',') > + PackagesSupported =3D [] > + for KeyValue in UnitTestModuleList: > + PkgName =3D KeyValue.split("Pkg")[0] + 'Pkg' > + if PkgName not in PackagesSupported: > + PackagesSupported.append(PkgName) > + cls.PackagesSupported =3D tuple(PackagesSupported) > + print('PackagesSupported for UnitTest is > + {}'.format(cls.PackagesSupported)) > + > + @classmethod > + def UpdateUnitTestConfig(cls, args): > + ''' Update UnitTest config by -u ShellUnitTestList and -p > PkgsToBuildForUT from cmd line. > + ShellUnitTestList is in this format: {module1:dsc1, module2:= dsc2, > module3:dsc2...}. > + Only the modules which are in the PkgsToBuildForUT list are = added > into self.UnitTestModuleList. > + ''' > + UnitTestModuleListStr =3D ','.join(args.ShellUnitTestList) > + if not re.search(r'.+.inf:.+.dsc', UnitTestModuleListStr): > + raise Exception('No valid ModulePath:DscPath in the -u > {}'.format(args.ShellUnitTestList)) > + UnitTestModuleList =3D UnitTestModuleListStr.split(',') > + if args.PkgsToBuildForUT is None or all(['Pkg' not in Pkg for Pk= g in > args.PkgsToBuildForUT]): > + # No invalid Pkgs from input. Build all modules in -u > UnitTestModuleList. > + for KeyValue in UnitTestModuleList: > + UnitTestPath =3D os.path.normpath(KeyValue.split(":")[0]= ) > + DscPath =3D os.path.normpath(KeyValue.split(":")[1]= ) > + cls.UnitTestModuleList[UnitTestPath] =3D DscPath > + else: > + PkgsToBuildForUT =3D ','.join(args.PkgsToBuildForUT).split('= ,') > + for KeyValue in UnitTestModuleList: > + UnitTestPath =3D os.path.normpath(KeyValue.split(":")[0]= ) > + DscPath =3D os.path.normpath(KeyValue.split(":")[1]= ) > + PkgName =3D UnitTestPath.split("Pkg")[0] + 'Pkg' > + if PkgName in PkgsToBuildForUT: > + cls.UnitTestModuleList[UnitTestPath] =3D DscPath > + if len(cls.UnitTestModuleList) > 0: > + cls.RunShellUnitTest =3D True > + cls.ShellUnitTestLog =3D os.path.join(cls.WorkspaceRoot, 'Bu= ild', > "BUILDLOG_UnitTest.txt") > + print('UnitTestModuleList is > + {}'.format(cls.UnitTestModuleList)) > + > + def BuildUnitTest(self): > + ''' Build specific DSC for modules in UnitTestModuleList ''' > + self.env =3D shell_environment.GetBuildVars() > + self.ws =3D PlatformBuilder.GetWorkspaceRoot(self) > + self.mws =3D MultipleWorkspace() > + self.pp =3D '' > + VirtualDrive =3D os.path.join(self.env.GetValue("BUILD_OUTPUT_BA= SE"), > "VirtualDrive") > + os.makedirs(VirtualDrive, exist_ok=3DTrue) > + > + # DSC by self.GetDscName() should have been built in BUILD proce= ss. > + BuiltDsc =3D > [CommonPlatform.GetDscName(",".join(self.env.GetValue("TARGET_ARCH") > .split(' ')))] > + for UnitTestPath, DscPath in > CommonPlatform.UnitTestModuleList.items(): > + if DscPath not in BuiltDsc: > + ModuleName =3D os.path.split(UnitTestPath)[1].split('.in= f')[0] > + logging.info('Build {0} for {1}'.format(DscPath, ModuleN= ame)) > + BuiltDsc.append(DscPath) > + Arch =3D self.env.GetValue("TARGET_ARCH").split(" ") > + if 'X64' in Arch: > + UTArch =3D 'X64' > + else: > + UTArch =3D 'IA32' > + self.env.AllowOverride("ACTIVE_PLATFORM") > + self.env.SetValue("ACTIVE_PLATFORM", DscPath, "For UnitT= est") > + self.env.AllowOverride("TARGET_ARCH") > + self.env.SetValue("TARGET_ARCH", UTArch, "For UnitTest")= # Set > UnitTest arch the same as Ovmf Shell module. > + ret =3D PlatformBuilder.Build(self) = # Build specific dsc > for UnitTest modules > + if (ret !=3D 0): > + return ret > + ret =3D PlatformBuilder.ParseDscFile(self) # Parse > OUTPUT_DIRECTORY from dsc files > + if(ret !=3D 0): > + return ret > + OutputPath =3D os.path.normpath(os.path.join(self.ws, > self.env.GetValue("OUTPUT_DIRECTORY"))) > + EfiPath =3D os.path.join(OutputPath, self.env.GetValue("T= ARGET") + > "_" + self.env.GetValue("TOOL_CHAIN_TAG"), > + UTArch, UnitTestPath.split('.inf')[0], "OUTPUT"= , > ModuleName + '.efi') > + logging.info('Copy {0}.efi from:{1}'.format(ModuleName, EfiP= ath)) > + shutil.copy(EfiPath, VirtualDrive) > + return 0 > + > + @staticmethod > + def WriteEfiToStartup(EfiFolder, FileObj): > + ''' Write all the .efi files' name in VirtualDrive into Startup.= nsh ''' > + for Root,Dirs,Files in os.walk(EfiFolder): > + for File in Files: > + if os.path.splitext(File)[1] =3D=3D '.efi': > + FileObj.write("{0} \n".format(File)) > + > + @classmethod > + def CheckUnitTestLog(cls): > + ''' Check the boot log for UnitTest ''' > + File =3D open(cls.ShellUnitTestLog, "r") > + FileContent =3D File.readlines() > + logging.info('Check the UnitTest boot > log:{0}'.format(cls.ShellUnitTestLog)) > + for Index in range(len(FileContent)): > + if 'FAILURE MESSAGE:' in FileContent[Index]: > + if FileContent[Index + 1].strip() !=3D '': > + FailureMessage =3D FileContent[Index + 1] + FileCont= ent[Index + > 2] > + return FailureMessage > + return 0 > + > import PlatformBuildLib > PlatformBuildLib.CommonPlatform =3D CommonPlatform diff --git > a/OvmfPkg/PlatformCI/PlatformBuildLib.py > b/OvmfPkg/PlatformCI/PlatformBuildLib.py > index bfef9849c7..b42235b2ac 100644 > --- a/OvmfPkg/PlatformCI/PlatformBuildLib.py > +++ b/OvmfPkg/PlatformCI/PlatformBuildLib.py > @@ -103,15 +103,28 @@ class SettingsManager(UpdateSettingsManager, > SetupSettingsManager, PrEvalSetting >=20 > return build_these_packages >=20 > + def AddCommandLineOptions(self, parserObj): > + parserObj.add_argument('-u', '--UnitTest', dest=3D'ShellUnitTest= List', > type=3Dstr, > + help=3D'Optional - Key:Value that contains Shell UnitTest li= st and > corresponding DscPath you want to test.(workspace relative)' > + 'Can list multiple by doing -u > , or -u -u > ', > + action=3D"append", default=3DNone) > + > + def RetrieveCommandLineOptions(self, args): > + if args.ShellUnitTestList: > + > + CommonPlatform.UpdatePackagesSupported(args.ShellUnitTestList) > + > def GetPlatformDscAndConfig(self) -> tuple: > ''' If a platform desires to provide its DSC then Policy 4 will = evaluate if > any of the changes will be built in the dsc. >=20 > The tuple should be (, dictionary of dsc key value pairs>) > + This Policy 4 can only be applied when PackagesSupported only > contains OvmfPkg Since it doesn't support > + mutiple packages evaluation. > ''' > - dsc =3D CommonPlatform.GetDscName(",".join(self.ActualArchitectu= res)) > - return (f"OvmfPkg/{dsc}", {}) > - > + if (len(CommonPlatform.PackagesSupported) =3D=3D 1) and > (CommonPlatform.PackagesSupported[0] =3D=3D 'OvmfPkg'): > + dsc =3D > CommonPlatform.GetDscName(",".join(self.ActualArchitectures)) > + return (f"OvmfPkg/{dsc}", {}) > + return None >=20 > # > ########################################################## > ############################# # > # Actual Configuration for Platform Build = # > @@ -126,6 +139,14 @@ class PlatformBuilder( UefiBuilder, > BuildSettingsManager): > help=3D"Optional - CSV of architecture to build. IA32 will = use IA32 for > Pei & Dxe. " > "X64 will use X64 for both PEI and DXE. IA32,X64 will use I= A32 for > PEI and " > "X64 for DXE. default is IA32,X64") > + parserObj.add_argument('-p', '--pkg', '--pkg-dir', > dest=3D'PkgsToBuildForUT', type=3Dstr, > + help=3D'Optional - Package list you want to build for UnitTe= st.efi. > (workspace relative).' > + 'Can list multiple by doing -p , or -p -p > .If no valid input -p, build and run all -u UnitTest', > + action=3D"append", default=3DNone) > + parserObj.add_argument('-u', '--UnitTest', dest=3D'ShellUnitTest= List', > type=3Dstr, > + help=3D'Optional - Key:Value that contains Shell UnitTest li= st and > corresponding DscPath you want to test.(workspace relative)' > + 'Can list multiple by doing -u > , or -u -u > ', > + action=3D"append", default=3DNone) >=20 > def RetrieveCommandLineOptions(self, args): > ''' Retrieve command line options from the argparser ''' > @@ -133,6 +154,10 @@ class PlatformBuilder( UefiBuilder, > BuildSettingsManager): > shell_environment.GetBuildVars().SetValue("TARGET_ARCH"," > ".join(args.build_arch.upper().split(",")), "From CmdLine") > dsc =3D CommonPlatform.GetDscName(args.build_arch) > shell_environment.GetBuildVars().SetValue("ACTIVE_PLATFORM", > f"OvmfPkg/{dsc}", "From CmdLine") > + self.RunShellUnitTest =3D False > + if args.ShellUnitTestList: > + CommonPlatform.UpdateUnitTestConfig(args) > + self.RunShellUnitTest =3D CommonPlatform.RunShellUnitTest >=20 > def GetWorkspaceRoot(self): > ''' get WorkspacePath ''' > @@ -176,6 +201,11 @@ class PlatformBuilder( UefiBuilder, > BuildSettingsManager): > return 0 >=20 > def PlatformPostBuild(self): > + if self.RunShellUnitTest: > + ret =3D CommonPlatform.BuildUnitTest(self) > + if ret !=3D0: > + logging.critical("Build UnitTest failed") > + return ret > return 0 >=20 > def FlashRomImage(self): > @@ -210,9 +240,13 @@ class PlatformBuilder( UefiBuilder, > BuildSettingsManager): > else: > args +=3D " -pflash " + os.path.join(OutputPath_FV, "OVMF.fd= ") # > path to firmware >=20 > - > if (self.env.GetValue("MAKE_STARTUP_NSH").upper() =3D=3D "TRUE")= : > f =3D open(os.path.join(VirtualDrive, "startup.nsh"), "w") > + if self.RunShellUnitTest: > + # When RunShellUnitTest is True, write all efi files nam= e into > startup.nsh. > + CommonPlatform.WriteEfiToStartup(VirtualDrive, f) > + # Output UnitTest log into ShellUnitTestLog. > + args +=3D " -serial > + file:{}".format(CommonPlatform.ShellUnitTestLog) > f.write("BOOT SUCCESS !!! \n") > ## add commands here > f.write("reset -s\n") > @@ -222,6 +256,11 @@ class PlatformBuilder( UefiBuilder, > BuildSettingsManager): >=20 > if ret =3D=3D 0xc0000005: > #for some reason getting a c0000005 on successful return > - return 0 > - > + ret =3D 0 > + if self.RunShellUnitTest and ret =3D=3D 0: > + # Check the UnitTest boot log. > + UnitTestResult =3D CommonPlatform.CheckUnitTestLog() > + if (UnitTestResult): > + logging.info("UnitTest failed with this FAILURE > MESSAGE:\n{}".format(UnitTestResult)) > + return UnitTestResult > return ret > -- > 2.31.1.windows.1 >=20 >=20 >=20 >=20 >=20