From: "Guo, Gua" <gua.guo@intel.com>
To: devel@edk2.groups.io
Cc: gua.guo@intel.com, Michael D Kinney <michael.d.kinney@intel.com>,
Sean Brogan <sean.brogan@microsoft.com>,
Michael Kubacki <mikuback@linux.microsoft.com>
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 [thread overview]
Message-ID: <20230510051457.1063-2-gua.guo@intel.com> (raw)
In-Reply-To: <20230510051457.1063-1-gua.guo@intel.com>
From: Gua Guo <gua.guo@intel.com>
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={workspace}Build
> --input_coverage=AAA.cov
> ...
> --input_coverage=NNN.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={workspace}Build
> --input_coverage=AAA.cov
> --input_coverage=coverage.cov
...
- Command Line N
> OpenCppCoverage
> --export_type binary:coverage.cov
> --working_dir={workspace}Build
> --input_coverage=NNN.cov
> --input_coverage=coverage.cov
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Kubacki <mikuback@linux.microsoft.com>
Signed-off-by: Gua Guo <gua.guo@intel.com>
---
.../HostBasedUnitTestRunner.py | 46 +++++++++++++++++--
1 file changed, 41 insertions(+), 5 deletions(-)
diff --git a/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.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 = glob.glob(os.path.join(buildOutputBase, "**","*Test*.exe"), recursive=True)
workspace = thebuilder.env.GetValue("WORKSPACE")
workspace = (workspace + os.sep) if workspace[-1] != os.sep else workspace
+ workspaceBuild = os.path.join(workspace, 'Build')
# Generate coverage file
coverageFile = ""
for testFile in testList:
ret = RunCmd("OpenCppCoverage", f"--source {workspace} --export_type binary:{testFile}.cov -- {testFile}")
- coverageFile += " --input_coverage=" + testFile + ".cov"
+ if ret != 0:
+ logging.error("UnitTest Coverage: Failed to collect coverage data.")
+ return 1
+
+ coverageFile = f" --input_coverage={testFile}.cov"
+ totalCoverageFile = os.path.join(buildOutputBase, 'coverage.cov')
+ if os.path.isfile(totalCoverageFile):
+ coverageFile += f" --input_coverage={totalCoverageFile}"
+ ret = RunCmd(
+ "OpenCppCoverage",
+ f"--export_type binary:{totalCoverageFile} " +
+ f"--working_dir={workspaceBuild} " +
+ f"{coverageFile}"
+ )
if ret != 0:
logging.error("UnitTest Coverage: Failed to collect coverage data.")
return 1
# Generate and XML file if requested.by each package
- ret = RunCmd("OpenCppCoverage", f"--export_type cobertura:{os.path.join(buildOutputBase, 'coverage.xml')} --working_dir={workspace}Build {coverageFile}")
+ ret = RunCmd(
+ "OpenCppCoverage",
+ f"--export_type cobertura:{os.path.join(buildOutputBase, 'coverage.xml')} " +
+ f"--working_dir={workspaceBuild} " +
+ f"--input_coverage={totalCoverageFile} "
+ )
if ret != 0:
logging.error("UnitTest Coverage: Failed to generate cobertura format xml in single package.")
return 1
# Generate total report XML file for all package
- testCoverageList = glob.glob(os.path.join(workspace, "Build", "**","*Test*.exe.cov"), recursive=True)
+ testCoverageList = glob.glob(os.path.join(workspace, "Build", "**", "*Test*.exe.cov"), recursive=True)
coverageFile = ""
+ totalCoverageFile = os.path.join(workspaceBuild, 'coverage.cov')
for testCoverage in testCoverageList:
- coverageFile += " --input_coverage=" + testCoverage
+ coverageFile = f" --input_coverage={testCoverage}"
+ if os.path.isfile(totalCoverageFile):
+ coverageFile += f" --input_coverage={totalCoverageFile}"
+ ret = RunCmd(
+ "OpenCppCoverage",
+ f"--export_type binary:{totalCoverageFile} " +
+ f"--working_dir={workspaceBuild} " +
+ f"{coverageFile}"
+ )
+ if ret != 0:
+ logging.error("UnitTest Coverage: Failed to collect coverage data.")
+ return 1
- ret = RunCmd("OpenCppCoverage", f"--export_type cobertura:{workspace}Build/coverage.xml --working_dir={workspace}Build {coverageFile}")
+ ret = RunCmd(
+ "OpenCppCoverage",
+ f"--export_type cobertura:{os.path.join(workspaceBuild, 'coverage.xml')} " +
+ f"--working_dir={workspaceBuild} " +
+ f"--input_coverage={totalCoverageFile}"
+ )
if ret != 0:
logging.error("UnitTest Coverage: Failed to generate cobertura format xml.")
return 1
--
2.39.2.windows.1
next prev parent reply other threads:[~2023-05-10 5:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-10 5:14 [PATCH v4 0/1] BaseTools/Plugin: Too many execute files cause "cmd too long" failure Guo, Gua
2023-05-10 5:14 ` Guo, Gua [this message]
2023-05-10 21:40 ` [edk2-devel] [PATCH v4 1/1] " Michael Kubacki
2023-05-10 22:00 ` Guo, Gua
2023-05-11 1:43 ` 回复: " gaoliming
2023-05-11 1:52 ` Michael D Kinney
2023-05-11 1:59 ` Guo, Gua
2023-05-11 2:06 ` 回复: " gaoliming
2023-05-11 2:12 ` Guo, Gua
2023-05-11 2:55 ` 回复: " gaoliming
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230510051457.1063-2-gua.guo@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox