<HTML
><HEAD
><TITLE
> Testing Tools
</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.49"><LINK
REL="HOME"
TITLE=" Linux Test Project HOWTO
"
HREF="t1.html"><LINK
REL="PREVIOUS"
TITLE=" Writing Tests
"
HREF="x50.html"><LINK
REL="NEXT"
TITLE=" To Do
"
HREF="x100.html"></HEAD
><BODY
CLASS="SECT1"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Linux Test Project HOWTO</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x50.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x100.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="AEN59"
>Testing Tools</A
></H1
><P
> The Linux Test Project has not yet decided on a "final" test harness. We have provided a simple solution with pan to make due until a complete solution has been found/created that compliments the Linux kernel development process. Several people have said we should use such and such a test harness. Until we find we need a large complex test harness, we will apply the KISS concept.
</P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN62"
>Pan</A
></H2
><P
> pan is a simple test driver with the ability to keep track of orphaned processes and capture test output. It works by reading a list of test tags and command lines and runs them. By default pan will select a command randomly from the list of test tags, wait for it to finish. Through command line options you can run through the entire list sequentially, run n tests, keep n test running at all times, and buffer test output. Pan can be nested to create very complex test environments.
</P
><P
> Pan uses an <I
CLASS="EMPHASIS"
>active file</I
>, also called a <I
CLASS="EMPHASIS"
>zoo file</I
> to keep track of which tests are currently running. This file holds the pid, tag, and a portion of the command line. When you start pan it becomes a test tag in itself, thus it requires a name for itself. Pan updates the active file to show which test tags are currently running. When a test tag exits, pan will overwrite the first character with a '#'. The active file can be shared between multiple instances of pan so you know which tests were running when the system crashes by looking at one file.
</P
><P
> A <I
CLASS="EMPHASIS"
>pan file</I
> contains a list of test tags for pan to run. The format of a pan file is as follows:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>testtag testprogram -o one -p two other command line options
# This is a comment. It is a good idea to describe the test
# tags in your pan file. Tests programs can have different
# behaviors depending on the command line options so it is
# helpful to describe what each test tag is meant to verify or # provoke.
# Some more test cases
mm01 mmap001 -m 10000
# 40 Mb mmap() test.
# Creates a 10000 page mmap, touches all of the map, sync's
# it, and munmap()s it.
mm03 mmap001 -i 0 -I 1 -m 100
# repetitive mmapping test.
# Creates a one page map repetitively for one minute.
dup02 dup02
# Negative test for dup(2) with bad fd
kill09 kill09
# Basic test for kill(2)
fs-suite01 pan -e -a fs-suite01.zoo -n fs-suite01 -f runtest/fs
# run the entire set of file system tests
</PRE
></TD
></TR
></TABLE
><P
> The test tags are simple identifiers, no spaces are allowed. The test of the line is the program to run, which is done using execvp(3). Lines starting with '#' are comments and ignored by pan. It is a good practice to include descriptions with your test tags so you can have a reminder what a certain obscure test tag tries to do.
</P
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN72"
>Examples</A
></H3
><P
> The most basic way to run pan is by passing the test program and parameters on the command line. This will run the single program once and wrap the output.
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>$ pan -a ltp.zoo -n tutor sleep 4
<<<test_start>>>
tag=cmdln stime=971450564
cmdline="sleep 4"
contacts=""
analysis=exit
initiation_status="ok"
<<<test_output>>>
<<<execution_status>>>
duration=103341903 termination_type=exited termination_id=0 corefile=no cutime=0 cstime=0
<<<test_end>>>
$ cat ltp.zoo
#9357,tutor,pan/pan -a ltp.zoo -n tutor sleep 4 #9358,cmdln,sleep 4
$
</PRE
></TD
></TR
></TABLE
><DIV
CLASS="SECT4"
><H4
CLASS="SECT4"
><A
NAME="AEN76"
>How it works</A
></H4
><P
> This example shows the two parameters that are always required by pan, the active file and a test tag for pan. The “sleep 4” on the end of the command line is a test program and parameters that pan should run. This test is given the tag “cmdln.” Pan will run one test randomly, which ends up being cmdln since it is the only test that we told pan about.
</P
><P
> In the active file, ltp.zoo, pan writes the pid, test tag, and part of the command line for the currently running tests. The command lines are truncated so each line will fit on an 80 column display. When a test tag finishes, pan will place a '#' at the beginning of the line to mark it as available. Here you can see that cmdln and tutor, the name we gave pan, ran to completion. If the computer hangs, you can read this file to see which test programs were running.
</P
><P
> We have run one test once. Let's do something a little more exciting. Let's run one test several times, at the same time.
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>$ pan -a ltp.zoo -n tutor -x 3 -s 3 -O . sleep 1
<<<test_start>>>
tag=cmdln stime=971465653
cmdline="sleep 1"
contacts=""
analysis=exit
initiation_status="ok"
<<<test_output>>>
<<<execution_status>>>
duration=103326814 termination_type=exited termination_id=0 corefile=no
cutime=1 cstime=0
<<<test_end>>>
<<<test_start>>>
tag=cmdln stime=971465653
cmdline="sleep 1"
contacts=""
analysis=exit
initiation_status="ok"
<<<test_output>>>
<<<execution_status>>>
duration=103326814 termination_type=exited termination_id=0 corefile=no
cutime=0 cstime=1
<<<test_end>>>
<<<test_start>>>
tag=cmdln stime=971465653
cmdline="sleep 1"
contacts=""
analysis=exit
initiation_status="ok"
<<<test_output>>>
<<<execution_status>>>
duration=103326814 termination_type=exited termination_id=0 corefile=no
cutime=0 cstime=0
<<<test_end>>>
</PRE
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="SECT4"
><H4
CLASS="SECT4"
><A
NAME="AEN82"
>How it works</A
></H4
><P
> In this example we run another fake test from the command line, but we run it three times (-s 3) and keep three test tags active at the same time (-x 3). The -O parameter is a directory where temporary files can be created to buffer the output of each test tag. You can see in the output that cmdln ran three times. If the -O option were omitted, your test output would be mixed, making it almost worthless.
</P
><P
>
</P
><P
></P
><UL
><LI
><P
> Using a pan file to run multiple tests
</P
></LI
><LI
><P
> Nesting pan
</P
></LI
></UL
><P
> For more information on pan see the man page doc/man1/pan.1.
</P
></DIV
></DIV
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN92"
>Scanner</A
></H2
><P
> scanner is a results analysis tool that understands the <I
CLASS="EMPHASIS"
>rts</I
> style output which pan generates by default. It will produce a table summarizing which tests passed and which failed.
</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN96"
>The Quick-hitter Package</A
></H2
><P
> Many of the tests released use the Quick-hitter test package to perform tasks like create and move to a temporary directory, handle some common command line parameters, loop, run in parallel, handle signals, and clean up.
</P
><P
> There is an example test case, doc/examples/quickhit.c, which shows how the quick-hitter package can be used. The file is meant to be a supplement to the documentation, not a working test case. Use any of the tests in tests/ as a template.
</P
></DIV
></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="x50.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="t1.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x100.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Writing Tests</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
> </TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>To Do</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>