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: Names, Next: Init Module, Up: Internals
|
25 |
|
|
|
26 |
|
|
Conventions for using tool names
|
27 |
|
|
================================
|
28 |
|
|
|
29 |
|
|
DejaGnu uses `$tool', the name of the tool under test, to tie
|
30 |
|
|
together the testing configuration in a straightforward but flexible
|
31 |
|
|
way. If there is only one testsuite for a particular application, then
|
32 |
|
|
`$tool' is optional.
|
33 |
|
|
|
34 |
|
|
`$tool' is _not_ used to invoke the tool, since sites that run
|
35 |
|
|
multiple configurations of a particular tool often call each
|
36 |
|
|
configuration by a different name. `runtest' uses the
|
37 |
|
|
configuration-dependent variables captured in `site.exp' to determine
|
38 |
|
|
how to call each tool.
|
39 |
|
|
|
40 |
|
|
`runtest' uses tool names to find directories containing tests.
|
41 |
|
|
`runtest' scans the source directory (specified with `--srcdir') for
|
42 |
|
|
all directories whose names start with the tool name. It is a common
|
43 |
|
|
practice to put a period after the tool part of the name. For instance,
|
44 |
|
|
directories that start with `g++.' contain G++ tests. To add a new
|
45 |
|
|
test, just put it in any directory (create an entirely new directory,
|
46 |
|
|
if you wish) whose name follows this convention.
|
47 |
|
|
|
48 |
|
|
A test is any file in an appropriately named subdirectory whose name
|
49 |
|
|
ends in `.exp' (the conventional way of naming `expect' scripts).
|
50 |
|
|
These simple naming conventions make it as simple as possible to
|
51 |
|
|
install new tests: all you must do is put the test in the right
|
52 |
|
|
directory.
|
53 |
|
|
|
54 |
|
|
`runtest' sorts the tests in each subdirectory by name (using the
|
55 |
|
|
Tcl `lsort' command) and runs them in the resulting order.
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
File: dejagnu.info, Node: Init Module, Next: DejaGnu Builtins, Prev: Names, Up: Internals
|
59 |
|
|
|
60 |
|
|
Initialization module
|
61 |
|
|
=====================
|
62 |
|
|
|
63 |
|
|
The initialization module (or "init file") has two purposes: to
|
64 |
|
|
provide tool and target dependent procedures, and to start up an
|
65 |
|
|
interactive tool to the point where it is ready to operate. The latter
|
66 |
|
|
includes establishing communications with the target. All the tests for
|
67 |
|
|
interactive programs assume that the tool is already running and
|
68 |
|
|
communicating. Initialization modules for non-interactive programs may
|
69 |
|
|
only need to supply the support functions.
|
70 |
|
|
|
71 |
|
|
Each test suite directory must contain (in its `config'
|
72 |
|
|
subdirectory) a separate initialization module for each target. The
|
73 |
|
|
appropriate init file is can be named several ways. The prefered name is
|
74 |
|
|
the _os_ part of the canonical configuration name with `.exp' as the
|
75 |
|
|
suffix. An example would be that for an `m68k-coff' system, the
|
76 |
|
|
`target_os' part would be `coff'. The next way is for system where
|
77 |
|
|
there are short filenames, or a shortcut is desired to refer to the OS
|
78 |
|
|
name for that target. This is uses the value of `$target_abbrev' rather
|
79 |
|
|
than the `target_os'.
|
80 |
|
|
|
81 |
|
|
The final file looked for is simply `default.exp'. If there is only
|
82 |
|
|
one operating system to support, then this file can be used. It's main
|
83 |
|
|
purpose is to offer some support for new operating systems, or for
|
84 |
|
|
unsupported cross targets. The last file looked for is `unknown.exp'.
|
85 |
|
|
This is usually limited to error handling for unsupported targets. It's
|
86 |
|
|
whole contents is typically.
|
87 |
|
|
|
88 |
|
|
perror "Sorry, there is no support for this target"
|
89 |
|
|
exit 1
|
90 |
|
|
|
91 |
|
|
At the beginning of the init file, you must first determine the
|
92 |
|
|
proper executable name of the tool to execute, since the actual name of
|
93 |
|
|
the tool to be tested my vary from system to system. Here's an example
|
94 |
|
|
for the GNU C compiler.
|
95 |
|
|
|
96 |
|
|
global AR
|
97 |
|
|
# look for the archiver ar
|
98 |
|
|
if ![info exists AR] {
|
99 |
|
|
set AR [findfile $base_dir/../../binutils/ar $base_dir/../../binutils/ar [tr
|
100 |
|
|
ansform ar]]
|
101 |
|
|
verbose "AR defaulting to $AR" 2
|
102 |
|
|
}
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
global CFLAGS
|
106 |
|
|
if ![info exists CFLAGS] then {
|
107 |
|
|
set CFLAGS ""
|
108 |
|
|
}
|
109 |
|
|
|
110 |
|
|
It is always a good idea to first check the variable, and only set
|
111 |
|
|
it if it has not yet been defined. Often the proper value of `AR' is
|
112 |
|
|
set on the command line that invokes `runtest'.
|
113 |
|
|
|
114 |
|
|
The `findfile' procedure takes as it's first argument a file name to
|
115 |
|
|
look for. The second argument is returned if the file is found, and the
|
116 |
|
|
third argument is returned if the file is not found. `base_dir' is set
|
117 |
|
|
internally by DejaGnu to the top level directory of the object tree.
|
118 |
|
|
|
119 |
|
|
The `transform' procedure takes as its argument the native name of a
|
120 |
|
|
tool (such as `gcc' for the compiler), and returns the name as
|
121 |
|
|
configured for that tool in the current installation. (For example, a
|
122 |
|
|
cross-compiling version of GNU CC that generates MIPS code may be
|
123 |
|
|
installed with a name like `mips-idt-ecoff-gcc'.)
|
124 |
|
|
|
125 |
|
|
In a test running native, writing the Tcl code for initialization is
|
126 |
|
|
usually quite simple. For cross configurations, however, more elaborate
|
127 |
|
|
instructions are usually needed to describe how to talk to a remote
|
128 |
|
|
target.
|
129 |
|
|
|
130 |
|
|
Each initialization module defines up to four procedures with
|
131 |
|
|
standard names and purposes. The names of these procedures begin with
|
132 |
|
|
`$tool', the string that identifies tests for a particular tool:
|
133 |
|
|
`$tool_start', `$tool_load', `$tool_exit', and `$tool_version'. For
|
134 |
|
|
example, the start procedure for GDB is called `gdb_start'. (Since
|
135 |
|
|
start procedures are used differently for batch and interactive tools,
|
136 |
|
|
however, `runtest' itself never calls the start procedure. Init files
|
137 |
|
|
for interactive tools are expected to end by running the start
|
138 |
|
|
procedure.)
|
139 |
|
|
|
140 |
|
|
The initialization module is also a good place to call `load_lib' to
|
141 |
|
|
get any collections of utility procedures meant for a family of test
|
142 |
|
|
cases, and to set up default values for any additional Tcl variables
|
143 |
|
|
needed for a specific set of tests.
|
144 |
|
|
|
145 |
|
|
*Note Target dependent procedures: Target Dependent, for full
|
146 |
|
|
descriptions of these procedures.
|
147 |
|
|
|
148 |
|
|
|
149 |
|
|
File: dejagnu.info, Node: DejaGnu Builtins, Next: Target Dependent, Prev: Init Module, Up: Internals
|
150 |
|
|
|
151 |
|
|
DejaGnu procedures
|
152 |
|
|
==================
|
153 |
|
|
|
154 |
|
|
DejaGnu provides these Tcl procedures for use in test scripts. You
|
155 |
|
|
can also use any standard `expect' or Tcl function. These procedures
|
156 |
|
|
are stored in libraries, which DejaGnu loads at runtime. Here's
|
157 |
|
|
explanation of the library procedures that get loaded at runtime. All
|
158 |
|
|
other librarys are optional, and need to be loaded by the testsuite.
|
159 |
|
|
|
160 |
|
|
* Menu:
|
161 |
|
|
|
162 |
|
|
* framework.exp:: Core Internal Procedures.
|
163 |
|
|
* remote.exp:: Procedures for remote communication.
|
164 |
|
|
* utils.exp:: Utility procedures.
|
165 |
|
|
* target.exp:: Cross target procedures.
|
166 |
|
|
* debugger.exp:: Procedures for debugging your Tcl code.
|
167 |
|
|
|
168 |
|
|
|
169 |
|
|
File: dejagnu.info, Node: framework.exp, Next: remote.exp, Up: DejaGnu Builtins
|
170 |
|
|
|
171 |
|
|
Core Internal Procedures
|
172 |
|
|
------------------------
|
173 |
|
|
|
174 |
|
|
*Note A POSIX conforming test framework: Posix, for more detailed
|
175 |
|
|
explanations of the test outcomes (`FAIL', `PASS', `UNTESTED',
|
176 |
|
|
`UNRESOLVED', `UNSUPPORTED').
|
177 |
|
|
|
178 |
|
|
`perror "STRING NUMBER"'
|
179 |
|
|
Declares a severe error in the testing framework itself. `perror'
|
180 |
|
|
writes in the log files a message beginning with `ERROR',
|
181 |
|
|
appending the argument STRING. If the optional NUMBER is supplied,
|
182 |
|
|
then this is used to set the internal count of errors to that
|
183 |
|
|
value.
|
184 |
|
|
|
185 |
|
|
As a side effect, `perror' also changes the effect of the next
|
186 |
|
|
`pass' or `fail' command: the test outcome becomes `UNRESOLVED',
|
187 |
|
|
since an automatic `PASS' or `FAIL' cannot be trusted after a
|
188 |
|
|
severe error in the test framework. If the optional numeric value
|
189 |
|
|
is `0', then there are no further side effects to calling this
|
190 |
|
|
function, and the following test outcome doesn't become
|
191 |
|
|
`UNRESOLVED'. This can be used for errors with no known side
|
192 |
|
|
effects.
|
193 |
|
|
|
194 |
|
|
`warning "STRING NUMBER"'
|
195 |
|
|
Declares detection of a minor error in the test case itself.
|
196 |
|
|
`warning' writes in the log files a message beginning with
|
197 |
|
|
`WARNING', appending the argument STRING. Use `warning' rather
|
198 |
|
|
than `error' for cases (such as communication failure to be
|
199 |
|
|
followed by a retry) where the test case can recover from the
|
200 |
|
|
error. If the optional NUMBER is supplied, then this is used to
|
201 |
|
|
set the internal count of warnings to that value.
|
202 |
|
|
|
203 |
|
|
As a side effect, `warning_threshold' or more calls to `warning'
|
204 |
|
|
in a single test case also changes the effect of the next `pass'
|
205 |
|
|
or `fail' command: the test outcome becomes `UNRESOLVED' since an
|
206 |
|
|
automatic `PASS' or `FAIL' may not be trustworthy after many
|
207 |
|
|
warnings. If the optional numeric value is `0', then there are no
|
208 |
|
|
further side effects to calling this function, and the following
|
209 |
|
|
test outcome doesn't become `UNRESOLVED'. This can be used for
|
210 |
|
|
errors with no known side effects.
|
211 |
|
|
|
212 |
|
|
`note "STRING"'
|
213 |
|
|
Appends an informational message to the log file. `note' writes
|
214 |
|
|
in the log files a message beginning with `NOTE', appending the
|
215 |
|
|
argument STRING. Use `note' sparingly. `verbose' should be used
|
216 |
|
|
for most such messages, but in cases where a message is needed in
|
217 |
|
|
the log file regardless of the verbosity level use `note'.
|
218 |
|
|
|
219 |
|
|
`pass "STRING"'
|
220 |
|
|
Declares a test to have passed. `pass' writes in the log files a
|
221 |
|
|
message beginning with `PASS' (or `XPASS', if failure was
|
222 |
|
|
expected), appending the argument STRING.
|
223 |
|
|
|
224 |
|
|
`fail "STRING"'
|
225 |
|
|
Declares a test to have failed. `fail' writes in the log files a
|
226 |
|
|
message beginning with `FAIL' (or `XFAIL', if failure was
|
227 |
|
|
expected), appending the argument STRING.
|
228 |
|
|
|
229 |
|
|
`unresolved "STRING"'
|
230 |
|
|
Declares a test to have an unresolved outcome. `unresolved' writes
|
231 |
|
|
in the log file a message beginning with `UNRESOLVED', appending
|
232 |
|
|
the argument STRING. This usually means the test did not execute
|
233 |
|
|
as expected, and a human being must go over results to determine
|
234 |
|
|
if it passed or failed (and to improve the test case).
|
235 |
|
|
|
236 |
|
|
`untested "STRING"'
|
237 |
|
|
Declares a test was not run. `untested' writes in the log file a
|
238 |
|
|
message beginning with `UNTESTED', appending the argument STRING.
|
239 |
|
|
For example, you might use this in a dummy test whose only role is
|
240 |
|
|
to record that a test does not yet exist for some feature.
|
241 |
|
|
|
242 |
|
|
`unsupported "STRING"'
|
243 |
|
|
Declares that a test case depends on some facility that does not
|
244 |
|
|
exist in the testing environment. `unsupported' writes in the log
|
245 |
|
|
file a message beginning with `UNSUPPORTED', appending the argument
|
246 |
|
|
STRING.
|
247 |
|
|
|
248 |
|
|
`get_warning_threshold'
|
249 |
|
|
Returns the current value of `warning_threshold'. The default
|
250 |
|
|
value is 3.
|
251 |
|
|
|
252 |
|
|
`set_warning_threshold THRESHOLD'
|
253 |
|
|
Sets the value of `warning_threshold'. A value of `0' disables
|
254 |
|
|
it: calls to `warning' will not turn a `PASS' or `FAIL' into an
|
255 |
|
|
`UNRESOLVED'.
|
256 |
|
|
|
257 |
|
|
`transform "TOOLNAME"'
|
258 |
|
|
Generates a string for the name of a tool as it was configured and
|
259 |
|
|
installed, given its native name (as the argument TOOLNAME). This
|
260 |
|
|
makes the assumption that all tools are installed using the same
|
261 |
|
|
naming conventions: it extrapolates from the invocation name for
|
262 |
|
|
`runtest'. For example, if you call `runtest' as
|
263 |
|
|
`m68k-vxworks-runtest', the result of ` transform "gcc" ' is
|
264 |
|
|
`m68k-vxworks-gcc'.
|
265 |
|
|
|
266 |
|
|
`ishost "HOST"'
|
267 |
|
|
Tests for a particular _host_ environment. If the currently
|
268 |
|
|
configured host matches the argument string, the result is `1';
|
269 |
|
|
otherwise the result is `0'. HOST must be a full three-part
|
270 |
|
|
`configure' host name; in particular, you may not use the shorter
|
271 |
|
|
nicknames supported by `configure' (but you can use wildcard
|
272 |
|
|
characters, using shell syntax, to specify sets of names).
|
273 |
|
|
|
274 |
|
|
`istarget "TARGET"'
|
275 |
|
|
Tests for a particular _target_ environment. If the currently
|
276 |
|
|
configured target matches the argument string, the result is `1';
|
277 |
|
|
otherwise the result is `0'. TARGET must be a full three-part
|
278 |
|
|
`configure' target name; in particular, you may not use the
|
279 |
|
|
shorter nicknames supported by `configure' (but you can use
|
280 |
|
|
wildcard characters, using shell syntax, to specify sets of
|
281 |
|
|
names). If it is passed a `NULL' string, then it returns the name
|
282 |
|
|
of the build canonical configuration.
|
283 |
|
|
|
284 |
|
|
`isbuild "HOST"'
|
285 |
|
|
Tests for a particular _build host_ environment. If the currently
|
286 |
|
|
configured host matches the argument string, the result is `1';
|
287 |
|
|
otherwise the result is `0'. HOST must be a full three-part
|
288 |
|
|
`configure' host name; in particular, you may not use the shorter
|
289 |
|
|
nicknames supported by `configure' (but you can use wildcard
|
290 |
|
|
characters, using shell syntax, to specify sets of names). If it is
|
291 |
|
|
passed a `NULL' string, then it returns the name of the build
|
292 |
|
|
canonical configuration.
|
293 |
|
|
|
294 |
|
|
item is3way "HOST" Tests for a canadian cross. This is when the
|
295 |
|
|
tests will be run on a remotly hosted cross compiler. If it is a
|
296 |
|
|
canadian cross, then the result is `1'; otherwise the result is
|
297 |
|
|
`0'.
|
298 |
|
|
|
299 |
|
|
`isnative'
|
300 |
|
|
Tests whether the current configuration has the same host and
|
301 |
|
|
target. When it runs in a _native_ configuration this procedure
|
302 |
|
|
returns a `1'; otherwise it returns a `0'.
|
303 |
|
|
|
304 |
|
|
`load_lib "LIBRARY-FILE"'
|
305 |
|
|
Loads the file LIBRARY-FILE by searching a fixed path built into
|
306 |
|
|
`runtest'. If DejaGnu has been installed, it looks in a path
|
307 |
|
|
starting with the installed library directory. If you are running
|
308 |
|
|
DejaGnu directly from a source directory, without first running
|
309 |
|
|
`make install', this path defaults to the current directory. In
|
310 |
|
|
either case, it then looks in the current directory for a directory
|
311 |
|
|
called `lib'. If there are duplicate definitions, the last one
|
312 |
|
|
loaded takes precedence over the earlier ones.
|
313 |
|
|
|
314 |
|
|
`setup_xfail "CONFIG [BUGID]"'
|
315 |
|
|
Declares that the test is expected to fail on a particular set of
|
316 |
|
|
configurations. The CONFIG argument must be a list of full
|
317 |
|
|
three-part `configure' target name; in particular, you may not use
|
318 |
|
|
the shorter nicknames supported by `configure' (but you can use the
|
319 |
|
|
common shell wildcard characters to specify sets of names). The
|
320 |
|
|
BUGID argument is optional, and used only in the logging file
|
321 |
|
|
output; use it as a link to a bug-tracking system such as GNATS
|
322 |
|
|
(*note Overview: (gnats.info)Overview.).
|
323 |
|
|
|
324 |
|
|
Once you use `setup_xfail', the `fail' and `pass' procedures
|
325 |
|
|
produce the messages `XFAIL' and `XPASS' respectively, allowing
|
326 |
|
|
you to distinguish expected failures (and unexpected success!)
|
327 |
|
|
from other test outcomes.
|
328 |
|
|
|
329 |
|
|
_Warning:_ you must clear the expected failure after using
|
330 |
|
|
`setup_xfail' in a test case. Any call to `pass' or `fail' clears
|
331 |
|
|
the expected failure implicitly; if the test has some other
|
332 |
|
|
outcome, e.g. an error, you can call `clear_xfail' to clear the
|
333 |
|
|
expected failure explicitly. Otherwise, the expected-failure
|
334 |
|
|
declaration applies to whatever test runs next, leading to
|
335 |
|
|
surprising results.
|
336 |
|
|
|
337 |
|
|
`check_conditional_xfail MESSAGE TARGETS INCLUDES EXCLUDES'
|
338 |
|
|
This procedure adds a condition xfail, based on compiler options
|
339 |
|
|
used to create a test case executable. If an include options is
|
340 |
|
|
found in the compiler flags, and it's the right architecture,
|
341 |
|
|
it'll trigger an XFAIL. Otherwise it'll produce an ordinary FAIL.
|
342 |
|
|
You can also specify flags to exclude. This makes a result be a
|
343 |
|
|
FAIL, even if the included options are found. To set the
|
344 |
|
|
conditional, set the variable COMPILER_CONDITIONAL_XFAIL_DATA to
|
345 |
|
|
the fields "[message string] [targets list] [includes list]
|
346 |
|
|
[excludes list]" (descriptions below). This is the checked at
|
347 |
|
|
pass/fail decision time, so there is no need to call the procedure
|
348 |
|
|
yourself, unless you wish to know if it gets triggered. After a
|
349 |
|
|
pass/fail, the variable is reset, so it doesn't effect other tests.
|
350 |
|
|
|
351 |
|
|
The parameters are:
|
352 |
|
|
|
353 |
|
|
`message'
|
354 |
|
|
is the message to print with the normal test result
|
355 |
|
|
|
356 |
|
|
`targets'
|
357 |
|
|
is a string with the targets to activate this conditional on.
|
358 |
|
|
|
359 |
|
|
`includes'
|
360 |
|
|
is a list of sets of options to search for in the compiler
|
361 |
|
|
options to activate this conditional. If any set of the
|
362 |
|
|
options matches, then this conditional is true.
|
363 |
|
|
|
364 |
|
|
`excludes'
|
365 |
|
|
is a list of sets of options to search for in the compiler
|
366 |
|
|
options to activate this conditional. If any set of the
|
367 |
|
|
options matches, (regardless of whether any of the include
|
368 |
|
|
sets match) then this conditional is de-activated.
|
369 |
|
|
|
370 |
|
|
returns:
|
371 |
|
|
|
372 |
|
|
`1'
|
373 |
|
|
if the conditional is true
|
374 |
|
|
|
375 |
|
|
`0'
|
376 |
|
|
if the conditional is false
|
377 |
|
|
|
378 |
|
|
An example of setting the variable would be:
|
379 |
|
|
|
380 |
|
|
set compiler_conditional_xfail_data { \
|
381 |
|
|
"I sure wish I knew why this was hosed" \
|
382 |
|
|
"sparc*-sun*-* *-pc-*-*" \
|
383 |
|
|
{-"Wall -v" "-O3"} \
|
384 |
|
|
{-"O1" "-Map" } \
|
385 |
|
|
}
|
386 |
|
|
|
387 |
|
|
What this does is it matches only for these two targets if "-Wall
|
388 |
|
|
-v" or "-O3" is set, but neither "-O1" or "-Map" is set.
|
389 |
|
|
|
390 |
|
|
For a set to match, the options specified are searched for
|
391 |
|
|
independantly of each other, so a "-Wall -v" matches either "-Wall
|
392 |
|
|
-v" or "-v -Wall". A space seperates the options in the string.
|
393 |
|
|
Glob-style regular expressions are also permitted.
|
394 |
|
|
|
395 |
|
|
`clear_xfail CONFIG'
|
396 |
|
|
Cancel an expected failure (previously declared with `setup_xfail')
|
397 |
|
|
for a particular set of configurations. The CONFIG argument is a
|
398 |
|
|
list of configuration target names. It is only necessary to call
|
399 |
|
|
`clear_xfail' if a test case ends without calling either `pass' or
|
400 |
|
|
`fail', after calling `setup_xfail'.
|
401 |
|
|
|
402 |
|
|
`verbose [-log] [-n] [--] "STRING" NUMBER'
|
403 |
|
|
Test cases can use this function to issue helpful messages
|
404 |
|
|
depending on the number of `--verbose' options on the `runtest'
|
405 |
|
|
command line. It prints STRING if the value of the variable
|
406 |
|
|
`verbose' is higher than or equal to the optional NUMBER. The
|
407 |
|
|
default value for NUMBER is 1. Use the optional `-log' argument
|
408 |
|
|
to cause STRING to always be added to the log file, even if it
|
409 |
|
|
won't be printed. Use the optional `-n' argument to print STRING
|
410 |
|
|
without a trailing newline. Use the optional `--' argument if
|
411 |
|
|
STRING begins with "-".
|
412 |
|
|
|
413 |
|
|
|
414 |
|
|
File: dejagnu.info, Node: remote.exp, Next: utils.exp, Prev: framework.exp, Up: DejaGnu Builtins
|
415 |
|
|
|
416 |
|
|
Remote Communication Procedures
|
417 |
|
|
-------------------------------
|
418 |
|
|
|
419 |
|
|
`lib/remote.exp' defines these functions, for establishing and managing
|
420 |
|
|
communications:
|
421 |
|
|
|
422 |
|
|
_Procedures to establish a connection:_ Each of these procedures
|
423 |
|
|
tries to establish the connection up to three times before returning.
|
424 |
|
|
Warnings (if retries will continue) or errors (if the attempt is
|
425 |
|
|
abandoned) report on communication failures. The result for any of
|
426 |
|
|
these procedures is either `-1', when the connection cannot be
|
427 |
|
|
established, or the spawn ID returned by the `expect' command `spawn'.
|
428 |
|
|
|
429 |
|
|
It use the value of the `connect' field in the `target_info' array
|
430 |
|
|
(was `connectmode' as the type of connection to make. Current supported
|
431 |
|
|
connection types are tip, kermit, telnet, rsh, rlogin, and netdata. If
|
432 |
|
|
the `--reboot' option was used on the runtest command line, then the
|
433 |
|
|
target is rebooted before the connection is made.
|
434 |
|
|
|
435 |
|
|
`remote_open TYPE'
|
436 |
|
|
_Remote Connection Procedure._ This is passed _host_ or _target_.
|
437 |
|
|
Host or target refers to whether it is a connection to a remote
|
438 |
|
|
target, or a remote host. This opens the connection to the desired
|
439 |
|
|
target or host using the default values in the configuration
|
440 |
|
|
system. It returns that `spawn_id' of the process that manages the
|
441 |
|
|
connection. This value can be used in `expect' or `exp_send'
|
442 |
|
|
statements, or passed to other procedures that need the connection
|
443 |
|
|
process's id. This also sets the `fileid' field in the
|
444 |
|
|
`target_info' array.
|
445 |
|
|
|
446 |
|
|
`remote_close SHELLID'
|
447 |
|
|
_shellid_ is value returned by a call to `remote_open'. This
|
448 |
|
|
closes the connection to the target so resources can be used by
|
449 |
|
|
others. This parameter can be left off if the `fileid' field in the
|
450 |
|
|
`target_info' array is set.
|
451 |
|
|
|
452 |
|
|
`telnet HOSTNAME PORT'
|
453 |
|
|
`rlogin HOSTNAME'
|
454 |
|
|
`rsh HOSTNAME'
|
455 |
|
|
_IP network procedures._ HOSTNAME refers to the IP address or name
|
456 |
|
|
(for example, an entry in `/etc/hosts') for this target. The
|
457 |
|
|
procedure names reflect the Unix utility used to establish a
|
458 |
|
|
connection. The optional PORT is used to specify the IP port
|
459 |
|
|
number. The value of the `netport' field in the `target_info'
|
460 |
|
|
array is used. (was `$netport') This value has two parts, the
|
461 |
|
|
hostname and the port number, seperated by a _:_. If `host' or
|
462 |
|
|
`target' is used in the `hostname' field, than the config array is
|
463 |
|
|
used for all information.
|
464 |
|
|
|
465 |
|
|
`tip PORT'
|
466 |
|
|
_Serial line procedure._ Connect using the Unix utility `tip'.
|
467 |
|
|
PORT must be a name from the `tip' configuration file
|
468 |
|
|
`/etc/remote'. Often, this is called `hardwire', or something
|
469 |
|
|
like `ttya'. This file holds all the configuration data for the
|
470 |
|
|
serial port. The value of the `serial' field in the `target_info'
|
471 |
|
|
array is used. (was `$serialport') If `host' or `target' is used
|
472 |
|
|
in the `port' field, than the config array is used for all
|
473 |
|
|
information.
|
474 |
|
|
|
475 |
|
|
`kermit PORT BPS'
|
476 |
|
|
_Serial line procedure._ Connect using the program `kermit'.
|
477 |
|
|
PORT is the device name, e.g. `/dev/ttyb'. BPS is the line speed
|
478 |
|
|
to use (in bits per second) for the connection. The value of the
|
479 |
|
|
`serial' field in the `target_info' array is used. (was
|
480 |
|
|
`$serialport') If `host' or `target' is used in the `port' field,
|
481 |
|
|
than the config array is used for all information.
|
482 |
|
|
|
483 |
|
|
_Procedures to manage a connection:_
|
484 |
|
|
|
485 |
|
|
`tip_download SPAWNID FILE'
|
486 |
|
|
Download `FILE' to the process SPAWNID (the value returned when
|
487 |
|
|
the connection was established), using the `~put' command under
|
488 |
|
|
`tip'. Most often used for single board computers that require
|
489 |
|
|
downloading programs in ASCII S-records. Returns `1' if an error
|
490 |
|
|
occurs, `0' otherwise.
|
491 |
|
|
|
492 |
|
|
`exit_remote_shell SPAWNID'
|
493 |
|
|
Exits a remote process started by any of the connection procedures.
|
494 |
|
|
SPAWNID is the result of the connection procedure that started the
|
495 |
|
|
remote process.
|
496 |
|
|
|
497 |
|
|
`download FILE [ SPAWNID ]'
|
498 |
|
|
After you establish a connection to a target, you can download
|
499 |
|
|
programs using this command. `download' reads in FILE (object
|
500 |
|
|
code in S-record format) and writes it to the device controlling
|
501 |
|
|
this SPAWNID. (From the point of view of the target, the S-record
|
502 |
|
|
file comes in via standard input.)
|
503 |
|
|
|
504 |
|
|
If you have more than one target active, you can use the optional
|
505 |
|
|
argument SPAWNID to specify an alternative target (the default is
|
506 |
|
|
the most recently established SPAWNID.)
|
507 |
|
|
|
508 |
|
|
|
509 |
|
|
File: dejagnu.info, Node: utils.exp, Next: target.exp, Prev: remote.exp, Up: DejaGnu Builtins
|
510 |
|
|
|
511 |
|
|
Utility Procedures
|
512 |
|
|
------------------
|
513 |
|
|
|
514 |
|
|
`lib/utils.exp' defines these utility procedures:
|
515 |
|
|
|
516 |
|
|
`getdirs DIR'
|
517 |
|
|
`getdirs DIR PATTERN'
|
518 |
|
|
Returns a list of all the directories in the single directory DIR
|
519 |
|
|
that match PATTERN. If you do not specify PATTERN, `getdirs'
|
520 |
|
|
assumes `*'. You may use the common shell wildcard characters in
|
521 |
|
|
PATTERN. If no directories match the pattern, then a `NULL' string
|
522 |
|
|
is returned.
|
523 |
|
|
|
524 |
|
|
`find DIR PATTERN'
|
525 |
|
|
Search for files whose names match PATTERN (using shell wildcard
|
526 |
|
|
characters for filename expansion). Search subdirectories
|
527 |
|
|
recursively, starting at DIR. The result is the list of files
|
528 |
|
|
whose names match; if no files match, the result is empty.
|
529 |
|
|
Filenames in the result include all intervening subdirectory
|
530 |
|
|
names. If no files match the pattern, then a `NULL' string is
|
531 |
|
|
returned.
|
532 |
|
|
|
533 |
|
|
`which BINARY'
|
534 |
|
|
Searches the execution path for an executable file BINARY, like
|
535 |
|
|
the the BSD `which' utility. This procedure uses the shell
|
536 |
|
|
environment variable `PATH'. It returns `0' if the binary is not
|
537 |
|
|
in the path, or if there is no `PATH' environment variable. If
|
538 |
|
|
BINARY is in the path, it returns the full path to BINARY.
|
539 |
|
|
|
540 |
|
|
`grep FILENAME REGEXP'
|
541 |
|
|
|
542 |
|
|
`grep FILENAME REGEXP line'
|
543 |
|
|
Search the file called FILENAME (a fully specified path) for lines
|
544 |
|
|
that contain a match for regular expression REGEXP. The result is
|
545 |
|
|
a list of all the lines that match. If no lines match, the result
|
546 |
|
|
is an empty string. Specify REGEXP using the standard regular
|
547 |
|
|
expression style used by the Unix utility program `grep'.
|
548 |
|
|
|
549 |
|
|
Use the optional third argument `line' to start lines in the result
|
550 |
|
|
with the line number in FILENAME. (This argument is simply an
|
551 |
|
|
option flag; type it just as shown--`line'.)
|
552 |
|
|
|
553 |
|
|
`diff FILENAME FILENAME'
|
554 |
|
|
Compares the two files and returns a 1 if they match, or a 0 if
|
555 |
|
|
they don't. If `verbose' is set, then it'll print the differences
|
556 |
|
|
to the screen.
|
557 |
|
|
|
558 |
|
|
`slay NAME'
|
559 |
|
|
This look in the process table for NAME and send it a unix
|
560 |
|
|
`SIGINT', killing the process.
|
561 |
|
|
|
562 |
|
|
`absolute PATH'
|
563 |
|
|
This procedure takes the relative PATH, and converts it to an
|
564 |
|
|
absolute path.
|
565 |
|
|
|
566 |
|
|
`psource FILENAME'
|
567 |
|
|
This sources the file FILENAME, and traps all errors. It also
|
568 |
|
|
ignores all extraneous output. If there was an error it returns a
|
569 |
|
|
1, otherwise it returns a 0.
|
570 |
|
|
|
571 |
|
|
`prune LIST PATTERN'
|
572 |
|
|
Remove elements of the Tcl list LIST. Elements are fields
|
573 |
|
|
delimited by spaces. The result is a copy of LIST, without any
|
574 |
|
|
elements that match PATTERN. You can use the common shell
|
575 |
|
|
wildcard characters to specify PATTERN.
|
576 |
|
|
|
577 |
|
|
`setenv VAR VAL'
|
578 |
|
|
Sets the variable VAR to the value VAL.
|
579 |
|
|
|
580 |
|
|
`unsetenv VAR'
|
581 |
|
|
Unsets the environment variable VAR
|
582 |
|
|
|
583 |
|
|
`getenv VAR'
|
584 |
|
|
returns the value of VAR in the environment if it exists,
|
585 |
|
|
otherwise it returns `NULL'.
|
586 |
|
|
|
587 |
|
|
`runtest_file_p RUNTESTS TESTCASE'
|
588 |
|
|
Search RUNTESTS for TESTCASE and return 1 if found, 0 if not.
|
589 |
|
|
RUNTESTS is a list of two elements. The first is the pathname of
|
590 |
|
|
the testsuite expect script running. The second is a copy of what
|
591 |
|
|
was on the right side of the `=' if `foo.exp="..."' was specified,
|
592 |
|
|
or an empty string if no such argument is present. This is used
|
593 |
|
|
by tools like compilers where each testcase is a file.
|
594 |
|
|
|
595 |
|
|
`prune_system_crud SYSTEM TEXT'
|
596 |
|
|
For system SYSTEM, delete text the host or target operating system
|
597 |
|
|
might issue that will interfere with pattern matching of program
|
598 |
|
|
output in TEXT. An example is the message that is printed if a
|
599 |
|
|
shared library is out of date.
|
600 |
|
|
|
601 |
|
|
|
602 |
|
|
File: dejagnu.info, Node: target.exp, Next: debugger.exp, Prev: utils.exp, Up: DejaGnu Builtins
|
603 |
|
|
|
604 |
|
|
Cross target procedure
|
605 |
|
|
----------------------
|
606 |
|
|
|
607 |
|
|
`lib/target.exp' defines these utility procedures:
|
608 |
|
|
|
609 |
|
|
`push_target _name_'
|
610 |
|
|
This makes the target named _name_ be the current target
|
611 |
|
|
connection. The value of _name_ is an index into the `target_info'
|
612 |
|
|
array and is set in the global config file.
|
613 |
|
|
|
614 |
|
|
`pop_target'
|
615 |
|
|
This unsets the current target connection.
|
616 |
|
|
|
617 |
|
|
`list_targets'
|
618 |
|
|
This lists all the supported targets for this architecture.
|
619 |
|
|
|
620 |
|
|
`push_host _name_'
|
621 |
|
|
This makes the host named _name_ be the current remote host
|
622 |
|
|
connection. The value of _name_ is an index into the `target_info'
|
623 |
|
|
array and is set in the global config file.
|
624 |
|
|
|
625 |
|
|
`pop_host'
|
626 |
|
|
This unsets the current host connection.
|
627 |
|
|
|
628 |
|
|
This invokes the compiler as set by `CC' to compile the file
|
629 |
|
|
_file_. The default options for many cross compilation targets are
|
630 |
|
|
_guessed_ by DejaGnu, and these options can be added to by passing
|
631 |
|
|
in more parameters as arguments to `compile'. Optionally, this will
|
632 |
|
|
also use the value of the `cflags' field in the target config
|
633 |
|
|
array. If the host is not the same as the build machines, then then
|
634 |
|
|
compiler is run on the remote host using `execute_anywhere'.
|
635 |
|
|
|
636 |
|
|
This produces an archive file. Any parameters passed to `archive'
|
637 |
|
|
are used in addition to the default flags. Optionally, this will
|
638 |
|
|
also use the value of the `arflags' field in the target config
|
639 |
|
|
array. If the host is not the same as the build machines, then then
|
640 |
|
|
archiver is run on the remote host using `execute_anywhere'.
|
641 |
|
|
|
642 |
|
|
This generates an index for the archive file for systems that
|
643 |
|
|
aren't POSIX yet. Any parameters passed to `ranlib' are used in
|
644 |
|
|
for the flags.
|
645 |
|
|
|
646 |
|
|
`execute_anywhere _cmdline_'
|
647 |
|
|
This executes the _cmdline_ on the proper host. This should be used
|
648 |
|
|
as a replacement for the Tcl command `exec' as this version
|
649 |
|
|
utilizes the target config info to execute this command on the
|
650 |
|
|
build machine or a remote host. All config information for the
|
651 |
|
|
remote host must be setup to have this command work. If this is a
|
652 |
|
|
canadian cross, (where we test a cross compiler that runs on a
|
653 |
|
|
different host then where DejaGnu is running) then a connection is
|
654 |
|
|
made to the remote host and the command is executed there. It
|
655 |
|
|
returns either _REMOTERROR_ (for an error) or the output produced
|
656 |
|
|
when the command was executed. This is used for running the tool
|
657 |
|
|
to be tested, not a test case.
|
658 |
|
|
|
659 |
|
|
|
660 |
|
|
File: dejagnu.info, Node: debugger.exp, Prev: target.exp, Up: DejaGnu Builtins
|
661 |
|
|
|
662 |
|
|
Debugging Procedures
|
663 |
|
|
--------------------
|
664 |
|
|
|
665 |
|
|
`lib/debugger.exp' defines these utility procedures:
|
666 |
|
|
|
667 |
|
|
`dumpvars _expr_'
|
668 |
|
|
This takes a csh style regular expression (glob rules) and prints
|
669 |
|
|
the values of the global variable names that match. It is
|
670 |
|
|
abbreviated as `dv'
|
671 |
|
|
|
672 |
|
|
`dumplocals _expr_'
|
673 |
|
|
This takes a csh style regular expression (glob rules) and prints
|
674 |
|
|
the values of the local variable names that match. It is
|
675 |
|
|
abbreviated as `dl'.
|
676 |
|
|
|
677 |
|
|
`dumprocs _expr_'
|
678 |
|
|
This takes a csh style regular expression (glob rules) and prints
|
679 |
|
|
the body of all procs that match. It is abbreviated as `dp'
|
680 |
|
|
|
681 |
|
|
`dumpwatch _expr_'
|
682 |
|
|
This takes a csh style regular expression (glob rules) and prints
|
683 |
|
|
all the watchpoints. It is abbreviated as `dw'.
|
684 |
|
|
|
685 |
|
|
`watchunset _var_'
|
686 |
|
|
This breaks program execution when the variable _var_ is unset. It
|
687 |
|
|
is abbreviated as `wu'.
|
688 |
|
|
|
689 |
|
|
`watchwrite _var_'
|
690 |
|
|
This breaks program execution when the variable _var_ is written.
|
691 |
|
|
It is abbreviated as `ww'.
|
692 |
|
|
|
693 |
|
|
`watchread _var_'
|
694 |
|
|
This breaks program execution when the variable _var_ is read. It
|
695 |
|
|
is abbreviated as `wr'.
|
696 |
|
|
|
697 |
|
|
`watchdel _watch_'
|
698 |
|
|
This deletes a the watchpoint for _watch_. It is abbreviated as
|
699 |
|
|
`wd'.
|
700 |
|
|
|
701 |
|
|
`print _var_'
|
702 |
|
|
This prints the value of the variable _var_. It is abbreviated as
|
703 |
|
|
`p'.
|
704 |
|
|
|
705 |
|
|
`quit'
|
706 |
|
|
This makes runtest exit. It is abbreviated as `q'.
|
707 |
|
|
|
708 |
|
|
`bt'
|
709 |
|
|
This prints a backtrace of the executed Tcl commands.
|
710 |
|
|
|
711 |
|
|
|
712 |
|
|
File: dejagnu.info, Node: Target Dependent, Next: Cross Targets, Prev: DejaGnu Builtins, Up: Internals
|
713 |
|
|
|
714 |
|
|
Target dependent procedures
|
715 |
|
|
===========================
|
716 |
|
|
|
717 |
|
|
Each combination of target and tool requires some target-dependent
|
718 |
|
|
procedures. The names of these procedures have a common form: the tool
|
719 |
|
|
name, followed by an underbar `_', and finally a suffix describing the
|
720 |
|
|
procedure's purpose. For example, a procedure to extract the version
|
721 |
|
|
from GDB is called `gdb_version'. *Note Initialization Module: Init
|
722 |
|
|
Module, for a discussion of how DejaGnu arranges to find the right
|
723 |
|
|
procedures for each target.
|
724 |
|
|
|
725 |
|
|
`runtest' itself calls only two of these procedures, `TOOL_exit' and
|
726 |
|
|
`TOOL_version'; these procedures use no arguments.
|
727 |
|
|
|
728 |
|
|
The other two procedures, `TOOL_start' and `TOOL_load', are only
|
729 |
|
|
called by the test suites themselves (or by testsuite-specific
|
730 |
|
|
initialization code); they may take arguments or not, depending on the
|
731 |
|
|
conventions used within each test suite.
|
732 |
|
|
|
733 |
|
|
`TOOL_start'
|
734 |
|
|
Starts a particular tool. For an interactive tool, `TOOL_start'
|
735 |
|
|
starts and initializes the tool, leaving the tool up and running
|
736 |
|
|
for the test cases; an example is `gdb_start', the start function
|
737 |
|
|
for GDB. For a batch oriented tool, `TOOL_start' is optional; the
|
738 |
|
|
recommended convention is to let `TOOL_start' run the tool,
|
739 |
|
|
leaving the output in a variable called `comp_output'. Test
|
740 |
|
|
scripts can then analyze `$comp_output' to determine the test
|
741 |
|
|
results. An example of this second kind of start function is
|
742 |
|
|
`gcc_start', the start function for GCC.
|
743 |
|
|
|
744 |
|
|
`runtest' itself _does not call_ `TOOL_start'. The initialization
|
745 |
|
|
module `TOOL_init.exp' must call `TOOL_start' for interactive
|
746 |
|
|
tools; for batch-oriented tools, each individual test script calls
|
747 |
|
|
`TOOL_start' (or makes other arrangements to run the tool).
|
748 |
|
|
|
749 |
|
|
`TOOL_load'
|
750 |
|
|
Loads something into a tool. For an interactive tool, this
|
751 |
|
|
conditions the tool for a particular test case; for example,
|
752 |
|
|
`gdb_load' loads a new executable file into the debugger. For
|
753 |
|
|
batch oriented tools, `TOOL_load' may do nothing--though, for
|
754 |
|
|
example, the GCC support uses `gcc_load' to load and run a binary
|
755 |
|
|
on the target environment. Conventionally, `TOOL_load' leaves the
|
756 |
|
|
output of any program it runs in a variable called `exec_output'.
|
757 |
|
|
Writing `TOOL_load' can be the most complex part of extending
|
758 |
|
|
DejaGnu to a new tool or a new target, if it requires much
|
759 |
|
|
communication coding or file downloading.
|
760 |
|
|
|
761 |
|
|
Test scripts call `TOOL_load'.
|
762 |
|
|
|
763 |
|
|
`TOOL_exit'
|
764 |
|
|
Cleans up (if necessary) before `runtest' exits. For interactive
|
765 |
|
|
tools, this usually ends the interactive session. You can also use
|
766 |
|
|
`TOOL_exit' to remove any temporary files left over from the tests.
|
767 |
|
|
|
768 |
|
|
`runtest' calls `TOOL_exit'.
|
769 |
|
|
|
770 |
|
|
`TOOL_version'
|
771 |
|
|
Prints the version label and number for TOOL. This is called by
|
772 |
|
|
the DejaGnu procedure that prints the final summary report. The
|
773 |
|
|
output should consist of the full path name used for the tested
|
774 |
|
|
tool, and its version number.
|
775 |
|
|
|
776 |
|
|
`runtest' calls `TOOL_version'.
|
777 |
|
|
|
778 |
|
|
The usual convention for return codes from any of these procedures
|
779 |
|
|
(although it is not required by `runtest') is to return `0' if the
|
780 |
|
|
procedure succeeded, `1' if it failed, and `-1' if there was a
|
781 |
|
|
communication error.
|
782 |
|
|
|
783 |
|
|
|
784 |
|
|
File: dejagnu.info, Node: Cross Targets, Next: Input Files, Prev: Target Dependent, Up: Internals
|
785 |
|
|
|
786 |
|
|
Remote targets supported
|
787 |
|
|
========================
|
788 |
|
|
|
789 |
|
|
The DejaGnu distribution includes support for the following remote
|
790 |
|
|
targets. You can set the target name and the connect mode in the
|
791 |
|
|
`site.exp' file (using the Tcl variables `targetname' and
|
792 |
|
|
`connectmode', respectively), or on the `runtest' command line (using
|
793 |
|
|
`--name' and `--connect').
|
794 |
|
|
|
795 |
|
|
*AMD 29000, with UDI protocol*
|
796 |
|
|
Configure DejaGnu for target `a29k-amd-udi'. (Cygnus `configure'
|
797 |
|
|
also recognizes the abbreviation `udi29k'.) Then, to run tests,
|
798 |
|
|
use the `runtest' target name to specify whether you want to use a
|
799 |
|
|
simulator, or a particular hardware board. The particular string
|
800 |
|
|
to use with `--name' will depend on your UDI setup file, `udi_soc'
|
801 |
|
|
(if `udi_soc' is not in your working directory, the environment
|
802 |
|
|
variable `UDICONF' should contain a path to this file). For
|
803 |
|
|
example, if your UDI setup file includes these lines:
|
804 |
|
|
|
805 |
|
|
iss AF_UNIX * isstip -r /home/gnu/29k/src/osboot/sim/osboot
|
806 |
|
|
mon AF_UNIX * montip -t serial -baud 9600 -com /dev/ttyb
|
807 |
|
|
|
808 |
|
|
* *
|
809 |
|
|
You can use `--name iss' to run tests on the simulator, and
|
810 |
|
|
`--name mon' to run tests on the 29K hardware. See the
|
811 |
|
|
manufacturer's manuals for more information on UDI and `udi_soc'.
|
812 |
|
|
|
813 |
|
|
The default connect protocol is `mondfe' with either back end.
|
814 |
|
|
`mondfe' is the only shell DejaGnu supports for UDI targets.
|
815 |
|
|
`mondfe' is an AMD specific monitor program freely available from
|
816 |
|
|
AMD.
|
817 |
|
|
|
818 |
|
|
_Warning:_ This target requires GDB version 4.7.2 (or greater).
|
819 |
|
|
Earlier versions of GDB do not fully support the `load' command on
|
820 |
|
|
this target, so DejaGnu has no way to load executable files from
|
821 |
|
|
the debugger.
|
822 |
|
|
|
823 |
|
|
*Motorola 680x0 boards, a.out or COFF object format*
|
824 |
|
|
Configure DejaGnu for any remote target matching `m68k-*'.
|
825 |
|
|
|
826 |
|
|
_Warning:_ Most `m68k-*' configurations run all tests only for
|
827 |
|
|
native testing (when the target is the same as the host). When you
|
828 |
|
|
specify most of these targets for a cross configuration, you will
|
829 |
|
|
only be able to use tests that run completely within the host (for
|
830 |
|
|
example, tests of the binary utilities such as the archiver; or
|
831 |
|
|
compiler tests that only generate code rather than running it).
|
832 |
|
|
|
833 |
|
|
To run a.out or COFF binaries on a remote M68K, you must configure
|
834 |
|
|
DejaGnu for a particular target board. `m68k-abug' is an example.
|
835 |
|
|
(In general for an embedded environment, because it does not have
|
836 |
|
|
absolute addresses, a.out is not a good choice for output format
|
837 |
|
|
in any case; most often S-records or Hex-32 are used instead.)
|
838 |
|
|
|
839 |
|
|
*Motorola 68K MVME 135 board running ABug boot monitor*
|
840 |
|
|
Configure for `m68k-abug-aout' or `m68k-abug-coff' (as a target).
|
841 |
|
|
This boot monitor can only download S-records; therefore, the
|
842 |
|
|
DejaGnu tests for this environment require a linker command script
|
843 |
|
|
to convert either output format to S-records, setting the default
|
844 |
|
|
addresses for `.text', `.bss', and `.data'.
|
845 |
|
|
|
846 |
|
|
With this configuration, the default for `--connect' is `tip'.
|
847 |
|
|
`tip' is the only communications protocol supported for connecting
|
848 |
|
|
to `m68k-abug-*' targets. `tip' uses an ASCII downloader (the
|
849 |
|
|
`~put' command) to load S-records into the target board. The
|
850 |
|
|
`--name' string must be a machine name that `tip' understands (for
|
851 |
|
|
example, on some `tip' implementations it must be an entry from
|
852 |
|
|
the initialization file for `tip'; this file is sometimes called
|
853 |
|
|
`/etc/remote').
|
854 |
|
|
|
855 |
|
|
See your system documentation for information on how to create new
|
856 |
|
|
entries in `/etc/remote'. (Some UNIX systems are distributed with
|
857 |
|
|
at least one default entry with a name resembling `hardwire'; if
|
858 |
|
|
your system has one, you can edit it, or make a modified copy with
|
859 |
|
|
a new name.) When you have a working `/etc/remote' entry
|
860 |
|
|
ABUGTARGET, you should be able to type `tip ABUGTARGET', and get
|
861 |
|
|
the prompt `135ABUG>' from the board. Use the same ABUGTARGET
|
862 |
|
|
string with `runtest --name'.
|
863 |
|
|
|
864 |
|
|
*Motorola IDP board running the rom68k boot monitor*
|
865 |
|
|
This is the same in functionality as the MVME board running the
|
866 |
|
|
`BUG' boot monitor. Only the monitor commands and the addresses are
|
867 |
|
|
different.
|
868 |
|
|
|
869 |
|
|
*VxWorks (Motorola 68K or Intel 960)*
|
870 |
|
|
Configure DejaGnu for either `m68k-wrs-vxworks' (abbreviated
|
871 |
|
|
`vxworks68') or `i960-wrs-vxworks' (abbreviated `vxworks960').
|
872 |
|
|
Since both targets support IP addressing, specify the network
|
873 |
|
|
address (for example, a host name from `/etc/hosts') with `--name'.
|
874 |
|
|
|
875 |
|
|
The default connect protocol is `rlogin', but you can use any of
|
876 |
|
|
`--connect rlogin', `--connect telnet', or `--connect rsh'.
|
877 |
|
|
|
878 |
|
|
Test scripts need no special code to load programs into these
|
879 |
|
|
targets; since VxWorks supports NFS, all you must do is ensure
|
880 |
|
|
test programs are on an exported filesystem.
|
881 |
|
|
|
882 |
|
|
When you compile for VxWorks, use the linker `-r' option to make
|
883 |
|
|
the linker output relocatable--at least if you want to use library
|
884 |
|
|
routines. Many standard C routines are included in VxWorks; often
|
885 |
|
|
no additional libraries are needed. See your VxWorks system
|
886 |
|
|
documentation for additional details.
|
887 |
|
|
|
888 |
|
|
|
889 |
|
|
File: dejagnu.info, Node: Input Files, Next: Output Files, Prev: Cross Targets, Up: Internals
|
890 |
|
|
|
891 |
|
|
The files DejaGnu reads
|
892 |
|
|
=======================
|
893 |
|
|
|
894 |
|
|
The `runtest' program used to invoke DejaGnu is a short shell script
|
895 |
|
|
generated by `make' during the configuration process. Its main task is
|
896 |
|
|
to read the main test framework driver, `runtest.exp'.
|
897 |
|
|
|
898 |
|
|
`runtest.exp', in turn, reads `expect' code from certain other
|
899 |
|
|
files, in this order:
|
900 |
|
|
|
901 |
|
|
1. Each of the `site.exp' local definition files available. *Note
|
902 |
|
|
Setting `runtest' defaults: Customizing, for details.
|
903 |
|
|
|
904 |
|
|
2. `lib/utils.exp', a collection of utility procedures. *Note
|
905 |
|
|
DejaGnu Builtins: DejaGnu Builtins, for descriptions of these
|
906 |
|
|
procedures.
|
907 |
|
|
|
908 |
|
|
3. `lib/framework.exp', a file of subroutines meant for `runtest'
|
909 |
|
|
itself rather than for general-purpose use in both `runtest' and
|
910 |
|
|
test suites.
|
911 |
|
|
|
912 |
|
|
4. `debugger.exp', Don Libes' Tcl Debugger. (See `A Debugger for Tcl
|
913 |
|
|
Applications' by Don Libes. This paper is distributed with
|
914 |
|
|
`expect' in PostScript form as the file `expect/tcl-debug.ps'.)
|
915 |
|
|
|
916 |
|
|
5. `lib/remote.exp', a collection of subroutines meant for connecting
|
917 |
|
|
to remote machines.
|
918 |
|
|
|
919 |
|
|
6. `lib/target.exp', a collection of subroutines used for the
|
920 |
|
|
configuration systems in DejaGnu. These procedures typically
|
921 |
|
|
manipulate or utilize the configuration system.
|
922 |
|
|
|
923 |
|
|
7. An initialization file `TOOL_init.exp'. *Note Initialization
|
924 |
|
|
module: Init Module, for more discussion of init files.
|
925 |
|
|
|
926 |
|
|
|
927 |
|
|
File: dejagnu.info, Node: Output Files, Prev: Input Files, Up: Internals
|
928 |
|
|
|
929 |
|
|
The files DejaGnu writes
|
930 |
|
|
========================
|
931 |
|
|
|
932 |
|
|
`runtest' always writes two kinds of output files: summary logs and
|
933 |
|
|
detailed logs. The contents of both of these are determined by your
|
934 |
|
|
tests.
|
935 |
|
|
|
936 |
|
|
For troubleshooting, a third kind of output file is useful: use
|
937 |
|
|
`--debug' to request an output file showing details of what `expect' is
|
938 |
|
|
doing internally.
|
939 |
|
|
|
940 |
|
|
* Menu:
|
941 |
|
|
|
942 |
|
|
* Summary:: Files that summarize tests
|
943 |
|
|
* Detail:: Files that contain complete test results
|
944 |
|
|
* Debug:: Logging expect internal actions
|
945 |
|
|
|
946 |
|
|
|
947 |
|
|
File: dejagnu.info, Node: Summary, Next: Detail, Up: Output Files
|
948 |
|
|
|
949 |
|
|
Summary log
|
950 |
|
|
-----------
|
951 |
|
|
|
952 |
|
|
`runtest' always produces a summary output file `TOOL.sum'. This
|
953 |
|
|
summary shows the names of all test files run; for each test file, one
|
954 |
|
|
line of output from each `pass' command (showing status `PASS' or
|
955 |
|
|
`XPASS') or `fail' command (status `FAIL' or `XFAIL'); trailing summary
|
956 |
|
|
statistics that count passing and failing tests (expected and
|
957 |
|
|
unexpected); and the full pathname and version number of the tool
|
958 |
|
|
tested. (All possible outcomes, and all errors, are always reflected in
|
959 |
|
|
the summary output file, regardless of whether or not you specify
|
960 |
|
|
`--all'.)
|
961 |
|
|
|
962 |
|
|
If any of your tests use the procedures `unresolved', `unsupported',
|
963 |
|
|
or `untested', the summary output also tabulates the corresponding
|
964 |
|
|
outcomes.
|
965 |
|
|
|
966 |
|
|
For example, after `runtest --tool binutils', look for a summary log
|
967 |
|
|
in `binutils.sum'. Normally, `runtest' writes this file in your
|
968 |
|
|
current working directory; use the `--outdir' option to select a
|
969 |
|
|
different directory.
|
970 |
|
|
|
971 |
|
|
Here is a short sample summary log:
|
972 |
|
|
|
973 |
|
|
Test Run By rob on Mon May 25 21:40:57 PDT 1992
|
974 |
|
|
=== gdb tests ===
|
975 |
|
|
Running ./gdb.t00/echo.exp ...
|
976 |
|
|
PASS: Echo test
|
977 |
|
|
Running ./gdb.all/help.exp ...
|
978 |
|
|
PASS: help add-symbol-file
|
979 |
|
|
PASS: help aliases
|
980 |
|
|
PASS: help breakpoint "bre" abbreviation
|
981 |
|
|
FAIL: help run "r" abbreviation
|
982 |
|
|
Running ./gdb.t10/crossload.exp ...
|
983 |
|
|
PASS: m68k-elf (elf-big) explicit format; loaded
|
984 |
|
|
XFAIL: mips-ecoff (ecoff-bigmips) "ptype v_signed_char" signed
|
985 |
|
|
C types
|
986 |
|
|
=== gdb Summary ===
|
987 |
|
|
# of expected passes 5
|
988 |
|
|
# of expected failures 1
|
989 |
|
|
# of unexpected failures 1
|
990 |
|
|
/usr/latest/bin/gdb version 4.6.5 -q
|
991 |
|
|
|
992 |
|
|
|
993 |
|
|
File: dejagnu.info, Node: Detail, Next: Debug, Prev: Summary, Up: Output Files
|
994 |
|
|
|
995 |
|
|
Detailed log
|
996 |
|
|
------------
|
997 |
|
|
|
998 |
|
|
`runtest' also saves a detailed log file `TOOL.log', showing any
|
999 |
|
|
output generated by tests as well as the summary output. For example,
|
1000 |
|
|
after `runtest --tool binutils', look for a detailed log in
|
1001 |
|
|
`binutils.log'. Normally, `runtest' writes this file in your current
|
1002 |
|
|
working directory; use the `--outdir' option to select a different
|
1003 |
|
|
directory.
|
1004 |
|
|
|
1005 |
|
|
Here is a brief example showing a detailed log for G++ tests:
|
1006 |
|
|
|
1007 |
|
|
Test Run By rob on Mon May 25 21:40:43 PDT 1992
|
1008 |
|
|
|
1009 |
|
|
=== g++ tests ===
|
1010 |
|
|
|
1011 |
|
|
--- Running ./g++.other/t01-1.exp ---
|
1012 |
|
|
PASS: operate delete
|
1013 |
|
|
|
1014 |
|
|
--- Running ./g++.other/t01-2.exp ---
|
1015 |
|
|
FAIL: i960 bug EOF
|
1016 |
|
|
p0000646.C: In function `int warn_return_1 ()':
|
1017 |
|
|
p0000646.C:109: warning: control reaches end of non-void function
|
1018 |
|
|
p0000646.C: In function `int warn_return_arg (int)':
|
1019 |
|
|
p0000646.C:117: warning: control reaches end of non-void function
|
1020 |
|
|
p0000646.C: In function `int warn_return_sum (int, int)':
|
1021 |
|
|
p0000646.C:125: warning: control reaches end of non-void function
|
1022 |
|
|
p0000646.C: In function `struct foo warn_return_foo ()':
|
1023 |
|
|
p0000646.C:132: warning: control reaches end of non-void function
|
1024 |
|
|
|
1025 |
|
|
--- Running ./g++.other/t01-4.exp ---
|
1026 |
|
|
FAIL: abort
|
1027 |
|
|
900403_04.C:8: zero width for bit-field `foo'
|
1028 |
|
|
--- Running ./g++.other/t01-3.exp ---
|
1029 |
|
|
FAIL: segment violation
|
1030 |
|
|
900519_12.C:9: parse error before `;'
|
1031 |
|
|
900519_12.C:12: Segmentation violation
|
1032 |
|
|
/usr/latest/bin/gcc: Internal compiler error: program cc1plus got
|
1033 |
|
|
fatal signal
|
1034 |
|
|
|
1035 |
|
|
=== g++ Summary ===
|
1036 |
|
|
|
1037 |
|
|
# of expected passes 1
|
1038 |
|
|
# of expected failures 3
|
1039 |
|
|
/usr/ps/bin/g++ version cygnus-2.0.1
|
1040 |
|
|
|
1041 |
|
|
|
1042 |
|
|
File: dejagnu.info, Node: Debug, Prev: Detail, Up: Output Files
|
1043 |
|
|
|
1044 |
|
|
Logging `expect' internal actions
|
1045 |
|
|
---------------------------------
|
1046 |
|
|
|
1047 |
|
|
With the `--debug' option, you can request a log file showing the
|
1048 |
|
|
output from `expect' itself, running in debugging mode. This file
|
1049 |
|
|
(`dbg.log', in the directory where you start `runtest') shows each
|
1050 |
|
|
pattern `expect' considers in analyzing test output.
|
1051 |
|
|
|
1052 |
|
|
This file reflects each `send' command, showing the string sent as
|
1053 |
|
|
input to the tool under test; and each `expect' command, showing each
|
1054 |
|
|
pattern it compares with the tool output.
|
1055 |
|
|
|
1056 |
|
|
The log messages for `expect' begin with a message of the form
|
1057 |
|
|
|
1058 |
|
|
expect: does {TOOL OUTPUT} (spawn_id N) match pattern
|
1059 |
|
|
{EXPECTED PATTERN}?
|
1060 |
|
|
|
1061 |
|
|
For every unsuccessful match, `expect' issues a `no' after this
|
1062 |
|
|
message; if other patterns are specified for the same `expect' command,
|
1063 |
|
|
they are reflected also, but without the first part of the message
|
1064 |
|
|
(`expect...match pattern').
|
1065 |
|
|
|
1066 |
|
|
When `expect' finds a match, the log for the successful match ends
|
1067 |
|
|
with `yes', followed by a record of the `expect' variables set to
|
1068 |
|
|
describe a successful match. Here is an excerpt from the debugging log
|
1069 |
|
|
for a GDB test:
|
1070 |
|
|
|
1071 |
|
|
send: sent {break gdbme.c:34\n} to spawn id 6
|
1072 |
|
|
expect: does {} (spawn_id 6) match pattern {Breakpoint.*at.* file
|
1073 |
|
|
gdbme.c, line 34.*\(gdb\) $}? no
|
1074 |
|
|
{.*\(gdb\) $}? no
|
1075 |
|
|
expect: does {} (spawn_id 0) match pattern {}? no
|
1076 |
|
|
{\(y or n\) }? no
|
1077 |
|
|
{buffer_full}? no
|
1078 |
|
|
{virtual}? no
|
1079 |
|
|
{memory}? no
|
1080 |
|
|
{exhausted}? no
|
1081 |
|
|
{Undefined}? no
|
1082 |
|
|
{command}? no
|
1083 |
|
|
break gdbme.c:34
|
1084 |
|
|
Breakpoint 8 at 0x23d8: file gdbme.c, line 34.
|
1085 |
|
|
(gdb) expect: does {break gdbme.c:34\r\nBreakpoint 8 at 0x23d8:
|
1086 |
|
|
file gdbme.c, line 34.\r\n(gdb) } (spawn_id 6) match pattern
|
1087 |
|
|
{Breakpoint.*at.* file gdbme.c, line 34.*\(gdb\) $}? yes
|
1088 |
|
|
expect: set expect_out(0,start) {18}
|
1089 |
|
|
expect: set expect_out(0,end) {71}
|
1090 |
|
|
expect: set expect_out(0,string) {Breakpoint 8 at 0x23d8: file
|
1091 |
|
|
gdbme.c, line 34.\r\n(gdb) }
|
1092 |
|
|
expect: set expect_out(spawn_id) {6}
|
1093 |
|
|
expect: set expect_out(buffer) {break gdbme.c:34\r\nBreakpoint 8
|
1094 |
|
|
at 0x23d8: file gdbme.c, line 34.\r\n(gdb) }
|
1095 |
|
|
PASS: 70 0 breakpoint line number in file
|
1096 |
|
|
|
1097 |
|
|
This example exhibits three properties of `expect' and DejaGnu that
|
1098 |
|
|
might be surprising at first glance:
|
1099 |
|
|
|
1100 |
|
|
* Empty output for the first attempted match. The first set of
|
1101 |
|
|
attempted matches shown ran against the output `{}'--that is, no
|
1102 |
|
|
output. `expect' begins attempting to match the patterns supplied
|
1103 |
|
|
immediately; often, the first pass is against incomplete output (or
|
1104 |
|
|
completely before all output, as in this case).
|
1105 |
|
|
|
1106 |
|
|
* Interspersed tool output. The beginning of the log entry for the
|
1107 |
|
|
second attempted match may be hard to spot: this is because the
|
1108 |
|
|
prompt `(gdb) ' appears on the same line, just before the `expect:'
|
1109 |
|
|
that marks the beginning of the log entry.
|
1110 |
|
|
|
1111 |
|
|
* Fail-safe patterns. Many of the patterns tested are fail-safe
|
1112 |
|
|
patterns provided by GDB testing utilities, to reduce possible
|
1113 |
|
|
indeterminacy. It is useful to anticipate potential variations
|
1114 |
|
|
caused by extreme system conditions (GDB might issue the message
|
1115 |
|
|
`virtual memory exhausted' in rare circumstances), or by changes in
|
1116 |
|
|
the tested program (`Undefined command' is the likeliest outcome if
|
1117 |
|
|
the name of a tested command changes).
|
1118 |
|
|
|
1119 |
|
|
The pattern `{}' is a particularly interesting fail-safe
|
1120 |
|
|
to notice; it checks for an unexpected prompt. This may
|
1121 |
|
|
happen, for example, if the tested tool can filter output through a
|
1122 |
|
|
pager.
|
1123 |
|
|
|
1124 |
|
|
These fail-safe patterns (like the debugging log itself) are
|
1125 |
|
|
primarily useful while developing test scripts. Use the `error'
|
1126 |
|
|
procedure to make the actions for fail-safe patterns produce
|
1127 |
|
|
messages starting with `ERROR' on the `runtest' standard output,
|
1128 |
|
|
and in the detailed log file.
|
1129 |
|
|
|
1130 |
|
|
|
1131 |
|
|
File: dejagnu.info, Node: Tests, Next: Extending, Prev: Internals, Up: Top
|
1132 |
|
|
|
1133 |
|
|
How To Write a Test Cases
|
1134 |
|
|
*************************
|
1135 |
|
|
|
1136 |
|
|
* Menu:
|
1137 |
|
|
|
1138 |
|
|
* Writing:: Writing a test case
|
1139 |
|
|
* Debugging:: Debugging a test case
|
1140 |
|
|
* Adding:: Adding a test case to a test suite
|
1141 |
|
|
* Hints:: Hints on writing a test case
|
1142 |
|
|
* Variables:: Special variables used by test cases
|
1143 |
|
|
|