1 |
578 |
markom |
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
1998
|
12 |
|
|
Free Software Foundation, Inc.">
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
16 |
|
|
This file documents the GNU Testing Framework ``DejaGnu''
|
17 |
|
|
|
18 |
|
|
Copyright (C) 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
|
19 |
|
|
|
20 |
|
|
This text may be freely distributed under the terms of the GNU
|
21 |
|
|
General Public License.
|
22 |
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
23 |
|
|
">
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
Copyright 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
|
27 |
|
|
|
28 |
|
|
Permission is granted to make and distribute verbatim copies of
|
29 |
|
|
this manual provided the copyright notice and this permission notice
|
30 |
|
|
are preserved on all copies.
|
31 |
|
|
|
32 |
|
|
Permission is granted to copy and distribute modified versions of this
|
33 |
|
|
manual under the conditions for verbatim copying, provided also that
|
34 |
|
|
the entire resulting derived work is distributed under the terms of a
|
35 |
|
|
permission notice identical to this one.
|
36 |
|
|
|
37 |
|
|
Permission is granted to copy and distribute translations of this manual
|
38 |
|
|
into another language, under the above conditions for modified versions.
|
39 |
|
|
">
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
]>
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
&dj;
|
53 |
|
|
The GNU Testing Framework
|
54 |
|
|
1998 Nov 24
|
55 |
|
|
&version
|
56 |
|
|
for circulation within Cygnus
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
Rob Savoye
|
60 |
|
|
|
61 |
|
|
Free Software Foundation
|
62 |
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
rob@welcomehome.org
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
&dejagnu-copyright;
|
78 |
|
|
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
0.1
|
87 |
|
|
1998-11
|
88 |
|
|
rob@welcomehome.org
|
89 |
|
|
Initial version after conversion to DocBook.
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
Abstract
|
99 |
|
|
|
100 |
|
|
This document attempts to describe the functionality of
|
101 |
|
|
DejaGnu, the GNU Testing Framework. DejaGnu is entirely written in
|
102 |
|
|
Expect, which uses
|
103 |
|
|
Tcl as a command
|
104 |
|
|
language. Expect serves as a very
|
105 |
|
|
programmable shell; you can run any program, as with the usual
|
106 |
|
|
Unix command shells---but once the program is started, your
|
107 |
|
|
test script has fully programmable control of
|
108 |
|
|
its input and output. This does not just apply to the programs
|
109 |
|
|
under test; expect can also run any auxiliary
|
110 |
|
|
program, such as diff or sh,
|
111 |
|
|
with full control over its input and output.
|
112 |
|
|
|
113 |
|
|
DejaGnu itself is merely a framework for creation of a test
|
114 |
|
|
suites. Test suites are distributed separately for each GNU
|
115 |
|
|
tool.
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
Overview
|
121 |
|
|
|
122 |
|
|
|
123 |
|
|
What is &dj; ?
|
124 |
|
|
|
125 |
|
|
DejaGnu is a framework for
|
126 |
|
|
testing other programs. Its purpose is to provide a single
|
127 |
|
|
front end for all tests. Think of it as a custom library of
|
128 |
|
|
Tcl procedures crafted to support writing a test harness. A
|
129 |
|
|
Test Harness is the testing
|
130 |
|
|
infrastructure that is created to support a specific program
|
131 |
|
|
or tool. Each program can have multiple test suites, all
|
132 |
|
|
supported by a single test harness. DejaGnu is written in
|
133 |
|
|
Expect, which in turn uses
|
134 |
|
|
Tcl -- Tool command
|
135 |
|
|
language. There is more information on Tcl at the
|
136 |
|
|
URL="http://www.scriptics.com">Scriptics web site, and the
|
137 |
|
|
Expect web site is at
|
138 |
|
|
URL="http://expect.nist.gov">NIST.
|
139 |
|
|
|
140 |
|
|
DejaGnu offers several advantages for testing:
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
|
144 |
|
|
The flexibility and consistency of the DejaGnu
|
145 |
|
|
framework make it easy to write tests for any program, with
|
146 |
|
|
either batch oriented, or interactive programs.
|
147 |
|
|
|
148 |
|
|
|
149 |
|
|
DejaGnu provides a layer of abstraction which
|
150 |
|
|
allows you to write tests that are portable to any host or
|
151 |
|
|
target where a program must be tested. For instance, a test
|
152 |
|
|
for GDB can run (from any Unix
|
153 |
|
|
based host) on any target architecture that DejaGnu
|
154 |
|
|
supports. Currently DejaGnu runs tests on many single board
|
155 |
|
|
computers, whose operating software ranges from just a boot
|
156 |
|
|
monitor to a full-fledged, Unix-like realtime OS.
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
All tests have the same output format. This
|
160 |
|
|
makes it easy to integrate testing into other software
|
161 |
|
|
development processes. DejaGnu's output is designed to be
|
162 |
|
|
parsed by other filtering script, and it is also human
|
163 |
|
|
readable.
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
Using Tcl and expect, it's easy to create wrappers
|
167 |
|
|
for existing test suites. By incorporating existing tests under
|
168 |
|
|
DejaGnu, it's easier to have a single set of report analyse
|
169 |
|
|
programs..
|
170 |
|
|
|
171 |
|
|
|
172 |
|
|
|
173 |
|
|
|
174 |
|
|
Running tests requires two things: the testing framework, and
|
175 |
|
|
the test suites themselves. Tests are usually written in
|
176 |
|
|
Expect using Tcl, but you can also use a
|
177 |
|
|
Tcl script to run a test suite that is not based on
|
178 |
|
|
Expect.
|
179 |
|
|
(expect script filenames conventionally
|
180 |
|
|
use .exp as a suffix; for example, the main
|
181 |
|
|
implementation of the DejaGnu test driver is in the file
|
182 |
|
|
runtest.exp.)
|
183 |
|
|
|
184 |
|
|
Julia Menapace first coined the term ``Deja Gnu'' to describe an
|
185 |
|
|
earlier testing framework at Cygnus Support she had written for
|
186 |
|
|
GDB. When we replaced it with the Expect-based
|
187 |
|
|
framework, it was like DejaGnu all over again... But more importantly, it
|
188 |
|
|
was also named after my daughter,
|
189 |
|
|
URL="mailto:deja@welcomehome.org">Deja Snow Savoye (now 9
|
190 |
|
|
years old in Dec of 1998), who was a toddler during DejaGnu's
|
191 |
|
|
creation.
|
192 |
|
|
|
193 |
|
|
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
What's New In This Release
|
197 |
|
|
|
198 |
|
|
This release has a number of substantial changes over version
|
199 |
|
|
1.3. The most visible change is that the version of Expect and Tcl
|
200 |
|
|
included in the release are up-to-date with the current stable net
|
201 |
|
|
releases. The biggest change is years of modifications to the
|
202 |
|
|
target configuration system, used for cross testing. While this
|
203 |
|
|
greatly improved cross testing, is has made that subsystem very
|
204 |
|
|
complicated. The goal is to have this entirely rewritten using
|
205 |
|
|
iTcl by the next release. Other changes
|
206 |
|
|
are:
|
207 |
|
|
|
208 |
|
|
|
209 |
|
|
More builtin support for building target binaries
|
210 |
|
|
with the correct linker flags. Currently this only works with
|
211 |
|
|
GCC as the cross compiler,
|
212 |
|
|
preferably with a target supported by
|
213 |
|
|
.
|
214 |
|
|
|
215 |
|
|
Lots of little bug fixes from years of heavy
|
216 |
|
|
use at Cygnus Solutions.
|
217 |
|
|
|
218 |
|
|
DejaGnu now uses
|
219 |
|
|
Automake for Makefile
|
220 |
|
|
configuration.
|
221 |
|
|
|
222 |
|
|
Updated documentation, now in SGML
|
223 |
|
|
(using the
|
224 |
|
|
URL="http://nis-www.lanl.gov/~rosalia/mydocs/docbook-intro.html">free
|
225 |
|
|
GNU DocBook tools) format.
|
226 |
|
|
|
227 |
|
|
NT support. There is beta level support for NT
|
228 |
|
|
that is still a work in progress. This requires the
|
229 |
|
|
URL=httpd://sourceware.cygnus.com>Cygwin POSIX system
|
230 |
|
|
for NT.
|
231 |
|
|
|
232 |
|
|
|
233 |
|
|
|
234 |
|
|
|
235 |
|
|
NT Support
|
236 |
|
|
|
237 |
|
|
To use DejaGnu on NT, you need to first install the
|
238 |
|
|
Cygwin
|
239 |
|
|
release. This works as of the B20.1 release. Cygwin is a POSIX
|
240 |
|
|
system for NT. This covers both utility programs, and a libray
|
241 |
|
|
that adds POSIX system calls to NT. Among them is pseudo tty
|
242 |
|
|
support for NT that emulates the POSIX pty standard. The
|
243 |
|
|
latest Cygwin is always available from
|
244 |
|
|
URL="http://sourceware.cygnus.com">this location. This
|
245 |
|
|
works well enough to run "make check" of
|
246 |
|
|
the GNU development tree on NT after a native build. But the
|
247 |
|
|
nature of pty's on NT is still evolving. Your mileage may
|
248 |
|
|
vary...
|
249 |
|
|
|
250 |
|
|
|
251 |
|
|
|
252 |
|
|
|
253 |
|
|
|
254 |
|
|
|
255 |
|
|
Design Goals
|
256 |
|
|
|
257 |
|
|
DejaGnu grew out of the internal needs of Cygnus Solutions. (then
|
258 |
|
|
Cygnus Support). Cygnus maintains and enhances a variety of free programs
|
259 |
|
|
in many different environments, and we needed a testing tool that:
|
260 |
|
|
|
261 |
|
|
|
262 |
|
|
is useful to developers while fixing bugs.
|
263 |
|
|
automates running many tests during a software
|
264 |
|
|
release process.
|
265 |
|
|
is portable among a variety of host
|
266 |
|
|
computers.
|
267 |
|
|
supports cross-development testing.
|
268 |
|
|
permits testing interactive programs, like
|
269 |
|
|
GDB; and
|
270 |
|
|
permits testing batch oriented programs, like
|
271 |
|
|
GCC.
|
272 |
|
|
|
273 |
|
|
|
274 |
|
|
Some of the requirements proved challenging. For example,
|
275 |
|
|
interactive programs do not lend themselves very well to automated testing.
|
276 |
|
|
But all the requirements are important: for instance, it is imperative to
|
277 |
|
|
make sure that GDB works as well when cross-debugging
|
278 |
|
|
as it does in a native configuration.
|
279 |
|
|
|
280 |
|
|
Probably the greatest challenge was testing in a cross-development
|
281 |
|
|
environment (which can be a real nightmare). Most cross-development
|
282 |
|
|
environments are customized by each developer. Even when buying packaged
|
283 |
|
|
boards from vendors there are many differences. The communication
|
284 |
|
|
interfaces vary from a serial line to ethernet. DejaGnu was designed with
|
285 |
|
|
a modular communication setup, so that each kind of communication can be
|
286 |
|
|
added as required, and supported thereafter. Once a communication
|
287 |
|
|
procedure is coded, any test can use it. Currently DejaGnu can use
|
288 |
|
|
rsh, rlogin,
|
289 |
|
|
telnet, tip,
|
290 |
|
|
kermit, and mondfe for remote
|
291 |
|
|
communications.
|
292 |
|
|
|
293 |
|
|
|
294 |
|
|
|
295 |
|
|
|
296 |
|
|
A POSIX conforming test framework
|
297 |
|
|
|
298 |
|
|
DejaGnu conforms to the POSIX 1003.3 standard for test
|
299 |
|
|
frameworks. I was also a member of that committe.
|
300 |
|
|
|
301 |
|
|
The POSIX standard 1003.3 defines what a testing framework needs to
|
302 |
|
|
provide, in order to permit the creation of POSIX conformance test
|
303 |
|
|
suites. This standard is primarily oriented to running POSIX conformance
|
304 |
|
|
tests, but its requirements also support testing of features not related
|
305 |
|
|
to POSIX conformance. POSIX 1003.3 does not specify a particular testing
|
306 |
|
|
framework, but at this time there is only one other POSIX conforming test
|
307 |
|
|
framework: TET. TET was created by Unisoft for a consortium comprised of
|
308 |
|
|
X/Open, Unix International, and the Open Software Foundation.
|
309 |
|
|
|
310 |
|
|
The POSIX documentation refers to assertions.
|
311 |
|
|
An assertion is a description of behavior. For example, if a standard
|
312 |
|
|
says ``The sun shall shine'', a corresponding assertion might be ``The
|
313 |
|
|
sun is shining.'' A test based on this assertion would pass or fail
|
314 |
|
|
depending on whether it is daytime or nighttime. It is important to note
|
315 |
|
|
that the standard being tested is never 1003.3; the standard being tested
|
316 |
|
|
is some other standard, for which the assertions were written.
|
317 |
|
|
|
318 |
|
|
As there is no test suite to test testing frameworks for POSIX
|
319 |
|
|
1003.3 conformance, verifying conformance to this standard is done by
|
320 |
|
|
repeatedly reading the standard and experimenting. One of the main
|
321 |
|
|
things 1003.3 does specify is the set of allowed output messages, and
|
322 |
|
|
their definitions. Four messages are supported for a required feature of
|
323 |
|
|
POSIX conforming systems, and a fifth for a conditional feature. DejaGnu
|
324 |
|
|
supports the use of all five output messages; in this sense a test suite
|
325 |
|
|
that uses exactly these messages can be considered POSIX conforming.
|
326 |
|
|
These definitions specify the output of a test case:
|
327 |
|
|
|
328 |
|
|
|
329 |
|
|
|
330 |
|
|
PASS
|
331 |
|
|
A test has succeeded. That is, it demonstrated that
|
332 |
|
|
the assertion is true.
|
333 |
|
|
|
334 |
|
|
|
335 |
|
|
|
336 |
|
|
XFAIL
|
337 |
|
|
POSIX 1003.3 does not incorporate the notion of
|
338 |
|
|
expected failures, so PASS, instead of
|
339 |
|
|
XPASS, must also be returned for test cases
|
340 |
|
|
which were expected to fail and did not. This means that
|
341 |
|
|
PASS is in some sense more ambiguous than if
|
342 |
|
|
XPASS is also used.
|
343 |
|
|
|
344 |
|
|
|
345 |
|
|
|
346 |
|
|
FAIL
|
347 |
|
|
A test has produced the bug it was intended to
|
348 |
|
|
capture. That is, it has demonstrated that the assertion is false.
|
349 |
|
|
The FAIL message is based on the test case only.
|
350 |
|
|
Other messages are used to indicate a failure of the framework. As
|
351 |
|
|
with PASS, POSIX tests must return
|
352 |
|
|
FAIL rather than XFAIL even
|
353 |
|
|
if a failure was expected.
|
354 |
|
|
|
355 |
|
|
|
356 |
|
|
|
357 |
|
|
UNRESOLVED
|
358 |
|
|
A test produced indeterminate results. Usually, this
|
359 |
|
|
means the test executed in an unexpected fashion; this outcome
|
360 |
|
|
requires that a human being go over results, to determine if the test
|
361 |
|
|
should have passed or failed. This message is also used for any test
|
362 |
|
|
that requires human intervention because it is beyond the abilities
|
363 |
|
|
of the testing framework. Any unresolved test should resolved to
|
364 |
|
|
PASS or FAIL before a test
|
365 |
|
|
run can be considered finished.
|
366 |
|
|
|
367 |
|
|
Note that for POSIX, each assertion must produce a test result
|
368 |
|
|
code. If the test isn't actually run, it must produce
|
369 |
|
|
UNRESOLVED rather than just leaving that test
|
370 |
|
|
out of the output. This means that you have to be careful when
|
371 |
|
|
writing tests, to not carelessly use tcl statements like
|
372 |
|
|
return---if you alter the flow of control of the
|
373 |
|
|
tcl code you must insure that every test still produces some result
|
374 |
|
|
code.
|
375 |
|
|
|
376 |
|
|
Here are some of the ways a test may wind up
|
377 |
|
|
UNRESOLVED:
|
378 |
|
|
|
379 |
|
|
|
380 |
|
|
A test's execution is interrupted.
|
381 |
|
|
|
382 |
|
|
A test does not produce a clear result. This is
|
383 |
|
|
usually because there was an ERROR from
|
384 |
|
|
DejaGnu while processing the test, or because there were three or
|
385 |
|
|
more WARNING messages. Any
|
386 |
|
|
WARNING or ERROR messages
|
387 |
|
|
can invalidate the output of the test. This usually requires a
|
388 |
|
|
human being to examine the output to determine what really
|
389 |
|
|
happened---and to improve the test case.
|
390 |
|
|
|
391 |
|
|
A test depends on a previous test, which
|
392 |
|
|
fails.
|
393 |
|
|
|
394 |
|
|
The test was set up incorrectly.
|
395 |
|
|
|
396 |
|
|
|
397 |
|
|
|
398 |
|
|
UNTESTED
|
399 |
|
|
A test was not run. This is a placeholder, used
|
400 |
|
|
when there is no real test case yet.
|
401 |
|
|
|
402 |
|
|
|
403 |
|
|
|
404 |
|
|
The only remaining output message left is intended to test
|
405 |
|
|
features that are specified by the applicable POSIX standard as
|
406 |
|
|
conditional:
|
407 |
|
|
|
408 |
|
|
|
409 |
|
|
|
410 |
|
|
UNSUPPORTED
|
411 |
|
|
There is no support for the tested case. This may
|
412 |
|
|
mean that a conditional feature of an operating system, or of a
|
413 |
|
|
compiler, is not implemented. DejaGnu also uses this message when
|
414 |
|
|
a testing environment (often a ``bare board'' target) lacks basic
|
415 |
|
|
support for compiling or running the test case. For example, a
|
416 |
|
|
test for the system subroutine gethostname
|
417 |
|
|
would never work on a target board running only a boot monitor.
|
418 |
|
|
|
419 |
|
|
|
420 |
|
|
|
421 |
|
|
DejaGnu uses the same output procedures to produce these messages
|
422 |
|
|
for all test suites, and these procedures are already known to conform
|
423 |
|
|
to POSIX 1003.3. For a DejaGnu test suite to conform to POSIX 1003.3,
|
424 |
|
|
you must avoid the setupxfail} procedure as
|
425 |
|
|
described in the PASS section above, and you must
|
426 |
|
|
be careful to return UNRESOLVED where appropriate,
|
427 |
|
|
as described in the UNRESOLVED section
|
428 |
|
|
above.
|
429 |
|
|
|
430 |
|
|
|
431 |
|
|
|
432 |
|
|
|
433 |
|
|
|
434 |
|
|
&user;
|
435 |
|
|
|
436 |
|
|
|
437 |
|
|
&ref;
|
438 |
|
|
|
439 |
|
|
|