From nobody Thu May 2 07:34:53 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1502830694895575.2663319846183; Tue, 15 Aug 2017 13:58:14 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0842E21D0A25A; Tue, 15 Aug 2017 13:55:47 -0700 (PDT) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E722621E1453D for ; Tue, 15 Aug 2017 13:55:45 -0700 (PDT) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP; 15 Aug 2017 13:58:11 -0700 Received: from mdkinney-mobl1.amr.corp.intel.com ([10.241.98.166]) by orsmga005.jf.intel.com with ESMTP; 15 Aug 2017 13:58:10 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,379,1498546800"; d="scan'208";a="137888602" From: Michael D Kinney To: edk2-devel@lists.01.org Date: Tue, 15 Aug 2017 13:58:08 -0700 Message-Id: <20170815205808.8060-1-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.13.1.windows.2 Subject: [edk2] [edk2-staging/edk2-test Patch V3] Test*Pkg: Replace POSTBUILD batch files with a python script X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Kinney , Andrew Fish MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Update the POSTBUILD step to use a python script to create and/or update the installer for the test framework and test cases. This expands the OS compatibility to include Windows, Linux, and Mac OS X. The python script TestFrameworkPkg/GenFramework.py is used by the TestFrameworkPkg to generate the installer with the test framework. This same python script is also used by packages that provide test cases (e.g. TestCasePkg) to add the test cases to the installer. The --package flag may be listed more than once for DSC files that build test cases from more than one package. The -v flag shows messages for all the directory and file operations. The usage for GenFramework.py is as follows: usage: GenFramework [-h] [--version] -a ARCH [ARCH ...] -t TOOLCHAIN -p PLATFORMFILE -b BUILDTARGET --conf=3D CONFDIRECTORY [-D [DEFINE [DEFINE ...]]] [-v] [--package [PACKAGE [PACKAGE ...]]] Create EDK II Test Framework installer in build output directory. Copyright (c) 2017, Intel Corporation. All rights reserved. optional arguments: -h, --help show this help message and exit --version show program's version number and exit -a ARCH [ARCH ...], --arch ARCH [ARCH ...] ARCHS is one of list: IA32, X64, IPF, ARM, AARCH64 or EBC, which overrides target.txt's TARGET_ARCH definition. To specify more archs, please repeat this option. -t TOOLCHAIN, --tagname TOOLCHAIN Using the Tool Chain Tagname to build the platform, overriding target.txt's TOOL_CHAIN_TAG definition. -p PLATFORMFILE, --platform PLATFORMFILE Build the platform specified by the DSC file name argument, overriding target.txt's ACTIVE_PLATFORM definition. -b BUILDTARGET, --buildtarget BUILDTARGET Using the TARGET to build the platform, overriding target.txt's TARGET definition. --conf=3D CONFDIRECTORY Specify the customized Conf directory. -D [DEFINE [DEFINE ...]], --define [DEFINE [DEFINE ...]] Macro: "Name [=3D Value]". -v, --verbose Turn on verbose output with informational messages printed --package [PACKAGE [PACKAGE ...]] The directory name of a package of tests to copy Cc: Andrew Fish Cc: Supreeth Venkatesh Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael Kinney --- TestCasePkg/GenFramework.cmd | 86 ------------ TestCasePkg/TestCasePkg.dsc | 2 +- TestFrameworkPkg/GenFramework.cmd | 111 ---------------- TestFrameworkPkg/GenFramework.py | 239 ++++++++++++++++++++++++++++++= ++++ TestFrameworkPkg/TestFrameworkPkg.dsc | 2 +- 5 files changed, 241 insertions(+), 199 deletions(-) delete mode 100644 TestCasePkg/GenFramework.cmd delete mode 100644 TestFrameworkPkg/GenFramework.cmd create mode 100644 TestFrameworkPkg/GenFramework.py diff --git a/TestCasePkg/GenFramework.cmd b/TestCasePkg/GenFramework.cmd deleted file mode 100644 index 280ca70aa..000000000 --- a/TestCasePkg/GenFramework.cmd +++ /dev/null @@ -1,86 +0,0 @@ -@REM @file -@REM Windows batch file used to create installer in build output directory -@REM -@REM Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
-@REM This program and the accompanying materials -@REM are licensed and made available under the terms and conditions of the= BSD License -@REM which accompanies this distribution. The full text of the license ma= y be found at -@REM http://opensource.org/licenses/bsd-license.php -@REM -@REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -@REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR = IMPLIED. -@REM - -@echo off - -::********************************************************************** -:: Parse command line arguments -::********************************************************************** -set ARCHLIST=3D -set CLEAN=3D"" -:ArgLoop -if /i "%~1"=3D=3D"" (goto Done) -if /i "%~1"=3D=3D"clean" ( - set CLEAN=3D%~1 - shift - goto ArgLoop -) -if /i "%~2"=3D=3D"" (goto Done) -if /i "%~1"=3D=3D"-a" ( - set ARCHLIST=3D%ARCHLIST% %~2 - shift - shift - goto ArgLoop -) -if /i "%~1"=3D=3D"-b" ( - set TARGET=3D%~2 - shift - shift - goto ArgLoop -) -if /i "%~1"=3D=3D"-t" ( - set TOOLCHAIN=3D%~2 - shift - shift - goto ArgLoop -) -shift -goto ArgLoop -:Done - -for %%G in (%ARCHLIST%) do ( - set ARCH=3D%%G - call :CopyFiles -) - -goto Finished - -:CopyFiles -set Framework=3D%WORKSPACE%\Build\SctPackage\%ARCH% -set BuildOutput=3D%WORKSPACE%\Build\TestCasePkg\%TARGET%_%TOOLCHAIN%\%ARCH% - -if not %CLEAN%=3D=3D"" ( - if exist %Framework%\Test rmdir /s/q %Framework%\Test - exit /b -) - -rem ********************************************* -rem Create target directories -rem ********************************************* - -if not exist %Framework% mkdir %Framework% -for %%G in (Data, Dependency, Support, Test, Sequence, Report, Proxy) do ( - if not exist %Framework%\%%G mkdir %Framework%\%%G -) - -::***************************************************** -:: Copy all test cases -::***************************************************** - -copy %BuildOutput%\*.efi %Framework%\Test > NUL -exit /b - -:Finished - - - diff --git a/TestCasePkg/TestCasePkg.dsc b/TestCasePkg/TestCasePkg.dsc index c2f1832ae..7ef656c27 100644 --- a/TestCasePkg/TestCasePkg.dsc +++ b/TestCasePkg/TestCasePkg.dsc @@ -22,7 +22,7 @@ SUPPORTED_ARCHITECTURES =3D IA32|IPF|X64|EBC|ARM BUILD_TARGETS =3D DEBUG|RELEASE SKUID_IDENTIFIER =3D DEFAULT - POSTBUILD =3D TestCasePkg/GenFramework.cmd + POSTBUILD =3D python TestFrameworkPkg/GenFramework.= py --package TestCasePkg =20 [LibraryClasses] UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntry= Point.inf diff --git a/TestFrameworkPkg/GenFramework.cmd b/TestFrameworkPkg/GenFramew= ork.cmd deleted file mode 100644 index 256294801..000000000 --- a/TestFrameworkPkg/GenFramework.cmd +++ /dev/null @@ -1,111 +0,0 @@ -@REM @file -@REM Windows batch file used to create installer in build output directory -@REM -@REM Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
-@REM This program and the accompanying materials -@REM are licensed and made available under the terms and conditions of the= BSD License -@REM which accompanies this distribution. The full text of the license ma= y be found at -@REM http://opensource.org/licenses/bsd-license.php -@REM -@REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -@REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR = IMPLIED. -@REM - -@echo off - -::********************************************************************** -:: Parse command line arguments -::********************************************************************** -set ARCHLIST=3D -set CLEAN=3D"" -:ArgLoop -if /i "%~1"=3D=3D"" (goto Done) -if /i "%~1"=3D=3D"clean" ( - set CLEAN=3D%~1 - shift - goto ArgLoop -) -if /i "%~2"=3D=3D"" (goto Done) -if /i "%~1"=3D=3D"-a" ( - set ARCHLIST=3D%ARCHLIST% %~2 - shift - shift - goto ArgLoop -) -if /i "%~1"=3D=3D"-b" ( - set TARGET=3D%~2 - shift - shift - goto ArgLoop -) -if /i "%~1"=3D=3D"-t" ( - set TOOLCHAIN=3D%~2 - shift - shift - goto ArgLoop -) -shift -goto ArgLoop -:Done - - -@set TEST_FRAMEWORK_PKG_PATH=3D%WORKSPACE%\TestFrameworkPkg -@if defined PACKAGES_PATH ( - @for %%i IN (%PACKAGES_PATH%) DO ( - @if exist %%~fi\TestFrameworkPkg ( - @set TEST_FRAMEWORK_PKG_PATH=3D%%~fi\TestFrameworkPkg - @goto ProcessArchList - ) - ) -) - -:ProcessArchList -for %%G in (%ARCHLIST%) do ( - set ARCH=3D%%G - call :CopyFiles -) - -goto Finished - -:CopyFiles -set Framework=3D%WORKSPACE%\Build\SctPackage\%ARCH% -set BuildOutput=3D%WORKSPACE%\Build\TestFrameworkPkg\%TARGET%_%TOOLCHAIN%\= %ARCH% -if not %CLEAN%=3D=3D"" ( - if exist %Framework%\.. rmdir /s/q %Framework%\.. - exit /b -) - -rem ********************************************* -rem Create target directories -rem ********************************************* - -if not exist %Framework% mkdir %Framework% -for %%G in (Data, Dependency, Support, Test, Sequence, Report, Proxy) do ( - if not exist %Framework%\%%G mkdir %Framework%\%%G -) - -::***************************************************** -:: Copy the SCT framework and the related application -::***************************************************** - -copy %BuildOutput%\InstallSct.efi %Framework% > NUL -copy %BuildOutput%\StallForKey.efi %Framework% > NUL - -copy %BuildOutput%\SCT.efi %Framework% > NUL - -copy %BuildOutput%\StandardTest.efi %Framework%\Support > NUL -copy %BuildOutput%\TestProfile.efi %Framework%\Support > NUL -copy %BuildOutput%\TestRecovery.efi %Framework%\Support > NUL -copy %BuildOutput%\TestLogging.efi %Framework%\Support > NUL - - -::********************************************* -:: Copy the SCT configuration data -::********************************************* - -copy %TEST_FRAMEWORK_PKG_PATH%\Scripts\SctStartup.nsh %Framework%\.. =20 -copy %TEST_FRAMEWORK_PKG_PATH%\Data\Category.ini %Framework%\Data >= NUL -copy %TEST_FRAMEWORK_PKG_PATH%\Data\GuidFile.txt %Framework%\Data >= NUL -exit /b - -:Finished diff --git a/TestFrameworkPkg/GenFramework.py b/TestFrameworkPkg/GenFramewo= rk.py new file mode 100644 index 000000000..8a1527883 --- /dev/null +++ b/TestFrameworkPkg/GenFramework.py @@ -0,0 +1,239 @@ +## @file +# Create EDK II Test Framework installer in build output directory +# +# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BS= D License +# which accompanies this distribution. The full text of the license may b= e found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. +# + +''' +GenFramework +''' + +import os +import sys +import argparse +import glob +import shutil + +# +# Globals for help information +# +__prog__ =3D 'GenFramework' +__version__ =3D '%s Version %s' % (__prog__, '1.0') +__copyright__ =3D 'Copyright (c) 2017, Intel Corporation. All rights res= erved.' +__description__ =3D 'Create EDK II Test Framework installer in build outpu= t directory.\n' + +# +# Globals +# +gWorkspace =3D '' +gArgs =3D None + +def Log(Message): + if not gArgs.Verbose: + return + sys.stdout.write (__prog__ + ': ' + Message + '\n') + +def Error(Message, ExitValue=3D1): + sys.stderr.write (__prog__ + ': ERROR: ' + Message + '\n') + sys.exit (ExitValue) + +def RelativePath(target): + return os.path.relpath (target, gWorkspace) + +def NormalizePath(target): + if isinstance(target, tuple): + return os.path.normpath (os.path.join (*target)) + else: + return os.path.normpath (target) + +def RemoveDirectory(target): + target =3D NormalizePath(target) + if not target or target =3D=3D os.pathsep: + Error ('RemoveDirectory() invalid target') + if os.path.exists(target): + Log ('rmdir %s' % (RelativePath (target))) + shutil.rmtree(target) + +def CreateDirectory(target): + target =3D NormalizePath(target) + if not os.path.exists(target): + Log ('mkdir %s' % (RelativePath (target))) + os.makedirs (target) + +def Copy(src, dst): + src =3D NormalizePath(src) + dst =3D NormalizePath(dst) + for File in glob.glob(src): + Log ('copy %s -> %s' % (RelativePath (File), RelativePath (dst))) + shutil.copy (File, dst) + +if __name__ =3D=3D '__main__': + # + # Create command line argument parser object + # + parser =3D argparse.ArgumentParser ( + prog =3D __prog__, + version =3D __version__, + description =3D __description__ + __copyright__, + conflict_handler =3D 'resolve' + ) + parser.add_argument ( + '-a', '--arch', dest =3D 'Arch', nargs =3D '+', action =3D 'app= end', + required =3D True, + help =3D '''ARCHS is one of list: IA32, X64, IPF, ARM, AARCH64 = or EBC, + which overrides target.txt's TARGET_ARCH definition. = To + specify more archs, please repeat this option.''' + ) + parser.add_argument ( + '-t', '--tagname', dest =3D 'ToolChain', required =3D True, + help =3D '''Using the Tool Chain Tagname to build the platform, + overriding target.txt's TOOL_CHAIN_TAG definition.''' + ) + parser.add_argument ( + '-p', '--platform', dest =3D 'PlatformFile', required =3D True, + help =3D '''Build the platform specified by the DSC file name a= rgument, + overriding target.txt's ACTIVE_PLATFORM definition.''' + ) + parser.add_argument ( + '-b', '--buildtarget', dest =3D 'BuildTarget', required =3D Tru= e, + help =3D '''Using the TARGET to build the platform, overriding + target.txt's TARGET definition.''' + ) + parser.add_argument ( + '--conf=3D', dest =3D 'ConfDirectory', required =3D True, + help =3D '''Specify the customized Conf directory.''' + ) + parser.add_argument ( + '-D', '--define', dest =3D 'Define', nargs=3D'*', action =3D 'a= ppend', + help =3D '''Macro: "Name [=3D Value]".''' + ) + parser.add_argument ( + '-v', '--verbose', dest =3D 'Verbose', action =3D 'store_true', + help =3D '''Turn on verbose output with informational messages = printed''' + ) + parser.add_argument ( + '--package', dest =3D 'Package', nargs =3D '*', action =3D 'app= end', + help =3D '''The directory name of a package of tests to copy''' + ) + + # + # Parse command line arguments + # + gArgs, remaining =3D parser.parse_known_args() + gArgs.BuildType =3D 'all' + for BuildType in ['all', 'fds', 'genc', 'genmake', 'clean', 'cleanall', = 'modules', 'libraries', 'run']: + if BuildType in remaining: + gArgs.BuildType =3D BuildType + remaining.remove(BuildType) + break + gArgs.Remaining =3D ' '.join(remaining) + + # + # Start + # + Log ('Start') + + # + # Get WORKSPACE environment variable + # + try: + gWorkspace =3D os.environ['WORKSPACE'] + except: + Error ('WORKSPACE environment variable not set') + + # + # Find test framework package directory in WORKSPACE or PACKAGES_PATH + # + PathList =3D [gWorkspace] + try: + PathList +=3D os.environ['PACKAGES_PATH'].split(os.pathsep) + except: + pass + for Path in PathList: + TestFrameworkPkgPath =3D NormalizePath((Path, 'TestFrameworkPkg')) + if os.path.exists(TestFrameworkPkgPath): + break + if not os.path.exists(TestFrameworkPkgPath): + Error ('TestFrameworkPkg directory not found in WORKSPACE or PACKAGES_= PATH') + + # + # Process build target + # + InstallerPath =3D NormalizePath((gWorkspace, 'Build', 'SctPackage')) + if gArgs.BuildType =3D=3D 'clean': + if gArgs.Package: + # + # Remove test cases for each package and CPU architecture + # + for Arch in gArgs.Arch: + Arch =3D Arch[0] + for Package in gArgs.Package: + Package =3D Package[0] + Log ('Remove test cases from %s from test framework installer in= %s' % (Package, InstallerPath)) + RemoveDirectory ((InstallerPath, Arch, 'Test', Package)) + else: + # + # Remove the installer + # + Log ('Remove test framework installer in %s' % (InstallerPath)) + RemoveDirectory (InstallerPath) + else: + if gArgs.Package: + # + # Copy test cases for each package and CPU architcture + # + for Package in gArgs.Package: + Package =3D Package[0] + Log ('Add test cases from %s to test framework installer in %s' % = (Package, InstallerPath)) + for Arch in gArgs.Arch: + Arch =3D Arch[0] + BuildOutput =3D NormalizePath(( + gWorkspace, + 'Build', + Package, + gArgs.BuildTarget + '_' + gArgs.ToolChain, + Arch + )) + if os.path.exists(BuildOutput): + CreateDirectory ((InstallerPath, Arch, 'Test', Package)) + Copy ((BuildOutput, '*.efi'), (InstallerPath, Arch, 'Test', Pa= ckage)) + else: + # + # Copy test framework files for each CPU architcture + # + Log ('Create test framework installer in %s' % (InstallerPath)) + CreateDirectory ((InstallerPath)) + Copy ((TestFrameworkPkgPath, 'Scripts', 'SctStartup.nsh'), (Installe= rPath)) + for Arch in gArgs.Arch: + Arch =3D Arch[0] + for Directory in ['Data', 'Dependency', 'Support', 'Test', 'Sequen= ce', 'Report', 'Proxy']: + CreateDirectory ((InstallerPath, Arch, Directory)) + + BuildOutput =3D NormalizePath(( + gWorkspace, + 'Build', + 'TestFrameworkPkg', + gArgs.BuildTarget + '_' + gArgs.ToolChain, + Arch + )) + if os.path.exists(BuildOutput): + for File in ['InstallSct.efi', 'StallForKey.efi', 'Sct.efi']: + Copy ((BuildOutput, File), (InstallerPath, Arch)) + for File in ['StandardTest.efi', 'TestProfile.efi', 'TestRecover= y.efi', 'TestLogging.efi']: + Copy ((BuildOutput, File), (InstallerPath, Arch, 'Support')) + + Copy ((TestFrameworkPkgPath, 'Data/Category.ini'), (InstallerPath,= Arch, 'Data')) + Copy ((TestFrameworkPkgPath, 'Data/GuidFile.txt'), (InstallerPath,= Arch, 'Data')) + Copy ((TestFrameworkPkgPath, 'Data/GuidFile.txt'), (InstallerPath,= Arch, 'Data')) + + # + # Done + # + Log ('Done') diff --git a/TestFrameworkPkg/TestFrameworkPkg.dsc b/TestFrameworkPkg/TestF= rameworkPkg.dsc index 93c8886af..b906839a1 100644 --- a/TestFrameworkPkg/TestFrameworkPkg.dsc +++ b/TestFrameworkPkg/TestFrameworkPkg.dsc @@ -22,7 +22,7 @@ SUPPORTED_ARCHITECTURES =3D IA32|IPF|X64|EBC|ARM BUILD_TARGETS =3D DEBUG|RELEASE SKUID_IDENTIFIER =3D DEFAULT - POSTBUILD =3D TestFrameworkPkg/GenFramework.cmd + POSTBUILD =3D python TestFrameworkPkg/GenFramework.= py =20 [LibraryClasses] UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntry= Point.inf --=20 2.13.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel