Skip to content

Code Coverage

pritigoel edited this page May 18, 2016 · 4 revisions

CCNx Code Coverage

Getting Ready

For convenience:

#export NS3_RELEASE=${NS3_RELEASE}
export NS3_RELEASE=3.25
export NSDIR=~/ns3/ns-allinone-${NS3_RELEASE}/ns-${NS3_RELEASE}

On OS X:

brew install lcov
patch -p2 < src/ccns3Sim/patch-files/ns-${NS3_RELEASE}.osx-gcov.patch

On GNU/Linux:

sudo <apt-get|yum|whatever> install gcov lcov

In a Nutshell

NOTE: All of the following are done from the ns-3 root directory (e.g. ns-3.25/).

  • For convenience create a couple symbolic links:
cd $NSDIR
ln -s ./src/ccns3Sim/bin/ccnx.sh
ln -s ./src/ccns3Sim/bin/run_ccnx_test_suites.sh
  • The code needs to be compiled with --enable-gcov. This can be done with following command. CAUTION The command below will clean, configure, and build the code.
./ccnx.sh rebuild gcov
  • You can also do the command above as three separate commands:
./ccnx.sh clean
./ccnx.sh configure gcov
./ccnx.sh build
  • To clean up all of the debug files and directories, you can:
./ccnx.sh debug_purge
  • To just clean up all of the gcov files, you can (.gcno files are preserved):
./ccnx.sh gcov_clean
  • To see a list of testcases, do:
./run_ccnx_test_suites.sh list
  • To run a single test suite with coverage, do:
./run_ccnx_test_suites.sh suite <TestSuiteName> coverage
  • To run a single test suite without coverage, do:
./run_ccnx_test_suites.sh suite <TestSuiteName>
  • To run all ccnx test suites with coverage, do:
./run_ccnx_test_suites.sh ccnx coverage
  • To run all ns-3 test suites, including ccnx, with coverage, do:
./run_ccnx_test_suites.sh ns3 coverage
  • To run a single test suite with coverage in debug mode, do:
./run_ccnx_test_suites.sh debug <TestSuiteName> coverage
  • To run a single test suite without coverage in debug mode, do:
./run_ccnx_test_suites.sh debug <TestSuiteName>
  • An example with multiple test suites and detailed coverage:
./run_ccnx_test_suites.sh suite ccnx-contentobject suite ccnx-fixedheader suite ccnx-interest coverage detailed
# or just
./run_ccnx_test_suites.sh suite ccnx-contentobject suite ccnx-fixedheader suite ccnx-interest  detailed

Other Information

  • All lcov coverage results will be placed under the directory ccnx-debug To view the coverage results for a single testcase, do:
# OS X:
open ./ccnx-debug/<TestSuiteName>/index.html
# GNU/Linux:
sensible-browser ./ccnx-debug/<TestSuiteName>/index.html
  • By default, all non-ccnx .gcda files will be deleted prior to running lcov. If you want all of the .gcda files included in the lcov, and subsequent genhtml HTML file generation, add the "full" argument to the ./run_ccnx_test_suites command line.

  • To delete all of the coverage files, you can:

./ccnx.sh gcov_clean
# Alternatively, _gcov_clean_ is implied any time the _rebuild_ or _config_
# arguments are given without the _gcov_ argument.
./ccnx.sh config      # _gcov_clean_ is implied
./ccnx.sh rebuild     # _gcov_clean_ is implied
  • Home
  • [Getting Started](Getting Started)
  • Developer
    • [Node Architecture](Node Architecture)
    • [Header doc format](Header doc format)
    • [Unit Tests](Unit Tests)
    • [Overriding Implementations](Overriding Implementations)
    • [Code Coverage](Code Coverage)

Clone this wiki locally