debugging.html   [plain text]


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<HTML
><HEAD
><TITLE
>Debugging A Test Case</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
"><LINK
REL="HOME"
TITLE="DejaGnu"
HREF="book1.html"><LINK
REL="UP"
TITLE="Extending DejaGnu"
HREF="extending.html"><LINK
REL="PREVIOUS"
TITLE="Writing A Test Case"
HREF="writing.html"><LINK
REL="NEXT"
TITLE="Adding A Test Case To A Test Suite."
HREF="adding.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>DejaGnu: The GNU Testing Framework</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="writing.html"
>&#60;&#60;&#60; Previous</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Extending DejaGnu</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="adding.html"
>Next &#62;&#62;&#62;</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="DEBUGGING"
>Debugging A Test Case</A
></H1
><P
>These are the kinds of debugging information available
      from DejaGnu:</P
><P
></P
><UL
><LI
STYLE="list-style-type: disc"
><P
>Output controlled by test scripts themselves,
      explicitly allowed for by the test author.  This kind of
      debugging output appears in the detailed output recorded in the
      DejaGnu log file.  To do the same for new tests, use the
      <B
CLASS="COMMAND"
>verbose</B
> procedure (which in turn uses the
      variable also called <I
CLASS="EMPHASIS"
>verbose</I
>) to control
      how much output to generate.  This will make it easier for other
      people running the test to debug it if necessary.  Whenever
      possible, if <I
CLASS="EMPHASIS"
>$verbose</I
> is
      <I
CLASS="EMPHASIS"
>0</I
>, there should be no output other than the
      output from <I
CLASS="EMPHASIS"
>pass</I
>,
      <I
CLASS="EMPHASIS"
>fail</I
>, <I
CLASS="EMPHASIS"
>error</I
>, and
      <I
CLASS="EMPHASIS"
>warning</I
>.  Then, to whatever extent is
      appropriate for the particular test, allow successively higher
      values of <I
CLASS="EMPHASIS"
>$verbose</I
> to generate more
      information.  Be kind to other programmers who use your tests:
      provide for a lot of debugging information.</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>Output from the internal debugging functions of
      Tcl and <SPAN
CLASS="PRODUCTNAME"
>Expect</SPAN
>. There is a command
      line options for each; both forms of debugging output are
      recorded in the file <TT
CLASS="FILENAME"
>dbg.log</TT
> in the current
      directory.</P
><P
>Use <TT
CLASS="OPTION"
>--debug</TT
> for information from the
       expect level; it generates displays of the expect attempts to
       match the tool output with the patterns specified. This output
       can be very helpful while developing test scripts, since it
       shows precisely the characters received.  Iterating between the
       latest attempt at a new test script and the corresponding
       <TT
CLASS="FILENAME"
>dbg.log</TT
> can allow you to create the final
       patterns by ``cut and paste''.  This is sometimes the best way
       to write a test case.</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>Use <TT
CLASS="OPTION"
>--strace</TT
> to see more
       detail at the Tcl level; this shows how Tcl procedure
       definitions expand, as they execute. The associated number
       controls the depth of definitions expanded.</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>Finally, if the value of
       <I
CLASS="EMPHASIS"
>verbose</I
> is 3 or greater,DejaGnu turns on
       the expect command <B
CLASS="COMMAND"
>log_user</B
>.  This command
       prints all expect actions to the expect standard output, to the
       detailed log file, and (if <TT
CLASS="OPTION"
>--debug</TT
> is on) to
       <TT
CLASS="FILENAME"
>dbg.log</TT
>.</P
></LI
></UL
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="writing.html"
>&#60;&#60;&#60; Previous</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="book1.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="adding.html"
>Next &#62;&#62;&#62;</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Writing A Test Case</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="extending.html"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Adding A Test Case To A Test Suite.</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>