From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web11.9406.1683695701564861887 for ; Tue, 09 May 2023 22:15:05 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=jVYJXiVy; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: gua.guo@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683695705; x=1715231705; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Smcjn5BjyBfGpio6L9xJHfzhSCSqdOFGNDaRflk1JzM=; b=jVYJXiVyG4baopjlauVHchHnNHxU5LWFgv+/IwnMAHbj1f7FyiG4C3JV kRmJxHwg9JN9jHTIQbtGqbTQ0UJakM4t63neoIn+LrsbImJNBoDLVm5+N 6gE9XNlE+2cnTy+7mtJlrFMBXaxd8PyRMc+tCViGJ+pS0Bie9wnp9HzNR /8Q7PvH3eerRJ0D3kB8FbIrOPSuauR4xiHwGvCjSMP6ul8zd1Q8kjs9QP 9foDBUZvvmuUH7Cuw6lAr0dxrYUTUmIurgyO7GX6+uqO9ltGx/mBiQ6Lv QS5FVLN4/RtKoYC9eO/6ckXjzwKm5gmDgzFLt843JU7B5CcmN8OpQVNHa w==; X-IronPort-AV: E=McAfee;i="6600,9927,10705"; a="329746748" X-IronPort-AV: E=Sophos;i="5.99,263,1677571200"; d="scan'208";a="329746748" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2023 22:15:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10705"; a="699157345" X-IronPort-AV: E=Sophos;i="5.99,263,1677571200"; d="scan'208";a="699157345" Received: from gguo-desk.gar.corp.intel.com ([10.5.215.23]) by orsmga002.jf.intel.com with ESMTP; 09 May 2023 22:15:04 -0700 From: "Guo, Gua" To: devel@edk2.groups.io Cc: gua.guo@intel.com, Michael D Kinney , Sean Brogan , Michael Kubacki Subject: [PATCH v4 1/1] BaseTools/Plugin: Too many execute files cause "cmd too long" failure Date: Wed, 10 May 2023 13:14:57 +0800 Message-Id: <20230510051457.1063-2-gua.guo@intel.com> X-Mailer: git-send-email 2.39.2.windows.1 In-Reply-To: <20230510051457.1063-1-gua.guo@intel.com> References: <20230510051457.1063-1-gua.guo@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Gua Guo Windows command prompt have 8191 characters limitation, enhance it to make command too long can be resloved. Provide an example, if have too many cov files, it causes to run single command over the 8191 characters limitation. > OpenCppCoverage > --export_type binary:coverage.cov > --working_dir=3D{workspace}Build > --input_coverage=3DAAA.cov > ... > --input_coverage=3DNNN.cov The solution is passing many coverage files in single command line to breaking it up into many command lines with one coverage file per command line in order to prevent single line is over to 8191 characters. - Command Line 1 > OpenCppCoverage > --export_type binary:coverage.cov > --working_dir=3D{workspace}Build > --input_coverage=3DAAA.cov > --input_coverage=3Dcoverage.cov ... - Command Line N > OpenCppCoverage > --export_type binary:coverage.cov > --working_dir=3D{workspace}Build > --input_coverage=3DNNN.cov > --input_coverage=3Dcoverage.cov Cc: Michael D Kinney Cc: Sean Brogan Cc: Michael Kubacki Signed-off-by: Gua Guo --- .../HostBasedUnitTestRunner.py | 46 +++++++++++++++++-- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunn= er.py b/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py index d993de9412..2e5c462cd2 100644 --- a/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py +++ b/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py @@ -205,28 +205,64 @@ class HostBasedUnitTestRunner(IUefiBuildPlugin): testList =3D glob.glob(os.path.join(buildOutputBase, "**","*Test*.= exe"), recursive=3DTrue)=0D workspace =3D thebuilder.env.GetValue("WORKSPACE")=0D workspace =3D (workspace + os.sep) if workspace[-1] !=3D os.sep el= se workspace=0D + workspaceBuild =3D os.path.join(workspace, 'Build')=0D # Generate coverage file=0D coverageFile =3D ""=0D for testFile in testList:=0D ret =3D RunCmd("OpenCppCoverage", f"--source {workspace} --exp= ort_type binary:{testFile}.cov -- {testFile}")=0D - coverageFile +=3D " --input_coverage=3D" + testFile + ".cov"=0D + if ret !=3D 0:=0D + logging.error("UnitTest Coverage: Failed to collect covera= ge data.")=0D + return 1=0D +=0D + coverageFile =3D f" --input_coverage=3D{testFile}.cov"=0D + totalCoverageFile =3D os.path.join(buildOutputBase, 'coverage.= cov')=0D + if os.path.isfile(totalCoverageFile):=0D + coverageFile +=3D f" --input_coverage=3D{totalCoverageFile= }"=0D + ret =3D RunCmd(=0D + "OpenCppCoverage",=0D + f"--export_type binary:{totalCoverageFile} " +=0D + f"--working_dir=3D{workspaceBuild} " +=0D + f"{coverageFile}"=0D + )=0D if ret !=3D 0:=0D logging.error("UnitTest Coverage: Failed to collect covera= ge data.")=0D return 1=0D =0D # Generate and XML file if requested.by each package=0D - ret =3D RunCmd("OpenCppCoverage", f"--export_type cobertura:{os.pa= th.join(buildOutputBase, 'coverage.xml')} --working_dir=3D{workspace}Build = {coverageFile}")=0D + ret =3D RunCmd(=0D + "OpenCppCoverage",=0D + f"--export_type cobertura:{os.path.join(buildOutputBase, 'cove= rage.xml')} " +=0D + f"--working_dir=3D{workspaceBuild} " +=0D + f"--input_coverage=3D{totalCoverageFile} "=0D + )=0D if ret !=3D 0:=0D logging.error("UnitTest Coverage: Failed to generate cobertura= format xml in single package.")=0D return 1=0D =0D # Generate total report XML file for all package=0D - testCoverageList =3D glob.glob(os.path.join(workspace, "Build", "*= *","*Test*.exe.cov"), recursive=3DTrue)=0D + testCoverageList =3D glob.glob(os.path.join(workspace, "Build", "*= *", "*Test*.exe.cov"), recursive=3DTrue)=0D coverageFile =3D ""=0D + totalCoverageFile =3D os.path.join(workspaceBuild, 'coverage.cov')= =0D for testCoverage in testCoverageList:=0D - coverageFile +=3D " --input_coverage=3D" + testCoverage=0D + coverageFile =3D f" --input_coverage=3D{testCoverage}"=0D + if os.path.isfile(totalCoverageFile):=0D + coverageFile +=3D f" --input_coverage=3D{totalCoverageFile= }"=0D + ret =3D RunCmd(=0D + "OpenCppCoverage",=0D + f"--export_type binary:{totalCoverageFile} " +=0D + f"--working_dir=3D{workspaceBuild} " +=0D + f"{coverageFile}"=0D + )=0D + if ret !=3D 0:=0D + logging.error("UnitTest Coverage: Failed to collect covera= ge data.")=0D + return 1=0D =0D - ret =3D RunCmd("OpenCppCoverage", f"--export_type cobertura:{works= pace}Build/coverage.xml --working_dir=3D{workspace}Build {coverageFile}")=0D + ret =3D RunCmd(=0D + "OpenCppCoverage",=0D + f"--export_type cobertura:{os.path.join(workspaceBuild, 'cover= age.xml')} " +=0D + f"--working_dir=3D{workspaceBuild} " +=0D + f"--input_coverage=3D{totalCoverageFile}"=0D + )=0D if ret !=3D 0:=0D logging.error("UnitTest Coverage: Failed to generate cobertura= format xml.")=0D return 1=0D --=20 2.39.2.windows.1