From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.37258.1683648753444691162 for ; Tue, 09 May 2023 09:12:33 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=PbHgeZyF; spf=pass (domain: linux.microsoft.com, ip: 13.77.154.182, mailfrom: mikuback@linux.microsoft.com) Received: from [192.168.4.22] (unknown [47.201.8.94]) by linux.microsoft.com (Postfix) with ESMTPSA id 8D85920B92A1; Tue, 9 May 2023 09:12:32 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 8D85920B92A1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1683648753; bh=1zZvLWOzE6QVeOfecRrxU70W7jTHklSEp5dkuIuoupY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=PbHgeZyFgxyZPp+/WZAazPLXOkqwmwdLZ9j8auIrUz3yYiTVzV5jFtD2mED+zeVkz sNdgace2oeMkS5LwnqoqPtCEAbETC9rRO3eU0dQTXyjBpo62Ye925m0fChHZfYTY15 xc7tr3NlP3Ycc9fh8oYJWC/FQmabKW7mAakRIfuA= Message-ID: <13c3ec25-54b3-334d-1e64-cd579185a277@linux.microsoft.com> Date: Tue, 9 May 2023 12:12:31 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: [PATCH v3] BaseTools/Plugin: Too many execute filess cause "cmd too long" failure To: gua.guo@intel.com, devel@edk2.groups.io Cc: Michael D Kinney , Sean Brogan References: <20230508201849.36-1-gua.guo@intel.com> From: "Michael Kubacki" In-Reply-To: <20230508201849.36-1-gua.guo@intel.com> Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit I understand it was common in some parts of the code base at one point to wrap all expressions in parentheses, but can it be avoided in newly added code? For example make: if (os.path.isfile(f"{os.path.join(buildOutputBase, 'coverage.cov')}")): Be: if os.path.isfile(f"{os.path.join(buildOutputBase, 'coverage.cov')}"): The first style is not consistent with what you added elsewhere: if ret != 0: And the parentheses are unnecessary in this case and don't follow typical Python style. --- Due to the number of references, it would be easier to follow if this path were assigned to a variable: os.path.join(buildOutputBase, 'coverage.cov') --- For consistency/compatibility, please use os.path.join() (or a similar abstraction) to build paths in cases like the following: if (os.path.isfile(f"{workspace}Build/coverage.cov")): --- Did you see any significant performance impact with this change? Thanks, Michael On 5/8/2023 4:18 PM, gua.guo@intel.com wrote: > 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={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 > Cc: Sean Brogan > Cc: Michael Kubacki > Signed-off-by: Gua Guo > --- > .../HostBasedUnitTestRunner.py | 31 ++++++++++++++++--- > 1 file changed, 27 insertions(+), 4 deletions(-) > > diff --git a/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py b/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py > index d993de9412..05bb6da50a 100644 > --- a/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py > +++ b/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py > @@ -209,13 +209,25 @@ class HostBasedUnitTestRunner(IUefiBuildPlugin): > 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" > > + if (os.path.isfile(f"{os.path.join(buildOutputBase, 'coverage.cov')}")): > > + coverageFile += f" --input_coverage={os.path.join(buildOutputBase, 'coverage.cov')}" > > + ret = RunCmd("OpenCppCoverage", f"--export_type binary:{os.path.join(buildOutputBase, 'coverage.cov')} --working_dir={workspace}Build {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={workspace}Build " + > > + f"--input_coverage={os.path.join(buildOutputBase, 'coverage.cov')}" > > + ) > > if ret != 0: > > logging.error("UnitTest Coverage: Failed to generate cobertura format xml in single package.") > > return 1 > > @@ -224,9 +236,20 @@ class HostBasedUnitTestRunner(IUefiBuildPlugin): > testCoverageList = glob.glob(os.path.join(workspace, "Build", "**","*Test*.exe.cov"), recursive=True) > > coverageFile = "" > > for testCoverage in testCoverageList: > > - coverageFile += " --input_coverage=" + testCoverage > > + coverageFile = f" --input_coverage={testCoverage}" > > + if (os.path.isfile(f"{workspace}Build/coverage.cov")): > > + coverageFile += f" --input_coverage={workspace}Build/coverage.cov" > > + ret = RunCmd("OpenCppCoverage", f"--export_type binary:{workspace}Build/coverage.cov --working_dir={workspace}Build {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:{workspace}Build/coverage.xml " + > > + f"--working_dir={workspace}Build " + > > + f"--input_coverage={workspace}Build/coverage.cov" > > + ) > > if ret != 0: > > logging.error("UnitTest Coverage: Failed to generate cobertura format xml.") > > return 1 >