Programs for Programmers

Test Coverage and Hot-Spot Analysis

A reasonable goal for a software test suite is to ensure that every line of source code is executed at least once. The plusFORT coverage analysis facility allows users to monitor progress against this goal, as well as identifying “hot-spots” – the sections of code which are executed most frequently, and which have most effect on program execution time.

The plusFORT coverage analysis facility places probes into Fortran source code which allow users to monitor the effectiveness of testing. At the end of each run, the probes update the coverage statistics for each source file. This data may be analysed at any time using the CVRANAL tool. CVRANAL identifies untested code blocks, and execution hot-spots.

In addition, CVRANAL can annotate your source code as shown below. The annotations are comments and do not affect the validity of the source code.


Fragment of CVRANAL Test Coverage Report

   4 Untested code blocks in subprogram MOO in file TESTMOO.BEF
     at lines     27    32    33    62
NO   Untested code blocks in subprogram BC in file TESTMOO.BEF
NO   Untested code blocks in subprogram GETNUM in file TESTMOO.BEF
NO   Untested code blocks in subprogram INIT in file TESTMOO.BEF

Fragment of CVRANAL Execution Hot-spot Report

         49682 :       IF(IGUESS(IDIG).NE.IANS(JDIG))GOTO 10
               : in s/prog BC at line    82 of TESTMOO.BEF
         16336 :       IF(IGUESS(IDIG).EQ.IANS(IDIG))GOTO 40
               : in s/prog BC at line    80 of TESTMOO.BEF
         14399 :       DO 10 JDIG=1,NDIGIT
               : in s/prog BC at line    81 of TESTMOO.BEF
         11283 : 10    IF(J.EQ.NUM(JDIG))GOTO 20
               : in s/prog GETNUM at line   104 of TESTMOO.BEF
          9039 :       GOTO 20
               : in s/prog BC at line    86 of TESTMOO.BEF

Annotated Source Code

      SUBROUTINE BC(IGUESS,IANS,NBULLS,NCOWS)
      PARAMETER (NDIGIT=4,MINDIG=1,MAXDIG=9)
      DIMENSION IGUESS(NDIGIT),IANS(NDIGIT)

      NBULLS=0                                           !   4084
      NCOWS=0
      DO 20 IDIG=1,NDIGIT
      IF(IGUESS(IDIG).EQ.IANS(IDIG))GOTO 40              !  16336
      DO 10 JDIG=1,NDIGIT                                !  14399
      IF(IGUESS(IDIG).NE.IANS(JDIG))GOTO 10              !  49682
      NCOWS=NCOWS+1                                      !   5360
      GOTO 20
10    CONTINUE
      GOTO 20                                            !   9039
40    NBULLS=NBULLS+1                                    !   1937
20    CONTINUE
      RETURN                                             !   4084
      END