cURL / Mailing Lists / curl-library / Single Mail

curl-library

curl test coverage report

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Fri, 2 Mar 2007 21:58:11 -0800

I just tried running curl's regression test suite with gcc's test coverage
feature to see how thorough a job the test suite is doing. The results
below came from ggcov. Here are the enabled curl features in the version I
tested:

curl 7.16.2-CVS (i686-pc-linux-gnu) libcurl/7.16.2-CVS OpenSSL/0.9.7a zlib/1.2.1.2 libidn/0.5.6
Protocols: tftp ftp telnet dict ldap http file https ftps
Features: IDN IPv6 Largefile NTLM SSL libz

SSH and C-Ares are the notable omissions. This combination of features
allowed 320 of 328 tests to run. Here's the code coverage summary over
both libcurl and curl:

Summary (all files)
=======
  62.5176% blocks executed (8885 of 14212)
     (0 blocks suppressed)
  83.829% functions executed (451 of 538)
  32.342% functions completely executed (174 of 538)
     (0 functions suppressed)
  66.05% lines executed (9782 of 14810)
  64.6725% lines completely executed (9578 of 14810)
     (0 lines suppressed)
  48.6% branches taken (4192 of 8619)

What this means is that 84% of the C functions within libcurl and curl
got exercised by the test suite. At the source level, 2/3 of the lines of
code compiled in were tested. The percentage coverage at the code block
level (where a block of code is all the code between branches or function
calls) is just slightly lower. Only half of the possible branches
were taken.

Those are respectable figures, but of course, anything less than 100% means
there's room for improvement! Many development groups require 85%
coverage to achieve quality targets ("Code coverage, what does it mean
in terms of quality?", Williams, et. al.), presumably, on the equivalent of
ggcov's blocks or lines coverage figures. That's a worthy goal and
probably reasonably doable.

A good chunk of the uncovered lines in curl are error handling code
that's tricky to exercise, especially out of memory error handling code.
Also, three of the protocols in the curl version under test (telnet,
dict and ldap) have no tests. The ggcov code browser makes it easy to
see those lines that aren't being executed.

For those interested in writing tests to improve the code coverage, here
are lists of the functions not yet exercised by the test suite, as well
as functions with poor code coverage. Read the README and FILEFORMAT files
in the tests/ directory of the curl source code distribution to learn
more about writing tests for the curl test suite.

Uncovered functions
===================
lib/connect.c
  trynextip
  tcpnodelay
lib/content_encoding.c
  check_gzip_header
lib/cookie.c
  Curl_cookie_clearall
  Curl_cookie_clearsess
  Curl_cookie_list
lib/dict.c
  unescape_word
  Curl_dict
lib/easy.c
  curl_global_init_mem
lib/escape.c
  curl_escape
  curl_unescape
lib/formdata.c
  AddFormInfo
  curl_formget
lib/hash.c
  Curl_hash_delete
lib/hostip.c
  Curl_global_host_cache_init
  Curl_global_host_cache_get
lib/hostsyn.c
  Curl_wait_for_resolv
  Curl_is_resolved
  Curl_resolv_getsock
lib/ldap.c
  DynaOpen
  DynaClose
  DynaGetFunction
  Curl_ldap
lib/llist.c
  Curl_llist_count
lib/mprintf.c
  curl_mvsprintf
  curl_mvprintf
lib/multi.c
  sh_addentry
  sh_delentry
  sh_freeentry
  multi_socket
  curl_multi_socket
  curl_multi_socket_all
  multi_timeout
  curl_multi_timeout
  curl_multi_assign
lib/netrc.c
  Curl_parsenetrc
lib/select.c
  Curl_poll
lib/sendf.c
  Curl_sendf
lib/socks.c
  blockread_all
  Curl_SOCKS4
  Curl_SOCKS5
lib/sslgen.c
  Curl_ssl_shutdown
  Curl_ssl_check_cxn
lib/ssluse.c
  passwd_callback
  do_file_type
  cert_stuff
  SSL_strerror
  Curl_ossl_check_cxn
  Curl_ossl_shutdown
  hostmatch
  cert_hostcheck
lib/strequal.c
  Curl_strcasestr
  Curl_strlcat
lib/strerror.c
  curl_multi_strerror
  curl_share_strerror
  Curl_idn_strerror
lib/telnet.c
  init_telnet
  negotiate
  printoption
  send_negotiation
  set_remote_option
  rec_will
  rec_wont
  set_local_option
  rec_do
  rec_dont
  printsub
  check_telnet_options
  suboption
  telrcv
  Curl_telnet_done
  Curl_telnet
lib/url.c
  alarmfunc
  Curl_async_resolved
src/curlutil.c
  cutil_tvdiff
  cutil_tvdiff_secs
  cutil_tvlong
src/getpass.c
  ttyecho
  getpass_r
src/hugehelp.c
  hugehelp
src/main.c
  help
  ftpfilemethod
  ftpcccmethod
  my_ioctl
  myprogress
  dump
  create_dir_hierarchy

Poorly covered functions
========================
lib/connect.c
  bindlocal (0.0588235%)
  Curl_is_connected (0.238095%)
lib/content_encoding.c
  Curl_unencode_gzip_write (0.178571%)
lib/easy.c
  curl_easy_init (0.555556%)
  curl_easy_perform (0.590909%)
  curl_easy_duphandle (0.361702%)
lib/file.c
  Curl_file (0.597015%)
lib/formdata.c
  FormAdd (0.459716%)
  Curl_getFormData (0.592593%)
lib/ftp.c
  ftp_state_use_port (0.603604%)
  ftp_state_loggedin (0.5%)
  ftp_statemach_act (0.459627%)
  ftp_parse_url_path (0.571429%)
lib/getinfo.c
  Curl_getinfo (0.363636%)
lib/hash.c
  Curl_hash_init (0.6%)
lib/hostip.c
  Curl_global_host_cache_dtor (0.5%)
  hostcache_timestamp_remove (0.5%)
  remove_entry_if_stale (0.529412%)
  Curl_cache_addr (0.625%)
lib/hostip6.c
  Curl_ipvalid (0.375%)
lib/http.c
  add_bufferf (0.583333%)
lib/if2ip.c
  Curl_if2ip (0.611111%)
lib/mprintf.c
  dprintf_formatf (0.565385%)
  curl_maprintf (0.538462%)
  curl_mvaprintf (0.538462%)
lib/multi.c
  curl_multi_init (0.526316%)
  singlesocket (0.288889%)
  curl_multi_setopt (0.45%)
  update_timer (0.25%)
  Curl_expire (0.583333%)
lib/progress.c
  time2str (0.583333%)
  max5data (0.230769%)
lib/sendf.c
  convert_lineends (0.615385%)
  Curl_plain_send (0.272727%)
  Curl_debug (0.181818%)
lib/share.c
  curl_share_setopt (0.457143%)
lib/speedcheck.c
  Curl_speedcheck (0.277778%)
lib/splay.c
  Curl_splay (0.421053%)
  Curl_splayinsert (0.461538%)
  Curl_splaygetbest (0.388889%)
  Curl_splayremovebyaddr (0.5%)
lib/sslgen.c
  Curl_clone_ssl_config (0.409091%)
  Curl_free_ssl_config (0.5%)
  Curl_ssl_getsessionid (0.176471%)
  Curl_ssl_addsessionid (0.611111%)
lib/ssluse.c
  ossl_seed (0.225806%)
  Curl_ossl_seed (0.571429%)
  Curl_ossl_set_engine (0.294118%)
  Curl_ossl_set_engine_default (0.272727%)
  Curl_ossl_close_all (0.4%)
  verifyhost (0.364865%)
  ssl_msg_type (0.518519%)
  Curl_ossl_connect_step1 (0.515789%)
  Curl_ossl_connect_step2 (0.452381%)
  Curl_ossl_send (0.4%)
  Curl_ossl_recv (0.5%)
lib/strerror.c
  curl_easy_strerror (0.101266%)
  Curl_strerror (0.538462%)
lib/tftp.c
  tftp_rx (0.416667%)
  tftp_tx (0.377778%)
  tftp_state_machine (0.625%)
  Curl_tftp (0.602941%)
lib/transfer.c
  Curl_readrewind (0.25%)
  Curl_connect_host (0.423077%)
lib/url.c
  Curl_ch_connc (0.5%)
  Curl_open (0.588235%)
  signalPipeClose (0.6%)
  ConnectionDone (0.5%)
  ConnectionStore (0.533333%)
  ConnectPlease (0.608696%)
  tld_check_name (0.588235%)
  Curl_do (0.227273%)
src/homedir.c
  homedir (0.4%)
src/main.c
  file2string (0.176471%)
  param2text (0.416667%)
  checkpasswd (0.272727%)
  getparameter (0.574786%)
  dumpeasycode (0.12%)
src/urlglob.c
  glob_set (0.442308%)
  glob_range (0.395833%)
src/writeout.c
  ourWriteOut (0.421488%)

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2007-03-03