git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/4] coverage: do not delete .gcno files before building

From
Thomas Rast <trast@inf.ethz.ch>
Date
May 13, 2013, 21:27 UTC
Message-ID
<13bcab7694a9aa4707845769cacea2128664e407.1368479988.git.trast@inf.ethz.ch>
In-Reply-To
<cover.1368479988.git.trast@inf.ethz.ch>

The coverage-compile target depends on coverage-clean, which is supposed to remove the earlier build products that would get in the way of the next coverage test run.

However, removing *.gcno is actively wrong. These are the files that contain the compile-time coverage related data. They are only rebuilt if the source is compiled. So if one ran 'make coverage' two times in a row, the second run would remove *.gcno, but then fail to recreate them because neither source files nor build flags have changed. (This remained hidden for so long most likely because any other intervening use of 'make' will change the build flags, causing a full rebuild.)

So we make an exception for *.gcno. The *.gcda are the coverage results, written when the gcov-instrumented program is run. We still remove those, so as to get a one-test-run view of the data; you could probably argue the other way too.

Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
---
 Makefile | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index f98296b..99e4d09 100644
--- a/Makefile
+++ b/Makefile
@@ -2443,7 +2443,7 @@ profile-clean:
 	$(RM) $(addsuffix *.gcda,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))
 	$(RM) $(addsuffix *.gcno,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))
 
-clean: profile-clean
+clean: profile-clean coverage-clean
 	$(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o vcs-svn/*.o \
 		builtin/*.o $(LIB_FILE) $(XDIFF_LIB) $(VCSSVN_LIB)
 	$(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git$X
@@ -2525,20 +2525,23 @@ check-builtins::
 ### Test suite coverage testing
 #
 .PHONY: coverage coverage-clean coverage-compile coverage-test coverage-report
+.PHONY: coverage-clean-results
 
 coverage:
 	$(MAKE) coverage-test
 	$(MAKE) coverage-report
 
 object_dirs := $(sort $(dir $(OBJECTS)))
-coverage-clean:
+coverage-clean-results:
 	$(RM) $(addsuffix *.gcov,$(object_dirs))
 	$(RM) $(addsuffix *.gcda,$(object_dirs))
-	$(RM) $(addsuffix *.gcno,$(object_dirs))
 	$(RM) coverage-untested-functions
 	$(RM) -r cover_db/
 	$(RM) -r cover_db_html/
 
+coverage-clean: coverage-clean-results
+	$(RM) $(addsuffix *.gcno,$(object_dirs))
+
 COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs
 COVERAGE_LDFLAGS = $(CFLAGS)  -O0 -lgcov
 GCOVFLAGS = --preserve-paths --branch-probabilities --all-blocks
-- 
1.8.3.rc1.400.g07d6e4a
Previous: Thomas RastNext: Thomas Rast
Message 3 of 8 in “Coverage support revisited”
  1. 0/4 Coverage support revisitedThomas Rast, May 13, 2013
  2. 1/4 coverage: split build target into compile and testThomas Rast, May 13, 2013
  3. 2/4 coverage: do not delete .gcno files before buildingThomas Rast, May 13, 2013
  4. 3/4 coverage: set DEFAULT_TEST_TARGET to avoid using proveThomas Rast, May 13, 2013
  5. 4/4 coverage: build coverage-untested-functions by defaultThomas Rast, May 13, 2013
  6. Junio C HamanoMay 13, 2013
  7. Jens LehmannMay 13, 2013
  8. Thomas RastMay 14, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.