<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html xmlns:fn="http://www.w3.org/2005/02/xpath-functions"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" href="../../../../doc/otp_doc.css" type="text/css"> <title>Erlang -- cover</title> </head> <body bgcolor="white" text="#000000" link="#0000ff" vlink="#ff00ff" alink="#ff0000"><div id="container"> <script id="js" type="text/javascript" language="JavaScript" src="../../../../doc/js/flipmenu/flipmenu.js"></script><script id="js2" type="text/javascript" src="../../../../doc/js/erlresolvelinks.js"></script><script language="JavaScript" type="text/javascript"> <!-- function getWinHeight() { var myHeight = 0; if( typeof( window.innerHeight ) == 'number' ) { //Non-IE myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible myHeight = document.body.clientHeight; } return myHeight; } function setscrollpos() { var objf=document.getElementById('loadscrollpos'); document.getElementById("leftnav").scrollTop = objf.offsetTop - getWinHeight()/2; } function addEvent(obj, evType, fn){ if (obj.addEventListener){ obj.addEventListener(evType, fn, true); return true; } else if (obj.attachEvent){ var r = obj.attachEvent("on"+evType, fn); return r; } else { return false; } } addEvent(window, 'load', setscrollpos); //--></script><div id="leftnav"><div class="innertube"> <img alt="Erlang logo" src="../../../../doc/erlang-logo.png"><br><small><a href="users_guide.html">User's Guide</a><br><a href="index.html">Reference Manual</a><br><a href="release_notes.html">Release Notes</a><br><a href="../pdf/tools-2.6.8.pdf">PDF</a><br><a href="../../../../doc/index.html">Top</a></small><p><strong>Tools</strong><br><strong>Reference Manual</strong><br><small>Version 2.6.8</small></p> <br><a href="javascript:openAllFlips()">Expand All</a><br><a href="javascript:closeAllFlips()">Contract All</a><p><small><strong>Table of Contents</strong></small></p> <ul class="flipMenu"> <li id="loadscrollpos" title="cover " expanded="true">cover<ul> <li><a href="cover.html"> Top of manual page </a></li> <li title="start-0"><a href="cover.html#start-0">start/0</a></li> <li title="start-1"><a href="cover.html#start-1">start/1</a></li> <li title="compile-1"><a href="cover.html#compile-1">compile/1</a></li> <li title="compile-2"><a href="cover.html#compile-2">compile/2</a></li> <li title="compile_module-1"><a href="cover.html#compile_module-1">compile_module/1</a></li> <li title="compile_module-2"><a href="cover.html#compile_module-2">compile_module/2</a></li> <li title="compile_directory-0"><a href="cover.html#compile_directory-0">compile_directory/0</a></li> <li title="compile_directory-1"><a href="cover.html#compile_directory-1">compile_directory/1</a></li> <li title="compile_directory-2"><a href="cover.html#compile_directory-2">compile_directory/2</a></li> <li title="compile_beam-1"><a href="cover.html#compile_beam-1">compile_beam/1</a></li> <li title="compile_beam_directory-0"><a href="cover.html#compile_beam_directory-0">compile_beam_directory/0</a></li> <li title="compile_beam_directory-1"><a href="cover.html#compile_beam_directory-1">compile_beam_directory/1</a></li> <li title="analyse-1"><a href="cover.html#analyse-1">analyse/1</a></li> <li title="analyse-2"><a href="cover.html#analyse-2">analyse/2</a></li> <li title="analyse-2"><a href="cover.html#analyse-2">analyse/2</a></li> <li title="analyse-3"><a href="cover.html#analyse-3">analyse/3</a></li> <li title="analyse_to_file-1"><a href="cover.html#analyse_to_file-1">analyse_to_file/1</a></li> <li title="analyse_to_file-2"><a href="cover.html#analyse_to_file-2">analyse_to_file/2</a></li> <li title="analyse_to_file-2"><a href="cover.html#analyse_to_file-2">analyse_to_file/2</a></li> <li title="analyse_to_file-3"><a href="cover.html#analyse_to_file-3">analyse_to_file/3</a></li> <li title="async_analyse_to_file-1"><a href="cover.html#async_analyse_to_file-1">async_analyse_to_file/1</a></li> <li title="async_analyse_to_file-2"><a href="cover.html#async_analyse_to_file-2">async_analyse_to_file/2</a></li> <li title="async_analyse_to_file-2"><a href="cover.html#async_analyse_to_file-2">async_analyse_to_file/2</a></li> <li title="async_analyse_to_file-3"><a href="cover.html#async_analyse_to_file-3">async_analyse_to_file/3</a></li> <li title="modules-0"><a href="cover.html#modules-0">modules/0</a></li> <li title="imported_modules-0"><a href="cover.html#imported_modules-0">imported_modules/0</a></li> <li title="imported-0"><a href="cover.html#imported-0">imported/0</a></li> <li title="which_nodes-0"><a href="cover.html#which_nodes-0">which_nodes/0</a></li> <li title="is_compiled-1"><a href="cover.html#is_compiled-1">is_compiled/1</a></li> <li title="reset-1"><a href="cover.html#reset-1">reset/1</a></li> <li title="reset-0"><a href="cover.html#reset-0">reset/0</a></li> <li title="export-1"><a href="cover.html#export-1">export/1</a></li> <li title="export-2"><a href="cover.html#export-2">export/2</a></li> <li title="import-1"><a href="cover.html#import-1">import/1</a></li> <li title="stop-0"><a href="cover.html#stop-0">stop/0</a></li> <li title="stop-1"><a href="cover.html#stop-1">stop/1</a></li> </ul> </li> <li id="no" title="cprof " expanded="false">cprof<ul> <li><a href="cprof.html"> Top of manual page </a></li> <li title="analyse-0"><a href="cprof.html#analyse-0">analyse/0</a></li> <li title="analyse-1"><a href="cprof.html#analyse-1">analyse/1</a></li> <li title="analyse-1"><a href="cprof.html#analyse-1">analyse/1</a></li> <li title="analyse-2"><a href="cprof.html#analyse-2">analyse/2</a></li> <li title="pause-0"><a href="cprof.html#pause-0">pause/0</a></li> <li title="pause-1"><a href="cprof.html#pause-1">pause/1</a></li> <li title="pause-2"><a href="cprof.html#pause-2">pause/2</a></li> <li title="pause-3"><a href="cprof.html#pause-3">pause/3</a></li> <li title="restart-0"><a href="cprof.html#restart-0">restart/0</a></li> <li title="restart-1"><a href="cprof.html#restart-1">restart/1</a></li> <li title="restart-2"><a href="cprof.html#restart-2">restart/2</a></li> <li title="restart-3"><a href="cprof.html#restart-3">restart/3</a></li> <li title="start-0"><a href="cprof.html#start-0">start/0</a></li> <li title="start-1"><a href="cprof.html#start-1">start/1</a></li> <li title="start-2"><a href="cprof.html#start-2">start/2</a></li> <li title="start-3"><a href="cprof.html#start-3">start/3</a></li> <li title="stop-0"><a href="cprof.html#stop-0">stop/0</a></li> <li title="stop-1"><a href="cprof.html#stop-1">stop/1</a></li> <li title="stop-2"><a href="cprof.html#stop-2">stop/2</a></li> <li title="stop-3"><a href="cprof.html#stop-3">stop/3</a></li> </ul> </li> <li id="no" title="eprof " expanded="false">eprof<ul> <li><a href="eprof.html"> Top of manual page </a></li> <li title="start-0"><a href="eprof.html#start-0">start/0</a></li> <li title="start_profiling-1"><a href="eprof.html#start_profiling-1">start_profiling/1</a></li> <li title="start_profiling-2"><a href="eprof.html#start_profiling-2">start_profiling/2</a></li> <li title="stop_profiling-0"><a href="eprof.html#stop_profiling-0">stop_profiling/0</a></li> <li title="profile-1"><a href="eprof.html#profile-1">profile/1</a></li> <li title="profile-1"><a href="eprof.html#profile-1">profile/1</a></li> <li title="profile-2"><a href="eprof.html#profile-2">profile/2</a></li> <li title="profile-3"><a href="eprof.html#profile-3">profile/3</a></li> <li title="profile-4"><a href="eprof.html#profile-4">profile/4</a></li> <li title="profile-5"><a href="eprof.html#profile-5">profile/5</a></li> <li title="analyze-0"><a href="eprof.html#analyze-0">analyze/0</a></li> <li title="analyze-1"><a href="eprof.html#analyze-1">analyze/1</a></li> <li title="analyze-2"><a href="eprof.html#analyze-2">analyze/2</a></li> <li title="log-1"><a href="eprof.html#log-1">log/1</a></li> <li title="stop-0"><a href="eprof.html#stop-0">stop/0</a></li> </ul> </li> <li title="erlang.el"><a href="erlang.el.html">erlang.el</a></li> <li id="no" title="fprof " expanded="false">fprof<ul> <li><a href="fprof.html"> Top of manual page </a></li> <li title="start-0"><a href="fprof.html#start-0">start/0</a></li> <li title="stop-0"><a href="fprof.html#stop-0">stop/0</a></li> <li title="stop-1"><a href="fprof.html#stop-1">stop/1</a></li> <li title="apply-2"><a href="fprof.html#apply-2">apply/2</a></li> <li title="apply-3"><a href="fprof.html#apply-3">apply/3</a></li> <li title="apply-3"><a href="fprof.html#apply-3">apply/3</a></li> <li title="apply-4"><a href="fprof.html#apply-4">apply/4</a></li> <li title="trace-2"><a href="fprof.html#trace-2">trace/2</a></li> <li title="trace-2"><a href="fprof.html#trace-2">trace/2</a></li> <li title="trace-2"><a href="fprof.html#trace-2">trace/2</a></li> <li title="trace-1"><a href="fprof.html#trace-1">trace/1</a></li> <li title="trace-1"><a href="fprof.html#trace-1">trace/1</a></li> <li title="trace-1"><a href="fprof.html#trace-1">trace/1</a></li> <li title="trace-1"><a href="fprof.html#trace-1">trace/1</a></li> <li title="profile-0"><a href="fprof.html#profile-0">profile/0</a></li> <li title="profile-2"><a href="fprof.html#profile-2">profile/2</a></li> <li title="profile-1"><a href="fprof.html#profile-1">profile/1</a></li> <li title="profile-1"><a href="fprof.html#profile-1">profile/1</a></li> <li title="profile-1"><a href="fprof.html#profile-1">profile/1</a></li> <li title="analyse-0"><a href="fprof.html#analyse-0">analyse/0</a></li> <li title="analyse-2"><a href="fprof.html#analyse-2">analyse/2</a></li> <li title="analyse-1"><a href="fprof.html#analyse-1">analyse/1</a></li> <li title="analyse-1"><a href="fprof.html#analyse-1">analyse/1</a></li> <li title="analyse-1"><a href="fprof.html#analyse-1">analyse/1</a></li> </ul> </li> <li id="no" title="instrument " expanded="false">instrument<ul> <li><a href="instrument.html"> Top of manual page </a></li> <li title="allocator_descr-2"><a href="instrument.html#allocator_descr-2">allocator_descr/2</a></li> <li title="block_header_size-1"><a href="instrument.html#block_header_size-1">block_header_size/1</a></li> <li title="class_descr-2"><a href="instrument.html#class_descr-2">class_descr/2</a></li> <li title="descr-1"><a href="instrument.html#descr-1">descr/1</a></li> <li title="holes-1"><a href="instrument.html#holes-1">holes/1</a></li> <li title="mem_limits-1"><a href="instrument.html#mem_limits-1">mem_limits/1</a></li> <li title="memory_data-0"><a href="instrument.html#memory_data-0">memory_data/0</a></li> <li title="memory_status-1"><a href="instrument.html#memory_status-1">memory_status/1</a></li> <li title="read_memory_data-1"><a href="instrument.html#read_memory_data-1">read_memory_data/1</a></li> <li title="read_memory_status-1"><a href="instrument.html#read_memory_status-1">read_memory_status/1</a></li> <li title="sort-1"><a href="instrument.html#sort-1">sort/1</a></li> <li title="store_memory_data-1"><a href="instrument.html#store_memory_data-1">store_memory_data/1</a></li> <li title="store_memory_status-1"><a href="instrument.html#store_memory_status-1">store_memory_status/1</a></li> <li title="sum_blocks-1"><a href="instrument.html#sum_blocks-1">sum_blocks/1</a></li> <li title="type_descr-2"><a href="instrument.html#type_descr-2">type_descr/2</a></li> <li title="type_no_range-1"><a href="instrument.html#type_no_range-1">type_no_range/1</a></li> </ul> </li> <li id="no" title="lcnt " expanded="false">lcnt<ul> <li><a href="lcnt.html"> Top of manual page </a></li> <li title="start-0"><a href="lcnt.html#start-0">start/0</a></li> <li title="stop-0"><a href="lcnt.html#stop-0">stop/0</a></li> <li title="collect-0"><a href="lcnt.html#collect-0">collect/0</a></li> <li title="collect-1"><a href="lcnt.html#collect-1">collect/1</a></li> <li title="clear-0"><a href="lcnt.html#clear-0">clear/0</a></li> <li title="clear-1"><a href="lcnt.html#clear-1">clear/1</a></li> <li title="conflicts-0"><a href="lcnt.html#conflicts-0">conflicts/0</a></li> <li title="conflicts-1"><a href="lcnt.html#conflicts-1">conflicts/1</a></li> <li title="locations-0"><a href="lcnt.html#locations-0">locations/0</a></li> <li title="locations-1"><a href="lcnt.html#locations-1">locations/1</a></li> <li title="inspect-1"><a href="lcnt.html#inspect-1">inspect/1</a></li> <li title="inspect-2"><a href="lcnt.html#inspect-2">inspect/2</a></li> <li title="information-0"><a href="lcnt.html#information-0">information/0</a></li> <li title="swap_pid_keys-0"><a href="lcnt.html#swap_pid_keys-0">swap_pid_keys/0</a></li> <li title="load-1"><a href="lcnt.html#load-1">load/1</a></li> <li title="save-1"><a href="lcnt.html#save-1">save/1</a></li> <li title="apply-1"><a href="lcnt.html#apply-1">apply/1</a></li> <li title="apply-2"><a href="lcnt.html#apply-2">apply/2</a></li> <li title="apply-3"><a href="lcnt.html#apply-3">apply/3</a></li> <li title="pid-2"><a href="lcnt.html#pid-2">pid/2</a></li> <li title="pid-3"><a href="lcnt.html#pid-3">pid/3</a></li> <li title="port-1"><a href="lcnt.html#port-1">port/1</a></li> <li title="port-2"><a href="lcnt.html#port-2">port/2</a></li> <li title="rt_collect-0"><a href="lcnt.html#rt_collect-0">rt_collect/0</a></li> <li title="rt_collect-1"><a href="lcnt.html#rt_collect-1">rt_collect/1</a></li> <li title="rt_clear-0"><a href="lcnt.html#rt_clear-0">rt_clear/0</a></li> <li title="rt_clear-1"><a href="lcnt.html#rt_clear-1">rt_clear/1</a></li> <li title="rt_opt-1"><a href="lcnt.html#rt_opt-1">rt_opt/1</a></li> <li title="rt_opt-2"><a href="lcnt.html#rt_opt-2">rt_opt/2</a></li> </ul> </li> <li id="no" title="make " expanded="false">make<ul> <li><a href="make.html"> Top of manual page </a></li> <li title="all-0"><a href="make.html#all-0">all/0</a></li> <li title="all-1"><a href="make.html#all-1">all/1</a></li> <li title="files-1"><a href="make.html#files-1">files/1</a></li> <li title="files-2"><a href="make.html#files-2">files/2</a></li> </ul> </li> <li id="no" title="tags " expanded="false">tags<ul> <li><a href="tags.html"> Top of manual page </a></li> <li title="file-1"><a href="tags.html#file-1">file/1</a></li> <li title="files-1"><a href="tags.html#files-1">files/1</a></li> <li title="dir-1"><a href="tags.html#dir-1">dir/1</a></li> <li title="dirs-1"><a href="tags.html#dirs-1">dirs/1</a></li> <li title="subdir-1"><a href="tags.html#subdir-1">subdir/1</a></li> <li title="subdirs-1"><a href="tags.html#subdirs-1">subdirs/1</a></li> <li title="root-1"><a href="tags.html#root-1">root/1</a></li> </ul> </li> <li id="no" title="xref " expanded="false">xref<ul> <li><a href="xref.html"> Top of manual page </a></li> <li title="add_application-2"><a href="xref.html#add_application-2">add_application/2</a></li> <li title="add_directory-2"><a href="xref.html#add_directory-2">add_directory/2</a></li> <li title="add_module-2"><a href="xref.html#add_module-2">add_module/2</a></li> <li title="add_release-2"><a href="xref.html#add_release-2">add_release/2</a></li> <li title="analyze-2"><a href="xref.html#analyze-2">analyze/2</a></li> <li title="d-1"><a href="xref.html#d-1">d/1</a></li> <li title="forget-1"><a href="xref.html#forget-1">forget/1</a></li> <li title="forget-2"><a href="xref.html#forget-2">forget/2</a></li> <li title="format_error-1"><a href="xref.html#format_error-1">format_error/1</a></li> <li title="get_default-1"><a href="xref.html#get_default-1">get_default/1</a></li> <li title="get_default-2"><a href="xref.html#get_default-2">get_default/2</a></li> <li title="get_library_path-1"><a href="xref.html#get_library_path-1">get_library_path/1</a></li> <li title="info-1"><a href="xref.html#info-1">info/1</a></li> <li title="info-2"><a href="xref.html#info-2">info/2</a></li> <li title="info-3"><a href="xref.html#info-3">info/3</a></li> <li title="m-1"><a href="xref.html#m-1">m/1</a></li> <li title="m-1"><a href="xref.html#m-1">m/1</a></li> <li title="q-2"><a href="xref.html#q-2">q/2</a></li> <li title="remove_application-2"><a href="xref.html#remove_application-2">remove_application/2</a></li> <li title="remove_module-2"><a href="xref.html#remove_module-2">remove_module/2</a></li> <li title="remove_release-2"><a href="xref.html#remove_release-2">remove_release/2</a></li> <li title="replace_application-3"><a href="xref.html#replace_application-3">replace_application/3</a></li> <li title="replace_module-3"><a href="xref.html#replace_module-3">replace_module/3</a></li> <li title="set_default-3"><a href="xref.html#set_default-3">set_default/3</a></li> <li title="set_default-2"><a href="xref.html#set_default-2">set_default/2</a></li> <li title="set_library_path-2"><a href="xref.html#set_library_path-2">set_library_path/2</a></li> <li title="start-1"><a href="xref.html#start-1">start/1</a></li> <li title="start-2"><a href="xref.html#start-2">start/2</a></li> <li title="stop-1"><a href="xref.html#stop-1">stop/1</a></li> <li title="update-1"><a href="xref.html#update-1">update/1</a></li> <li title="variables-1"><a href="xref.html#variables-1">variables/1</a></li> </ul> </li> </ul> </div></div> <div id="content"> <div class="innertube"> <!-- refpage --><center><h1>cover</h1></center> <h3>MODULE</h3> <div class="REFBODY">cover</div> <h3>MODULE SUMMARY</h3> <div class="REFBODY">A Coverage Analysis Tool for Erlang</div> <h3>DESCRIPTION</h3> <div class="REFBODY"><p> <p>The module <span class="code">cover</span> provides a set of functions for coverage analysis of Erlang programs, counting how many times each <strong>executable line</strong> of code is executed when a program is run. <br> An executable line contains an Erlang expression such as a matching or a function call. A blank line or a line containing a comment, function head or pattern in a <span class="code">case</span>- or <span class="code">receive</span> statement is not executable.</p> <p>Coverage analysis can be used to verify test cases, making sure all relevant code is covered, and may also be helpful when looking for bottlenecks in the code.</p> <p>Before any analysis can take place, the involved modules must be <strong>Cover compiled</strong>. This means that some extra information is added to the module before it is compiled into a binary which then is loaded. The source file of the module is not affected and no <span class="code">.beam</span> file is created.</p> <p>Each time a function in a Cover compiled module is called, information about the call is added to an internal database of Cover. The coverage analysis is performed by examining the contents of the Cover database. The output <span class="code">Answer</span> is determined by two parameters, <span class="code">Level</span> and <span class="code">Analysis</span>.</p> <ul> <li> <p><span class="code">Level = module</span></p> <p><span class="code">Answer = {Module,Value}</span>, where <span class="code">Module</span> is the module name.</p> </li> <li> <p><span class="code">Level = function</span></p> <p><span class="code">Answer = [{Function,Value}]</span>, one tuple for each function in the module. A function is specified by its module name <span class="code">M</span>, function name <span class="code">F</span> and arity <span class="code">A</span> as a tuple <span class="code">{M,F,A}</span>.</p> </li> <li> <p><span class="code">Level = clause</span></p> <p><span class="code">Answer = [{Clause,Value}]</span>, one tuple for each clause in the module. A clause is specified by its module name <span class="code">M</span>, function name <span class="code">F</span>, arity <span class="code">A</span> and position in the function definition <span class="code">C</span> as a tuple <span class="code">{M,F,A,C}</span>.</p> </li> <li> <p><span class="code">Level = line</span></p> <p><span class="code">Answer = [{Line,Value}]</span>, one tuple for each executable line in the module. A line is specified by its module name <span class="code">M</span> and line number in the source file <span class="code">N</span> as a tuple <span class="code">{M,N}</span>.</p> </li> <li> <p><span class="code">Analysis = coverage</span></p> <p><span class="code">Value = {Cov,NotCov}</span> where <span class="code">Cov</span> is the number of executable lines in the module, function, clause or line that have been executed at least once and <span class="code">NotCov</span> is the number of executable lines that have not been executed.</p> </li> <li> <p><span class="code">Analysis = calls</span></p> <p><span class="code">Value = Calls</span> which is the number of times the module, function, or clause has been called. In the case of line level analysis, <span class="code">Calls</span> is the number of times the line has been executed.</p> </li> </ul> <p><strong>Distribution</strong></p> <p>Cover can be used in a distributed Erlang system. One of the nodes in the system must then be selected as the <strong>main node</strong>, and all Cover commands must be executed from this node. The error reason <span class="code">not_main_node</span> is returned if an interface function is called on one of the remote nodes.</p> <p>Use <span class="code">cover:start/1</span> and <span class="code">cover:stop/1</span> to add or remove nodes. The same Cover compiled code will be loaded on each node, and analysis will collect and sum up coverage data results from all nodes.</p> </p></div> <h3>EXPORTS</h3> <p><a name="start-0"><span class="bold_code">start() -> {ok,Pid} | {error,Reason}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Pid = pid()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Reason = {already_started,Pid}</span><br> </div> </div> <div class="REFBODY"><p> <p>Starts the Cover server which owns the Cover internal database. This function is called automatically by the other functions in the module.</p> </p></div> <p><a name="start-1"><span class="bold_code">start(Nodes) -> {ok,StartedNodes} | {error,not_main_node}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Nodes = StartedNodes = [atom()]</span><br> </div> </div> <div class="REFBODY"><p> <p>Starts a Cover server on the each of given nodes, and loads all cover compiled modules.</p> </p></div> <p><a name="compile-1"><span class="bold_code">compile(ModFile) -> Result</span></a><br><a name="compile-2"><span class="bold_code">compile(ModFile, Options) -> Result</span></a><br><a name="compile_module-1"><span class="bold_code">compile_module(ModFile) -> Result</span></a><br><a name="compile_module-2"><span class="bold_code">compile_module(ModFile, Options) -> Result</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">ModFile = Module | File</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Module = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> File = string()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Options = [Option]</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Option = {i,Dir} | {d,Macro} | {d,Macro,Value}</span><br> </div> <div class="REFBODY">See <span class="code">compile:file/2.</span> </div> <div class="REFTYPES"> <span class="bold_code">Result = {ok,Module} | {error,File} | {error,not_main_node}</span><br> </div> </div> <div class="REFBODY"><p> <p>Compiles a module for Cover analysis. The module is given by its module name <span class="code">Module</span> or by its file name <span class="code">File</span>. The <span class="code">.erl</span> extension may be omitted. If the module is located in another directory, the path has to be specified.</p> <p><span class="code">Options</span> is a list of compiler options which defaults to <span class="code">[]</span>. Only options defining include file directories and macros are passed to <span class="code">compile:file/2</span>, everything else is ignored.</p> <p>If the module is successfully Cover compiled, the function returns <span class="code">{ok,Module}</span>. Otherwise the function returns <span class="code">{error,File}</span>. Errors and warnings are printed as they occur.</p> <p>Note that the internal database is (re-)initiated during the compilation, meaning any previously collected coverage data for the module will be lost.</p> </p></div> <p><a name="compile_directory-0"><span class="bold_code">compile_directory() -> [Result] | {error,Reason}</span></a><br><a name="compile_directory-1"><span class="bold_code">compile_directory(Dir) -> [Result] | {error,Reason}</span></a><br><a name="compile_directory-2"><span class="bold_code">compile_directory(Dir, Options) -> [Result] | {error,Reason}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Dir = string()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Options = [Option]</span><br> </div> <div class="REFBODY">See <span class="code">compile_module/1,2</span> </div> <div class="REFTYPES"> <span class="bold_code">Result = {ok,Module} | {error,File} | {error,not_main_node}</span><br> </div> <div class="REFBODY">See <span class="code">compile_module/1,2</span> </div> <div class="REFTYPES"> <span class="bold_code">Reason = eacces | enoent</span><br> </div> </div> <div class="REFBODY"><p> <p>Compiles all modules (<span class="code">.erl</span> files) in a directory <span class="code">Dir</span> for Cover analysis the same way as <span class="code">compile_module/1,2</span> and returns a list with the return values.</p> <p><span class="code">Dir</span> defaults to the current working directory.</p> <p>The function returns <span class="code">{error,eacces}</span> if the directory is not readable or <span class="code">{error,enoent}</span> if the directory does not exist.</p> </p></div> <p><a name="compile_beam-1"><span class="bold_code">compile_beam(ModFile) -> Result</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">ModFile = Module | BeamFile</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Module = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> BeamFile = string()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Result = {ok,Module} | {error,BeamFile} | {error,Reason}</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Reason = non_existing | {no_abstract_code,BeamFile} | {encrypted_abstract_code,BeamFile} | {already_cover_compiled,no_beam_found,Module} | not_main_node</span><br> </div> </div> <div class="REFBODY"><p> <p>Does the same as <span class="code">compile/1,2</span>, but uses an existing <span class="code">.beam</span> file as base, i.e. the module is not compiled from source. Thus <span class="code">compile_beam/1</span> is faster than <span class="code">compile/1,2</span>.</p> <p>Note that the existing <span class="code">.beam</span> file must contain <strong>abstract code</strong>, i.e. it must have been compiled with the <span class="code">debug_info</span> option. If not, the error reason <span class="code">{no_abstract_code,BeamFile}</span> is returned. If the abstract code is encrypted, and no key is available for decrypting it, the error reason <span class="code">{encrypted_abstract_code,BeamFile} is returned. <p>If only the module name (i.e. not the full name of the <c>.beam</span> file) is given to this function, the <span class="code">.beam</span> file is found by calling <span class="code">code:which(Module)</span>. If no <span class="code">.beam</span> file is found, the error reason <span class="code">non_existing</span> is returned. If the module is already cover compiled with <span class="code">compile_beam/1</span>, the <span class="code">.beam</span> file will be picked from the same location as the first time it was compiled. If the module is already cover compiled with <span class="code">compile/1,2</span>, there is no way to find the correct <span class="code">.beam</span> file, so the error reason <span class="code">{already_cover_compiled,no_beam_found,Module}</span> is returned.</p> <p><span class="code">{error,BeamFile}</span> is returned if the compiled code can not be loaded on the node.</p> </p></div> <p><a name="compile_beam_directory-0"><span class="bold_code">compile_beam_directory() -> [Result] | {error,Reason}</span></a><br><a name="compile_beam_directory-1"><span class="bold_code">compile_beam_directory(Dir) -> [Result] | {error,Reason}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Dir = string()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Result = See compile_beam/1</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Reason = eacces | enoent</span><br> </div> </div> <div class="REFBODY"><p> <p>Compiles all modules (<span class="code">.beam</span> files) in a directory <span class="code">Dir</span> for Cover analysis the same way as <span class="code">compile_beam/1</span> and returns a list with the return values.</p> <p><span class="code">Dir</span> defaults to the current working directory.</p> <p>The function returns <span class="code">{error,eacces}</span> if the directory is not readable or <span class="code">{error,enoent}</span> if the directory does not exist.</p> </p></div> <p><a name="analyse-1"><span class="bold_code">analyse(Module) -> {ok,Answer} | {error,Error}</span></a><br><a name="analyse-2"><span class="bold_code">analyse(Module, Analysis) -> {ok,Answer} | {error,Error}</span></a><br><a name="analyse-2"><span class="bold_code">analyse(Module, Level) -> {ok,Answer} | {error,Error}</span></a><br><a name="analyse-3"><span class="bold_code">analyse(Module, Analysis, Level) -> {ok,Answer} | {error,Error}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Module = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Analysis = coverage | calls</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Level = line | clause | function | module</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Answer = {Module,Value} | [{Item,Value}]</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Item = Line | Clause | Function</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Line = {M,N}</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Clause = {M,F,A,C}</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Function = {M,F,A}</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> M = F = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> N = A = C = integer()</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Value = {Cov,NotCov} | Calls</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Cov = NotCov = Calls = integer()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Error = {not_cover_compiled,Module} | not_main_node</span><br> </div> </div> <div class="REFBODY"><p> <p>Performs analysis of a Cover compiled module <span class="code">Module</span>, as specified by <span class="code">Analysis</span> and <span class="code">Level</span> (see above), by examining the contents of the internal database.</p> <p><span class="code">Analysis</span> defaults to <span class="code">coverage</span> and <span class="code">Level</span> defaults to <span class="code">function</span>.</p> <p>If <span class="code">Module</span> is not Cover compiled, the function returns <span class="code">{error,{not_cover_compiled,Module}}</span>.</p> <p>HINT: It is possible to issue multiple analyse_to_file commands at the same time. </p> </p></div> <p><a name="analyse_to_file-1"><span class="bold_code">analyse_to_file(Module) -> </span></a><br><a name="analyse_to_file-2"><span class="bold_code">analyse_to_file(Module,Options) -> </span></a><br><a name="analyse_to_file-2"><span class="bold_code">analyse_to_file(Module, OutFile) -> </span></a><br><a name="analyse_to_file-3"><span class="bold_code">analyse_to_file(Module, OutFile, Options) -> {ok,OutFile} | {error,Error}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Module = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">OutFile = string()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Options = [Option]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Option = html</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Error = {not_cover_compiled,Module} | {file,File,Reason} | no_source_code_found | not_main_node</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> File = string()</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Reason = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Makes a copy <span class="code">OutFile</span> of the source file for a module <span class="code">Module</span>, where it for each executable line is specified how many times it has been executed.</p> <p>The output file <span class="code">OutFile</span> defaults to <span class="code">Module.COVER.out</span>, or <span class="code">Module.COVER.html</span> if the option <span class="code">html</span> was used.</p> <p>If <span class="code">Module</span> is not Cover compiled, the function returns <span class="code">{error,{not_cover_compiled,Module}}</span>.</p> <p>If the source file and/or the output file cannot be opened using <span class="code">file:open/2</span>, the function returns <span class="code">{error,{file,File,Reason}}</span> where <span class="code">File</span> is the file name and <span class="code">Reason</span> is the error reason.</p> <p>If the module was cover compiled from the <span class="code">.beam</span> file, i.e. using <span class="code">compile_beam/1</span> or <span class="code">compile_beam_directory/0,1</span>, it is assumed that the source code can be found in the same directory as the <span class="code">.beam</span> file, or in <span class="code">../src</span> relative to that directory. If no source code is found, <span class="code">,{error,no_source_code_found}</span> is returned.</p> <p>HINT: It is possible to issue multiple analyse_to_file commands at the same time. </p> </p></div> <p><a name="async_analyse_to_file-1"><span class="bold_code">async_analyse_to_file(Module) -> </span></a><br><a name="async_analyse_to_file-2"><span class="bold_code">async_analyse_to_file(Module,Options) -> </span></a><br><a name="async_analyse_to_file-2"><span class="bold_code">async_analyse_to_file(Module, OutFile) -> </span></a><br><a name="async_analyse_to_file-3"><span class="bold_code">async_analyse_to_file(Module, OutFile, Options) -> pid()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Module = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">OutFile = string()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Options = [Option]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Option = html</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Error = {not_cover_compiled,Module} | {file,File,Reason} | no_source_code_found | not_main_node</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> File = string()</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Reason = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>This function works exactly the same way as <span class="bold_code"><a href="#analyse_to_file-1">analyse_to_file</a></span> except that it is asynchronous instead of synchronous. The spawned process will link with the caller when created. If an <span class="code">Error</span> occurs while doing the cover analysis the process will crash with the same error reason as <span class="bold_code"><a href="#analyse_to_file-1">analyse_to_file</a></span> would return.</p> </p></div> <p><a name="modules-0"><span class="bold_code">modules() -> [Module] | {error,not_main_node}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Module = atom()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a list with all modules that are currently Cover compiled.</p> </p></div> <p><a name="imported_modules-0"><span class="bold_code">imported_modules() -> [Module] | {error,not_main_node}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Module = atom()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a list with all modules for which there are imported data.</p> </p></div> <p><a name="imported-0"><span class="bold_code">imported() -> [File] | {error,not_main_node}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">File = string()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a list with all imported files.</p> </p></div> <p><a name="which_nodes-0"><span class="bold_code">which_nodes() -> [Node] | {error,not_main_node}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Node = atom()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a list with all nodes that are part of the coverage analysis. Note that the current node is not returned. This node is always part of the analysis.</p> </p></div> <p><a name="is_compiled-1"><span class="bold_code">is_compiled(Module) -> {file,File} | false | {error,not_main_node}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Module = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Beam = string()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns <span class="code">{file,File}</span> if the module <span class="code">Module</span> is Cover compiled, or <span class="code">false</span> otherwise. <span class="code">File</span> is the <span class="code">.erl</span> file used by <span class="code">cover:compile_module/1,2</span> or the <span class="code">.beam</span> file used by <span class="code">compile_beam/1</span>.</p> </p></div> <p><a name="reset-1"><span class="bold_code">reset(Module) -></span></a><br><a name="reset-0"><span class="bold_code">reset() -> ok | {error,not_main_node}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Module = atom()</span><br> </div> </div> <div class="REFBODY"><p> <p>Resets all coverage data for a Cover compiled module <span class="code">Module</span> in the Cover database on all nodes. If the argument is omitted, the coverage data will be reset for all modules known by Cover.</p> <p>If <span class="code">Module</span> is not Cover compiled, the function returns <span class="code">{error,{not_cover_compiled,Module}}</span>.</p> </p></div> <p><a name="export-1"><span class="bold_code">export(ExportFile)</span></a><br><a name="export-2"><span class="bold_code">export(ExportFile,Module) -> ok | {error,Reason}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">ExportFile = string()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Module = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Reason = {not_cover_compiled,Module} | {cant_open_file,ExportFile,Reason} | not_main_node</span><br> </div> </div> <div class="REFBODY"><p> <p>Exports the current coverage data for <span class="code">Module</span> to the file <span class="code">ExportFile</span>. It is recommended to name the <span class="code">ExportFile</span> with the extension <span class="code">.coverdata</span>, since other filenames can not be read by the web based interface to cover.</p> <p>If <span class="code">Module</span> is not given, data for all Cover compiled or earlier imported modules is exported.</p> <p>This function is useful if coverage data from different systems is to be merged.</p> <p>See also <span class="code">cover:import/1</span></p> </p></div> <p><a name="import-1"><span class="bold_code">import(ExportFile) -> ok | {error,Reason}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">ExportFile = string()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Reason = {cant_open_file,ExportFile,Reason} | not_main_node</span><br> </div> </div> <div class="REFBODY"><p> <p>Imports coverage data from the file <span class="code">ExportFile</span> created with <span class="code">cover:export/1,2</span>. Any analysis performed after this will include the imported data.</p> <p>Note that when compiling a module <strong>all existing coverage data is removed</strong>, including imported data. If a module is already compiled when data is imported, the imported data is <strong>added</strong> to the existing coverage data.</p> <p>Coverage data from several export files can be imported into one system. The coverage data is then added up when analysing.</p> <p>Coverage data for a module can not be imported from the same file twice unless the module is first reset or compiled. The check is based on the filename, so you can easily fool the system by renaming your export file.</p> <p>See also <span class="code">cover:export/1,2</span></p> </p></div> <p><a name="stop-0"><span class="bold_code">stop() -> ok | {error,not_main_node}</span></a><br></p> <div class="REFBODY"><p> <p>Stops the Cover server and unloads all Cover compiled code.</p> </p></div> <p><a name="stop-1"><span class="bold_code">stop(Nodes) -> ok | {error,not_main_node}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Nodes = [atom()]</span><br> </div> </div> <div class="REFBODY"><p> <p>Stops the Cover server and unloads all Cover compiled code on the given nodes. Data stored in the Cover database on the remote nodes is fetched and stored on the main node.</p> </p></div> <h3><a name="id74993">SEE ALSO</a></h3> <div class="REFBODY"> <p>code(3), compile(3)</p> </div> </div> <div class="footer"> <hr> <p>Copyright © 1997-2012 Ericsson AB. All Rights Reserved.</p> </div> </div> </div></body> </html>