1 \input texinfo @c -*- Texinfo -*-
2 @setfilename dejagnu.info
3 @documentencoding us-ascii
12 @c man begin COPYRIGHT
13 Copyright @copyright{} 1992-2020 Free Software Foundation, Inc.
15 Permission is granted to copy, distribute and/or modify this document
16 under the terms of the GNU Free Documentation License, Version 1.3 or
17 any later version published by the Free Software Foundation; with no
18 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
19 Texts. A copy of the license is included in the section entitled
20 ``GNU Free Documentation License''.
25 @dircategory Software development
27 * DejaGnu: (dejagnu). The GNU testing framework.
32 @ifset VERSION_PACKAGE
33 @subtitle @value{VERSION_PACKAGE}
35 @subtitle Version @value{VERSION}
37 @subtitle @value{UPDATED}
38 @author Rob Savoye et al.
39 @author Cygnus Support and the GNU Project
42 @vskip 0pt plus 1filll
47 @node Top, Introduction, , (dir)
53 * Running other DejaGnu commands::
54 * Customizing DejaGnu::
57 * Built-in Procedures::
58 * GNU Free Documentation License::
68 * New in this release: Release Notes
70 * A POSIX conforming test framework: A POSIX Conforming Test Framework.
75 * Running 'make check': Make Check.
76 * Running runtest: Runtest.
77 * Output files: Output Files.
79 Running other DejaGnu commands
81 * Invoking dejagnu:: Command line options for the launcher itself.
82 * Invoking dejagnu help:: Reading man pages for dejagnu subcommands.
83 * Invoking dejagnu report card:: Summarizing test results from many tools.
87 * Global configuration file::
88 * Local configuration file::
89 * Board configuration file::
90 * Remote host testing::
91 * Configuration file values::
95 * Adding a new testsuite::
97 * Adding a new target::
98 * Adding a new board::
100 * Writing a test case::
101 * Debugging a test case::
102 * Adding a test case to a testsuite::
103 * Test case special variables: Test case variables.
107 * What is unit testing?:: Unit testing and system testing.
108 * Running unit tests::
109 * DejaGnu unit test protocol:: DejaGnu native unit testing protocol.
110 * C unit testing API::
111 * C++ unit testing API::
115 * Built-in Procedures::
126 @node Introduction, Running tests, Top, Top
127 @chapter Introduction
131 * New in this release: Release Notes.
133 * A POSIX compliant test framework: A POSIX Conforming Test Framework.
137 @node What is DejaGnu?, Release Notes, , Introduction
138 @section What is DejaGnu?
140 DejaGnu is a framework for testing other programs, providing a single
141 front-end for all tests. You can think of it as a library of Tcl
142 procedures to help with writing a test harness. A @emph{test harness}
143 is the infrastructure that is created to test a specific program or
144 tool. Each program can have multiple testsuites, all supported by a
145 single test harness. DejaGnu is written in Expect, which in turn uses
146 Tcl, the Tool command language. There is more information on Tcl at
147 the @uref{http://www.tcl.tk,Tcl/Tk web site} and the
148 @uref{http://expect.nist.gov,Expect web site}.
150 Julia Menapace first coined the term @emph{DejaGnu} to describe an
151 earlier testing framework she wrote at Cygnus Support for testing GDB.
152 When we replaced it with the Expect-based framework, it was like
153 DejaGnu all over again. More importantly, it was also named after my
154 daughter, Deja Snow Savoye, who was a toddler during DejaGnu's
157 DejaGnu offers several advantages for testing:
162 The flexibility and consistency of the DejaGnu framework make it easy to
163 write tests for any program, with either batch-oriented, or interactive
167 DejaGnu provides a layer of abstraction which allows you to write
168 tests that are portable to any host or target where a program must be
169 tested. For instance, a test for @code{GDB} can run from any
170 supported host system on any supported target system. DejaGnu runs
171 tests on many single board computers, whose operating software ranges
172 from a simple boot monitor to a real-time OS.
175 All tests have the same output format. This makes it easy to
176 integrate testing into other software development processes.
177 DejaGnu's output is designed to be parsed by other filtering script
178 and it is also human readable.
181 Using Tcl and Expect, it's easy to create wrappers for existing
182 testsuites. By incorporating existing tests under DejaGnu, it's
183 easier to have a single set of report analyse programs..
186 Running tests requires two things: the testing framework and the
187 testsuites themselves. Tests are usually written in Expect using Tcl,
188 but you can also use a Tcl script to run a testsuite that is not based
189 on Expect. Expect script filenames conventionally use @file{.exp} as
190 a suffix. For example, the main implementation of the DejaGnu test
191 driver is in the file @file{runtest.exp}.
193 @node Release Notes, Design goals, What is DejaGnu?, Introduction
194 @section New in this release
196 The following major, user-visible changes have been introduced since
202 Support for target communication via SSH has been added.
205 A large number of very old config and baseboard files have been
206 removed. If you need to resurrect these, you can get them from
207 version 1.5.3. If you can show that a board is still in use, it can
208 be put back in the distribution.
211 The @command{--status} command line option is now the default. This
212 means that any error in the testsuite Tcl scripts will cause runtest
213 to abort with exit status code 2. The @command{--status} option has
214 been removed from the documentation, but will continue to be accepted
215 for backward compatibility.
218 @command{runtest} now exits with exit code 0 if the testsuite
219 "passed", 1 if something unexpected happened (eg, FAIL, XPASS or
220 UNRESOLVED), and 2 if an exception is raised by the Tcl interpreter.
223 @command{runtest} now exits with the standard exit codes of programs
224 that are terminated by the SIGINT, SIGTERM and SIGQUIT signals.
227 The user-visible utility procedures @code{absolute}, @code{psource}
228 and @code{slay} have been removed. If a testsuite uses any of these
229 procedures, a copy of the procedure should be made and placed in the
230 lib directory of the testsuite.
233 Support was added for testing the D compiler.
236 @file{~/.dejagnurc} is now loaded last, not first. This allows the
237 user to have the ability to override anything in their environment
238 (even the @file{site.exp} file specified by @code{$DEJAGNU}).
241 The user-visible utility procedure @code{unsetenv} is
242 @strong{deprecated} and will be removed in the next release. If a
243 testsuite uses this procedure, a copy should be made and placed in the
244 lib directory of the testsuite.
248 @node Design goals, A POSIX Conforming Test Framework, Release Notes, Introduction
249 @section Design goals
252 DejaGnu grew out of the internal needs of Cygnus Solutions (formerly
253 Cygnus Support). Cygnus maintained and enhanced a variety of free
254 programs in many different environments and needed a testing tool
260 was useful to developers while fixing bugs;
263 automated running many tests during a software release process;
266 was portable among a variety of host computers;
269 supported a cross-development environment;
272 permitted testing of interactive programs like @code{GDB}; and
275 permitted testing of batch-oriented programs like @code{GCC}.
278 Some of the requirements proved challenging. For example, interactive
279 programs do not lend themselves very well to automated testing. But
280 all the requirements are important. For instance, it is imperative to
281 make sure that @code{GDB} works as well when cross-debugging as it
282 does in a native configuration.
284 Probably the greatest challenge was testing in a cross-development
285 environment. Most cross-development environments are customized by
286 each developer. Even when buying packaged boards from vendors there
287 are many differences. The communication interfaces vary from a serial
288 line to Ethernet. DejaGnu was designed with a modular communication
289 setup, so that each kind of communication can be added as required and
290 supported thereafter. Once a communication procedure is written, any
291 test can use it. Currently DejaGnu can use @code{ssh}, @code{rsh},
292 @code{rlogin}, @code{telnet}, @code{tip}, and @code{kermit} for remote
295 @node A POSIX Conforming Test Framework, Installation, Design goals, Introduction
296 @section A POSIX compliant test framework
297 @cindex POSIX compliant test framework
300 DejaGnu conforms to the POSIX 1003.3 standard for test frameworks.
301 Rob Savoye was a member of that committee.
303 POSIX standard 1003.3 defines what a testing framework needs to
304 provide to create a POSIX compliant testsuite. This standard is
305 primarily oriented to checking POSIX conformance, but its requirements
306 also support testing of features not related to POSIX conformance.
307 POSIX 1003.3 does not specify a particular testing framework, but at
308 this time there is only one other POSIX conforming test framework.
309 TET was created by Unisoft for a consortium comprised of X/Open, Unix
310 International and the Open Software Foundation.
313 The POSIX documentation refers to @dfn{assertions}. An assertion is a
314 description of behavior. For example, if a standard says ``The sun
315 shall shine'', a corresponding assertion might be ``The sun is
316 shining.'' A test based on this assertion would pass or fail
317 depending on whether it is day or night. It is important to note that
318 the standard being tested is never 1003.3; the standard being tested
319 is some other standard, for which the assertions were written.
321 As there is no testsuite to verify that testing frameworks are POSIX
322 1003.3 compliant, this is done by repeatedly reading the standard and
323 experimenting. One of the main things POSIX 1003.3 does specify is
324 the set of allowed output messages and their definitions. Four
325 messages are supported for a required feature of POSIX conforming
326 systems and a fifth for a conditional feature. DejaGnu supports all
327 five output messages. In this sense a testsuite that uses exactly
328 these messages can be considered POSIX compliant. These definitions
329 specify the output of a test case:
334 A test has succeeded. That is, it demonstrated that the assertion is
338 A test has not succeeded -- the assertion is false. The @emph{FAIL}
339 message is based on this test case only. Other messages are used to
340 indicate a failure of the framework. As with @emph{PASS}, POSIX tests
341 must return @emph{FAIL} rather than @emph{XFAIL} even if a failure was
345 POSIX 1003.3 does not incorporate the notion of expected failures, so
346 @emph{PASS}, instead of @emph{XPASS}, must also be returned for test
347 cases which were expected to fail and did not. This means that
348 @emph{PASS} is in some sense more ambiguous than if @emph{XPASS} is
352 A test produced indeterminate results. Usually, this means the test
353 executed in an unexpected fashion. This outcome requires a human to
354 go over results to determine if the test should have passed or failed.
355 This message is also used for any test that requires human
356 intervention because it is beyond the abilities of the testing
357 framework. Any unresolved test should resolved to @emph{PASS} or
358 @emph{FAIL} before a test run can be considered finished.
360 Note that for POSIX, each assertion must produce a test result code.
361 If the test isn't actually run, it must produce @emph{UNRESOLVED}
362 rather than just leaving that test out of the output. This means that
363 you have to be careful when writing tests to not carelessly use Tcl
364 commands like @emph{return}---if you alter the flow of control of the
365 Tcl code you must insure that every test still produces some result
368 Here are some of the ways a test may wind up @emph{UNRESOLVED}:
374 Execution of a test is interrupted.
377 A test does not produce a clear result. This is usually because there
378 was an @emph{ERROR} from DejaGnu while processing the test, or because
379 there were three or more @emph{WARNING} messages. Any @emph{WARNING}
380 or @emph{ERROR} messages can invalidate the output of the test. This
381 usually requires a human to examine the output to determine what
382 really happened -- and to improve the test case.
385 A test depends on a previous test, which has failed.
388 The test was set up incorrectly.
391 A test script aborts due to a Tcl error. In this case, the DejaGnu
392 framework inserts an @emph{UNRESOLVED} result as a placeholder for an
393 unknown number of tests that were not run because the script crashed.
399 A test was not run. This is a placeholder used when there is no real
406 There is no support for the tested case. This may mean that a
407 conditional feature of an operating system, or of a compiler, is not
408 implemented. DejaGnu also uses this message when a testing
409 environment (often a ``bare board'' target) lacks basic support for
410 compiling or running the test case. For example, a test for the
411 system subroutine @emph{gethostname} would never work on a target
412 board running only a boot monitor.
415 DejaGnu uses the same output procedures to produce these messages for
416 all testsuites and these procedures are already known to conform to
417 POSIX 1003.3. For a DejaGnu testsuite to conform to POSIX 1003.3, you
418 must avoid the @emph{setup_xfail} procedure as described in the
419 @emph{PASS} section above and you must be careful to return
420 @emph{UNRESOLVED} where appropriate, as described in the
421 @emph{UNRESOLVED} section above.
423 @node Installation, , A POSIX Conforming Test Framework, Introduction
424 @section Installation
426 Refer to the @file{INSTALL} in the source distribution for detailed
427 installation instructions. Note that there is no compilation step as
428 with many other GNU packages, as DejaGnu consists of interpreted code
431 Save for its own small testsuite, the DejaGnu distribution does not
432 include any testsuites. Testsuites for the various GNU development
433 tools are included with those packages. After configuring the
434 top-level DejaGnu directory, unpack and configure the test directories
435 for the tools you want to test; then, in each test directory, run
436 @emph{make check} to build auxiliary programs required by some of the
437 tests, and run the test suites.
439 @node Running tests, Running other DejaGnu commands, Introduction, Top
440 @chapter Running tests
442 There are two ways to execute a testsuite. The most common way is
443 when there is existing support in the @file{Makefile} of the tool
444 being tested. This usually consists of a @emph{check} target. The
445 other way is to execute the @code{runtest} program directly. To run
446 @code{runtest} directly from the command line requires either all of
447 the correct command line options, or a @ref{Local configuration file}
448 must be set up correctly.
451 * Running 'make check': Make Check.
452 * Running runtest: Runtest.
453 * Output files: Output Files.
456 @node Make Check, Runtest, , Running tests
457 @section Running 'make check'
459 To run tests from an existing collection, first use @code{configure}
460 as usual to set up the build directory. Then type @code{make check}.
461 If the @emph{check} target exists, it usually saves you some trouble.
462 For instance, it can set up any auxiliary programs or other files
463 needed by the tests. The most common file the @emph{check} target
464 depends on is the @file{site.exp} file. The @file{site.exp} contains
465 various variables that DejaGnu uses to determine the configuration of
466 the program being tested.
468 Once you have run @emph{make check} to build any auxiliary files, you
469 can invoke the test driver @code{runtest} directly to repeat the
470 tests. You will also have to execute @code{runtest} directly for test
471 collections with no @emph{check} target in the @file{Makefile}.
473 GNU Automake has built-in support for DejaGnu. To add DejaGnu support
474 to your generated @file{Makefile.in}, just add the keyword
475 @code{dejagnu} to the AUTOMAKE_OPTIONS variable in @file{Makefile.am}.
476 This will ensure that the generated @file{Makefile.in} has a
477 @code{check} target that invokes DejaGnu correctly. @xref{Tests,,
478 DejaGnu Tests, automake, The GNU Automake Manual}.
480 @node Runtest, Output Files, Make Check, Running tests
481 @section Running runtest
484 @code{runtest} is the test driver for DejaGnu. You can specify two
485 kinds of things on the @code{runtest} command line: command line
486 options, and Tcl variables that are passed to the test scripts. The
487 options are listed alphabetically below.
489 @code{runtest} returns one of the following exit codes:
493 if all tests passed including expected failures and unsupported tests.
495 if any test failed, passed unexpectedly, or was unresolved.
497 if Expect encountered any error in the test scripts.
503 * Common Options: Common Operations.
506 @node Output States, Invoking runtest, , Runtest
507 @subsection Output States
508 @cindex output states
510 @file{runtest} flags the outcome of each test as one of these cases.
511 See @ref{A POSIX Conforming Test Framework} for a discussion of how
512 POSIX specifies the meanings of these cases.
517 The most desirable outcome: the test was expected to succeed and did
521 A pleasant kind of failure: a test was expected to fail, but
522 succeeded. This may indicate progress; inspect the test case to
523 determine whether you should amend it to stop expecting failure.
526 A test failed, although it was expected to succeed. This may indicate
527 regress; inspect the test case and the failing software to locate the
531 A test failed, but it was expected to fail. This result indicates no
532 change in a known bug. If a test fails because the operating system
533 where the test runs lacks some facility required by the test, the
534 outcome is @emph{UNSUPPORTED} instead.
537 Output from a test requires manual inspection; the testsuite could not
538 automatically determine the outcome. For example, your tests can
539 report this outcome is when a test does not complete as expected.
542 A test case is not yet complete, and in particular cannot yet produce
543 a @emph{PASS} or @emph{FAIL}. You can also use this outcome in dummy
544 ``tests'' that note explicitly the absence of a real test case for a
548 A test depends on a conditionally available feature that does not
549 exist (in the configured testing environment). For example, you can
550 use this outcome to report on a test case that does not work on a
551 particular target because its operating system support does not
552 include a required subroutine.
555 @code{runtest} may also display the following messages:
560 Indicates a major problem (detected by the test case itself) in
561 running the test. This is usually an unrecoverable error, such as a
562 missing file or loss of communication to the target. POSIX testsuites
563 should not emit this message; use @emph{UNSUPPORTED}, @emph{UNTESTED},
564 or @emph{UNRESOLVED} instead, as appropriate.
567 Indicates a possible problem in running the test. Usually warnings
568 correspond to recoverable errors, or display an important message
569 about the following tests.
572 An informational message about the test case.
575 @node Invoking runtest, Common Operations, Output States, Runtest
576 @subsection Invoking runtest
577 @cindex runtest, invoking
579 This is the full set of command line options that @code{runtest}
580 recognizes. Option names may be abbreviated to the shortest unique
585 @item @code{-a}, @code{--all}
586 Display all test output. By default, @emph{runtest} shows only the
587 output of tests that produce unexpected results; that is, tests with
588 status @emph{FAIL} (unexpected failure), @emph{XPASS} (unexpected
589 success), or @emph{ERROR} (a severe error in the test case itself).
590 Specify @code{--all} to see output for tests with status @emph{PASS}
591 (success, as expected) @emph{XFAIL} (failure, as expected), or
592 @emph{WARNING} (minor error in the test case itself).
594 @item @code{--build [triplet]}
595 @emph{triplet} is a system triplet of the form
596 @emph{cpu-manufacturer-os}. This is the type of machine DejaGnu and
597 the tools to be tested are built on. For a normal cross environment
598 this is the same as the host, but for a Canadian cross, they are
601 @item @code{-D0}, @code{-D1}
602 Start the internal Tcl debugger. The Tcl debugger supports
603 breakpoints, single stepping, and other common debugging activities.
604 See the document @uref{http://expect.sourceforge.net/doc/tcl-debug.ps,
605 Debugger for Tcl Applications} by Don Libes. If you specify
606 @emph{-D1}, the @emph{expect} shell stops at a breakpoint as soon as
607 DejaGnu invokes it. If you specify @emph{-D0}, DejaGnu starts as
608 usual, but you can enter the debugger by sending an interrupt (e.g. by
609 typing @key{Ctrl}-@key{c}).
612 Turns on the Expect internal debugging output. Debugging output is
613 displayed as part of the @emph{runtest} output, and logged to a file
614 called @file{dbg.log}. The extra debugging output does @emph{not}
615 appear on standard output, unless the verbose level is greater than 2
616 (for instance, to see debug output immediately, specify @code{--debug
617 -v -v}). The debugging output shows all attempts at matching the test
618 output of the tool with the scripted patterns describing expected
619 output. The output generated with @code{--strace} also goes into
622 @item @code{--global_init [name]}
623 Use @emph{name} as the global init file instead of @file{site.exp} in
624 @emph{libdir}. The default is, of course, @file{site.exp}. Note that
625 this option accepts a relative file name, interpreted starting at
626 @emph{libdir}, so a file in a subdirectory may be used. This is
627 probably less useful for most sites, but is orthogonal with the
628 @code{--local_init} option and may be useful in large testing labs.
631 Prints out a short summary of the @emph{runtest} options, then exits
632 (even if you specify other options).
634 @item @code{--host [triplet]}
635 @emph{triplet} is a system triplet of the form
636 @emph{cpu-manufactuer-os}. Use this option to override the default
637 string recorded by your configuration's choice of host. This choice
638 does not change how anything is actually configured unless --build is
639 also specified; it affects @emph{only} DejaGnu procedures that compare
640 the host string with particular values. The procedures @emph{ishost},
641 @emph{istarget}, @emph{isnative}, and @emph{setup_xfail} are affected
642 by @code{--host}. In this usage, @emph{host} refers to the machine
643 that the tests are to be run on, which may not be the same as the
644 @emph{build} machine. If @code{--build} is also specified, then
645 @code{--host} refers to the machine that the tests will be run on, not
646 the machine DejaGnu is run on.
648 @item @code{--host_board [name]}
649 The host board to use.
651 @item @code{--ignore [tests(s)] }
652 The name(s) of specific tests to ignore.
654 @item @code{--local_init [name]}
655 Use @emph{name} as the testsuite local init file instead of
656 @file{site.exp} in the current directory and in @emph{objdir}. The
657 default is, of course, @file{site.exp}. Note that this option accepts
658 a relative file name, so a file in a subdirectory may be used.
660 @item @code{--log_dialog}
661 Emit Expect output to stdout. The Expect output is usually only
662 written to the @file{.log} file. By enabling this option, they are
663 also printed to standard output.
665 @item @code{--mail [address(es)]}
666 Send test results to one or more email addresses.
668 @item @code{--objdir [path]}
669 Use @emph{path} as the top directory containing any auxiliary compiled
670 test code. The default is '.'. Use this option to locate
671 pre-compiled test code. You can normally prepare any auxiliary files
672 needed with @emph{make}.
674 @item @code{--outdir [path]}
675 Write log files in directory @file{path}. The default is '.', the
676 directory where you start @emph{runtest}. This option affects only
677 the summary (@file{.sum}) and the detailed log files (@file{.log}).
678 The DejaGnu debug log @file{dbg.log} always appears (when requested)
679 in the local directory.
681 @item @code{--reboot [name]}
682 Reboot the target board when @code{runtest} starts. When running
683 tests on a separate target board, it is safer to reboot the target to
684 be certain of its state. However, when developing test scripts,
685 rebooting can take a lot of time.
687 @item @code{--srcdir [path]}
688 Use @file{path} as the top directory for test scripts to run.
689 @emph{runtest} looks in this directory for any subdirectory whose name
690 begins with the toolname (specified with @code{--tool}). For
691 instance, with @code{--tool gdb}, @emph{runtest} uses tests in
692 subdirectories @file{gdb.*} (with the usual shell-like filename
693 expansion). If you do not use @code{--srcdir}, @emph{runtest} looks
694 for test directories under the current working directory.
696 @item @code{--strace [n]}
697 Turn on internal tracing for @emph{expect}, to n levels deep. By
698 adjusting the level, you can control the extent to which your output
699 expands multi-level Tcl statements. This allows you to ignore some
700 levels of @emph{case} or @emph{if} statements. Each procedure call or
701 control structure counts as one ``level''. The output is recorded in
702 the same file, @file{dbg.log}, used for output from @code{--debug}.
704 @item @code{--target [triplet]}
705 Use this option to override the default setting (native testing).
706 @emph{triplet} is a system triplet of the form
707 @emph{cpu-manufacturer-os}. This option changes the configuration
708 @code{runtest} uses for the default tool names, and other setup
711 @item @code{--target_board [name(s)]}
712 The list of target boards to run tests on.
714 @item @code{--tool [name(s)]}
715 Specifies which testsuite to run, and what initialization module to
716 use. @code{--tool} is used @emph{only} for these two purposes. It is
717 @emph{not} used to name the executable program to test. Executable
718 tool names (and paths) are recorded in @file{site.exp} and you can
719 override them by specifying Tcl variables on the command line.
721 For example, including @code{--tool} gcc on the command line runs
722 tests from all test subdirectories whose names match @file{gcc.*}, and
723 uses one of the initialization modules named @file{config/*-gcc.exp}.
724 To specify the name of the compiler (perhaps as an alternative path to
725 what @emph{runtest} would use by default), use @emph{GCC=path-to-gcc}
726 on the @emph{runtest} command line.
728 @item @code{--tool_exec [name]}
729 The path to the tool executable to test.
731 @item @code{--tool_opts [options]}
732 A list of additional options to pass to the tool.
734 @item @code{-v}, @code{--verbose}
735 Turns on more output. Repeating this option increases the amount of
736 output displayed. Level one (@emph{-v}) is simply test output. Level
737 two (@emph{-v -v}) shows messages on options, configuration, and
738 process control. Verbose messages appear in the detailed
739 (@file{*.log}) log file, but not in the summary (@file{*.sum}) log
742 @item @code{-V}, @code{--version}
743 Prints out the version numbers of DejaGnu, Expect, and Tcl.
745 @item @code{-x}, @code{--xml}
746 Generate XML output. The output file is named after the tool with an
749 @item @file{testfile}.exp[=arg(s)]
750 Specify the names of testsuites to run. By default, @emph{runtest}
751 runs all tests for the tool, but you can restrict it to particular
752 testsuites by giving the names of the @emph{.exp} scripts that control
753 them. @emph{testsuite}.exp cannot include directory names, only plain
756 @code{arg(s)} specifies a subset of test cases to run. For compiler
757 or assembler tests, which often use a single @emph{.exp} script
758 covering many different test case files, this option allows you to
759 further restrict the tests by listing particular test cases. For
760 larger testsuites such as that included in GCC, this can save a lot of
761 time. Some tools support wildcards here, but this varies from tool to
762 tool. Typically the wildcards @emph{?}, @emph{*}, and @emph{[chars]}
765 @item @code{tclvar}=value
766 You can define Tcl variables for use by your test scripts in the same
767 style used with @emph{make} for environment variables. For example,
768 @emph{runtest GDB=gdb.old} defines a variable called @code{GDB}; when
769 your scripts refer to @code{$GDB} in this run, they use the value
772 The default Tcl variables used for most tools are defined in the main
773 DejaGnu @emph{Makefile}; their values are captured in the
774 @file{site.exp} file.
777 @node Common Operations, , Invoking runtest, Runtest
778 @subsection Common Options
779 @cindex options, common
781 Typically, you don't need to use any command line options. The
782 @code{--tool} option is only required when there is more than one
783 testsuite in the same directory. The default options are in the local
784 @file{site.exp} file, created by @code{make site.exp}.
786 For example, if the directory @file{gdb/testsuite} contains a
787 collection of DejaGnu tests for GDB, you can run them like this:
794 The test output follows, then ends with:
799 # of expected passes 508
800 # of expected failures 103
801 /usr/latest/bin/gdb version 4.14.4 -nx
804 You can use the option @code{--srcdir} to point to some other
805 directory containing a collection of tests:
808 $ runtest --srcdir /devo/gdb/testsuite
811 By default, @code{runtest} prints only the names of the tests it runs,
812 output from any tests that have unexpected results, and a summary
813 showing how many tests passed and how many failed. To display output
814 from all tests (whether or not they behave as expected), use the
815 @code{-a} (all) option. For more verbose output about processes being
816 run, communication, and so on, use @code{-v} (verbose). To see even
817 more output, use multiple @code{-v} options. See @ref{Invoking
818 runtest} for a more detailed explanation of each @code{runtest}
821 @node Output Files, , Runtest, Running tests
822 @section Output files
824 DejaGnu always writes two kinds of output files. Summary output is
825 written to the @file{.sum} file, and detailed output is written to the
826 @file{.log} file. The tool name determines the prefix for these
827 files. For example, after running with @code{--tool gdb}, the output
828 files will be called @file{gdb.sum} and @file{gdb.log}. For
829 troubleshooting, a debug log file that logs the operation of Expect is
830 available. Each of these will be described in turn.
834 * Detailed log file::
838 @node Summary log file, Detailed log file, , Output Files
839 @subsection Summary log file
840 @cindex output file, summary log
842 DejaGnu always produces a summary (@file{.sum}) output file. This
843 summary lists the names of all test files run. For each test file,
844 one line of output from each @code{pass} command (showing status
845 @emph{PASS} or @emph{XPASS}) or @code{fail} command (status
846 @emph{FAIL} or @emph{XFAIL}), trailing summary statistics that count
847 passing and failing tests (expected and unexpected), the full pathname
848 of the tool tested, and the version number of the tool. All possible
849 outcomes, and all errors, are always reflected in the summary output
850 file, regardless of whether or not you specify @code{--all}.
852 If any of your tests use the procedures @code{unresolved},
853 @code{unsupported}, or @code{untested}, the summary output also
854 tabulates the corresponding outcomes.
856 For example, after running @code{runtest --tool binutils} a summary
857 log file will be written to @file{binutils.sum}. Normally, DejaGnu
858 writes this file in your current working directory. Use the
859 @code{--outdir} option to select a different output directory.
861 @strong{Sample summary log}
864 Test Run By bje on Sat Nov 14 21:04:30 AEDT 2015
868 Running ./gdb.t00/echo.exp ...
870 Running ./gdb.all/help.exp ...
871 PASS: help add-symbol-file
873 PASS: help breakpoint "bre" abbreviation
874 FAIL: help run "r" abbreviation
875 Running ./gdb.t10/crossload.exp ...
876 PASS: m68k-elf (elf-big) explicit format; loaded
877 XFAIL: mips-ecoff (ecoff-bigmips) "ptype v_signed_char" signed C types
879 @ === gdb Summary ===
881 # of expected passes 5
882 # of expected failures 1
883 # of unexpected failures 1
884 /usr/latest/bin/gdb version 4.6.5 -q
888 @node Detailed log file, Debug log file, Summary log file, Output Files
889 @subsection Detailed log file
890 @cindex output file, detailed log
892 DejaGnu also saves a detailed log file (@file{.log}), showing any
893 output generated by test cases as well as the summary output. For
894 example, after running @code{runtest --tool binutils}, a detailed log
895 file will be written to @file{binutils.log}. Normally, DejaGnu writes
896 this file in your current working directory. Use the @code{--outdir}
897 option to select a different output directory.
899 @strong{Sample detailed log for g++ tests}
902 Test Run By bje on Sat Nov 14 21:07:23 AEDT 2015
906 Running ./g++.other/t01-1.exp ...
909 Running ./g++.other/t01-2.exp ...
911 p0000646.C: In function `int warn_return_1 ()':
912 p0000646.C:109: warning: control reaches end of non-void function
913 p0000646.C: In function `int warn_return_arg (int)':
914 p0000646.C:117: warning: control reaches end of non-void function
915 p0000646.C: In function `int warn_return_sum (int, int)':
916 p0000646.C:125: warning: control reaches end of non-void function
917 p0000646.C: In function `struct foo warn_return_foo ()':
918 p0000646.C:132: warning: control reaches end of non-void function
919 Running ./g++.other/t01-4.exp ...
921 900403_04.C:8: zero width for bit-field `foo'
922 Running ./g++.other/t01-3.exp ...
923 FAIL: segment violation
924 900519_12.C:9: parse error before `;'
925 900519_12.C:12: Segmentation violation
926 /usr/latest/bin/gcc: Internal compiler error: program cc1plus got fatal signal
928 @ === g++ Summary ===
930 # of expected passes 1
931 # of expected failures 3
932 /usr/latest/bin/g++ version cygnus-2.0.1
936 @node Debug log file, , Detailed log file, Output Files
937 @subsection Debug log file
938 @cindex output file, debug log
940 The @code{runtest} option @code{--debug} creates a file showing the
941 output from Expect in debugging mode. The @file{dbg.log} file is
942 created in the current directory. The log file shows the string sent
943 to the tool being tested by each @code{send} command and the pattern
944 it compares with the tool output by each @code{expect} command.
946 The log messages begin with a message of the form:
949 expect: does @{tool output@} (spawn_id n)
950 match pattern @{expected pattern@}?
953 For every unsuccessful match, Expect issues a @emph{no} after this
954 message. If other patterns are specified for the same Expect command,
955 they are reflected also, but without the first part of the message
956 (@emph{expect... match pattern}).
958 When Expect finds a match, the log for the successful match ends with
959 @emph{yes}, followed by a record of the Expect variables set to
960 describe a successful match.
962 @strong{Example debug log file for a GDB test}
965 send: sent @{break gdbme.c:34\n@} to spawn id 6
966 expect: does @{@} (spawn_id 6) match pattern @{Breakpoint.*at.* file
967 gdbme.c, line 34.*\(gdb\) $@}? no
969 expect: does @{@} (spawn_id 0) match pattern @{return@} ? no
978 Breakpoint 8 at 0x23d8: file gdbme.c, line 34.
979 (gdb) expect: does @{break gdbme.c:34\r\nBreakpoint 8 at 0x23d8:
980 file gdbme.c, line 34.\r\n(gdb) @} (spawn_id 6) match pattern
981 @{Breakpoint.*at.* file gdbme.c, line 34.*\(gdb\) $@}? yes
982 expect: set expect_out(0,start) @{18@}
983 expect: set expect_out(0,end) @{71@}
984 expect: set expect_out(0,string) @{Breakpoint 8 at 0x23d8: file
985 gdbme.c, line 34.\r\n(gdb) @}
986 epect: set expect_out(spawn_id) @{6@}
987 expect: set expect_out(buffer) @{break gdbme.c:34\r\nBreakpoint 8
988 at 0x23d8: file gdbme.c, line 34.\r\n(gdb) @}
989 PASS: 70 0 breakpoint line number in file
993 This example exhibits three properties of Expect and DejaGnu that
994 might be surprising at first glance:
999 Empty output for the first attempted match. The first set of
1000 attempted matches shown ran against the output @emph{@{@}} --- that
1001 is, no output. Expect begins attempting to match the patterns
1002 supplied immediately; often, the first pass is against incomplete
1003 output (or completely before all output, as in this case).
1006 Interspersed tool output. The beginning of the log entry for the
1007 second attempted match may be hard to spot: this is because the prompt
1008 @emph{@{(gdb) @}} appears on the same line, just before the
1009 @emph{expect:} that marks the beginning of the log entry.
1012 Fail-safe patterns. Many of the patterns tested are fail-safe
1013 patterns provided by GDB testing utilities, to reduce possible
1014 indeterminacy. It is useful to anticipate potential variations caused
1015 by extreme system conditions (GDB might issue the message
1016 @emph{virtual memory exhausted} in rare circumstances), or by changes
1017 in the tested program (@emph{Undefined command} is the likeliest
1018 outcome if the name of a tested command changes).
1020 The pattern @emph{@{return@}} is a particularly interesting fail-safe
1021 to notice; it checks for an unexpected @key{RET} prompt. This may
1022 happen, for example, if the tested tool can filter output through a
1025 These fail-safe patterns (like the debugging log itself) are primarily
1026 useful while developing test scripts. Use the @code{error} procedure
1027 to make the actions for fail-safe patterns produce messages starting
1028 with @emph{ERROR} on standard output, and in the detailed log file.
1032 @node Running other DejaGnu commands, Customizing DejaGnu, Running tests, Top
1033 @chapter Running other DejaGnu commands
1035 DejaGnu now features auxiliary commands not directly related to
1036 running tests, but somehow related to the broader purpose of testing.
1038 These commands are run via the @command{dejagnu} multiplex launcher,
1039 which locates an appropriate script and the required interpreter and
1040 then runs the requested command.
1043 * Invoking dejagnu:: Command line options for the launcher itself.
1044 * Invoking dejagnu help:: Reading man pages for dejagnu subcommands.
1045 * Invoking dejagnu report card:: Summarizing test results from many tools.
1048 @node Invoking dejagnu, Invoking dejagnu help, Running other DejaGnu commands, Running other DejaGnu commands
1049 @section Invoking @command{dejagnu}
1050 @cindex dejagnu, invoking
1052 The @command{dejagnu} launcher is primarily designed to pass most
1053 options on to the scripts that it runs, but does process the
1054 @option{--help} and @option{--version} options entirely internally,
1055 while also recognizing the @option{--verbose} option.
1058 @command{dejagnu} <command> [options...]
1059 @command{dejagnu} --help
1060 @command{dejagnu} --version
1063 Note that the command names may contain multiple words. In this case,
1064 the command can be given as separate arguments to @command{dejagnu} or
1065 combined with dashes (@samp{-}); both forms are equivalent.
1067 All words of the command name must appear before any options. The
1068 search for a command terminates when an option is found.
1070 Note that the first valid command found is used. A longer command
1071 name can be shadowed by a shorter command name that happens to be a
1072 prefix of the longer name, if the command name is given as multiple
1073 arguments. The equivalent form with the longer command name combined
1074 using dashes into a single argument will correctly refer to the
1075 otherwise shadowed command.
1077 The @command{dejagnu} launcher can also be run using symbolic links,
1078 provided that the shell places the name under which @command{dejagnu}
1079 was invoked in @code{$0}. Any dash-separated words after ``dejagnu''
1080 in the name of such a link are taken to be the leading words of a
1083 The @command{dejagnu} launcher supports alternate implementations
1084 depending upon available interpreters.
1086 Options for the @command{dejagnu} launcher itself cannot be
1087 abbreviated, since the launcher has no way to know which abbreviations
1088 are unique and which would be ambiguous to the invoked command.
1093 Print a help message instead of running a command.
1095 @item @code{-V}, @code{--version}
1096 Print a version banner for the launcher itself including the version
1097 of DejaGnu. Any command given is ignored.
1099 @item @code{-v}, @code{--verbose}
1100 Emit additional output describing the inner workings of the
1101 @command{dejagnu} launcher. This option is also passed on to the
1106 All arguments after the command name are passed to the invoked
1109 @node Invoking dejagnu help, Invoking dejagnu report card, Invoking dejagnu, Running other DejaGnu commands
1110 @section Invoking @command{dejagnu help}
1111 @cindex dejagnu help, invoking
1113 The @command{dejagnu help} tool displays long-form documentation for
1114 DejaGnu auxiliary commands that are invoked using the
1115 @command{dejagnu} launcher.
1118 @command{dejagnu help} [options...] <command>
1121 Again, command names may contain multiple words. This command forms
1122 an operand by joining all words in the command name using dashes
1123 (@samp{-}) and prepending @samp{dejagnu-}. This is then used as the
1124 name of a manual page and passed to the @command{man} command.
1126 If the manual page is in a particular directory relative to the script
1127 implementing this command, a full file name is produced, otherwise,
1128 @command{man} performs its normal search.
1130 The @option{--verbose} option causes additional output describing the
1131 inner workings of the @command{dejagnu help} command to be produced.
1133 The @option{--path}, @option{-w}, and @option{-W} options are passed
1136 @node Invoking dejagnu report card, , Invoking dejagnu help, Running other DejaGnu commands
1137 @section Invoking @command{dejagnu report card}
1138 @cindex dejagnu report card, invoking
1139 @cindex dejagnu report-card, invoking
1141 The @command{dejagnu report card} tool produces a tabular summary of
1142 the results from test runs by reading the summary files that DejaGnu
1146 @command{dejagnu report card} [<option>|<tool>|<file>]...
1149 The @option{--verbose} option causes additional output describing the
1150 inner workings of the @command{dejagnu report card} command to be
1153 Aside from options, the command may include a list of tools or files.
1154 Names ending in @samp{.sum} are used as-is. Names ending in
1155 @samp{.log} are changed to instead refer to the summary file. Names
1156 ending with a simple dot (@samp{.}) have @samp{sum} appended, for
1157 convenience when using Readline filename completion in a shell, which
1158 will complete to the dot, since there are both @samp{.sum} and
1159 @samp{.log} files produced for each tool tested. Lastly, all other
1160 names are taken as tool names and @samp{.sum} is appended to refer to
1161 the summary file produced by DejaGnu.
1163 The relevant summary files are read and an ASCII-art table is
1164 produced. The table has columns for counts of tests passed, failed,
1165 unsupported, unresolved, and untested. Tests that are expected to
1166 pass and tests that are expected to fail are counted in separate
1167 columns, but known failures (@samp{KFAIL} and @samp{KPASS}) are
1168 summarized together with expected failures (@samp{XFAIL} and
1169 @samp{XPASS}) in two additional columns: @samp{?PASS} and
1170 @samp{?FAIL}. Additionally, if a test produced any warnings or
1171 errors, tags @samp{!W!} or @samp{!E!} are added at the end of the row.
1173 @node Customizing DejaGnu, Extending DejaGnu, Running other DejaGnu commands, Top
1174 @chapter Customizing DejaGnu
1175 @cindex customization
1177 The site configuration file, @file{site.exp}, captures
1178 configuration-dependent values and propagates them to the DejaGnu test
1179 environment using Tcl variables. This ties the DejaGnu test scripts
1180 into the @code{configure} and @code{make} programs. If this file is
1181 setup correctly, it is possible to execute a testsuite merely by
1182 typing @code{runtest}.
1184 DejaGnu supports two @file{site.exp} files. The multiple instances of
1185 @file{site.exp} are loaded in a fixed order. The first file loaded is
1186 the local file @file{site.exp}, and then the optional global
1187 @file{site.exp} file as pointed to by the @code{DEJAGNU} environment
1190 There is an optional global @file{site.exp}, containing configuration
1191 values that apply to DejaGnu site-wide. @code{runtest} loads these
1192 values first. The global @file{site.exp} contains the default values
1193 for all targets and hosts supported by DejaGnu. This global file is
1194 identified by setting the environment variable @code{DEJAGNU} to the
1195 name of the file. If @code{DEJAGNU} is set, but the file cannot be
1196 located, an error will be raised and @code{runtest} will abort.
1198 Any directory containing a configured testsuite also has a local
1199 @file{site.exp}, capturing configuration values specific to the tool
1200 being tested. Since @code{runtest} loads these values last, the
1201 individual test configuration can either rely on and use, or override,
1202 any of the global values from the global @file{site.exp} file.
1204 You can usually generate or update the testsuite's local
1205 @file{site.exp} by typing @code{make site.exp} in the testsuite
1206 directory, after the test suite is configured.
1208 You can also have a file in your home directory called
1209 @file{.dejagnurc}. This gets loaded after the other config files.
1210 Usually this is used for personal stuff, like setting the
1211 @code{all_flag} so all the output gets printed, or your own verbosity
1212 levels. This file is usually restricted to setting command line
1215 You can further override the default values in a user-editable section
1216 of any @file{site.exp}, or by setting variables on the @code{runtest}
1220 * Local configuration file::
1221 * Global configuration file::
1222 * Board configuration file::
1223 * Remote host testing::
1224 * Configuration file values::
1227 @node Global configuration file, Local configuration file, , Customizing DejaGnu
1228 @section Global configuration file
1229 @cindex configuration file, global
1231 The global configuration file is where all the target specific
1232 configuration variables for a site are set. For example, a
1233 centralized testing lab where multiple developers have to share an
1234 embedded development board. There are settings for both remote hosts
1235 and remote targets. Below is an example of a global configuration
1236 file for a Canadian cross environment. A Canadian cross is a
1237 toolchain that is built on, runs on, and targets three different
1238 system triplets (for example, building a Solaris-hosted MIPS R4000
1239 toolchain on a GNU/Linux system). This example is based on a
1240 configuration once used at Cygnus.
1242 @strong{Example global configuration file}
1245 # Make sure we look in the right place for the board description files.
1246 lappend boards_dir "/nfs/cygint/s1/cygnus/dejagnu/boards"
1248 verbose "Global config file: target_triplet is $target_triplet" 2
1251 switch -glob -- $target_triplet @{
1253 @ set target_list "unix"
1256 @ set target_list "sparc64-sim"
1259 @ set target_list "mips-sim wilma barney"
1262 @ set target_list "mips-lsi-sim@{,soft-float,el@}"
1267 In this case, we have support for several cross compilers, that all
1268 run on this host. To run DejaGnu tests on tools hosted on operating
1269 systems that do not run Expect, DejaGnu can be run on the build
1270 machine and connect to the remote host to run all the tests. As you
1271 can see, all one does is set the variable @code{target_list} to the
1272 list of targets and options to test.
1274 In this example, simple cases like @emph{sparc64-elf} only require
1275 setting the name of the single board configuration file. The
1276 @emph{mips-elf} target is more complicated and sets the list to three
1277 target boards. @emph{mips-sim} is a symbolic name for a simulator
1278 ``board'' and @emph{wilma} and @emph{barney} are symbolic names for
1279 physical boards. Symbolic names are covered in the @ref{Adding a new
1280 board} section. The more complicated example is the entry for
1281 @emph{mips-lsi-elf}. This one runs the tests with multiple iterations
1282 using all possible combinations of the @code{--soft-float} and the
1283 @code{--el} (little endian) options. The braced string includes an
1284 initial comma so that the set of combinations includes no options at
1285 all. Needless to say, this last target example is mostly specific to
1288 @node Local configuration file, Board configuration file, Global configuration file, Customizing DejaGnu
1289 @section Local configuration file
1290 @cindex configuration file, local
1292 It is usually more convenient to keep these @emph{manual overrides} in
1293 the @file{site.exp} local to each test directory, rather than in the
1294 global @file{site.exp} in the installed DejaGnu library. This file is
1295 mostly for supplying tool specific info that is required by the
1298 All local @file{site.exp} files have two sections, separated by
1299 comments. The first section is generated by @code{make}. It is
1300 essentially a collection of Tcl variable definitions based on
1301 @file{Makefile} environment variables. Since they are generated by
1302 @code{make}, they contain the values as specified by @code{configure}.
1303 In particular, this section contains the @file{Makefile} variables for
1304 host and target configuration data. Do not edit this first section;
1305 if you do, your changes will be overwritten the next time you run
1306 @code{make}. The first section starts with:
1309 ## these variables are automatically generated by make ##
1310 # Do not edit here. If you wish to override these values
1311 # add them to the last section
1314 In the second section, you can override any default values for all the
1315 variables. The second section can also contain your preferred
1316 defaults for all the command line options to @code{runtest}. This
1317 allows you to easily customize @code{runtest} for your preferences in
1318 each configured testsuite tree, so that you need not type options
1319 repeatedly on the command line. The second section may also be empty
1320 if you do not wish to override any defaults.
1322 @strong{The first section ends with this line}
1325 ## All variables above are generated by configure. Do Not Edit ##
1328 You can make any changes under this line. If you wish to redefine a
1329 variable in the top section, then just put a duplicate value in this
1330 second section. Usually the values defined in this configuration file
1331 are related to the configuration of the test run. This is the ideal
1332 place to set the variables @code{host_triplet}, @code{build_triplet},
1333 @code{target_triplet}. All other variables are tool dependent, i.e.,
1334 for testing a compiler, the value for @code{CC} might be set to a
1335 freshly built binary, as opposed to one in the user's path.
1337 Here's an example local site.exp file, as used for GCC/G++ testing.
1339 @strong{Local Configuration File}
1342 ## these variables are automatically generated by make ##
1343 # Do not edit here. If you wish to override these values
1344 # add them to the last section
1345 set rootme "/build/devo-builds/i686-pc-linux-gnu/gcc"
1346 set host_triplet i686-pc-linux-gnu
1347 set build_triplet i686-pc-linux-gnu
1348 set target_triplet i686-pc-linux-gnu
1349 set target_alias i686-pc-linux-gnu
1351 set CXXFLAGS "-isystem /build/devo-builds/i686-pc-linux-gnu/gcc/../libio -isystem $srcdir/../libg++/src -isystem $srcdir/../libio -isystem $srcdir/../libstdc++ -isystem $srcdir/../libstdc++/stl -L/build/devo-builds/i686-pc-linux-gnu/gcc/../libg++ -L/build/devo-builds/i686-pc-linux-gnu/gcc/../libstdc++"
1352 append LDFLAGS " -L/build/devo-builds/i686-pc-linux-gnu/gcc/../ld"
1353 set tmpdir /build/devo-builds/i686-pc-linux-gnu/gcc/testsuite
1354 set srcdir "$@{srcdir@}/testsuite"
1355 ## All variables above are generated by configure. Do Not Edit ##
1358 This file defines the required fields for a local configuration file,
1359 namely the three system triplets, and the srcdir. It also defines
1360 several other Tcl variables that are used exclusively by the GCC
1361 testsuite. For most test cases, the CXXFLAGS and LDFLAGS are supplied
1362 by DejaGnu itself for cross testing, but to test a compiler, GCC needs
1363 to manipulate these itself.
1365 @vindex test_timeout
1366 The local @file{site.exp} may also set Tcl variables such as
1367 @code{test_timeout} which can control the amount of time (in seconds)
1368 to wait for a remote test to complete. If not specified,
1369 @code{test_timeout} defaults to 300 seconds.
1371 @node Board configuration file, Remote host testing, Local configuration file, Customizing DejaGnu
1372 @section Board configuration file
1373 @cindex configuration file, board
1375 The board configuration file is where board-specific configuration
1376 details are stored. A board configuration file contains all the
1377 higher-level configuration settings. There is a rough inheritance
1378 scheme, where it is possible to derive a new board description file
1379 from an existing one. There are also collections of custom procedures
1380 for common environments. For more information on adding a new board
1381 config file, see @ref{Adding a new board}.
1383 An example board configuration file for a GNU simulator is as follows.
1384 @code{set_board_info} is a procedure that sets the field name to the
1385 specified value. The procedures mentioned in brackets are
1386 @emph{helper procedures}. These are used to find parts of a toolchain
1387 required to build an executable image that may reside in various
1388 locations. This is mostly of use when the startup code, the standard
1389 C libraries, or the toolchain itself is part of your build tree.
1391 @strong{Example file}
1393 # This is a list of toolchains that are supported on this board.
1394 set_board_info target_install @{sparc64-elf@}
1396 # Load the generic configuration for this board. This will define any
1397 # routines needed by the tool to communicate with the board.
1398 load_generic_config "sim"
1400 # We need this for find_gcc and *_include_flags/*_link_flags.
1401 load_base_board_description "basic-sim"
1403 # Use long64 by default.
1404 process_multilib_options "long64"
1408 # We only support newlib on this target. We assume that all multilib
1409 # options have been specified before we get here.
1411 set_board_info compiler "[find_gcc]"
1412 set_board_info cflags "[libgloss_include_flags] [newlib_include_flags]"
1413 set_board_info ldflags "[libgloss_link_flags] [newlib_link_flags]"
1415 set_board_info ldscript ""
1417 # Used by a few gcc.c-torture testcases to delimit how large the
1419 set_board_info gcc,stack_size 16384
1420 # The simulator doesn't return exit status and we need to indicate this
1421 # the standard GCC wrapper will work with this target.
1422 set_board_info needs_status_wrapper 1
1423 # We can't pass arguments to programs.
1424 set_board_info noargs 1
1427 There are five helper procedures used in this example:
1431 @code{find_gcc} looks for a copy of the GNU compiler in your build
1432 tree, or it uses the one in your path. This will also return the
1433 proper transformed name for a cross compiler if you whole build tree
1434 is configured for one. DejaGnu will use this procedure to locate a
1435 compiler if the @code{compiler} field is not set.
1438 @code{libgloss_include_flags} returns the flags to compile using
1439 @ref{Libgloss, libgloss}, the GNU board support package (BSP).
1442 @code{libgloss_link_flags} returns the flags to link an executable
1443 using @ref{Libgloss, libgloss}.
1446 @code{newlib_include_flags} returns the flags to compile using
1447 @uref{https://sourceware.org/newlib, newlib}, a re-entrant standard C
1448 library for embedded systems comprising of non-GPL'd code
1451 @code{newlib_link_flags} returns the flags to link an executable with
1452 @uref{https://sourceware.org/newlib, newlib}.
1456 @node Remote host testing, Configuration file values, Board configuration file, Customizing DejaGnu
1457 @section Remote host testing
1458 @cindex testing on remote hosts
1460 DejaGnu also supports running the tests on a remote host. To set this
1461 up, the remote host needs an FTP server, and a telnet server.
1462 Currently foreign operating systems used as remote hosts are VxWorks,
1463 VRTX, DOS/Windows 3.1, MacOS and Windows.
1465 The recommended source for a Windows-based FTP server is to get IIS
1466 (either IIS 1 or Personal Web Server) from
1467 @uref{http://www.microsoft.com,http://www.microsoft.com}. When you
1468 install it, make sure you install the FTP server - it's not selected
1469 by default. Go into the IIS manager and change the FTP server so that
1470 it does not allow anonymous FTP. Set the home directory to the root
1471 directory (i.e. c:\) of a suitable drive. Allow writing via FTP.
1473 It will create an account like IUSR_FOOBAR where foobar is the name of
1474 your machine. Go into the user editor and give that account a
1475 password that you don't mind hanging around in the clear (i.e. not the
1476 same as your admin or personal passwords). Also, add it to all the
1477 various permission groups.
1479 You'll also need a telnet server. For Windows, go to the
1480 @uref{http://ataman.com,Ataman} web site, pick up the Ataman Remote
1481 Logon Services for Windows, and install it. You can get started on
1482 the eval period anyway. Add IUSR_FOOBAR to the list of allowed users,
1483 set the HOME directory to be the same as the FTP default directory.
1484 Change the Mode prompt to simple.
1486 Now you need to pick a directory name to do all the testing in. For
1487 the sake of this example, we'll call it piggy (i.e. c:\piggy). Create
1490 You'll need a Unix machine. Create a directory for the scripts you'll
1491 need. For this example, we'll use /usr/local/swamp/testing. You'll
1492 need to have a source tree somewhere, say /usr/src/devo. Now, copy
1493 some files from releng's area in SV to your machine:
1495 @strong{Remote host setup}
1498 cd /usr/local/swamp/testing
1500 scp darkstar.welcomehome.org:/dejagnu/cst/bin/MkTestDir .
1501 scp darkstar.welcomehome.org:/dejagnu/site.exp .
1502 scp darkstar.welcomehome.org:/dejagnu/boards/useless98r2.exp boards/foobar.exp
1503 export DEJAGNU=/usr/local/swamp/testing/site.exp
1506 You must edit the boards/foobar.exp file to reflect your machine;
1507 change the hostname (foobar.com), username (iusr_foobar), password,
1508 and ftp_directory (c:/piggy) to match what you selected.
1510 Edit the global @file{ site.exp} to reflect your boards directory:
1512 @strong{Add The Board Directory}
1515 lappend boards_dir "/usr/local/swamp/testing/boards"
1518 Now run MkTestDir, which is in the contrib directory. The first
1519 parameter is the toolchain prefix, the second is the location of your
1520 devo tree. If you are testing a cross compiler (ex: you have
1521 sh-hms-gcc.exe in your PATH on the PC), do something like this:
1523 @strong{Setup Cross Remote Testing}
1526 ./MkTestDir sh-hms /usr/dejagnu/src/devo
1529 If you are testing a native PC compiler (ex: you have gcc.exe in your
1530 PATH on the PC), do this:
1532 @strong{Setup Native Remote Testing}
1535 ./MkTestDir '' /usr/dejagnu/src/devo
1538 To test the setup, @code{ftp} to your PC using the username
1539 (iusr_foobar) and password you selected. CD to the test directory.
1540 Upload a file to the PC. Now telnet to your PC using the same
1541 username and password. CD to the test directory. Make sure the file
1542 is there. Type "set" and/or "gcc -v" (or sh-hms-gcc -v) and make sure
1543 the default PATH contains the installation you want to test.
1545 @strong{Run Test Remotely}
1548 cd /usr/local/swamp/testing
1549 make -k -w check RUNTESTFLAGS="--host_board foobar --target_board foobar -v -v" > check.out 2>&1
1552 To run a specific test, use a command like this (for this example,
1553 you'd run this from the gcc directory that MkTestDir created):
1555 @strong{Run a Test Remotely}
1558 make check RUNTESTFLAGS="--host_board sloth --target_board sloth -v compile.exp=921202-1.c"
1561 Note: if you are testing a cross-compiler, put in the correct target
1562 board. You'll also have to download more .exp files and modify them
1563 for your local configuration. The -v's are optional.
1565 @node Configuration file values, , Remote host testing, Customizing DejaGnu
1566 @section Configuration file values
1567 @cindex configuration values
1570 DejaGnu uses a Tcl associative array to hold all the info for each
1571 machine. In the case of a Canadian cross, this means host information
1572 as well as target information. The named array is called
1573 @code{target_info}, and it has two indices. The following fields are
1577 * Command line option variables::
1578 * User configuration file::
1581 @node Command line option variables, User configuration file, , Configuration file values
1582 @subsection Command line option variables
1584 In the user editable second section of the @ref{User configuration
1585 file} you can not only override the configuration variables captured
1586 in the first section, but also specify default values for all of the
1587 @code{runtest} command line options. Excepting @code{--debug},
1588 @code{--help}, and @code{--version}, each command line option has an
1589 associated Tcl variable. Use the Tcl @code{set} command to specify a
1590 new default value (as for the configuration variables). The following
1591 table describes the correspondence between command line options and
1592 variables you can set in @file{site.exp}. Refer to @ref{Invoking
1593 runtest}, for explanations of the command-line options.
1595 @multitable {--target_board} {TOOL_EXECUTABLE} {verbosity level greater than or equal to 0}
1597 Option@tab Tcl variable@tab Description
1600 -a, --all@tab all_flag@tab display all test results if set
1603 --build@tab build_triplet@tab system triplet for the build host
1606 --dir@tab cmdline_dir_to_run@tab run only tests in the specified directory
1609 --global_init@tab global_init_file@tab file name for global init file in @code{libdir}
1612 --host@tab host_triplet@tab system triplet for the host
1615 --host_board@tab host_board@tab host board definition to use
1618 --ignore@tab ignoretests @tab do not run the specified tests
1621 --local_init@tab local_init_file@tab file name for local init file in @code{objdir}
1624 --log_dialog@tab log_dialog@tab emit Expect output to standard output
1627 --outdir@tab outdir@tab directory for @file{.sum} and @file{.log} files
1630 --objdir@tab objdir@tab directory for pre-compiled binaries
1633 --reboot@tab reboot@tab reboot the target if set to 1
1636 --srcdir@tab srcdir@tab directory of test subdirectories
1639 --target@tab target_triplet@tab system triplet for the target
1642 --target_board@tab target_list@tab list of target boards to run tests on
1645 --tool@tab tool@tab name of tool to test (selects tests to run)
1648 --tool_exec@tab TOOL_EXECUTABLE@tab path to the executable to test
1651 --tool_opts@tab TOOL_OPTIONS@tab additional options to pass to the tool
1654 --tool_root_dir@tab tool_root_dir@tab tool root directory
1657 -v, --verbose@tab verbose@tab verbosity level greater than or equal to 0
1661 @node User configuration file, , Command line option variables, Configuration file values
1662 @subsection Per-user configuration file (.dejagnurc)
1664 The per-user configuration file is named @file{.dejagnurc} in the
1665 user's home directory. It is used to customize the behaviour of
1666 @code{runtest} for each user -- typically the user's preference for
1667 log verbosity, and for storing any experimental Tcl procedures. An
1668 example @file{~/.dejagnurc} file looks like:
1670 @strong{Example .dejagnurc}
1674 set RLOGIN /usr/ucb/rlogin
1675 set RSH /usr/local/sbin/ssh
1678 Here @code{all_flag} is set so that I see all the test cases that PASS
1679 along with the ones that FAIL. I also set @code{RLOGIN} to the BSD
1680 (non-Kerberos) version. I also set @code{RSH} to the SSH secure
1681 shell, as rsh is mostly used to test Unix machines within a local
1684 @node Extending DejaGnu, Unit testing, Customizing DejaGnu, Top
1685 @chapter Extending DejaGnu
1687 @cindex extending DejaGnu
1689 This chapter describes how to extend DejaGnu with new testsuites, new
1690 tools, new targets and new boards.
1693 * Adding a new testsuite::
1694 * Adding a new tool::
1695 * Adding a new target::
1696 * Adding a new board::
1697 * Board file values::
1698 * Writing a test case::
1699 * Debugging a test case::
1700 * Adding a test case to a testsuite::
1701 * Test case special variables: Test case variables.
1704 @node Adding a new testsuite, Adding a new tool, , Extending DejaGnu
1705 @section Adding a new testsuite
1706 @cindex adding, testsuite
1708 The testsuite for a new package should always be located in the source
1709 directory of that package. DejaGnu requires this directory to be
1710 named @file{testsuite}. Under this directory, the test cases go in
1711 various subdirectories whose name begins with the tool name. The
1712 organization of the various testsuite subdirectories is up to you.
1713 For a tool named @code{gdb}, for instance, each subdirectory
1714 containing tests must start with @samp{gdb.}.
1716 @node Adding a new tool, Adding a new target, Adding a new testsuite, Extending DejaGnu
1717 @section Adding a new tool
1719 In general, the best way to learn how to write code, or even prose, is
1720 to read something similar. This principle applies to test cases and
1721 to testsuites. Unfortunately, well-established testsuites have a way
1722 of developing their own conventions: as test writers become more
1723 experienced with DejaGnu and with Tcl, they accumulate more utilities,
1724 and take advantage of more and more features of Expect and Tcl in
1725 general. Inspecting such established testsuites may make the prospect
1726 of creating an entirely new testsuite appear overwhelming.
1727 Nevertheless, it is straightforward to start a new testsuite.
1729 To help orient you further in this task, here is an outline of the
1730 steps to begin building a testsuite for a program example.
1732 Create or select a directory to contain your new collection of tests.
1733 Change into that directory (shown here as @file{testsuite}):
1735 Create a @file{configure.in} file in this directory, to control
1736 configuration-dependent choices for your tests. So far as DejaGnu is
1737 concerned, the important thing is to set a value for the variable
1738 @code{target_abbrev}; this value is the link to the init file you will
1739 write soon. (For simplicity, we assume the environment is Unix, and
1740 use @emph{unix} as the value.)
1742 What else is needed in @file{configure.in} depends on the requirements
1743 of your tool, your intended test environments, and which configure
1744 system you use. This example is a minimal @file{configure.ac} for use
1747 @subsection Sample Makefile.in Fragment
1749 Create @file{Makefile.in} (if using Autoconf), or @file{Makefile.am}
1750 (if using Automake), the source file used by configure to build your
1751 @file{Makefile}. If you are using GNU Automake.just add the keyword
1752 @emph{dejagnu} to the @emph{AUTOMAKE_OPTIONS} variable in your
1753 @file{Makefile.am} file. This will add all the @file{Makefile}
1754 support needed to run DejaGnu, and support the @ref{Make Check, make
1757 You also need to include two targets important to DejaGnu:
1758 @emph{check}, to run the tests, and @emph{site.exp}, to set up the Tcl
1759 copies of configuration-dependent values. This is called the
1760 @ref{Local configuration file} The @emph{check} target must invoke the
1761 @code{runtest} program to run the tests.
1763 The @emph{site.exp} target should usually set up (among other things)
1764 the @emph{$tool} variable for the name of your program. If the local
1765 @file{site.exp} file is setup correctly, it is possible to execute the
1766 tests by merely typing @code{runtest} on the command line.
1769 # Look for a local version of DejaGnu, otherwise use one in the path
1770 RUNTEST = `if test -f $(top_srcdir)/../dejagnu/runtest; then \
1771 echo $(top_srcdir) ../dejagnu/runtest; \
1776 # Flags to pass to runtest
1781 @ $(RUNTEST) $(RUNTESTFLAGS) --tool $@{example@} --srcdir $(srcdir)
1783 # Make the local config file
1784 site.exp: ./config.status Makefile
1785 @ @@echo "Making a new config file..."
1789 @ -@@mv site.exp site.bak
1790 @ @@echo "## these variables are automatically generated by make ##" > ./tmp0
1791 @ @@echo "# Do not edit here. If you wish to override these values" >> ./tmp0
1792 @ @@echo "# add them to the last section" >> ./tmp0
1793 @ @@echo "set host_os $@{host_os@}" >> ./tmp0
1794 @ @@echo "set host_alias $@{host_alias@}" >> ./tmp0
1795 @ @@echo "set host_cpu $@{host_cpu@}" >> ./tmp0
1796 @ @@echo "set host_vendor $@{host_vendor@}" >> ./tmp0
1797 @ @@echo "set target_os $@{target_os@}" >> ./tmp0
1798 @ @@echo "set target_alias $@{target_alias@}" >> ./tmp0
1799 @ @@echo "set target_cpu $@{target_cpu@}" >> ./tmp0
1800 @ @@echo "set target_vendor $@{target_vendor@}" >> ./tmp0
1801 @ @@echo "set host_triplet $@{host_canonical@}" >> ./tmp0
1802 @ @@echo "set target_triplet $@{target_canonical@}">>./tmp0
1803 @ @@echo "set tool binutils" >> ./tmp0
1804 @ @@echo "set srcdir $@{srcdir@}" >> ./tmp0
1805 @ @@echo "set objdir `pwd`" >> ./tmp0
1806 @ @@echo "set $@{examplename@} $@{example@}" >> ./tmp0
1807 @ @@echo "## All variables above are generated by configure. Do Not Edit ##" >> ./tmp0
1808 @ @@cat ./tmp0 > site.exp
1809 @ @@sed < site.bak \
1810 @ -e '1,/^## All variables above are.*##/ d' \
1815 @subsection Simple tool init file for batch programs
1817 The tool init file may be placed in @file{testsuite/lib} or in
1818 @file{testsuite/lib/tool} and must be named @file{@var{tool}.exp},
1819 where @var{tool} is the name of the tool to be tested. For this
1820 example, we will use the name @samp{example} for the tool name, which
1821 means that the tool init file must be named @file{example.exp}. If the
1822 program being tested is not interactive, you can get away with this
1823 minimal tool init file to begin with:
1826 proc example_exit @{@} @{@}
1827 proc example_version @{@} @{@}
1830 By convention, the file name for the executable for a tool should be
1831 stored in a global variable with the same name as the tool, but in all
1832 uppercase. For our example program @samp{example}, the name of the
1833 program under test should be stored in @samp{EXAMPLE}.
1835 @subsection Simple tool init file for interactive programs
1837 If the program being tested is interactive, however, you might as well
1838 define a @emph{start} routine and invoke it by using a tool init file
1842 proc example_exit @{@} @{@}
1843 proc example_version @{@} @{@}
1845 proc example_start @{@} @{
1853 # Start the program running we want to test
1857 Create a directory whose name begins with your tool's name, to contain
1858 tests. For example, if the tool name is @samp{example}, then the
1859 directories all need to start with @samp{example.}. Create a sample
1860 test file ending in @file{.exp}. You can name the file
1861 @file{first-try.exp}. To begin with, just write one line of Tcl code
1865 send_user "Testing: one, two...\n"
1868 @subsection Testing A New Tool Config
1870 Back in the @file{testsuite} (top level) directory, run
1871 @code{configure}. Typically you do this while in the build directory.
1872 You are now ready to type @code{make check} or @code{runtest}. You
1873 should see something like this:
1876 Test Run By bje on Sat Nov 14 15:08:54 AEDT 2015
1878 @ === example tests ===
1880 Running ./example.0/first-try.exp ...
1881 Testing: one, two...
1883 @ === example Summary ===
1886 There is no output in the summary, because so far the example does not
1887 call any of the procedures that report a test outcome.
1889 Write some real tests. For an interactive tool, you should probably
1890 write a real exit routine in fairly short order. In any case, you
1891 should also write a real version routine soon.
1893 @node Adding a new target, Adding a new board, Adding a new tool, Extending DejaGnu
1894 @section Adding a new target
1895 @cindex adding, target
1897 DejaGnu has some additional requirements for target support, beyond
1898 the general-purpose provisions of a @code{configure} script. DejaGnu
1899 must actively communicate with the target, rather than simply
1900 generating or managing code for the target architecture. Therefore,
1901 each tool requires an initialization module for each target. For new
1902 targets, you must supply a few Tcl procedures to adapt DejaGnu to the
1905 Usually the best way to write a new initialization module is to edit
1906 an existing initialization module; some trial and error will be
1907 required. If necessary, you can use the @code{--debug} option to see
1908 what is really going on.
1910 When you code an initialization module, be generous in printing
1911 information using the @code{verbose} procedure. In cross-development
1912 environments, most of the work is in getting the communications right.
1913 Code for communicating via TCP/IP networks or serial lines is
1914 available in a DejaGnu library files such as @file{lib/telnet.exp}.
1916 If you suspect a communication problem, try running the connection
1917 interactively from Expect. (There are three ways of running Expect as
1918 an interactive interpreter. You can run Expect with no arguments, and
1919 control it completely interactively; or you can use @code{expect -i}
1920 together with other command-line options and arguments; or you can run
1921 the command @code{interpreter} from any Expect procedure. Use
1922 @code{return} to get back to the calling procedure (if any), or
1923 @code{return -tcl} to make the calling procedure itself return to its
1924 caller; use @code{exit} or end-of-file to leave Expect altogether.)
1925 Run the program whose name is recorded in @code{$connectmode}, with
1926 the arguments in @code{$targetname}, to establish a connection. You
1927 should at least be able to get a prompt from any target that is
1928 physically connected.
1930 @node Adding a new board, Board file values, Adding a new target, Extending DejaGnu
1931 @section Adding a new board
1932 @cindex adding, board
1934 Adding a new board consists of creating a new board configuration
1935 file. Examples are in @file{dejagnu/baseboards}. Usually to make a
1936 new board file, it's easiest to copy an existing one. It is also
1937 possible to have your file be based on a @emph{baseboard} file with
1938 only one or two changes needed. Typically, this can be as simple as
1939 just changing the linker script. Once the new baseboard file is done,
1940 add it to the @code{boards_DATA} list in the
1941 @file{dejagnu/baseboards/Makefile.am}, and regenerate the Makefile.in
1942 using automake. Then just rebuild and install DejaGnu. You can test
1945 There is a crude inheritance scheme going on with board files, so you
1946 can include one board file into another, The two main procedures used
1947 to do this are @code{load_generic_config} and
1948 @code{load_base_board_description}. The generic configuration file
1949 contains other procedures used for a certain class of target. The
1950 board description file is where the board specific settings go.
1951 Commonly there are similar target environments with just different
1954 @strong{Testing a New Board Configuration File}
1957 make check RUNTESTFLAGS="--target_board=newboardfile".
1960 Here's an example of a board configuration file. There are several
1961 @emph{helper procedures} used in this example. A helper procedure is
1962 one that look for a tool of files in commonly installed locations.
1963 These are mostly used when testing in the build tree, because the
1964 executables to be tested are in the same tree as the new DejaGnu
1965 files. The helper procedures are the ones in brackets, which
1966 indicates a Tcl procedure call.
1968 @strong{Example Board Configuration File}
1971 # Load the generic configuration for this board. This will define a basic
1972 # set of routines needed by the tool to communicate with the board.
1973 load_generic_config "sim"
1975 # basic-sim.exp is a basic description for the standard Cygnus simulator.
1976 load_base_board_description "basic-sim"
1978 # The compiler used to build for this board. This has *nothing* to do
1979 # with what compiler is tested if we're testing gcc. Further, this is
1980 # the default, so this line is optional for most boards.
1981 set_board_info compiler "[find_gcc]"
1983 # We only support newlib on this target.
1984 # However, we include libgloss so we can find the linker scripts.
1985 set_board_info cflags "[newlib_include_flags] [libgloss_include_flags]"
1986 set_board_info ldflags "[newlib_link_flags]"
1988 # No linker script for this board.
1989 set_board_info ldscript "-Tsim.ld"
1991 # The simulator doesn't return exit statuses and we need to indicate this.
1992 set_board_info needs_status_wrapper 1
1994 # Can't pass arguments to this target.
1995 set_board_info noargs 1
1998 set_board_info gdb,nosignals 1
2000 # And it can't call functions.
2001 set_board_info gdb,cannot_call_functions 1
2004 @node Board file values, Writing a test case, Adding a new board, Extending DejaGnu
2005 @section Board configuration file values
2007 The following fields are in the @code{board_info} array. These are
2008 set by the @code{set_board_info} procedure (or @code{add_board_info}
2009 procedure for appending to lists). Both procedures take a field name
2010 and a value for the field (or is added to the field), respectively.
2011 Some common board info fields are shown below.
2013 @multitable @columnfractions 0.2 0.2 0.6
2015 @strong{Field} @tab @strong{Example value} @tab @strong{Description}
2017 compiler@tab @code{[find_gcc]}@tab The path to the compiler to use.
2019 cflags@tab @code{-mca}@tab Compilation flags for the compiler.
2021 ldflags@tab @code{[libgloss_link_flags] [newlib_link_flags]}@tab Linking flags for the compiler.
2023 ldscript@tab @code{-Wl,-Tidt.ld}@tab The linker script to use when cross compiling.
2025 libs@tab @code{-lgcc}@tab Any additional libraries to link in.
2027 shell_prompt@tab @code{cygmon>}@tab The command prompt of the remote shell.
2029 hex_startaddr@tab @code{0xa0020000}@tab The Starting address as a string.
2031 start_addr@tab 0xa0008000@tab The starting address as a value.
2033 startaddr@tab @code{a0020000}@tab
2035 exit_statuses_bad@tab 1@tab Whether there is an accurate exit status.
2037 reboot_delay@tab 10@tab The delay between power off and power on.
2039 unreliable@tab 1@tab Whether communication with the board is unreliable.
2041 sim@tab [find_sim]@tab The path to the simulator to use.
2043 objcopy@tab $tempfil@tab The path to the @code{objcopy} program.
2045 support_libs@tab @code{$@{prefix_dir@}/i386-coff/}@tab Support libraries needed for cross compiling.
2047 addl_link_flags@tab @code{-N}@tab Additional link flags, rarely used.
2049 remotedir@tab @code{/tmp/runtest.[pid]}@tab Directory on the remote target in which executables are downloaded and executed.
2052 These fields are used by the GCC and GDB tests, and are mostly only
2053 useful to somewhat trying to debug a new board file for one of these
2054 tools. Many of these are used only by a few testcases, and their
2055 purpose is esoteric. These are listed with sample values as a guide
2056 to better guessing if you need to change any of these.
2058 @strong{Board Info Fields For GCC & GDB}
2060 @multitable @columnfractions 0.333333333333333 0.333333333333333 0.333333333333333
2062 Field@tab Sample Value@tab Description
2064 strip@tab $tempfile@tab Strip the executable of symbols.
2066 gdb_load_offset@tab "0x40050000"@tab
2068 gdb_protocol@tab "remote"@tab The GDB debugging protocol to use.
2070 gdb_sect_offset@tab "0x41000000";@tab
2072 gdb_stub_ldscript@tab "-Wl,-Teva-stub.ld"@tab The linker script to use with a GDB stub.
2074 gdb,noargs@tab 1@tab Whether the target can take command line arguments.
2076 gdb,nosignals@tab 1@tab Whether there are signals on the target.
2078 gdb,short_int@tab 1@tab
2080 gdb,target_sim_options@tab "-sparclite"@tab Special options to pass to the simulator.
2082 gdb,timeout@tab 540@tab Timeout value to use for remote communication.
2084 gdb_init_command@tab "set mipsfpu none"@tab A single command to send to GDB before the program being
2085 debugged is started.
2087 gdb_init_commands@tab "print/x \$fsr = 0x0"@tab Same as @emph{gdb_init_command}, except
2088 that this is a list, more commands can be added.
2090 gdb_load_offset@tab "0x12020000"@tab
2092 gdb_opts@tab "--command gdbinit"@tab
2094 gdb_prompt@tab "\\(gdb960\\)"@tab The prompt GDB is using.
2096 gdb_run_command@tab "jump start"@tab
2098 gdb_stub_offset@tab "0x12010000"@tab
2100 use_gdb_stub@tab 1@tab Whether to use a GDB stub.
2102 wrap_m68k_aout@tab 1@tab
2104 gcc,no_label_values@tab 1@tab
2106 gcc,no_trampolines@tab 1@tab
2108 gcc,no_varargs@tab 1@tab
2110 gcc,stack_size@tab 16384@tab Stack size to use with some GCC testcases.
2112 ieee_multilib_flags@tab "-mieee"@tab
2114 is_simulator@tab 1@tab
2116 needs_status_wrapper@tab 1@tab
2120 no_long_long@tab 1@tab
2124 target_install@tab @{sh-hms@}@tab
2127 @node Writing a test case, Debugging a test case, Board file values, Extending DejaGnu
2128 @section Writing a test case
2129 @cindex Writing a test case
2131 The easiest way to prepare a new test case is to base it on an
2132 existing one for a similar situation. There are two major categories
2133 of tests: batch-oriented and interactive. Batch-oriented tests are
2134 usually easier to write.
2136 The GCC tests are a good example of batch-oriented tests. All GCC
2137 tests consist primarily of a call to a single common procedure, since
2138 all the tests either have no output, or only have a few warning
2139 messages when successfully compiled. Any non-warning output
2140 constitutes a test failure. All the C code needed is kept in the test
2141 directory. The test driver, written in Tcl, need only get a listing
2142 of all the C files in the directory, and compile them all using a
2143 generic procedure. This procedure and a few others supporting for
2144 these tests are kept in the library module @file{lib/c-torture.exp} of
2145 the GCC testsuite. Most tests of this kind use very few Expect
2146 features, and are coded almost purely in Tcl.
2148 Writing the complete suite of C tests, then, consisted of these steps:
2152 Copying all the C code into the test directory. These tests were
2153 based on the C-torture test created by Torbjorn Granlund (on behalf of
2154 the Free Software Foundation) for GCC development.
2157 Writing (and debugging) the generic Tcl procedures for compilation.
2160 Writing the simple test driver: its main task is to search the
2161 directory (using the Tcl procedure @emph{glob} for filename expansion
2162 with wildcards) and call a Tcl procedure with each filename. It also
2163 checks for a few errors from the testing procedure.
2166 Testing interactive programs is intrinsically more complex. Tests for
2167 most interactive programs require some trial and error before they are
2170 However, some interactive programs can be tested in a simple fashion
2171 reminiscent of batch tests. For example, prior to the creation of
2172 DejaGnu, the GDB distribution already included a wide-ranging testing
2173 procedure. This procedure was very robust, and had already undergone
2174 much more debugging and error checking than many recent DejaGnu test
2175 cases. Accordingly, the best approach was simply to encapsulate the
2176 existing GDB tests, for reporting purposes. Thereafter, new GDB tests
2177 built up a family of Tcl procedures specialized for GDB testing.
2179 @subsection Hints on writing a test case
2180 @cindex hints on writing a test case
2181 @cindex test cases, writing
2183 To preserve basic sanity, no should test ever pass if there was any
2184 kind of problem in the test case. To take an extreme case, tests that
2185 pass even when the tool will not spawn are misleading. Ideally, a
2186 test in this sort of situation should not fail either. Instead, print
2187 an error message by calling one of the DejaGnu procedures
2188 @code{perror} or @code{warning}. Note that using @code{perror} will
2189 cause the next text result to be reported as @samp{UNRESOLVED}, so
2190 printing an error and allowing the test to fail is a good option.
2192 If you have trouble understanding why a pattern does not match the
2193 program output, try using the @code{--debug} option to @code{runtest},
2194 and examine the debug log carefully.
2196 If you use glob patterns, you will need to escape any @samp{*},
2197 @samp{?}, @samp{[}, @samp{]}, and @samp{\} characters that are meant
2198 to match literally. If you use regular expressions, see the
2199 @cite{re_syntax(n)} manual page from Tcl for the syntax details, and
2200 be sure to understand what punctuation characters match literally and
2201 what characters have special meanings in regular expressions.
2203 Tcl has a few options for quoting; the most notable are @samp{@{@}}
2204 and @samp{""}. These quotes behave differently: @samp{@{@}} must
2205 balance, while @samp{""} performs various interpolations. In
2206 @samp{@{@}} quotes, unbalanced @samp{@{} or @samp{@}} characters must
2207 be escaped with @samp{\} and these escapes are @emph{not} removed;
2208 fortunately, backslash-escaped braces match literal braces in Tcl
2209 regular expressions. In @samp{""} quotes, any embedded @samp{"}
2210 characters must be escaped, a literal @samp{$} begins a variable
2211 substitution, and unescaped @samp{[]} introduce a Tcl command
2214 @subsubheading Synchronization with the tested program
2216 A DejaGnu testsuite executes concurrently with the programs that it
2217 tests. As a result, DejaGnu may see parts of the tested program's
2218 output while the tested program is still producing more output.
2219 Expect patterns must be written to handle the possibility that
2220 incomplete output from the tested program will be considered for
2223 Expect reads the output from the tested program into an internal
2224 matching buffer and removes everything from the start of the buffer to
2225 the end of the match when a match is found. Any given character can
2226 be matched at most once, or skipped if a match is found starting later
2227 in the buffer or the buffer reaches its capacity. Anything left in
2228 the buffer after the end of the match remains in the buffer and is
2229 considered for the next @code{expect} command. If @code{expect} is
2230 invoked and no patterns match, Expect waits for more text to arrive.
2231 New text is appended to the buffer as it is read. If the buffer
2232 reaches its capacity, the entire contents of the buffer are discarded
2233 and Expect resumes reading.
2235 In Expect patterns, the regular expression anchors @samp{^} and
2236 @samp{$} match at the beginning and end of the @emph{buffer}, not at
2237 line boundaries. The @samp{$} anchor must be used with care because
2238 it will match at the end of what Expect @emph{has} read, but the
2239 program may have produced more output that Expect @emph{has not yet}
2240 read. Similarly, regular expressions ending with the @samp{*}
2241 quantifier can potentially match a prefix of the intended text, only
2242 for the rest to arrive shortly thereafter.
2244 Maintaining synchronization with the tested program is easier if the
2245 patterns match all of the output generated by the tested program; this
2248 For interactive programs, a prompt is usually a good synchronization
2249 point, provided that the program's prompt can be uniquely recognized.
2250 Since the prompt is usually the last output until the program receives
2251 further input, the @samp{$} anchor can be useful here.
2253 If the output from the tested program is organized into lines,
2254 matching end-of-line using @samp{\n} is usually a good way to process
2255 one line at a time. Note that terminal settings may result in the
2256 insertion of additional @samp{\r} characters, usually translating
2257 @samp{\n} to @samp{\r\n}.
2259 Be careful not to neglect output generated by setup rather than by the
2260 interesting parts of a test case. For example, while testing GDB, a
2261 @samp{set height 0\n} command is issued. The purpose is simply to
2262 make sure GDB never calls a paging program. The @samp{set height}
2263 command in GDB does not generate any output; but running any command
2264 makes GDB issue a new @samp{(gdb) } prompt. If there were no
2265 @code{expect} command to match this prompt, the @samp{(gdb) } prompt
2266 will remain in the buffer and begin the text seen by the next
2267 @code{expect} command---which might make that pattern fail to match.
2269 @subsubheading Priority of Expect patterns
2271 Be particularly careful about how you write the patterns. Expect
2272 attempts to match each pattern in the order that they are written in
2273 the @code{expect} command. Unless a regexp pattern is anchored at the
2274 beginning of the buffer, Expect can search ahead for a match for a
2275 pattern that appears earlier in the @code{expect} command and skip
2276 over text that would match a later pattern. @emph{The text thus
2277 skipped is discarded.} This is a source of very hard to trace bugs,
2278 especially when reading input from batch-oriented unit tests.
2280 For example, consider a simple model once used by the DejaGnu
2281 testsuite for unit testing. In this example, a test has failed, but
2282 the tests before and after it have passed. First the relevant input
2291 The test script is reading this with two Expect patterns, simplified
2292 for this example by omitting handling of the actual messages and other
2297 -re @{PASSED: [^\r\n]+[\r\n]+@} @{ pass ... @}
2298 -re @{FAILED: [^\r\n]+[\r\n]+@} @{ fail ... @}
2302 At every cycle, Expect attempts to match each pattern in the order
2303 that they are written against the available input. If DejaGnu is
2304 processing the input as quickly as it arrives, this example will
2305 actually work. However, if the system scheduler sets DejaGnu aside
2306 for a bit, or the external program produces output in a burst, Expect
2307 can find that its input buffer contains the text in the first example
2308 above all at once as the cycle begins.
2310 If this occurs, Expect will first attempt to match @code{@{PASSED:
2311 [^\r\n]+[\r\n]+@}} against the input and will succeed, since the input
2312 begins with @samp{PASSED: foo}. The @code{pass} procedure is called
2313 and the test result recorded. Expect then starts a new matching
2316 If the input had been presented one line at a time, the expected
2317 result would occur: the @code{@{FAILED: [^\r\n]+[\r\n]+@}} pattern
2318 would match and the test driver would work correctly. But we are
2319 considering the case where all three lines arrived ``at once'' so we
2320 must examine what Expect will do in this case. After the first line
2321 has been processed, the Expect buffer now contains:
2328 Expect again attempts to match each pattern in order. Expect will
2329 attempt to match @code{@{PASSED: [^\r\n]+[\r\n]+@}} before attempting
2330 to match @code{@{FAILED: [^\r\n]+[\r\n]+@}} and the first attempt
2331 succeeds because the pattern is not anchored. The @samp{FAILED: bar}
2332 message is simply discarded when Expect finds the later
2333 @samp{PASSED:baz} message in the buffer.
2335 How to prevent this? There are two ways: either group all of your
2336 test matches into a single regexp using alternation, or ensure that
2337 all patterns can match only at the start of Expect's buffer. Both
2338 options can be made to work. Grouping all status results into a
2339 single regexp allows some other unspecified text to still be silently
2340 discarded, while ensuring that all patterns are anchored absolutely
2341 requires closure, as any unmatched text will cause Expect to run out
2342 of buffer space. Expect discards the entire buffer when this occurs.
2344 @node Debugging a test case, Adding a test case to a testsuite, Writing a test case, Extending DejaGnu
2345 @section Debugging a test case
2346 @cindex test cases, debugging
2348 These are the kinds of debugging information available from DejaGnu:
2353 Output controlled by test scripts themselves, explicitly allowed for
2354 by the test author. This kind of debugging output appears in the
2355 detailed output recorded in the DejaGnu log file. To do the same for
2356 new tests, use the @code{verbose} procedure (which in turn uses the
2357 Tcl variable @samp{verbose}) to control how much output to generate.
2358 This will make it easier for other people running the test to debug it
2359 if necessary. If @samp{verbose} is zero, there should be no output
2360 other than the output from the framework (eg. FAIL). Then, to
2361 whatever extent is appropriate for the particular test, allow
2362 successively higher values of @samp{verbose} to generate more
2363 information. Be kind to other programmers who use your tests --
2364 provide plenty of debugging information.
2367 Output from the internal debugging functions of Tcl and Expect. There
2368 is a command line options for each; both forms of debugging output are
2369 recorded in the file @file{dbg.log} in the current directory.
2371 Use @code{--debug} for information from Expect. It logs how Expect
2372 attempts to match the tool output with the patterns specified. This
2373 can be very helpful while developing test scripts, since it shows
2374 precisely the characters received. Iterating between the latest
2375 attempt at a new test script and the corresponding @file{dbg.log} can
2376 allow you to create the final patterns by ``cut and paste''. This is
2377 sometimes the best way to write a test case.
2380 Use @code{--strace} to see more detail from Tcl. This logs how Tcl
2381 procedure definitions are expanded as they execute. The trace level
2382 argument controls the depth of definitions expanded.
2385 If the value of @samp{verbose} is 3 or greater (@code{runtest -v -v
2386 -v}), DejaGnu activates the Expect command @code{log_user}. This
2387 command prints all Expect actions to standard output, to the
2388 @file{.log} file and, if @code{--debug} is given, to @file{dbg.log}.
2391 @node Adding a test case to a testsuite, Test case variables, Debugging a test case, Extending DejaGnu
2392 @section Adding a test case to a testsuite
2393 @cindex test cases, adding
2395 There are two slightly different ways to add a test case. One is to
2396 add the test case to an existing directory. The other is to create a
2397 new directory to hold your test. The existing test directories
2398 represent several styles of testing, all of which are slightly
2399 different. Examine the testsuite subdirectories for the tool of
2400 interest to see which approach is most suitable.
2402 Adding a GCC test may be very simple: just add the source file to any
2403 test directory beginning with @file{gcc.} and it will be tested on the
2406 Adding a test by creating a new directory involves:
2410 Create the new directory. All subdirectory names begin with the name
2411 of the tool to test; e.g. G++ tests might be in a directory called
2412 @file{g++.other}. There can be multiple testsuite subdirectories with
2413 the same tool name prefix.
2416 Add the new test case to the directory, as above.
2419 @node Test case variables, , Adding a test case to a testsuite, Extending DejaGnu
2420 @section Test case special variables
2422 There are special variables that contain other information from
2423 DejaGnu. Your test cases can inspect these variables, as well as the
2424 variables saved in @file{site.exp}. These variables should never be
2431 The bug tracking system (eg. PRMS/GNATS) number identifying a
2432 corresponding bug report (@emph{0} if you do not specify it).
2436 An optional bug ID, perhaps a bug identification number from another
2437 organization (@emph{0} if you do not specify it).
2441 The subdirectory for the current test case.
2445 This is the output from a @code{$@{tool@}_load} command. This only
2446 applies to tools like GCC and GAS which produce an object file that
2447 must in turn be executed to complete a test.
2451 This is the output from a @code{$@{tool@}_start} command. This is
2452 conventionally used for batch-oriented programs, like GCC and GAS,
2453 that may produce interesting output (warnings, errors) without further
2456 @item $expect_out(buffer)
2457 @vindex expect_out(buffer)
2458 The output from the last command. This is an internal variable set by
2459 Expect. More information can be found in the Expect manual.
2462 @node Unit testing, Built-in Procedures, Extending DejaGnu, Top
2463 @chapter Unit testing
2466 * What is unit testing?:: Unit testing and system testing.
2467 * Running unit tests::
2468 * DejaGnu unit test protocol:: DejaGnu native unit testing protocol.
2469 * C unit testing API::
2470 * C++ unit testing API::
2473 @node What is unit testing?, Running unit tests, Unit testing, Unit testing
2474 @section What is unit testing?
2475 @cindex unit testing
2477 Most regression testing as done by DejaGnu is system testing: the
2478 complete application is tested all at once. Unit testing is for
2479 testing single files, or small libraries. In this case, each file is
2480 linked with a test case in C or C++, and each function or class and
2481 method is tested in turn, with the test case having to check private
2482 data or global variables to see if the function or method worked.
2484 This works particularly well for testing APIs at a level where it is
2485 easier to debug them, than by needing to trace through the entire
2486 application. Also if there is a specification for the API to be
2487 tested, the testcase can also function as a compliance test.
2489 @node Running unit tests, DejaGnu unit test protocol, What is unit testing?, Unit testing
2490 @section Running unit tests
2491 @findex host_execute
2493 The native DejaGnu unit testing support is provided by a library
2494 module @file{dejagnu.exp} and the procedure @code{host_execute} is
2495 called by testsuite code to run unit tests.
2498 @t{@b{host_execute} @i{program} @i{arguments}}
2501 The @code{host_execute} procedure runs @i{program}, passing
2502 @i{arguments} on the command line, and examines the output for test
2503 result messages according to the DejaGnu unit testing protocol.
2505 If successful, the return value is an empty string. Otherwise, an
2506 error message is returned.
2508 @node DejaGnu unit test protocol, C unit testing API, Running unit tests, Unit testing
2509 @section DejaGnu unit test protocol
2511 DejaGnu spawns a unit test program and reads that program's output.
2512 Arguments for the unit test program can be specified in the testsuite.
2514 Unit test programs may produce any output for the benefit of a
2515 developer running them directly or reading the DejaGnu log, but output
2516 matching the Tcl regexp @code{@{\n\t[][[:upper:]]*:@}} (a tab character
2517 at the beginning of a line, followed by any sequence of uppercase
2518 letters and square brackets, followed by a colon) should be considered
2519 reserved for future extension. Future versions of DejaGnu will
2520 interpret more lines matching this pattern as additional unit test
2523 @print{}@t{@ @ @ @ @ @ @ @ NOTE: }@i{text}
2525 This will cause @i{text} to be printed at verbose levels 2 and higher.
2527 @print{}@t{@ @ @ @ @ @ @ @ PASSED: }@i{name}
2529 @print{}@t{@ @ @ @ @ @ @ @ FAILED: }@i{name}
2531 @print{}@t{@ @ @ @ @ @ @ @ XPASSED: }@i{name}
2533 @print{}@t{@ @ @ @ @ @ @ @ XFAILED: }@i{name}
2535 @print{}@t{@ @ @ @ @ @ @ @ UNTESTED: }@i{name}
2537 @print{}@t{@ @ @ @ @ @ @ @ UNRESOLVED: }@i{name}
2539 These indicate simple test results.
2541 Note that all output from a unit test program, including the lines
2542 recognized and interpreted by DejaGnu, appears in the log.
2544 @node C unit testing API, C++ unit testing API, DejaGnu unit test protocol, Unit testing
2545 @section C unit testing API
2546 @cindex C unit testing API
2548 The C API is provided in the @file{dejagnu.h} header file. This
2549 header provides a self-contained implementation. For convenience, the
2550 @code{totals()} function can be called at the end of the unit test
2551 program to output summary totals. DejaGnu counts the test results
2552 independently and will operate correctly even if @code{totals()} is
2555 All of the functions that take a @code{msg} parameter use a C
2556 @code{char *} that is the message to be displayed. All of the
2557 functions that display a message accept a @code{printf}-style format
2558 string and variable arguments.
2562 @code{note} emits a note that will be displayed at verbose level 2 or
2566 @t{@b{note}(@i{msg}, ...);}
2570 @code{pass} prints a message for a successful test completion.
2573 @t{@b{pass}(@i{msg}, ...);}
2577 @code{fail} prints a message for an unsuccessful test completion.
2580 @t{@b{fail}(@i{msg}, ...);}
2584 @code{xfail} prints a message for an expected unsuccessful test
2588 @t{@b{xfail}(@i{msg}, ...);}
2592 @code{xpass} prints a message for an unexpected successful test
2596 @t{@b{xpass}(@i{msg}, ...);}
2600 @code{untested} prints a placeholder message for a test case that is
2601 not yet implemented or that could not be run for some reason.
2604 @t{@b{untested}(@i{msg}, ...);}
2608 @code{unresolved} prints a message for a test case that was run, but
2609 did not produce a clear result. These output states require a human
2610 to look over the results to determine what happened.
2613 @t{@b{unresolved}(@i{msg}, ...);}
2617 @code{totals} prints out the total counts of all of the test results
2618 as a convenience when running the unit test program directly. DejaGnu
2619 does not use this information and instead counts the results
2628 @node C++ unit testing API, , C unit testing API, Unit testing
2629 @section C++ unit testing API
2630 @cindex C++ unit testing API
2632 The C++ API is also provided in the @file{dejagnu.h} header file.
2633 This header provides a self-contained implementation. For
2634 convenience, the @code{totals()} method outputs summary totals to be
2635 used at the end of unit test program. DejaGnu does not depend on this
2636 summary and counts the test results independently.
2638 All of the methods that take a @code{msg} parameter use a STL string
2639 as the message to be displayed. There currently is no support for
2640 formatted output in the C++ API; build the desired string before
2641 passing it to these functions.
2643 Note that the C API is also available in C++ unit test programs; using
2644 both will cause confusion because each @code{TestState} object carries
2645 its own set of summary counters, while the C API has an independent
2646 global set of summary counters.
2648 The @code{TestState} class supports the following instance methods:
2652 @code{pass} prints a message for a successful test completion.
2655 @t{@b{TestState::pass}(@i{msg});}
2659 @code{fail} prints a message for an unsuccessful test completion.
2662 @t{@b{TestState::fail}(@i{msg});}
2666 @code{xfail} prints a message for an expected unsuccessful test completion.
2669 @t{@b{TestState::xfail}(@i{msg});}
2673 @code{xpass} prints a message for an unexpected successful test completion.
2676 @t{@b{TestState::xpass}(@i{msg});}
2680 @code{untested} prints a placeholder message for a test case that is
2681 not yet implemented or that could not be run for some reason.
2684 @t{@b{TestState::untested}(@i{msg});}
2688 @code{unresolved} prints a message for a test case that was run, but
2689 did not produce a clear result. These output states require a human
2690 to look over the results to determine what happened.
2693 @t{@b{TestState::unresolved}(@i{msg});}
2697 @code{totals} prints out the total counts of all of the test results
2698 as a convenience when running the unit test program directly. DejaGnu
2699 does not use this information and instead counts the results
2702 In the C++ API, this method is automatically called when a
2703 @code{TestState} instance is destroyed.
2706 @t{@b{TestState::totals}(@i{});}
2711 @node Built-in Procedures, GNU Free Documentation License, Unit testing, Top
2712 @appendix Built-in Procedures
2714 DejaGnu provides these Tcl procedures.
2717 * Core Internal Procedures::
2718 * Procedures For Remote Communication::
2719 * Procedures For Using Utilities to Connect: connprocs.
2720 * Procedures For Target Boards::
2721 * Target Database Procedures: target database library file.
2722 * Platform Dependent Procedures: platform dependent procedures.
2723 * Utility Procedures::
2724 * Libgloss, a free board support package (BSP): Libgloss.
2725 * Debugging Procedures::
2728 @node Core Internal Procedures, Procedures For Remote Communication, , Built-in Procedures
2729 @section Core Internal Procedures
2732 * open_logs Procedure: open_logs procedure
2733 * close_logs Procedure: close_logs procedure
2734 * isbuild Procedure: isbuild procedure
2735 * isremote Procedure: isremote procedure
2736 * is_remote Procedure: is_remote procedure
2737 * is3way Procedure: is3way procedure
2738 * ishost Procedure: ishost procedure
2739 * istarget Procedure: istarget procedure
2740 * isnative Procedure: isnative procedure
2741 * log_and_exit Procedure: log_and_exit procedure
2742 * log_summary Procedure: log_summary procedure
2743 * setup_xfail Procedure: setup_xfail procedure
2744 * pass Procedure: pass procedure
2745 * fail Procedure: fail procedure
2746 * xpass Procedure: xpass procedure
2747 * xfail Procedure: xfail procedure
2748 * set_warning_threshold Procedure: set_warning_threshold procedure
2749 * get_warning_threshold Procedure: get_warning_threshold procedure
2750 * warning Procedure: warning procedure
2751 * perror Procedure: perror procedure
2752 * note Procedure: note procedure
2753 * untested Procedure: untested procedure
2754 * unresolved Procedure: unresolved procedure
2755 * unsupported Procedure: unsupported procedure
2756 * transform Procedure: transform procedure
2757 * check_conditional_xfail Procedure: check_conditional_xfail procedure
2758 * clear_xfail Procedure: clear_xfail procedure
2759 * verbose Procedure: verbose procedure
2760 * load_lib Procedure: load_lib procedure
2761 * testsuite Procedure: testsuite procedure
2762 * testcase procedure: testcase procedure
2765 @node open_logs procedure, close_logs procedure, , Core Internal Procedures
2766 @subsubheading open_logs Procedure
2769 Open the output logs.
2775 @node close_logs procedure, isbuild procedure, open_logs procedure, Core Internal Procedures
2776 @subsubheading close_logs Procedure
2779 Close the output logs.
2785 @node isbuild procedure, isremote procedure, close_logs procedure, Core Internal Procedures
2786 @subsubheading isbuild Procedure
2789 Tests for a particular build host environment. If the currently
2790 configured host matches the @code{pattern} argument, the result is
2791 @emph{1}; otherwise the result is @emph{0}. @emph{pattern} must be a
2792 full three-part configure triplet; in particular, you may not use the
2793 shorter aliases supported by @code{configure} (but you can use Tcl
2794 globbing to specify a range of triplets). If called with no arguments
2795 or an empty pattern, this procedure returns the build system triplet.
2798 @t{@b{isbuild} @i{pattern}}
2801 @node isremote procedure, is_remote procedure, isbuild procedure, Core Internal Procedures
2802 @subsubheading isremote Procedure
2805 Is @i{board} remote? Return a non-zero value, if so.
2808 @t{@b{isremote} @i{ board }}
2811 This procedure is to be used instead of @code{is_remote}.
2813 @node is_remote procedure, is3way procedure, isremote procedure, Core Internal Procedures
2814 @subsubheading is_remote Procedure
2817 Is @i{board} remote? Return a non-zero value, if so.
2820 @t{@b{is_remote} @i{ board }}
2823 Note that this procedure is now deprecated. Use @code{isremote}
2826 @node is3way procedure, ishost procedure, is_remote procedure, Core Internal Procedures
2827 @subsubheading is3way Procedure
2830 Tests for a Canadian cross. This is when the tests will be run on a
2831 remotely hosted cross-compiler. If it is a Canadian cross, then the
2832 result is @emph{1}; otherwise @emph{0}.
2838 @node ishost procedure, istarget procedure, is3way procedure, Core Internal Procedures
2839 @subsubheading ishost Procedure
2842 Tests for a particular host environment. If the currently configured
2843 host matches the argument string, the result is @emph{1}; otherwise
2844 the result is @emph{0}. @emph{pattern} must be a full three-part
2845 configure triplet; in particular, you may not use the shorter aliases
2846 supported by @code{configure} (but you can use Tcl globbing to specify
2847 a range of triplets). If called with no arguments or an empty
2848 pattern, this procedure returns the host triplet.
2851 @t{@b{ishost} @i{pattern}}
2854 @node istarget procedure, isnative procedure, ishost procedure, Core Internal Procedures
2855 @subsubheading istarget Procedure
2858 Tests for a particular target environment. If the currently
2859 configured target matches the argument string, the result is @emph{1}
2860 ; otherwise the result is @emph{0}. @emph{pattern} must be a full
2861 three-part configure triplet; in particular, you may not use the
2862 shorter aliases supported by @code{configure} (but you can use Tcl
2863 globbing to specify a range of triplets). If called with no arguments
2864 or an empty pattern, this procedure returns the target triplet.
2867 @t{@b{istarget} @i{pattern} }
2870 @node isnative procedure, log_and_exit procedure, istarget procedure, Core Internal Procedures
2871 @subsubheading isnative Procedure
2874 This procedure returns @emph{1} if the current configuration has the
2875 same host and target (ie. it is a native configuration). Otherwise it
2882 @node log_and_exit procedure, log_summary procedure, isnative procedure, Core Internal Procedures
2883 @subsubheading log_and_exit Procedure
2884 @findex log_and_exit
2887 @t{@b{log_and_exit}}
2890 This procedure writes out the end of the test log and terminates
2894 @node log_summary procedure, setup_xfail procedure, log_and_exit procedure, Core Internal Procedures
2895 @subsubheading log_summary Procedure
2899 @t{@b{log_summary} @i{args}}
2906 @node setup_xfail procedure, pass procedure, log_summary procedure, Core Internal Procedures
2907 @subsubheading setup_xfail Procedure
2910 Declares that the test is expected to fail on a particular set of
2911 configurations. The config argument must be a list of full three-part
2912 configure target name; in particular, you may not use the shorter
2913 nicknames supported by configure (but you can use the common shell
2914 wildcard characters to specify a range of triplets). The @emph{bugid}
2915 argument is optional, and used only in the logging file output; use it
2916 as a link to a bug-tracking system such as GNATS.
2918 Once you use @code{setup_xfail}, the @code{fail} and @code{pass}
2919 procedures produce the messages @emph{XFAIL} and @emph{XPASS}
2920 respectively, allowing you to distinguish expected failures (and
2921 unexpected success!) from other test outcomes.
2927 Warning you must clear the expected failure after using setup_xfail in
2928 a test case. Any call to @code{pass }or @code{fail} clears the
2929 expected failure implicitly; if the test has some other outcome,
2930 e.g. an error, you can call @code{clear_xfail} to clear the expected
2931 failure explicitly. Otherwise, the expected-failure declaration
2932 applies to whatever test runs next, leading to surprising results.
2936 @t{@b{setup_xfail} @i{config} @i{bugid}}
2941 The config triplet to trigger whether this is an unexpected or expect
2945 The optional bugid, used to tie this test case to a bug tracking
2949 @node pass procedure, fail procedure, setup_xfail procedure, Core Internal Procedures
2950 @subsubheading pass Procedure
2953 Declares a test to have passed. @code{pass} writes in the log files a
2954 message beginning with @emph{PASS} (or @emph{XPASS}, if failure was
2955 expected), appending the @code{message} argument.
2958 @t{@b{pass} @i{message} }
2961 @node fail procedure, xpass procedure, pass procedure, Core Internal Procedures
2962 @subsubheading fail Procedure
2965 Declares a test to have failed. @code{fail} writes in the log files a
2966 message beginning with @emph{FAIL} (or @emph{XFAIL}, if failure was
2967 expected), appending the @code{message} argument.
2970 @t{@b{fail} @i{message} }
2973 @node xpass procedure, xfail procedure, fail procedure, Core Internal Procedures
2974 @subsubheading xpass Procedure
2977 Declares a test to have passed when it was expected to fail.
2978 @code{xpass} writes in the log files a message beginning with
2979 @emph{XPASS} (or @emph{XFAIL} if failure was expected) and the
2980 @code{message} argument.
2983 @t{@b{xpass} @i{message} }
2986 @node xfail procedure, set_warning_threshold procedure, xpass procedure, Core Internal Procedures
2987 @subsubheading xfail Procedure
2990 Declares a test to have expectedly failed. @code{xfail} writes in the
2991 log files a message beginning with @emph{XFAIL} (or @emph{PASS}, if
2992 success was expected), appending the @code{message} argument.
2995 @t{@b{xpass} @i{message} }
2998 @node set_warning_threshold procedure, get_warning_threshold procedure, xfail procedure, Core Internal Procedures
2999 @subsubheading set_warning_threshold Procedure
3000 @findex set_warning_threshold
3002 Sets the value of @code{warning_threshold}. A value of @emph{0}
3003 disables it: calls to @code{warning} will not turn a @emph{PASS} or
3004 @emph{FAIL} into an @emph{UNRESOLVED}.
3007 @t{@b{set_warning_threshold} @i{threshold}}
3012 @item @code{threshold}
3013 This is the value of the new warning threshold.
3016 @node get_warning_threshold procedure, warning procedure, set_warning_threshold procedure, Core Internal Procedures
3017 @subsubheading get_warning_threshold Procedure
3018 @findex get_warning_threshold
3020 Returns the current value of @code{@{warning_threshold}. The default
3021 value is 3. This value controls how many @code{warning} procedures
3022 can be called before becoming @emph{UNRESOLVED}.
3025 @t{@b{get_warning_threshold}}
3028 @node warning procedure, perror procedure, get_warning_threshold procedure, Core Internal Procedures
3029 @subsubheading warning Procedure
3032 Declares detection of a minor error in the test case itself.
3033 @code{warning} writes in the log files a message beginning with
3034 @emph{WARNING}, appending the argument @code{string}. Use
3035 @code{warning} rather than @code{perror} for cases (such as
3036 communication failure to be followed by a retry) where the test case
3037 can recover from the error. If the optional @code{number} is
3038 supplied, then this is used to set the internal count of warnings to
3041 As a side effect, @code{warning_threshold} or more calls to warning in
3042 a single test case also changes the effect of the next @code{pass} or
3043 @code{fail} command: the test outcome becomes @emph{UNRESOLVED} since
3044 an automatic @emph{PASS} or @emph{FAIL} may not be trustworthy after
3045 many warnings. If the optional numeric value is @emph{0}, then there
3046 are no further side effects to calling this function, and the
3047 following test outcome doesn't become @emph{UNRESOLVED}. This can be
3048 used for errors with no known side effects.
3051 @t{@b{warning} @i{messsage} @i{number} }
3056 @item @code{message}
3057 The warning message.
3060 The optional number to set the error counter. This is only used to
3061 fake out the counter when using the @code{xfail} procedure to control
3062 when it flips the output over to @emph{UNRESOLVED} state.
3065 @node perror procedure, note procedure, warning procedure, Core Internal Procedures
3066 @subsubheading perror Procedure
3069 Declares a severe error in the testing framework itself.
3070 @code{perror} writes in the log files a message beginning with
3071 @emph{ERROR}, appending the argument @code{string}.
3073 As a side effect, perror also changes the effect of the next
3074 @code{pass} or @code{fail} command: the test outcome becomes
3075 @emph{UNRESOLVED}, since an automatic @emph{PASS} or @emph{FAIL}
3076 cannot be trusted after a severe error in the test framework. If the
3077 optional numeric value is @emph{0}, then there are no further side
3078 effects to calling this function, and the following test outcome
3079 doesn't become @emph{UNRESOLVED}. This can be used for errors with no
3083 @t{@b{perror} @i{message} @i{number} }
3087 @item @code{message}
3088 The message to be logged.
3091 The optional number to set the error counter. This is only used to
3092 fake out the counter when using the @code{xfail} procedure to control
3093 when it flips the output over to @emph{UNRESOLVED} state.
3096 @node note procedure, untested procedure, perror procedure, Core Internal Procedures
3097 @subsubheading note Procedure
3100 Appends an informational message to the log file. @code{note} writes
3101 in the log files a message beginning with @emph{NOTE}, appending the
3102 @code{message} argument. Use @code{note} sparingly. The
3103 @code{verbose} should be used for most such messages, but in cases
3104 where a message is needed in the log file regardless of the verbosity
3105 level use @code{note}.
3108 @t{@b{note} @i{messsage} }
3112 @node untested procedure, unresolved procedure, note procedure, Core Internal Procedures
3113 @subsubheading untested Procedure
3116 Declares a test was not run. @code{untested} writes in the log file a
3117 message beginning with @emph{UNTESTED}, appending the @code{message}
3118 argument. For example, you might use this in a dummy test whose only
3119 role is to record that a test does not yet exist for some feature.
3122 @t{@b{untested} @i{message} }
3126 @node unresolved procedure, unsupported procedure, untested procedure, Core Internal Procedures
3127 @subsubheading unresolved Procedure
3130 Declares a test to have an unresolved outcome. @code{unresolved}
3131 writes in the log file a message beginning with @emph{UNRESOLVED},
3132 appending the @code{message} argument. This usually means the test
3133 did not execute as expected, and a human being must go over results to
3134 determine if it passed or failed (and to improve the test case).
3137 @t{@b{unresolved} @i{message} }
3141 @node unsupported procedure, transform procedure, unresolved procedure, Core Internal Procedures
3142 @subsubheading unsupported Procedure
3145 Declares that a test case depends on some facility that does not exist
3146 in the testing environment. @code{unsupported} writes in the log file
3147 a message beginning with @emph{UNSUPPORTED}, appending the
3148 @code{message} argument.
3151 @t{@b{unsupported} @i{message} }
3155 @node transform procedure, check_conditional_xfail procedure, unsupported procedure, Core Internal Procedures
3156 @subsubheading transform Procedure
3159 Generates a string for the name of a tool as it was configured and
3160 installed, given its native name (as the argument @code{toolname}).
3161 This makes the assumption that all tools are installed using the same
3162 naming conventions: For example, for a cross compiler supporting the
3163 @emph{m68k-vxworks} configuration, the result of transform @code{gcc}
3164 is @code{m68k-vxworks-gcc}.
3167 @t{@b{transform} @i{toolname}}
3172 @item @code{toolname}
3173 The name of the cross-development program to transform.
3176 @node check_conditional_xfail procedure, clear_xfail procedure, transform procedure, Core Internal Procedures
3177 @subsubheading check_conditional_xfail Procedure
3178 @findex check_conditional_xfail
3180 This procedure adds a conditional xfail, based on compiler options
3181 used to create a test case executable. If an include options is found
3182 in the compiler flags, and it's the right architecture, it'll trigger
3183 an @emph{XFAIL}. Otherwise it'll produce an ordinary @emph{FAIL}.
3184 You can also specify flags to exclude. This makes a result be a
3185 @emph{FAIL}, even if the included options are found. To set the
3186 conditional, set the variable @code{compiler_conditional_xfail_data}
3190 "[message string] [targets list] [includes list] [excludes list]"
3193 (descriptions below). This is the checked at pass/fail decision time,
3194 so there is no need to call the procedure yourself, unless you wish to
3195 know if it gets triggered. After a pass/fail, the variable is reset,
3196 so it doesn't effect other tests. It returns @emph{1} if the
3197 conditional is true, or @emph{0} if the conditional is false.
3200 @t{@b{check_conditional_xfail} @i{message} @i{targets} @i{includes}
3206 @item @code{message}
3207 This is the message to print with the normal test result.
3209 @item @code{targets}
3210 This is a string with the list targets to activate this conditional
3213 @item @code{includes}
3214 This is a list of sets of options to search for in the compiler
3215 options to activate this conditional. If the list of sets of options
3216 is empty or if any set of the options matches, then this conditional
3217 is true. (It may be useful to specify an empty list of include sets
3218 if the conditional is always true unless one of the exclude sets
3221 @item @code{excludes}
3222 This is a list of sets of options to search for in the compiler
3223 options to activate this conditional. If any set of the options
3224 matches, (regardless of whether any of the include sets match) then
3225 this conditional is de-activated.
3228 @strong{Specifying the conditional xfail data}
3231 set compiler_conditional_xfail_data @{ \
3232 "I sure wish I knew why this was hosed" \
3233 "sparc*-sun*-* *-pc-*-*" \
3234 @{"-Wall -v" "-O3"@} \
3239 What this does is it matches only for these two targets if @code{-Wall
3240 -v} or @code{-O3} is set, but neither @code{-O1} or @code{-Map} is
3241 set. For a set to match, the options specified are searched for
3242 independently of each other, so a @code{-Wall -v} matches either
3243 @code{-Wall -v} or @code{-v -Wall}. A space separates the options in
3244 the string. Glob patterns are also permitted.
3246 @node clear_xfail procedure, verbose procedure, check_conditional_xfail procedure, Core Internal Procedures
3247 @subsubheading clear_xfail Procedure
3250 Cancel an expected failure (previously declared with
3251 @code{setup_xfail}) for a particular set of configurations. The
3252 @code{config} argument is a list of configuration target names. It is
3253 only necessary to call @code{clear_xfail} if a test case ends without
3254 calling either @code{pass} or @code{fail}, after calling
3258 @t{@b{clear_xfail} @i{config}}
3264 The system triplets to clear.
3267 @node verbose procedure, load_lib procedure, clear_xfail procedure, Core Internal Procedures
3268 @subsubheading verbose Procedure
3271 Test cases can use this procedure to issue helpful messages depending
3272 on the number of @code{-v}/@code{--verbose} options passed on the
3273 command line to @code{runtest}. It prints @i{message} if the value of
3274 the number of @code{-v} options passed is greater than or equal to the
3275 @i{loglevel} argument. The default log level is 1.
3289 Always write @i{message} to the log file, even if it won't be printed
3293 Log the @i{message} into an XML file.
3296 Print @i{message} without a trailing newline.
3299 Use this option if @i{message} begins with @samp{-}.
3301 @item @code{message}
3304 @item @code{loglevel}
3305 The specified log level. The default level is 1.
3308 @node load_lib procedure, testsuite procedure, verbose procedure, Core Internal Procedures
3309 @subsubheading load_lib Procedure
3312 @code{load_lib} loads a DejaGnu library file by searching the default
3313 fixed paths built into DejaGnu. If DejaGnu has been installed, it
3314 looks in a path starting with the installed library directory. If you
3315 are running DejaGnu directly from a source directory, without first
3316 running @code{make install}, this path defaults to the current
3317 directory. In either case, it then looks in the current directory for
3318 a directory called @file{lib}. If there are duplicate definitions,
3319 the last one loaded takes precedence over the earlier ones.
3322 @t{@b{load_lib} @i{filespec}}
3327 @item @code{filespec}
3328 The name of the DejaGnu library file to load.
3331 The global variable @code{libdirs}, handled as a list, is appended to
3332 the default fixed paths built into DejaGnu.
3334 @strong{Additional search directories for load_lib}
3337 # append a non-standard search path
3339 lappend libdirs $srcdir/../../gcc/testsuite/lib
3340 # now loading $srcdir/../../gcc/testsuite/lib/foo.exp works
3344 @node testsuite procedure, testcase procedure, load_lib procedure, Core Internal Procedures
3345 @subsubheading testsuite Procedure
3348 The @code{testsuite} procedure is a multiplex call for retrieving or
3349 providing information about the current testsuite.
3351 @subsubheading testsuite file
3353 The @code{testsuite file} command returns an absolute file name
3354 specified relative to either the testsuite source or object trees.
3357 @t{ @b{testsuite file}
3358 ?@b{-source}|@b{-object}?
3361 ?@b{--}? @i{name}... }
3364 Any number of @i{name}s are accepted and combined as if by @code{file
3365 join} with a directory relevant to the testsuite prepended.
3369 @item @code{-object}
3370 Return a file name in the object tree.
3372 @item @code{-source}
3373 Return a file name in the source tree.
3376 Prepend the @code{testsuite} directory itself.
3379 Prepend the directory containing the current test script.
3381 @item @code{-hypothetical}
3382 Allow the returned value to imply directories that do not exist.
3385 Use this option if the first @i{name} could begin with @samp{-}.
3389 One of @code{-top} or @code{-test} must be given; an error is raised
3392 Unless the @code{-hypothetical} option is given, any directories
3393 implied by the returned value will exist upon return. Implied
3394 directories are created in the object tree if needed. An error is
3395 raised if an implied directory does not exist in the source tree.
3397 @subsubheading testsuite can call
3399 The @code{testsuite can call} command is a feature test and returns a
3400 boolean value indicating if a subcommand under a multiplex point is
3401 available. This API call is needed because only the multiplex points
3402 themselves are visible to the Tcl info command.
3405 @t{ @b{testsuite can call} @i{feature}... }
3408 Any number of words are joined together into a single name, beginning
3409 with a multiplex entry point and forming the full name of an API call
3410 as documented in this manual.
3412 @node testcase procedure, , testsuite procedure, Core Internal Procedures
3413 @subsubheading testcase Procedure
3415 The @code{testcase} procedure is a multiplex call for retrieving or
3416 providing information about the state of the testing process.
3418 @subsubheading testcase group
3420 The @code{testcase group} command provides support for grouping tests
3421 into hierarchical groups within a test script.
3423 Group names are internally tracked as Tcl lists, but are reported as
3424 strings delimited using forward slash (@samp{/}) characters.
3425 Individual name elements may not contain whitespace, but may contain
3426 forward slash. A group entered by traversing intermediate levels must
3427 be left by traversing those same levels. Groups must properly nest.
3429 There are three uses:
3432 @t{ @b{testcase group}}
3435 Return the current group as a string delimited with forward slash
3436 (@samp{/}) characters.
3439 @t{ @b{testcase group begin} @i{name}}
3442 @t{ @b{testcase group end} @i{name}}
3445 These forms allow a group to be explicitly entered and left. The
3446 @i{name} parameter must be identical across a pair of these calls, and
3447 both the @code{begin} and @code{end} calls must be in the same file.
3450 @t{ @b{testcase group eval} @i{name} @{@i{code}@}}
3453 This form is available to wrap the @code{begin} and @code{end} calls
3454 around the execution of the provided @i{code}. This form is preferred
3455 for convenience in top-level scripts, but the @code{begin} and
3456 @code{end} calls are preferred in helper procedures for performance.
3458 @node Procedures For Remote Communication, connprocs, Core Internal Procedures, Built-in Procedures
3459 @section Procedures For Remote Communication
3461 The file @file{lib/remote.exp} defines procedures for establishing and
3462 managing communications. Each of these procedures tries to establish
3463 the connection up to three times before returning. Warnings (if
3464 retries will continue) or errors (if the attempt is abandoned) report
3465 on communication failures. The result for any of these procedures is
3466 either @emph{-1}, when the connection cannot be established, or the
3467 spawn ID returned by the Expect command @code{spawn}.
3469 It use the value of the @code{connect} field in the @code{target_info}
3470 array as the type of connection to make. Current supported connection
3471 types are ssh, tip, kermit, telnet, rsh, and rlogin. If the
3472 @code{--reboot} option was used on the @command{runtest} command line,
3473 then the target is rebooted before the connection is made.
3476 * call_remote Procedure: call_remote procedure
3477 * check_for_board_status Procedure: check_for_board_status procedure
3478 * file_on_build Procedure: file_on_build procedure
3479 * file_on_host Procedure: file_on_host procedure
3480 * local_exec Procedure: local_exec procedure
3481 * remote_binary Procedure: remote_binary procedure
3482 * remote_close Procedure: remote_close procedure
3483 * remote_download Procedure: remote_download procedure
3484 * remote_exec Procedure: remote_exec procedure
3485 * remote_expect Procedure: remote_expect procedure
3486 * remote_file Procedure: remote_file procedure
3487 * remote_ld Procedure: remote_ld procedure
3488 * remote_load Procedure: remote_load procedure
3489 * remote_open Procedure: remote_open procedure
3490 * remote_pop_conn Procedure: remote_pop_conn procedure
3491 * remote_push_conn Procedure: remote_push_conn procedure
3492 * remote_raw_binary Procedure: remote_raw_binary procedure
3493 * remote_raw_close Procedure: remote_raw_close procedure
3494 * remote_raw_file Procedure: remote_raw_file procedure
3495 * remote_raw_ld Procedure: remote_raw_ld procedure
3496 * remote_raw_load Procedure: remote_raw_load procedure
3497 * remote_raw_open Procedure: remote_raw_open procedure
3498 * remote_raw_send Procedure: remote_raw_send procedure
3499 * remote_raw_spawn Procedure: remote_raw_spawn procedure
3500 * remote_raw_transmit Procedure: remote_raw_transmit procedure
3501 * remote_raw_wait Procedure: remote_raw_wait procedure
3502 * remote_reboot Procedure: remote_reboot procedure
3503 * remote_send Procedure: remote_send procedure
3504 * remote_spawn Procedure: remote_spawn procedure
3505 * remote_swap_conn Procedure: remote_swap_conn procedure
3506 * remote_transmit Procedure: remote_transmit procedure
3507 * remote_upload Procedure: remote_upload procedure
3508 * remote_wait Procedure: remote_wait procedure
3509 * standard_close Procedure: standard_close procedure
3510 * standard_download Procedure: standard_download procedure
3511 * standard_exec Procedure: standard_exec procedure
3512 * standard_file Procedure: standard_file procedure
3513 * standard_load Procedure: standard_load procedure
3514 * standard_reboot Procedure: standard_reboot procedure
3515 * standard_send Procedure: standard_send procedure
3516 * standard_spawn Procedure: standard_spawn procedure
3517 * standard_transmit Procedure: standard_transmit procedure
3518 * standard_upload Procedure: standard_upload procedure
3519 * standard_wait Procedure: standard_wait procedure
3520 * unix_clean_filename Procedure: unix_clean_filename procedure
3523 @node call_remote procedure, check_for_board_status procedure, , Procedures For Remote Communication
3524 @subsubheading call_remote Procedure
3527 A standard procedure to call the appropriate @i{proc}. This proceure
3528 first looks for a board-specific version, then a protocol-specific
3529 version, and finally @code{call_remote} will call
3530 @code{standard_$proc}.
3533 @t{@b{call_remote} @i{type} @i{proc} @i{dest} @i{args}}
3542 @node check_for_board_status procedure, file_on_build procedure, call_remote procedure, Procedures For Remote Communication
3543 @subsubheading check_for_board_status Procedure
3544 @findex check_for_board_status
3546 This procedure inspected the named variable within the calling
3547 procedure for the expected output from the status wrapper. A
3548 non-negative value is returned if it exists. Otherwise, it returns
3549 -1. The output from the status wrapper is removed from the variable.
3552 @t{@b{check_for_board_status} @i{variable}}
3556 @item @code{variable}
3557 The name of the variable to check in the calling procedure. Be sure
3558 to pass the name of the variable (@code{var}) and not the value of the
3559 variable (@code{$var}).
3562 @node file_on_build procedure, file_on_host procedure, check_for_board_status procedure, Procedures For Remote Communication
3563 @subsubheading file_on_build Procedure
3564 @findex file_on_build
3567 @t{@b{file_on_build} @i{op} @i{file} @i{args}}
3576 @node file_on_host procedure, local_exec procedure, file_on_build procedure, Procedures For Remote Communication
3577 @subsubheading file_on_host Procedure
3578 @findex file_on_host
3581 @t{@b{file_on_host} @i{op} @i{file} @i{args}}
3590 @node local_exec procedure, remote_binary procedure, file_on_host procedure, Procedures For Remote Communication
3591 @subsubheading local_exec Procedure
3594 Run the specified command on the local machine, redirecting input from
3595 file @code{inp} (if non-empty), redirecting output to file @code{outp}
3596 (if non-empty), and waiting @code{timeout} seconds for the command to
3597 complete before killing it. A two-element list is returned: the exit
3598 status of the command and any output produced by the command. If
3599 output is redirected, this may or may not be empty. If output is
3600 redirected, both stdout and stderr will appear in the specified file.
3603 @t{@b{local_exec} @i{commandline} @i{inp} @i{outp} @i{timeout}}
3608 Redirect input into the input filename if not set to @code{""}.
3611 Redirect output into the output filename if not set to @code{""}.
3613 @item @code{timeout}
3618 @node remote_binary procedure, remote_close procedure, local_exec procedure, Procedures For Remote Communication
3619 @subsubheading remote_binary Procedure
3620 @findex remote_binary
3622 This procedure sets the connection into @i{binary} mode. That is,
3623 there is no processing of input characters.
3626 @t{@b{remote_binary} @i{host}}
3631 The host on which to set a binary connection.
3634 @node remote_close procedure, remote_download procedure, remote_binary procedure, Procedures For Remote Communication
3635 @subsubheading remote_close Procedure
3636 @findex remote_close
3639 @t{@b{remote_close} @i{shellid}}
3644 @item @code{shellid}
3645 This is the value returned by a call to @code{remote_open}. This
3646 closes the connection to the target so resources can be used by
3647 others. This parameter can be left off if the @code{fileid} field in
3648 the @code{target_info} array is set.
3651 @node remote_download procedure, remote_exec procedure, remote_close procedure, Procedures For Remote Communication
3652 @subsubheading remote_download Procedure
3653 @findex remote_download
3655 Download a file to a destination machine. This procedure returns
3656 either an empty string (indicating failure) or the name of the file on
3657 the destination macine.
3660 @t{@b{remote_download} @i{dest} @i{file} @i{args}}
3665 Destination machine name.
3671 If the optional destination filename is specified, that filename will
3672 be used on the destination machine.
3675 @node remote_exec procedure, remote_expect procedure, remote_download procedure, Procedures For Remote Communication
3676 @subsubheading remote_exec Procedure
3679 Execute the supplied program on a remote host. A two-element list is
3680 returned. The first element is the exit status of the program or -1
3681 if execution failed. The second element is any output produced by the
3682 program. This may be an empty string if output from the program was
3686 @t{ @b{remote_exec} @i{hostname} @i{program}
3687 ?@i{options}? ?@i{input}? ?@i{output}? ?@i{timeout}?}
3691 @item @code{hostname}
3692 Name of the host to execute the command on.
3694 @item @code{program}
3697 @item @code{options}
3698 Arguments to pass to the program.
3701 Input filename to feed to standard input of the command.
3704 Output filename where the output from the command should be written.
3706 @item @code{timeout}
3707 Timeout value in seconds.
3711 All of the optional positional arguments accept an empty string as a
3714 @node remote_expect procedure, remote_file procedure, remote_exec procedure, Procedures For Remote Communication
3715 @subsubheading remote_expect Procedure
3716 @findex remote_expect
3719 @t{@b{remote_expect} @i{board} @i{timeout} @i{args}}
3724 @item @code{timeout}
3728 @node remote_file procedure, remote_ld procedure, remote_expect procedure, Procedures For Remote Communication
3729 @subsubheading remote_file Procedure
3733 @t{@b{remote_file} @i{dest} @i{args}}
3743 @node remote_ld procedure, remote_load procedure, remote_file procedure, Procedures For Remote Communication
3744 @subsubheading remote_ld Procedure
3748 @t{@b{remote_ld} @i{dest} @i{prog}}
3756 @node remote_load procedure, remote_open procedure, remote_ld procedure, Procedures For Remote Communication
3757 @subsubheading remote_load Procedure
3761 @t{@b{remote_load} @i{dest} @i{prog} @i{args}}
3770 @node remote_open procedure, remote_pop_conn procedure, remote_load procedure, Procedures For Remote Communication
3771 @subsubheading remote_open Procedure
3774 Open connection to a remote host or target. This requires the
3775 @code{target_info} array be filled in with the proper information to
3776 work. It returns the spawn id of the process that is the connection.
3779 @t{@b{remote_open} @i{type}}
3784 This is passed @code{host} or @code{target}. Host or target refers to
3785 whether it is a connection to a remote target, or a remote host. This
3786 opens the connection to the desired target or host using the default
3787 values in the configuration system. It returns that @code{spawn_id}
3788 of the process that manages the connection. This value can be used in
3789 Expect or @code{exp_send} statements, or passed to other procedures
3790 that need the connection process's id. This also sets the
3791 @code{fileid} field in the @code{target_info} array.
3794 @node remote_pop_conn procedure, remote_push_conn procedure, remote_open procedure, Procedures For Remote Communication
3795 @subsubheading remote_pop_conn Procedure
3796 @findex remote_pop_conn
3798 Pop a previously-pushed connection from the stack. You should have
3799 closed the current connection before calling this procedure. Returns
3800 @code{pass} or @code{fail}.
3803 @t{@b{remote_pop_conn} @i{host}}
3810 @node remote_push_conn procedure, remote_raw_binary procedure, remote_pop_conn procedure, Procedures For Remote Communication
3811 @subsubheading remote_push_conn Procedure
3812 @findex remote_push_conn
3814 Pushes the current connection onto a stack. Returns @code{pass} or
3818 @t{@b{remote_push_conn} @i{host}}
3825 @node remote_raw_binary procedure, remote_raw_close procedure, remote_push_conn procedure, Procedures For Remote Communication
3826 @subsubheading remote_raw_binary Procedure
3827 @findex remote_raw_binary
3830 @t{@b{remote_raw_binary} @i{host}}
3837 @node remote_raw_close procedure, remote_raw_file procedure, remote_raw_binary procedure, Procedures For Remote Communication
3838 @subsubheading remote_raw_close Procedure
3839 @findex remote_raw_close
3842 @t{@b{remote_raw_close} @i{host}}
3849 @node remote_raw_file procedure, remote_raw_ld procedure, remote_raw_close procedure, Procedures For Remote Communication
3850 @subsubheading remote_raw_file Procedure
3851 @findex remote_raw_file
3854 @t{@b{remote_raw_file} @i{dest} @i{args}}
3863 @node remote_raw_ld procedure, remote_raw_load procedure, remote_raw_file procedure, Procedures For Remote Communication
3864 @subsubheading remote_raw_ld Procedure
3865 @findex remote_raw_ld
3868 @t{@b{remote_raw_ld} @i{dest} @i{prog}}
3876 @node remote_raw_load procedure, remote_raw_open procedure, remote_raw_ld procedure, Procedures For Remote Communication
3877 @subsubheading remote_raw_load Procedure
3878 @findex remote_raw_load
3881 @t{@b{remote_raw_load} @i{dest} @i{prog} @i{args}}
3890 @node remote_raw_open procedure, remote_raw_send procedure, remote_raw_load procedure, Procedures For Remote Communication
3891 @subsubheading remote_raw_open Procedure
3892 @findex remote_raw_open
3895 @t{@b{remote_raw_open} @i{args}}
3902 @node remote_raw_send procedure, remote_raw_spawn procedure, remote_raw_open procedure, Procedures For Remote Communication
3903 @subsubheading remote_raw_send Procedure
3904 @findex remote_raw_send
3908 @t{@b{remote_raw_send} @i{dest} @i{string}}
3916 @node remote_raw_spawn procedure, remote_raw_transmit procedure, remote_raw_send procedure, Procedures For Remote Communication
3917 @subsubheading remote_raw_spawn Procedure
3918 @findex remote_raw_spawn
3921 @t{@b{remote_raw_spawn} @i{dest} @i{commandline}}
3926 @item @code{commandline}
3929 @node remote_raw_transmit procedure, remote_raw_wait procedure, remote_raw_spawn procedure, Procedures For Remote Communication
3930 @subsubheading remote_raw_transmit Procedure
3931 @findex remote_raw_transmit
3934 @t{@b{remote_raw_transmit} @i{dest} @i{file}}
3942 @node remote_raw_wait procedure, remote_reboot procedure, remote_raw_transmit procedure, Procedures For Remote Communication
3943 @subsubheading remote_raw_wait Procedure
3944 @findex remote_raw_wait
3947 @t{@b{remote_raw_wait} @i{dest} @i{timeout}}
3952 @item @code{timeout}
3955 @node remote_reboot procedure, remote_send procedure, remote_raw_wait procedure, Procedures For Remote Communication
3956 @subsubheading remote_reboot Procedure
3957 @findex remote_reboot
3959 Reboot the host. The return value of this procedure depends on the
3960 actual implementation of reboot that will be used, in practice it is
3961 expected that @code{remote_reboot} returns @b{1} on success and @b{0}
3965 @t{@b{remote_reboot} @i{host}}
3972 @node remote_send procedure, remote_spawn procedure, remote_reboot procedure, Procedures For Remote Communication
3973 @subsubheading remote_send Procedure
3977 @t{@b{remote_send} @i{dest} @i{string}}
3985 @node remote_spawn procedure, remote_swap_conn procedure, remote_send procedure, Procedures For Remote Communication
3986 @subsubheading remote_spawn Procedure
3987 @findex remote_spawn
3989 Start a command on the destination. By default it is not possible to
3990 redirect I/O. If the command is successfully started, a positive
3991 spawn ID is returned. If the spawn fails, a negative value will be
3992 returned. Once the command has started, you can interact with it
3993 using @code{remote_expect} and @code{remote_wait} procedures.
3996 @t{@b{remote_spawn} @i{dest} @i{commandline} @i{args}}
4003 @item @code{commandline}
4004 The command to execute.
4007 If the optional keyword @code{readonly} is specified, input to the
4008 command may be redirected.
4011 @node remote_swap_conn procedure, remote_transmit procedure, remote_spawn procedure, Procedures For Remote Communication
4012 @subsubheading remote_swap_conn Procedure
4013 @findex remote_swap_conn
4015 Swap the current connection with the topmost one on the stack.
4016 Returns @code{pass} or @code{fail}.
4019 @t{@b{remote_swap_conn} @i{host}}
4026 @node remote_transmit procedure, remote_upload procedure, remote_swap_conn procedure, Procedures For Remote Communication
4027 @subsubheading remote_transmit Procedure
4028 @findex remote_transmit
4031 @t{@b{remote_transmit} @i{dest} @i{file}}
4039 @node remote_upload procedure, remote_wait procedure, remote_transmit procedure, Procedures For Remote Communication
4040 @subsubheading remote_upload Procedure
4041 @findex remote_upload
4044 @t{@b{remote_upload} @i{dest} @i{srcfile} @i{arg}}
4049 @item @code{srcfile}
4053 @node remote_wait procedure, standard_close procedure, remote_upload procedure, Procedures For Remote Communication
4054 @subsubheading remote_wait Procedure
4057 Wait for the last spawned command on the destination to complete. A
4058 list of two values is returned: the exit status (-1 if the program
4059 timed out) and any output produced by the command.
4062 @t{@b{remote_wait} @i{dest} @i{timeout}}
4067 The destination board.
4069 @item @code{timeout}
4070 The timeout in seconds.
4073 @node standard_close procedure, standard_download procedure, remote_wait procedure, Procedures For Remote Communication
4074 @subsubheading standard_close Procedure
4075 @findex standard_close
4077 This procedure closes a connection.
4080 @t{@b{standard_close} @i{host}}
4085 The host to close the connection to.
4088 @node standard_download procedure, standard_exec procedure, standard_close procedure, Procedures For Remote Communication
4089 @subsubheading standard_download Procedure
4090 @findex standard_download
4092 Downloads a file to a destination. It returns either the empty string
4093 (indicating failure) or the name of the file on the destination.
4096 @t{@b{standard_download} @i{dest} @i{file} @i{destfile}}
4104 The name of the file to download.
4106 @item @code{destfile}
4107 If the optional @i{destile} is specified, that filename will be used
4108 on the destination board.
4111 @node standard_exec procedure, standard_file procedure, standard_download procedure, Procedures For Remote Communication
4112 @subsubheading standard_exec Procedure
4113 @findex standard_exec
4116 @t{@b{standard_exec} @i{hostname} @i{args}}
4120 @item @code{hostname}
4124 @node standard_file procedure, standard_load procedure, standard_exec procedure, Procedures For Remote Communication
4125 @subsubheading standard_file Procedure
4126 @findex standard_file
4129 @t{@b{standard_file} @i{dest} @i{op} @i{args}}
4136 @node standard_load procedure, standard_reboot procedure, standard_file procedure, Procedures For Remote Communication
4137 @subsubheading standard_load Procedure
4138 @findex standard_load
4141 @t{@b{standard_load} @i{dest} @i{prog} @i{args}}
4150 @node standard_reboot procedure, standard_send procedure, standard_load procedure, Procedures For Remote Communication
4151 @subsubheading standard_reboot Procedure
4152 @findex standard_reboot
4154 It looks like that this procedure is never called, instead
4155 @code{$@{board@}_reboot} defined in @file{base-config.exp} will be
4156 used because it has higher priority and @file{base-config.exp} is
4157 always imported by @code{runtest}.
4160 @t{@b{standard_reboot} @i{host}}
4167 @node standard_send procedure, standard_spawn procedure, standard_reboot procedure, Procedures For Remote Communication
4168 @subsubheading standard_send Procedure
4169 @findex standard_send
4172 @t{@b{standard_send} @i{dest} @i{string}}
4180 @node standard_spawn procedure, standard_transmit procedure, standard_send procedure, Procedures For Remote Communication
4181 @subsubheading standard_spawn Procedure
4182 @findex standard_spawn
4185 @t{@b{standard_spawn} @i{dest} @i{commandline}}
4190 @item @code{commandline}
4193 @node standard_transmit procedure, standard_upload procedure, standard_spawn procedure, Procedures For Remote Communication
4194 @subsubheading standard_transmit Procedure
4195 @findex standard_transmit
4197 The default transmit procedure if none other exists. This feeds the
4198 file directly into the connection.
4201 @t{@b{standard_transmit} @i{dest} @i{file}}
4211 @node standard_upload procedure, standard_wait procedure, standard_transmit procedure, Procedures For Remote Communication
4212 @subsubheading standard_upload Procedure
4213 @findex standard_upload
4216 @t{@b{standard_upload} @i{dest srcfile destfile}}
4221 @item @code{srcfile}
4222 @item @code{destfile}
4225 @node standard_wait procedure, unix_clean_filename procedure, standard_upload procedure, Procedures For Remote Communication
4226 @subsubheading standard_wait Procedure
4227 @findex standard_wait
4230 @t{@b{standard_wait} @i{dest} @i{timeout}}
4235 @item @code{timeout}
4238 @node unix_clean_filename procedure, , standard_wait procedure, Procedures For Remote Communication
4239 @subsubheading unix_clean_filename Procedure
4240 @findex unix_clean_filename
4242 This procedure returns an absolute version of the filename argument
4243 with @samp{.} and @samp{..} removed.
4246 @t{@b{unix_clean_filename} @i{dest} @i{file}}
4255 @node connprocs, Procedures For Target Boards, Procedures For Remote Communication, Built-in Procedures
4256 @section Procedures For Using Utilities to Connect
4259 * kermit_open Procedure: kermit_open procedure
4260 * kermit_command Procedure: kermit_command procedure
4261 * kermit_send Procedure: kermit_send procedure
4262 * kermit_transmit Procedure: kermit_transmit procedure
4263 * telnet_open Procedure: telnet_open procedure
4264 * telnet_binary Procedure: telnet_binary procedure
4265 * tip_open Procedure: tip_open procedure
4266 * rlogin_open Procedure: rlogin_open procedure
4267 * rlogin_spawn Procedure: rlogin_spawn procedure
4268 * rsh_open Procedure: rsh_open procedure
4269 * rsh_download Procedure: rsh_download procedure
4270 * rsh_upload Procedure: rsh_upload procedure
4271 * rsh_exec Procedure: rsh_exec procedure
4272 * ssh_close Procedure: ssh_close procedure
4273 * ssh_exec Procedure: ssh_exec procedure
4274 * ssh_download Procedure: ssh_download procedure
4275 * ssh_upload Procedure: ssh_upload procedure
4276 * ftp_open Procedure: ftp_open procedure
4277 * ftp_upload Procedure: ftp_upload procedure
4278 * ftp_download Procedure: ftp_download procedure
4279 * ftp_close Procedure: ftp_close procedure
4280 * tip_download Procedure: tip_download procedure
4283 @node kermit_open procedure, kermit_command procedure, connprocs, connprocs
4284 @subsubheading kermit_open Procedure
4288 @t{@b{kermit_open} @i{dest} @i{args}}
4296 @node kermit_command procedure, kermit_send procedure, kermit_open procedure, connprocs
4297 @subsubheading kermit_command Procedure
4298 @findex kermit_command
4301 @t{@b{kermit_command} @i{dest} @i{args}}
4309 @node kermit_send procedure, kermit_transmit procedure, kermit_command procedure, connprocs
4310 @subsubheading kermit_send Procedure
4314 @t{@b{kermit_send} @i{dest string args}}
4323 @node kermit_transmit procedure, telnet_open procedure, kermit_send procedure, connprocs
4324 @subsubheading kermit_transmit Procedure
4325 @findex kermit_transmit
4328 @t{@b{kermit_transmit} @i{dest} @i{file} @i{args}}
4337 @node telnet_open procedure, telnet_binary procedure, kermit_transmit procedure, connprocs
4338 @subsubheading telnet_open Procedure
4341 This procedure opens a connection to a remote host using TELNET. This
4342 procedure sets the @code{fileid} field in the @code{board_info} array
4343 and returns the spawn id (or -1 for error).
4346 @t{@b{telnet_open} @i{hostname} @i{args}}
4350 @item @code{hostname}
4351 The host to connect to with TELNET.
4354 A list of options. Currently the only supported option is @code{raw}.
4357 @node telnet_binary procedure, tip_open procedure, telnet_open procedure, connprocs
4358 @subsubheading telnet_binary Procedure
4359 @findex telnet_binary
4361 Puts an existing TELNET connection into binary mode.
4364 @t{@b{telnet_binary} @i{hostname}}
4368 @item @code{hostname}
4369 Hostname for the connection.
4372 @node tip_open procedure, rlogin_open procedure, telnet_binary procedure, connprocs
4373 @subsubheading tip_open Procedure
4376 Connect to a host using @code{tip(1)}. This procedure sets the board
4377 @code{fileid} field with the @code{spawn_id} on success and,
4378 otherwise, returns -1.
4381 @t{@b{tip_open} @i{hostname}}
4385 @item @code{hostname}
4386 Hostname to connect to.
4389 @node rlogin_open procedure, rlogin_spawn procedure, tip_open procedure, connprocs
4390 @subsubheading rlogin_open Procedure
4394 @t{@b{rlogin_open} @i{arg}}
4401 @node rlogin_spawn procedure, rsh_open procedure, rlogin_open procedure, connprocs
4402 @subsubheading rlogin_spawn Procedure
4403 @findex rlogin_spawn
4406 @t{@b{rlogin_spawn} @i{dest} @i{cmdline}}
4411 @item @code{cmdline}
4414 @node rsh_open procedure, rsh_download procedure, rlogin_spawn procedure, connprocs
4415 @subsubheading rsh_open Procedure
4419 @t{@b{rsh_open} @i{hostname}}
4423 @item @code{hostname}
4426 @node rsh_download procedure, rsh_upload procedure, rsh_open procedure, connprocs
4427 @subsubheading rsh_download Procedure
4428 @findex rsh_download
4431 @t{@b{rsh_download} @i{desthost} @i{srcfile} @i{destfile}}
4435 @item @code{desthost}
4436 @item @code{srcfile}
4437 @item @code{destfile}
4440 @node rsh_upload procedure, rsh_exec procedure, rsh_download procedure, connprocs
4441 @subsubheading rsh_upload Procedure
4445 @t{@b{rsh_upload} @i{desthost} @i{srcfile} @i{destfile}}
4449 @item @code{desthost}
4450 @item @code{srcfile}
4451 @item @code{destfile}
4454 @node rsh_exec procedure, ssh_close procedure, rsh_upload procedure, connprocs
4455 @subsubheading rsh_exec Procedure
4459 @t{@b{rsh_exec} @i{boardname} @i{cmd} @i{args}}
4463 @item @code{boardname}
4468 @node ssh_close procedure, ssh_exec procedure, rsh_exec procedure, connprocs
4469 @subsubheading ssh_close procedure
4473 @t{@b{ssh_close} @i{desthost}}
4477 @item @code{desthost}
4480 @node ssh_exec procedure, ssh_download procedure, ssh_close procedure, connprocs
4481 @subsubheading ssh_exec procedure
4485 @t{@b{ssh_exec} @i{boardname} @i{program} @i{pargs} @i{inp} @i{outp}}
4489 @item @code{boardname}
4490 @item @code{program}
4496 @node ssh_download procedure, ssh_upload procedure, ssh_exec procedure, connprocs
4497 @subsubheading ssh_download procedure
4498 @findex ssh_download
4501 @t{@b{ssh_download} @i{desthost} @i{srcfile} @i{destfile}}
4505 @item @code{desthost}
4506 @item @code{srcfile}
4507 @item @code{destfile}
4510 @node ssh_upload procedure, ftp_open procedure, ssh_download procedure, connprocs
4511 @subsubheading ssh_upload procedure
4515 @t{@b{ssh_upload} @i{desthost} @i{srcfile} @i{destfile}}
4519 @item @code{desthost}
4520 @item @code{srcfile}
4521 @item @code{destfile}
4524 @node ftp_open procedure, ftp_upload procedure, ssh_upload procedure, connprocs
4525 @subsubheading ftp_open Procedure
4528 Open an FTP connection.
4531 @t{@b{ftp_open} @i{host}}
4536 The host to open the FTP connection to.
4539 @node ftp_upload procedure, ftp_download procedure, ftp_open procedure, connprocs
4540 @subsubheading ftp_upload Procedure
4543 Fetches a file from a remote host using FTP.
4546 @t{@b{ftp_upload} @i{host} @i{remotefile} @i{localfile}}
4551 The host to transfer the file from.
4553 @item @code{remotefile}
4554 The filename at the remote end.
4556 @item @code{localfile}
4557 The filename to store locally.
4561 @node ftp_download procedure, ftp_close procedure, ftp_upload procedure, connprocs
4562 @subsubheading ftp_download Procedure
4563 @findex ftp_download
4565 Sends a file to a remote host using FTP.
4568 @t{@b{ftp_download} @i{host} @i{localfile} @i{remotefile}}
4573 The host to transfer the file from.
4575 @item @code{localfile}
4576 The filename on the local system.
4578 @item @code{remotefile}
4579 The filename at the remote end.
4582 @node ftp_close procedure, tip_download procedure, ftp_download procedure, connprocs
4583 @subsubheading ftp_close Procedure
4586 Closes the FTP connection to a host.
4589 @t{@b{ftp_close} @i{host}}
4594 The host connection to close.
4597 @node tip_download procedure, , ftp_close procedure, connprocs
4598 @subsubheading tip_download Procedure
4599 @findex tip_download
4602 @t{@b{tip_download} @i{spawnid} @i{file}}
4607 @item @code{spawnid}
4608 Download @code{file} to the process @code{spawnid} (the value returned
4609 when the connection was established), using the @code{~put} command
4610 under tip. Most often used for single board computers that require
4611 downloading programs in ASCII S-records. Returns @emph{1} if an error
4612 occurs, @emph{0} otherwise.
4615 This is the filename to download.
4618 @node Procedures For Target Boards, target database library file, connprocs, Built-in Procedures
4619 @section Procedures For Target Boards
4622 * default_link Procedure: default_link procedure
4623 * default_target_assemble Procedure: default_target_assemble procedure
4624 * default_target_compile Procedure: default_target_compile procedure
4625 * pop_config Procedure: pop_config procedure
4626 * prune_warnings Procedure: prune_warnings procedure
4627 * push_build Procedure: push_build procedure
4628 * push_config Procedure: push_config procedure
4629 * reboot_target Procedure: reboot_target procedure
4630 * target_assemble Procedure: target_assemble procedure
4631 * target_compile Procedure: target_compile procedure
4632 * target_link Procedure: target_link procedure
4635 @node default_link procedure, default_target_assemble procedure, , Procedures For Target Boards
4636 @subsubheading default_link Procedure
4637 @findex default_link
4640 @t{@b{default_link} @i{board} @i{objects} @i{destfile} @i{flags}}
4643 This is the internal implementation for the @ref{target_link
4644 procedure}, and should not be directly called from testsuite code.
4646 @node default_target_assemble procedure, default_target_compile procedure, default_link procedure, Procedures For Target Boards
4647 @subsubheading default_target_assemble Procedure
4648 @findex default_target_assemble
4651 @t{@b{default_target_assemble} @i{source} @i{destfile} @i{flags}}
4654 This is the internal implementation for the @ref{target_assemble
4655 procedure}, and should not be directly called from testsuite code.
4657 @node default_target_compile procedure, pop_config procedure, default_target_assemble procedure, Procedures For Target Boards
4658 @subsubheading default_target_compile Procedure
4659 @findex default_target_compile
4662 @t{@b{default_target_compile} @i{source} @i{destfile} @i{type}
4666 This is the default implementation for the @ref{target_compile
4667 procedure}, and is used if the current target board does not have a
4668 special procedure for this purpose. @xref{target_compile procedure},
4669 for API details. Calling this procedure directly from testsuite code
4672 @node pop_config procedure, prune_warnings procedure, default_target_compile procedure, Procedures For Target Boards
4673 @subsubheading pop_config Procedure
4677 @t{@b{pop_config} @i{type}}
4684 @node prune_warnings procedure, push_build procedure, pop_config procedure, Procedures For Target Boards
4685 @subsubheading prune_warnings Procedure
4686 @findex prune_warnings
4689 @t{@b{prune_warnings} @i{text}}
4696 @node push_build procedure, push_config procedure, prune_warnings procedure, Procedures For Target Boards
4697 @subsubheading push_build Procedure
4701 @t{@b{push_build} @i{name}}
4708 @node push_config procedure, reboot_target procedure, push_build procedure, Procedures For Target Boards
4709 @subsubheading push_config Procedure
4713 @t{@b{push_config} @i{type} @i{name}}
4722 @node reboot_target procedure, target_assemble procedure, push_config procedure, Procedures For Target Boards
4723 @subsubheading reboot_target Procedure
4724 @findex reboot_target
4729 @t{@b{reboot_target}}
4732 @node target_assemble procedure, target_compile procedure, reboot_target procedure, Procedures For Target Boards
4733 @subsubheading target_assemble Procedure
4734 @findex target_assemble
4737 @t{@b{target_assemble} @i{source destfile flags}}
4742 @item @code{destfile}
4746 @node target_compile procedure, target_link procedure, target_assemble procedure, Procedures For Target Boards
4747 @subsubheading target_compile Procedure
4748 @findex target_compile
4751 @t{@b{target_compile} @i{source} @i{destfile} @i{type} @i{options}}
4756 Source file or other arguments if @var{type} is @code{none}.
4758 Destination file or empty string to request output as return value.
4760 Type of output that should be produced.
4761 @multitable {@code{preprocess}} {Special applications where no source is actually given.}
4763 @tab Special applications where no source is actually given.
4764 @item @code{preprocess}
4765 @tab Run the source files through the C preprocessor.
4766 @item @code{assembly}
4767 @tab Produce assembler source from the compiler.
4769 @tab Produce binary object files.
4770 @item @code{executable}
4771 @tab Produce an executable program.
4774 List of additional options:
4776 @b{Language-selection options:}
4779 Use an Ada compiler.
4783 Use a compiler for the D language.
4785 Use a compiler for Fortran 77.
4787 Use a compiler for Fortran 90.
4789 Use a compiler for Go.
4791 Use a compiler for Rust.
4793 If none of these options are given, the C compiler is used by default.
4794 Giving multiple language-selection options is an error.
4796 The @code{f77} option generally selects the @command{g77} compiler,
4797 while the @code{f90} option selects the newer @command{gfortran}
4798 frontend. Both of these can compile Fortran 77, but only
4799 @command{gfortran} supports Fortran 90.
4801 @b{Search path options:}
4803 @item incdir=@var{dir}
4804 Additional directory to search for preprocessor include files.
4805 Multiple uses of this option add multiple directories to the search
4807 @item libdir=@var{dir}
4808 Additional directory to search for libraries. Multiple uses of this
4809 option add multiple directories to the search path.
4815 Compile with debugging information. Multiple uses of this option are
4816 treated as a single use.
4817 @item dest=@var{target}
4818 Override the current target and compile for @var{target} instead. If
4819 this option is given multiple times, only the last use is significant.
4820 @item compiler=@var{command}
4821 Override the defaults and use @var{command} as the compiler. If
4822 this option is given multiple times, only the last use is significant.
4823 @item linker=@var{command}
4824 Override the defaults and use @var{command} to build executables. If
4825 this option is given multiple times, only the last use is significant.
4826 @item early_flags=@var{flags}
4827 Prepend @var{flags} to the set of arguments to be passed to the compiler.
4828 Multiple uses of this option specify additional arguments.
4829 @item additional_flags=@var{flags}
4830 Add @var{flags} to the set of arguments to be passed to the compiler.
4831 Multiple uses of this option specify additional arguments.
4832 @item optimize=@var{flags}
4833 Specify optimization flags to be passed to the compiler. Nothing
4834 enforces that the flags given with option must actually be related to
4835 optimization, however. If this option is given multiple times, only
4836 the last use is significant.
4837 @item ldflags=@var{flags}
4838 Add @var{flags} to the set of arguments to be passed to the linker.
4839 Note that these are passed literally to the compiler driver, without
4840 adding a special prefix to each option. If a @samp{-Wl,} prefix is
4841 needed with GCC, it must be included in the given @var{flags}. As a
4842 group, the linker flags are only used if an executable is requested
4843 and are given special treatment with some languages. Multiple uses of
4844 this option specify additional arguments.
4845 @item ldscript=@var{script}
4846 Specify a linker script, or more precisely, the argument to pass to
4847 the linker via the compiler driver to select a linker script. The
4848 @var{script} value is passed literally to the compiler driver. If
4849 this option is given multiple times, only the last use is significant.
4850 @item libs=@var{libs}
4851 Specify additional libraries to be included in the link. The
4852 @var{libs} value is a space-separated list of libraries to include.
4853 Each element is checked, and if a file exists with that exact name, it
4854 is added to the list of sources to be given to the compiler.
4855 Otherwise, the element is passed literally to the compiler driver
4856 after any linker flags specified with the @code{ldflags} option.
4857 Multiple uses of this option specify additional lists, which are
4858 concatenated in the order they are given.
4861 @b{Execution options:}
4863 @item timeout=@var{timeout}
4864 Abort the compile job if it is still running after @var{timeout}
4865 seconds. This is intended for compiler tests that are known to cause
4866 infinite loops upon failure.
4867 @item redirect=@var{file}
4868 Instead of returning output emitted on @code{stdout}, place it into
4873 The @code{target_compile} procedure also uses several global Tcl variables as overrides:
4875 @item CFLAGS_FOR_TARGET
4876 If @code{CFLAGS_FOR_TARGET} is set, its value is prepended to the
4877 flags otherwise prepared for the compiler, even ahead of any
4878 board-specific flags inserted as a result of a language-selection
4880 @item LDFLAGS_FOR_TARGET
4881 If @code{LDFLAGS_FOR_TARGET} is set, the set of arguments to be passed
4882 to linker is initialized to its value instead of an empty list. The
4883 @code{ldflags} option appends to this list.
4885 Override default compiler. If no other compiler is given and this
4886 variable is set, its value will be used instead of searching for a
4887 compiler or using the default from the target board configuration.
4888 The @code{compiler} option overrides this variable.
4889 @item CXX_FOR_TARGET
4890 Override C++ compiler. If the @code{c++} option is given, this
4891 compiler will be used and the @code{compiler} option ignored.
4893 Override D language compiler. If the @code{d} option is given, this
4894 compiler will be used and the @code{compiler} option ignored.
4895 @item F77_FOR_TARGET
4896 Override Fortran 77 compiler. If the @code{f77} option is given, this
4897 compiler will be used and the @code{compiler} option ignored.
4898 @item F90_FOR_TARGET
4899 Override Fortran 90 compiler. If the @code{f90} option is given, this
4900 compiler will be used and the @code{compiler} option ignored.
4902 Override Go compiler. If the @code{go} option is given, this
4903 compiler will be used and the @code{compiler} option ignored.
4904 @item GO_LD_FOR_TARGET
4905 Override Go linker. If the @code{go} option is given, this
4906 linker will be used.
4907 @item RUSTC_FOR_TARGET
4908 Override Rust compiler. If the @code{rust} option is given, this
4909 compiler will be used and the @code{compiler} option ignored.
4910 @item GNATMAKE_FOR_TARGET
4911 Override Ada compiler. If the @code{ada} option is given, this
4912 compiler will be used and the @code{compiler} option ignored.
4915 The @code{target_compile} procedure obtains most defaults from the
4916 target board configuration, but additionally inserts any flags
4917 specified as @code{cflags_for_target} on the @emph{host} board
4918 configuration. If no host is set, the @code{unix} board configuration
4919 is checked for a @code{cflags_for_target} key. If the
4920 @code{cflags_for_target} key exists, its value is inserted into the
4921 set of arguments given to the compiler after any arguments given with
4922 the @code{additional_flags} option.
4924 In DejaGnu 1.6.2 and older, this mechanism did not work reliably and
4925 the @code{unix} board configuration was always searched for the
4926 @code{cflags_for_target} key, regardless of the host board selected.
4928 Also in DejaGnu 1.6.2 and older, the @code{dest} option interacted
4929 very badly with the language-selection options. There was no correct
4930 way to combine these options because the language-specific defaults
4931 would be read from the current target board configuration instead of
4932 the board configuration specified with the @code{dest} option. The
4933 closest solution was to always specify the language-selection option
4934 first, but this results in defaults appropriate for the current
4935 target, instead of the target selected with the @code{dest} option.
4937 @node target_link procedure, , target_compile procedure, Procedures For Target Boards
4938 @subsubheading target_link Procedure
4942 @t{@b{target_link} @i{objects} @i{destfile} @i{flags}}
4946 @item @code{objects}
4947 @item @code{destfile}
4951 @node target database library file, platform dependent procedures, Procedures For Target Boards, Built-in Procedures
4952 @section Target Database Procedures
4955 * board_info Procedure: board_info procedure
4956 * host_info Procedure: host_info procedure
4957 * set_board_info Procedure: set_board_info procedure
4958 * add_board_info Procedure: add_board_info procedure
4959 * set_currtarget_info Procedure: set_currtarget_info procedure
4960 * target_info Procedure: target_info procedure
4961 * unset_board_info Procedure: unset_board_info procedure
4962 * unset_currtarget_info Procedure: unset_currtarget_info procedure
4963 * push_target Procedure: push_target procedure
4964 * pop_target Procedure: pop_target procedure
4965 * push_host Procedure: push_host procedure
4966 * pop_host Procedure: pop_host procedure
4969 @node board_info procedure, host_info procedure, , target database library file
4970 @subsubheading board_info Procedure
4973 Searches the @code{board_info} array for the specified information.
4976 @t{@b{board_info} @i{machine} @i{op} @i{args}}
4980 @item @code{machine}
4985 @node host_info procedure, set_board_info procedure, board_info procedure, target database library file
4986 @subsubheading host_info Procedure
4990 @t{@b{host_info} @i{op} @i{args}}
4998 @node set_board_info procedure, add_board_info procedure, host_info procedure, target database library file
4999 @subsubheading set_board_info Procedure
5000 @findex set_board_info
5002 This checks if the @code{board_info} array entry has been set already
5003 and, if not, sets it to given value.
5006 @t{@b{set_board_info} @i{entry} @i{value}}
5011 Field of the @code{board_info} to set.
5014 Value to set the field to.
5017 @node add_board_info procedure, set_currtarget_info procedure, set_board_info procedure, target database library file
5018 @subsubheading add_board_info Procedure
5019 @findex add_board_info
5021 This treats @code{board_info} array's field @emph{entry} as a TCL list
5022 and adds @emph{value} at the end.
5025 @t{@b{add_board_info} @i{entry} @i{value}}
5031 The name of a @code{board_info} field to operate on.
5034 The value to add to the field.
5037 @node set_currtarget_info procedure, target_info procedure, add_board_info procedure, target database library file
5038 @subsubheading set_currtarget_info Procedure
5039 @findex set_currtarget_info
5042 @t{@b{set_currtarget_info} @i{entry} @i{value}}
5050 @node target_info procedure, unset_board_info procedure, set_currtarget_info procedure, target database library file
5051 @subsubheading target_info Procedure
5055 @t{@b{target_info} @i{op} @i{args}}
5063 @node unset_board_info procedure, unset_currtarget_info procedure, target_info procedure, target database library file
5064 @subsubheading unset_board_info Procedure
5065 @findex unset_board_info
5067 This checks if @code{board_info} array's field @emph{entry} has been
5068 set and if so, then removes it.
5071 @t{@b{unset_board_info} @i{entry}}
5076 The name of a @code{board_info} field to operate on.
5079 @node unset_currtarget_info procedure, push_target procedure, unset_board_info procedure, target database library file
5080 @subsubheading unset_currtarget_info Procedure
5081 @findex unset_currtarget_info
5084 @t{@b{unset_currtarget_info} @i{entry}}
5091 @node push_target procedure, pop_target procedure, unset_currtarget_info procedure, target database library file
5092 @subsubheading push_target Procedure
5095 This makes the target named @emph{name} be the current target
5099 @t{@b{push_target} @i{name}}
5104 Name of the target to make the current connection.
5107 @node pop_target procedure, push_host procedure, push_target procedure, target database library file
5108 @subsubheading pop_target Procedure
5111 This unsets the current target connection.
5117 @node push_host procedure, pop_host procedure, pop_target procedure, target database library file
5118 @subsubheading push_host Procedure
5121 This procedure makes the host named @emph{name} be the current remote
5125 @t{@b{push_host} @i{name}}
5130 Name of the host to make the current connection.
5133 @node pop_host procedure, , push_host procedure, target database library file
5134 @subsubheading pop_host Procedure
5137 This unsets the current host connection.
5143 @node platform dependent procedures, Utility Procedures, target database library file, Built-in Procedures
5144 @section Platform Dependent Procedures
5146 Each combination of target and tool requires some target-dependent
5147 procedures. The names of these procedures have a common form: the
5148 tool name, followed by an underscore @emph{_}, and finally a suffix
5149 describing the procedure's purpose. For example, a procedure to
5150 extract the version from GDB is called @code{gdb_version}.
5152 @code{runtest} itself calls only two of these procedures,
5153 @code{$@{tool@}_exit} and @code{$@{tool@}_version}; these procedures
5156 The other two procedures, @code{$@{tool@}_start} and
5157 @code{$@{tool@}_load}, are only called by the test suites themselves
5158 (or by testsuite-specific initialization code); they may take
5159 arguments or not, depending on the conventions used within each
5162 The usual convention for return codes from any of these procedures
5163 (although it is not required by @code{runtest}) is to return @emph{0}
5164 if the procedure succeeded, @emph{1} if it failed, and @emph{-1} if
5165 there was a communication error.
5168 * $@{tool@}_start Procedure: $@{tool@}_start procedure
5169 * $@{tool@}_load Procedure: $@{tool@}_load procedure
5170 * $@{tool@}_exit Procedure: $@{tool@}_exit procedure
5171 * $@{tool@}_version Procedure: $@{tool@}_version procedure
5174 @node $@{tool@}_start procedure, $@{tool@}_load procedure, , platform dependent procedures
5175 @subsubheading $@{tool@}_start Procedure
5176 @findex $@{tool@}_start
5178 Starts a particular tool. For an interactive tool,
5179 @code{$@{tool@}_start} starts and initializes the tool, leaving the
5180 tool up and running for the test cases; an example is
5181 @code{gdb_start}, the start function for GDB. For a batch-oriented
5182 tool, @code{$@{tool@}_start} is optional; the recommended convention
5183 is to let @code{$@{tool@}_start} run the tool, leaving the output in a
5184 variable called @code{comp_output}. Test scripts can then analyze
5185 @code{$comp_output} to determine the test results. An example of this
5186 second kind of start function is @code{gcc_start}, the start function
5189 DejaGnu itself does not call @code{$@{tool@}_start}. The
5190 initialization module @code{$@{tool@}_init.exp} must call
5191 @code{$@{tool@}_start} for interactive tools; for batch-oriented
5192 tools, each individual test script calls @code{$@{tool@}_start} (or
5193 makes other arrangements to run the tool).
5196 @t{@b{$@{tool@}_start}}
5199 @node $@{tool@}_load procedure, $@{tool@}_exit procedure, $@{tool@}_start procedure, platform dependent procedures
5200 @subsubheading $@{tool@}_load Procedure
5201 @findex $@{tool@}_load
5203 Loads something into a tool. For an interactive tool, this conditions
5204 the tool for a particular test case; for example, @code{gdb_load}
5205 loads a new executable file into the debugger. For batch-oriented
5206 tools, @code{$@{tool@}_load} may do nothing---though, for example, the
5207 GCC support uses @code{gcc_load} to load and run a binary on the
5208 target environment. Conventionally, @code{$@{tool@}_load} leaves the
5209 output of any program it runs in a variable called
5210 @code{$exec_output}. Writing @code{$@{tool@}_load} can be the most
5211 complex part of extending DejaGnu to a new tool or a new target, if it
5212 requires much communication coding or file downloading. Test scripts
5213 call @code{$@{tool@}_load}.
5216 @t{@b{$@{tool@}_load}}
5219 @node $@{tool@}_exit procedure, $@{tool@}_version procedure, $@{tool@}_load procedure, platform dependent procedures
5220 @subsubheading $@{tool@}_exit Procedure
5221 @findex $@{tool@}_exit
5223 Cleans up (if necessary) before DejaGnu exits. For interactive tools,
5224 this usually ends the interactive session. You can also use
5225 @code{$@{tool@}_exit} to remove any temporary files left over from the
5226 tests. @code{runtest} calls @code{$@{tool@}_exit}.
5229 @t{@b{$@{tool@}_exit}}
5232 @node $@{tool@}_version procedure, , $@{tool@}_exit procedure, platform dependent procedures
5233 @subsubheading $@{tool@}_version Procedure
5234 @findex $@{tool@}_version
5236 Prints the version label and number for @code{$@{tool@}}. This is
5237 called by the DejaGnu procedure that prints the final summary report.
5238 The output should consist of the full path name used for the tested
5239 tool, and its version number.
5242 @t{@b{$@{tool@}_version}}
5245 @node Utility Procedures, Libgloss, platform dependent procedures, Built-in Procedures
5246 @section Utility Procedures
5249 * getdirs Procedure: getdirs procedure
5250 * relative_filename Procedure: relative_filename procedure
5251 * find Procedure: find procedure
5252 * which Procedure: which procedure
5253 * grep Procedure: grep procedure
5254 * prune Procedure: prune procedure
5255 * runtest_file_p Procedure: runtest_file_p procedure
5256 * diff Procedure: diff procedure
5257 * setenv Procedure: setenv procedure
5258 * unsetenv Procedure: unsetenv procedure
5259 * getenv Procedure: getenv procedure
5262 @node getdirs procedure, relative_filename procedure, Utility Procedures, Utility Procedures
5263 @subsubheading getdirs Procedure
5266 Returns a list of all the subdirectories in a single directory that
5267 match a glob pattern. If no directories match the pattern, then an
5268 empty list is returned.
5270 This procedure is specialized as a search for tests in testsuites:
5271 @code{getdirs} ignores directories named @samp{testsuite},
5272 @samp{config}, or @samp{lib}, and also ignores directories associated
5273 with a few revision control systems, specifically Git (@samp{.git}),
5274 Subversion (@samp{.svn}), CVS (@samp{CVS}), RCS (@samp{RCS}), and SCCS
5275 (@samp{SCCS}). These ignored directories will not appear in the
5276 returned list, nor will they be examined in a recursive search.
5279 @t{@b{getdirs} @i{-all} @i{rootdir} @i{pattern}}
5285 If this option is given, then subdirectories will be matched
5288 @item @code{rootdir}
5289 The top level directory to start the search from.
5291 @item @code{pattern}
5292 The Tcl glob pattern to match. If you do not specify @code{pattern},
5293 @code{getdirs} uses a default pattern of @code{*}.
5297 @node relative_filename procedure, find procedure, getdirs procedure, Utility Procedures
5298 @subsubheading relative_filename Procedure
5299 @findex relative_filename
5301 Return a relative file name, given a starting point.
5304 @t{@b{relative_filename} @i{base} @i{destination}}
5310 The starting point for relative file name traversal.
5312 @item @code{destination}
5313 The absolute file name that should be reached by appending the return
5317 @node find procedure, which procedure, relative_filename procedure, Utility Procedures
5318 @subsubheading find Procedure
5321 Search for files whose names match a glob pattern. Search
5322 subdirectories recursively, starting at a particular root directory.
5323 The result is the list of files whose names match. Filenames in the
5324 result include all intervening subdirectory names. If no files match
5325 the pattern, then an empty string is returned.
5328 @t{@b{find} @i{rootdir} @i{pattern}}
5332 @item @code{rootdir}
5333 The top level directory to start the search from.
5335 @item @code{pattern}
5336 A glob pattern representing the files to find.
5339 @node which procedure, grep procedure, find procedure, Utility Procedures
5340 @subsubheading which Procedure
5343 Searches the execution path for an executable file like the BSD
5344 @code{which(1)} utility. This procedure uses the shell environment
5345 variable @code{PATH}. It returns @b{0} if the binary is not in the
5346 path or if the @code{PATH} environment variable is not set. If the
5347 file is in the path, this procedure returns the full path to the file.
5350 @t{@b{which} @i{file}}
5355 The executable program or shell script to look for.
5358 @node grep procedure, prune procedure, which procedure, Utility Procedures
5359 @subsubheading grep Procedure
5362 Search a named file for lines that contain a match for a regular
5363 expression. The result is a list of all the lines that match. If no
5364 lines match, the result is an empty string. All of the Tcl regular
5365 expression syntax is supported.
5368 @t{@b{grep} @i{-n} @i{filename} @i{regexp} @b{line}}
5373 The @code{-n} option prefixes matched lines in the result with the
5374 line number, just like GNU @code{grep} does. This option should be
5375 used in preference to the @code{line} keyword documented below.
5377 @item @code{filename}
5381 The Unix style regular expression (as used by the @code{grep} UNIX
5382 utility) to search for.
5385 Use the optional keyword @code{line} to prefix matched lines in the
5386 result with the line number. This usage is deprecated.
5389 @node prune procedure, runtest_file_p procedure, grep procedure, Utility Procedures
5390 @subsubheading prune Procedure
5393 This procedure is deprecated and will be removed in a future release
5394 of DejaGnu. If a testsuite uses this procedure, a copy of the
5395 procedure should be made and placed in the @file{lib} directory of the
5398 @node runtest_file_p procedure, diff procedure, prune procedure, Utility Procedures
5399 @subsubheading runtest_file_p Procedure
5400 @findex runtest_file_p
5402 Search @emph{runtest}s for @emph{testcase} and return @b{1} if found,
5403 @b{0} if not. This is used by tools like compilers where each
5407 @t{@b{runtest_file_p} @i{runtests} @i{testcase}}
5411 @item @code{runtests}
5413 @code{runtests} is a list of two elements. The second is a copy of
5414 what was on the right side of the @code{=} if @code{foo.exp="..."} was
5415 specified, or an empty string if no such argument is present.
5417 @item @code{testcase}
5418 The filename of the current testcase under consideration.
5421 @node diff procedure, setenv procedure, runtest_file_p procedure, Utility Procedures
5422 @subsubheading diff Procedure
5425 Compares two files and returns @b{1} if they match (no differences) or
5426 @b{0} if not. If @code{verbose} is set, then it will print the
5427 differences to the console.
5430 @t{@b{diff} @i{file1} @i{file2}}
5435 First file for the comparison.
5438 Second file for the comparison.
5441 @node setenv procedure, unsetenv procedure, diff procedure, Utility Procedures
5442 @subsubheading setenv Procedure
5445 Set an environment variable.
5448 @t{@b{setenv} @i{var} @i{val}}
5453 The environment variable to set.
5456 The value to set the variable to.
5459 @node unsetenv procedure, getenv procedure, setenv procedure, Utility Procedures
5460 @subsubheading unsetenv Procedure
5463 Unset an environment variable.
5466 @t{@b{unsetenv} @i{var} }
5471 The environment variable to unset.
5474 @node getenv procedure, , unsetenv procedure, Utility Procedures
5475 @subsubheading getenv Procedure
5478 Returns the value of the envrionment variable @emph{var} if it is
5479 defined, otherwise an empty string is returned.
5482 @t{@b{getenv} @i{var} }
5487 Environment variable to retrieve.
5490 @node Libgloss, Debugging Procedures, Utility Procedures, Built-in Procedures
5491 @section Libgloss, a free board support package (BSP)
5493 Libgloss is a free board support package @dfn{BSP} commonly used with
5494 GCC and G++ to produce a fully linked executable image for an embedded
5498 * libgloss_link_flags Procedure: libgloss_link_flags procedure
5499 * libgloss_include_flags Procedure: libgloss_include_flags procedure
5500 * newlib_link_flags Procedure: newlib_link_flags procedure
5501 * newlib_include_flags Procedure: newlib_include_flags procedure
5502 * libio_include_flags Procedure: libio_include_flags procedure
5503 * libio_link_flags Procedure: libio_link_flags procedure
5504 * g++_include_flags Procedure: g++_include_flags procedure
5505 * g++_link_flags Procedure: g++_link_flags procedure
5506 * libstdc++_include_flags Procedure: libstdc++_include_flags procedure
5507 * libstdc++_link_flags Procedure: libstdc++_link_flags procedure
5508 * get_multilibs Procedure: get_multilibs procedure
5509 * find_binutils_prog Procedure: find_binutils_prog procedure
5510 * find_gcc Procedure: find_gcc procedure
5511 * find_gcj Procedure: find_gcj procedure
5512 * find_g++ Procedure: find_g++ procedure
5513 * find_g77 Procedure: find_g77 procedure
5514 * find_gfortran Procedure: find_gfortran procedure
5515 * find_go Procedure: find_go procedure
5516 * find_go_linker Procedure: find_go_linker procedure
5517 * find_rustc Procedure: find_rustc procedure
5518 * process_multilib_options Procedure: process_multilib_options procedure
5519 * add_multilib_option Procedure: add_multilib_option procedure
5520 * find_gas Procedure: find_gas procedure
5521 * find_ld Procedure: find_ld procedure
5522 * build_wrapper Procedure: build_wrapper procedure
5523 * winsup_include_flags Procedure: winsup_include_flags procedure
5524 * winsup_link_flags Procedure: winsup_link_flags procedure
5527 @node libgloss_link_flags procedure, libgloss_include_flags procedure, , Libgloss
5528 @subsubheading libgloss_link_flags Procedure
5529 @findex libgloss_link_flags
5531 Finds the pieces of @code{libgloss} needed to link a set of object
5532 files into an executable. This usually means setting the @code{-L}
5533 and @code{-B} paths correctly.
5536 @t{@b{libgloss_link_flags} @i{args} }
5544 @node libgloss_include_flags procedure, newlib_link_flags procedure, libgloss_link_flags procedure, Libgloss
5545 @subsubheading libgloss_include_flags Procedure
5546 @findex libgloss_include_flags
5548 This procedure always returns an empty string. It is provided for
5552 @t{@b{libgloss_include_flags} @i{args}}
5560 @node newlib_link_flags procedure, newlib_include_flags procedure, libgloss_include_flags procedure, Libgloss
5561 @subsubheading newlib_link_flags Procedure
5562 @findex newlib_link_flags
5564 Return the options needed to link an executable with @code{newlib}.
5565 This usually means setting the @code{-L} and @code{-B} paths
5569 @t{@b{newlib_link_flags} @i{args}}
5577 @node newlib_include_flags procedure, libio_include_flags procedure, newlib_link_flags procedure, Libgloss
5578 @subsubheading newlib_include_flags Procedure
5579 @findex newlib_include_flags
5581 Return the options needed to locate the @code{newlib} header files.
5584 @t{@b{newlib_include_flags} @i{args}}
5592 @node libio_include_flags procedure, libio_link_flags procedure, newlib_include_flags procedure, Libgloss
5593 @subsubheading libio_include_flags Procedure
5594 @findex libio_include_flags
5597 @t{@b{libio_include_flags} @i{args}}
5600 Return the options needed to locate the @code{libio} header files.
5607 @node libio_link_flags procedure, g++_include_flags procedure, libio_include_flags procedure, Libgloss
5608 @subsubheading libio_link_flags Procedure
5609 @findex libio_link_flags
5612 @t{@b{libio_link_flags} @i{args}}
5615 Return the options needed to link an executable with @code{libio}.
5616 This usually means setting the @code{-L} and @code{-B} paths
5624 @node g++_include_flags procedure, g++_link_flags procedure, libio_link_flags procedure, Libgloss
5625 @subsubheading g++_include_flags Procedure
5626 @findex g++_include_flags
5628 Return the options needed to locate the C++ stnadard library header
5632 @t{@b{g++_include_flags} @i{args}}
5640 @node g++_link_flags procedure, libstdc++_include_flags procedure, g++_include_flags procedure, Libgloss
5641 @subsubheading g++_link_flags Procedure
5642 @findex g++_link_flags
5645 @t{@b{g++_link_flags} @i{args}}
5648 Return the options needed to link an executable with @code{libg++}.
5649 This usually means setting the @code{-L} and @code{-B} paths
5657 @node libstdc++_include_flags procedure, libstdc++_link_flags procedure, g++_link_flags procedure, Libgloss
5658 @subsubheading libstdc++_include_flags Procedure
5659 @findex libstdc++_include_flags
5662 @t{@b{libstdc++_include_flags} @i{args}}
5665 Return the options needed to locate the C++ stnadard library header
5673 @node libstdc++_link_flags procedure, get_multilibs procedure, libstdc++_include_flags procedure, Libgloss
5674 @subsubheading libstdc++_link_flags Procedure
5675 @findex libstdc++_link_flags
5678 @t{@b{libstdc++_link_flags} @i{args}}
5685 @node get_multilibs procedure, find_binutils_prog procedure, libstdc++_link_flags procedure, Libgloss
5686 @subsubheading get_multilibs Procedure
5687 @findex get_multilibs
5690 @t{@b{get_multilibs} @i{args}}
5697 @node find_binutils_prog procedure, find_gcc procedure, get_multilibs procedure, Libgloss
5698 @subsubheading find_binutils_prog Procedure
5699 @findex find_binutils_prog
5702 @t{@b{find_binutils_prog} @i{name}}
5709 @node find_gcc procedure, find_gcj procedure, find_binutils_prog procedure, Libgloss
5710 @subsubheading find_gcc Procedure
5713 Looks for a copy of the GNU C compiler in the build tree and in the
5714 @code{PATH}. This will also return the proper transformed name for a
5715 cross-compiler if the build tree is configured for one.
5721 @node find_gcj procedure, find_g++ procedure, find_gcc procedure, Libgloss
5722 @subsubheading find_gcj Procedure
5725 Looks for a copy of the GNU Java compiler in the build tree and in the
5726 @code{PATH}. This will also return the proper transformed name for a
5727 cross-compiler if the build tree is configured for one.
5733 @node find_g++ procedure, find_g77 procedure, find_gcj procedure, Libgloss
5734 @subsubheading find_g++ Procedure
5737 Looks for a copy of the GNU C++ compiler in the build tree and in the
5738 @code{PATH}. This will also return the proper transformed name for a
5739 cross-compiler if the build tree is configured for one.
5745 @node find_g77 procedure, find_gfortran procedure, find_g++ procedure, Libgloss
5746 @subsubheading find_g77 Procedure
5749 Looks for a copy of the GNU Fortran 77 compiler in the build tree and
5750 in the @code{PATH}. This will also return the proper transformed name
5751 for a cross-compiler if the build tree is configured for one.
5757 @node find_gfortran procedure, find_go procedure, find_g77 procedure, Libgloss
5758 @subsubheading find_gfortran Procedure
5759 @findex find_gfortran
5761 Looks for a copy of the GNU Fortran compiler in the build tree and in
5762 the @code{PATH}. This will also return the proper transformed name
5763 for a cross-compiler if the build tree is configured for one.
5766 @t{@b{find_gfortran}}
5769 @node find_go procedure, find_go_linker procedure, find_gfortran procedure, Libgloss
5770 @subsubheading find_go Procedure
5773 Looks for a copy of the GNU compiler for the Go language in the build
5774 tree and in the @code{PATH}. This will also return the proper
5775 transformed name for a cross-compiler if the build tree is configured
5782 @node find_go_linker procedure, find_rustc procedure, find_go procedure, Libgloss
5783 @subsubheading find_go_linker Procedure
5784 @findex find_go_linker
5786 Looks for a copy of the special linker associated with the GNU
5787 compiler for the Go language in the build tree and in the @code{PATH}.
5788 This will also return the proper transformed name for a cross-compiler
5789 if the build tree is configured for one.
5792 @t{@b{find_go_linker}}
5795 @node find_rustc procedure, process_multilib_options procedure, find_go_linker procedure, Libgloss
5796 @subsubheading find_rustc Procedure
5799 Looks for a copy of a compiler for the Rust language in the build tree
5800 and in the @code{PATH}. The Rust compiler is different and this
5801 procedure also ensures that it will be called with options to suppress
5808 @node process_multilib_options procedure, add_multilib_option procedure, find_rustc procedure, Libgloss
5809 @subsubheading process_multilib_options Procedure
5810 @findex process_multilib_options
5813 @t{@b{process_multilib_options} @i{args}}
5820 @node add_multilib_option procedure, find_gas procedure, process_multilib_options procedure, Libgloss
5821 @subsubheading add_multilib_option Procedure
5822 @findex add_multilib_option
5825 @t{@b{add_multilib_option} @i{args}}
5832 @node find_gas procedure, find_ld procedure, add_multilib_option procedure, Libgloss
5833 @subsubheading find_gas Procedure
5840 @node find_ld procedure, build_wrapper procedure, find_gas procedure, Libgloss
5841 @subsubheading find_ld Procedure
5848 @node build_wrapper procedure, winsup_include_flags procedure, find_ld procedure, Libgloss
5849 @subsubheading build_wrapper Procedure
5850 @findex build_wrapper
5853 @t{@b{build_wrapper} @i{gluefile}}
5857 @item @code{gluefile}
5860 @node winsup_include_flags procedure, winsup_link_flags procedure, build_wrapper procedure, Libgloss
5861 @subsubheading winsup_include_flags Procedure
5862 @findex winsup_include_flags
5865 @t{@b{winsup_include_flags} @i{args}}
5872 @node winsup_link_flags procedure, , winsup_include_flags procedure, Libgloss
5873 @subsubheading winsup_link_flags Procedure
5874 @findex winsup_link_flags
5877 @t{@b{winsup_link_flags} @i{args}}
5884 @node Debugging Procedures, , Libgloss, Built-in Procedures
5885 @section Procedures for debugging your scripts
5888 * bt Procedure: bt procedure
5889 * dumpvars Procedure: dumpvars procedure
5890 * dumplocals Procedure: dumplocals procedure
5891 * dumprocs Procedure: dumprocs procedure
5892 * dumpwatch Procedure: dumpwatch procedure
5893 * watcharray Procedure: watcharray procedure
5894 * watchvar Procedure: watchvar procedure
5895 * watchunset Procedure: watchunset procedure
5896 * watchwrite Procedure: watchwrite procedure
5897 * watchread Procedure: watchread procedure
5898 * watchdel Procedure: watchdel procedure
5899 * print Procedure: print procedure
5900 * quit Procedure: quit procedure
5903 @node bt procedure, dumpvars procedure, Debugging Procedures, Debugging Procedures
5904 @subsubheading bt Procedure
5907 This procedure prints a backtrace using the @code{w} command from the
5914 @node dumpvars procedure, dumplocals procedure, bt procedure, Debugging Procedures
5915 @subsubheading dumpvars Procedure
5919 This procedure prints the values of the global variables that match a
5920 glob pattern. Abbreviation: @kbd{dv}.
5923 @t{@b{dumpvars} @i{pattern}}
5927 @item @code{pattern}
5928 The global variables to dump.
5931 @node dumplocals procedure, dumprocs procedure, dumpvars procedure, Debugging Procedures
5932 @subsubheading dumplocals Procedure
5936 This procedure prints the values of local variables that match a glob
5937 pattern. Abbreviation: @kbd{dl}.
5940 @t{@b{dumplocals} @i{pattern} }
5944 @item @code{pattern}
5945 The local variables to dump.
5948 @node dumprocs procedure, dumpwatch procedure, dumplocals procedure, Debugging Procedures
5949 @subsubheading dumprocs Procedure
5953 This procedure dumps the body of all procs that match a glob pattern.
5954 It is abbreviated as @kbd{dp}.
5957 @t{@b{dumprocs} @i{pattern}}
5961 @item @code{pattern}
5962 The proc bodies to dump.
5965 @node dumpwatch procedure, watcharray procedure, dumprocs procedure, Debugging Procedures
5966 @subsubheading dumpwatch Procedure
5970 This procedure prints all of the watchpoints matching a glob pattern.
5971 It is abbreviated as @kbd{dw}.
5974 @t{@b{dumpwatch} @i{pattern}}
5978 @item @code{pattern}
5979 The watchpoints to dump.
5982 @node watcharray procedure, watchvar procedure, dumpwatch procedure, Debugging Procedures
5983 @subsubheading watcharray Procedure
5987 @t{@b{watcharray} @i{array} @i{element} @i{type}}
5993 @item @code{element}
5996 The csh "glob" style pattern to look for.
5999 @node watchvar procedure, watchunset procedure, watcharray procedure, Debugging Procedures
6000 @subsubheading watchvar Procedure
6004 @t{@b{watchvar} @i{var} @i{type}}
6013 @node watchunset procedure, watchwrite procedure, watchvar procedure, Debugging Procedures
6014 @subsubheading watchunset Procedure
6018 This breaks program execution when the variable @code{var} is unset.
6019 Abbreviation: @kbd{wu}.
6022 @t{@b{watchunset} @i{pattern}}
6026 @item @code{pattern}
6029 @node watchwrite procedure, watchread procedure, watchunset procedure, Debugging Procedures
6030 @subsubheading watchwrite Procedure
6034 This breaks program execution when the variable @code{var} is written.
6035 Abbreviation: @kbd{ww}.
6038 @t{@b{watchwrite} @i{var}}
6043 The variable to watch.
6046 @node watchread procedure, watchdel procedure, watchwrite procedure, Debugging Procedures
6047 @subsubheading watchread Procedure
6051 This breaks program execution when the variable @code{var} is read.
6052 Abbreviation: @kbd{wr}.
6055 @t{@b{watchread} @i{var}}
6060 The variable to watch.
6063 @node watchdel procedure, print procedure, watchread procedure, Debugging Procedures
6064 @subsubheading watchdel Procedure
6068 This deletes a watchpoint from the watch list. Abbreviation:
6072 @t{@b{watchdel} @i{pattern}}
6076 @item @code{pattern}
6079 @node print procedure, quit procedure, watchdel procedure, Debugging Procedures
6080 @subsubheading print Procedure
6083 This prints the value of a variable. Abbreviation: @kbd{p}.
6086 @t{@b{print} @i{var}}
6091 The variable to print.
6094 @node quit procedure, , print procedure, Debugging Procedures
6095 @subsubheading quit Procedure
6098 This makes @code{runtest} exit. Abbreviation: @kbd{q}.
6104 @node GNU Free Documentation License, Concept Index, Built-in Procedures, Top
6105 @appendix GNU Free Documentation License
6108 @node Concept Index, Procedure Index, GNU Free Documentation License, Top
6109 @unnumbered Concept Index
6112 @node Procedure Index, Variable Index, Concept Index, Top
6113 @unnumbered Procedure Index
6116 @node Variable Index, , Procedure Index, Top
6117 @unnumbered Variable Index
6122 @c LocalWords: subdirectory prepend prepended testsuite filename Expect's svn
6123 @c LocalWords: DejaGnu CVS RCS SCCS prepending subcommands Tcl Awk Readline
6124 @c LocalWords: POSIX KFAIL KPASS XFAIL XPASS hostname multitable gfortran api
6125 @c LocalWords: boolean subcommand testcase eval rustc executables perror gdb
6126 @c LocalWords: interprocess lookahead XPASSED XFAILED printf TestState init