123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- cat app.info | awk -F '[,:]' '
- BEGIN { OFS = ":"; }
- /^SF:/{ FILEN = $2; }
- /^end_of_record$/{ FILEN = ""; }
- /^DA:/{ print FILEN, $2, $3; }
- ' | sort | awk -F : '
- BEGIN {
- OFS = ":";
- FILEN = "";
- LINE = "";
- HITS = 0;
- }
- {
- NEWFILEN = $1;
- NEWLINE = $2;
- if ((NEWFILEN == FILEN) && (NEWLINE == LINE)) {
- HITS += $3
- } else {
- if (FILEN != "") {
- print FILEN, LINE, HITS;
- }
- FILEN = NEWFILEN;
- LINE = NEWLINE;
- HITS = $3;
- }
- }
- ' | grep '^.*\/trunk\/src\/platform\/update_engine\/' | \
- fgrep -v '_unittest.cc:' | \
- fgrep -v '/test_utils.' | \
- fgrep -v '/test_http_server.cc' | \
- fgrep -v '/testrunner.cc' | \
- fgrep -v '/mock' | \
- fgrep -v '.pb.cc' | \
- awk -F : '
- function printfile() {
- if (FNAME != "")
- printf "%-40s %4d / %4d: %5.1f%%\n", FNAME, FILE_GOOD_LINES,
- (FILE_BAD_LINES + FILE_GOOD_LINES),
- (FILE_GOOD_LINES * 100) / (FILE_BAD_LINES + FILE_GOOD_LINES);
- }
- BEGIN {
- FNAME = "";
- FILE_BAD_LINES = 0;
- FILE_GOOD_LINES = 0;
- }
- {
- // calc filename
- ARR_SIZE = split($1, PARTS, "/");
- NEWFNAME = PARTS[ARR_SIZE];
- if (NEWFNAME != FNAME) {
- printfile();
- FILE_BAD_LINES = 0;
- FILE_GOOD_LINES = 0;
- FNAME = NEWFNAME;
- }
- if ($3 == "0") {
- BAD_LINES += 1;
- FILE_BAD_LINES += 1;
- } else {
- GOOD_LINES += 1;
- FILE_GOOD_LINES += 1;
- }
- }
- END {
- printfile();
- print "---\nSummary: tested " GOOD_LINES " / " (BAD_LINES + GOOD_LINES);
- printf(
- "Test coverage: %.1f%%\n",
- ((GOOD_LINES * 100) / (BAD_LINES + GOOD_LINES)));
- }
- '
|