codekingpro/portable-devtools
115k
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>33.5. Test Coverage Examination</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="regress-tap.html" title="33.4. TAP Tests" /><link rel="next" href="client-interfaces.html" title="Part IV. Client Interfaces" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">33.5. Test Coverage Examination</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="regress-tap.html" title="33.4. TAP Tests">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="regress.html" title="Chapter 33. Regression Tests">Up</a></td><th width="60%" align="center">Chapter 33. Regression Tests</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="client-interfaces.html" title="Part IV. Client Interfaces">Next</a></td></tr></table><hr /></div><div class="sect1" id="REGRESS-COVERAGE"><div class="titlepage"><div><div><h2 class="title" style="clear: both">33.5. Test Coverage Examination <a href="#REGRESS-COVERAGE" class="id_link">#</a></h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="regress-coverage.html#REGRESS-COVERAGE-CONFIGURE">33.5.1. Coverage with Autoconf and Make</a></span></dt><dt><span class="sect2"><a href="regress-coverage.html#REGRESS-COVERAGE-MESON">33.5.2. Coverage with Meson</a></span></dt></dl></div><p>3 The PostgreSQL source code can be compiled with coverage testing4 instrumentation, so that it becomes possible to examine which5 parts of the code are covered by the regression tests or any other6 test suite that is run with the code. This is currently supported7 when compiling with GCC, and it requires the <code class="literal">gcov</code>8 and <code class="literal">lcov</code> packages.9 </p><div class="sect2" id="REGRESS-COVERAGE-CONFIGURE"><div class="titlepage"><div><div><h3 class="title">33.5.1. Coverage with Autoconf and Make <a href="#REGRESS-COVERAGE-CONFIGURE" class="id_link">#</a></h3></div></div></div><p>10 A typical workflow looks like this:11</p><pre class="screen">12./configure --enable-coverage ... OTHER OPTIONS ...13make14make check # or other test suite15make coverage-html16</pre><p>17 Then point your HTML browser18 to <code class="filename">coverage/index.html</code>.19 </p><p>20 If you don't have <code class="command">lcov</code> or prefer text output over an21 HTML report, you can run22</p><pre class="screen">23make coverage24</pre><p>25 instead of <code class="literal">make coverage-html</code>, which will26 produce <code class="filename">.gcov</code> output files for each source file27 relevant to the test. (<code class="literal">make coverage</code> and <code class="literal">make28 coverage-html</code> will overwrite each other's files, so mixing them29 might be confusing.)30 </p><p>31 You can run several different tests before making the coverage report;32 the execution counts will accumulate. If you want33 to reset the execution counts between test runs, run:34</p><pre class="screen">35make coverage-clean36</pre><p>37 </p><p>38 You can run the <code class="literal">make coverage-html</code> or <code class="literal">make39 coverage</code> command in a subdirectory if you want a coverage40 report for only a portion of the code tree.41 </p><p>42 Use <code class="literal">make distclean</code> to clean up when done.43 </p></div><div class="sect2" id="REGRESS-COVERAGE-MESON"><div class="titlepage"><div><div><h3 class="title">33.5.2. Coverage with Meson <a href="#REGRESS-COVERAGE-MESON" class="id_link">#</a></h3></div></div></div><p>44 A typical workflow looks like this:45</p><pre class="screen">46meson setup -Db_coverage=true ... OTHER OPTIONS ... builddir/47meson compile -C builddir/48meson test -C builddir/49cd builddir/50ninja coverage-html51</pre><p>52 Then point your HTML browser53 to <code class="filename">./meson-logs/coveragereport/index.html</code>.54 </p><p>55 You can run several different tests before making the coverage report;56 the execution counts will accumulate.57 </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="regress-tap.html" title="33.4. TAP Tests">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="regress.html" title="Chapter 33. Regression Tests">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="client-interfaces.html" title="Part IV. Client Interfaces">Next</a></td></tr><tr><td width="40%" align="left" valign="top">33.4. TAP Tests </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> Part IV. Client Interfaces</td></tr></table></div></body></html>