From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web11.113834.1669628028335614811 for ; Mon, 28 Nov 2022 01:33:48 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=J/ghIXFH; spf=pass (domain: intel.com, ip: 192.55.52.151, mailfrom: dun.tan@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669628028; x=1701164028; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=5h7afXlWLZCE2Tchfg+9VpcW3/70YP2I+yBV8WIuSTs=; b=J/ghIXFHF6KoRm6epQ1ezNSwMAUwf5WwSR6DnAS4/xtzBPdUrrBbYaFE IYdctVpIlIjO1P3QAWy+KVwp130O/Obe74+LA9YrzsMQ8FszbxF2vFtzs 1n/WoeA//UiCUiQInAq1j3Y1X4BvWcI7RI4kBvua+faJvt8MS4HNBp8yD qpxF33AJsPY/gIJoXzXzaKCbPsORN/bDS2h39VCYAGaHQZ8fR0f9Uk9do DBFNg5fhRS0b4xAcgkNr1AzgUzhWaIjXOUY7ItY7anaJTz7vLRFlFTbXb augCaMrkBgr2JJKHltXVwG0bA047X02LjCxgNtTMBMyomG211Ek6avi8R g==; X-IronPort-AV: E=McAfee;i="6500,9779,10544"; a="295175150" X-IronPort-AV: E=Sophos;i="5.96,200,1665471600"; d="scan'208";a="295175150" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2022 01:33:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10544"; a="643325055" X-IronPort-AV: E=Sophos;i="5.96,200,1665471600"; d="scan'208";a="643325055" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orsmga002.jf.intel.com with ESMTP; 28 Nov 2022 01:33:47 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 28 Nov 2022 01:33:46 -0800 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 28 Nov 2022 01:33:46 -0800 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) 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; Mon, 28 Nov 2022 01:33:46 -0800 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.109) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.16; Mon, 28 Nov 2022 01:33:45 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hM1BLmWZQyt2mR3LletYseFhbfB6Fx0bkwlTat3gvaEFibnfVcyqFMFEPFCmWMRfs1g/JpwySqSsCm8JR485TOcpOgmgW/foIXQicpxhzGGMztCHKXhR0gLDU3DMNVGCFkvq7k8VHwyRK+s7OQIAgEo7mnj+Wu8GXqILPYUoFZjasen43RBVMKkE/0teabV+wYquXZaHqaJN29Vy1iuW37O8/oRvGuGSe1ahFe/Q0t0Uc9bkyLjFKaXsIKonE9GRHCeUp0oMQU1Lnuweyv5a2/IGH1zbRLyinjfP9gkJvUQOsLujWrLY2IqpmDcmp/LCx1bmoIEPPOOA+kbIUYNNaA== 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=V040VYMry4g5ageMoIBb03sPIxwO7MQBv5D3oc5gjTA=; b=Y22hXRwh2muFx4TYvfeYPYLhAMWpfuu9Yc69AEwVPMaEeWzhzav0TsZdfAZ9h4s9bDke0GmQUmQ4kqAICcqInXLM1wIXtXWhKprR3rJ+BjTsy/+fHhnaB8/VDm/U7hXdby1asm88+iwJv9lUQOSBd9DmImxWfLaB0k86bMgWXkIi/OGU9Nd9Q2IGor4pmq+tBFit1YZ7qw4G+wxlIn/IF6B70cKTNQr0SQU5djJE30HfobE2PbumFXnNcThdBHTUlXcH+p1XhU6TxRGKAGA9WN7HXuSvzOXQZqCra3s2Ns8foRNs6wJJQ2jFvlhbNXXdkEE2n/qLtZ7j5wjnWnWF3g== 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 BN9PR11MB5483.namprd11.prod.outlook.com (2603:10b6:408:104::10) by PH7PR11MB6769.namprd11.prod.outlook.com (2603:10b6:510:1af::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Mon, 28 Nov 2022 09:33:43 +0000 Received: from BN9PR11MB5483.namprd11.prod.outlook.com ([fe80::c945:6fc3:ca84:dd9b]) by BN9PR11MB5483.namprd11.prod.outlook.com ([fe80::c945:6fc3:ca84:dd9b%9]) with mapi id 15.20.5857.023; Mon, 28 Nov 2022 09:33:43 +0000 From: "duntan" 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 Thread-Topic: [edk2-devel] [PATCH 1/3] OvmfPkg/PlatformCI: Expand Ovmf PlatformCI for Shell UnitTest Thread-Index: AQHY/mhUjTU/B98SM02Ddp8TdwXJ865UGptg Date: Mon, 28 Nov 2022 09:33:43 +0000 Message-ID: References: <20221122114737.393-1-dun.tan@intel.com> <1729E5AF924ED134.5511@groups.io> In-Reply-To: <1729E5AF924ED134.5511@groups.io> Accept-Language: zh-CN, 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: BN9PR11MB5483:EE_|PH7PR11MB6769:EE_ x-ms-office365-filtering-correlation-id: e231bc7c-ca3c-4458-3a23-08dad123a460 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: dNs9PAeDDztkrbFA7pmgCaHwCb0RCtjmrpSaSqEgQ+H3b+ZEHt6jo96AADGkvyXWsTronpu8U8Xu4Kuwj7kJ81tnqpez9BH0JpP/OCG4VW2GG88CEDrUM974miieWQQhyabrKi8Kz1U+RoD0OlXfajAFaoUCaDnb3J94GxFVWWwyTa7hwzgAXDpK7/HMyivboiEmoYbJ7Nhd90ml6LQipYHgP7XE7v0ezoTF3P2HPR6OMBPP2evl0xHd/XO0ulDK2gPuBA7ghPP+J7rvFH85JLKvTl5vNpq+5CnEH/vMCJEqhEAMr/97CbonyvGzgqSFPJrHy+Sodc+9/74th7nbmu/xa2jC40rIW1mIhLBd3FhkUKhhqf3ufUU8TB3U1HgGwIQhR4iL6hpaMzTOyqe94Xgc8YdrtaxecbMaOC8FBxCbXCE4Zdd+ixfcb/UxmPg4eMtm51KIEniQsJw4MZX7h5riIIF/PB3xQ/pXtD8kf7sxGZCVBhkKKawJRpdXi9+RXDriF02Q5MuyOXJYiq2qbn4eAT8WIMiuhghqzSskxn4IBplx02ffc4WN5kpLlRksnWbcFI6DrXQPsv8rgeRJVGTzH3GmDNjbateLpzmoQolyIJ5ElBStyMoqvuTisBihO/PPyPRLYpNLa8+0nDW0DvhEKTCgOpIEZON2t1+eN2k6tO7EAOsXfM+tPLoLhxhCaF9O0WKiKRlBF7K0KKTCH1joDNebRiqctm23KzNfx9A8Zus1CXCTiIi/FnRIUHR+lLWzvh8obe15kgOh043RtA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN9PR11MB5483.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(376002)(366004)(136003)(396003)(346002)(39860400002)(451199015)(66899015)(316002)(2906002)(30864003)(8936002)(186003)(83380400001)(52536014)(33656002)(5660300002)(86362001)(41300700001)(66446008)(38100700002)(66476007)(82960400001)(76116006)(66556008)(66946007)(38070700005)(55016003)(122000001)(54906003)(110136005)(64756008)(53546011)(966005)(478600001)(7696005)(6506007)(107886003)(4326008)(26005)(9686003)(8676002)(71200400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?50uUlLMkUYNfh6vnQJLSGHugz4bY5bWnBffaLnXOrMZvkoyEHzyXCS3vYNkA?= =?us-ascii?Q?GSSe6Lcdn4N5F9B1J8HmXT3XDDoxZQi3Ur2nmqzrZBu9WX8xjLcgZVFXCc9Q?= =?us-ascii?Q?mJyuKJG9k6V3+GZ++ghAUjUVqLJohwmRpvuckxtieawgco2DjcBaKKzuHR6n?= =?us-ascii?Q?6guIQtsj7ywdteiSp0DEak0FCg3XT4gkTLSGvIx+G84uZh8FmyDE6IzpIwMm?= =?us-ascii?Q?VXbhHOUnaVKatMzU8CgN4TPQ5xanXmoOlwEx7+pRMcqbrQ4kHIBSDvW92y7r?= =?us-ascii?Q?RhjGM/eHoKNCIiFLjTE7aPMKRkx/Jhrlcmk/v+nVxAzUN/L0EijI3JJ8jaVD?= =?us-ascii?Q?4y3SJxnk/e5VEEoL3QVUjsnTU+4aP7ooKcEQVGdFAVbxiqc1AwIDpIvImzkc?= =?us-ascii?Q?aMLg8NwQa4mwUnHdSIivUB/p8HjzAYZEFzuKGFlDmltdntWPvCecqhamQkke?= =?us-ascii?Q?f0epR3oYzSvcTwPPwtBZKGFAS01YM6+xGxV0/COS2NkiZOsKhHQzRpfnYw5N?= =?us-ascii?Q?YB6MHu5IZAov5CPrilh/S1M3DrjAUKHVbLhadyt+shUxgpEI0ACmldvE3fYI?= =?us-ascii?Q?hGSA0sKl8TjN9pFqC6gnXmnpmt6EA9RDtGcKfet7Cul85poIZY/LpQpKz70a?= =?us-ascii?Q?sfI76IHQhAVEfdv0hjo56cuXbvEnKHP4cNEg3V3KbRkI6/Y38/LEC5MyME8z?= =?us-ascii?Q?RDwZCGxEsppewWP1x+zl8GUUGdz2BTKT1v30OtNn2B9MhULkKXD0zBukL06P?= =?us-ascii?Q?4FPdAWAhRQCYMdxa+FnKZJG+pi3n+PxO4aky76uUKi0U4TZSIHonlQOwnbLo?= =?us-ascii?Q?gTfnPZ8Sw5eRToUWN73B4a4JvOSFPl/n83FbMOP8nlTUsYbUAas4pavfuE5h?= =?us-ascii?Q?qmF8xjfk/EUKDVnPWxOaL24fiAqMU0lL7zBjh/rUzsUEVTPLrUjrXkil1FC8?= =?us-ascii?Q?syOBsYrzdD9geRCe1ZpkxrWRt8atV8HFYIhO1t001n7kTb5IGrSFcn/SViga?= =?us-ascii?Q?I1G2KZlXqko5gNbNNdIghg3uZy4TguA54DcnhBKV5m68vxHGem7F8mLtOJcM?= =?us-ascii?Q?9LPKN8i+fl6DV6T4RhP62rEktyoX5egloz7HzrQOpGRNwoSPnvjf8rixzFml?= =?us-ascii?Q?/gFyfC/4WESsALo6CRok63XSB1Wj/KmbxaAJ2cWjA1YSmUEInUgCoaqdDC8i?= =?us-ascii?Q?3IoP9ThU6UB5GOCPspOi4q+3DOmWpnBecxVWb/AReJhX239FQQ02F8rHjZs/?= =?us-ascii?Q?g/hVhCuze8x/pa6XXxl+0azjGwNr49cDZ1AxGNbpXto5Bp7CRrVecVOYFYOP?= =?us-ascii?Q?2GR/Qx+vyZT2G9F6WuHMK62/rMSrhn0asJEKeAHYFll8+BFQBJXPo9MRvc2u?= =?us-ascii?Q?W0BV4nrT+w4h7yovWwkKJOF3xFp+2nYEjOjzPUqsUzz3OJhfhpNVaKTEORY2?= =?us-ascii?Q?vUl9mEc1FCHzfwyfrEXx50Oq2aPjIDttwpLIurlw9lMU+V/8fz9edf9Nn8aO?= =?us-ascii?Q?wURP9dLh0yNrvL8S5fFv/IeaCiAnqM53ryAvTgyvo1cZFRDPb0w1JOZKAtZ1?= =?us-ascii?Q?8tR96vfTb0eB74Rs7r2qsh+BKa2j7Rf3w6LfBCFX?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN9PR11MB5483.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e231bc7c-ca3c-4458-3a23-08dad123a460 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Nov 2022 09:33:43.8016 (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: IAx4NW+mY5TzGKNQqXsbTS5pqvYYhn0t61WlKE7sqLXjKdPdEUkUr4l8oco44wWUnAVwB845oBvjFyl49/YNQQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB6769 Return-Path: dun.tan@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi all, Could you please help to review this patch? Thanks a lot! Thanks, Dun -----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 PlatformC= I for Shell UnitTest Expand Ovmf PlatformBuild.py and PlatformBuildLib.py to support building an= d running specific Shell target UnitTest modules. In the new CommonPlatform class: It provides new class attributes and new methods to support build and run s= pecific Shell Unit Test modules. 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 evaluat= ion. In the new PlatformBuilder class for stuart_build: 1.In PlatformPostBuild(), it conditionally calls new API in CommonPlatform = to build -u ShellUnitTestList in -p PkgsToBuild and copy them to VirtualDri= ve folder. If no -p option, all the modules in -u ShellUnitTestList will be= built. 2.In FlashRomImage(), it conditionally calls the new API in CommonPlatform = to write all efi files name in VirtualDrive into startup.nsh and output Uni= tTest log into ShellUnitTestLog. 3. After the boot process, it conditionally calls new API in CommonPlatform= to check the UnitTest boot log. 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(-) diff --git a/OvmfPkg/PlatformCI/PlatformBuild.py b/OvmfPkg/PlatformCI/Platf= ormBuild.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=20 +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 Comm= onPlatform(): 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 line= . ''' + UnitTestModuleListStr =3D ','.join(ShellUnitTestListArg) + if not re.search(r'.+.inf:.+.dsc', UnitTestModuleListStr): + raise Exception('No valid ModulePath:DscPath in the -u {}'.for= mat(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=20 + {}'.format(cls.PackagesSupported)) + + @classmethod + def UpdateUnitTestConfig(cls, args): + ''' Update UnitTest config by -u ShellUnitTestList and -p PkgsToBu= ildForUT from cmd line. + ShellUnitTestList is in this format: {module1:dsc1, module2:ds= c2, module3:dsc2...}. + Only the modules which are in the PkgsToBuildForUT list are ad= ded 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 {}'.for= mat(args.ShellUnitTestList)) + UnitTestModuleList =3D UnitTestModuleListStr.split(',') + if args.PkgsToBuildForUT is None or all(['Pkg' not in Pkg for Pkg = in args.PkgsToBuildForUT]): + # No invalid Pkgs from input. Build all modules in -u UnitTest= ModuleList. + 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, 'Buil= d', "BUILDLOG_UnitTest.txt") + print('UnitTestModuleList is=20 + {}'.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_BASE= "), "VirtualDrive") + os.makedirs(VirtualDrive, exist_ok=3DTrue) + + # DSC by self.GetDscName() should have been built in BUILD process= . + BuiltDsc =3D [CommonPlatform.GetDscName(",".join(self.env.GetValue= ("TARGET_ARCH").split(' ')))] + for UnitTestPath, DscPath in CommonPlatform.UnitTestModuleList.ite= ms(): + if DscPath not in BuiltDsc: + ModuleName =3D os.path.split(UnitTestPath)[1].split('.inf'= )[0] + logging.info('Build {0} for {1}'.format(DscPath, ModuleNam= e)) + 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 UnitTes= t") + 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_DIRE= CTORY 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("TAR= GET") + "_" + self.env.GetValue("TOOL_CHAIN_TAG"), + UTArch, UnitTestPath.split('.inf')[0], "OUTPUT", = ModuleName + '.efi') + logging.info('Copy {0}.efi from:{1}'.format(ModuleName, EfiPat= h)) + shutil.copy(EfiPath, VirtualDrive) + return 0 + + @staticmethod + def WriteEfiToStartup(EfiFolder, FileObj): + ''' Write all the .efi files' name in VirtualDrive into Startup.ns= h ''' + 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.ShellUni= tTestLog)) + for Index in range(len(FileContent)): + if 'FAILURE MESSAGE:' in FileContent[Index]: + if FileContent[Index + 1].strip() !=3D '': + FailureMessage =3D FileContent[Index + 1] + FileConten= t[Index + 2] + return FailureMessage + return 0 + import PlatformBuildLib PlatformBuildLib.CommonPlatform =3D CommonPlatform diff --git a/OvmfPkg/Pl= atformCI/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, SetupSet= tingsManager, PrEvalSetting =20 return build_these_packages =20 + def AddCommandLineOptions(self, parserObj): + parserObj.add_argument('-u', '--UnitTest', dest=3D'ShellUnitTestLi= st', type=3Dstr, + help=3D'Optional - Key:Value that contains Shell UnitTest list= 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: + =20 + CommonPlatform.UpdatePackagesSupported(args.ShellUnitTestList) + def GetPlatformDscAndConfig(self) -> tuple: ''' If a platform desires to provide its DSC then Policy 4 will ev= aluate if any of the changes will be built in the dsc. =20 The tuple should be (, ) + This Policy 4 can only be applied when PackagesSupported only cont= ains OvmfPkg Since it doesn't support + mutiple packages evaluation. ''' - dsc =3D CommonPlatform.GetDscName(",".join(self.ActualArchitecture= s)) - return (f"OvmfPkg/{dsc}", {}) - + if (len(CommonPlatform.PackagesSupported) =3D=3D 1) and (CommonPla= tform.PackagesSupported[0] =3D=3D 'OvmfPkg'): + dsc =3D CommonPlatform.GetDscName(",".join(self.ActualArchitec= tures)) + return (f"OvmfPkg/{dsc}", {}) + return None =20 # ####################################################################= ################### # # Actual Configuration for Platform Build = # @@ -126,6 +139,14 @@ class PlatformBuilder( UefiBuilder, BuildSettingsManag= er): help=3D"Optional - CSV of architecture to build. IA32 will us= e IA32 for Pei & Dxe. " "X64 will use X64 for both PEI and DXE. IA32,X64 will use IA3= 2 for PEI and " "X64 for DXE. default is IA32,X64") + parserObj.add_argument('-p', '--pkg', '--pkg-dir', dest=3D'PkgsToB= uildForUT', type=3Dstr, + help=3D'Optional - Package list you want to build for UnitTest= .efi. (workspace relative).' + 'Can list multiple by doing -p , or -p -p <= pkg4>.If no valid input -p, build and run all -u UnitTest', + action=3D"append", default=3DNone) + parserObj.add_argument('-u', '--UnitTest', dest=3D'ShellUnitTestLi= st', type=3Dstr, + help=3D'Optional - Key:Value that contains Shell UnitTest list= 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, BuildSettingsManag= er): shell_environment.GetBuildVars().SetValue("TARGET_ARCH"," ".join(a= rgs.build_arch.upper().split(",")), "From CmdLine") dsc =3D CommonPlatform.GetDscName(args.build_arch) shell_environment.GetBuildVars().SetValue("ACTIVE_PLATFORM", f"Ovm= fPkg/{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, BuildSettingsManag= er): 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, BuildSettingsManag= er): 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 name = into startup.nsh. + CommonPlatform.WriteEfiToStartup(VirtualDrive, f) + # Output UnitTest log into ShellUnitTestLog. + args +=3D " -serial=20 + file:{}".format(CommonPlatform.ShellUnitTestLog) f.write("BOOT SUCCESS !!! \n") ## add commands here f.write("reset -s\n") @@ -222,6 +256,11 @@ class PlatformBuilder( UefiBuilder, BuildSettingsManag= er): =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