Appendix A. cvcov Command Line Examples

This appendix contains several examples of command line usage for cvcov. For complete details about using cvcov, see the cvcov(1) man page and Chapter 3, “Tester Command Line Reference”.

General Test Command Examples

The following examples demonstrate commands that support the creation, inspection, modification, and deletion of tests:

cattest describes the test details for a test, test set, or test group.

Example A-1. cattest Example

% cvcov cattest test0000
Test Info                Settings
------------------------------------------------------------
Test                     /disk2/tutorial/tutorial/test0000
Type                     single
Description              
Command Line             copyn alphabet targetfile 20
Number of Exes           1
Exe List                 copyn
Instrument Directory     /disk2/tutorial/tutorial/
Experiment List          
                           exp##0
                           exp##1


Example A-2. cattest Example without -r

% cvcov cattest tut_testset
Test Info                Settings
----------------------------------------------------------
Test                    /disk2/tutorial/tutorial/tut_testset
Type                    set
Description             full coverage testset
Number of Exes          1
Exe List                copyn
Number of Subtests      9
Subtest List             
                        [0] /disk2/tutorial/tutorial/test0000
                        [1] /disk2/tutorial/tutorial/test0001
                        [2] /disk2/tutorial/tutorial/test0002
                        [3] /disk2/tutorial/tutorial/test0003
                        [4] /disk2/tutorial/tutorial/test0004
                        [5] /disk2/tutorial/tutorial/test0005
                        [6] /disk2/tutorial/tutorial/test0006
                        [7] /disk2/tutorial/tutorial/test0007
                        [8] /disk2/tutorial/tutorial/test0008
Experiment List          
                        exp##0


Example A-3. cattest Example with -r

% cvcov cattest -r tut_testset

Test Info                Settings
---------------------------------------------------------
Test                    /disk2/tutorial/tutorial/tut_testset
Type                    set
Description             full coverage testset
Number of Exes          1
Exe List                copyn
Number of Subtests      9
Subtest List             
                        /disk2/tutorial/tutorial/test0000
                        /disk2/tutorial/tutorial/test0001
                        /disk2/tutorial/tutorial/test0002
                        /disk2/tutorial/tutorial/test0003
                        /disk2/tutorial/tutorial/test0004
                        /disk2/tutorial/tutorial/test0005
                        /disk2/tutorial/tutorial/test0006
                        /disk2/tutorial/tutorial/test0007
                        /disk2/tutorial/tutorial/test0008
Experiment List          
                        exp##0


lsinstr lists the test directories in the current working directory.

Example A-4. lsinstr Example

% cvcov lsinstr test0000
Instrumentation         Info
---------------------------------------------------------
Executable              copyn
Version                 0
Instrument Directory    /x/tmp/carol/
Instrument File         tut_instr_file
Criteria                RBPA
Instrumented Objects    copyn.pixie(2.57X)
                          libc.so.1_RBP_Instr(1.07X)

mktest creates a test directory.


Example A-5. Test Description File Examples

% cvcov mktest -cmd "copyn tut_instr_file targetfile"
cvcov: Made test directory: /d/Tester/tutorial/test0002

% cvcov cattest test0002
Test Info               Settings
---------------------------------------------------------
Test                    /d/Tester/tutorial/test0002
Type                    single
Description              
Command Line            copyn tut_instr_file targetfile
Number of Exes          1
Exe List                copyn
Instrument Directory    /d/Tester/tutorial
Experiment List 


Coverage Analysis Commands

After the data has been collected from the test experiments, data can be analyzed with special commands for the various types of coverage available.

lssum shows the overall coverage based on the user-defined weighted average over function, line, block, branch, and arc coverage.

Example A-6. lssum Example

% cvcov lssum test0000   
Coverages        Covered     Total       % Coverage    Weight
------------------------------------------------------------
Function         2           2           100.00%       0.400
Source Line      17          35          48.57%        0.200
Branch           0            10           0.00%        0.200   
Arc              8           18          44.44%        0.200
Block            19          42          45.24%        0.000
Weighted Sum                             58.60%        1.000

lsfun lists coverage information for the specified functions in the program that was tested.

Example A-7. lsfun Example

% cvcov lsfun -pretty -sort function test0000
Functions    Files       Counts
-------------------------------------
copy_file    copyn.c     1
main         copyn.c     1



: C++ inline functions are not counted as functions.

lsblock displays a list of blocks for one or more functions and the count information associated with each block.

Example A-8. lsblock Example

cvcov lsblock -pat main -pretty test0000
Blocks      Functions    Files       Counts
-------------------------------------------------
13~16       main         copyn.c     1
17~17       main         copyn.c     0
18~18       main         copyn.c     0
19~19       main         copyn.c     0
21~21       main         copyn.c     1
22~22       main         copyn.c     0
23~23       main         copyn.c     0
24~24       main         copyn.c     0
26~26       main         copyn.c     1
26~27       main         copyn.c     1
27~27       main         copyn.c     1
28~28       main         copyn.c     0   
28~28(2)    main         copyn.c     0   
28~28(3)    main         copyn.c     0   
28~28(4)    main         copyn.c     0   
30~30       main         copyn.c     0   
31~31       main         copyn.c     0   
33~33       main         copyn.c     0   
34~34       main         copyn.c     0   
36~36       main         copyn.c     0   
37~37       main         copyn.c     0   
39~39       main         copyn.c     0   
41~41       main         copyn.c     0     
43~43       main         copyn.c     1
43~43(2)    main         copyn.c     0   
43~43(3)    main         copyn.c     1

lsbranch lists coverage information for branches in the program, including the line number at which the branch occurs.

Example A-9. lsbranch Example

% cvcov lsbranch -pretty -sort function test0000
Line        Functions    Files       Taken       Not Taken
-------------------------------------------------------------
50          copy_file    copyn.c     1           0       
54          copy_file    copyn.c     1           0       
57          copy_file    copyn.c     1           0       
60          copy_file    copyn.c     1           0       
16          main         copyn.c     1           0       
21          main         copyn.c     1           0       
27          main         copyn.c     1           0       
28          main         copyn.c     0           0       
28(2)       main         copyn.c     0           0       
28(3)       main         copyn.c     0           0

lsarc shows arc coverage, that is, the number of arcs taken out of the total possible arcs.

Example A-10. lsarc Example

% cvcov lsarc -callee printf -pretty test0001
Callers    Callees     Line       Files       Counts
---------------------------------------------------------
main        printf      17          copyn.c     1        
main        printf      18          copyn.c     1        
main        printf      22          copyn.c     0        
main        printf      23          copyn.c     0        
main        printf      30          copyn.c     0        
main        printf      33          copyn.c     0        
main        printf      36          copyn.c     0        

lscall lists the call graph for the executable with counts for each function.

Example A-11. lscall Example

% cvcov lscall -pretty test0000
Graph            Counts
---------------------------------
main             1
     copy_file     1
        _open      N/A
        _stat...   N/A
        _creat     N/A
        _malloc... N/A
        _read      N/A
        _write     N/A
     printf...     N/A
     exit...       N/A
     atoi          N/A

Lists the coverage for native source lines.

Example A-12. lsline Example

% cvcov lsline -pretty -pat main test0000
Functions   Files      Covered   Total     % Coverage
---------------------------------------------------------
main        copyn.c    6         20        30.00%

lssource displays the source annotated with line counts. This option requires the code to be compiled with the -g option.

Example A-13. lssource Example

% cvcov lssource main test0000
Counts  Source
-------------------------------------------------------------
          #include <stdio.h>
          #include <sys/stat.h>
          #include <sys/types.h>
          #include <fcntl.h>
   
          #define OPEN_ERR         1
          #define NOT_ENOUGH_BYTES 2
          #define SIZE_0           3
   
          int copy_file();
   
          main (int argc, char *argv[])
1       {
              int bytes, status;
   
1           if( argc < 4){
0               printf(“copyn: Insufficient arguments.\n”); 
0               printf(“Usage: copyn f1 f2 bytes\n”); 
0               exit(1); 
              }
1           if( argc > 4 ) {
0               printf(“Error: Too many arguments\n”); 
0               printf(“Usage: copyn f1 f2 bytes\n”); 
0               exit(1); 
              }
1           bytes = atoi(argv[3]);

diff shows the difference in coverage for different versions of the same program. The following examples show different uses of the diff option.

Example A-14. diff between Two Tests

% cvcov diff test0000/exp##0 test0001/exp##0

Experiment 1:    test0000/exp##0
Experiment 2:    test0001/exp##0

Coverages            Exp 1       Exp 2        Differences
----------------------------------------------------------
Function Coverage    2(100.00%)  1(50.00%)    1(50.00%)
Source Line Coverage 17(48.57%)  5(14.29%)    12(34.29%)
Branch Coverage      0(0.00%)    0(0.00%)     0(0.00%)
Arc Coverage         8(44.44%)   3(16.67%)    5(27.78%)
Block Coverage       19(45.24%)  4(9.52%)     15(35.71%) 


Example A-15. diff between Different Instrumentations of the Same Test

% cvcov diff test0000/exp##0 test0000/exp##1
Experiment 1:    test0000/exp##0
Experiment 2:    test0000/exp##1

Coverages            Exp 1        Exp 2       Differences
----------------------------------------------------------
Function Coverage    2(100.00%)    2(100.00%)    0(0.00%)
Source Line Coverage 17(48.57%)    17(47.22%)    0(1.35%)
Branch Coverage      0(0.00%)      0(0.00%)      0(0.00%)
Arc Coverage         8(44.44%)     8(44.44%)     0(0.00%)
Block Coverage       19(45.24%)    19(44.19%)    0(-1.05%)


Test Set Command Examples

A test set is a named collection of tests and other test sets. Test sets can be hierarchical. There are several commands used with test sets, including mktset, addtest, deltest, and optimize.

optimize selects the minimum set of tests that give the same coverage or meet the given coverage criteria as the given set.

Example A-16. Optimizing Test Sets

% cvcov optimize -pretty -blocks -branches test00*

Test                Block Coverage    Branch Coverage
---------------------------------------------------------
test0000            41.54%            0.00%
test0001            7.69%             10.00%
test0002            7.69%             10.00%
test0003            9.23%             20.00%
test0004            9.23%             20.00%
test0005            6.15%             20.00%
test0006            1.54%             10.00%
Total Coverage      83.08%            90.00%