1 |
578 |
markom |
|
2 |
|
|
Running Tests
|
3 |
|
|
|
4 |
|
|
There are two ways to execute a test suite. The most
|
5 |
|
|
common way is when there is existing support in the
|
6 |
|
|
Makefile. This support consists of a
|
7 |
|
|
check target. The other way is to execute the
|
8 |
|
|
runtest program directly. To run
|
9 |
|
|
runtest directcly from the command line requires
|
10 |
|
|
either all the correct options, or the must be setup
|
11 |
|
|
correctly.
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
Make check
|
15 |
|
|
|
16 |
|
|
To run tests from an existing collection, first use
|
17 |
|
|
configure as usual to set up the
|
18 |
|
|
build directory. Then try typing:
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
make check
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
If the check target exists, it
|
25 |
|
|
usually saves you some trouble. For instance, it can set up any
|
26 |
|
|
auxiliary programs or other files needed by the tests. The most
|
27 |
|
|
common file the check builds is the
|
28 |
|
|
site.exp. The site.exp file contains
|
29 |
|
|
various variables that DejaGnu used to dertermine the
|
30 |
|
|
configuration of the program being tested. This is mostly for
|
31 |
|
|
supporting remote testing.
|
32 |
|
|
|
33 |
|
|
The check target is supported by GNU
|
34 |
|
|
Automake. To have DejaGnu support added to your
|
35 |
|
|
generated Makefile.in, just add the keyword
|
36 |
|
|
dejagnu to the AUTOMAKE_OPTIONS variable in your
|
37 |
|
|
Makefile.am file.
|
38 |
|
|
|
39 |
|
|
Once you have run make check to build
|
40 |
|
|
any auxiliary files, you can invoke the test driver
|
41 |
|
|
runtest directly to repeat the tests.
|
42 |
|
|
You will also have to execute runtest
|
43 |
|
|
directly for test collections with no
|
44 |
|
|
check target in the
|
45 |
|
|
Makefile.
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
Runtest
|
51 |
|
|
|
52 |
|
|
runtest is the executable test driver
|
53 |
|
|
for DejaGnu. You can specify two kinds of things on the
|
54 |
|
|
runtest command line: command line options,
|
55 |
|
|
and Tcl variables for the test scripts. The options are listed
|
56 |
|
|
alphabetically below.
|
57 |
|
|
|
58 |
|
|
runtest returns an exit code of
|
59 |
|
|
1 if any test has an unexpected result; otherwise
|
60 |
|
|
(if all tests pass or fail as expected) it returns 0
|
61 |
|
|
as the exit code.
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
Output States
|
65 |
|
|
|
66 |
|
|
runtest flags the outcome of each
|
67 |
|
|
test as one of these cases. for a
|
68 |
|
|
discussion of how POSIX specifies the meanings of these
|
69 |
|
|
cases.
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
PASS
|
74 |
|
|
The most desirable outcome: the test succeeded, and
|
75 |
|
|
was expected to succeed.
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
XPASS
|
80 |
|
|
A pleasant kind of failure: a test was expected to
|
81 |
|
|
fail, but succeeded. This may indicate progress; inspect the test
|
82 |
|
|
case to determine whether you should amend it to stop expecting
|
83 |
|
|
failure.
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
FAIL
|
88 |
|
|
A test failed, although it was expected to succeed.
|
89 |
|
|
This may indicate regress; inspect the test case and the failing
|
90 |
|
|
software to ocate the bug.
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
|
94 |
|
|
XFAIL
|
95 |
|
|
A test failed, but it was expected to fail. This
|
96 |
|
|
result indicates no change in a known bug. If a test fails because
|
97 |
|
|
the operating system where the test runs lacks some facility required
|
98 |
|
|
by the test, the outcome is UNSUPPORTED
|
99 |
|
|
instead.
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
UNRESOLVED
|
104 |
|
|
Output from a test requires manual inspection; the
|
105 |
|
|
test suite could not automatically determine the outcome. For
|
106 |
|
|
example, your tests can report this outcome is when a test does not
|
107 |
|
|
complete as expected.
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
UNTESTED
|
112 |
|
|
A test case is not yet complete, and in particular
|
113 |
|
|
cannot yet produce a PASS or
|
114 |
|
|
FAIL. You can also use this outcome in dummy
|
115 |
|
|
``tests'' that note explicitly the absence of a real test case for a
|
116 |
|
|
particular property.
|
117 |
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
UNSUPPORTED
|
121 |
|
|
A test depends on a conditionally available feature
|
122 |
|
|
that does not exist (in the configured testing environment). For
|
123 |
|
|
example, you can use this outcome to report on a test case that does
|
124 |
|
|
not work on a particular target because its operating system support
|
125 |
|
|
does not include a required subroutine.
|
126 |
|
|
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
runtest may also display the following messages:
|
130 |
|
|
|
131 |
|
|
|
132 |
|
|
|
133 |
|
|
ERROR
|
134 |
|
|
Indicates a major problem (detected by the test case
|
135 |
|
|
itself) in running the test. This is usually an unrecoverable error,
|
136 |
|
|
such as a missing file or loss of communication to the target. (POSIX
|
137 |
|
|
test suites should not emit this message; use
|
138 |
|
|
UNSUPPORTED, UNTESTED, or
|
139 |
|
|
UNRESOLVED instead, as
|
140 |
|
|
appropriate.)
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
|
144 |
|
|
WARNING
|
145 |
|
|
Indicates a possible problem in running the
|
146 |
|
|
test. Usually warnings correspond to recoverable errors, or display
|
147 |
|
|
an important message about the following tests.
|
148 |
|
|
|
149 |
|
|
|
150 |
|
|
|
151 |
|
|
NOTE
|
152 |
|
|
An informational message about the test
|
153 |
|
|
case.
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
Invoking Runtest
|
161 |
|
|
|
162 |
|
|
This is the full set of command line options that
|
163 |
|
|
runtest recognizes. Arguments may be
|
164 |
|
|
abbreviated to the shortest unique string.
|
165 |
|
|
|
166 |
|
|
|
167 |
|
|
|
168 |
|
|
(-a)
|
169 |
|
|
Display all test output. By default,
|
170 |
|
|
runtest shows only the output of tests that
|
171 |
|
|
produce unexpected results; that is, tests with status
|
172 |
|
|
FAIL (unexpected failure),
|
173 |
|
|
XPASS (unexpected success), or
|
174 |
|
|
ERROR (a severe error in the test case
|
175 |
|
|
itself). Specify --all to see output for tests
|
176 |
|
|
with status PASS (success, as expected)
|
177 |
|
|
XFAIL (failure, as expected), or
|
178 |
|
|
WARNING (minor error in the test case
|
179 |
|
|
itself).
|
180 |
|
|
|
181 |
|
|
|
182 |
|
|
|
183 |
|
|
|
184 |
|
|
string is a full configuration
|
185 |
|
|
``triple'' name as used by configure. This
|
186 |
|
|
is the type of machine DejaGnu and the tools to be tested are built
|
187 |
|
|
on. For a normal cross this is the same as the host, but for a
|
188 |
|
|
canadian cross, they are seperate.
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
|
192 |
|
|
|
193 |
|
|
string is a full configuration
|
194 |
|
|
``triple'' name as used by configure. Use this
|
195 |
|
|
option to override the default string recorded by your
|
196 |
|
|
configuration's choice of host. This choice does not change how
|
197 |
|
|
anything is actually configured unless --build is also specified; it
|
198 |
|
|
affects only DejaGnu procedures that compare the
|
199 |
|
|
host string with particular values. The procedures
|
200 |
|
|
ishost, istarget,
|
201 |
|
|
isnative, and setupxfail}
|
202 |
|
|
are affected by --host. In this usage,
|
203 |
|
|
host refers to the machine that the tests are to
|
204 |
|
|
be run on, which may not be the same as the
|
205 |
|
|
build machine. If --build
|
206 |
|
|
is also specified, then --host refers to the
|
207 |
|
|
machine that the tests wil, be run on, not the machine DejaGnu is run
|
208 |
|
|
on.
|
209 |
|
|
|
210 |
|
|
|
211 |
|
|
|
212 |
|
|
|
213 |
|
|
The host board to use.
|
214 |
|
|
|
215 |
|
|
|
216 |
|
|
|
217 |
|
|
|
218 |
|
|
Use this option to override the default setting
|
219 |
|
|
(running native tests). string is a full
|
220 |
|
|
configuration ``triple'' name of the form
|
221 |
|
|
cpu-vendor-os as used by
|
222 |
|
|
configure. This option changes the
|
223 |
|
|
configuration runtest uses for the default tool
|
224 |
|
|
names, and other setup information.
|
225 |
|
|
|
226 |
|
|
|
227 |
|
|
|
228 |
|
|
(-de)
|
229 |
|
|
Turns on the expect internal
|
230 |
|
|
debugging output. Debugging output is displayed as part of the
|
231 |
|
|
runtest output, and logged to a file called
|
232 |
|
|
dbg.log. The extra debugging output does
|
233 |
|
|
not appear on standard output, unless the
|
234 |
|
|
verbose level is greater than 2 (for instance, to see debug output
|
235 |
|
|
immediately, specify --debug-v -v}). The
|
236 |
|
|
debugging output shows all attempts at matching the test output of
|
237 |
|
|
the tool with the scripted patterns describing expected output. The
|
238 |
|
|
output generated with --strace also goes into
|
239 |
|
|
dbg.log.
|
240 |
|
|
|
241 |
|
|
|
242 |
|
|
|
243 |
|
|
(-he)
|
244 |
|
|
Prints out a short summary of the
|
245 |
|
|
runtest options, then exits (even if you also
|
246 |
|
|
specify other options).
|
247 |
|
|
|
248 |
|
|
|
249 |
|
|
|
250 |
|
|
|
251 |
|
|
The names of specific tests to
|
252 |
|
|
ignore.
|
253 |
|
|
|
254 |
|
|
|
255 |
|
|
|
256 |
|
|
|
257 |
|
|
Use path as the top directory
|
258 |
|
|
containing any auxiliary compiled test code. This defaults to
|
259 |
|
|
.. Use this option to locate pre-compiled test
|
260 |
|
|
code. You can normally prepare any auxiliary files needed with
|
261 |
|
|
make.
|
262 |
|
|
|
263 |
|
|
|
264 |
|
|
|
265 |
|
|
|
266 |
|
|
Write output logs in directory
|
267 |
|
|
path. The default is .},
|
268 |
|
|
the directory where you start
|
269 |
|
|
runtest. This option affects only the summary
|
270 |
|
|
and the detailed log files
|
271 |
|
|
tool.sum and
|
272 |
|
|
tool.log. The DejaGnu debug
|
273 |
|
|
log dbg.log always appears (when requested) in
|
274 |
|
|
the local directory.
|
275 |
|
|
|
276 |
|
|
|
277 |
|
|
|
278 |
|
|
|
279 |
|
|
Reboot the target board when
|
280 |
|
|
runtest initializes. Usually, when running tests
|
281 |
|
|
on a separate target board, it is safer to reboot the target to be
|
282 |
|
|
certain of its state. However, when developing test scripts,
|
283 |
|
|
rebooting takes a lot of time.
|
284 |
|
|
|
285 |
|
|
|
286 |
|
|
|
287 |
|
|
|
288 |
|
|
Use path as the top directory
|
289 |
|
|
for test scripts to run. runtest looks in this
|
290 |
|
|
directory for any subdirectory whose name begins with the toolname
|
291 |
|
|
(specified with --tool). For instance, with
|
292 |
|
|
--toolgdb}, runtest uses
|
293 |
|
|
tests in subdirectories gdb.* (with the usual
|
294 |
|
|
shell-like filename expansion). If you do not use
|
295 |
|
|
--srcdir, runtest looks for
|
296 |
|
|
test directories under the current working
|
297 |
|
|
directory.
|
298 |
|
|
|
299 |
|
|
|
300 |
|
|
|
301 |
|
|
|
302 |
|
|
Turn on internal tracing for
|
303 |
|
|
expect, to n levels deep. By adjusting the
|
304 |
|
|
level, you can control the extent to which your output expands
|
305 |
|
|
multi-level Tcl statements. This allows you to ignore some levels of
|
306 |
|
|
case or if statements.
|
307 |
|
|
Each procedure call or control structure counts as one ``level''. The
|
308 |
|
|
output is recorded in the same file, dbg.log,
|
309 |
|
|
used for output from --debug.
|
310 |
|
|
|
311 |
|
|
|
312 |
|
|
|
313 |
|
|
|
314 |
|
|
Connect to a target testing environment as specified
|
315 |
|
|
by type, if the target is not the computer
|
316 |
|
|
running runtest. For example, use
|
317 |
|
|
--connect to change the program used to connect
|
318 |
|
|
to a ``bare board'' boot monitor. The choices for
|
319 |
|
|
type in the DejaGnu 1.4 distribution are
|
320 |
|
|
rlogin, telnet,
|
321 |
|
|
rsh, tip,
|
322 |
|
|
kermit, and mondfe.
|
323 |
|
|
|
324 |
|
|
The default for this option depends on the configuration most
|
325 |
|
|
convenient communication method available, but often other
|
326 |
|
|
alternatives work as well; you may find it useful to try alternative
|
327 |
|
|
connect methods if you suspect a communication problem with your
|
328 |
|
|
testing target.
|
329 |
|
|
|
330 |
|
|
|
331 |
|
|
|
332 |
|
|
|
333 |
|
|
Set the default baud rate to something other than
|
334 |
|
|
9600. (Some serial interface programs, like tip,
|
335 |
|
|
use a separate initialization file instead of this
|
336 |
|
|
value.)
|
337 |
|
|
|
338 |
|
|
|
339 |
|
|
|
340 |
|
|
|
341 |
|
|
The list of target boards to run tests
|
342 |
|
|
on.
|
343 |
|
|
|
344 |
|
|
|
345 |
|
|
|
346 |
|
|
|
347 |
|
|
Specifies which test suite to run, and what
|
348 |
|
|
initialization module to use. is used
|
349 |
|
|
only for these two purposes. It is
|
350 |
|
|
not used to name the executable program to
|
351 |
|
|
test. Executable tool names (and paths) are recorded in
|
352 |
|
|
site.exp and you can override them by specifying
|
353 |
|
|
Tcl variables on the command line.
|
354 |
|
|
|
355 |
|
|
For example, including " gcc" on the
|
356 |
|
|
runtest command line runs tests from all test
|
357 |
|
|
subdirectories whose names match gcc.*, and uses
|
358 |
|
|
one of the initialization modules named
|
359 |
|
|
config/*-gcc.exp. To specify the name of the
|
360 |
|
|
compiler (perhaps as an alternative path to what
|
361 |
|
|
runtest would use by default), use
|
362 |
|
|
GCC=binname on the runtest
|
363 |
|
|
command line.
|
364 |
|
|
|
365 |
|
|
|
366 |
|
|
|
367 |
|
|
|
368 |
|
|
The path to the tool executable to
|
369 |
|
|
test.
|
370 |
|
|
|
371 |
|
|
|
372 |
|
|
|
373 |
|
|
|
374 |
|
|
A list of additional options to pass to the
|
375 |
|
|
tool.
|
376 |
|
|
|
377 |
|
|
|
378 |
|
|
|
379 |
|
|
(-v)
|
380 |
|
|
Turns on more output. Repeating this option increases
|
381 |
|
|
the amount of output displayed. Level one (-v)
|
382 |
|
|
is simply test output. Level two (-v-v}) shows
|
383 |
|
|
messages on options, configuration, and process control. Verbose
|
384 |
|
|
messages appear in the detailed (*.log) log
|
385 |
|
|
file, but not in the summary (*.sum) log
|
386 |
|
|
file.
|
387 |
|
|
|
388 |
|
|
|
389 |
|
|
|
390 |
|
|
(-V)
|
391 |
|
|
Prints out the version numbers of DejaGnu,
|
392 |
|
|
expect and Tcl, and exits without running any
|
393 |
|
|
tests.
|
394 |
|
|
|
395 |
|
|
|
396 |
|
|
|
397 |
|
|
|
398 |
|
|
Start the internal Tcl debugger. The Tcl debugger
|
399 |
|
|
supports breakpoints, single stepping, and other common debugging
|
400 |
|
|
activities. See the document "Debugger for Tcl Applications} by Don
|
401 |
|
|
Libes. (Distributed in PostScript form with
|
402 |
|
|
expect as the file
|
403 |
|
|
expect/tcl-debug.ps.. If you specify
|
404 |
|
|
-D1, the expect shell stops
|
405 |
|
|
at a breakpoint as soon as DejaGnu invokes it. If you specify
|
406 |
|
|
-D0, DejaGnu starts as usual, but you can enter
|
407 |
|
|
the debugger by sending an interrupt (e.g. by typing
|
408 |
|
|
Cc).
|
409 |
|
|
|
410 |
|
|
|
411 |
|
|
|
412 |
|
|
|
413 |
|
|
testfile.exp[=arg(s)]
|
414 |
|
|
Specify the names of testsuites to run. By default,
|
415 |
|
|
runtest runs all tests for the tool, but you can
|
416 |
|
|
restrict it to particular testsuites by giving the names of the
|
417 |
|
|
.exp expect scripts that control
|
418 |
|
|
them. testsuite.exp may not include path
|
419 |
|
|
information; use plain filenames.
|
420 |
|
|
|
421 |
|
|
|
422 |
|
|
|
423 |
|
|
testfile.exp="testfile1 ..."
|
424 |
|
|
Specify a subset of tests in a suite to run. For
|
425 |
|
|
compiler or assembler tests, which often use a single
|
426 |
|
|
.exp script covering many different source
|
427 |
|
|
files, this option allows you to further restrict the tests by
|
428 |
|
|
listing particular source files to compile. Some tools even support
|
429 |
|
|
wildcards here. The wildcards supported depend upon the tool, but
|
430 |
|
|
typically they are ?, *,
|
431 |
|
|
and [chars].
|
432 |
|
|
|
433 |
|
|
|
434 |
|
|
|
435 |
|
|
tclvar=value
|
436 |
|
|
You can define Tcl variables for use by your test
|
437 |
|
|
scripts in the same style used with make for
|
438 |
|
|
environment variables. For example, runtest
|
439 |
|
|
GDB=gdb.old defines a variable called
|
440 |
|
|
GDB; when your scripts refer to
|
441 |
|
|
$GDB in this run, they use the value
|
442 |
|
|
gdb.old.
|
443 |
|
|
|
444 |
|
|
The default Tcl variables used for most tools are defined in
|
445 |
|
|
the main DejaGnu Makefile; their values are
|
446 |
|
|
captured in the site.exp file.
|
447 |
|
|
|
448 |
|
|
|
449 |
|
|
|
450 |
|
|
|
451 |
|
|
|
452 |
|
|
Common Options
|
453 |
|
|
|
454 |
|
|
Typically, you don't need must to use any command-line options.
|
455 |
|
|
used is only required when there are more than
|
456 |
|
|
one test suite in the same directory. The default options are in the
|
457 |
|
|
local site.exp file, created by "make site.exp".
|
458 |
|
|
|
459 |
|
|
For example, if the directory gdb/testsuite
|
460 |
|
|
contains a collection of DejaGnu tests for GDB, you can run them like
|
461 |
|
|
this:
|
462 |
|
|
|
463 |
|
|
|
464 |
|
|
eg$ cd gdb/testsuite
|
465 |
|
|
eg$ runtest --tool gdb
|
466 |
|
|
|
467 |
|
|
|
468 |
|
|
Test output follows, ending with:
|
469 |
|
|
|
470 |
|
|
|
471 |
|
|
=== gdb Summary ===
|
472 |
|
|
|
473 |
|
|
# of expected passes 508
|
474 |
|
|
# of expected failures 103
|
475 |
|
|
/usr/latest/bin/gdb version 4.14.4 -nx
|
476 |
|
|
|
477 |
|
|
|
478 |
|
|
You can use the option --srcdir to point to
|
479 |
|
|
some other directory containing a collection of tests:
|
480 |
|
|
|
481 |
|
|
|
482 |
|
|
eg$ runtest--srcdir /devo/gdb/testsuite
|
483 |
|
|
|
484 |
|
|
|
485 |
|
|
By default, runtest prints only the
|
486 |
|
|
names of the tests it runs, output from any tests that have unexpected
|
487 |
|
|
results, and a summary showing how many tests passed and how many
|
488 |
|
|
failed. To display output from all tests (whether or not they behave
|
489 |
|
|
as expected), use the --all option. For more
|
490 |
|
|
verbose output about processes being run, communication, and so on, use
|
491 |
|
|
--verbose. To see even more output, use multiple
|
492 |
|
|
--verbose options. for a more detailed explanation
|
493 |
|
|
of each runtest option.
|
494 |
|
|
|
495 |
|
|
Test output goes into two files in your current directory:
|
496 |
|
|
summary output in tool.sum,
|
497 |
|
|
and detailed output in
|
498 |
|
|
tool.log. (tool
|
499 |
|
|
refers to the collection of tests; for example, after a run with
|
500 |
|
|
--tool gdb, look for output files
|
501 |
|
|
gdb.sum and gdb.log.)
|
502 |
|
|
|
503 |
|
|
|
504 |
|
|
|
505 |
|
|
|
506 |
|
|
|
507 |
|
|
The files DejaGnu produces.
|
508 |
|
|
|
509 |
|
|
DejaGnu always writes two kinds of output files: summary
|
510 |
|
|
logs and detailed logs. The contents of both of these are
|
511 |
|
|
determined by your tests.
|
512 |
|
|
|
513 |
|
|
For troubleshooting, a third kind of output file is useful:
|
514 |
|
|
use to request an output file showing
|
515 |
|
|
details of what Expect is doing
|
516 |
|
|
internally.
|
517 |
|
|
|
518 |
|
|
|
519 |
|
|
Summary File
|
520 |
|
|
|
521 |
|
|
DejaGnu always produces a summary output file
|
522 |
|
|
tool.sum. This summary shows the names of
|
523 |
|
|
all test files run; for each test file, one line of output from
|
524 |
|
|
each pass command (showing status
|
525 |
|
|
PASS or XPASS) or
|
526 |
|
|
fail command (status
|
527 |
|
|
FAIL or XFAIL);
|
528 |
|
|
trailing summary statistics that count passing and failing tests
|
529 |
|
|
(expected and unexpected); and the full pathname and version
|
530 |
|
|
number of the tool tested. (All possible outcomes, and all
|
531 |
|
|
errors, are always reflected in the summary output file,
|
532 |
|
|
regardless of whether or not you specify .)
|
533 |
|
|
|
534 |
|
|
If any of your tests use the procedures
|
535 |
|
|
unresolved, unsupported,
|
536 |
|
|
or runtested, the summary output also
|
537 |
|
|
tabulates the corresponding outcomes.
|
538 |
|
|
|
539 |
|
|
For example, after runtest --tool
|
540 |
|
|
binutils, look for a summary log in
|
541 |
|
|
binutils.sum. Normally, DejaGnu writes this
|
542 |
|
|
file in your current working directory; use the
|
543 |
|
|
option to select a different
|
544 |
|
|
directory.
|
545 |
|
|
|
546 |
|
|
|
547 |
|
|
Here is a short sample summary log
|
548 |
|
|
|
549 |
|
|
|
550 |
|
|
Test Run By rob on Mon May 25 21:40:57 PDT 1992
|
551 |
|
|
=== gdb tests ===
|
552 |
|
|
Running ./gdb.t00/echo.exp ...
|
553 |
|
|
PASS: Echo test
|
554 |
|
|
Running ./gdb.all/help.exp ...
|
555 |
|
|
PASS: help add-symbol-file
|
556 |
|
|
PASS: help aliases
|
557 |
|
|
PASS: help breakpoint "bre" abbreviation
|
558 |
|
|
FAIL: help run "r" abbreviation
|
559 |
|
|
Running ./gdb.t10/crossload.exp ...
|
560 |
|
|
PASS: m68k-elf (elf-big) explicit format; loaded
|
561 |
|
|
XFAIL: mips-ecoff (ecoff-bigmips) "ptype v_signed_char" signed C types
|
562 |
|
|
=== gdb Summary ===
|
563 |
|
|
# of expected passes 5
|
564 |
|
|
# of expected failures 1
|
565 |
|
|
# of unexpected failures 1
|
566 |
|
|
/usr/latest/bin/gdb version 4.6.5 -q
|
567 |
|
|
|
568 |
|
|
|
569 |
|
|
|
570 |
|
|
|
571 |
|
|
|
572 |
|
|
|
573 |
|
|
Log File
|
574 |
|
|
|
575 |
|
|
DejaGnu also saves a detailed log file
|
576 |
|
|
tool.log, showing any output generated by
|
577 |
|
|
tests as well as the summary output. For example, after
|
578 |
|
|
runtest --tool binutils, look for a detailed
|
579 |
|
|
log in binutils.log. Normally, DejaGnu
|
580 |
|
|
writes this file in your current working directory; use the
|
581 |
|
|
option to select a different
|
582 |
|
|
directory.
|
583 |
|
|
|
584 |
|
|
|
585 |
|
|
|
586 |
|
|
Here is a brief example showing a detailed log for
|
587 |
|
|
G++ tests
|
588 |
|
|
|
589 |
|
|
|
590 |
|
|
Test Run By rob on Mon May 25 21:40:43 PDT 1992
|
591 |
|
|
|
592 |
|
|
=== g++ tests ===
|
593 |
|
|
|
594 |
|
|
--- Running ./g++.other/t01-1.exp ---
|
595 |
|
|
PASS: operate delete
|
596 |
|
|
|
597 |
|
|
--- Running ./g++.other/t01-2.exp ---
|
598 |
|
|
FAIL: i960 bug EOF
|
599 |
|
|
p0000646.C: In function `int warn_return_1 ()':
|
600 |
|
|
p0000646.C:109: warning: control reaches end of non-void function
|
601 |
|
|
p0000646.C: In function `int warn_return_arg (int)':
|
602 |
|
|
p0000646.C:117: warning: control reaches end of non-void function
|
603 |
|
|
p0000646.C: In function `int warn_return_sum (int, int)':
|
604 |
|
|
p0000646.C:125: warning: control reaches end of non-void function
|
605 |
|
|
p0000646.C: In function `struct foo warn_return_foo ()':
|
606 |
|
|
p0000646.C:132: warning: control reaches end of non-void function
|
607 |
|
|
|
608 |
|
|
--- Running ./g++.other/t01-4.exp ---
|
609 |
|
|
FAIL: abort
|
610 |
|
|
900403_04.C:8: zero width for bit-field `foo'
|
611 |
|
|
--- Running ./g++.other/t01-3.exp ---
|
612 |
|
|
FAIL: segment violation
|
613 |
|
|
900519_12.C:9: parse error before `;'
|
614 |
|
|
900519_12.C:12: Segmentation violation
|
615 |
|
|
/usr/latest/bin/gcc: Internal compiler error: program cc1plus got fatal signal
|
616 |
|
|
|
617 |
|
|
=== g++ Summary ===
|
618 |
|
|
|
619 |
|
|
# of expected passes 1
|
620 |
|
|
# of expected failures 3
|
621 |
|
|
/usr/latest/bin/g++ version cygnus-2.0.1
|
622 |
|
|
|
623 |
|
|
|
624 |
|
|
|
625 |
|
|
|
626 |
|
|
|
627 |
|
|
|
628 |
|
|
Debug Log File
|
629 |
|
|
|
630 |
|
|
With the option, you can request
|
631 |
|
|
a log file showing the output from
|
632 |
|
|
Expect itself, running in debugging
|
633 |
|
|
mode. This file (dbg.log, in the directory
|
634 |
|
|
where you start runtest) shows each pattern
|
635 |
|
|
Expect considers in analyzing test
|
636 |
|
|
output.
|
637 |
|
|
|
638 |
|
|
This file reflects each send command,
|
639 |
|
|
showing the string sent as input to the tool under test; and
|
640 |
|
|
each Expect command, showing each
|
641 |
|
|
pattern it compares with the tool output.
|
642 |
|
|
|
643 |
|
|
|
644 |
|
|
The log messages begin with a message of the form
|
645 |
|
|
|
646 |
|
|
|
647 |
|
|
|
648 |
|
|
expect: does {tool output} (spawn_id n)
|
649 |
|
|
match pattern {expected pattern}?
|
650 |
|
|
|
651 |
|
|
|
652 |
|
|
|
653 |
|
|
|
654 |
|
|
For every unsuccessful match,
|
655 |
|
|
Expect issues a
|
656 |
|
|
no after this message; if other patterns
|
657 |
|
|
are specified for the same Expect
|
658 |
|
|
command, they are reflected also, but without the first part of
|
659 |
|
|
the message (expect... match pattern).
|
660 |
|
|
|
661 |
|
|
When Expect finds a match, the
|
662 |
|
|
log for the successful match ends with yes,
|
663 |
|
|
followed by a record of the Expect
|
664 |
|
|
variables set to describe a successful match.
|
665 |
|
|
|
666 |
|
|
|
667 |
|
|
Here is an excerpt from the debugging log for a
|
668 |
|
|
GDB test:
|
669 |
|
|
|
670 |
|
|
|
671 |
|
|
send: sent {break gdbme.c:34\n} to spawn id 6
|
672 |
|
|
expect: does {} (spawn_id 6) match pattern {Breakpoint.*at.* file
|
673 |
|
|
gdbme.c, line 34.*\(gdb\) $}? no
|
674 |
|
|
{.*\(gdb\) $}? no
|
675 |
|
|
expect: does {} (spawn_id 0) match pattern {return} ? no
|
676 |
|
|
{\(y or n\) }? no
|
677 |
|
|
{buffer_full}? no
|
678 |
|
|
{virtual}? no
|
679 |
|
|
{memory}? no
|
680 |
|
|
{exhausted}? no
|
681 |
|
|
{Undefined}? no
|
682 |
|
|
{command}? no
|
683 |
|
|
break gdbme.c:34
|
684 |
|
|
Breakpoint 8 at 0x23d8: file gdbme.c, line 34.
|
685 |
|
|
(gdb) expect: does {break gdbme.c:34\r\nBreakpoint 8 at 0x23d8:
|
686 |
|
|
file gdbme.c, line 34.\r\n(gdb) } (spawn_id 6) match pattern
|
687 |
|
|
{Breakpoint.*at.* file gdbme.c, line 34.*\(gdb\) $}? yes
|
688 |
|
|
expect: set expect_out(0,start) {18}
|
689 |
|
|
expect: set expect_out(0,end) {71}
|
690 |
|
|
expect: set expect_out(0,string) {Breakpoint 8 at 0x23d8: file
|
691 |
|
|
gdbme.c, line 34.\r\n(gdb) }
|
692 |
|
|
epect: set expect_out(spawn_id) {6}
|
693 |
|
|
expect: set expect_out(buffer) {break gdbme.c:34\r\nBreakpoint 8
|
694 |
|
|
at 0x23d8: file gdbme.c, line 34.\r\n(gdb) }
|
695 |
|
|
PASS: 70 0 breakpoint line number in file
|
696 |
|
|
|
697 |
|
|
|
698 |
|
|
|
699 |
|
|
This example exhibits three properties of
|
700 |
|
|
Expect and
|
701 |
|
|
DejaGnu that might be surprising at
|
702 |
|
|
first glance:
|
703 |
|
|
|
704 |
|
|
|
705 |
|
|
Empty output for the first attempted match. The
|
706 |
|
|
first set of attempted matches shown ran against the output
|
707 |
|
|
{} --- that is, no
|
708 |
|
|
output. Expect begins
|
709 |
|
|
attempting to match the patterns supplied immediately; often,
|
710 |
|
|
the first pass is against incomplete output (or completely
|
711 |
|
|
before all output, as in this case).
|
712 |
|
|
|
713 |
|
|
Interspersed tool output. The beginning of
|
714 |
|
|
the log entry for the second attempted match may be hard to
|
715 |
|
|
spot: this is because the prompt {(gdb) }
|
716 |
|
|
appears on the same line, just before the
|
717 |
|
|
expect: that marks the beginning of the
|
718 |
|
|
log entry.
|
719 |
|
|
|
720 |
|
|
Fail-safe patterns. Many of the patterns
|
721 |
|
|
tested are fail-safe patterns provided by
|
722 |
|
|
GDB testing utilities, to reduce
|
723 |
|
|
possible indeterminacy. It is useful to anticipate potential
|
724 |
|
|
variations caused by extreme system conditions
|
725 |
|
|
(GDB might issue the message
|
726 |
|
|
virtual memory exhausted in rare
|
727 |
|
|
circumstances), or by changes in the tested program
|
728 |
|
|
(Undefined command is the likeliest
|
729 |
|
|
outcome if the name of a tested command changes).
|
730 |
|
|
|
731 |
|
|
The pattern {return} is a
|
732 |
|
|
particularly interesting fail-safe to notice; it checks for an
|
733 |
|
|
unexpected RET prompt. This may happen,
|
734 |
|
|
for example, if the tested tool can filter output through a
|
735 |
|
|
pager.
|
736 |
|
|
|
737 |
|
|
These fail-safe patterns (like the debugging log itself)
|
738 |
|
|
are primarily useful while developing test scripts. Use the
|
739 |
|
|
error procedure to make the actions for
|
740 |
|
|
fail-safe patterns produce messages starting with
|
741 |
|
|
ERROR on standard output, and in the
|
742 |
|
|
detailed log file.
|
743 |
|
|
|
744 |
|
|
|
745 |
|
|
|
746 |
|
|
|
747 |
|
|
|
748 |
|
|
|
749 |
|
|
Customizing DejaGnu
|
750 |
|
|
|
751 |
|
|
The site configuration file, site.exp,
|
752 |
|
|
captures configuration-dependent values and propagates them to the
|
753 |
|
|
DejaGnu test environment using Tcl variables. This ties the
|
754 |
|
|
DejaGnu test scripts into the configure and
|
755 |
|
|
make programs. If this file is setup correctly,
|
756 |
|
|
it is possible to execute a test suite merely by typing
|
757 |
|
|
runtest.
|
758 |
|
|
|
759 |
|
|
DejaGnu supports two site.exp
|
760 |
|
|
files. The multiple instances of site.exp are
|
761 |
|
|
loaded in a fixed order built into DejaGnu. The first file loaded
|
762 |
|
|
is the local file site.exp, and then the
|
763 |
|
|
optional global site.exp file as
|
764 |
|
|
pointed to by the DEJAGNU environment
|
765 |
|
|
variable.
|
766 |
|
|
|
767 |
|
|
There is an optional master
|
768 |
|
|
site.exp, capturing configuration values that
|
769 |
|
|
apply to DejaGnu across the board, in each configuration-specific
|
770 |
|
|
subdirectory of the DejaGnu library directory.
|
771 |
|
|
runtest loads these values first. The master
|
772 |
|
|
site.exp contains the default values for all
|
773 |
|
|
targets and hosts supported by DejaGnu. This master file is
|
774 |
|
|
identified by setting the environment variable
|
775 |
|
|
DEJAGNU to the name of the file. This is also
|
776 |
|
|
refered to as the ``global'' config file.
|
777 |
|
|
|
778 |
|
|
Any directory containing a configured test suite also has a
|
779 |
|
|
local site.exp, capturing configuration values
|
780 |
|
|
specific to the tool under test. Since runtest
|
781 |
|
|
loads these values last, the individual test configuration can
|
782 |
|
|
either rely on and use, or override, any of the global values from
|
783 |
|
|
the global site.exp file.
|
784 |
|
|
|
785 |
|
|
You can usually generate or update the testsuite's local
|
786 |
|
|
site.exp by typing make
|
787 |
|
|
site.exp in the test suite directory, after the test
|
788 |
|
|
suite is configured.
|
789 |
|
|
|
790 |
|
|
You can also have a file in your home directory called
|
791 |
|
|
.dejagnurc. This gets loaded first before the
|
792 |
|
|
other config files. Usually this is used for personal stuff, like
|
793 |
|
|
setting the all_flag so all the output gets
|
794 |
|
|
printed, or your own verbosity levels. This file is usually
|
795 |
|
|
restricted to setting command line options.
|
796 |
|
|
|
797 |
|
|
You can further override the default values in a
|
798 |
|
|
user-editable section of any site.exp, or by
|
799 |
|
|
setting variables on the runtest command
|
800 |
|
|
line.
|
801 |
|
|
|
802 |
|
|
|
803 |
|
|
Local Config File
|
804 |
|
|
|
805 |
|
|
It is usually more convenient to keep these manual
|
806 |
|
|
overrides in the site.exp
|
807 |
|
|
local to each test directory, rather than in the global
|
808 |
|
|
site.exp in the installed DejaGnu
|
809 |
|
|
library. This file is mostly for supplying tool specific info
|
810 |
|
|
that is required by the test suite.
|
811 |
|
|
|
812 |
|
|
All local site.exp files have
|
813 |
|
|
two sections, separated by comment text. The first section is
|
814 |
|
|
the part that is generated by make. It is
|
815 |
|
|
essentially a collection of Tcl variable definitions based on
|
816 |
|
|
Makefile environment variables. Since they
|
817 |
|
|
are generated by make, they contain the
|
818 |
|
|
values as specified by configure. (You can
|
819 |
|
|
also customize these values by using the
|
820 |
|
|
option to configure.) In particular, this
|
821 |
|
|
section contains the Makefile
|
822 |
|
|
variables for host and target configuration data. Do not edit
|
823 |
|
|
this first section; if you do, your changes are replaced next
|
824 |
|
|
time you run make.
|
825 |
|
|
|
826 |
|
|
|
827 |
|
|
The first section starts with
|
828 |
|
|
|
829 |
|
|
|
830 |
|
|
## these variables are automatically generated by make ##
|
831 |
|
|
# Do not edit here. If you wish to override these values
|
832 |
|
|
# add them to the last section
|
833 |
|
|
|
834 |
|
|
|
835 |
|
|
|
836 |
|
|
In the second section, you can override any default values
|
837 |
|
|
(locally to DejaGnu) for all the variables. The second section
|
838 |
|
|
can also contain your preferred defaults for all the command
|
839 |
|
|
line options to runtest. This allows you to
|
840 |
|
|
easily customize runtest for your preferences
|
841 |
|
|
in each configured test-suite tree, so that you need not type
|
842 |
|
|
options repeatedly on the command line. (The second section may
|
843 |
|
|
also be empty, if you do not wish to override any defaults.)
|
844 |
|
|
|
845 |
|
|
|
846 |
|
|
The first section ends with this line
|
847 |
|
|
|
848 |
|
|
|
849 |
|
|
## All variables above are generated by configure. Do Not Edit ##
|
850 |
|
|
|
851 |
|
|
|
852 |
|
|
|
853 |
|
|
You can make any changes under this line. If you wish to
|
854 |
|
|
redefine a variable in the top section, then just put a
|
855 |
|
|
duplicate value in this second section. Usually the values
|
856 |
|
|
defined in this config file are related to the configuration of
|
857 |
|
|
the test run. This is the ideal place to set the variables
|
858 |
|
|
host_triplet, build_triplet,
|
859 |
|
|
target_triplet. All other variables are tool
|
860 |
|
|
dependant. ie for testing a compiler, the value for
|
861 |
|
|
CC might be set to a freshly built binary, as
|
862 |
|
|
opposed to one in the user's path.
|
863 |
|
|
|
864 |
|
|
Here's an example local site.exp file, as used for
|
865 |
|
|
GCC/G++ testing.
|
866 |
|
|
|
867 |
|
|
|
868 |
|
|
Local Config File
|
869 |
|
|
|
870 |
|
|
|
871 |
|
|
## these variables are automatically generated by make ##
|
872 |
|
|
# Do not edit here. If you wish to override these values
|
873 |
|
|
# add them to the last section
|
874 |
|
|
set rootme "/build/devo-builds/i586-pc-linux-gnulibc1/gcc"
|
875 |
|
|
set host_triplet i586-pc-linux-gnulibc1
|
876 |
|
|
set build_triplet i586-pc-linux-gnulibc1
|
877 |
|
|
set target_triplet i586-pc-linux-gnulibc1
|
878 |
|
|
set target_alias i586-pc-linux-gnulibc1
|
879 |
|
|
set CFLAGS ""
|
880 |
|
|
set CXXFLAGS "-I/build/devo-builds/i586-pc-linux-gnulibc1/gcc/../libio -I$srcdir/../libg++/src -I$srcdir/../libio -I$srcdir/../libstdc++ -I$srcdir/../libstdc++/stl -L/build/devo-builds/i586-pc-linux-gnulibc1/gcc/../libg++ -L/build/devo-builds/i586-pc-linux-gnulibc1/gcc/../libstdc++"
|
881 |
|
|
append LDFLAGS " -L/build/devo-builds/i586-pc-linux-gnulibc1/gcc/../ld"
|
882 |
|
|
set tmpdir /build/devo-builds/i586-pc-linux-gnulibc1/gcc/testsuite
|
883 |
|
|
set srcdir "${srcdir}/testsuite"
|
884 |
|
|
## All variables above are generated by configure. Do Not Edit ##
|
885 |
|
|
|
886 |
|
|
|
887 |
|
|
|
888 |
|
|
|
889 |
|
|
This file defines the required fields for a local config
|
890 |
|
|
file, namely the three config triplets, and the srcdir. It also
|
891 |
|
|
defines several other Tcl variables that are used exclusivly by
|
892 |
|
|
the GCC test suite. For most test cases, the CXXFLAGS and LDFLAGS
|
893 |
|
|
are supplied by DejaGnu itself for cross testing, but to test a
|
894 |
|
|
compiler, GCC needs to manipulate these itself.
|
895 |
|
|
|
896 |
|
|
|
897 |
|
|
|
898 |
|
|
Global Config File
|
899 |
|
|
|
900 |
|
|
The master config file is where all the target specific
|
901 |
|
|
config variables get set for a whole site get set. The idea is
|
902 |
|
|
that for a centralized testing lab where people have to share a
|
903 |
|
|
target between multiple developers. There are settings for both
|
904 |
|
|
remote targets and remote hosts. Here's an example of a Master
|
905 |
|
|
Config File (also called the Global config file) for a
|
906 |
|
|
canadian cross. A canadian cross is when
|
907 |
|
|
you build and test a cross compiler on a machine other than the
|
908 |
|
|
one it's to be hosted on.
|
909 |
|
|
|
910 |
|
|
Here we have the config settings for our California
|
911 |
|
|
office. Note that all config values are site dependant. Here we
|
912 |
|
|
have two sets of values that we use for testing m68k-aout cross
|
913 |
|
|
compilers. As both of these target boards has a different
|
914 |
|
|
debugging protocol, we test on both of them in sequence.
|
915 |
|
|
|
916 |
|
|
|
917 |
|
|
Global Config file
|
918 |
|
|
|
919 |
|
|
|
920 |
|
|
|
921 |
|
|
# Make sure we look in the right place for the board description files.
|
922 |
|
|
if ![info exists boards_dir] {
|
923 |
|
|
set boards_dir {}
|
924 |
|
|
}
|
925 |
|
|
lappend boards_dir "/nfs/cygint/s1/cygnus/dejagnu/boards"
|
926 |
|
|
|
927 |
|
|
verbose "Global Config File: target_triplet is $target_triplet" 2
|
928 |
|
|
global target_list
|
929 |
|
|
|
930 |
|
|
case "$target_triplet" in {
|
931 |
|
|
{ "native" } {
|
932 |
|
|
set target_list "unix"
|
933 |
|
|
}
|
934 |
|
|
{ "sparc64-*elf" } {
|
935 |
|
|
set target_list "sparc64-sim"
|
936 |
|
|
}
|
937 |
|
|
{ "mips-*elf" } {
|
938 |
|
|
set target_list "mips-sim wilma barney"
|
939 |
|
|
}
|
940 |
|
|
{ "mips-lsi-elf" } {
|
941 |
|
|
set target_list "mips-lsi-sim{,soft-float,el}"
|
942 |
|
|
}
|
943 |
|
|
{ "sh-*hms" } {
|
944 |
|
|
set target_list { "sh-hms-sim" "bloozy" }
|
945 |
|
|
}
|
946 |
|
|
}
|
947 |
|
|
|
948 |
|
|
|
949 |
|
|
|
950 |
|
|
In this case, we have support for several cross compilers,
|
951 |
|
|
that all run on this host. For testing on operating systems that
|
952 |
|
|
don't support Expect, DejaGnu can be run on the local build
|
953 |
|
|
machine, and it can connect to the remote host and run all the
|
954 |
|
|
tests for this cross compiler on that host. All the remote OS
|
955 |
|
|
requires is a working telnetd.
|
956 |
|
|
|
957 |
|
|
As you can see, all one does is set the variable
|
958 |
|
|
target_list to the list of targets and options to
|
959 |
|
|
test. The simple settings, like for
|
960 |
|
|
sparc64-elf only require setting the name of
|
961 |
|
|
the single board config file. The mips-elf
|
962 |
|
|
target is more complicated. Here it sets the list to three target
|
963 |
|
|
boards. One is the default mips target, and both
|
964 |
|
|
wilma barney are
|
965 |
|
|
symbolic names for other mips boards. Symbolic names are covered
|
966 |
|
|
in the chapter. The more complicated
|
967 |
|
|
example is the one for mips-lsi-elf. This one
|
968 |
|
|
runs the tests with multiple iterations using all possible
|
969 |
|
|
combinations of the and the
|
970 |
|
|
(little endian) option. Needless to say,
|
971 |
|
|
this last feature is mostly compiler specific.
|
972 |
|
|
|
973 |
|
|
|
974 |
|
|
|
975 |
|
|
|
976 |
|
|
Board Config File
|
977 |
|
|
|
978 |
|
|
The board config file is where board specfic config data
|
979 |
|
|
is stored. A board config file contains all the higher-level
|
980 |
|
|
configuration settings. There is a rough inheritance scheme, where it is
|
981 |
|
|
possible to base a new board description file on an existing one. There
|
982 |
|
|
are also collections of custom procedures for common environments. For
|
983 |
|
|
more information on adding a new board config file, go to the
|
984 |
|
|
linkend=addboard> chapter.
|
985 |
|
|
|
986 |
|
|
An example board config file for a GNU simulator is as
|
987 |
|
|
follows. set_board_info is a procedure that sets the
|
988 |
|
|
field name to the specified value. The procedures in square brackets
|
989 |
|
|
[] are helper procedures. Thes
|
990 |
|
|
are used to find parts of a tool chain required to build an executable
|
991 |
|
|
image that may reside in various locations. This is mostly of use for
|
992 |
|
|
when the startup code, the standard C lobraries, or the tool chain itself
|
993 |
|
|
is part of your build tree.
|
994 |
|
|
|
995 |
|
|
|
996 |
|
|
Board Config File
|
997 |
|
|
|
998 |
|
|
|
999 |
|
|
# This is a list of toolchains that are supported on this board.
|
1000 |
|
|
set_board_info target_install {sparc64-elf}
|
1001 |
|
|
|
1002 |
|
|
# Load the generic configuration for this board. This will define any
|
1003 |
|
|
# routines needed by the tool to communicate with the board.
|
1004 |
|
|
load_generic_config "sim"
|
1005 |
|
|
|
1006 |
|
|
# We need this for find_gcc and *_include_flags/*_link_flags.
|
1007 |
|
|
load_base_board_description "basic-sim"
|
1008 |
|
|
|
1009 |
|
|
# Use long64 by default.
|
1010 |
|
|
process_multilib_options "long64"
|
1011 |
|
|
|
1012 |
|
|
setup_sim sparc64
|
1013 |
|
|
|
1014 |
|
|
# We only support newlib on this target. We assume that all multilib
|
1015 |
|
|
# options have been specified before we get here.
|
1016 |
|
|
set_board_info compiler "[find_gcc]"
|
1017 |
|
|
set_board_info cflags "[libgloss_include_flags] [newlib_include_flags]"
|
1018 |
|
|
set_board_info ldflags "[libgloss_link_flags] [newlib_link_flags]"
|
1019 |
|
|
# No linker script.
|
1020 |
|
|
set_board_info ldscript "";
|
1021 |
|
|
|
1022 |
|
|
# Used by a few gcc.c-torture testcases to delimit how large the
|
1023 |
|
|
# stack can be.
|
1024 |
|
|
set_board_info gcc,stack_size 16384
|
1025 |
|
|
# The simulator doesn't return exit statuses and we need to indicate this
|
1026 |
|
|
# the standard GCC wrapper will work with this target.
|
1027 |
|
|
set_board_info needs_status_wrapper 1
|
1028 |
|
|
# We can't pass arguments to programs.
|
1029 |
|
|
set_board_info noargs 1
|
1030 |
|
|
|
1031 |
|
|
|
1032 |
|
|
|
1033 |
|
|
There are five helper procedures used in this example. The first
|
1034 |
|
|
one, find gcc looks for a copy of the GNU compiler in
|
1035 |
|
|
your build tree, or it uses the one in your path. This will also return
|
1036 |
|
|
the proper transformed name for a cross compiler if you whole build tree
|
1037 |
|
|
is configured for one. The next helper procedures are
|
1038 |
|
|
libgloss_include_flags &
|
1039 |
|
|
libgloss_link_flags. These return the proper flags to
|
1040 |
|
|
compiler and link an executable image using
|
1041 |
|
|
linkend=libgloss>, the GNU BSP (Board Support Package). The final
|
1042 |
|
|
procedures are newlib_include_flag &
|
1043 |
|
|
newlib_include_flag. These find the Newlib C
|
1044 |
|
|
library, which is a reentrant standard C library for embedded systems
|
1045 |
|
|
comprising of non GPL'd code.
|
1046 |
|
|
|
1047 |
|
|
|
1048 |
|
|
|
1049 |
|
|
|
1050 |
|
|
Remote Host Testing
|
1051 |
|
|
|
1052 |
|
|
Thanks to Dj Delorie for the original paper that
|
1053 |
|
|
this section is based on.
|
1054 |
|
|
|
1055 |
|
|
DejaGnu also supports running the tests on a remote
|
1056 |
|
|
host. To set this up, the remote host needs an ftp server, and a
|
1057 |
|
|
telnet server. Currently foreign operating systems used as
|
1058 |
|
|
remote hosts are VxWorks, VRTX, Dos/Win3.1, MacOS, and
|
1059 |
|
|
win95/win98/NT.
|
1060 |
|
|
|
1061 |
|
|
The recommended source for a win95/win98/NT based ftp
|
1062 |
|
|
server is to get IIS (either IIS 1 or Personal Web Server) from
|
1063 |
|
|
|
1064 |
|
|
URL="http://www.microsoft.com">http://www.microsoft.com.
|
1065 |
|
|
When you install it, make sure you install the FTP server - it's
|
1066 |
|
|
not selected by default. Go into the IIS manager and change the
|
1067 |
|
|
FTP server so that it does not allow anonymous ftp. Set the home
|
1068 |
|
|
directory to the root directory (i.e. c:\) of a suitable
|
1069 |
|
|
drive. Allow writing via ftp.
|
1070 |
|
|
|
1071 |
|
|
It will create an account like IUSR_FOOBAR where foobar is
|
1072 |
|
|
the name of your machine. Go into the user editor and give that
|
1073 |
|
|
account a password that you don't mind hanging around in the
|
1074 |
|
|
clear (i.e. not the same as your admin or personal
|
1075 |
|
|
passwords). Also, add it to all the various permission groups.
|
1076 |
|
|
|
1077 |
|
|
You'll also need a telnet server. For win95/win98/NT, go
|
1078 |
|
|
to the Ataman web site,
|
1079 |
|
|
pick up the Ataman Remote Logon Services for Windows, and
|
1080 |
|
|
install it. You can get started on the eval period anyway. Add
|
1081 |
|
|
IUSR_FOOBAR to the list of allowed users, set the HOME directory
|
1082 |
|
|
to be the same as the FTP default directory. Change the Mode
|
1083 |
|
|
prompt to simple.
|
1084 |
|
|
|
1085 |
|
|
Ok, now you need to pick a directory name to do all the
|
1086 |
|
|
testing in. For the sake of this example, we'll call it piggy
|
1087 |
|
|
(i.e. c:\piggy). Create this directory.
|
1088 |
|
|
|
1089 |
|
|
You'll need a unix machine. Create a directory for the
|
1090 |
|
|
scripts you'll need. For this example, we'll use
|
1091 |
|
|
/usr/local/swamp/testing. You'll need to have a source tree
|
1092 |
|
|
somewhere, say /usr/src/devo. Now, copy some files from
|
1093 |
|
|
releng's area in SV to your machine:
|
1094 |
|
|
|
1095 |
|
|
|
1096 |
|
|
Remote host setup
|
1097 |
|
|
|
1098 |
|
|
|
1099 |
|
|
cd /usr/local/swamp/testing
|
1100 |
|
|
mkdir boards
|
1101 |
|
|
scp darkstar.welcomehome.org:/dejagnu/cst/bin/MkTestDir .
|
1102 |
|
|
scp darkstar.welcomehome.org:/dejagnu/site.exp .
|
1103 |
|
|
scp darkstar.welcomehome.org:/dejagnu/boards/useless98r2.exp boards/foobar.exp
|
1104 |
|
|
export DEJAGNU=/usr/local/swamp/testing/site.exp
|
1105 |
|
|
|
1106 |
|
|
|
1107 |
|
|
|
1108 |
|
|
|
1109 |
|
|
You must edit the boards/foobar.exp file to reflect your
|
1110 |
|
|
machine; change the hostname (foobar.com), username
|
1111 |
|
|
(iusr_foobar), password, and ftp_directory (c:/piggy) to match
|
1112 |
|
|
what you selected.
|
1113 |
|
|
|
1114 |
|
|
Edit the global site.exp to reflect your
|
1115 |
|
|
boards directory:
|
1116 |
|
|
|
1117 |
|
|
|
1118 |
|
|
Add The Board Directory
|
1119 |
|
|
|
1120 |
|
|
|
1121 |
|
|
lappend boards_dir "/usr/local/swamp/testing/boards"
|
1122 |
|
|
|
1123 |
|
|
|
1124 |
|
|
|
1125 |
|
|
Now run MkTestDir, which is in the contrib
|
1126 |
|
|
directory. The first parameter is the toolchain prefix, the
|
1127 |
|
|
second is the location of your devo tree. If you are testing a
|
1128 |
|
|
cross compiler (ex: you have sh-hms-gcc.exe in your PATH on
|
1129 |
|
|
the PC), do something like this:
|
1130 |
|
|
|
1131 |
|
|
|
1132 |
|
|
Setup Cross Remote Testing
|
1133 |
|
|
|
1134 |
|
|
|
1135 |
|
|
./MkTestDir sh-hms /usr/dejagnu/src/devo
|
1136 |
|
|
|
1137 |
|
|
|
1138 |
|
|
|
1139 |
|
|
If you are testing a native PC compiler (ex: you have
|
1140 |
|
|
gcc.exe in your PATH on the PC), do this:
|
1141 |
|
|
|
1142 |
|
|
|
1143 |
|
|
Setup Native Remote Testing
|
1144 |
|
|
|
1145 |
|
|
|
1146 |
|
|
./MkTestDir '' /usr/dejagnu/src/devo
|
1147 |
|
|
|
1148 |
|
|
|
1149 |
|
|
|
1150 |
|
|
To test the setup, ftp to your PC
|
1151 |
|
|
using the username (iusr_foobar) and password you selected. CD
|
1152 |
|
|
to the test directory. Upload a file to the PC. Now telnet to
|
1153 |
|
|
your PC using the same username and password. CD to the test
|
1154 |
|
|
directory. Make sure the file is there. Type "set" and/or "gcc
|
1155 |
|
|
-v" (or sh-hms-gcc -v) and make sure the default PATH contains
|
1156 |
|
|
the installation you want to test.
|
1157 |
|
|
|
1158 |
|
|
|
1159 |
|
|
Run Test Remotely
|
1160 |
|
|
|
1161 |
|
|
|
1162 |
|
|
cd /usr/local/swamp/testing
|
1163 |
|
|
make -k -w check RUNTESTFLAGS="--host_board foobar --target_board foobar -v -v" > check.out 2>&1
|
1164 |
|
|
|
1165 |
|
|
|
1166 |
|
|
|
1167 |
|
|
To run a specific test, use a command like this (for
|
1168 |
|
|
this example, you'd run this from the gcc directory that
|
1169 |
|
|
MkTestDir created):
|
1170 |
|
|
|
1171 |
|
|
|
1172 |
|
|
Run a Test Remotely
|
1173 |
|
|
|
1174 |
|
|
|
1175 |
|
|
make check RUNTESTFLAGS="--host_board sloth --target_board sloth -v compile.exp=921202-1.c"
|
1176 |
|
|
|
1177 |
|
|
|
1178 |
|
|
|
1179 |
|
|
Note: if you are testing a cross-compiler, put in the
|
1180 |
|
|
correct target board. You'll also have to download more .exp
|
1181 |
|
|
files and modify them for your local configuration. The -v's
|
1182 |
|
|
are optional.
|
1183 |
|
|
|
1184 |
|
|
|
1185 |
|
|
|
1186 |
|
|
|
1187 |
|
|
Config File Values
|
1188 |
|
|
|
1189 |
|
|
DejaGnu uses a named array in Tcl to hold all the info for
|
1190 |
|
|
each machine. In the case of a canadian cross, this means host
|
1191 |
|
|
information as well as target information. The named array is
|
1192 |
|
|
called target_info, and it has two indices. The
|
1193 |
|
|
following fields are part of the array.
|
1194 |
|
|
|
1195 |
|
|
|
1196 |
|
|
Command Line Option Variables
|
1197 |
|
|
|
1198 |
|
|
In the user editable second section of the
|
1199 |
|
|
linkend=personal> you can not only override the configuration
|
1200 |
|
|
variables captured in the first section, but also specify
|
1201 |
|
|
default values for all on the runtest
|
1202 |
|
|
command line options. Save for ,
|
1203 |
|
|
, and , each
|
1204 |
|
|
command line option has an associated Tcl variable. Use the
|
1205 |
|
|
Tcl set command to specify a new default
|
1206 |
|
|
value (as for the configuration variables). The following
|
1207 |
|
|
table describes the correspondence between command line
|
1208 |
|
|
options and variables you can set in
|
1209 |
|
|
site.exp. , for
|
1210 |
|
|
explanations of the command-line options.
|
1211 |
|
|
|
1212 |
|
|
1213 |
|
|
Tcl Variables For Command Line Options
|
1214 |
|
|
|
1215 |
|
|
|
1216 |
|
|
1217 |
|
|
runtestTcl
|
1218 |
|
|
optionvariabledescription
|
1219 |
|
|
|
|
1220 |
|
|
1221 |
|
|
|
1222 |
|
|
|
|
1223 |
|
|
--all
|
1224 |
|
|
all_flag
|
1225 |
|
|
display all test results if set
|
1226 |
|
|
|
1227 |
|
|
|
1228 |
|
|
|
|
1229 |
|
|
--baud
|
1230 |
|
|
baud
|
1231 |
|
|
set the default baud rate to something other than
|
1232 |
|
|
9600.
|
1233 |
|
|
|
1234 |
|
|
|
1235 |
|
|
|
|
1236 |
|
|
--connect
|
1237 |
|
|
connectmode
|
1238 |
|
|
rlogin,
|
1239 |
|
|
telnet, rsh,
|
1240 |
|
|
kermit, tip, or
|
1241 |
|
|
mondfe
|
1242 |
|
|
|
1243 |
|
|
|
1244 |
|
|
|
|
1245 |
|
|
--outdir
|
1246 |
|
|
outdir
|
1247 |
|
|
directory for tool.sum and
|
1248 |
|
|
tool.log.
|
1249 |
|
|
|
1250 |
|
|
|
1251 |
|
|
|
|
1252 |
|
|
--objdir
|
1253 |
|
|
objdir
|
1254 |
|
|
directory for pre-compiled binaries
|
1255 |
|
|
|
1256 |
|
|
|
1257 |
|
|
|
|
1258 |
|
|
--reboot
|
1259 |
|
|
reboot
|
1260 |
|
|
reboot the target if set to
|
1261 |
|
|
"1"; do not reboot if set to
|
1262 |
|
|
"0" (the default).
|
1263 |
|
|
|
1264 |
|
|
|
1265 |
|
|
|
|
1266 |
|
|
--srcdir
|
1267 |
|
|
srcdir
|
1268 |
|
|
directory of test subdirectories
|
1269 |
|
|
|
1270 |
|
|
|
1271 |
|
|
|
|
1272 |
|
|
--strace
|
1273 |
|
|
tracelevel
|
1274 |
|
|
a number: Tcl trace depth
|
1275 |
|
|
|
1276 |
|
|
|
1277 |
|
|
|
|
1278 |
|
|
--tool
|
1279 |
|
|
tool
|
1280 |
|
|
name of tool to test; identifies init, test subdir
|
1281 |
|
|
|
1282 |
|
|
|
1283 |
|
|
|
|
1284 |
|
|
--verbose
|
1285 |
|
|
verbose
|
1286 |
|
|
verbosity level. As option, use multiple times; as
|
1287 |
|
|
variable, set a number, 0 or greater.
|
1288 |
|
|
|
1289 |
|
|
|
1290 |
|
|
|
|
1291 |
|
|
--target
|
1292 |
|
|
target_triplet
|
1293 |
|
|
The canonical configuration string for the target.
|
1294 |
|
|
|
1295 |
|
|
|
1296 |
|
|
|
|
1297 |
|
|
--host
|
1298 |
|
|
host_triplet
|
1299 |
|
|
The canonical configuration string for the host.
|
1300 |
|
|
|
1301 |
|
|
|
1302 |
|
|
|
|
1303 |
|
|
--build
|
1304 |
|
|
build_triplet
|
1305 |
|
|
The canonical configuration string for the build
|
1306 |
|
|
host.
|
1307 |
|
|
|
1308 |
|
|
|
1309 |
|
|
|
|
1310 |
|
|
|
1311 |
|
|
|
|
1312 |
|
|
|
1313 |
|
|
|
1314 |
|
|
|
1315 |
|
|
|
1316 |
|
|
|
1317 |
|
|
Personal Config File
|
1318 |
|
|
|
1319 |
|
|
The personal config file is used to customize
|
1320 |
|
|
runtest's behaviour for each person. It's
|
1321 |
|
|
typically used to set the user prefered setting for verbosity,
|
1322 |
|
|
and any experimental Tcl procedures. My personal
|
1323 |
|
|
~/.dejagnurc file looks like:
|
1324 |
|
|
|
1325 |
|
|
|
1326 |
|
|
Personal Config File
|
1327 |
|
|
|
1328 |
|
|
|
1329 |
|
|
set all_flag 1
|
1330 |
|
|
set RLOGIN /usr/ucb/rlogin
|
1331 |
|
|
set RSH /usr/local/sbin/ssh
|
1332 |
|
|
|
1333 |
|
|
|
1334 |
|
|
|
1335 |
|
|
Here I set all_flag so I see all the test
|
1336 |
|
|
cases that PASS along with the ones that FAIL. I also set
|
1337 |
|
|
RLOGIN to the BSD version. I have
|
1338 |
|
|
Kerberos installed, and when I rlogin
|
1339 |
|
|
to a target board, it usually isn't supported. So I use the non
|
1340 |
|
|
secure version rather than the default that's in my path. I also
|
1341 |
|
|
set RSH to the SSH
|
1342 |
|
|
secure shell, as rsh is mostly used to test unix
|
1343 |
|
|
machines within a local network here.
|
1344 |
|
|
|
1345 |
|
|
|
1346 |
|
|
|
1347 |
|
|
|
1348 |
|
|
|
1349 |
|
|
|
1350 |
|
|
Extending DejaGnu
|
1351 |
|
|
|
1352 |
|
|
|
1353 |
|
|
Adding A New Test Suite
|
1354 |
|
|
|
1355 |
|
|
The testsuite for a new tool should always be located in that tools
|
1356 |
|
|
source directory. DejaGnu require the directory be named
|
1357 |
|
|
testsuite. Under this directory, the test cases go
|
1358 |
|
|
in a subdirectory whose name begins with the tool name. For example, for
|
1359 |
|
|
a tool named flubber, each subdirectory containing
|
1360 |
|
|
testsuites must start with "flubber.".
|
1361 |
|
|
|
1362 |
|
|
|
1363 |
|
|
|
1364 |
|
|
|
1365 |
|
|
Adding A New Tool
|
1366 |
|
|
|
1367 |
|
|
In general, the best way to learn how to write (code or even prose)
|
1368 |
|
|
is to read something similar. This principle applies to test cases and
|
1369 |
|
|
to test suites. Unfortunately, well-established test suites have a way
|
1370 |
|
|
of developing their own conventions: as test writers become more
|
1371 |
|
|
experienced with DejaGnu and with Tcl, they accumulate more utilities,
|
1372 |
|
|
and take advantage of more and more features of
|
1373 |
|
|
Expect and Tcl in
|
1374 |
|
|
general.
|
1375 |
|
|
|
1376 |
|
|
Inspecting such established test suites may make the prospect of
|
1377 |
|
|
creating an entirely new test suite appear overwhelming. Nevertheless,
|
1378 |
|
|
it is quite straightforward to get a new test suite going.
|
1379 |
|
|
|
1380 |
|
|
There is one test suite that is guaranteed not to grow more
|
1381 |
|
|
elaborate over time: both it and the tool it tests were created expressly
|
1382 |
|
|
to illustrate what it takes to get started with DejaGnu. The
|
1383 |
|
|
example/ directory of the DejaGnu distribution
|
1384 |
|
|
contains both an interactive tool called calc, and a
|
1385 |
|
|
test suite for it. Reading this test suite, and experimenting with it,
|
1386 |
|
|
is a good way to supplement the information in this section. (Thanks to
|
1387 |
|
|
Robert Lupton for creating calc and its test suite---and also the first
|
1388 |
|
|
version of this section of the manual!)
|
1389 |
|
|
|
1390 |
|
|
To help orient you further in this task, here is an outline of the
|
1391 |
|
|
steps to begin building a test suite for a program example.
|
1392 |
|
|
|
1393 |
|
|
|
1394 |
|
|
|
1395 |
|
|
Create or select a directory to contain your new
|
1396 |
|
|
collection of tests. Change into that directory (shown here as
|
1397 |
|
|
testsuite):
|
1398 |
|
|
|
1399 |
|
|
Create a configure.in file in this directory,
|
1400 |
|
|
to control configuration-dependent choices for your tests. So far as
|
1401 |
|
|
DejaGnu is concerned, the important thing is to set a value for the
|
1402 |
|
|
variable target_abbrev; this value is the link to the
|
1403 |
|
|
init file you will write soon. (For simplicity, we assume the
|
1404 |
|
|
environment is Unix, and use unix as the
|
1405 |
|
|
value.)
|
1406 |
|
|
|
1407 |
|
|
What else is needed in configure.in depends on
|
1408 |
|
|
the requirements of your tool, your intended test environments, and which
|
1409 |
|
|
configure system you use. This example is a minimal configure.in for use
|
1410 |
|
|
with GNU Autoconf.
|
1411 |
|
|
|
1412 |
|
|
Create Makefile.in (if you are using
|
1413 |
|
|
Autoconf), or Makefile.am(if you are using
|
1414 |
|
|
Automake), the source file used by configure to build your
|
1415 |
|
|
Makefile. If you are using GNU Automake.just add the
|
1416 |
|
|
keyword dejagnu to the
|
1417 |
|
|
AUTOMAKE_OPTIONS variable in your
|
1418 |
|
|
Makefile.am file. This will add all the Makefile
|
1419 |
|
|
support needed to run DejaGnu, and support the
|
1420 |
|
|
target.
|
1421 |
|
|
|
1422 |
|
|
You also need to include two targets important to DejaGnu:
|
1423 |
|
|
check, to run the tests, and
|
1424 |
|
|
site.exp, to set up the Tcl copies of
|
1425 |
|
|
configuration-dependent values. This is called the
|
1426 |
|
|
The check target must run the runtest program to
|
1427 |
|
|
execute the tests.
|
1428 |
|
|
|
1429 |
|
|
The site.exp target should usually set up
|
1430 |
|
|
(among other things) the $tool variable for the name of your program. If
|
1431 |
|
|
the local site.exp file is setup correctly, it is possible to execute the
|
1432 |
|
|
tests by merely typing runtest on the command
|
1433 |
|
|
line.
|
1434 |
|
|
|
1435 |
|
|
|
1436 |
|
|
Sample Makefile.in Fragment
|
1437 |
|
|
|
1438 |
|
|
|
1439 |
|
|
# Look for a local version of DejaGnu, otherwise use one in the path
|
1440 |
|
|
RUNTEST = `if test -f $(top_srcdir)/../dejagnu/runtest; then \
|
1441 |
|
|
echo $(top_srcdir) ../dejagnu/runtest; \
|
1442 |
|
|
else \
|
1443 |
|
|
echo runtest; \
|
1444 |
|
|
fi`
|
1445 |
|
|
|
1446 |
|
|
# The flags to pass to runtest
|
1447 |
|
|
RUNTESTFLAGS =
|
1448 |
|
|
|
1449 |
|
|
# Execute the tests
|
1450 |
|
|
check: site.exp all
|
1451 |
|
|
$(RUNTEST) $(RUNTESTFLAGS) \
|
1452 |
|
|
--tool ${example} --srcdir $(srcdir)
|
1453 |
|
|
|
1454 |
|
|
# Make the local config file
|
1455 |
|
|
site.exp: ./config.status Makefile
|
1456 |
|
|
@echo "Making a new config file..."
|
1457 |
|
|
-@rm -f ./tmp?
|
1458 |
|
|
@touch site.exp
|
1459 |
|
|
|
1460 |
|
|
-@mv site.exp site.bak
|
1461 |
|
|
@echo "## these variables are automatically\
|
1462 |
|
|
generated by make ##" > ./tmp0
|
1463 |
|
|
@echo "# Do not edit here. If you wish to\
|
1464 |
|
|
override these values" >> ./tmp0
|
1465 |
|
|
@echo "# add them to the last section" >> ./tmp0
|
1466 |
|
|
@echo "set host_os ${host_os}" >> ./tmp0
|
1467 |
|
|
@echo "set host_alias ${host_alias}" >> ./tmp0
|
1468 |
|
|
@echo "set host_cpu ${host_cpu}" >> ./tmp0
|
1469 |
|
|
@echo "set host_vendor ${host_vendor}" >> ./tmp0
|
1470 |
|
|
@echo "set target_os ${target_os}" >> ./tmp0
|
1471 |
|
|
@echo "set target_alias ${target_alias}" >> ./tmp0
|
1472 |
|
|
@echo "set target_cpu ${target_cpu}" >> ./tmp0
|
1473 |
|
|
@echo "set target_vendor ${target_vendor}" >> ./tmp0
|
1474 |
|
|
@echo "set host_triplet ${host_canonical}" >> ./tmp0
|
1475 |
|
|
@echo "set target_triplet ${target_canonical}">>./tmp0
|
1476 |
|
|
@echo "set tool binutils" >> ./tmp0
|
1477 |
|
|
@echo "set srcdir ${srcdir}" >> ./tmp0
|
1478 |
|
|
@echo "set objdir `pwd`" >> ./tmp0
|
1479 |
|
|
@echo "set ${examplename} ${example}" >> ./tmp0
|
1480 |
|
|
@echo "## All variables above are generated by\
|
1481 |
|
|
configure. Do Not Edit ##" >> ./tmp0
|
1482 |
|
|
@cat ./tmp0 > site.exp
|
1483 |
|
|
@sed < site.bak \
|
1484 |
|
|
-e '1,/^## All variables above are.*##/ d' \
|
1485 |
|
|
>> site.exp
|
1486 |
|
|
-@rm -f ./tmp?
|
1487 |
|
|
|
1488 |
|
|
|
1489 |
|
|
|
1490 |
|
|
|
1491 |
|
|
|
1492 |
|
|
Create a directory (in testsuite)
|
1493 |
|
|
called config. Make a Tool Init
|
1494 |
|
|
File in this directory. Its name must start with the
|
1495 |
|
|
target_abbrev value, or be named
|
1496 |
|
|
default.exp so call it
|
1497 |
|
|
config/unix.exp for our Unix based example. This
|
1498 |
|
|
is the file that contains the target-dependent procedures.
|
1499 |
|
|
Fortunately, on Unix, most of them do not have to do very much in
|
1500 |
|
|
order for runtest to run.
|
1501 |
|
|
|
1502 |
|
|
If the program being tested is not interactive, you can get
|
1503 |
|
|
away with this minimal unix.exp to begin
|
1504 |
|
|
with:
|
1505 |
|
|
|
1506 |
|
|
|
1507 |
|
|
Simple Batch Program Tool Init File
|
1508 |
|
|
|
1509 |
|
|
|
1510 |
|
|
|
1511 |
|
|
proc foo_exit {} {}
|
1512 |
|
|
proc foo_version {} {}
|
1513 |
|
|
|
1514 |
|
|
|
1515 |
|
|
|
1516 |
|
|
|
1517 |
|
|
If the program being tested is interactive, however, you might
|
1518 |
|
|
as well define a start routine and invoke it by
|
1519 |
|
|
using an init file like this:
|
1520 |
|
|
|
1521 |
|
|
|
1522 |
|
|
Simple Interactive Program Tool Init File
|
1523 |
|
|
|
1524 |
|
|
|
1525 |
|
|
|
1526 |
|
|
proc foo_exit {} {}
|
1527 |
|
|
proc foo_version {} {}
|
1528 |
|
|
|
1529 |
|
|
proc foo_start {} {
|
1530 |
|
|
global ${examplename}
|
1531 |
|
|
spawn ${examplename}
|
1532 |
|
|
expect {
|
1533 |
|
|
-re "" {}
|
1534 |
|
|
}
|
1535 |
|
|
}
|
1536 |
|
|
|
1537 |
|
|
# Start the program running we want to test
|
1538 |
|
|
foo_start
|
1539 |
|
|
|
1540 |
|
|
|
1541 |
|
|
|
1542 |
|
|
|
1543 |
|
|
|
1544 |
|
|
Create a directory whose name begins with your tool's
|
1545 |
|
|
name, to contain tests. For example, if your tool's name is
|
1546 |
|
|
gcc, then the directories all need to start with
|
1547 |
|
|
"gcc.".
|
1548 |
|
|
|
1549 |
|
|
Create a sample test file. Its name must end with
|
1550 |
|
|
.exp. You can use
|
1551 |
|
|
first-try.exp. To begin with, just write there a
|
1552 |
|
|
line of Tcl code to issue a message.
|
1553 |
|
|
|
1554 |
|
|
|
1555 |
|
|
Testing A New Tool Config
|
1556 |
|
|
|
1557 |
|
|
|
1558 |
|
|
|
1559 |
|
|
send_user "Testing: one, two...\n"
|
1560 |
|
|
|
1561 |
|
|
|
1562 |
|
|
|
1563 |
|
|
|
1564 |
|
|
|
1565 |
|
|
Back in the testsuite (top
|
1566 |
|
|
level) directory, run configure. Typically you do
|
1567 |
|
|
this while in the build directory. You may have to specify more of a
|
1568 |
|
|
path, if a suitable configure is not available in your execution
|
1569 |
|
|
path.
|
1570 |
|
|
|
1571 |
|
|
e now ready to triumphantly type make
|
1572 |
|
|
check or runtest. You should see
|
1573 |
|
|
something like this:
|
1574 |
|
|
|
1575 |
|
|
|
1576 |
|
|
Example Test Case Run
|
1577 |
|
|
|
1578 |
|
|
|
1579 |
|
|
Test Run By rhl on Fri Jan 29 16:25:44 EST 1993
|
1580 |
|
|
|
1581 |
|
|
=== example tests ===
|
1582 |
|
|
|
1583 |
|
|
Running ./example.0/first-try.exp ...
|
1584 |
|
|
Testing: one, two...
|
1585 |
|
|
|
1586 |
|
|
=== example Summary ===
|
1587 |
|
|
|
1588 |
|
|
|
1589 |
|
|
|
1590 |
|
|
|
1591 |
|
|
There is no output in the summary, because so far the example
|
1592 |
|
|
does not call any of the procedures that establish a test
|
1593 |
|
|
outcome.
|
1594 |
|
|
|
1595 |
|
|
Write some real tests. For an interactive tool, you
|
1596 |
|
|
should probably write a real exit routine in fairly short order. In
|
1597 |
|
|
any case, you should also write a real version routine
|
1598 |
|
|
soon.
|
1599 |
|
|
|
1600 |
|
|
|
1601 |
|
|
|
1602 |
|
|
|
1603 |
|
|
|
1604 |
|
|
|
1605 |
|
|
Adding A New Target
|
1606 |
|
|
|
1607 |
|
|
DejaGnu has some additional requirements for target support, beyond
|
1608 |
|
|
the general-purpose provisions of configure. DejaGnu must actively
|
1609 |
|
|
communicate with the target, rather than simply generating or managing
|
1610 |
|
|
code for the target architecture. Therefore, each tool requires an
|
1611 |
|
|
initialization module for each target. For new targets, you must supply
|
1612 |
|
|
a few Tcl procedures to adapt DejaGnu to the target. This permits
|
1613 |
|
|
DejaGnu itself to remain target independent.
|
1614 |
|
|
|
1615 |
|
|
Usually the best way to write a new initialization module is to
|
1616 |
|
|
edit an existing initialization module; some trial and error will be
|
1617 |
|
|
required. If necessary, you can use the @samp{--debug} option to see what
|
1618 |
|
|
is really going on.
|
1619 |
|
|
|
1620 |
|
|
When you code an initialization module, be generous in printing
|
1621 |
|
|
information controlled by the verbose
|
1622 |
|
|
procedure.
|
1623 |
|
|
|
1624 |
|
|
For cross targets, most of the work is in getting the
|
1625 |
|
|
communications right. Communications code (for several situations
|
1626 |
|
|
involving IP networks or serial lines) is available in a DejaGnu library
|
1627 |
|
|
file.
|
1628 |
|
|
|
1629 |
|
|
If you suspect a communication problem, try running the connection
|
1630 |
|
|
interactively from Expect. (There are three
|
1631 |
|
|
ways of running Expect as an interactive
|
1632 |
|
|
interpreter. You can run Expect with no
|
1633 |
|
|
arguments, and control it completely interactively; or you can use
|
1634 |
|
|
expect -i together with other command-line options and
|
1635 |
|
|
arguments; or you can run the command interpreter from
|
1636 |
|
|
any Expect procedure. Use
|
1637 |
|
|
return to get back to the calling procedure (if any),
|
1638 |
|
|
or return -tcl to make the calling procedure itself
|
1639 |
|
|
return to its caller; use exit or end-of-file to leave
|
1640 |
|
|
Expect altogether.) Run the program whose name is recorded in
|
1641 |
|
|
$connectmode, with the arguments in
|
1642 |
|
|
$targetname, to establish a connection. You should at
|
1643 |
|
|
least be able to get a prompt from any target that is physically
|
1644 |
|
|
connected.
|
1645 |
|
|
|
1646 |
|
|
|
1647 |
|
|
|
1648 |
|
|
|
1649 |
|
|
Adding A New Board
|
1650 |
|
|
|
1651 |
|
|
Adding a new board consists of creating a new board config
|
1652 |
|
|
file. Examples are in
|
1653 |
|
|
dejagnu/baseboards. Usually to make a new
|
1654 |
|
|
board file, it's easiest to copy an existing one. It is also
|
1655 |
|
|
possible to have your file be based on a
|
1656 |
|
|
baseboard file with only one or two
|
1657 |
|
|
changes needed. Typically, this can be as simple as just
|
1658 |
|
|
changing the linker script. Once the new baseboard file is done,
|
1659 |
|
|
add it to the boards_DATA list in the
|
1660 |
|
|
dejagnu/baseboards/Makefile.am, and regenerate the
|
1661 |
|
|
Makefile.in using automake. Then just rebuild and install DejaGnu. You
|
1662 |
|
|
can test it by:
|
1663 |
|
|
|
1664 |
|
|
There is a crude inheritance scheme going on with board files, so
|
1665 |
|
|
you can include one board file into another, The two main procedures used
|
1666 |
|
|
to do this are load_generic_config and
|
1667 |
|
|
load_base_board_description. The generic config file
|
1668 |
|
|
contains other procedures used for a certain class of target. The
|
1669 |
|
|
board description file is where the board specfic settings go. Commonly
|
1670 |
|
|
there are similar target environments with just different
|
1671 |
|
|
processors.
|
1672 |
|
|
|
1673 |
|
|
|
1674 |
|
|
Testing a New Board Config File
|
1675 |
|
|
|
1676 |
|
|
|
1677 |
|
|
make check RUNTESTFLAGS="--target_board=newboardfile".
|
1678 |
|
|
|
1679 |
|
|
|
1680 |
|
|
|
1681 |
|
|
Here's an example of a board config file. There are
|
1682 |
|
|
several helper procedures used in this
|
1683 |
|
|
example. A helper procedure is one that look for a tool of files
|
1684 |
|
|
in commonly installed locations. These are mostly used when
|
1685 |
|
|
testing in the build tree, because the executables to be tested
|
1686 |
|
|
are in the same tree as the new dejagnu files. The helper
|
1687 |
|
|
procedures are the ones in square braces
|
1688 |
|
|
[], which is the Tcl execution characters.
|
1689 |
|
|
|
1690 |
|
|
|
1691 |
|
|
Example Board Config File
|
1692 |
|
|
|
1693 |
|
|
|
1694 |
|
|
|
1695 |
|
|
# Load the generic configuration for this board. This will define a basic
|
1696 |
|
|
# set of routines needed by the tool to communicate with the board.
|
1697 |
|
|
load_generic_config "sim"
|
1698 |
|
|
|
1699 |
|
|
# basic-sim.exp is a basic description for the standard Cygnus simulator.
|
1700 |
|
|
load_base_board_description "basic-sim"
|
1701 |
|
|
|
1702 |
|
|
# The compiler used to build for this board. This has *nothing* to do
|
1703 |
|
|
# with what compiler is tested if we're testing gcc.
|
1704 |
|
|
set_board_info compiler "[find_gcc]"
|
1705 |
|
|
|
1706 |
|
|
# We only support newlib on this target.
|
1707 |
|
|
# However, we include libgloss so we can find the linker scripts.
|
1708 |
|
|
set_board_info cflags "[newlib_include_flags] [libgloss_include_flags]"
|
1709 |
|
|
set_board_info ldflags "[newlib_link_flags]"
|
1710 |
|
|
|
1711 |
|
|
# No linker script for this board.
|
1712 |
|
|
set_board_info ldscript "-Tsim.ld";
|
1713 |
|
|
|
1714 |
|
|
# The simulator doesn't return exit statuses and we need to indicate this.
|
1715 |
|
|
set_board_info needs_status_wrapper 1
|
1716 |
|
|
|
1717 |
|
|
# Can't pass arguments to this target.
|
1718 |
|
|
set_board_info noargs 1
|
1719 |
|
|
|
1720 |
|
|
# No signals.
|
1721 |
|
|
set_board_info gdb,nosignals 1
|
1722 |
|
|
|
1723 |
|
|
# And it can't call functions.
|
1724 |
|
|
set_board_info gdb,cannot_call_functions 1
|
1725 |
|
|
|
1726 |
|
|
|
1727 |
|
|
|
1728 |
|
|
|
1729 |
|
|
|
1730 |
|
|
|
1731 |
|
|
|
1732 |
|
|
Board Config File Values
|
1733 |
|
|
|
1734 |
|
|
These fields are all in the board_info These are
|
1735 |
|
|
all set by using the set_board_info procedure. The
|
1736 |
|
|
parameters are the field name, followed by the value to set the field
|
1737 |
|
|
to.
|
1738 |
|
|
|
1739 |
|
|
1740 |
|
|
Common Board Info Fields
|
1741 |
|
|
|
1742 |
|
|
|
1743 |
|
|
1744 |
|
|
Field
|
1745 |
|
|
Sample Value
|
1746 |
|
|
Description
|
1747 |
|
|
|
|
1748 |
|
|
1749 |
|
|
|
1750 |
|
|
|
|
1751 |
|
|
compiler
|
1752 |
|
|
"[find_gcc]"
|
1753 |
|
|
The path to the compiler to use.
|
1754 |
|
|
|
1755 |
|
|
|
1756 |
|
|
|
|
1757 |
|
|
cflags
|
1758 |
|
|
"-mca"
|
1759 |
|
|
Compilation flags for the compiler.
|
1760 |
|
|
|
1761 |
|
|
|
1762 |
|
|
|
|
1763 |
|
|
ldflags
|
1764 |
|
|
"[libgloss_link_flags] [newlib_link_flags]"
|
1765 |
|
|
Linking flags for the compiler.
|
1766 |
|
|
|
1767 |
|
|
|
1768 |
|
|
|
|
1769 |
|
|
ldscript
|
1770 |
|
|
"-Wl,-Tidt.ld"
|
1771 |
|
|
The linker script to use when cross compiling.
|
1772 |
|
|
|
1773 |
|
|
|
1774 |
|
|
|
|
1775 |
|
|
libs
|
1776 |
|
|
"-lgcc"
|
1777 |
|
|
Any additional libraries to link in.
|
1778 |
|
|
|
1779 |
|
|
|
1780 |
|
|
|
|
1781 |
|
|
shell_prompt
|
1782 |
|
|
"cygmon>"
|
1783 |
|
|
The command prompt of the remote shell.
|
1784 |
|
|
|
1785 |
|
|
|
1786 |
|
|
|
|
1787 |
|
|
hex_startaddr
|
1788 |
|
|
"0xa0020000"
|
1789 |
|
|
The Starting address as a string.
|
1790 |
|
|
|
1791 |
|
|
|
1792 |
|
|
|
|
1793 |
|
|
start_addr
|
1794 |
|
|
0xa0008000
|
1795 |
|
|
The starting address as a value.
|
1796 |
|
|
|
1797 |
|
|
|
1798 |
|
|
|
|
1799 |
|
|
startaddr
|
1800 |
|
|
"a0020000"
|
1801 |
|
|
|
1802 |
|
|
|
1803 |
|
|
|
1804 |
|
|
|
|
1805 |
|
|
exit_statuses_bad
|
1806 |
|
|
1
|
1807 |
|
|
Whether there is an accurate exit status.
|
1808 |
|
|
|
1809 |
|
|
|
1810 |
|
|
|
|
1811 |
|
|
reboot_delay
|
1812 |
|
|
10
|
1813 |
|
|
The delay between power off and power on.
|
1814 |
|
|
|
1815 |
|
|
|
1816 |
|
|
|
|
1817 |
|
|
unreliable
|
1818 |
|
|
1
|
1819 |
|
|
Whether communication with the board is unreliable.
|
1820 |
|
|
|
1821 |
|
|
|
1822 |
|
|
|
|
1823 |
|
|
sim
|
1824 |
|
|
[find_sim]
|
1825 |
|
|
The path to the simulator to use.
|
1826 |
|
|
|
1827 |
|
|
|
1828 |
|
|
|
|
1829 |
|
|
objcopy
|
1830 |
|
|
$tempfil
|
1831 |
|
|
The path to the objcopy program.
|
1832 |
|
|
|
1833 |
|
|
|
1834 |
|
|
|
|
1835 |
|
|
support_libs
|
1836 |
|
|
"${prefix_dir}/i386-coff/"
|
1837 |
|
|
Support libraries needed for cross compiling.
|
1838 |
|
|
|
1839 |
|
|
|
1840 |
|
|
|
|
1841 |
|
|
addl_link_flags
|
1842 |
|
|
"-N"
|
1843 |
|
|
Additional link flags, rarely used.
|
1844 |
|
|
|
1845 |
|
|
|
1846 |
|
|
|
|
1847 |
|
|
|
1848 |
|
|
|
|
1849 |
|
|
|
1850 |
|
|
|
1851 |
|
|
These fields are used by the GCC and GDB tests, and are mostly
|
1852 |
|
|
only useful to somewhat trying to debug a new board file for one of
|
1853 |
|
|
these tools. Many of these are used only by a few testcases, and their
|
1854 |
|
|
purpose is esoteric. These are listed with sample values as a guide to
|
1855 |
|
|
better guessing if you need to change any of these.
|
1856 |
|
|
|
1857 |
|
|
1858 |
|
|
Board Info Fields For GCC & GDB
|
1859 |
|
|
|
1860 |
|
|
|
1861 |
|
|
1862 |
|
|
Field
|
1863 |
|
|
Sample Value
|
1864 |
|
|
Description
|
1865 |
|
|
|
|
1866 |
|
|
1867 |
|
|
|
1868 |
|
|
|
|
1869 |
|
|
strip
|
1870 |
|
|
$tempfile
|
1871 |
|
|
Strip the executable of symbols.
|
1872 |
|
|
|
1873 |
|
|
|
1874 |
|
|
|
|
1875 |
|
|
gdb_load_offset
|
1876 |
|
|
"0x40050000"
|
1877 |
|
|
|
1878 |
|
|
|
1879 |
|
|
|
|
1880 |
|
|
gdb_protocol
|
1881 |
|
|
"remote"
|
1882 |
|
|
The GDB debugging protocol to use.
|
1883 |
|
|
|
1884 |
|
|
|
1885 |
|
|
|
|
1886 |
|
|
gdb_sect_offset
|
1887 |
|
|
"0x41000000";
|
1888 |
|
|
|
1889 |
|
|
|
1890 |
|
|
|
|
1891 |
|
|
gdb_stub_ldscript
|
1892 |
|
|
"-Wl,-Teva-stub.ld"
|
1893 |
|
|
The linker script to use with a GDB stub.
|
1894 |
|
|
|
1895 |
|
|
|
1896 |
|
|
|
|
1897 |
|
|
gdb_init_command
|
1898 |
|
|
"set mipsfpu none"
|
1899 |
|
|
|
1900 |
|
|
|
1901 |
|
|
|
|
1902 |
|
|
gdb,cannot_call_functions
|
1903 |
|
|
1
|
1904 |
|
|
Whether GDB can call functions on the target,
|
1905 |
|
|
|
1906 |
|
|
|
1907 |
|
|
|
|
1908 |
|
|
gdb,noargs
|
1909 |
|
|
1
|
1910 |
|
|
Whether the target can take command line arguments.
|
1911 |
|
|
|
1912 |
|
|
|
1913 |
|
|
|
|
1914 |
|
|
gdb,nosignals
|
1915 |
|
|
1
|
1916 |
|
|
Whether there are signals on the target.
|
1917 |
|
|
|
1918 |
|
|
|
1919 |
|
|
|
|
1920 |
|
|
gdb,short_int
|
1921 |
|
|
1
|
1922 |
|
|
|
1923 |
|
|
|
1924 |
|
|
|
|
1925 |
|
|
gdb,start_symbol
|
1926 |
|
|
"_start";
|
1927 |
|
|
The starting symbol in the executable.
|
1928 |
|
|
|
1929 |
|
|
|
1930 |
|
|
|
|
1931 |
|
|
gdb,target_sim_options
|
1932 |
|
|
"-sparclite"
|
1933 |
|
|
Special options to pass to the simulator.
|
1934 |
|
|
|
1935 |
|
|
|
1936 |
|
|
|
|
1937 |
|
|
gdb,timeout
|
1938 |
|
|
540
|
1939 |
|
|
Timeout value to use for remote communication.
|
1940 |
|
|
|
1941 |
|
|
|
1942 |
|
|
|
|
1943 |
|
|
gdb_init_command
|
1944 |
|
|
"print/x \$fsr = 0x0"
|
1945 |
|
|
|
1946 |
|
|
|
1947 |
|
|
|
|
1948 |
|
|
gdb_load_offset
|
1949 |
|
|
"0x12020000"
|
1950 |
|
|
|
1951 |
|
|
|
1952 |
|
|
|
|
1953 |
|
|
gdb_opts
|
1954 |
|
|
"--command gdbinit"
|
1955 |
|
|
|
1956 |
|
|
|
1957 |
|
|
|
|
1958 |
|
|
gdb_prompt
|
1959 |
|
|
"\\(gdb960\\)"
|
1960 |
|
|
The prompt GDB is using.
|
1961 |
|
|
|
1962 |
|
|
|
1963 |
|
|
|
|
1964 |
|
|
gdb_run_command
|
1965 |
|
|
"jump start"
|
1966 |
|
|
|
1967 |
|
|
|
1968 |
|
|
|
|
1969 |
|
|
gdb_stub_offset
|
1970 |
|
|
"0x12010000"
|
1971 |
|
|
|
1972 |
|
|
|
1973 |
|
|
|
|
1974 |
|
|
use_gdb_stub
|
1975 |
|
|
1
|
1976 |
|
|
Whether to use a GDB stub.
|
1977 |
|
|
|
1978 |
|
|
|
1979 |
|
|
|
|
1980 |
|
|
use_vma_offset
|
1981 |
|
|
1
|
1982 |
|
|
|
1983 |
|
|
|
1984 |
|
|
|
|
1985 |
|
|
wrap_m68k_aout
|
1986 |
|
|
1
|
1987 |
|
|
|
1988 |
|
|
|
1989 |
|
|
|
|
1990 |
|
|
gcc,no_label_values
|
1991 |
|
|
1
|
1992 |
|
|
|
1993 |
|
|
|
1994 |
|
|
|
|
1995 |
|
|
gcc,no_trampolines
|
1996 |
|
|
1
|
1997 |
|
|
|
1998 |
|
|
|
1999 |
|
|
|
|
2000 |
|
|
gcc,no_varargs
|
2001 |
|
|
1
|
2002 |
|
|
|
2003 |
|
|
|
2004 |
|
|
|
|
2005 |
|
|
gcc,stack_size
|
2006 |
|
|
16384
|
2007 |
|
|
Stack size to use with some GCC testcases.
|
2008 |
|
|
|
2009 |
|
|
|
2010 |
|
|
|
|
2011 |
|
|
ieee_multilib_flags
|
2012 |
|
|
"-mieee";
|
2013 |
|
|
|
2014 |
|
|
|
2015 |
|
|
|
|
2016 |
|
|
is_simulator
|
2017 |
|
|
1
|
2018 |
|
|
|
2019 |
|
|
|
2020 |
|
|
|
|
2021 |
|
|
needs_status_wrapper
|
2022 |
|
|
1
|
2023 |
|
|
|
2024 |
|
|
|
2025 |
|
|
|
|
2026 |
|
|
no_double
|
2027 |
|
|
1
|
2028 |
|
|
|
2029 |
|
|
|
2030 |
|
|
|
|
2031 |
|
|
no_long_long
|
2032 |
|
|
1
|
2033 |
|
|
|
2034 |
|
|
|
2035 |
|
|
|
|
2036 |
|
|
noargs
|
2037 |
|
|
1
|
2038 |
|
|
|
2039 |
|
|
|
2040 |
|
|
|
|
2041 |
|
|
nullstone,lib
|
2042 |
|
|
"mips-clock.c"
|
2043 |
|
|
|
2044 |
|
|
|
2045 |
|
|
|
|
2046 |
|
|
nullstone,ticks_per_sec
|
2047 |
|
|
3782018
|
2048 |
|
|
|
2049 |
|
|
|
2050 |
|
|
|
|
2051 |
|
|
sys_speed_value
|
2052 |
|
|
200
|
2053 |
|
|
|
2054 |
|
|
|
2055 |
|
|
|
|
2056 |
|
|
target_install
|
2057 |
|
|
{sh-hms}
|
2058 |
|
|
|
2059 |
|
|
|
2060 |
|
|
|
|
2061 |
|
|
|
2062 |
|
|
|
|
2063 |
|
|
|
2064 |
|
|
|
2065 |
|
|
|
2066 |
|
|
|
2067 |
|
|
|
2068 |
|
|
Writing A Test Case
|
2069 |
|
|
|
2070 |
|
|
The easiest way to prepare a new test case is to base it
|
2071 |
|
|
on an existing one for a similar situation. There are two major
|
2072 |
|
|
categories of tests: batch or interactive. Batch oriented tests
|
2073 |
|
|
are usually easier to write.
|
2074 |
|
|
|
2075 |
|
|
The GCC tests are a good example of batch oriented tests.
|
2076 |
|
|
All GCC tests consist primarily of a call to a single common
|
2077 |
|
|
procedure, Since all the tests either have no output, or only
|
2078 |
|
|
have a few warning messages when successfully compiled. Any
|
2079 |
|
|
non-warning output is a test failure. All the C code needed is
|
2080 |
|
|
kept in the test directory. The test driver, written in Tcl,
|
2081 |
|
|
need only get a listing of all the C files in the directory, and
|
2082 |
|
|
compile them all using a generic procedure. This procedure and a
|
2083 |
|
|
few others supporting for these tests are kept in the library
|
2084 |
|
|
module lib/c-torture.exp in the GCC test
|
2085 |
|
|
suite. Most tests of this kind use very few
|
2086 |
|
|
expect features, and are coded almost
|
2087 |
|
|
purely in Tcl.
|
2088 |
|
|
|
2089 |
|
|
Writing the complete suite of C tests, then, consisted of
|
2090 |
|
|
these steps:
|
2091 |
|
|
|
2092 |
|
|
|
2093 |
|
|
Copying all the C code into the test directory.
|
2094 |
|
|
These tests were based on the C-torture test created by Torbjorn
|
2095 |
|
|
Granlund (on behalf of the Free Software Foundation) for GCC
|
2096 |
|
|
development.
|
2097 |
|
|
|
2098 |
|
|
Writing (and debugging) the generic Tcl procedures for
|
2099 |
|
|
compilation.
|
2100 |
|
|
|
2101 |
|
|
Writing the simple test driver: its main task is to
|
2102 |
|
|
search the directory (using the Tcl procedure
|
2103 |
|
|
glob for filename expansion with wildcards)
|
2104 |
|
|
and call a Tcl procedure with each filename. It also checks for
|
2105 |
|
|
a few errors from the testing procedure.
|
2106 |
|
|
|
2107 |
|
|
|
2108 |
|
|
Testing interactive programs is intrinsically more
|
2109 |
|
|
complex. Tests for most interactive programs require some trial
|
2110 |
|
|
and error before they are complete.
|
2111 |
|
|
|
2112 |
|
|
However, some interactive programs can be tested in a
|
2113 |
|
|
simple fashion reminiscent of batch tests. For example, prior
|
2114 |
|
|
to the creation of DejaGnu, the GDB distribution already
|
2115 |
|
|
included a wide-ranging testing procedure. This procedure was
|
2116 |
|
|
very robust, and had already undergone much more debugging and
|
2117 |
|
|
error checking than many recent DejaGnu test cases.
|
2118 |
|
|
Accordingly, the best approach was simply to encapsulate the
|
2119 |
|
|
existing GDB tests, for reporting purposes. Thereafter, new GDB
|
2120 |
|
|
tests built up a family of Tcl procedures specialized for GDB
|
2121 |
|
|
testing.
|
2122 |
|
|
|
2123 |
|
|
|
2124 |
|
|
|
2125 |
|
|
|
2126 |
|
|
Debugging A Test Case
|
2127 |
|
|
|
2128 |
|
|
These are the kinds of debugging information available
|
2129 |
|
|
from DejaGnu:
|
2130 |
|
|
|
2131 |
|
|
|
2132 |
|
|
|
2133 |
|
|
Output controlled by test scripts themselves,
|
2134 |
|
|
explicitly allowed for by the test author. This kind of
|
2135 |
|
|
debugging output appears in the detailed output recorded in the
|
2136 |
|
|
DejaGnu log file. To do the same for new tests, use the
|
2137 |
|
|
verbose procedure (which in turn uses the
|
2138 |
|
|
variable also called verbose) to control
|
2139 |
|
|
how much output to generate. This will make it easier for other
|
2140 |
|
|
people running the test to debug it if necessary. Whenever
|
2141 |
|
|
possible, if $verbose is
|
2142 |
|
|
0, there should be no output other than the
|
2143 |
|
|
output from pass,
|
2144 |
|
|
fail, error, and
|
2145 |
|
|
warning. Then, to whatever extent is
|
2146 |
|
|
appropriate for the particular test, allow successively higher
|
2147 |
|
|
values of $verbose to generate more
|
2148 |
|
|
information. Be kind to other programmers who use your tests:
|
2149 |
|
|
provide for a lot of debugging information.
|
2150 |
|
|
|
2151 |
|
|
Output from the internal debugging functions of
|
2152 |
|
|
Tcl and Expect. There is a command
|
2153 |
|
|
line options for each; both forms of debugging output are
|
2154 |
|
|
recorded in the file dbg.log in the current
|
2155 |
|
|
directory.
|
2156 |
|
|
|
2157 |
|
|
Use for information from the
|
2158 |
|
|
expect level; it generates displays of the expect attempts to
|
2159 |
|
|
match the tool output with the patterns specified. This output
|
2160 |
|
|
can be very helpful while developing test scripts, since it
|
2161 |
|
|
shows precisely the characters received. Iterating between the
|
2162 |
|
|
latest attempt at a new test script and the corresponding
|
2163 |
|
|
dbg.log can allow you to create the final
|
2164 |
|
|
patterns by ``cut and paste''. This is sometimes the best way
|
2165 |
|
|
to write a test case.
|
2166 |
|
|
|
2167 |
|
|
Use to see more
|
2168 |
|
|
detail at the Tcl level; this shows how Tcl procedure
|
2169 |
|
|
definitions expand, as they execute. The associated number
|
2170 |
|
|
controls the depth of definitions expanded.
|
2171 |
|
|
|
2172 |
|
|
Finally, if the value of
|
2173 |
|
|
verbose is 3 or greater,DejaGnu turns on
|
2174 |
|
|
the expect command log_user. This command
|
2175 |
|
|
prints all expect actions to the expect standard output, to the
|
2176 |
|
|
detailed log file, and (if is on) to
|
2177 |
|
|
dbg.log.
|
2178 |
|
|
|
2179 |
|
|
|
2180 |
|
|
|
2181 |
|
|
|
2182 |
|
|
|
2183 |
|
|
Adding A Test Case To A Test Suite.
|
2184 |
|
|
|
2185 |
|
|
There are two slightly different ways to add a test
|
2186 |
|
|
case. One is to add the test case to an existing directory. The
|
2187 |
|
|
other is to create a new directory to hold your test. The
|
2188 |
|
|
existing test directories represent several styles of testing,
|
2189 |
|
|
all of which are slightly different; examine the directories for
|
2190 |
|
|
the tool of interest to see which (if any) is most suitable.
|
2191 |
|
|
|
2192 |
|
|
Adding a GCC test can be very simple: just add the C code
|
2193 |
|
|
to any directory beginning with gcc. and it
|
2194 |
|
|
runs on the next runtest --tool
|
2195 |
|
|
gcc.
|
2196 |
|
|
|
2197 |
|
|
To add a test to GDB, first add any source code you will
|
2198 |
|
|
need to the test directory. Then you can either create a new
|
2199 |
|
|
expect file, or add your test to an existing one (any
|
2200 |
|
|
file with a .exp suffix). Creating a new
|
2201 |
|
|
.exp file is probably a better idea if the test is significantly
|
2202 |
|
|
different from existing tests. Adding it as a separate file also
|
2203 |
|
|
makes upgrading easier. If the C code has to be already compiled
|
2204 |
|
|
before the test will run, then you'll have to add it to the
|
2205 |
|
|
Makefile.in file for that test directory,
|
2206 |
|
|
then run configure and
|
2207 |
|
|
make.
|
2208 |
|
|
|
2209 |
|
|
Adding a test by creating a new directory is very
|
2210 |
|
|
similar:
|
2211 |
|
|
|
2212 |
|
|
|
2213 |
|
|
|
2214 |
|
|
Create the new directory. All subdirectory names
|
2215 |
|
|
begin with the name of the tool to test; e.g. G++ tests might be
|
2216 |
|
|
in a directory called g++.other. There can
|
2217 |
|
|
be multiple test directories that start with the same tool name
|
2218 |
|
|
(such as g++).
|
2219 |
|
|
|
2220 |
|
|
Add the new directory name to the
|
2221 |
|
|
configdirs definition in the
|
2222 |
|
|
configure.in file for the test suite
|
2223 |
|
|
directory. This way when make and
|
2224 |
|
|
configure next run, they include the new
|
2225 |
|
|
directory.
|
2226 |
|
|
|
2227 |
|
|
Add the new test case to the directory, as
|
2228 |
|
|
above.
|
2229 |
|
|
|
2230 |
|
|
To add support in the new directory for
|
2231 |
|
|
configure and make, you must also create a
|
2232 |
|
|
Makefile.in and a
|
2233 |
|
|
configure.in.
|
2234 |
|
|
|
2235 |
|
|
|
2236 |
|
|
|
2237 |
|
|
|
2238 |
|
|
|
2239 |
|
|
Hints On Writing A Test Case
|
2240 |
|
|
|
2241 |
|
|
It is safest to write patterns that match all the output
|
2242 |
|
|
generated by the tested program; this is called closure.
|
2243 |
|
|
If a pattern does not match the entire output, any output that
|
2244 |
|
|
remains will be examined by the next expect
|
2245 |
|
|
command. In this situation, the precise boundary that determines
|
2246 |
|
|
which expect command sees what is very
|
2247 |
|
|
sensitive to timing between the Expect task and the task running
|
2248 |
|
|
the tested tool. As a result, the test may sometimes appear to
|
2249 |
|
|
work, but is likely to have unpredictable results. (This problem
|
2250 |
|
|
is particularly likely for interactive tools, but can also
|
2251 |
|
|
affect batch tools---especially for tests that take a long time
|
2252 |
|
|
to finish.) The best way to ensure closure is to use the
|
2253 |
|
|
option for the expect
|
2254 |
|
|
command to write the pattern as a full regular expressions; then
|
2255 |
|
|
you can match the end of output using a $.
|
2256 |
|
|
It is also a good idea to write patterns that match all
|
2257 |
|
|
available output by using .*\ after the
|
2258 |
|
|
text of interest; this will also match any intervening blank
|
2259 |
|
|
lines. Sometimes an alternative is to match end of line using
|
2260 |
|
|
\r or \n, but this is
|
2261 |
|
|
usually too dependent on terminal settings.
|
2262 |
|
|
|
2263 |
|
|
Always escape punctuation, such as (
|
2264 |
|
|
or ", in your patterns; for example, write
|
2265 |
|
|
\(. If you forget to escape punctuation,
|
2266 |
|
|
you will usually see an error message like extra
|
2267 |
|
|
characters after close-quote.
|
2268 |
|
|
|
2269 |
|
|
If you have trouble understanding why a pattern does not
|
2270 |
|
|
match the program output, try using the
|
2271 |
|
|
option to runtest, and examine the debug log
|
2272 |
|
|
carefully.
|
2273 |
|
|
|
2274 |
|
|
Be careful not to neglect output generated by setup rather
|
2275 |
|
|
than by the interesting parts of a test case. For example,
|
2276 |
|
|
while testing GDB, I issue a send set height
|
2277 |
|
|
0\n command. The purpose is simply to make sure GDB
|
2278 |
|
|
never calls a paging program. The set
|
2279 |
|
|
height command in GDB does not generate any
|
2280 |
|
|
output; but running any command makes GDB issue a new
|
2281 |
|
|
(gdb) prompt. If there were no
|
2282 |
|
|
expect command to match this prompt, the
|
2283 |
|
|
output (gdb) begins the text seen by the
|
2284 |
|
|
next expect command---which might make that
|
2285 |
|
|
pattern fail to match.
|
2286 |
|
|
|
2287 |
|
|
To preserve basic sanity, I also recommended that no test
|
2288 |
|
|
ever pass if there was any kind of problem in the test case. To
|
2289 |
|
|
take an extreme case, tests that pass even when the tool will
|
2290 |
|
|
not spawn are misleading. Ideally, a test in this sort of
|
2291 |
|
|
situation should not fail either. Instead, print an error
|
2292 |
|
|
message by calling one of the DejaGnu procedures
|
2293 |
|
|
error or warning.
|
2294 |
|
|
|
2295 |
|
|
|
2296 |
|
|
|
2297 |
|
|
|
2298 |
|
|
Special variables used by test cases.
|
2299 |
|
|
|
2300 |
|
|
There are special variables used by test cases. These contain
|
2301 |
|
|
other information from DejaGnu. Your test cases can use these variables,
|
2302 |
|
|
with conventional meanings (as well as the variables saved in
|
2303 |
|
|
site.exp. You can use the value of these variables,
|
2304 |
|
|
but they should never be changed.
|
2305 |
|
|
|
2306 |
|
|
|
2307 |
|
|
|
2308 |
|
|
$prms_id
|
2309 |
|
|
The tracking system (e.g. GNATS) number identifying
|
2310 |
|
|
a corresponding bugreport. (0} if you do not
|
2311 |
|
|
specify it in the test script.)
|
2312 |
|
|
|
2313 |
|
|
|
2314 |
|
|
|
2315 |
|
|
$item bug_id
|
2316 |
|
|
An optional bug id; may reflect a bug
|
2317 |
|
|
identification from another organization. (0
|
2318 |
|
|
if you do not specify it.)
|
2319 |
|
|
|
2320 |
|
|
|
2321 |
|
|
|
2322 |
|
|
$subdir
|
2323 |
|
|
The subdirectory for the current test
|
2324 |
|
|
case.
|
2325 |
|
|
|
2326 |
|
|
|
2327 |
|
|
|
2328 |
|
|
$expect_out(buffer)
|
2329 |
|
|
The output from the last command. This is an
|
2330 |
|
|
internal variable set by Expect. More information can be found in
|
2331 |
|
|
the Expect manual.
|
2332 |
|
|
|
2333 |
|
|
|
2334 |
|
|
|
2335 |
|
|
$exec_output
|
2336 |
|
|
This is the output from a
|
2337 |
|
|
${tool}_load command. This only applies to
|
2338 |
|
|
tools like GCC and GAS which produce an object file that must in
|
2339 |
|
|
turn be executed to complete a test.
|
2340 |
|
|
|
2341 |
|
|
|
2342 |
|
|
|
2343 |
|
|
$comp_output
|
2344 |
|
|
This is the output from a
|
2345 |
|
|
${tool}_start command. This is conventionally
|
2346 |
|
|
used for batch oriented programs, like GCC and GAS, that may
|
2347 |
|
|
produce interesting output (warnings, errors) without further
|
2348 |
|
|
interaction.
|
2349 |
|
|
|
2350 |
|
|
|
2351 |
|
|
|
2352 |
|
|
|
2353 |
|
|
|
2354 |
|
|
|
2355 |
|
|
|