1 |
578 |
markom |
This is dejagnu.info, produced by makeinfo version 4.0 from
|
2 |
|
|
dejagnu.texi.
|
3 |
|
|
|
4 |
|
|
START-INFO-DIR-ENTRY
|
5 |
|
|
* DejaGnu: (dejagnu). The GNU testing framework.
|
6 |
|
|
END-INFO-DIR-ENTRY
|
7 |
|
|
|
8 |
|
|
Copyright (C) 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
9 |
|
|
|
10 |
|
|
Permission is granted to make and distribute verbatim copies of this
|
11 |
|
|
manual provided the copyright notice and this permission notice are
|
12 |
|
|
preserved on all copies.
|
13 |
|
|
|
14 |
|
|
Permission is granted to copy and distribute modified versions of
|
15 |
|
|
this manual under the conditions for verbatim copying, provided also
|
16 |
|
|
that the entire resulting derived work is distributed under the terms
|
17 |
|
|
of a permission notice identical to this one.
|
18 |
|
|
|
19 |
|
|
Permission is granted to copy and distribute translations of this
|
20 |
|
|
manual into another language, under the above conditions for modified
|
21 |
|
|
versions.
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
File: dejagnu.info, Node: Top, Next: Overview, Up: (dir)
|
25 |
|
|
|
26 |
|
|
DejaGnu
|
27 |
|
|
*******
|
28 |
|
|
|
29 |
|
|
DejaGnu is a framework for running test suites on software tools.
|
30 |
|
|
|
31 |
|
|
This file describes version 1.3 of DejaGnu.
|
32 |
|
|
|
33 |
|
|
* Menu:
|
34 |
|
|
|
35 |
|
|
* Overview:: What is DejaGnu?
|
36 |
|
|
* What is New:: What is new in this release.
|
37 |
|
|
* Invoking runtest:: Using `runtest', the main test driver
|
38 |
|
|
* Customizing:: Setting `runtest' defaults
|
39 |
|
|
* Internals:: The DejaGnu implementation
|
40 |
|
|
* Tests:: How to write a test case
|
41 |
|
|
* Extending:: New tools, new targets, and new hosts
|
42 |
|
|
* Installation:: Configuring and Installing DejaGnu
|
43 |
|
|
* Index:: Index
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
File: dejagnu.info, Node: Overview, Next: What is New, Prev: Top, Up: Top
|
47 |
|
|
|
48 |
|
|
What is DejaGnu?
|
49 |
|
|
****************
|
50 |
|
|
|
51 |
|
|
DejaGnu is a framework for testing other programs. Its purpose is to
|
52 |
|
|
provide a single front end for all tests. Beyond this, DejaGnu offers
|
53 |
|
|
several advantages for testing:
|
54 |
|
|
|
55 |
|
|
1. The flexibility and consistency of the DejaGnu framework make it
|
56 |
|
|
easy to write tests for any program.
|
57 |
|
|
|
58 |
|
|
2. DejaGnu provides a layer of abstraction which allows you to write
|
59 |
|
|
tests that are portable to any host or target where a program must
|
60 |
|
|
be tested. For instance, a test for GDB can run (from any Unix
|
61 |
|
|
based host) on any target architecture that DejaGnu supports.
|
62 |
|
|
Currently DejaGnu runs tests on several single board computers,
|
63 |
|
|
whose operating software ranges from just a boot monitor to a
|
64 |
|
|
full-fledged, Unix-like realtime OS.
|
65 |
|
|
|
66 |
|
|
3. All tests have the same output format. This makes it easy to
|
67 |
|
|
integrate testing into other software development processes.
|
68 |
|
|
DejaGnu's output is designed to be parsed by other filtering
|
69 |
|
|
script, and it is also human readable.
|
70 |
|
|
|
71 |
|
|
DejaGnu is written in `expect', which in turn uses "Tcl"--Tool
|
72 |
|
|
command language.
|
73 |
|
|
|
74 |
|
|
Running tests requires two things: the testing framework, and the
|
75 |
|
|
test suites themselves. Tests are usually written in `expect' using
|
76 |
|
|
Tcl, but you can also use a Tcl script to run a test suite that is not
|
77 |
|
|
based on `expect'. (`expect' script filenames conventionally use
|
78 |
|
|
`.exp' as a suffix; for example, the main implementation of the DejaGnu
|
79 |
|
|
test driver is in the file `runtest.exp'.)
|
80 |
|
|
|
81 |
|
|
* Menu:
|
82 |
|
|
|
83 |
|
|
* Running Tests:: A first look at running DejaGnu tests
|
84 |
|
|
* Sample Test:: What does a DejaGnu test case look like?
|
85 |
|
|
* Design Goals:: Goals behind DejaGnu
|
86 |
|
|
* Posix:: DejaGnu conforms to POSIX 1003.3
|
87 |
|
|
* Future Directions:: Where is DejaGnu going?
|
88 |
|
|
* Tcl and Expect:: Reading more about Tcl and Expect
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
File: dejagnu.info, Node: What is New, Next: Invoking runtest, Prev: Overview, Up: Top
|
92 |
|
|
|
93 |
|
|
What is new in this release ?
|
94 |
|
|
*****************************
|
95 |
|
|
|
96 |
|
|
This release has a number of substantial changes over version 1.2.
|
97 |
|
|
The most visible change is that the version of expect and Tcl included
|
98 |
|
|
in the release are up-to-date with the current stable net releases.
|
99 |
|
|
Other changes are:
|
100 |
|
|
|
101 |
|
|
1. The config sub-system in DejaGnu has been completely redesigned.
|
102 |
|
|
It now supports testing on remote hosts as well as remote targets.
|
103 |
|
|
|
104 |
|
|
2. More builtin support for building target binaries with the correct
|
105 |
|
|
linker flags. Currently this only works with GCC, preferably with a
|
106 |
|
|
target support by `libgloss'.
|
107 |
|
|
|
108 |
|
|
3. Lots of little bug fixes from a year of heavy use here at Cygnus
|
109 |
|
|
Support.
|
110 |
|
|
|
111 |
|
|
4. DejaGnu now uses `autoconf' for configuration.
|
112 |
|
|
|
113 |
|
|
5. New test cases for DejaGnu have been added for the new features,
|
114 |
|
|
plus the "-tool" option bug in the 1.2 testsuite has been fixed.
|
115 |
|
|
|
116 |
|
|
6. The `--tool' option is now optional.
|
117 |
|
|
|
118 |
|
|
7. `runtest' when searching for test drivers ignores all directories
|
119 |
|
|
named SCCS, RCS, and CVS.
|
120 |
|
|
|
121 |
|
|
8. There is now a generic keyword based test harness that uses
|
122 |
|
|
comments in source code to control how each test case gets built
|
123 |
|
|
and run.
|
124 |
|
|
|
125 |
|
|
9. There is now some support for running a testsuite with multiple
|
126 |
|
|
passes and multiple targets.
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
|
130 |
|
|
File: dejagnu.info, Node: Running Tests, Next: Sample Test, Up: Overview
|
131 |
|
|
|
132 |
|
|
Running existing tests
|
133 |
|
|
======================
|
134 |
|
|
|
135 |
|
|
To run tests from an existing collection, first use `configure' as
|
136 |
|
|
usual to set up the source directory containing the tests. Then try
|
137 |
|
|
running
|
138 |
|
|
|
139 |
|
|
make check
|
140 |
|
|
|
141 |
|
|
If the `check' target exists, it usually saves you some trouble--for
|
142 |
|
|
instance, it can set up any auxiliary programs or other files needed by
|
143 |
|
|
the tests.
|
144 |
|
|
|
145 |
|
|
Once you have run `make check' to build any auxiliary files, you
|
146 |
|
|
might want to call the test driver `runtest' directly to repeat the
|
147 |
|
|
tests. You may also have to call `runtest' directly for test
|
148 |
|
|
collections with no `check' target in the `Makefile'.
|
149 |
|
|
|
150 |
|
|
Typically, you must use two command-line options: `--tool', to
|
151 |
|
|
specify which set of tests to run(1), and `--srcdir', to specify where
|
152 |
|
|
to find test directories.
|
153 |
|
|
|
154 |
|
|
For example, if the directory `gdb/testsuite' contains a collection
|
155 |
|
|
of DejaGnu tests for GDB, you can run them like this:
|
156 |
|
|
|
157 |
|
|
eg$ cd gdb/testsuite
|
158 |
|
|
eg$ runtest --tool gdb
|
159 |
|
|
_Test output follows, ending with:_
|
160 |
|
|
|
161 |
|
|
=== gdb Summary ===
|
162 |
|
|
|
163 |
|
|
# of expected passes 508
|
164 |
|
|
# of expected failures 103
|
165 |
|
|
/usr/latest/bin/gdb version 4.14.4 -nx
|
166 |
|
|
|
167 |
|
|
You can use the option `--srcdir' to point to some other directory
|
168 |
|
|
containing a collection of tests:
|
169 |
|
|
|
170 |
|
|
eg$ runtest --tool gdb --srcdir /devo/gdb/testsuite
|
171 |
|
|
|
172 |
|
|
These examples assume a "native" configuration, where the same
|
173 |
|
|
computer runs both `runtest' and the tests themselves. When you have a
|
174 |
|
|
"cross" configuration, the tests run on a different computer,
|
175 |
|
|
controlled by the host running `runtest'. In this situation, you need
|
176 |
|
|
the option `--name' to specify the network address for the other
|
177 |
|
|
computer:
|
178 |
|
|
|
179 |
|
|
eg$ runtest --tool gdb --name vx9.munist.com
|
180 |
|
|
|
181 |
|
|
If you always use the same option values, you can record them in a
|
182 |
|
|
file called `site.exp', rather than typing them each time. *Note
|
183 |
|
|
Setting defaults for `runtest' options: Config Values.
|
184 |
|
|
|
185 |
|
|
By default, `runtest' prints only the names of the tests it runs,
|
186 |
|
|
output from any tests that have unexpected results, and a summary
|
187 |
|
|
showing how many tests passed and how many failed. To display output
|
188 |
|
|
from all tests (whether or not they behave as expected), use the
|
189 |
|
|
`--all' option. For more verbose output about processes being run,
|
190 |
|
|
communication, and so on, use `--verbose'. To see even more output, use
|
191 |
|
|
multiple `--verbose' options. *Note Using `runtest': Invoking runtest,
|
192 |
|
|
for a more detailed explanation of each `runtest' option.
|
193 |
|
|
|
194 |
|
|
Test output goes into two files in your current directory: summary
|
195 |
|
|
output in `TOOL.sum', and detailed output in `TOOL.log'. (TOOL refers
|
196 |
|
|
to the collection of tests; for example, after a run with `--tool gdb',
|
197 |
|
|
look for output files `gdb.sum' and `gdb.log'.) *Note The files
|
198 |
|
|
DejaGnu writes: Output Files.
|
199 |
|
|
|
200 |
|
|
---------- Footnotes ----------
|
201 |
|
|
|
202 |
|
|
(1) `--tool' selects a particular suite of tests, _not_ the name of
|
203 |
|
|
the executable program to run. *Note Configuration dependent values:
|
204 |
|
|
Config Values, for information on the variables that you can use to
|
205 |
|
|
specify the names of programs to run.
|
206 |
|
|
|
207 |
|
|
|
208 |
|
|
File: dejagnu.info, Node: Sample Test, Next: Design Goals, Prev: Running Tests, Up: Overview
|
209 |
|
|
|
210 |
|
|
What does a DejaGnu test look like?
|
211 |
|
|
===================================
|
212 |
|
|
|
213 |
|
|
Each DejaGnu test is an `expect' script; the tests vary widely in
|
214 |
|
|
complexity, depending on the nature of the tool and the feature tested.
|
215 |
|
|
|
216 |
|
|
Here is a very simple GDB test--one of the simplest tests shipped
|
217 |
|
|
with DejaGnu (extracted from `gdb.t00/echo.exp'):(1)
|
218 |
|
|
|
219 |
|
|
# send a string to the GDB stdin:
|
220 |
|
|
send "echo Hello world!\n"
|
221 |
|
|
|
222 |
|
|
# inspect the GDB stdout for the correct reply,
|
223 |
|
|
# and determine whether the test passes or fails:
|
224 |
|
|
expect {
|
225 |
|
|
-re "Hello world.*$prompt $" { pass "Echo test" }
|
226 |
|
|
-re "$prompt $" { fail "Echo test" }
|
227 |
|
|
timeout { fail "(timeout) Echo test" }
|
228 |
|
|
}
|
229 |
|
|
|
230 |
|
|
Though brief, this example is a complete test. It illustrates some
|
231 |
|
|
of the main features of DejaGnu test scripts:
|
232 |
|
|
|
233 |
|
|
* The test case does not start the tested program (GDB in this case);
|
234 |
|
|
all test scripts for interactive tools can assume the
|
235 |
|
|
corresponding tool is running.
|
236 |
|
|
|
237 |
|
|
* Comments start with `#'.
|
238 |
|
|
|
239 |
|
|
* The main commands you use to control a tested program are `send'
|
240 |
|
|
(to give it commands) and `expect' (to analyze its responses).
|
241 |
|
|
|
242 |
|
|
* The `expect' command uses a list of pairs; a pattern (regular
|
243 |
|
|
expression if `-re' specified), followed by an action to run if the
|
244 |
|
|
pattern matches output from the program. Only the action for the
|
245 |
|
|
_first_ matching pattern will execute.
|
246 |
|
|
|
247 |
|
|
* Test cases use the commands `pass' and `fail' to record the test
|
248 |
|
|
outcome.
|
249 |
|
|
|
250 |
|
|
---------- Footnotes ----------
|
251 |
|
|
|
252 |
|
|
(1) More recent GDB tests use the `gdb_test' procedure. An
|
253 |
|
|
equivalent test using that procedure is ` gdb_test "echo Hello world!"
|
254 |
|
|
"Hello world!" '
|
255 |
|
|
|
256 |
|
|
|
257 |
|
|
File: dejagnu.info, Node: Design Goals, Next: Posix, Prev: Sample Test, Up: Overview
|
258 |
|
|
|
259 |
|
|
Design goals
|
260 |
|
|
============
|
261 |
|
|
|
262 |
|
|
DejaGnu grew out of the internal needs of Cygnus Support. Cygnus
|
263 |
|
|
maintains and enhances a variety of free programs in many different
|
264 |
|
|
environments, and we needed a testing tool that:
|
265 |
|
|
|
266 |
|
|
* is useful to developers while fixing bugs;
|
267 |
|
|
|
268 |
|
|
* automates running many tests during a software release process;
|
269 |
|
|
|
270 |
|
|
* is portable among a variety of host computers;
|
271 |
|
|
|
272 |
|
|
* supports cross-development testing;
|
273 |
|
|
|
274 |
|
|
* permits testing interactive programs, like GDB; and
|
275 |
|
|
|
276 |
|
|
* permits testing batch oriented programs, like GCC.
|
277 |
|
|
|
278 |
|
|
Some of the requirements proved challenging. For example,
|
279 |
|
|
interactive programs do not lend themselves very well to automated
|
280 |
|
|
testing. But all the requirements are important: for instance, it is
|
281 |
|
|
imperative to make sure that GDB works as well when cross-debugging as
|
282 |
|
|
it does in a native configuration.
|
283 |
|
|
|
284 |
|
|
Probably the greatest challenge was testing in a cross-development
|
285 |
|
|
environment (which can be a real nightmare). Most cross-development
|
286 |
|
|
environments are customized by each developer. Even when buying
|
287 |
|
|
packaged boards from vendors there are many differences. The
|
288 |
|
|
communication interfaces vary from a serial line to ethernet. DejaGnu
|
289 |
|
|
was designed with a modular communication setup, so that each kind of
|
290 |
|
|
communication can be added as required, and supported thereafter. Once
|
291 |
|
|
a communication procedure is coded, any test can use it. Currently
|
292 |
|
|
DejaGnu can use `rsh', `rlogin', `telnet', `tip', `kermit', and
|
293 |
|
|
`mondfe' for remote communications.
|
294 |
|
|
|
295 |
|
|
Julia Menapace first coined the term "Deja Gnu" to describe an
|
296 |
|
|
earlier testing framework at Cygnus Support. When we replaced it with
|
297 |
|
|
the Expect-based framework, it was like DejaGnu all over again...
|
298 |
|
|
|
299 |
|
|
|
300 |
|
|
File: dejagnu.info, Node: Posix, Next: Future Directions, Prev: Design Goals, Up: Overview
|
301 |
|
|
|
302 |
|
|
A POSIX conforming test framework
|
303 |
|
|
=================================
|
304 |
|
|
|
305 |
|
|
DejaGnu conforms to the POSIX standard for test frameworks.
|
306 |
|
|
|
307 |
|
|
POSIX standard 1003.3 defines what a testing framework needs to
|
308 |
|
|
provide, in order to permit the creation of POSIX conformance test
|
309 |
|
|
suites. This standard is primarily oriented to running POSIX
|
310 |
|
|
conformance tests, but its requirements also support testing of features
|
311 |
|
|
not related to POSIX conformance. POSIX 1003.3 does not specify a
|
312 |
|
|
particular testing framework, but at this time there is only one other
|
313 |
|
|
POSIX conforming test framework: TET.(1)
|
314 |
|
|
|
315 |
|
|
The POSIX documentation refers to "assertions". An assertion is a
|
316 |
|
|
description of behavior. For example, if a standard says "The sun
|
317 |
|
|
shall shine", a corresponding assertion might be "The sun is shining."
|
318 |
|
|
A test based on this assertion would pass or fail depending on whether
|
319 |
|
|
it is daytime or nighttime. It is important to note that the standard
|
320 |
|
|
being tested is never 1003.3; the standard being tested is some other
|
321 |
|
|
standard, for which the assertions were written.
|
322 |
|
|
|
323 |
|
|
As there is no test suite to test _testing frameworks_ for POSIX
|
324 |
|
|
1003.3 conformance, verifying conformance to this standard is done by
|
325 |
|
|
repeatedly reading the standard and experimenting. One of the main
|
326 |
|
|
things 1003.3 does specify is the set of allowed output messages, and
|
327 |
|
|
their definitions. Four messages are supported for a required feature
|
328 |
|
|
of POSIX conforming systems, and a fifth for a conditional feature.
|
329 |
|
|
DejaGnu supports the use of all five output messages; in this sense a
|
330 |
|
|
test suite that uses exactly these messages can be considered POSIX
|
331 |
|
|
conforming. These definitions specify the output of a test case:
|
332 |
|
|
|
333 |
|
|
`PASS'
|
334 |
|
|
A test has succeeded. That is, it demonstrated that the assertion
|
335 |
|
|
is true.
|
336 |
|
|
|
337 |
|
|
`XFAIL'
|
338 |
|
|
POSIX 1003.3 does not incorporate the notion of expected failures,
|
339 |
|
|
so `PASS', instead of `XPASS', must also be returned for test
|
340 |
|
|
cases which were expected to fail and did not. This means that
|
341 |
|
|
`PASS' is in some sense more ambiguous than if `XPASS' is also
|
342 |
|
|
used. For information on `XPASS' and `XFAIL', see *Note Using
|
343 |
|
|
`runtest': Invoking runtest.
|
344 |
|
|
|
345 |
|
|
`FAIL'
|
346 |
|
|
A test _has_ produced the bug it was intended to capture. That is,
|
347 |
|
|
it has demonstrated that the assertion is false. The `FAIL'
|
348 |
|
|
message is based on the test case only. Other messages are used to
|
349 |
|
|
indicate a failure of the framework.
|
350 |
|
|
|
351 |
|
|
As with `PASS', POSIX tests must return `FAIL' rather than `XFAIL'
|
352 |
|
|
even if a failure was expected.
|
353 |
|
|
|
354 |
|
|
`UNRESOLVED'
|
355 |
|
|
A test produced indeterminate results. Usually, this means the
|
356 |
|
|
test executed in an unexpected fashion; this outcome requires that
|
357 |
|
|
a human being go over results, to determine if the test should
|
358 |
|
|
have passed or failed. This message is also used for any test
|
359 |
|
|
that requires human intervention because it is beyond the
|
360 |
|
|
abilities of the testing framework. Any unresolved test should
|
361 |
|
|
resolved to `PASS' or `FAIL' before a test run can be considered
|
362 |
|
|
finished.
|
363 |
|
|
|
364 |
|
|
Note that for POSIX, each assertion must produce a test result
|
365 |
|
|
code. If the test isn't actually run, it must produce `UNRESOLVED'
|
366 |
|
|
rather than just leaving that test out of the output. This means
|
367 |
|
|
that you have to be careful when writing tests, to not carelessly
|
368 |
|
|
use tcl statements like `return'--if you alter the flow of control
|
369 |
|
|
of the tcl code you must insure that every test still produces
|
370 |
|
|
some result code.
|
371 |
|
|
|
372 |
|
|
Here are some of the ways a test may wind up `UNRESOLVED':
|
373 |
|
|
|
374 |
|
|
* A test's execution is interrupted.
|
375 |
|
|
|
376 |
|
|
* A test does not produce a clear result. This is usually
|
377 |
|
|
because there was an `ERROR' from DejaGnu while processing
|
378 |
|
|
the test, or because there were three or more `WARNING'
|
379 |
|
|
messages. Any `WARNING' or `ERROR' messages can invalidate
|
380 |
|
|
the output of the test. This usually requires a human being
|
381 |
|
|
to examine the output to determine what really happened--and
|
382 |
|
|
to improve the test case.
|
383 |
|
|
|
384 |
|
|
* A test depends on a previous test, which fails.
|
385 |
|
|
|
386 |
|
|
* The test was set up incorrectly.
|
387 |
|
|
|
388 |
|
|
`UNTESTED'
|
389 |
|
|
A test was not run. This is a placeholder, used when there is no
|
390 |
|
|
real test case yet.
|
391 |
|
|
|
392 |
|
|
The only remaining output message left is intended to test features that
|
393 |
|
|
are specified by the applicable POSIX standard as conditional:
|
394 |
|
|
|
395 |
|
|
`UNSUPPORTED'
|
396 |
|
|
There is no support for the tested case. This may mean that a
|
397 |
|
|
conditional feature of an operating system, or of a compiler, is
|
398 |
|
|
not implemented. DejaGnu also uses this message when a testing
|
399 |
|
|
environment (often a "bare board" target) lacks basic support for
|
400 |
|
|
compiling or running the test case. For example, a test for the
|
401 |
|
|
system subroutine `gethostname' would never work on a target board
|
402 |
|
|
running only a boot monitor.
|
403 |
|
|
|
404 |
|
|
DejaGnu uses the same output procedures to produce these messages for
|
405 |
|
|
all test suites, and these procedures are already known to conform to
|
406 |
|
|
POSIX 1003.3. For a DejaGnu test suite to conform to POSIX 1003.3, you
|
407 |
|
|
must avoid the `setup_xfail' procedure as described in the `PASS'
|
408 |
|
|
section above, and you must be careful to return `UNRESOLVED' where
|
409 |
|
|
appropriate, as described in the `UNRESOLVED' section above.
|
410 |
|
|
|
411 |
|
|
---------- Footnotes ----------
|
412 |
|
|
|
413 |
|
|
(1) TET was created by Unisoft for a consortium comprised of X/Open,
|
414 |
|
|
Unix International, and the Open Software Foundation.
|
415 |
|
|
|
416 |
|
|
|
417 |
|
|
File: dejagnu.info, Node: Future Directions, Next: Tcl and Expect, Prev: Posix, Up: Overview
|
418 |
|
|
|
419 |
|
|
Future directions
|
420 |
|
|
=================
|
421 |
|
|
|
422 |
|
|
In the near future, there are two parallel directions for DejaGnu
|
423 |
|
|
development. The first is to add support for more hosts and targets.
|
424 |
|
|
|
425 |
|
|
The second would permit testing programs with a more complex
|
426 |
|
|
interface, whether text based or GUI based. Two components already
|
427 |
|
|
exist: a Tcl based X window toolkit, and a terminal package for
|
428 |
|
|
`expect'. Both of these could be merged into DejaGnu in a way that
|
429 |
|
|
permits testing programs that run in each environment.
|
430 |
|
|
|
431 |
|
|
Meanwhile, we hope DejaGnu enables the creation of test suites for
|
432 |
|
|
conformance to ANSI C and C++, to POSIX, and to other standards. We
|
433 |
|
|
encourage you to make any test suites you create freely available,
|
434 |
|
|
under the same terms as DejaGnu itself.
|
435 |
|
|
|
436 |
|
|
|
437 |
|
|
File: dejagnu.info, Node: Tcl and Expect, Prev: Future Directions, Up: Overview
|
438 |
|
|
|
439 |
|
|
Tcl and Expect
|
440 |
|
|
==============
|
441 |
|
|
|
442 |
|
|
Tcl was introduced in a paper by John K. Ousterhout at the 1990
|
443 |
|
|
Winter Usenix conference, `Tcl: An Embeddable Command Language'. That
|
444 |
|
|
paper is included in PostScript form in the `doc' subdirectory of the
|
445 |
|
|
Tcl distribution. The version of Tcl included in DejaGnu at this time is
|
446 |
|
|
Tcl 7.4p3.
|
447 |
|
|
|
448 |
|
|
Don Libes introduced `expect' in his paper `expect: Curing Those
|
449 |
|
|
Uncontrollable Fits of Interaction' at the 1990 Summer Usenix
|
450 |
|
|
conference. The paper is included in PostScript form in the `expect'
|
451 |
|
|
distribution (as are several other papers about `expect'). The version
|
452 |
|
|
of expect included in DejaGnu at this time is expect 5.18.0.
|
453 |
|
|
|
454 |
|
|
|
455 |
|
|
File: dejagnu.info, Node: Invoking runtest, Next: Customizing, Prev: What is New, Up: Top
|
456 |
|
|
|
457 |
|
|
Using `runtest'
|
458 |
|
|
***************
|
459 |
|
|
|
460 |
|
|
`runtest' is the executable test driver for DejaGnu. You can
|
461 |
|
|
specify two kinds of things on the `runtest' command line: command line
|
462 |
|
|
options, and Tcl variables for the test scripts. The options are
|
463 |
|
|
listed alphabetically below.
|
464 |
|
|
|
465 |
|
|
`runtest' returns an exit code of `1' if any test has an unexpected
|
466 |
|
|
result; otherwise (if all tests pass or fail as expected) it returns
|
467 |
|
|
`0' as the exit code.
|
468 |
|
|
|
469 |
|
|
`runtest' flags the outcome of each test as one of these cases.
|
470 |
|
|
(*Note A POSIX conforming test framework: Posix, for a discussion of
|
471 |
|
|
how POSIX specifies the meanings of these cases.)
|
472 |
|
|
|
473 |
|
|
`PASS'
|
474 |
|
|
The most desirable outcome: the test succeeded, and was expected to
|
475 |
|
|
succeed.
|
476 |
|
|
|
477 |
|
|
`XPASS'
|
478 |
|
|
A pleasant kind of failure: a test was expected to fail, but
|
479 |
|
|
succeeded. This may indicate progress; inspect the test case to
|
480 |
|
|
determine whether you should amend it to stop expecting failure.
|
481 |
|
|
|
482 |
|
|
`FAIL'
|
483 |
|
|
A test failed, although it was expected to succeed. This may
|
484 |
|
|
indicate regress; inspect the test case and the failing software
|
485 |
|
|
to locate the bug.
|
486 |
|
|
|
487 |
|
|
`XFAIL'
|
488 |
|
|
A test failed, but it was expected to fail. This result indicates
|
489 |
|
|
no change in a known bug. If a test fails because the operating
|
490 |
|
|
system where the test runs lacks some facility required by the
|
491 |
|
|
test, the outcome is `UNSUPPORTED' instead.
|
492 |
|
|
|
493 |
|
|
`UNRESOLVED'
|
494 |
|
|
Output from a test requires manual inspection; the test suite
|
495 |
|
|
could not automatically determine the outcome. For example, your
|
496 |
|
|
tests can report this outcome is when a test does not complete as
|
497 |
|
|
expected.
|
498 |
|
|
|
499 |
|
|
`UNTESTED'
|
500 |
|
|
A test case is not yet complete, and in particular cannot yet
|
501 |
|
|
produce a `PASS' or `FAIL'. You can also use this outcome in dummy
|
502 |
|
|
"tests" that note explicitly the absence of a real test case for a
|
503 |
|
|
particular property.
|
504 |
|
|
|
505 |
|
|
`UNSUPPORTED'
|
506 |
|
|
A test depends on a conditionally available feature that does not
|
507 |
|
|
exist (in the configured testing environment). For example, you
|
508 |
|
|
can use this outcome to report on a test case that does not work
|
509 |
|
|
on a particular target because its operating system support does
|
510 |
|
|
not include a required subroutine.
|
511 |
|
|
|
512 |
|
|
`runtest' may also display the following messages:
|
513 |
|
|
|
514 |
|
|
`ERROR'
|
515 |
|
|
Indicates a major problem (detected by the test case itself) in
|
516 |
|
|
running the test. This is usually an unrecoverable error, such as
|
517 |
|
|
a missing file or loss of communication to the target. (POSIX
|
518 |
|
|
test suites should not emit this message; use `UNSUPPORTED',
|
519 |
|
|
`UNTESTED', or `UNRESOLVED' instead, as appropriate.)
|
520 |
|
|
|
521 |
|
|
`WARNING'
|
522 |
|
|
Indicates a possible problem in running the test. Usually warnings
|
523 |
|
|
correspond to recoverable errors, or display an important message
|
524 |
|
|
about the following tests.
|
525 |
|
|
|
526 |
|
|
`NOTE'
|
527 |
|
|
An informational message about the test case.
|
528 |
|
|
|
529 |
|
|
This is the full set of command line options that `runtest'
|
530 |
|
|
recognizes. Arguments may be abbreviated to the shortest unique string.
|
531 |
|
|
|
532 |
|
|
runtest --tool TOOL [ TESTSUITE.exp ... ]
|
533 |
|
|
[ TESTSUITE.exp="testfile1 ..." ]
|
534 |
|
|
[ TCLVAR=VALUE... ]
|
535 |
|
|
[ --all ] [ --baud BAUD-RATE ] [ --connect TYPE ]
|
536 |
|
|
[ --debug ] [ --help ] [ --host STRING ]
|
537 |
|
|
[ --mail "NAME ..." ] [ --name STRING ]
|
538 |
|
|
[ --name NAME ] [ --outdir PATH ]
|
539 |
|
|
[ --objdir PATH ] [ --reboot ]
|
540 |
|
|
[ --srcdir PATH ] [ --strace N ]
|
541 |
|
|
[ --target STRING --build STRING ]
|
542 |
|
|
[ -v | --verbose ] [ -V | --version ] [ --DN ]
|
543 |
|
|
|
544 |
|
|
`--tool TOOL'
|
545 |
|
|
TOOL specifies what set of tests to run, and what initialization
|
546 |
|
|
module to use. TOOL is used _only_ for these two purposes: it is
|
547 |
|
|
_not_ used to name the executable program to test. Executable
|
548 |
|
|
tool names (and paths) are recorded in `site.exp' (*note
|
549 |
|
|
Configuration dependent values: Config Values.), and you can
|
550 |
|
|
override them by specifying Tcl variables on the command line.
|
551 |
|
|
|
552 |
|
|
For example, including `--tool gcc' on the `runtest' command line
|
553 |
|
|
runs tests from all test subdirectories whose names match `gcc.*',
|
554 |
|
|
and uses one of the initialization modules named
|
555 |
|
|
`config/*-gcc.exp'. To specify the name of the compiler (perhaps
|
556 |
|
|
as an alternative path to what `runtest' would use by default), use
|
557 |
|
|
`GCC=BINNAME' on the `runtest' command line.
|
558 |
|
|
|
559 |
|
|
`TESTSUITE.exp ...'
|
560 |
|
|
Specify the names of testsuites to run. By default, `runtest'
|
561 |
|
|
runs all tests for the tool, but you can restrict it to particular
|
562 |
|
|
testsuites by giving the names of the `.exp' `expect' scripts that
|
563 |
|
|
control them.
|
564 |
|
|
|
565 |
|
|
TESTSUITE.exp may not include path information; use plain
|
566 |
|
|
filenames.
|
567 |
|
|
|
568 |
|
|
`TESTFILE.exp="testfile1 ..."'
|
569 |
|
|
Specify a subset of tests in a suite to run. For compiler or
|
570 |
|
|
assembler tests, which often use a single `.exp' script covering
|
571 |
|
|
many different source files, this option allows you to further
|
572 |
|
|
restrict the tests by listing particular source files to compile.
|
573 |
|
|
Some tools even support wildcards here. The wildcards supported
|
574 |
|
|
depend upon the tool, but typically they are `?', `*', and
|
575 |
|
|
`[chars]'.
|
576 |
|
|
|
577 |
|
|
`TCLVAR=VALUE'
|
578 |
|
|
You can define Tcl variables for use by your test scripts in the
|
579 |
|
|
same style used with `make' for environment variables. For
|
580 |
|
|
example, `runtest GDB=gdb.old' defines a variable called `GDB';
|
581 |
|
|
when your scripts refer to `$GDB' in this run, they use the value
|
582 |
|
|
`gdb.old'.
|
583 |
|
|
|
584 |
|
|
The default Tcl variables used for most tools are defined in the
|
585 |
|
|
main DejaGnu `Makefile'; their values are captured in the
|
586 |
|
|
`site.exp' file. *Note Configuration dependent values: Config
|
587 |
|
|
Values.
|
588 |
|
|
|
589 |
|
|
`--all'
|
590 |
|
|
Display all test output. By default, `runtest' shows only the
|
591 |
|
|
output of tests that produce unexpected results; that is, tests
|
592 |
|
|
with status `FAIL' (unexpected failure), `XPASS' (unexpected
|
593 |
|
|
success), or `ERROR' (a severe error in the test case itself).
|
594 |
|
|
Specify `--all' to see output for tests with status `PASS'
|
595 |
|
|
(success, as expected) `XFAIL' (failure, as expected), or
|
596 |
|
|
`WARNING' (minor error in the test case itself).
|
597 |
|
|
|
598 |
|
|
`--baud BAUD-RATE'
|
599 |
|
|
`-b BAUD-RATE'
|
600 |
|
|
Set the default baud rate to something other than 9600. (Some
|
601 |
|
|
serial interface programs, like `tip', use a separate
|
602 |
|
|
initialization file instead of this value.)
|
603 |
|
|
|
604 |
|
|
`--connect TYPE'
|
605 |
|
|
Connect to a target testing environment as specified by TYPE, if
|
606 |
|
|
the target is not the computer running `runtest'. For example, use
|
607 |
|
|
`--connect' to change the program used to connect to a "bare
|
608 |
|
|
board" boot monitor. The choices for TYPE in the DejaGnu 1.0
|
609 |
|
|
distribution are `rlogin', `telnet', `rsh', `tip', `kermit', and
|
610 |
|
|
`mondfe'.
|
611 |
|
|
|
612 |
|
|
The default for this option depends on the configuration (*note
|
613 |
|
|
Remote targets supported: Cross Targets.). The default is chosen
|
614 |
|
|
to be the most convenient communication method available, but
|
615 |
|
|
often other alternatives work as well; you may find it useful to
|
616 |
|
|
try alternative connect methods if you suspect a communication
|
617 |
|
|
problem with your testing target.
|
618 |
|
|
|
619 |
|
|
`--debug'
|
620 |
|
|
Turns on the `expect' internal debugging output. Debugging output
|
621 |
|
|
is displayed as part of the `runtest' output, and logged to a file
|
622 |
|
|
called `dbg.log'. The extra debugging output does _not_ appear on
|
623 |
|
|
standard output, unless the verbose level is greater than 2 (for
|
624 |
|
|
instance, to see debug output immediately, specify `--debug -v
|
625 |
|
|
-v'). The debugging output shows all attempts at matching the test
|
626 |
|
|
output of the tool with the scripted patterns describing expected
|
627 |
|
|
output. The output generated with `--strace' also goes into
|
628 |
|
|
`dbg.log'.
|
629 |
|
|
|
630 |
|
|
`--help'
|
631 |
|
|
`-he'
|
632 |
|
|
Prints out a short summary of the `runtest' options, then exits
|
633 |
|
|
(even if you also specify other options).
|
634 |
|
|
|
635 |
|
|
`--host STRING'
|
636 |
|
|
STRING is a full configuration "triple" name as used by
|
637 |
|
|
`configure'. Use this option to override the default string
|
638 |
|
|
recorded by your configuration's choice of host. This choice does
|
639 |
|
|
not change how anything is actually configured unless -build is
|
640 |
|
|
also specified; it affects _only_ DejaGnu procedures that compare
|
641 |
|
|
the host string with particular values. The procedures `ishost',
|
642 |
|
|
`istarget', `isnative', and `setup_xfail' are affected by
|
643 |
|
|
`--host'. In this usage, `host' refers to the machine that the
|
644 |
|
|
tests are to be run on, which may not be the same as the `build'
|
645 |
|
|
machine. If `--build' is also specified, then `--host' refers to
|
646 |
|
|
the machine that the tests wil, be run on, not the machine DejaGnu
|
647 |
|
|
is run on.
|
648 |
|
|
|
649 |
|
|
`--build STRING'
|
650 |
|
|
STRING is a full configuration "triple" name as used by
|
651 |
|
|
`configure'. This is the type of machine DejaGnu and the tools to
|
652 |
|
|
be tested are built on. For a normal cross this is the same as the
|
653 |
|
|
host, but for a canadian cross, they are seperate.
|
654 |
|
|
|
655 |
|
|
`--name NAME'
|
656 |
|
|
NAME is a name for the particular testing target machine (for
|
657 |
|
|
cross testing). If the testing target has IP network support (for
|
658 |
|
|
example, `RPC' or `NFS'), this is the network name for the target
|
659 |
|
|
itself. (NAME is _not the configuration string_ you specify as a
|
660 |
|
|
target with `configure'; the `--name' option names a particular
|
661 |
|
|
target, rather than describing a class of targets.) For targets
|
662 |
|
|
that connect in other ways, the meaning of the NAME string depends
|
663 |
|
|
on the connection method. *Note Remote targets supported: Cross
|
664 |
|
|
Targets.
|
665 |
|
|
|
666 |
|
|
`--name STRING'
|
667 |
|
|
Specify a network name of testing target or its host. The
|
668 |
|
|
particular names that are meaningful with `--name' will depend on
|
669 |
|
|
your site configuration, and on the connection protocol: for
|
670 |
|
|
example, `tip' connections require names from a serial line
|
671 |
|
|
configuration file (usually called `/etc/remote'), while `telnet'
|
672 |
|
|
connections use IP hostnames.
|
673 |
|
|
|
674 |
|
|
`--objdir PATH'
|
675 |
|
|
Use PATH as the top directory containing any auxiliary compiled
|
676 |
|
|
test code. This defaults to `.'. Use this option to locate
|
677 |
|
|
pre-compiled test code. You can normally prepare any auxiliary
|
678 |
|
|
files needed with `make'.
|
679 |
|
|
|
680 |
|
|
`--outdir PATH'
|
681 |
|
|
Write output logs in directory PATH. The default is `.', the
|
682 |
|
|
directory where you start `runtest'. This option affects only the
|
683 |
|
|
summary and the detailed log files `TOOL.sum' and `TOOL.log'. The
|
684 |
|
|
DejaGnu debug log `dbg.log' always appears (when requested) in the
|
685 |
|
|
local directory.
|
686 |
|
|
|
687 |
|
|
`--reboot'
|
688 |
|
|
Reboot the target board when `runtest' initializes. Usually, when
|
689 |
|
|
running tests on a separate target board, it is safer to reboot
|
690 |
|
|
the target to be certain of its state. However, when developing
|
691 |
|
|
test scripts, rebooting takes a lot of time.
|
692 |
|
|
|
693 |
|
|
`--srcdir PATH'
|
694 |
|
|
Use PATH as the top directory for test scripts to run. `runtest'
|
695 |
|
|
looks in this directory for any subdirectory whose name begins
|
696 |
|
|
with the toolname (specified with `--tool'). For instance, with
|
697 |
|
|
`--tool gdb', `runtest' uses tests in subdirectories `gdb.*' (with
|
698 |
|
|
the usual shell-like filename expansion). If you do not use
|
699 |
|
|
`--srcdir', `runtest' looks for test directories under the current
|
700 |
|
|
working directory.
|
701 |
|
|
|
702 |
|
|
`--strace N'
|
703 |
|
|
Turn on internal tracing for `expect', to N levels deep. By
|
704 |
|
|
adjusting the level, you can control the extent to which your
|
705 |
|
|
output expands multi-level Tcl statements. This allows you to
|
706 |
|
|
ignore some levels of `case' or `if' statements. Each procedure
|
707 |
|
|
call or control structure counts as one "level".
|
708 |
|
|
|
709 |
|
|
The output is recorded in the same file, `dbg.log', used for output
|
710 |
|
|
from `--debug'.
|
711 |
|
|
|
712 |
|
|
`--target STRING'
|
713 |
|
|
Use this option to override the default setting (running native
|
714 |
|
|
tests). STRING is a full configuration "triple" name(1) as used
|
715 |
|
|
by `configure'. This option changes the configuration `runtest'
|
716 |
|
|
uses for the default tool names, and other setup information.
|
717 |
|
|
*Note Using `configure': (configure.info)Using configure, for
|
718 |
|
|
details about `configure' names.
|
719 |
|
|
|
720 |
|
|
`--verbose'
|
721 |
|
|
`-v'
|
722 |
|
|
Turns on more output. Repeating this option increases the amount
|
723 |
|
|
of output displayed. Level one (`-v') is simply test output. Level
|
724 |
|
|
two (`-v -v') shows messages on options, configuration, and process
|
725 |
|
|
control. Verbose messages appear in the detailed (`*.log') log
|
726 |
|
|
file, but not in the summary (`*.sum') log file.
|
727 |
|
|
|
728 |
|
|
`--version'
|
729 |
|
|
`-V'
|
730 |
|
|
Prints out the version numbers of DejaGnu, `expect' and Tcl, and
|
731 |
|
|
exits without running any tests.
|
732 |
|
|
|
733 |
|
|
`-D0'
|
734 |
|
|
`-D1'
|
735 |
|
|
Start the internal Tcl debugger. The Tcl debugger supports
|
736 |
|
|
breakpoints, single stepping, and other common debugging
|
737 |
|
|
activities. (See `A Debugger for Tcl Applications' by Don Libes.
|
738 |
|
|
(2))
|
739 |
|
|
|
740 |
|
|
If you specify `-D1', the `expect' shell stops at a breakpoint as
|
741 |
|
|
soon as DejaGnu invokes it.
|
742 |
|
|
|
743 |
|
|
If you specify `-D0', DejaGnu starts as usual, but you can enter
|
744 |
|
|
the debugger by sending an interrupt (e.g. by typing ).
|
745 |
|
|
|
746 |
|
|
---------- Footnotes ----------
|
747 |
|
|
|
748 |
|
|
(1) Configuration triples have the form `CPU-VENDOR-OS'.
|
749 |
|
|
|
750 |
|
|
(2) Distributed in PostScript form with `expect' as the file
|
751 |
|
|
`expect/tcl-debug.ps'.
|
752 |
|
|
|
753 |
|
|
|
754 |
|
|
File: dejagnu.info, Node: Customizing, Next: Internals, Prev: Invoking runtest, Up: Top
|
755 |
|
|
|
756 |
|
|
Setting `runtest' defaults
|
757 |
|
|
**************************
|
758 |
|
|
|
759 |
|
|
The site configuration file, `site.exp', captures
|
760 |
|
|
configuration-dependent values and propagates them to the DejaGnu test
|
761 |
|
|
environment using Tcl variables. This ties the DejaGnu test scripts
|
762 |
|
|
into the `configure' and `make' programs.
|
763 |
|
|
|
764 |
|
|
DejaGnu supports more than one `site.exp' file. The multiple
|
765 |
|
|
instances of `site.exp' are loaded in a fixed order built into DejaGnu
|
766 |
|
|
(the more local last). The first file loaded is the optional
|
767 |
|
|
`~/.dejagnurc', then the local files, and finally the global file.
|
768 |
|
|
|
769 |
|
|
1. There is am optional "master" `site.exp', capturing configuration
|
770 |
|
|
values that apply to DejaGnu across the board, in each
|
771 |
|
|
configuration-specific subdirectory of the DejaGnu library
|
772 |
|
|
directory. `runtest' loads these values first. *Note Configuring
|
773 |
|
|
and Installing DejaGnu: Installation. The master `site.exp'
|
774 |
|
|
contains the default values for all targets and hosts supported by
|
775 |
|
|
DejaGnu. This master file is identified by setting the environment
|
776 |
|
|
variable `DEJAGNU' to the name of the file. This is also refered
|
777 |
|
|
to as the "global" config file.
|
778 |
|
|
|
779 |
|
|
2. Any directory containing a configured test suite also has a
|
780 |
|
|
`site.exp', capturing configuration values specific to the tool
|
781 |
|
|
under test. Since `runtest' loads these values last, the
|
782 |
|
|
individual test configuration can either rely on and use, or
|
783 |
|
|
override, any of the global values from the "master" `site.exp'.
|
784 |
|
|
|
785 |
|
|
You can usually generate or update the testsuite `site.exp' by
|
786 |
|
|
typing `make site.exp' in the test suite directory, after the test
|
787 |
|
|
suite is configured.
|
788 |
|
|
|
789 |
|
|
3. You can also have a file in your home directory called
|
790 |
|
|
`.dejagnurc'. This gets loaded first before the other config
|
791 |
|
|
files. Usually this is used for personal stuff, like setting
|
792 |
|
|
`all_flag' so all the output gets printed, or verbosity levels.
|
793 |
|
|
|
794 |
|
|
You can further override the default values in a user-editable
|
795 |
|
|
section of any `site.exp', or by setting variables on the `runtest'
|
796 |
|
|
command line.
|
797 |
|
|
|
798 |
|
|
* Menu:
|
799 |
|
|
|
800 |
|
|
* Config Values:: Variables used in the configuration file.
|
801 |
|
|
* Master Config File:: The master configuration file.
|
802 |
|
|
* Local Config File:: The local configuration file.
|
803 |
|
|
* Personal Config File:: The personal configuration file.
|
804 |
|
|
|
805 |
|
|
|
806 |
|
|
File: dejagnu.info, Node: Config Values, Next: Master Config File, Up: Customizing
|
807 |
|
|
|
808 |
|
|
Config Variables
|
809 |
|
|
----------------
|
810 |
|
|
|
811 |
|
|
DejaGnu uses a named array in Tcl to hold all the info for each
|
812 |
|
|
machine. In the case of a canadian cross, this means host information as
|
813 |
|
|
well as target information. The named array is called `target_info',
|
814 |
|
|
and it has two indices. The following fields are part of the array.
|
815 |
|
|
|
816 |
|
|
`name'
|
817 |
|
|
The name of the target. (mostly for error messages) This should
|
818 |
|
|
also be the string used for this target's array. It should also
|
819 |
|
|
be the same as the linker script so we can find them dynamically.
|
820 |
|
|
This should be the same as the argument used for `push_target{}'.
|
821 |
|
|
|
822 |
|
|
`ldflags'
|
823 |
|
|
This is the linker flags required to produce a fully linked
|
824 |
|
|
executable. For `libgloss' supported targets this is usually just
|
825 |
|
|
the name of the linker script.
|
826 |
|
|
|
827 |
|
|
`config'
|
828 |
|
|
The target canonical for this target. This is used by some init
|
829 |
|
|
files to make sure the target is supported.
|
830 |
|
|
|
831 |
|
|
`cflags'
|
832 |
|
|
The flags required to produce an object file from a source file.
|
833 |
|
|
|
834 |
|
|
`connect'
|
835 |
|
|
This is the connectmode for this target. This is for both IP and
|
836 |
|
|
serial connections. Typically this is either `telnet', `rlogin',
|
837 |
|
|
or `rsh'.
|
838 |
|
|
|
839 |
|
|
`target'
|
840 |
|
|
This is the hostname of the target. This is for TCP/IP based
|
841 |
|
|
connections, and is also used for version of tip that use
|
842 |
|
|
/etc/remote.
|
843 |
|
|
|
844 |
|
|
`serial'
|
845 |
|
|
This is the serial port. This is typically /dev/tty? or com?:.
|
846 |
|
|
|
847 |
|
|
`netport'
|
848 |
|
|
This is the IP port. This is commonly used for telneting to target
|
849 |
|
|
boards that are connected to a terminal server. In that case the
|
850 |
|
|
IP port specifies the which serial port to use.
|
851 |
|
|
|
852 |
|
|
`baud'
|
853 |
|
|
This is the baud rate for a serial port connection.
|
854 |
|
|
|
855 |
|
|
`x10'
|
856 |
|
|
This is the parameters for an x10 controller. These are simple
|
857 |
|
|
devices that let us power cycle or reset a target board remotely.
|
858 |
|
|
|
859 |
|
|
`fileid'
|
860 |
|
|
This is the fileid or spawn id of of the connection.
|
861 |
|
|
|
862 |
|
|
`prompt'
|
863 |
|
|
a glob style pattern to recognize the prompt.
|
864 |
|
|
|
865 |
|
|
`abbrev'
|
866 |
|
|
abbreviation for tool init files.
|
867 |
|
|
|
868 |
|
|
`ioport'
|
869 |
|
|
This is the port for I/O on dual port systems. In this
|
870 |
|
|
configuration, the main serial port `0' is usually used for stdin
|
871 |
|
|
and stdout, which the second serial port can be used for debugging.
|
872 |
|
|
|
873 |
|
|
The first index into the array is the same value as used in the
|
874 |
|
|
`name' field. This is usually a short version of the name of the target
|
875 |
|
|
board. For an example, here's the settings I use for my `Motorola's'
|
876 |
|
|
`IDP' board and my `Motorola' 6U VME `MVME135-1' board. (both m68k
|
877 |
|
|
targets)
|
878 |
|
|
|
879 |
|
|
# IDP board
|
880 |
|
|
set target_info(idp,name) "idp"
|
881 |
|
|
set target_info(idp,ldflags) "-Tidp.ld"
|
882 |
|
|
set target_info(idp,config) m68k-unknown-aout
|
883 |
|
|
set target_info(idp,cflags) ""
|
884 |
|
|
set target_info(idp,connect) telnet
|
885 |
|
|
set target_info(idp,target) "s7"
|
886 |
|
|
set target_info(idp,serial) "tstty7"
|
887 |
|
|
set target_info(idp,netport) "wharfrat:1007"
|
888 |
|
|
set target_info(idp,baud) "9600"
|
889 |
|
|
# MVME 135 board
|
890 |
|
|
set target_info(idp,name) "mvme"
|
891 |
|
|
set target_info(idp,ldflags) "-Tmvme.ld"
|
892 |
|
|
set target_info(idp,config) m68k-unknown-aout
|
893 |
|
|
set target_info(idp,cflags) ""
|
894 |
|
|
set target_info(idp,connect) telnet
|
895 |
|
|
set target_info(idp,target) "s8"
|
896 |
|
|
set target_info(idp,serial) "tstty8"
|
897 |
|
|
set target_info(idp,netport) "wharfrat:1008"
|
898 |
|
|
set target_info(idp,baud) "9600"
|
899 |
|
|
|
900 |
|
|
DejaGnu can use this information to switch between multiple targets
|
901 |
|
|
in one test run. This is done through the use of the `push_target'
|
902 |
|
|
procedure, which is discussed elsewhere.
|
903 |
|
|
|
904 |
|
|
This array can also hold information for a remote host, which is used
|
905 |
|
|
when testing a candain cross. In this case, the only thing different is
|
906 |
|
|
the index is just `host'. Here's the settings I use to run tests on my
|
907 |
|
|
NT machine while running DejaGnu on a Unix machine. (in this case a
|
908 |
|
|
Linux box)
|
909 |
|
|
|
910 |
|
|
set target_info(host,name) "nt-host"
|
911 |
|
|
set target_info(host,config) "386-unknown-winnt"
|
912 |
|
|
set target_info(host,connect) "telnet"
|
913 |
|
|
set target_info(host,target) "ripple"
|
914 |
|
|
|
915 |
|
|
There is more info on how to use these variables in the sections on
|
916 |
|
|
the config files. *Note Configuration Files: Master Config File.
|
917 |
|
|
|
918 |
|
|
In the user editable second section of `site.exp', you can not only
|
919 |
|
|
override the configuration variables captured in the first section, but
|
920 |
|
|
also specify default values for all the `runtest' command line options.
|
921 |
|
|
Save for `--debug', `--help', and `--version', each command line
|
922 |
|
|
option has an associated Tcl variable. Use the Tcl `set' command to
|
923 |
|
|
specify a new default value (as for the configuration variables). The
|
924 |
|
|
following table describes the correspondence between command line
|
925 |
|
|
options and variables you can set in `site.exp'. *Note Running the
|
926 |
|
|
Tests: Invoking runtest, for explanations of the command-line options.
|
927 |
|
|
|
928 |
|
|
runtest Tcl
|
929 |
|
|
option variable description
|
930 |
|
|
__________ ________ ___________________________________________
|
931 |
|
|
|
932 |
|
|
--all all_flag display all test results if set
|
933 |
|
|
|
934 |
|
|
--baud baud set the default baud rate to something other
|
935 |
|
|
than 9600.
|
936 |
|
|
--connect connectmode `rlogin', `telnet', `rsh',
|
937 |
|
|
`kermit', `tip', or `mondfe'
|
938 |
|
|
|
939 |
|
|
--outdir outdir directory for `TOOL.sum' and `TOOL.log'
|
940 |
|
|
|
941 |
|
|
--objdir objdir directory for pre-compiled binaries
|
942 |
|
|
|
943 |
|
|
--reboot reboot reboot the target if set to `"1"';
|
944 |
|
|
do not reboot if set to `"0"' (the default)
|
945 |
|
|
|
946 |
|
|
--srcdir srcdir directory of test subdirectories
|
947 |
|
|
|
948 |
|
|
--strace tracelevel a number: Tcl trace depth
|
949 |
|
|
|
950 |
|
|
--tool tool name of tool to test; identifies init, test subdir
|
951 |
|
|
|
952 |
|
|
--verbose verbose verbosity level. As option, use multiple times;
|
953 |
|
|
as variable, set a number, 0 or greater
|
954 |
|
|
--target target_triplet The canonical configuration string for the target.
|
955 |
|
|
--host host_triplet The canonical configuration string for the host.
|
956 |
|
|
--build build_triplet The canonical configuration string for the
|
957 |
|
|
build host.
|
958 |
|
|
|
959 |
|
|
|
960 |
|
|
File: dejagnu.info, Node: Master Config File, Next: Local Config File, Prev: Config Values, Up: Customizing
|
961 |
|
|
|
962 |
|
|
Master Config File
|
963 |
|
|
------------------
|
964 |
|
|
|
965 |
|
|
The master config file is where all the target specific config
|
966 |
|
|
variables get set for a whole site get set. The idea is that for a
|
967 |
|
|
centralized testing lab where people have to share a target between
|
968 |
|
|
multiple developers. There are settings for both remote targets and
|
969 |
|
|
remote hosts. Here's an example of a Master Config File (also called
|
970 |
|
|
the Global config file) for a _canadian cross_. A canadian cross is
|
971 |
|
|
when you build and test a cross compiler on a machine other than the
|
972 |
|
|
one it's to be hosted on.
|
973 |
|
|
|
974 |
|
|
Here we have the config settings for our California office. Note that
|
975 |
|
|
all config values are site dependant. Here we have two sets of values
|
976 |
|
|
that we use for testing m68k-aout cross compilers. As both of these
|
977 |
|
|
target boards has a different debugging protocol, we test on both of
|
978 |
|
|
them in sequence.
|
979 |
|
|
|
980 |
|
|
global CFLAGS
|
981 |
|
|
global CXXFLAGS
|
982 |
|
|
|
983 |
|
|
case "$target_triplet" in {
|
984 |
|
|
{ "native" } {
|
985 |
|
|
set target_abbrev unix
|
986 |
|
|
}
|
987 |
|
|
{ "m68*-unknown-aout" } {
|
988 |
|
|
set target_abbrev "rom68k"
|
989 |
|
|
# IDP target # IDP board with rom68k monitor
|
990 |
|
|
set target_info(idp,name) "idp"
|
991 |
|
|
set target_info(idp,ldflags) "-Tidp.ld"
|
992 |
|
|
set target_info(idp,config) m68k-unknown-aout
|
993 |
|
|
set target_info(idp,cflags) ""
|
994 |
|
|
set target_info(idp,connect) telnet
|
995 |
|
|
set target_info(idp,target) "s7"
|
996 |
|
|
set target_info(idp,serial) "tstty12"
|
997 |
|
|
set target_info(idp,netport) "truckin:1007"
|
998 |
|
|
set target_info(idp,baud) "9600"
|
999 |
|
|
# MVME target # Motorola MVME 135 with BUG monitor
|
1000 |
|
|
set target_info(mvme,name) "mvme"
|
1001 |
|
|
set target_info(mvme,ldflags) "-Tmvme.ld"
|
1002 |
|
|
set target_info(mvme,config) m68k-unknown-aout
|
1003 |
|
|
set target_info(mvme,cflags) ""
|
1004 |
|
|
set target_info(mvme,connect) telnet
|
1005 |
|
|
set target_info(mvme,target) "s4"
|
1006 |
|
|
set target_info(mvme,serial) "tstty8"
|
1007 |
|
|
set target_info(mvme,netport) "truckin:1004"
|
1008 |
|
|
set target_info(mvme,baud) "9600"
|
1009 |
|
|
}
|
1010 |
|
|
}
|
1011 |
|
|
|
1012 |
|
|
In this case, we have support for several remote hosts for our
|
1013 |
|
|
m68k-aout cross compiler. Typically the remote Unix hosts run DejaGnu
|
1014 |
|
|
locally, but we also use them for debugging the testsuites when we find
|
1015 |
|
|
problems in running on remote hosts. Expect won't run on NT, so DejaGnu
|
1016 |
|
|
is run on the local build machine, and it'll connect to the NT host and
|
1017 |
|
|
run all the tests for this cross compiler on that host.
|
1018 |
|
|
|
1019 |
|
|
case "$host_triplet" in {
|
1020 |
|
|
"native" {
|
1021 |
|
|
}
|
1022 |
|
|
"i?86-*-linux*" { # Linux host
|
1023 |
|
|
set target_info(host,name) "linux-host"
|
1024 |
|
|
set target_info(host,config) $host_triplet
|
1025 |
|
|
set target_info(host,connect) rlogin
|
1026 |
|
|
set target_info(host,target) chinadoll
|
1027 |
|
|
}
|
1028 |
|
|
"i?86-*-winnt # NT host
|
1029 |
|
|
set target_info(host,name) "nt-host"
|
1030 |
|
|
set target_info(host,config) i386-unknown-winnt
|
1031 |
|
|
set target_info(host,connect) telnet
|
1032 |
|
|
set target_info(host,target) ripple
|
1033 |
|
|
}
|
1034 |
|
|
"hppa*-hp-hpux*" { # HP-UX host
|
1035 |
|
|
set target_info(host,name) "hpux-host"
|
1036 |
|
|
set target_info(host,config) $host_triplet
|
1037 |
|
|
set target_info(host,connect) rlogin
|
1038 |
|
|
set target_info(host,target) slipknot
|
1039 |
|
|
}
|
1040 |
|
|
"sparc-sun-sunos*" { # SunOS (sun4)
|
1041 |
|
|
set target_info(host,name) "sunos-host"
|
1042 |
|
|
set target_info(host,config) $host_triplet
|
1043 |
|
|
set target_info(host,connect) rlogin
|
1044 |
|
|
set target_info(host,target) darkstar
|
1045 |
|
|
}
|
1046 |
|
|
}
|
1047 |
|
|
|
1048 |
|
|
|
1049 |
|
|
File: dejagnu.info, Node: Local Config File, Next: Personal Config File, Prev: Master Config File, Up: Customizing
|
1050 |
|
|
|
1051 |
|
|
Local Config File
|
1052 |
|
|
-----------------
|
1053 |
|
|
|
1054 |
|
|
It is usually more convenient to keep these "manual overrides" in the
|
1055 |
|
|
`site.exp' local to each test directory, rather than in the "master"
|
1056 |
|
|
`site.exp' in the DejaGnu library.
|
1057 |
|
|
|
1058 |
|
|
All local `site.exp' usually files have two sections, separated by
|
1059 |
|
|
comment text. The first section is the part that is generated by
|
1060 |
|
|
`make'. It is essentially a collection of Tcl variable definitions
|
1061 |
|
|
based on `Makefile' environment variables. Since they are generated by
|
1062 |
|
|
`make', they contain the values as specified by `configure'. (You can
|
1063 |
|
|
also customize these values by using the `--site' option to
|
1064 |
|
|
`configure'.) In particular, this section contains the `Makefile'
|
1065 |
|
|
variables for host and target configuration data. Do not edit this
|
1066 |
|
|
first section; if you do, your changes are replaced next time you run
|
1067 |
|
|
`make'.
|
1068 |
|
|
|
1069 |
|
|
The first section starts with:
|
1070 |
|
|
|
1071 |
|
|
## these variables are automatically generated by make ##
|
1072 |
|
|
# Do not edit here. If you wish to override these values
|
1073 |
|
|
# add them to the last section
|
1074 |
|
|
|
1075 |
|
|
In the second section, you can override any default values (locally
|
1076 |
|
|
to DejaGnu) for all the variables. The second section can also contain
|
1077 |
|
|
your preferred defaults for all the command line options to `runtest'.
|
1078 |
|
|
This allows you to easily customize `runtest' for your preferences in
|
1079 |
|
|
each configured test-suite tree, so that you need not type options
|
1080 |
|
|
repeatedly on the command line. (The second section may also be empty,
|
1081 |
|
|
if you do not wish to override any defaults.)
|
1082 |
|
|
|
1083 |
|
|
The first section ends with this line:
|
1084 |
|
|
|
1085 |
|
|
## All variables above are generated by configure. Do Not Edit ##
|
1086 |
|
|
|
1087 |
|
|
You can make any changes under this line. If you wish to redefine a
|
1088 |
|
|
variable in the top section, then just put a duplicate value in this
|
1089 |
|
|
second section. Usually the values defined in this config file are
|
1090 |
|
|
related to the configuration of the test run. This is the ideal place to
|
1091 |
|
|
set the variables `host_triplet', `build_triplet', `target_triplet'.
|
1092 |
|
|
All other variables are tool dependant. ie for testing a compiler, the
|
1093 |
|
|
value for CC might be set to a freshly built binary, as opposed to one
|
1094 |
|
|
in the user's path.
|
1095 |
|
|
|
1096 |
|
|
|
1097 |
|
|
File: dejagnu.info, Node: Personal Config File, Prev: Local Config File, Up: Customizing
|
1098 |
|
|
|
1099 |
|
|
Personal Config File
|
1100 |
|
|
--------------------
|
1101 |
|
|
|
1102 |
|
|
The personal config file is used to customize `runtest's' behaviour
|
1103 |
|
|
for each person. It's typically used to set the user prefered setting
|
1104 |
|
|
for verbosity, and any experimental Tcl procedures. My personal
|
1105 |
|
|
`~/.dejagnurc' file looks like:
|
1106 |
|
|
|
1107 |
|
|
set all_flag 1
|
1108 |
|
|
set RLOGIN /usr/ucb/rlogin
|
1109 |
|
|
set RSH /usr/ucb/rsh
|
1110 |
|
|
|
1111 |
|
|
Here I set `all_flag' so I see all the test cases that PASS along
|
1112 |
|
|
with the ones that FAIL. I also set RLOGIN and `RSH' to the BSD
|
1113 |
|
|
version. I have `kerberos' installed, and when I rlogin to a target
|
1114 |
|
|
board, it usually isn't supported. So I use the non secure versions of
|
1115 |
|
|
these programs rather than the default that's in my path.
|
1116 |
|
|
|
1117 |
|
|
|
1118 |
|
|
File: dejagnu.info, Node: Internals, Next: Tests, Prev: Customizing, Up: Top
|
1119 |
|
|
|
1120 |
|
|
The DejaGnu Implementation
|
1121 |
|
|
**************************
|
1122 |
|
|
|
1123 |
|
|
DejaGnu is entirely written in `expect', which uses Tcl as a command
|
1124 |
|
|
language. `expect' serves as a very programmable shell; you can run
|
1125 |
|
|
any program, as with the usual Unix command shells--but once the
|
1126 |
|
|
program is started, your `expect' script has fully programmable control
|
1127 |
|
|
of its input and output. This does not just apply to the programs
|
1128 |
|
|
under test; `expect' can also run any auxiliary program, such as `diff'
|
1129 |
|
|
or `sh', with full control over its input and output.
|
1130 |
|
|
|
1131 |
|
|
DejaGnu itself is merely a framework for the set of test suites
|
1132 |
|
|
distributed separately for each GNU tool. Future releases of GNU tools
|
1133 |
|
|
will include even more tests, developed throughout the free software
|
1134 |
|
|
community.
|
1135 |
|
|
|
1136 |
|
|
`runtest' is the glue to tie together and manage the test scripts.
|
1137 |
|
|
The `runtest' program is actually a simple Bourne shell script that
|
1138 |
|
|
locates a copy of the `expect' shell and then starts the main Tcl code,
|
1139 |
|
|
`runtest.exp'. `runtest.exp' itself has these essential functions:
|
1140 |
|
|
|
1141 |
|
|
1. Parse the command line options, load the library files, and load
|
1142 |
|
|
the default configuration files.
|
1143 |
|
|
|
1144 |
|
|
2. Locating the individual test scripts. `runtest.exp' locates the
|
1145 |
|
|
tests by exploiting a straightforward naming convention based on
|
1146 |
|
|
the string you specify with the `--tool' option.
|
1147 |
|
|
|
1148 |
|
|
3. Providing an extended test environment, by defining additional Tcl
|
1149 |
|
|
procedures beyond those already in `expect'.
|
1150 |
|
|
|
1151 |
|
|
4. Locating target-dependent functions, to standardize the test
|
1152 |
|
|
environment across a wide variety of test platforms.
|
1153 |
|
|
|
1154 |
|
|
* Menu:
|
1155 |
|
|
|
1156 |
|
|
* Names:: Conventions for using tool names
|
1157 |
|
|
* Init Module:: Initialization module
|
1158 |
|
|
* DejaGnu Builtins:: DejaGnu provides these Tcl procedures
|
1159 |
|
|
* Target Dependent:: Procedures supplied by the init module
|
1160 |
|
|
* Cross Targets:: Remote targets supported
|
1161 |
|
|
* Input Files:: The files DejaGnu depends on
|
1162 |
|
|
* Output Files:: The files DejaGnu produces
|
1163 |
|
|
|