Cleanup package dependencies, incremental build and unit testing scripts
* Removed stale dependency / use of fakeroot unit test invocation.
* Separated incremental build and unit test invocation from
gen_coverage_html.sh into their own scripts.
* Added checks for required binaries in gen_coverage_html.sh.
* Renamed setup_dev_packages to have a .sh suffix, for uniformity. Also
requires that it installs packages regardless of whether or not
they're already installed; this is to prevent a situation where
packages were removed from the portage tree but happen to still live
in the local chroot, so the discrepancy goes unnoticed (for example,
sys-apps/fakeroot and dev-util/lcov).
* Cosmetics: switched to long options when applicable, for clarity.
BUG=None
TEST=Update engine builds, tests, and coverage generation correctly
invoked
CQ-DEPEND=I949f6b4abad52d04245e5982ac95884d1d0a05fc
Change-Id: I439e74eb9772f8f368256a0adf13503e3257e66c
Reviewed-on: https://gerrit.chromium.org/gerrit/23229
Reviewed-by: Gilad Arnold <[email protected]>
Tested-by: Gilad Arnold <[email protected]>
Commit-Ready: Gilad Arnold <[email protected]>
diff --git a/local_coverage_rate b/local_coverage_rate
new file mode 100755
index 0000000..8a44f73
--- /dev/null
+++ b/local_coverage_rate
@@ -0,0 +1,89 @@
+#!/bin/bash
+
+# Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Calculates the test-coverage percentage for non-test files in the
+# update_engine directory. Requires a file 'app.info' to contain the
+# results of running the unittests while collecting coverage data.
+
+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)));
+}
+'