Hitachi

Job Management Partner 1 Version 10 Job Management Partner 1/Advanced Shell Description, User's Guide, Reference, and Operator's Guide


3.9.4 Displaying coverage information

The following figure shows the general procedure from executing a job definition script to displaying the coverage information.

Figure 3‒5: General procedure for displaying coverage information

[Figure]

You can also use an editor to display coverage information in the development environment. For details about how to use an editor to display coverage information, see 4.4.7 Displaying coverage information.

Organization of this subsection

(1) How to display and command format

The adshcvshow coverage information display command is used to display coverage information. This command displays the contents of a specified asc file. If you wish to display only a desired range of a job definition script's coverage information, you can do so by specifying the range in the -l option.

If the -s option is specified, the command displays only the contents of a job definition script that has been backed up. You use the -s option to check the contents of a job definition script that has been backed up and to determine if there is any differential information between job definition scripts.

The following shows the format of the coverage information display command:

adshcvshow {[-l n1[-[n2]][,n3[-[n4]]]...]|-s} path-name-of-asc-file

To specify lines, use the comma (,) to separate individual line numbers and the hyphen (-) to specify a range of lines numbers. For example, to specify lines 1 through 10, line 15, and lines 21 through 30, specify the command as follows:

adshcvshow -l 1-10,15,21-30 path-name-of-asc-file

If no number follows a hyphen, the command assumes a range from the specified line number through the last line. For example, to specify lines 21 through the last line, specify the command as follows:

adshcvshow -l 21- path-name-of-asc-file

(2) Coverage information display format

The following table explains the coverage information display format.

Table 3‒9: Explanation of the coverage information display format

Item

Description

Title line (Advanced Shell Coverage Information)

Main title line indicating that this is coverage information acquired by JP1/Advanced Shell.

Date and time (top right)

Displays the date and time the adshcvshow command was executed, in the format yyyy-mm-dd hh:mm:ss. If the month, day, hour, minute, or second value consists of one digit, a leading zero is added.

Header section (Header Information)

Section title line indicating display of header information.

Job definition script name (Shellscript Name)

Displays the absolute path name of the job definition script.

Version of asc file (Asc version)

Displays the asc file's version number.

Coverage information collection start time (Coverage Start Time)

Displays the time collection of coverage information started. The format is the same as for the date and time.

Coverage information collection end time (Coverage End Time)

Displays the time collection of coverage information ended. The format is the same as for the date and time.

Number of times coverage information was collected (Test Count)

Displays the number of times coverage information was collected.

If the coverage information collection count exceeds 9,999, 9999+ is displayed.

How the collection count is obtained depends on an option specified in the batch job execution command (adshexec).

adshexec command with -t and -d specified

  • For coverage information in memory

    [Figure] Initial value

    If there is an asc file, the coverage information collection count for the asc file is used.

    If there is no asc file, the collection count is 0.

    [Figure] Updating

    The coverage information collection count is incremented by one each time the debugger's run command is executed.

  • For an asc file

    When the adshexec command terminates, the coverage information collection count is increased by the number of times the debugger's run command executed.

adshexec command with -t only specified

When the adshexec command terminates, the coverage information collection count is increased by one.

adshexec command with -d only specified

  • Coverage information in memory

    [Figure] Initial value

    The initial value for the coverage information collection count is 0.

    [Figure] Updating

    The coverage information collection count is incremented by one each time the debugger's run command is executed.

  • For an asc file

    asc files are not updated.

Main information section (Main Information)

Section title line indicating display of coverage information (C0 and C1 information).

Line number (Line)

The line numbers begin with 1.

A line number exceeding 9999 is displayed as 9999+

Additional information (Info)

This is the header for C0 and C1 information. The coverage information is displayed in units of lines. If a command spans multiple lines, the C0 and C1 information is displayed on the lines containing the command name.

If the numbers of C0 and C1 information items are both 32 or fewer, the coverage information can be recorded and this item is blank. The character strings that are displayed when the coverage information cannot be recorded are explained below:

overC0: The number of C0 information items exceeds 32.

overC1: The number of C1 information items exceeds 32.

over: The numbers of C0 and C1 information items both exceed 32.

C0 information (C0)

Displays the C0 information:

@: Command was executed.

-: Command was not executed.

If a line contains multiple commands, the C0 information for a maximum of the first four commands is displayed as four characters.

C1 information (C1)

Displays the C1 information:

@: Execution path was executed.

-: Execution path was not executed.

If a line contains multiple execution paths, the C1 information for a maximum of the first four execution paths is displayed as four characters.

Job definition script (<Shellscript Image>)

Displays the contents of the job definition script in units of lines. If a range is specified, only the lines in the specified range are displayed.

Totals section (Total Information)

Section title line indicating display of totals of the C0 and C1 information. If a range is specified, the Total Information line and lines subsequent to it are not displayed. If the count exceeds 99,999,999, 99999999+ is displayed.

Totals subject to C0 and C1 targets (Target Total)

<C0> displays the total number of target commands, and <C1> displays the total number of execution paths.

<C0>

Includes the total number of commands subject to C0 in the job definition script. All target commands are counted even if there is a line that contains more than 32 commands subject to C0.

<C1>

Includes the total number of execution paths subject to C1 in the job definition script. All execution paths are counted even if there is a line that contains more than 32 execution paths subject to C1.

Totals subject to C0 and C1 that were executed (Executed Total)

<C0> displays the total number of commands executed, and <C1> displays the total number of execution paths executed.

<C0>

Execution is recorded as coverage information for a maximum of the first 32 commands subject to C0 in each line. Of these 32 commands, the commands that were executed are counted.

<C1>

Execution is recorded as coverage information for a maximum of the first 32 execution paths subject to C1 in each line. Of these 32 execution paths, the execution paths that were executed are counted.

Totals subject to C0 and C1 that were not executed (Unexecuted Total)

<C0> displays the total number commands that were not executed, and <C1> displays the total number of execution paths that were not executed.

<C0>

This is the total number subject to C0 (Target Total) - total number subject to C0 that were executed (Executed Total).

<C1>

This is the total number subject to C1 (Target Total) - total number subject to C1 that were executed (Executed Total).

Execution percentage rate (Coverage Rate)

Displays the execution percentages of C0 and C1 (%). The values are rounded off to the first decimal place.

<C0>

This is the total subject to C0 that were executed (Executed Total)/total subject to C0 (Target Total).

If there was a line containing more than 32 commands subject to C0, this value would be less than 100%, even if all commands were executed.

<C1>

This is the total subject to C1 that were executed (Executed Total)/total subject to C1 (Target Total).

If there was a line containing more than 32 execution paths subject to C1, this value would be less than 100%, even if all execution paths were executed.

The following subsections presents example coverage information displays. One is for when a maximum of one C0 and one C1 information item is displayed per line. The second display is for when a maximum of four information items are displayed per line.

(a) Example display of commands for which coverage information is displayed (maximum of one C0 and one C1 information item displayed per line)

In this example, a single @ and a single - in Main Information indicate that C0 and C1 were acquired.

                    * Advanced Shell Coverage Information *
 
                                                            2013-12-06 12:22:50
****    Header Information    **************************************************
Shellscript Name     : /home/testuser/sample
Asc version          : 1.0
Coverage Start Time  : 2013-12-06 12:21:38
Coverage End Time    : 2013-12-06 12:21:39
Test Count           :    1
 
****    Main Information      **************************************************
Line   Info   C0   C1   <Shellscript Image>
    1
    2         @         echo 1
    3
    4         @    @    if true
    5                   then
    6         @           echo 2
    7              -    fi
    8
    9         @         echo 3
   10
   11         @    -    if false
   12                   then
   13         -           echo 4
   14              @    fi
   15
   16         @         echo 5
   17
   18         @    @    if true
   19                   then
   20         @           echo 6
   21              -    else
   22         -           echo 7
   23                   fi
   24
   25         @         echo 8
   26
   27         @    -    if false
   28                   then
   29         -           echo 9
   30              @    else
   31         @           echo 10
   32                   fi
   33
   34         @         echo 11
   35
   36
 
****    Total Information     **************************************************
                         <C0>      <C1>
  Target     Total         15         8
  Executed   Total         12         4
  Unexecuted Total          3         4
--------------------------------------------------------------------------------
                         <C0>      <C1>
  Coverage   Rate        80.0 %    50.0 %

(b) Example display of commands for which coverage information is displayed (maximum of four C0 and C1 information items displayed per line)

In this example, lines 13 and 37 in Main Information indicate that multiple C0 and C1 information items were acquired.

  • Line 13 displays the contents of lines 3 through 7.

    @@@@ in the C0 column indicates that the commands echo 1, echo 2, echo 3, and echo 4 were executed in this order.

    @@@@ in the C0 column does not indicate whether command echo 5 was executed.

  • Line 37 displays the contents of lines 20 through 31.

    • Each character in @@-- in the C0 column corresponds to a command from the top.

      The first character @ indicates that the command true was executed.

      The second character @ indicates that the command echo 1 was executed.

      The third character - indicates that the command true that follows the first elif was not executed.

      The fourth character - indicates that the command echo 2 was not executed.

      The characters @@-- in the C0 column show only whether the first four commands above were executed; whether the commands starting with true that follows the second elif were executed is not indicated.

    • Each character in @--- in the C1 column corresponds to each command from the beginning.

      The first character @ indicates that the execution path of the first then of if was executed.

      The second character - indicates that the execution path of then for the first elif was not executed.

      The third character - indicates that the execution path of then for the second elif was not executed.

      The fourth character - indicates that the execution path of else was not executed.

  • Line 73 displays the contents of lines 43 through 67.

    The meaning of each character in @@-- in the C0 column and in @--- in the C1 column is the same as for line 37.

    @--- in the C1 column does not indicate whether the execution paths that follow the execution path of then for if (the fifth execution path from the top) were executed.

                    * Advanced Shell Coverage Information *
 
                                                            2013-12-06 12:24:27
****    Header Information    **************************************************
Shellscript Name     : /home/testuser/sample1.ash
Asc version          : 1.0
Coverage Start Time  : 2013-12-06 12:21:49
Coverage End Time    : 2013-12-06 12:21:50
Test Count           :    1
 
****    Main Information      **************************************************
Line   Info   C0   C1   <Shellscript Image>
    1
    2
    3         @         echo 1
    4         @         echo 2
    5         @         echo 3
    6         @         echo 4
    7         @         echo 5
    8
    9
   10
   11
   12
   13         @@@@      echo 1;echo 2;echo 3;echo 4;echo 5
   14
   15
   16
   17
   18
   19
   20         @    @    if true
   21                   then
   22         @           echo 1
   23         -    -    elif true
   24                   then
   25         -           echo 2
   26         -    -    elif true
   27                   then
   28         -           echo 3
   29              -    else
   30         -           echo 4
   31                   fi
   32
   33
   34
   35
   36
   37         @@-- @--- if true ;then echo 1 ;elif true ;then echo 2 ;elif true ;then echo 3 ;else echo 4 ;fi
   38
   39
   40
   41
   42
   43         @    @    if true
   44                   then
   45         @           echo 1
   46         -    -    elif true
   47                   then
   48         -           echo 2
   49         -    -    elif true
   50                   then
   51         -           echo 3
   52              -    else
   53         -           echo 4
   54                   fi
   55
   56         @    @    if true
   57                   then
   58         @           echo 5
   59         -    -    elif true
   60                   then
   61         -           echo 6
   62         -    -    elif true
   63                   then
   64         -           echo 7
   65              -    else
   66         -           echo 8
   67                   fi
   68
   69
   70
   71
   72
   73         @@-- @--- if true ;then echo 1 ;elif true ;then echo 2 ;elif true ;then echo 3 ;else echo 4 ;fi; if true ;then echo 5 ;elif true ;then echo 6 ;elif true ;then echo 7 ;else echo 8 ;fi
   74
 
****    Total Information     **************************************************
                         <C0>      <C1>
  Target     Total         52        24
  Executed   Total         22         6
  Unexecuted Total         30        18
--------------------------------------------------------------------------------
                         <C0>      <C1>
  Coverage   Rate        42.3 %    25.0 %

(3) How to display C0 and C1 information

The target subject to collection of coverage information varies depending on how script control statements are executed in a job definition script. When coverage information is displayed, an at mark (@) is displayed for a target that was executed, and a hyphen (-) is displayed for a target that was not executed.

(a) if statements

  • When there is no else

    • If a path of then was executed, the following information is displayed:

    C0   C1   Job definition script
         @    if          <--  C1 is acquired
    @           true      <--  C0 is acquired
              then
    @           cmd2       <--  C0 is acquired
    @           cmd3       <--  C0 is acquired
         -    fi           <--  C1 is not acquired
    • If a path of then was not executed, the following information is displayed:

    C0   C1  Job definition script
         -    if           <--  C1 is not acquired
    @           false      <--  C0 is acquired
              then
    -           cmd2       <--  C0 is not acquired
    -           cmd3       <--  C0 is not acquired
         @    fi           <--  C1 is acquired
    • If a path of then and a path that is not then were both executed, the following information is displayed:

    C0   C1  Job definition script
         @    if           <--  C1 is acquired
    @           false      <-  C0 is acquired
              then
    @           cmd2       <--  C0 is acquired
    @           cmd3       <--  C0 is acquired
         @    fi           <--  C1 is acquired
  • When there is else

    • If then was executed, the following information is displayed:

    C0   C1  Job definition script
         @    if           <--  C1 is acquired
    @           true       <--  C0 is acquired
              then
    @           cmd2       <--  C0 is acquired
         -    else         <--  C1 is not acquired
    -           cmd3       <--  C0 is not acquired
              fi           <--  None
    • If else was executed, the following information is displayed:

    C0   C1  Job definition script
         -    if           <--  C1 is not acquired
    @           false      <--  C0 is acquired
              then
    -           cmd2       <--  C0 is not acquired
         @    else         <--  C1 is acquired
    @           cmd3       <--  C0 is acquired
              fi           <--  None
    • If then and else were both executed, the following information is displayed:

    C0   C1  Job definition script
         @    if           <--  C1 is acquired
    @           false      <--  C0 is acquired
              then
    @           cmd2       <--  C0 is acquired
         @    else         <--  C1 is acquired
    @           cmd3       <--  C0 is acquired
              fi           <--  None

(b) for statements

  • If a loop was executed, the following information is displayed:

    C0   C1  Job definition script
         @    for          <--  C1 is acquired
              do
    @           cmd1       <--  C0 is acquired
         -    done         <--  C1 is not acquired
  • If a loop was not executed, the following information is displayed:

    C0   C1  Job definition script
         -    for          <--  C1 is not acquired
              do
    -           cmd1       <--  C0 is not acquired
         @    done         <--  C1 is acquired
  • If execution involved executing a loop and then skipping a loop, the following information is displayed:

    C0   C1  Job definition script
         @    for          <--  C1 is acquired
              do
    @           cmd1       <--  C0 is acquired
         @    done         <--  C1 is acquired

(c) while and until statements

This subsection describes how while statements are displayed. until statements are displayed in the same manner.

  • If a loop was executed, the following information is displayed:

    C0   C1  Job definition script
         @    while        <--  C1 is acquired
              do
    @           cmd1       <--  C0 is acquired
         -    done         <--  C1 is not acquired
  • If a loop was not executed, the following information is displayed:

    C0   C1  Job definition script
         -    while        <--  C1 is not acquired
              do
    -           cmd1       <--  C0 is not acquired
         @    done         <--  C1 is acquired
  • If execution involved executing a loop and then skipping a loop, the following information is displayed:

    C0   C1  Job definition script
         @    while        <--  C1 is acquired
              do
    @           cmd1       <--  C0 is acquired
         @    done         <--  C1 is acquired

(d) case statements

Whether an * pattern is used determines how the C1 information is displayed. An * pattern means that none of the patterns was a match in the case statement.

  • If there is an * pattern

    The C1 information is displayed for esac.

  • If there is no * pattern

    The C1 information is displayed for esac.

  • Display method when there is an * pattern

    • If case 1 was executed, the following information is displayed:

    C0   C1  Job definition script
              case $A in
         @      1)             <--  C1 is acquired
    @              echo "abc"  <--  C0 is acquired
                   ;;
         -      *)             <--  C1 is not acquired
    -              echo "efg"  <--  C0 is not acquired
                   ;;
              esac             <--  None
    • If an * pattern was executed, the following information is displayed:

    C0   C1  Job definition script
              case $A in
         -      1)             <--  C1 is not acquired
                   echo "abc"
                   ;;
         @      *)             <--  C1 is acquired
    @              echo "efg"  <--  C0 is acquired
                   ;;
              esac             <--  None
    • If case 1 and an * pattern were both executed, the following information is displayed:

    C0   C1  Job definition script
              case $A in
         @      1)             <--  C1 is acquired
    @              echo "abc"  <--  C0 is acquired
                   ;;
         -      *)             <--  C1 is not acquired
    -              echo "efg"  <--  C0 is not acquired
                   ;;
              esac             <--  None
  • Display method when there is no * pattern

    • If case 1 was executed, the following information is displayed:

    C0   C1  Job definition script
              case $A in
         @      1)             <--  C1 is acquired
    @              echo "abc"  <--  C0 is acquired
                   ;;
         -      2)             <--  C1 is not acquired
    -              echo "efg"  <--  C0 is not acquired
                   ;;
         -    esac             <--  C1 is not acquired
    • If case 2 was executed, the following information is displayed:

    C0   C1  Job definition script
              case $A in
         -      1)             <--  C1 is not acquired
    -              echo "abc"  <--  C0 is not acquired
                   ;;
         @      2)             <--  C1 is acquired
    @              echo "efg"  <--  C0 is acquired
                   ;;
         -    esac             <--  C1 is not acquired
    • If an * pattern was executed, the following information is displayed:

    C0   C1  Job definition script
    @         case $A in       <--  C0 is acquired
         -      1)             <--  C1 is not acquired
    -              echo "abc"  <--  C0 is not acquired
                   ;;
         -      2)             <--  C1 is not acquired
    -              echo "efg"  <--  C0 is not acquired
                   ;;
         @    esac             <--  C1 is acquired

(e) #-adsh_step_start command

Specification of the argument shown below in the #-adsh_step_start command sets whether a job step's execution is to be determined by the preceding job step and the status of the extended script command in the job definition script.

[ -run {normal | abnormal | always} ]

The following information is displayed in the C1 information to indicate whether a job step was executed:

  • --: Execution did not reach the #-adsh_step_start command.

  • N-: The preceding job step or job definition script is normal.

  • -A: The preceding job step or job definition script is erroneous.

  • NA: Cases N- and -A were both executed.

(f) #-adsh_step_error command

If an error occurs in a job step, the job definition script following the #-adsh_step_error command is executed. To indicate whether the error was handled, the following information is displayed in the C1 information.

  • --: Execution did not reach the step containing the #-adsh_step_error command.

  • N-: No error handling procedure executed because no error occurred in a job step.

  • -E: An error handling procedure was executed because an error occurred in a job step.

  • NE: Cases N- and -E were both executed.

(g) Functions

The following shows an example of function execution:

C0   C1   Job definition script
           funcAAA(){                 --> 1.
@              echo "start funcAAA"   --> 2.
     @         if true                --> 2.
               then                   --> 2.
@                echo true            --> 2.
     -         else                   --> 2.
-                echo false           --> 2.
               fi                     --> 2.
           }
             :
@          funcAAA                    --> 3.
  1. When a function is executed, neither C0 nor C1 information is displayed at the location where the function is defined.

  2. In the body of the function, C0 and C1 information is displayed for the commands and execution paths that executed

  3. When a function has executed, the C0 information is displayed at the location where the function was called.

(h) (cmd1; cmd 2)

Commands enclosed in parentheses are executed as a separate process. In this case, coverage information is not collected either for the entire command group or for the individual commands in the command group.

(i) {cmd1; cmd2}

Commands enclosed in curly brackets are executed in the same process as the adshexec command. In this case, coverage information is collected for each command in the command group.

(j) cmd1 &

A separate process is generated, and the command is executed in the background in parallel with execution of the job definition script by the adshexec command. No coverage information is collected for job definition scripts that are executed in the background.

(k) trap actions

No coverage information is collected for trap actions.

  • Example

    trap "date; echo xxx" INT

(l) Command substitution

No coverage information is collected for a command or a script control statement that is executed by command substitution.

  • Example

    ls `which adshexec`

(m) Arguments of the time command

No coverage information is collected for a command that is executed as an argument of the time command.

  • Example

    time adshexec script1

(n) Arguments of the eval command

No coverage information is collected for a command that is executed as an argument of the eval command.

  • Example

    eval ls dir1

(o) Pipe function

No coverage information is collected for a command that is executed by using the pipe function.

  • Example

    ls | cat

(p) External scripts

Coverage information is not collected for called external scripts. Coverage information is collected for a process that calls an external script. An external script call is subject to collection of C0 information, but is not subject to collection of C1 information.

(4) Displaying coverage information collected in memory (UNIX only)

If you have used the info coverage command for debugging, you can display coverage information collected in memory.

The coverage information to be displayed depends on the accumulation type (initial or continued accumulation). For the initial accumulation, the coverage information up to the breakpoint is displayed. For a continued accumulation, the accumulated coverage information plus the coverage information up to the breakpoint is displayed. If accumulation is not specified, the coverage information up to the breakpoint is displayed in the same manner as for initial accumulation.

The types and format of the information that is displayed are the same as when the adshcvshow command is used to display coverage information.

(5) Case where the C1 execution percentage rate is not 100%

If the #-adsh_step_start command is used and no job step or command precedes the job step of #-adsh_step_start, the C1 execution percentage rate will never be 100%, even if all the execution paths are executed. #-adsh_step_start collects C1 information in the cases described below. However, if no job step or command precedes the job step of #-adsh_step_start, C1 information cannot be collected for case 2 below:

  1. All the preceding job steps and commands terminated normally.

  2. At least one of the preceding job steps or commands did not terminate normally.

In this case, you can enable the fault injection mode during debugging to simulate errors at the corresponding locations. This method enables you to collect CI information and improve the CI execution percentage rate to 100%. The following explains how to simulate errors.