@@ -1722,33 +1722,27 @@ sub list()
1722
1722
my $readSourceFile = ReadCurrentSource-> new();
1723
1723
my $data =
1724
1724
TraceFile-> load($list , $readSourceFile , $lcovutil::verify_checksum );
1725
- my $found ;
1726
- my $hit ;
1727
- my $entry ;
1728
- my $fn_found ;
1729
- my $fn_hit ;
1730
- my $br_found ;
1731
- my $br_hit ;
1732
1725
my $total_found = 0;
1733
1726
my $total_hit = 0;
1734
1727
my $fn_total_found = 0;
1735
1728
my $fn_total_hit = 0;
1736
1729
my $br_total_found = 0;
1737
1730
my $br_total_hit = 0;
1731
+ my $total_mcdc = 0;
1732
+ my $total_mcdc_hit = 0;
1738
1733
my $strlen = length (" Filename" );
1739
1734
my @footer ;
1740
- my $rate ;
1741
- my $fnrate ;
1742
- my $brrate ;
1743
1735
my $lastpath ;
1744
1736
my $F_LN_NUM = 0;
1745
1737
my $F_LN_RATE = 1;
1746
1738
my $F_FN_NUM = 2;
1747
1739
my $F_FN_RATE = 3;
1748
1740
my $F_BR_NUM = 4;
1749
1741
my $F_BR_RATE = 5;
1750
- my @fwidth_narrow = (5, 5, 3, 5, 4, 5);
1751
- my @fwidth_wide = (6, 5, 5, 5, 6, 5);
1742
+ my $F_MCDC_NUM = 6;
1743
+ my $F_MCDC_RATE = 7;
1744
+ my @fwidth_narrow = (5, 5, 3, 5, 4, 5, 4, 5);
1745
+ my @fwidth_wide = (6, 5, 5, 5, 6, 5, 6, 5);
1752
1746
my @fwidth = @fwidth_wide ;
1753
1747
my $max_width = $opt_list_width ;
1754
1748
my $max_long = $opt_list_truncate_max ;
@@ -1817,39 +1811,24 @@ sub list()
1817
1811
my $heading1 = sprintf (" %*s|" , $w , " " );
1818
1812
my $heading2 = sprintf (" %-*s|" , $w , " Filename" );
1819
1813
my $barlen = $w + 1;
1820
- # Line coverage rate
1821
- $w = $fwidth [$F_LN_RATE ];
1822
- $format .= " %${w} s " ;
1823
- $heading1 .= sprintf (" %-*s |" , $w + $fwidth [$F_LN_NUM ], " Lines" );
1824
- $heading2 .= sprintf (" %-*s " , $w , " Rate" );
1825
- $barlen += $w + 1;
1826
- # Number of lines
1827
- $w = $fwidth [$F_LN_NUM ];
1828
- $format .= " %${w} s|" ;
1829
- $heading2 .= sprintf (" %*s|" , $w , " Num" );
1830
- $barlen += $w + 1;
1831
- # Function coverage rate
1832
- $w = $fwidth [$F_FN_RATE ];
1833
- $format .= " %${w} s " ;
1834
- $heading1 .= sprintf (" %-*s|" , $w + $fwidth [$F_FN_NUM ] + 1, " Functions" );
1835
- $heading2 .= sprintf (" %-*s " , $w , " Rate" );
1836
- $barlen += $w + 1;
1837
- # Number of functions
1838
- $w = $fwidth [$F_FN_NUM ];
1839
- $format .= " %${w} s|" ;
1840
- $heading2 .= sprintf (" %*s|" , $w , " Num" );
1841
- $barlen += $w + 1;
1842
- # Branch coverage rate
1843
- $w = $fwidth [$F_BR_RATE ];
1844
- $format .= " %${w} s " ;
1845
- $heading1 .= sprintf (" %-*s" , $w + $fwidth [$F_BR_NUM ] + 1, " Branches" );
1846
- $heading2 .= sprintf (" %-*s " , $w , " Rate" );
1847
- $barlen += $w + 1;
1848
- # Number of branches
1849
- $w = $fwidth [$F_BR_NUM ];
1850
- $format .= " %${w} s" ;
1851
- $heading2 .= sprintf (" %*s" , $w , " Num" );
1852
- $barlen += $w ;
1814
+
1815
+ foreach my $d ([' Lines' , $F_LN_NUM , $F_LN_RATE ],
1816
+ [' Functions' , $F_FN_NUM , $F_FN_RATE ],
1817
+ [' Branches' , $F_BR_NUM , $F_BR_RATE ],
1818
+ [' MC/DC' , $F_MCDC_NUM , $F_MCDC_RATE ],
1819
+ ) {
1820
+ my ($type , $n , $r ) = @$d ;
1821
+ $w = $fwidth [$r ];
1822
+ $format .= " %${w} s " ;
1823
+ $heading1 .= sprintf (" %-*s |" , $w + $fwidth [$n ], $type );
1824
+ $heading2 .= sprintf (" %-*s " , $w , " Rate" );
1825
+ $barlen += $w + 1;
1826
+ # Number of coverpoints
1827
+ $w = $fwidth [$n ];
1828
+ $format .= " %${w} s|" ;
1829
+ $heading2 .= sprintf (" %*s|" , $w , " Num" );
1830
+ $barlen += $w + 1;
1831
+ }
1853
1832
# Line end
1854
1833
$format .= " \n " ;
1855
1834
$heading1 .= " \n " ;
@@ -1890,20 +1869,16 @@ sub list()
1890
1869
}
1891
1870
$print_filename = shorten_filename($print_filename , $strlen );
1892
1871
}
1893
-
1894
- ($found , $hit , $br_found , $br_hit , $fn_found , $fn_hit ) =
1895
- $entry -> get_info();
1896
-
1897
- # Assume zero count if there is no function data for this file
1898
- if (!defined ($fn_found ) || !defined ($fn_hit )) {
1899
- $fn_found = 0;
1900
- $fn_hit = 0;
1901
- }
1902
- # Assume zero count if there is no branch data for this file
1903
- if (!defined ($br_found ) || !defined ($br_hit )) {
1904
- $br_found = 0;
1905
- $br_hit = 0;
1906
- }
1872
+ my $lineData = $entry -> sum();
1873
+ my $branchData = $entry -> sumbr();
1874
+ my $funcData = $entry -> func();
1875
+ my $mcdcData = $entry -> mcdc();
1876
+ my ($found , $hit , $br_found , $br_hit , $fn_found , $fn_hit , $mcdc_found ,
1877
+ $mcdc_hit )
1878
+ = ($lineData -> found(), $lineData -> hit(),
1879
+ $branchData -> found(), $branchData -> hit(),
1880
+ $funcData -> numFunc(), $funcData -> numHit(),
1881
+ $mcdcData -> found(), $mcdcData -> hit());
1907
1882
1908
1883
# Add line coverage totals
1909
1884
$total_found += $found ;
@@ -1914,46 +1889,41 @@ sub list()
1914
1889
# Add branch coverage totals
1915
1890
$br_total_found += $br_found ;
1916
1891
$br_total_hit += $br_hit ;
1892
+ $total_mcdc += $mcdc_found ;
1893
+ $total_mcdc_hit += $mcdc_hit ;
1917
1894
1918
- # Determine line coverage rate for this file
1919
- $rate = shorten_rate($hit , $found , $fwidth [$F_LN_RATE ]);
1920
- # Determine function coverage rate for this file
1921
- $fnrate = shorten_rate($fn_hit , $fn_found , $fwidth [$F_FN_RATE ]);
1922
- # Determine branch coverage rate for this file
1923
- $brrate = shorten_rate($br_hit , $br_found , $fwidth [$F_BR_RATE ]);
1924
-
1925
- # Assemble line parameters
1926
1895
my @file_data ;
1927
1896
push (@file_data , $print_filename );
1928
- push (@file_data , $rate );
1929
- push (@file_data , shorten_number($found , $fwidth [$F_LN_NUM ]));
1930
- push (@file_data , $fnrate );
1931
- push (@file_data , shorten_number($fn_found , $fwidth [$F_FN_NUM ]));
1932
- push (@file_data , $brrate );
1933
- push (@file_data , shorten_number($br_found , $fwidth [$F_BR_NUM ]));
1934
-
1897
+ foreach my $d ([$hit , $found , $F_LN_RATE , $F_LN_NUM ],
1898
+ [$fn_hit , $fn_found , $F_FN_RATE , $F_FN_NUM ],
1899
+ [$br_hit , $br_found , $F_BR_RATE , $F_BR_NUM ],
1900
+ [$mcdc_hit , $mcdc_found , $F_MCDC_RATE , $F_MCDC_NUM ],
1901
+ ) {
1902
+ my ($h , $f , $r , $n ) = @$d ;
1903
+
1904
+ push (@file_data , shorten_rate($h , $f , $fwidth [$r ]));
1905
+ push (@file_data , shorten_number($f , $fwidth [$n ]));
1906
+ }
1935
1907
# Print assembled line
1936
1908
printf ($format , @file_data );
1937
1909
}
1938
1910
1939
- # Determine total line coverage rate
1940
- $rate = shorten_rate($total_hit , $total_found , $fwidth [$F_LN_RATE ]);
1941
- # Determine total function coverage rate
1942
- $fnrate = shorten_rate($fn_total_hit , $fn_total_found , $fwidth [$F_FN_RATE ]);
1943
- # Determine total branch coverage rate
1944
- $brrate = shorten_rate($br_total_hit , $br_total_found , $fwidth [$F_BR_RATE ]);
1945
-
1946
1911
# Print separator
1947
1912
print ((" =" x $barlen ) . " \n " );
1948
1913
1949
1914
# Assemble line parameters
1950
1915
push (@footer , sprintf (" %*s" , $strlen , " Total:" ));
1951
- push (@footer , $rate );
1952
- push (@footer , shorten_number($total_found , $fwidth [$F_LN_NUM ]));
1953
- push (@footer , $fnrate );
1954
- push (@footer , shorten_number($fn_total_found , $fwidth [$F_FN_NUM ]));
1955
- push (@footer , $brrate );
1956
- push (@footer , shorten_number($br_total_found , $fwidth [$F_BR_NUM ]));
1916
+
1917
+ foreach my $d ([$total_hit , $total_found , $F_LN_RATE , $F_LN_NUM ],
1918
+ [$fn_total_hit , $fn_total_found , $F_FN_RATE , $F_FN_NUM ],
1919
+ [$br_total_hit , $br_total_found , $F_BR_RATE , $F_BR_NUM ],
1920
+ [$total_mcdc_hit , $total_mcdc , $F_MCDC_RATE , $F_MCDC_NUM ],
1921
+ ) {
1922
+ my ($h , $f , $r , $n ) = @$d ;
1923
+
1924
+ push (@footer , shorten_rate($h , $f , $fwidth [$r ]));
1925
+ push (@footer , shorten_number($f , $fwidth [$n ]));
1926
+ }
1957
1927
1958
1928
# Print assembled line
1959
1929
printf ($format , @footer );
0 commit comments