Coverage support revisited
cover Coverage support revisited
Jens asked me at git-merge if coverage support was still available. Turns out it is, but there were some weirdnesses. So this should fix them. It is reaaaally slow as you still have to run the tests one by one; despite claims in the wild that it is multiprocess- safe but thread-unsafe, I am in fact observing the opposite behavior pretty clearly. (As before, it switches to sequential tests automatically, so you have to edit the Makefile if you want to try with parallel tests.)
Below is the coverage-untested-functions output; it seems submodule.c is covered, so there is nothing for Jens to do ;-)
Thomas Rast (4):
coverage: split build target into compile and test
coverage: do not delete .gcno files before building
coverage: set DEFAULT_TEST_TARGET to avoid using prove
coverage: build coverage-untested-functions by default
Makefile | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
--- coverage-untested-functions ---alloc.c: reportalloc.c: alloc_reportarchive-tar.c: write_extended_headerattr.c: git_etc_gitattributes
builtin#add.c: ignore_removal_cb builtin#apply.c: checkout_target builtin#apply.c: add_name_limit
builtin#apply.c: option_parse_exclude builtin#apply.c: option_parse_include builtin#apply.c: option_parse_z
builtin#blame.c: read_ancestry
builtin#blame.c: sanity_check_refcnt builtin#blame.c: prepare_initial builtin#blame.c: blame_move_callback builtin#branch.c: calc_maxwidth builtin#checkout-index.c: option_parse_z builtin#clone.c: remove_junk_on_signal builtin#commit.c: find_author_by_nickname builtin#config.c: cmd_repo_config builtin#fetch.c: unlock_pack_on_signal builtin#fmt-merge-msg.c: add_branch_desc builtin#for-each-ref.c: copy_advance builtin#grep.c: help_callback
builtin#help.c: parse_help_format builtin#help.c: get_man_viewer_info builtin#help.c: check_emacsclient_version builtin#help.c: exec_woman_emacs
builtin#help.c: exec_man_konqueror builtin#help.c: exec_man_man
builtin#help.c: exec_man_cmd
builtin#help.c: add_man_viewer
builtin#help.c: supported_man_viewer builtin#help.c: do_add_man_viewer_info builtin#help.c: add_man_viewer_path builtin#help.c: add_man_viewer_cmd builtin#help.c: add_man_viewer_info builtin#help.c: git_help_config
builtin#help.c: is_git_command
builtin#help.c: prepend
builtin#help.c: cmd_to_page
builtin#help.c: setup_man_path
builtin#help.c: exec_viewer
builtin#help.c: show_man_page
builtin#help.c: show_info_page
builtin#help.c: get_html_page_path builtin#help.c: open_html
builtin#help.c: show_html_page
builtin#help.c: list_common_guides_help builtin#help.c: cmd_help
builtin#index-pack.c: delta_pos_compare builtin#log.c: estimate_commit_count builtin#log.c: show_early_header
builtin#log.c: log_show_early
builtin#log.c: early_output
builtin#log.c: setup_early_output
builtin#log.c: finish_early_output builtin#log.c: no_numbered_callback builtin#log.c: header_callback builtin#mailsplit.c: populate_maildir_list builtin#mailsplit.c: maildir_filename_cmp builtin#mailsplit.c: split_maildir builtin#merge-base.c: handle_is_ancestor builtin#merge.c: reset_hard
builtin#merge.c: setup_with_upstream builtin#pack-objects.c: pbase_tree_cache_ix_incr builtin#pack-objects.c: try_to_free_from_threads builtin#pack-objects.c: mark_in_pack_object builtin#pack-objects.c: ofscmp builtin#pack-objects.c: add_objects_in_unpacked_packs builtin#pack-objects.c: option_parse_ulong builtin#pack-redundant.c: llist_item_put builtin#pack-redundant.c: llist_item_get builtin#pack-redundant.c: llist_free builtin#pack-redundant.c: llist_init builtin#pack-redundant.c: llist_copy builtin#pack-redundant.c: llist_insert builtin#pack-redundant.c: llist_insert_back builtin#pack-redundant.c: llist_insert_sorted_unique builtin#pack-redundant.c: llist_sorted_remove builtin#pack-redundant.c: llist_sorted_difference_inplace builtin#pack-redundant.c: pack_list_insert builtin#pack-redundant.c: pack_list_size builtin#pack-redundant.c: pack_list_difference builtin#pack-redundant.c: cmp_two_packs builtin#pack-redundant.c: pll_free builtin#pack-redundant.c: get_permutations builtin#pack-redundant.c: is_superset builtin#pack-redundant.c: sizeof_union builtin#pack-redundant.c: get_pack_redundancy builtin#pack-redundant.c: pack_set_bytecount builtin#pack-redundant.c: minimize builtin#pack-redundant.c: load_all_objects builtin#pack-redundant.c: cmp_local_packs builtin#pack-redundant.c: scan_alt_odb_packs builtin#pack-redundant.c: add_pack builtin#pack-redundant.c: add_pack_file builtin#pack-redundant.c: load_all builtin#pack-redundant.c: cmd_pack_redundant builtin#push.c: advise_use_upstream builtin#push.c: advise_checkout_pull_push builtin#push.c: advise_ref_needs_force builtin#read-tree.c: debug_stage builtin#read-tree.c: debug_merge builtin#reflog.c: find_cfg_ent builtin#remote-ext.c: send_git_request builtin#remote-fd.c: command_loop builtin#remote-fd.c: cmd_remote_fd builtin#rev-list.c: show_edge builtin#rev-list.c: print_var_str builtin#rev-list.c: print_var_int builtin#rev-list.c: show_bisect_vars builtin#rev-parse.c: anti_reference builtin#rev-parse.c: show_datestring builtin#send-pack.c: print_helper_status builtin#shortlog.c: compare_by_number builtin#shortlog.c: parse_uint builtin#show-branch.c: append_tag_ref builtin#show-branch.c: count_slash builtin#show-branch.c: append_matching_ref builtin#show-branch.c: parse_reflog_param builtin#show-ref.c: add_existing builtin#show-ref.c: exclude_existing builtin#show-ref.c: exclude_existing_callback builtin#show-ref.c: help_callback builtin#unpack-objects.c: add_delta_to_list combine-diff.c: reuse_combine_diff compat#terminal.c: restore_term_on_signal compat#terminal.c: restore_term compat#terminal.c: disable_echo compat#terminal.c: git_terminal_promptconfig.c: git_etc_gitconfigconfig.c: write_errorconnect.c: enable_keepaliveconnect.c: ai_nameconnect.c: git_tcp_connect_sockconnect.c: git_tcp_connectconnect.c: get_portcredential-cache--daemon.c: cleanup_socket_on_signal date.c: date_midnightdate.c: date_teadiff.c: parse_algorithm_valuediff.c: remove_tempfile_on_signal diffcore-order.c: prepare_order diffcore-order.c: match_orderdiffcore-order.c: compare_pair_order diffcore-order.c: diffcore_orderdir.c: strcmp_icaseenvironment.c: have_git_direxec_cmd.c: system_pathexec_cmd.c: prepare_git_cmdexec_cmd.c: execv_git_cmdexec_cmd.c: execl_git_cmdfast-import.c: checkpoint_signalfetch-pack.c: clear_marksfsck.c: fsck_error_functiongraph.c: column_get_color_codegrep.c: compile_pcre_regexpgrep.c: pcrematchgrep.c: free_pcre_regexpgrep.c: indentgrep.c: dump_grep_patgrep.c: dump_grep_expression_1grep.c: dump_grep_expressionhelp.c: clean_cmdnameshelp.c: pretty_print_string_listhelp.c: list_commandshelp.c: git_unknown_cmd_confighelp.c: levenshtein_comparehelp.c: add_cmd_listhelp.c: help_unknown_cmdhttp-backend.c: inflate_requesthttp-backend.c: die_webcgihttp.c: fread_bufferhttp.c: ioctl_bufferhttp.c: fwrite_bufferhttp.c: fwrite_nullhttp.c: process_curl_messageshttp.c: http_optionshttp.c: init_curl_http_authhttp.c: has_cert_passwordhttp.c: get_curl_handlehttp.c: set_from_envhttp.c: http_inithttp.c: http_cleanuphttp.c: get_active_slothttp.c: start_active_slothttp.c: add_fill_functionhttp.c: fill_active_slotshttp.c: step_active_slotshttp.c: run_active_slothttp.c: closedown_active_slothttp.c: release_active_slothttp.c: finish_active_slothttp.c: finish_all_active_slotshttp.c: needs_quotehttp.c: quote_ref_urlhttp.c: append_remote_object_urlhttp.c: get_remote_object_urlhttp.c: handle_curl_resulthttp.c: http_requesthttp.c: http_request_reauthhttp.c: http_get_strbufhttp.c: http_get_filehttp.c: http_fetch_refhttp.c: fetch_pack_indexhttp.c: fetch_and_setup_pack_indexhttp.c: http_get_info_packshttp.c: release_http_pack_requesthttp.c: finish_http_pack_requesthttp.c: new_http_pack_requesthttp.c: fwrite_sha1_filehttp.c: new_http_object_requesthttp.c: process_http_object_requesthttp.c: finish_http_object_requesthttp.c: abort_http_object_requesthttp.c: release_http_object_requesthttp-push.c: xml_entitieshttp-push.c: curl_setup_http_gethttp-push.c: curl_setup_httphttp-push.c: get_dav_token_headershttp-push.c: process_responsehttp-push.c: start_fetch_loosehttp-push.c: start_mkcolhttp-push.c: start_fetch_packedhttp-push.c: start_puthttp-push.c: start_movehttp-push.c: refresh_lockhttp-push.c: check_lockshttp-push.c: release_requesthttp-push.c: finish_requesthttp-push.c: fill_active_slothttp-push.c: add_fetch_requesthttp-push.c: add_send_requesthttp-push.c: fetch_indiceshttp-push.c: one_remote_objecthttp-push.c: handle_lockprop_ctxhttp-push.c: handle_new_lock_ctxhttp-push.c: xml_start_taghttp-push.c: xml_end_taghttp-push.c: xml_cdatahttp-push.c: lock_remotehttp-push.c: unlock_remotehttp-push.c: remove_lockshttp-push.c: remove_locks_on_signalhttp-push.c: process_ls_objecthttp-push.c: process_ls_refhttp-push.c: handle_remote_ls_ctxhttp-push.c: remote_lshttp-push.c: get_remote_object_listhttp-push.c: locking_availablehttp-push.c: add_one_objecthttp-push.c: process_blobhttp-push.c: process_treehttp-push.c: get_deltahttp-push.c: update_remotehttp-push.c: one_remote_refhttp-push.c: get_dav_remote_headshttp-push.c: add_remote_info_refhttp-push.c: update_remote_info_refs http-push.c: remote_existshttp-push.c: fetch_symrefhttp-push.c: verify_merge_basehttp-push.c: delete_remote_branchhttp-push.c: run_request_queueident.c: author_ident_sufficiently_given levenshtein.c: levenshteinlockfile.c: remove_lock_file_on_signal lockfile.c: unable_to_lock_messagelockfile.c: unable_to_lock_errorlockfile.c: unable_to_lock_index_dielog-tree.c: add_graft_decorationlog-tree.c: show_parentslog-tree.c: show_childrenlog-tree.c: which_parentlog-tree.c: is_common_mergelog-tree.c: show_one_mergetagmerge-blobs.c: common_outfname-hash.c: remove_dir_entryname-hash.c: slow_same_namename-hash.c: free_dir_entrynotes.c: combine_notes_ignoreobject.c: object_list_insertobject.c: object_list_containspager.c: wait_for_pagerpager.c: wait_for_pager_signalparse-options.c: optbugpath.c: getpw_strpath.c: daemon_avoid_aliaspkt-line.c: packet_read_line_buf preload-index.c: preload_threadprogress.c: progress_intervalprompt.c: git_getpassquote.c: sq_dequoteread-cache.c: different_nameread-cache.c: create_alias_ceread-cache.c: expand_name_fieldrefs.c: for_each_branch_refrefs.c: for_each_remote_refrefs.c: ref_msgremote.c: remote_has_urlrevision.c: prepare_show_mergerun-command.c: cleanup_children_on_signal run-command.c: dup_devnullrun-command.c: run_command_v_opt_cd_env sha1_file.c: sha1_get_pack_namesha1_file.c: sha1_pack_namesha1_file.c: sha1_pack_index_namesha1_file.c: release_pack_memorysha1_file.c: try_to_free_pack_memory sha1_file.c: parse_pack_indexsha1_file.c: write_pack_access_logsha1_file.c: has_pack_indexsha1-lookup.c: sha1_entry_pos sh-i18n--envsubst.c: cmp_stringstrbuf.c: strbuf_addstr_xml_quotedstrbuf.c: is_rfc3986_reservedstring-list.c: print_string_listtest-ctype.c: report_errortest-wildmatch.c: perftransport.c: external_specification_len transport-helper.c: xchglinetransport-helper.c: standard_options transport-helper.c: fetch_with_fetch transport-helper.c: connect_helper transport-helper.c: push_refs_with_push transport-helper.c: has_attributetree.c: read_one_entrytree-walk.c: match_wildcard_baseunix-socket.c: chdir_lenunpack-trees.c: debug_pathunpack-trees.c: debug_name_entryunpack-trees.c: debug_unpack_callback unpack-trees.c: verify_clean_submodule unpack-trees.c: icase_existsupload-pack.c: check_non_tipurl.c: str_end_url_with_slashutf8.c: is_utf8varint.c: decode_varintvarint.c: encode_varint
vcs-svn#fast_export.c: fast_export_truncate vcs-svn#fast_export.c: die_short_read vcs-svn#svndump.c: die_short_readwrapper.c: do_nothingwrapper.c: warn_on_inaccessiblewrite_or_die.c: check_pipe
xdiff#xhistogram.c: fall_back_to_classic_diff xdiff#xpatience.c: fall_back_to_classic_diff xdiff#xutils.c: xdl_fall_back_diffzlib.c: git_inflate_init_gzip_onlyzlib.c: git_deflate_init_gzip
Signature · 1 line
1.8.3.rc1.400.g07d6e4a
PATCH 1/4 coverage: split build target into compile and test
Confusingly, the coverage-build target in fact builds with gcov support _and runs tests_.
Split it into two targets that actually are named after what they do.
--- Makefile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
Makefile +5 -3
@@ -2524,10 +2524,10 @@ check-builtins:: ### Test suite coverage testing # -.PHONY: coverage coverage-clean coverage-build coverage-report +.PHONY: coverage coverage-clean coverage-compile coverage-test coverage-report coverage: - $(MAKE) coverage-build + $(MAKE) coverage-test $(MAKE) coverage-report object_dirs := $(sort $(dir $(OBJECTS)))
@@ -2543,8 +2543,10 @@ COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs COVERAGE_LDFLAGS = $(CFLAGS) -O0 -lgcov GCOVFLAGS = --preserve-paths --branch-probabilities --all-blocks -coverage-build: coverage-clean +coverage-compile: $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" all + +coverage-test: coverage-clean-results coverage-compile $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" \ -j1 test
Signature · 1 line
1.8.3.rc1.400.g07d6e4a
PATCH 2/4 coverage: do not delete .gcno files before building
In reply to Thomas RastThe 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.
--- Makefile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
Makefile +6 -3
@@ -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
Signature · 1 line
1.8.3.rc1.400.g07d6e4a
Am 13.05.2013 23:27, schrieb Thomas Rast:
Quoted 8 lines
Jens asked me at git-merge if coverage support was still available. Turns out it is, but there were some weirdnesses. So this should fix them. It is reaaaally slow as you still have to run the tests one by one; despite claims in the wild that it is multiprocess- safe but thread-unsafe, I am in fact observing the opposite behavior pretty clearly. (As before, it switches to sequential tests automatically, so you have to edit the
Makefileif you want to try with parallel tests.)
Thx! That might explain why the coverage run I tried today didn't work (I saw bogus test failures).
Quoted 2 lines
Below is the coverage-untested-functions output; it seems
submodule.cis covered, so there is nothing for Jens to do ;-)
Hehe, I kinda expected that part ;-)
Quoted 1 line
unpack-trees.c:verify_clean_submodule
This is the one I was after. While discussing my recursive update code with Peff on Saturday we wondered if that function would ever be called. I'll check if the tests are missing some relevant cases, if that function can be removed or some refactoring is necessary.
Hmm, while function coverage is already extremely useful me thinks lcov support would be really nice. We'd have line and branch coverage, which help me a lot in finding dead code and missing tests at $DAYJOB ... will look into that when I have the recursive update ready.
Quoted 10 lines · Jens Lehmann
Am 13.05.2013 23:27, schrieb Thomas Rast:
Quoted 8 lines
Jens asked me at git-merge if coverage support was still available. Turns out it is, but there were some weirdnesses. So this should fix them. It is reaaaally slow as you still have to run the tests one by one; despite claims in the wild that it is multiprocess- safe but thread-unsafe, I am in fact observing the opposite behavior pretty clearly. (As before, it switches to sequential tests automatically, so you have to edit the
Makefileif you want to try with parallel tests.)
Quoted 2 lines
Thx! That might explain why the coverage run I tried today didn't work (I saw bogus test failures).
Indeed it does. I should have mentioned it in the cover letter; it's fixed by this series but if you set DEFAULT_TEST_TARGET=prove like everyone else, it ignored the (existing) force-to-sequential rule.
Quoted 11 lines
Quoted 1 line
unpack-trees.c:verify_clean_submoduleThis is the one I was after. While discussing my recursive update code with Peff on Saturday we wondered if that function would ever be called. I'll check if the tests are missing some relevant cases, if that function can be removed or some refactoring is necessary.
Hmm, while function coverage is already extremely useful me thinks lcov support would be really nice. We'd have line and branch coverage, which help me a lot in finding dead code and missing tests at $DAYJOB ... will look into that when I have the recursive update ready.
Actually if you run it, it generates submodule.c.gcov as an intermediate step to the uncovered-functions list. Of course you can also use any other tool that can read gcov; the results are cleaned before the run, not after, so they will remain in place.
Originally I hacked together an uncovered-functions list because that list was so long that looking at things in even more detail seemed extremely pointless.
Signature · 2 lines
Thomas Rast
trast@{inf,student}.ethz.chPATCH 3/4 coverage: set DEFAULT_TEST_TARGET to avoid using prove
In reply to Thomas RastIf the user sets DEFAULT_TEST_TARGET=prove in his config.mak, that carries over into the coverage tests. Which is really bad if he also sets GIT_PROVE_OPTS=-j<..> as that completely breaks the coverage runs.
Instead of attempting to mess with the GIT_PROVE_OPTS, just force the test target to 'test' so that we run under make, like we intended all along.
--- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
@@ -2551,7 +2551,7 @@ coverage-compile: coverage-test: coverage-clean-results coverage-compile $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" \ - -j1 test + DEFAULT_TEST_TARGET=test -j1 test coverage-report: $(QUIET_GCOV)for dir in $(object_dirs); do \
Signature · 1 line
1.8.3.rc1.400.g07d6e4a
Quoted 2 lines · Thomas Rast
Below is the coverage-untested-functions output; it seems
submodule.cis covered, so there is nothing for Jens to do ;-)
Nice.
Here are some hints to add coverages to the selected functions.
Quoted 2 lines
alloc.c: reportalloc.c:alloc_report
I believe these are only for debugging.
Quoted 1 line
archive-tar.c:write_extended_header
Need to create an archive that contains loong pathname (iirc, over 100 bytes) in the test.
Quoted 2 lines
attr.c:git_etc_gitattributes
builtin#add.c:ignore_removal_cb
"--ignore-removal" option parsing.
Quoted 1 line
builtin#apply.c:
checkout_target
Try "git apply --index" to an empty working tree with a valid index.
Quoted 3 lines
builtin#apply.c:
add_name_limit
builtin#apply.c:option_parse_exclude
builtin#apply.c:option_parse_include
"git apply --exclude/include".
Quoted 1 line
builtin#apply.c:
option_parse_z
"git apply --stat -z".
Quoted 1 line
builtin#blame.c:
read_ancestry
"git blame -S<file>".
Quoted 1 line
builtin#blame.c:
sanity_check_refcnt
Only used for debugging.
Quoted 1 line
builtin#blame.c:
prepare_initial
"git blame --reverse".
Quoted 1 line
builtin#blame.c:
blame_move_callback
"git blame -M" (option parsing).
Quoted 2 lines
varint.c:decode_varintvarint.c:encode_varint
"git update-index --index-version 4" and then read from the resulting index.
PATCH 4/4 coverage: build coverage-untested-functions by default
In reply to Thomas RastChange the 'coverage' target to build coverage-untested-functions by default, so as to make it more discoverable.
--- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
@@ -2529,7 +2529,7 @@ check-builtins:: coverage: $(MAKE) coverage-test - $(MAKE) coverage-report + $(MAKE) coverage-untested-functions object_dirs := $(sort $(dir $(OBJECTS))) coverage-clean-results:
Signature · 1 line
1.8.3.rc1.400.g07d6e4a