Sophie

Sophie

distrib > Mandriva > 2006.0 > i586 > by-pkgid > 9c646fa862f3ddbc469622b1cf108654 > files > 30

check-0.9.2-1mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML
><HEAD
><TITLE
>Test Logging
   </TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Check Tutorial"
HREF="index.html"><LINK
REL="UP"
TITLE="Advanced Features
  "
HREF="c163.html"><LINK
REL="PREVIOUS"
TITLE="Test timeouts
   "
HREF="x226.html"><LINK
REL="NEXT"
TITLE="Conclusion
   "
HREF="x246.html"></HEAD
><BODY
CLASS="SECTION"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Check Tutorial</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x226.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 4. Advanced Features</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x246.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECTION"
><H1
CLASS="SECTION"
><A
NAME="AEN232"
>4.7. Test Logging<A
NAME="TESTLOGGING"
></A
></A
></H1
><P
>Check supports operation to log the results of a test run. To use test logging, use the srunner_set_log function with the name of the log file you wish to create:
   </P
><PRE
CLASS="PROGRAMLISTING"
>SRunner *sr;
sr = srunner_create(make_s1_suite());
srunner_add_suite(sr, make_s2_suite());
srunner_set_log(sr, "test.log");
srunner_run_all(sr, CRNORMAL);</PRE
><P
>Check will write the results of the run to test.log. The printmode argument to srunner_run_all does not apply to test logging; the log will contain a result entry, organized by suite, for every test run. Here is an example of test log output:
   </P
><PRE
CLASS="PROGRAMLISTING"
>Running suite S1 
ex_log_output.c:8:P:Core:test_pass: Test passed
ex_log_output.c:14:F:Core:test_fail: Failure
ex_log_output.c:18:E:Core:test_exit: (after this point) Early exit with return value 1
Running suite S2 
ex_log_output.c:26:P:Core:test_pass2: Test passed
Results for all suites run:
50%: Checks: 4, Failures: 1, Errors: 1</PRE
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN239"
>4.7.1. XML logging</A
></H2
><P
>The log can also be written in XML. The following functions define the interface for XML logs:
   </P
><PRE
CLASS="PROGRAMLISTING"
>void srunner_set_xml(SRunner *sr, const char *fname);
int srunner_has_xml(SRunner *sr);
const char *srunner_xml_fname(SRunner *sr);</PRE
><P
>The only thing you need to do to get XML output is call <CODE
CLASS="FUNCTION"
>srunner_set_xml()</CODE
> before the tests are run. Here is an example of the same log output as above but in XML:
   </P
><PRE
CLASS="PROGRAMLISTING"
>&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;testsuites xmlns=&quot;http://check.sourceforge.net/ns&quot;&gt;
  &lt;datetime&gt;2004-08-20 12:53:32&lt;/datetime&gt;
  &lt;suite&gt;
    &lt;title&gt;S1&lt;/title&gt;
    &lt;test result=&quot;success&quot;&gt;
      &lt;path&gt;.&lt;/path&gt;
      &lt;fn&gt;ex_xml_output.c:8&lt;/fn&gt;
      &lt;id&gt;test_pass&lt;/id&gt;
      &lt;description&gt;Core&lt;/description&gt;
      &lt;message&gt;Passed&lt;/message&gt;
    &lt;/test&gt;
    &lt;test result=&quot;failure&quot;&gt;
      &lt;path&gt;.&lt;/path&gt;
      &lt;fn&gt;ex_xml_output.c:14&lt;/fn&gt;
      &lt;id&gt;test_fail&lt;/id&gt;
      &lt;description&gt;Core&lt;/description&gt;
      &lt;message&gt;Failure&lt;/message&gt;
    &lt;/test&gt;
    &lt;test result=&quot;error&quot;&gt;
      &lt;path&gt;.&lt;/path&gt;
      &lt;fn&gt;ex_xml_output.c:18&lt;/fn&gt;
      &lt;id&gt;test_exit&lt;/id&gt;
      &lt;description&gt;Core&lt;/description&gt;
      &lt;message&gt;Early exit with return value 1&lt;/message&gt;
    &lt;/test&gt;
  &lt;/suite&gt;
  &lt;suite&gt;
    &lt;title&gt;S2&lt;/title&gt;
    &lt;test result=&quot;success&quot;&gt;
      &lt;path&gt;.&lt;/path&gt;
      &lt;fn&gt;ex_xml_output.c:26&lt;/fn&gt;
      &lt;id&gt;test_pass2&lt;/id&gt;
      &lt;description&gt;Core&lt;/description&gt;
      &lt;message&gt;Passed&lt;/message&gt;
    &lt;/test&gt;
  &lt;/suite&gt;
  &lt;duration&gt;0.304875&lt;/duration&gt;
&lt;/testsuites&gt;</PRE
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="x226.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x246.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Test timeouts</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="c163.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Conclusion</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>