XCode 5.1 Unit Test Coverage Analysis Fails On Files Using Blocks

前端 未结 4 1395
醉话见心
醉话见心 2020-12-13 02:46

Today I was tasked with adding unit test coverage analysis to our code base. Today is also the day iOS 7.1 is released along with XCode 5.1. From the release notes:

相关标签:
4条回答
  • 2020-12-13 03:27

    Actually I noticed that lcov is invoking gcov with -b option and gcov-4.2 will crash on this option (raise segmentation fault). If I remove the -b option from getinfo, then even though it still shows some error info, the gcov file can still be generated.

    That is probably why coverstory can still give coverage output. So I guess the workaround is to remove -b option from lcov. And also as you suggested, ignore the error in getinfo

    0 讨论(0)
  • 2020-12-13 03:42

    The problem is in the LCOV 1.10 geninfo script. It tests for the current version of gcov. It does this by parsing the version string. Since gcov now points to llvm-cov, the version string is parsed incorrectly.

    The solution is to modify geninfo’s get_gcov_version() subroutine. In line 1868, change -v to --version. Then replace line 1874 with:

    if ($version_string =~ m/LLVM/)
    {
        info("Found llvm-cov\n");
        $result = 0x40201;
    }
    elsif ($version_string =~ /(\d+)\.(\d+)(\.(\d+))?/)
    

     

    The modified subroutine should look like this:

    sub get_gcov_version()
    {
        local *HANDLE;
        my $version_string;
        my $result;
    
        open(GCOV_PIPE, "-|", "$gcov_tool --version")
            or die("ERROR: cannot retrieve gcov version!\n");
        $version_string = <GCOV_PIPE>;
        close(GCOV_PIPE);
    
        $result = 0;
        if ($version_string =~ m/LLVM/)
        {
            info("Found llvm-cov\n");
            $result = 0x40201;
        }
        elsif ($version_string =~ /(\d+)\.(\d+)(\.(\d+))?/)
        {
            if (defined($4))
            {
                info("Found gcov version: $1.$2.$4\n");
                $result = $1 << 16 | $2 << 8 | $4;
            }
            else
            {
                info("Found gcov version: $1.$2\n");
                $result = $1 << 16 | $2 << 8;
            }
        }
        return ($result, $version_string);
    }
    

     

    NOTE: Make sure --gcov-tool is not set to gcov-4.2.

    0 讨论(0)
  • 2020-12-13 03:42

    Rather than modifying geninfo I created an llvm-cov-wrapper script and used lcov's --gcov-tool command line option:

    #!/bin/bash
    # llvm-cov wrapper to make it behave more like gcov
    
    if [ "$1" = "-v" ]; then
        echo "llvm-cov-wrapper 4.2.1"
        exit 0
    else
        /usr/bin/gcov $*
    fi
    
    0 讨论(0)
  • 2020-12-13 03:48

    For anyone new to this thread, note that lcov-1.11 is out. This eliminates the issue with gcov -v compatibility. However, I am using XCode 6.1 and still getting errors on some files.

    geninfo: WARNING: /Users/XXX/MyFile.gcno: found unrecognized record format - skipping

    Note that you can add --ignore-errors graph to skip over these errors, but the problem isn't really solved.

    0 讨论(0)
提交回复
热议问题