* debian/changelog: Add entry for new release.
[dejagnu.git] / doc / overview / writing.html
blob17e09ed5f4120ceaca4d0a341802ab501d376a87
1 <HTML
2 ><HEAD
3 ><TITLE
4 >Writing A Test Case</TITLE
5 ><META
6 NAME="GENERATOR"
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.44"><LINK
8 REL="HOME"
9 TITLE="DejaGnu"
10 HREF="book1.html"><LINK
11 REL="UP"
12 TITLE="Extending DejaGnu"
13 HREF="extending.html"><LINK
14 REL="PREVIOUS"
15 TITLE="Board Config File Values"
16 HREF="boarddefs.html"><LINK
17 REL="NEXT"
18 TITLE="Debugging A Test Case"
19 HREF="debugging.html"></HEAD
20 ><BODY
21 ><DIV
22 CLASS="NAVHEADER"
23 ><TABLE
24 WIDTH="100%"
25 BORDER="0"
26 CELLPADDING="0"
27 CELLSPACING="0"
28 ><TR
29 ><TH
30 COLSPAN="3"
31 ALIGN="center"
32 >DejaGnu: The GNU Testing Framework</TH
33 ></TR
34 ><TR
35 ><TD
36 WIDTH="10%"
37 ALIGN="left"
38 VALIGN="bottom"
39 ><A
40 HREF="boarddefs.html"
41 >Prev</A
42 ></TD
43 ><TD
44 WIDTH="80%"
45 ALIGN="center"
46 VALIGN="bottom"
47 >Chapter 4. Extending DejaGnu</TD
48 ><TD
49 WIDTH="10%"
50 ALIGN="right"
51 VALIGN="bottom"
52 ><A
53 HREF="debugging.html"
54 >Next</A
55 ></TD
56 ></TR
57 ></TABLE
58 ><HR
59 ALIGN="LEFT"
60 WIDTH="100%"></DIV
61 ><DIV
62 CLASS="SECT1"
63 ><H1
64 CLASS="SECT1"
65 ><A
66 NAME="WRITING"
67 >Writing A Test Case</A
68 ></H1
69 ><P
70 >The easiest way to prepare a new test case is to base it
71 on an existing one for a similar situation. There are two major
72 categories of tests: batch or interactive. Batch oriented tests
73 are usually easier to write.</P
74 ><P
75 >The GCC tests are a good example of batch oriented tests.
76 All GCC tests consist primarily of a call to a single common
77 procedure, Since all the tests either have no output, or only
78 have a few warning messages when successfully compiled. Any
79 non-warning output is a test failure. All the C code needed is
80 kept in the test directory. The test driver, written in Tcl,
81 need only get a listing of all the C files in the directory, and
82 compile them all using a generic procedure. This procedure and a
83 few others supporting for these tests are kept in the library
84 module <TT
85 CLASS="FILENAME"
86 >lib/c-torture.exp</TT
87 > in the GCC test
88 suite. Most tests of this kind use very few
89 <SPAN
90 CLASS="PRODUCTNAME"
91 >expect</SPAN
92 > features, and are coded almost
93 purely in Tcl.</P
94 ><P
95 >Writing the complete suite of C tests, then, consisted of
96 these steps:</P
97 ><P
98 ></P
99 ><UL
100 ><LI
101 STYLE="list-style-type: disc"
103 >Copying all the C code into the test directory.
104 These tests were based on the C-torture test created by Torbjorn
105 Granlund (on behalf of the Free Software Foundation) for GCC
106 development.</P
107 ></LI
108 ><LI
109 STYLE="list-style-type: disc"
111 >Writing (and debugging) the generic Tcl procedures for
112 compilation.</P
113 ></LI
114 ><LI
115 STYLE="list-style-type: disc"
117 >Writing the simple test driver: its main task is to
118 search the directory (using the Tcl procedure
120 CLASS="EMPHASIS"
121 >glob</I
122 > for filename expansion with wildcards)
123 and call a Tcl procedure with each filename. It also checks for
124 a few errors from the testing procedure.</P
125 ></LI
126 ></UL
128 >Testing interactive programs is intrinsically more
129 complex. Tests for most interactive programs require some trial
130 and error before they are complete.</P
132 >However, some interactive programs can be tested in a
133 simple fashion reminiscent of batch tests. For example, prior
134 to the creation of DejaGnu, the GDB distribution already
135 included a wide-ranging testing procedure. This procedure was
136 very robust, and had already undergone much more debugging and
137 error checking than many recent DejaGnu test cases.
138 Accordingly, the best approach was simply to encapsulate the
139 existing GDB tests, for reporting purposes. Thereafter, new GDB
140 tests built up a family of Tcl procedures specialized for GDB
141 testing.</P
142 ></DIV
143 ><DIV
144 CLASS="NAVFOOTER"
145 ><HR
146 ALIGN="LEFT"
147 WIDTH="100%"><TABLE
148 WIDTH="100%"
149 BORDER="0"
150 CELLPADDING="0"
151 CELLSPACING="0"
152 ><TR
153 ><TD
154 WIDTH="33%"
155 ALIGN="left"
156 VALIGN="top"
158 HREF="boarddefs.html"
159 >Prev</A
160 ></TD
161 ><TD
162 WIDTH="34%"
163 ALIGN="center"
164 VALIGN="top"
166 HREF="book1.html"
167 >Home</A
168 ></TD
169 ><TD
170 WIDTH="33%"
171 ALIGN="right"
172 VALIGN="top"
174 HREF="debugging.html"
175 >Next</A
176 ></TD
177 ></TR
178 ><TR
179 ><TD
180 WIDTH="33%"
181 ALIGN="left"
182 VALIGN="top"
183 >Board Config File Values</TD
184 ><TD
185 WIDTH="34%"
186 ALIGN="center"
187 VALIGN="top"
189 HREF="extending.html"
190 >Up</A
191 ></TD
192 ><TD
193 WIDTH="33%"
194 ALIGN="right"
195 VALIGN="top"
196 >Debugging A Test Case</TD
197 ></TR
198 ></TABLE
199 ></DIV
200 ></BODY
201 ></HTML