1function gbcovshow 2%GBCOVSHOW report GraphBLAS statement coverage 3 4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved. 5% SPDX-License-Identifier: GPL-3.0-or-later 6 7% report the coverage summary 8 9global gbcov_global 10 11if (isempty (gbcov_global)) 12 error ('no coverage stats') ; 13end 14 15covered = sum (gbcov_global > 0) ; 16not_covered = find (gbcov_global == 0) - 1 ; 17n = length (gbcov_global) ; 18 19fprintf ('test coverage: %d of %d (%0.4f%%), not covered %d\n', ... 20 covered, n, 100 * (covered / n), length (not_covered)) ; 21 22% create the coverage reports in tmp/cover 23 24infiles = dir ('tmp/@GrB/*/*.c') ; 25 26nfiles = length (infiles) ; 27 28for k = 1:nfiles 29 30 if (infiles (k).bytes == 0) 31 continue ; 32 end 33 34 infile = [ infiles(k).folder filesep infiles(k).name ] ; 35 outfile = [ 'tmp/cover/' infiles(k).name ] ; 36 37 f_input = fopen (infile, 'r') ; 38 f_output = fopen (outfile, 'w') ; 39 40 % get the first line 41 cline = fgetl (f_input) ; 42 43 while (ischar (cline)) 44 45 fprintf (f_output, '%s\n', cline) ; 46 47 if (~isempty (strfind (cline, 'gbcov[')) && ... 48 ~isempty (strfind (cline, '++'))) %#ok<*STREMP> 49 % got one; get the count 50 k1 = strfind (cline, '[') ; 51 k2 = strfind (cline, ']') ; 52 s = cline (k1+1:k2-1) ; 53 i = str2num (s) + 1 ; %#ok<*ST2NM> 54 c = gbcov_global (i) ; 55 if (c == 0) 56 fprintf (f_output, '// NOT COVERED:\n') ; 57 else 58 fprintf (f_output, '// covered: %d\n', c) ; 59 end 60 end 61 62 cline = fgetl (f_input) ; 63 end 64 65 fclose (f_output) ; 66 fclose (f_input) ; 67 68end 69 70