Exercise: Coverage measurement

 

This aim of this exercise is to define ‘good’ test cases from informal specifications and evaluate the the cases by using the coverage tools ‘gcov’ and/or ‘bullseye’.

 

(A)

Consider the following program specification:

The program takes two integer inputs and calculates the greatest common

divisor as output.

·         Design a ‘good’ set of test cases.

Consider the C-program gcd.c implementing the above specification (available in gcd)

·         Check and show (manually) whether the test set developed under (a) above satisfies the decision coverage (branch coverage) criterion.

·         VisualStudio+Bullseye Version:

o        Calculate the decision coverage using Bullseye coverage tool for the test set developed under (a).

Open the GCDcoverage workspace, and in the tools menu "enable Bullseye Coverage build", and rebuild project.

Open a command prompt and execute your test inputs
prompt%> ./gcd 1 1
prompt%> ./gcd 1 9
 etc…

View the coverage results (using Bulls eye coverage viewer). Bullseye uses condition/decision coverage by default.  To see decision coverage, in coverage viewer choose "Tools->options->view->decision coverage"

·         GNU GCC+GCOV Version. The necessary tools are available in most GCC installations under Linux/Solaris (/coll/local/bin/gcov or /usr/bin/gcov).

o        Calculate the line coverage using GCOV coverage tool for the test set developed under (a).

prompt%> gccfprofile-arcs -ftest-coverage gcd.c –o gcd
prompt%> ./gcd 1 1
prompt%> ./gcd 1 9
 etc…
prompt%> gcov gcd.c
prompt%> less gcd.c.gcov

·         If necessary, extend the test set developed under (a) such that 100% branch coverage is obtained (remember to refresh view in CoverageViewer to load new coverage information).

·         Did you also achieve condition/decision coverage?


(B)

Consider the following specification:

A program reads three integer values. The three values are

interpreted as representing the lengths of the sides of a triangle.

The program prints a message that states whether the triangle is

scalene (uligesidet), isosceles (ligebenet) , or equilateral (ligesidet).

 

·         Design a ’good’ set of test cases (or revisit the ones designed in the previous lecture)

 

The program triangle.c implements the above specification (available in triangle.h and triangle.c)

 

·         Evaluate your test cases using the coverage tools described above