0

When I use a stream operator, gcov/lcov report a branch not covered.

For example :

    namespace {
        const std::string LinuxBuildVersionFile = "/etc/linux.build.version";
    }

    std::string GetLinuxBuildVersion()
    {
        std::ifstream version_file(LinuxBuildVersionFile);
        std::string version;

        version_file >> version;

        return version;
    }

For the 3rd line, gcov reports : "one branch taken, one branch not taken". I suppose it is for the case where the file doesn't exist, but if so, it seems to me it should be reported in the stream operator coverage report.

What can I do so that the reported coverage is 100 % when I pass through this function ?

Thanks.

Oodini
  • 829
  • 1
  • 6
  • 16
  • Ok, what is your question? Do you want to know where the branch is coming from, or how to get it to report differently, or how to report bugs to gcov developers or something else entirely? –  Dec 08 '20 at 10:12
  • Can you provide information enough for us to be able to reproduce this? Please describe all the steps needed. – Ted Lyngmo Dec 08 '20 at 12:47
  • @dratenik I am interested in all these questions and their answer. – Oodini Dec 08 '20 at 15:42
  • @TedLyngmo I edited the code so that you can reproduce it. You just have to create a file (here /etc/linux.build.version). – Oodini Dec 08 '20 at 15:44
  • @Oodini What is the exact input to `lcov`? – Ted Lyngmo Dec 08 '20 at 16:55

0 Answers0