4 >Writing A Test Case
</TITLE
7 CONTENT=
"Modular DocBook HTML Stylesheet Version 1.44"><LINK
10 HREF=
"book1.html"><LINK
12 TITLE=
"Extending DejaGnu"
13 HREF=
"extending.html"><LINK
15 TITLE=
"Board Config File Values"
16 HREF=
"boarddefs.html"><LINK
18 TITLE=
"Debugging A Test Case"
19 HREF=
"debugging.html"></HEAD
32 >DejaGnu: The GNU Testing Framework
</TH
47 >Chapter
4. Extending DejaGnu
</TD
67 >Writing A Test Case
</A
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
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
86 >lib/c-torture.exp
</TT
88 suite. Most tests of this kind use very few
92 > features, and are coded almost
95 >Writing the complete suite of C tests, then, consisted of
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
109 STYLE=
"list-style-type: disc"
111 >Writing (and debugging) the generic Tcl procedures for
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
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
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
158 HREF=
"boarddefs.html"
174 HREF=
"debugging.html"
183 >Board Config File Values
</TD
189 HREF=
"extending.html"
196 >Debugging A Test Case
</TD