tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

cov-exclude (745B)


      1 #!/usr/bin/perl -p -i
      2 
      3 use warnings;
      4 use strict;
      5 our $excluding;
      6 
      7 # This script is meant to post-process a .gcov file for an input source
      8 # that was annotated with LCOV_EXCL_START, LCOV_EXCL_STOP, and LCOV_EXCL_LINE
      9 # entries.  It doesn't understand the LCOV_EXCL_BR* variations.
     10 #
     11 # It replaces unreached reached lines with x:, and reached excluded lines
     12 # with !!!num:.
     13 
     14 BEGIN { our $excluding = 0; }
     15 
     16 if (m/LCOV_EXCL_START/) {
     17   $excluding = 1;
     18 }
     19 if ($excluding and m/LCOV_EXCL_STOP/) {
     20   $excluding = 0;
     21 }
     22 
     23 my $exclude_this = (m/LCOV_EXCL_LINE/);
     24 
     25 if ($excluding or $exclude_this) {
     26   s{^\s*\#\#+:}{        x:};
     27   s{^   (\s*)(\d+):}{$1!!!$2:};
     28 }
     29 
     30 if (eof and $excluding) {
     31     warn "Runaway LCOV_EXCL_START in $ARGV";
     32     $excluding = 0;
     33 }
     34