[PATCH] Added basic testing support for llvm-cov.

Yuchen Wu yuchenericwu at hotmail.com
Mon Nov 11 16:19:00 PST 2013


----------------------------------------
> From: mail at justinbogner.com
> To: llvm-commits at cs.uiuc.edu
> CC: llvm-commits at cs.uiuc.edu
> Subject: Re: [PATCH] Added basic testing support for llvm-cov.
> Date: Mon, 11 Nov 2013 15:52:18 -0800
>
>> +#include <unistd.h>
>
> Pretty sure this is left over from the previous patch - you don't use
> it.

Yep, that's my mistake.

>> using namespace llvm;
>>
>> static cl::opt<bool>
>> @@ -34,6 +35,9 @@ InputGCDA("gcda", cl::desc("<input gcda file>"), cl::init(""));
>> static cl::opt<std::string>
>> OutputFile("o", cl::desc("<output llvm-cov file>"), cl::init("-"));
>>
>> +static cl::opt<std::string>
>> +WorkingDir("C", cl::desc("change path of working directory"),
>> + cl::init(""));
>>
>> //===----------------------------------------------------------------------===//
>> int main(int argc, char **argv) {
>> @@ -54,8 +58,9 @@ int main(int argc, char **argv) {
>> errs() << " " << argv[0] << ": No gcov input file!\n";
>>
>> OwningPtr<MemoryBuffer> GCNO_Buff;
>> - if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputGCNO, GCNO_Buff)) {
>> - errs() << InputGCNO << ": " << ec.message() << "\n";
>> + if (error_code ec =
>> + MemoryBuffer::getFileOrSTDIN(WorkingDir + InputGCNO, GCNO_Buff)) {
>> + errs() << WorkingDir + InputGCNO << ": " << ec.message() << "\n";
>
> I think this only works correctly if the working dir is specified on the
> command line with a trailing slash. What if this is called with a
> spelling like "-C /some/dir"?

I appended an extra "/" to WorkingDir if it's non-empty, should fix that issue.

>> if (DumpGCOV)
>> GF.dump();
>>
>> FileInfo FI;
>> GF.collectLineCounts(FI);
>> - FI.print(OS, InputGCNO, InputGCDA);
>> + FI.print(OS, WorkingDir, InputGCNO, InputGCDA);
>
> Does this behave strangely if InputGCDA or InputGCNO are absolute paths?

It depends, without WorkingDir defined, it should be fine. If WorkingDir is defined, then you really shouldn't be using absolute paths for InputGCNO and InputGCDA.

>> return 0;
>> }
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits 		 	   		  



More information about the llvm-commits mailing list