1 \input texinfo @c -*- Texinfo -*-
2 @setfilename dejagnu.info
3 @documentencoding us-ascii
12 @c man begin COPYRIGHT
13 Copyright @copyright{} 1992-2020, 2022, 2023, 2024 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{https://www.tcl.tk,Tcl/Tk web site} and the
148 @uref{https://core.tcl-lang.org/expect/,Expect web site}. There is
149 also some historical information about Expect at the
150 @uref{https://www.nist.gov/services-resources/software/expect,NIST web
153 Julia Menapace first coined the term @emph{DejaGnu} to describe an
154 earlier testing framework she wrote at Cygnus Support for testing GDB.
155 When we replaced it with the Expect-based framework, it was like
156 DejaGnu all over again. More importantly, it was also named after my
157 daughter, Deja Snow Savoye, who was a toddler during DejaGnu's
160 DejaGnu offers several advantages for testing:
165 The flexibility and consistency of the DejaGnu framework make it easy to
166 write tests for any program, with either batch-oriented, or interactive
170 DejaGnu provides a layer of abstraction which allows you to write
171 tests that are portable to any host or target where a program must be
172 tested. For instance, a test for @code{GDB} can run from any
173 supported host system on any supported target system. DejaGnu runs
174 tests on many single board computers, whose operating software ranges
175 from a simple boot monitor to a real-time OS.
178 All tests have the same output format. This makes it easy to
179 integrate testing into other software development processes.
180 DejaGnu's output is designed to be parsed by other filtering script
181 and it is also human readable.
184 Using Tcl and Expect, it's easy to create wrappers for existing
185 testsuites. By incorporating existing tests under DejaGnu, it's
186 easier to have a single set of report analyse programs..
189 Running tests requires two things: the testing framework and the
190 testsuites themselves. Tests are usually written in Expect using Tcl,
191 but you can also use a Tcl script to run a testsuite that is not based
192 on Expect. Expect script filenames conventionally use @file{.exp} as
193 a suffix. For example, the main implementation of the DejaGnu test
194 driver is in the file @file{runtest.exp}.
196 @node Release Notes, Design goals, What is DejaGnu?, Introduction
197 @section New in this release
199 The following major, user-visible changes have been introduced since
205 Support for target communication via SSH has been added.
208 A large number of very old config and baseboard files have been
209 removed. If you need to resurrect these, you can get them from
210 version 1.5.3. If you can show that a board is still in use, it can
211 be put back in the distribution.
214 The @command{--status} command line option is now the default. This
215 means that any error in the testsuite Tcl scripts will cause runtest
216 to abort with exit status code 2. The @command{--status} option has
217 been removed from the documentation, but will continue to be accepted
218 for backward compatibility.
221 @command{runtest} now exits with exit code 0 if the testsuite
222 "passed", 1 if something unexpected happened (eg, FAIL, XPASS or
223 UNRESOLVED), and 2 if an exception is raised by the Tcl interpreter.
226 @command{runtest} now exits with the standard exit codes of programs
227 that are terminated by the SIGINT, SIGTERM and SIGQUIT signals.
230 The user-visible utility procedures @code{absolute}, @code{psource}
231 and @code{slay} have been removed. If a testsuite uses any of these
232 procedures, a copy of the procedure should be made and placed in the
233 lib directory of the testsuite.
236 Support was added for testing the D compiler.
239 @file{~/.dejagnurc} is now loaded last, not first. This allows the
240 user to have the ability to override anything in their environment
241 (even the @file{site.exp} file specified by @code{$DEJAGNU}).
244 The user-visible utility procedure @code{unsetenv} is
245 @strong{deprecated} and will be removed in the next release. If a
246 testsuite uses this procedure, a copy should be made and placed in the
247 lib directory of the testsuite.
251 @node Design goals, A POSIX Conforming Test Framework, Release Notes, Introduction
252 @section Design goals
255 DejaGnu grew out of the internal needs of Cygnus Solutions (formerly
256 Cygnus Support). Cygnus maintained and enhanced a variety of free
257 programs in many different environments and needed a testing tool
263 was useful to developers while fixing bugs;
266 automated running many tests during a software release process;
269 was portable among a variety of host computers;
272 supported a cross-development environment;
275 permitted testing of interactive programs like @code{GDB}; and
278 permitted testing of batch-oriented programs like @code{GCC}.
281 Some of the requirements proved challenging. For example, interactive
282 programs do not lend themselves very well to automated testing. But
283 all the requirements are important. For instance, it is imperative to
284 make sure that @code{GDB} works as well when cross-debugging as it
285 does in a native configuration.
287 Probably the greatest challenge was testing in a cross-development
288 environment. Most cross-development environments are customized by
289 each developer. Even when buying packaged boards from vendors there
290 are many differences. The communication interfaces vary from a serial
291 line to Ethernet. DejaGnu was designed with a modular communication
292 setup, so that each kind of communication can be added as required and
293 supported thereafter. Once a communication procedure is written, any
294 test can use it. Currently DejaGnu can use @code{ssh}, @code{rsh},
295 @code{rlogin}, @code{telnet}, @code{tip}, and @code{kermit} for remote
298 @node A POSIX Conforming Test Framework, Installation, Design goals, Introduction
299 @section A POSIX compliant test framework
300 @cindex POSIX compliant test framework
303 DejaGnu conforms to the POSIX 1003.3 standard for test frameworks.
304 Rob Savoye was a member of that committee.
306 POSIX standard 1003.3 defines what a testing framework needs to
307 provide to create a POSIX compliant testsuite. This standard is
308 primarily oriented to checking POSIX conformance, but its requirements
309 also support testing of features not related to POSIX conformance.
310 POSIX 1003.3 does not specify a particular testing framework, but at
311 this time there is only one other POSIX conforming test framework.
312 TET was created by Unisoft for a consortium comprised of X/Open, Unix
313 International and the Open Software Foundation.
316 The POSIX documentation refers to @dfn{assertions}. An assertion is a
317 description of behavior. For example, if a standard says ``The sun
318 shall shine'', a corresponding assertion might be ``The sun is
319 shining.'' A test based on this assertion would pass or fail
320 depending on whether it is day or night. It is important to note that
321 the standard being tested is never 1003.3; the standard being tested
322 is some other standard, for which the assertions were written.
324 As there is no testsuite to verify that testing frameworks are POSIX
325 1003.3 compliant, this is done by repeatedly reading the standard and
326 experimenting. One of the main things POSIX 1003.3 does specify is
327 the set of allowed output messages and their definitions. Four
328 messages are supported for a required feature of POSIX conforming
329 systems and a fifth for a conditional feature. DejaGnu supports all
330 five output messages. In this sense a testsuite that uses exactly
331 these messages can be considered POSIX compliant. These definitions
332 specify the output of a test case:
337 A test has succeeded. That is, it demonstrated that the assertion is
341 A test has not succeeded -- the assertion is false. The @emph{FAIL}
342 message is based on this test case only. Other messages are used to
343 indicate a failure of the framework. As with @emph{PASS}, POSIX tests
344 must return @emph{FAIL} rather than @emph{XFAIL} even if a failure was
348 POSIX 1003.3 does not incorporate the notion of expected failures, so
349 @emph{PASS}, instead of @emph{XPASS}, must also be returned for test
350 cases which were expected to fail and did not. This means that
351 @emph{PASS} is in some sense more ambiguous than if @emph{XPASS} is
355 A test produced indeterminate results. Usually, this means the test
356 executed in an unexpected fashion. This outcome requires a human to
357 go over results to determine if the test should have passed or failed.
358 This message is also used for any test that requires human
359 intervention because it is beyond the abilities of the testing
360 framework. Any unresolved test should resolved to @emph{PASS} or
361 @emph{FAIL} before a test run can be considered finished.
363 Note that for POSIX, each assertion must produce a test result code.
364 If the test isn't actually run, it must produce @emph{UNRESOLVED}
365 rather than just leaving that test out of the output. This means that
366 you have to be careful when writing tests to not carelessly use Tcl
367 commands like @emph{return}---if you alter the flow of control of the
368 Tcl code you must insure that every test still produces some result
371 Here are some of the ways a test may wind up @emph{UNRESOLVED}:
377 Execution of a test is interrupted.
380 A test does not produce a clear result. This is usually because there
381 was an @emph{ERROR} from DejaGnu while processing the test, or because
382 there were three or more @emph{WARNING} messages. Any @emph{WARNING}
383 or @emph{ERROR} messages can invalidate the output of the test. This
384 usually requires a human to examine the output to determine what
385 really happened -- and to improve the test case.
388 A test depends on a previous test, which has failed.
391 The test was set up incorrectly.
394 A test script aborts due to a Tcl error. In this case, the DejaGnu
395 framework inserts an @emph{UNRESOLVED} result as a placeholder for an
396 unknown number of tests that were not run because the script crashed.
402 A test was not run. This is a placeholder used when there is no real
409 There is no support for the tested case. This may mean that a
410 conditional feature of an operating system, or of a compiler, is not
411 implemented. DejaGnu also uses this message when a testing
412 environment (often a ``bare board'' target) lacks basic support for
413 compiling or running the test case. For example, a test for the
414 system subroutine @emph{gethostname} would never work on a target
415 board running only a boot monitor.
418 DejaGnu uses the same output procedures to produce these messages for
419 all testsuites and these procedures are already known to conform to
420 POSIX 1003.3. For a DejaGnu testsuite to conform to POSIX 1003.3, you
421 must avoid the @emph{setup_xfail} procedure as described in the
422 @emph{PASS} section above and you must be careful to return
423 @emph{UNRESOLVED} where appropriate, as described in the
424 @emph{UNRESOLVED} section above.
426 @node Installation, , A POSIX Conforming Test Framework, Introduction
427 @section Installation
429 Refer to the @file{INSTALL} in the source distribution for detailed
430 installation instructions. Note that there is no compilation step as
431 with many other GNU packages, as DejaGnu consists of interpreted code
434 Save for its own small testsuite, the DejaGnu distribution does not
435 include any testsuites. Testsuites for the various GNU development
436 tools are included with those packages. After configuring the
437 top-level DejaGnu directory, unpack and configure the test directories
438 for the tools you want to test; then, in each test directory, run
439 @emph{make check} to build auxiliary programs required by some of the
440 tests, and run the test suites.
442 @node Running tests, Running other DejaGnu commands, Introduction, Top
443 @chapter Running tests
445 There are two ways to execute a testsuite. The most common way is
446 when there is existing support in the @file{Makefile} of the tool
447 being tested. This usually consists of a @emph{check} target. The
448 other way is to execute the @code{runtest} program directly. To run
449 @code{runtest} directly from the command line requires either all of
450 the correct command line options, or a @ref{Local configuration file}
451 must be set up correctly.
454 * Running `make check': Make Check.
455 * Running runtest: Runtest.
456 * Output files: Output Files.
459 @node Make Check, Runtest, , Running tests
460 @section Running `make check'
462 To run tests from an existing collection, first use @code{configure}
463 as usual to set up the build directory. Then type @code{make check}.
464 If the @emph{check} target exists, it usually saves you some trouble.
465 For instance, it can set up any auxiliary programs or other files
466 needed by the tests. The most common file the @emph{check} target
467 depends on is the @file{site.exp} file. The @file{site.exp} contains
468 various variables that DejaGnu uses to determine the configuration of
469 the program being tested.
471 Once you have run @emph{make check} to build any auxiliary files, you
472 can invoke the test driver @code{runtest} directly to repeat the
473 tests. You will also have to execute @code{runtest} directly for test
474 collections with no @emph{check} target in the @file{Makefile}.
476 GNU Automake has built-in support for DejaGnu. To add DejaGnu support
477 to your generated @file{Makefile.in}, just add the keyword
478 @code{dejagnu} to the AUTOMAKE_OPTIONS variable in @file{Makefile.am}.
479 This will ensure that the generated @file{Makefile.in} has a
480 @code{check} target that invokes DejaGnu correctly. @xref{Tests,,
481 DejaGnu Tests, automake, The GNU Automake Manual}.
483 @node Runtest, Output Files, Make Check, Running tests
484 @section Running runtest
487 @code{runtest} is the test driver for DejaGnu. You can specify two
488 kinds of things on the @code{runtest} command line: command line
489 options, and Tcl variables that are passed to the test scripts. The
490 options are listed alphabetically below.
492 @code{runtest} returns one of the following exit codes:
496 if all tests passed including expected failures and unsupported tests.
498 if any test failed, passed unexpectedly, or was unresolved.
500 if Expect encountered any error in the test scripts.
506 * Common Options: Common Operations.
509 @node Output States, Invoking runtest, , Runtest
510 @subsection Output States
511 @cindex output states
513 @file{runtest} flags the outcome of each test as one of these cases.
514 See @ref{A POSIX Conforming Test Framework} for a discussion of how
515 POSIX specifies the meanings of these cases.
520 The most desirable outcome: the test was expected to succeed and did
524 A pleasant kind of failure: a test was expected to fail, but
525 succeeded. This may indicate progress; inspect the test case to
526 determine whether you should amend it to stop expecting failure.
529 A test failed, although it was expected to succeed. This may indicate
530 regress; inspect the test case and the failing software to locate the
534 A test failed, but it was expected to fail. This result indicates no
535 change in a known bug. If a test fails because the operating system
536 where the test runs lacks some facility required by the test, the
537 outcome is @emph{UNSUPPORTED} instead.
540 Output from a test requires manual inspection; the testsuite could not
541 automatically determine the outcome. For example, your tests can
542 report this outcome is when a test does not complete as expected.
545 A test case is not yet complete, and in particular cannot yet produce
546 a @emph{PASS} or @emph{FAIL}. You can also use this outcome in dummy
547 ``tests'' that note explicitly the absence of a real test case for a
551 A test depends on a conditionally available feature that does not
552 exist (in the configured testing environment). For example, you can
553 use this outcome to report on a test case that does not work on a
554 particular target because its operating system support does not
555 include a required subroutine.
558 @code{runtest} may also display the following messages:
563 Indicates a major problem (detected by the test case itself) in
564 running the test. This is usually an unrecoverable error, such as a
565 missing file or loss of communication to the target. POSIX testsuites
566 should not emit this message; use @emph{UNSUPPORTED}, @emph{UNTESTED},
567 or @emph{UNRESOLVED} instead, as appropriate.
570 Indicates a possible problem in running the test. Usually warnings
571 correspond to recoverable errors, or display an important message
572 about the following tests.
575 An informational message about the test case.
578 @node Invoking runtest, Common Operations, Output States, Runtest
579 @subsection Invoking runtest
580 @cindex runtest, invoking
582 This is the full set of command line options that @code{runtest}
583 recognizes. Option names may be abbreviated to the shortest unique
588 @item @code{-a}, @code{--all}
589 Display all test output. By default, @emph{runtest} shows only the
590 output of tests that produce unexpected results; that is, tests with
591 status @emph{FAIL} (unexpected failure), @emph{XPASS} (unexpected
592 success), or @emph{ERROR} (a severe error in the test case itself).
593 Specify @code{--all} to see output for tests with status @emph{PASS}
594 (success, as expected) @emph{XFAIL} (failure, as expected), or
595 @emph{WARNING} (minor error in the test case itself).
597 @item @code{--build [triplet]}
598 @emph{triplet} is a system triplet of the form
599 @emph{cpu-manufacturer-os}. This is the type of machine DejaGnu and
600 the tools to be tested are built on. For a normal cross environment
601 this is the same as the host, but for a Canadian cross, they are
604 @item @code{-D0}, @code{-D1}
605 Start the internal Tcl debugger. The Tcl debugger supports
606 breakpoints, single stepping, and other common debugging activities.
607 See the document @uref{http://expect.sourceforge.net/doc/tcl-debug.ps,
608 Debugger for Tcl Applications} by Don Libes. If you specify
609 @emph{-D1}, the @emph{expect} shell stops at a breakpoint as soon as
610 DejaGnu invokes it. If you specify @emph{-D0}, DejaGnu starts as
611 usual, but you can enter the debugger by sending an interrupt (e.g. by
612 typing @key{Ctrl}-@key{c}).
615 Turns on the Expect internal debugging output. Debugging output is
616 displayed as part of the @emph{runtest} output, and logged to a file
617 called @file{dbg.log}. The extra debugging output does @emph{not}
618 appear on standard output, unless the verbose level is greater than 2
619 (for instance, to see debug output immediately, specify @code{--debug
620 -v -v}). The debugging output shows all attempts at matching the test
621 output of the tool with the scripted patterns describing expected
622 output. The output generated with @code{--strace} also goes into
625 @item @code{--global_init [name]}
626 Use @emph{name} as the global init file instead of @file{site.exp} in
627 @emph{libdir}. The default is, of course, @file{site.exp}. Note that
628 this option accepts a relative file name, interpreted starting at
629 @emph{libdir}, so a file in a subdirectory may be used. This is
630 probably less useful for most sites, but is orthogonal with the
631 @code{--local_init} option and may be useful in large testing labs.
634 Prints out a short summary of the @emph{runtest} options, then exits
635 (even if you specify other options).
637 @item @code{--host [triplet]}
638 @emph{triplet} is a system triplet of the form
639 @emph{cpu-manufactuer-os}. Use this option to override the default
640 string recorded by your configuration's choice of host. This choice
641 does not change how anything is actually configured unless --build is
642 also specified; it affects @emph{only} DejaGnu procedures that compare
643 the host string with particular values. The procedures @emph{ishost},
644 @emph{istarget}, @emph{isnative}, and @emph{setup_xfail} are affected
645 by @code{--host}. In this usage, @emph{host} refers to the machine
646 that the tests are to be run on, which may not be the same as the
647 @emph{build} machine. If @code{--build} is also specified, then
648 @code{--host} refers to the machine that the tests will be run on, not
649 the machine DejaGnu is run on.
651 @item @code{--host_board [name]}
652 The host board to use.
654 @item @code{--ignore [tests(s)] }
655 The name(s) of specific tests to ignore.
657 @item @code{--local_init [name]}
658 Use @emph{name} as the testsuite local init file instead of
659 @file{site.exp} in the current directory and in @emph{objdir}. The
660 default is, of course, @file{site.exp}. Note that this option accepts
661 a relative file name, so a file in a subdirectory may be used.
663 @item @code{--log_dialog}
664 Emit Expect output to stdout. The Expect output is usually only
665 written to the @file{.log} file. By enabling this option, they are
666 also printed to standard output.
668 @item @code{--mail [address(es)]}
669 Send test results to one or more email addresses.
671 @item @code{--objdir [path]}
672 Use @emph{path} as the top directory containing any auxiliary compiled
673 test code. The default is '.'. Use this option to locate
674 pre-compiled test code. You can normally prepare any auxiliary files
675 needed with @emph{make}.
677 @item @code{--outdir [path]}
678 Write log files in directory @file{path}. The default is '.', the
679 directory where you start @emph{runtest}. This option affects only
680 the summary (@file{.sum}) and the detailed log files (@file{.log}).
681 The DejaGnu debug log @file{dbg.log} always appears (when requested)
682 in the local directory.
684 @item @code{--reboot [name]}
685 Reboot the target board when @code{runtest} starts. When running
686 tests on a separate target board, it is safer to reboot the target to
687 be certain of its state. However, when developing test scripts,
688 rebooting can take a lot of time.
690 @item @code{--srcdir [path]}
691 Use @file{path} as the top directory for test scripts to run.
692 @emph{runtest} looks in this directory for any subdirectory whose name
693 begins with the toolname (specified with @code{--tool}). For
694 instance, with @code{--tool gdb}, @emph{runtest} uses tests in
695 subdirectories @file{gdb.*} (with the usual shell-like filename
696 expansion). If you do not use @code{--srcdir}, @emph{runtest} looks
697 for test directories under the current working directory.
699 @item @code{--strace [n]}
700 Turn on internal tracing for @emph{expect}, to n levels deep. By
701 adjusting the level, you can control the extent to which your output
702 expands multi-level Tcl statements. This allows you to ignore some
703 levels of @emph{case} or @emph{if} statements. Each procedure call or
704 control structure counts as one ``level''. The output is recorded in
705 the same file, @file{dbg.log}, used for output from @code{--debug}.
707 @item @code{--target [triplet]}
708 Use this option to override the default setting (native testing).
709 @emph{triplet} is a system triplet of the form
710 @emph{cpu-manufacturer-os}. This option changes the configuration
711 @code{runtest} uses for the default tool names, and other setup
714 @item @code{--target_board [name(s)]}
715 The list of target boards to run tests on.
717 @item @code{--tool [name(s)]}
718 Specifies which testsuite to run, and what initialization module to
719 use. @code{--tool} is used @emph{only} for these two purposes. It is
720 @emph{not} used to name the executable program to test. Executable
721 tool names (and paths) are recorded in @file{site.exp} and you can
722 override them by specifying Tcl variables on the command line.
724 For example, including @code{--tool} gcc on the command line runs
725 tests from all test subdirectories whose names match @file{gcc.*}, and
726 uses one of the initialization modules named @file{config/*-gcc.exp}.
727 To specify the name of the compiler (perhaps as an alternative path to
728 what @emph{runtest} would use by default), use @emph{GCC=path-to-gcc}
729 on the @emph{runtest} command line.
731 @item @code{--tool_exec [name]}
732 The path to the tool executable to test.
734 @item @code{--tool_opts [options]}
735 A list of additional options to pass to the tool.
737 @item @code{-v}, @code{--verbose}
738 Turns on more output. Repeating this option increases the amount of
739 output displayed. Level one (@emph{-v}) is simply test output. Level
740 two (@emph{-v -v}) shows messages on options, configuration, and
741 process control. Verbose messages appear in the detailed
742 (@file{*.log}) log file, but not in the summary (@file{*.sum}) log
745 @item @code{-V}, @code{--version}
746 Prints out the version numbers of DejaGnu, Expect, and Tcl.
748 @item @code{-x}, @code{--xml}
749 Generate XML output. The output file is named after the tool with an
752 @item @file{testfile}.exp[=arg(s)]
753 Specify the names of testsuites to run. By default, @emph{runtest}
754 runs all tests for the tool, but you can restrict it to particular
755 testsuites by giving the names of the @emph{.exp} scripts that control
756 them. @emph{testsuite}.exp cannot include directory names, only plain
759 @code{arg(s)} specifies a subset of test cases to run. For compiler
760 or assembler tests, which often use a single @emph{.exp} script
761 covering many different test case files, this option allows you to
762 further restrict the tests by listing particular test cases. For
763 larger testsuites such as that included in GCC, this can save a lot of
764 time. Some tools support wildcards here, but this varies from tool to
765 tool. Typically the wildcards @emph{?}, @emph{*}, and @emph{[chars]}
768 @item @code{tclvar}=value
769 You can define Tcl variables for use by your test scripts in the same
770 style used with @emph{make} for environment variables. For example,
771 @emph{runtest GDB=gdb.old} defines a variable called @code{GDB}; when
772 your scripts refer to @code{$GDB} in this run, they use the value
775 The default Tcl variables used for most tools are defined in the main
776 DejaGnu @emph{Makefile}; their values are captured in the
777 @file{site.exp} file.
780 @node Common Operations, , Invoking runtest, Runtest
781 @subsection Common Options
782 @cindex options, common
784 Typically, you don't need to use any command line options. The
785 @code{--tool} option is only required when there is more than one
786 testsuite in the same directory. The default options are in the local
787 @file{site.exp} file, created by @code{make site.exp}.
789 For example, if the directory @file{gdb/testsuite} contains a
790 collection of DejaGnu tests for GDB, you can run them like this:
797 The test output follows, then ends with:
802 # of expected passes 508
803 # of expected failures 103
804 /usr/latest/bin/gdb version 4.14.4 -nx
807 You can use the option @code{--srcdir} to point to some other
808 directory containing a collection of tests:
811 $ runtest --srcdir /devo/gdb/testsuite
814 By default, @code{runtest} prints only the names of the tests it runs,
815 output from any tests that have unexpected results, and a summary
816 showing how many tests passed and how many failed. To display output
817 from all tests (whether or not they behave as expected), use the
818 @code{-a} (all) option. For more verbose output about processes being
819 run, communication, and so on, use @code{-v} (verbose). To see even
820 more output, use multiple @code{-v} options. See @ref{Invoking
821 runtest} for a more detailed explanation of each @code{runtest}
824 @node Output Files, , Runtest, Running tests
825 @section Output files
827 DejaGnu always writes two kinds of output files. Summary output is
828 written to the @file{.sum} file, and detailed output is written to the
829 @file{.log} file. The tool name determines the prefix for these
830 files. For example, after running with @code{--tool gdb}, the output
831 files will be called @file{gdb.sum} and @file{gdb.log}. For
832 troubleshooting, a debug log file that logs the operation of Expect is
833 available. Each of these will be described in turn.
837 * Detailed log file::
841 @node Summary log file, Detailed log file, , Output Files
842 @subsection Summary log file
843 @cindex output file, summary log
845 DejaGnu always produces a summary (@file{.sum}) output file. This
846 summary lists the names of all test files run. For each test file,
847 one line of output from each @code{pass} command (showing status
848 @emph{PASS} or @emph{XPASS}) or @code{fail} command (status
849 @emph{FAIL} or @emph{XFAIL}), trailing summary statistics that count
850 passing and failing tests (expected and unexpected), the full pathname
851 of the tool tested, and the version number of the tool. All possible
852 outcomes, and all errors, are always reflected in the summary output
853 file, regardless of whether or not you specify @code{--all}.
855 If any of your tests use the procedures @code{unresolved},
856 @code{unsupported}, or @code{untested}, the summary output also
857 tabulates the corresponding outcomes.
859 For example, after running @code{runtest --tool binutils} a summary
860 log file will be written to @file{binutils.sum}. Normally, DejaGnu
861 writes this file in your current working directory. Use the
862 @code{--outdir} option to select a different output directory.
864 @strong{Sample summary log}
867 Test Run By bje on Sat Nov 14 21:04:30 AEDT 2015
871 Running ./gdb.t00/echo.exp ...
873 Running ./gdb.all/help.exp ...
874 PASS: help add-symbol-file
876 PASS: help breakpoint "bre" abbreviation
877 FAIL: help run "r" abbreviation
878 Running ./gdb.t10/crossload.exp ...
879 PASS: m68k-elf (elf-big) explicit format; loaded
880 XFAIL: mips-ecoff (ecoff-bigmips) "ptype v_signed_char" signed C types
882 @ === gdb Summary ===
884 # of expected passes 5
885 # of expected failures 1
886 # of unexpected failures 1
887 /usr/latest/bin/gdb version 4.6.5 -q
891 @node Detailed log file, Debug log file, Summary log file, Output Files
892 @subsection Detailed log file
893 @cindex output file, detailed log
895 DejaGnu also saves a detailed log file (@file{.log}), showing any
896 output generated by test cases as well as the summary output. For
897 example, after running @code{runtest --tool binutils}, a detailed log
898 file will be written to @file{binutils.log}. Normally, DejaGnu writes
899 this file in your current working directory. Use the @code{--outdir}
900 option to select a different output directory.
902 @strong{Sample detailed log for g++ tests}
905 Test Run By bje on Sat Nov 14 21:07:23 AEDT 2015
909 Running ./g++.other/t01-1.exp ...
912 Running ./g++.other/t01-2.exp ...
914 p0000646.C: In function `int warn_return_1 ()':
915 p0000646.C:109: warning: control reaches end of non-void function
916 p0000646.C: In function `int warn_return_arg (int)':
917 p0000646.C:117: warning: control reaches end of non-void function
918 p0000646.C: In function `int warn_return_sum (int, int)':
919 p0000646.C:125: warning: control reaches end of non-void function
920 p0000646.C: In function `struct foo warn_return_foo ()':
921 p0000646.C:132: warning: control reaches end of non-void function
922 Running ./g++.other/t01-4.exp ...
924 900403_04.C:8: zero width for bit-field `foo'
925 Running ./g++.other/t01-3.exp ...
926 FAIL: segment violation
927 900519_12.C:9: parse error before `;'
928 900519_12.C:12: Segmentation violation
929 /usr/latest/bin/gcc: Internal compiler error: program cc1plus got fatal signal
931 @ === g++ Summary ===
933 # of expected passes 1
934 # of expected failures 3
935 /usr/latest/bin/g++ version cygnus-2.0.1
939 @node Debug log file, , Detailed log file, Output Files
940 @subsection Debug log file
941 @cindex output file, debug log
943 The @code{runtest} option @code{--debug} creates a file showing the
944 output from Expect in debugging mode. The @file{dbg.log} file is
945 created in the current directory. The log file shows the string sent
946 to the tool being tested by each @code{send} command and the pattern
947 it compares with the tool output by each @code{expect} command.
949 The log messages begin with a message of the form:
952 expect: does @{tool output@} (spawn_id n)
953 match pattern @{expected pattern@}?
956 For every unsuccessful match, Expect issues a @emph{no} after this
957 message. If other patterns are specified for the same Expect command,
958 they are reflected also, but without the first part of the message
959 (@emph{expect... match pattern}).
961 When Expect finds a match, the log for the successful match ends with
962 @emph{yes}, followed by a record of the Expect variables set to
963 describe a successful match.
965 @strong{Example debug log file for a GDB test}
968 send: sent @{break gdbme.c:34\n@} to spawn id 6
969 expect: does @{@} (spawn_id 6) match pattern @{Breakpoint.*at.* file
970 gdbme.c, line 34.*\(gdb\) $@}? no
972 expect: does @{@} (spawn_id 0) match pattern @{return@} ? no
981 Breakpoint 8 at 0x23d8: file gdbme.c, line 34.
982 (gdb) expect: does @{break gdbme.c:34\r\nBreakpoint 8 at 0x23d8:
983 file gdbme.c, line 34.\r\n(gdb) @} (spawn_id 6) match pattern
984 @{Breakpoint.*at.* file gdbme.c, line 34.*\(gdb\) $@}? yes
985 expect: set expect_out(0,start) @{18@}
986 expect: set expect_out(0,end) @{71@}
987 expect: set expect_out(0,string) @{Breakpoint 8 at 0x23d8: file
988 gdbme.c, line 34.\r\n(gdb) @}
989 epect: set expect_out(spawn_id) @{6@}
990 expect: set expect_out(buffer) @{break gdbme.c:34\r\nBreakpoint 8
991 at 0x23d8: file gdbme.c, line 34.\r\n(gdb) @}
992 PASS: 70 0 breakpoint line number in file
996 This example exhibits three properties of Expect and DejaGnu that
997 might be surprising at first glance:
1002 Empty output for the first attempted match. The first set of
1003 attempted matches shown ran against the output @emph{@{@}} --- that
1004 is, no output. Expect begins attempting to match the patterns
1005 supplied immediately; often, the first pass is against incomplete
1006 output (or completely before all output, as in this case).
1009 Interspersed tool output. The beginning of the log entry for the
1010 second attempted match may be hard to spot: this is because the prompt
1011 @emph{@{(gdb) @}} appears on the same line, just before the
1012 @emph{expect:} that marks the beginning of the log entry.
1015 Fail-safe patterns. Many of the patterns tested are fail-safe
1016 patterns provided by GDB testing utilities, to reduce possible
1017 indeterminacy. It is useful to anticipate potential variations caused
1018 by extreme system conditions (GDB might issue the message
1019 @emph{virtual memory exhausted} in rare circumstances), or by changes
1020 in the tested program (@emph{Undefined command} is the likeliest
1021 outcome if the name of a tested command changes).
1023 The pattern @emph{@{return@}} is a particularly interesting fail-safe
1024 to notice; it checks for an unexpected @key{RET} prompt. This may
1025 happen, for example, if the tested tool can filter output through a
1028 These fail-safe patterns (like the debugging log itself) are primarily
1029 useful while developing test scripts. Use the @code{error} procedure
1030 to make the actions for fail-safe patterns produce messages starting
1031 with @emph{ERROR} on standard output, and in the detailed log file.
1035 @node Running other DejaGnu commands, Customizing DejaGnu, Running tests, Top
1036 @chapter Running other DejaGnu commands
1038 DejaGnu now features auxiliary commands not directly related to
1039 running tests, but somehow related to the broader purpose of testing.
1041 These commands are run via the @command{dejagnu} multiplex launcher,
1042 which locates an appropriate script and the required interpreter and
1043 then runs the requested command.
1046 * Invoking dejagnu:: Command line options for the launcher itself.
1047 * Invoking dejagnu help:: Reading man pages for dejagnu subcommands.
1048 * Invoking dejagnu report card:: Summarizing test results from many tools.
1051 @node Invoking dejagnu, Invoking dejagnu help, Running other DejaGnu commands, Running other DejaGnu commands
1052 @section Invoking @command{dejagnu}
1053 @cindex dejagnu, invoking
1055 The @command{dejagnu} launcher is primarily designed to pass most
1056 options on to the scripts that it runs, but does process the
1057 @option{--help} and @option{--version} options entirely internally,
1058 while also recognizing the @option{--verbose} option.
1061 @command{dejagnu} <command> [options...]
1062 @command{dejagnu} --help
1063 @command{dejagnu} --version
1066 Note that the command names may contain multiple words. In this case,
1067 the command can be given as separate arguments to @command{dejagnu} or
1068 combined with dashes (@samp{-}); both forms are equivalent.
1070 All words of the command name must appear before any options. The
1071 search for a command terminates when an option is found.
1073 Note that the first valid command found is used. A longer command
1074 name can be shadowed by a shorter command name that happens to be a
1075 prefix of the longer name, if the command name is given as multiple
1076 arguments. The equivalent form with the longer command name combined
1077 using dashes into a single argument will correctly refer to the
1078 otherwise shadowed command.
1080 The @command{dejagnu} launcher can also be run using symbolic links,
1081 provided that the shell places the name under which @command{dejagnu}
1082 was invoked in @code{$0}. Any dash-separated words after ``dejagnu''
1083 in the name of such a link are taken to be the leading words of a
1086 The @command{dejagnu} launcher supports alternate implementations
1087 depending upon available interpreters.
1089 Options for the @command{dejagnu} launcher itself cannot be
1090 abbreviated, since the launcher has no way to know which abbreviations
1091 are unique and which would be ambiguous to the invoked command.
1096 Print a help message instead of running a command.
1098 @item @code{-V}, @code{--version}
1099 Print a version banner for the launcher itself including the version
1100 of DejaGnu. Any command given is ignored.
1102 @item @code{-v}, @code{--verbose}
1103 Emit additional output describing the inner workings of the
1104 @command{dejagnu} launcher. This option is also passed on to the
1109 All arguments after the command name are passed to the invoked
1112 @node Invoking dejagnu help, Invoking dejagnu report card, Invoking dejagnu, Running other DejaGnu commands
1113 @section Invoking @command{dejagnu help}
1114 @cindex dejagnu help, invoking
1116 The @command{dejagnu help} tool displays long-form documentation for
1117 DejaGnu auxiliary commands that are invoked using the
1118 @command{dejagnu} launcher.
1121 @command{dejagnu help} [options...] <command>
1124 Again, command names may contain multiple words. This command forms
1125 an operand by joining all words in the command name using dashes
1126 (@samp{-}) and prepending @samp{dejagnu-}. This is then used as the
1127 name of a manual page and passed to the @command{man} command.
1129 If the manual page is in a particular directory relative to the script
1130 implementing this command, a full file name is produced, otherwise,
1131 @command{man} performs its normal search.
1133 The @option{--verbose} option causes additional output describing the
1134 inner workings of the @command{dejagnu help} command to be produced.
1136 The @option{--path}, @option{-w}, and @option{-W} options are passed
1139 @node Invoking dejagnu report card, , Invoking dejagnu help, Running other DejaGnu commands
1140 @section Invoking @command{dejagnu report card}
1141 @cindex dejagnu report card, invoking
1142 @cindex dejagnu report-card, invoking
1144 The @command{dejagnu report card} tool produces a tabular summary of
1145 the results from test runs by reading the summary files that DejaGnu
1149 @command{dejagnu report card} [<option>|<tool>|<file>]...
1152 The @option{--verbose} option causes additional output describing the
1153 inner workings of the @command{dejagnu report card} command to be
1156 Aside from options, the command may include a list of tools or files.
1157 Names ending in @samp{.sum} are used as-is. Names ending in
1158 @samp{.log} are changed to instead refer to the summary file. Names
1159 ending with a simple dot (@samp{.}) have @samp{sum} appended, for
1160 convenience when using Readline filename completion in a shell, which
1161 will complete to the dot, since there are both @samp{.sum} and
1162 @samp{.log} files produced for each tool tested. Lastly, all other
1163 names are taken as tool names and @samp{.sum} is appended to refer to
1164 the summary file produced by DejaGnu.
1166 The relevant summary files are read and an ASCII-art table is
1167 produced. The table has columns for counts of tests passed, failed,
1168 unsupported, unresolved, and untested. Tests that are expected to
1169 pass and tests that are expected to fail are counted in separate
1170 columns, but known failures (@samp{KFAIL} and @samp{KPASS}) are
1171 summarized together with expected failures (@samp{XFAIL} and
1172 @samp{XPASS}) in two additional columns: @samp{?PASS} and
1173 @samp{?FAIL}. Additionally, if a test produced any warnings or
1174 errors, tags @samp{!W!} or @samp{!E!} are added at the end of the row.
1176 If DejaGnu's multiple-pass testing features were used, the table
1177 features an additional group of summary rows reporting totals for each
1178 named pass across all tools that ran that pass. Lastly, the table
1179 ends with an unmarked grand total row reporting totals for all tools
1180 across all testing passes.
1182 @node Customizing DejaGnu, Extending DejaGnu, Running other DejaGnu commands, Top
1183 @chapter Customizing DejaGnu
1184 @cindex customization
1186 The site configuration file, @file{site.exp}, captures
1187 configuration-dependent values and propagates them to the DejaGnu test
1188 environment using Tcl variables. This ties the DejaGnu test scripts
1189 into the @code{configure} and @code{make} programs. If this file is
1190 setup correctly, it is possible to execute a testsuite merely by
1191 typing @code{runtest}.
1193 DejaGnu supports two @file{site.exp} files. The multiple instances of
1194 @file{site.exp} are loaded in a fixed order. The first file loaded is
1195 the local file @file{site.exp}, and then the optional global
1196 @file{site.exp} file as pointed to by the @code{DEJAGNU} environment
1199 There is an optional global @file{site.exp}, containing configuration
1200 values that apply to DejaGnu site-wide. @code{runtest} loads these
1201 values first. The global @file{site.exp} contains the default values
1202 for all targets and hosts supported by DejaGnu. This global file is
1203 identified by setting the environment variable @code{DEJAGNU} to the
1204 name of the file. If @code{DEJAGNU} is set, but the file cannot be
1205 located, an error will be raised and @code{runtest} will abort.
1207 Any directory containing a configured testsuite also has a local
1208 @file{site.exp}, capturing configuration values specific to the tool
1209 being tested. Since @code{runtest} loads these values last, the
1210 individual test configuration can either rely on and use, or override,
1211 any of the global values from the global @file{site.exp} file.
1213 You can usually generate or update the testsuite's local
1214 @file{site.exp} by typing @code{make site.exp} in the testsuite
1215 directory, after the test suite is configured.
1217 You can also have a file in your home directory called
1218 @file{.dejagnurc}. This gets loaded after the other config files.
1219 Usually this is used for personal stuff, like setting the
1220 @code{all_flag} so all the output gets printed, or your own verbosity
1221 levels. This file is usually restricted to setting command line
1224 You can further override the default values in a user-editable section
1225 of any @file{site.exp}, or by setting variables on the @code{runtest}
1229 * Local configuration file::
1230 * Global configuration file::
1231 * Board configuration file::
1232 * Remote host testing::
1233 * Configuration file values::
1236 @node Global configuration file, Local configuration file, , Customizing DejaGnu
1237 @section Global configuration file
1238 @cindex configuration file, global
1240 The global configuration file is where all the target specific
1241 configuration variables for a site are set. For example, a
1242 centralized testing lab where multiple developers have to share an
1243 embedded development board. There are settings for both remote hosts
1244 and remote targets. Below is an example of a global configuration
1245 file for a Canadian cross environment. A Canadian cross is a
1246 toolchain that is built on, runs on, and targets three different
1247 system triplets (for example, building a Solaris-hosted MIPS R4000
1248 toolchain on a GNU/Linux system). This example is based on a
1249 configuration once used at Cygnus.
1251 @strong{Example global configuration file}
1254 # Make sure we look in the right place for the board description files.
1255 lappend boards_dir "/nfs/cygint/s1/cygnus/dejagnu/boards"
1257 verbose "Global config file: target_triplet is $target_triplet" 2
1260 switch -glob -- $target_triplet @{
1262 @ set target_list "unix"
1265 @ set target_list "sparc64-sim"
1268 @ set target_list "mips-sim wilma barney"
1271 @ set target_list "mips-lsi-sim@{,soft-float,el@}"
1276 In this case, we have support for several cross compilers, that all
1277 run on this host. To run DejaGnu tests on tools hosted on operating
1278 systems that do not run Expect, DejaGnu can be run on the build
1279 machine and connect to the remote host to run all the tests. As you
1280 can see, all one does is set the variable @code{target_list} to the
1281 list of targets and options to test.
1283 In this example, simple cases like @emph{sparc64-elf} only require
1284 setting the name of the single board configuration file. The
1285 @emph{mips-elf} target is more complicated and sets the list to three
1286 target boards. @emph{mips-sim} is a symbolic name for a simulator
1287 ``board'' and @emph{wilma} and @emph{barney} are symbolic names for
1288 physical boards. Symbolic names are covered in the @ref{Adding a new
1289 board} section. The more complicated example is the entry for
1290 @emph{mips-lsi-elf}. This one runs the tests with multiple iterations
1291 using all possible combinations of the @code{--soft-float} and the
1292 @code{--el} (little endian) options. The braced string includes an
1293 initial comma so that the set of combinations includes no options at
1294 all. Needless to say, this last target example is mostly specific to
1297 @node Local configuration file, Board configuration file, Global configuration file, Customizing DejaGnu
1298 @section Local configuration file
1299 @cindex configuration file, local
1301 It is usually more convenient to keep these @emph{manual overrides} in
1302 the @file{site.exp} local to each test directory, rather than in the
1303 global @file{site.exp} in the installed DejaGnu library. This file is
1304 mostly for supplying tool specific info that is required by the
1307 All local @file{site.exp} files have two sections, separated by
1308 comments. The first section is generated by @code{make}. It is
1309 essentially a collection of Tcl variable definitions based on
1310 @file{Makefile} environment variables. Since they are generated by
1311 @code{make}, they contain the values as specified by @code{configure}.
1312 In particular, this section contains the @file{Makefile} variables for
1313 host and target configuration data. Do not edit this first section;
1314 if you do, your changes will be overwritten the next time you run
1315 @code{make}. The first section starts with:
1318 ## these variables are automatically generated by make ##
1319 # Do not edit here. If you wish to override these values
1320 # add them to the last section
1323 In the second section, you can override any default values for all the
1324 variables. The second section can also contain your preferred
1325 defaults for all the command line options to @code{runtest}. This
1326 allows you to easily customize @code{runtest} for your preferences in
1327 each configured testsuite tree, so that you need not type options
1328 repeatedly on the command line. The second section may also be empty
1329 if you do not wish to override any defaults.
1331 @strong{The first section ends with this line}
1334 ## All variables above are generated by configure. Do Not Edit ##
1337 You can make any changes under this line. If you wish to redefine a
1338 variable in the top section, then just put a duplicate value in this
1339 second section. Usually the values defined in this configuration file
1340 are related to the configuration of the test run. This is the ideal
1341 place to set the variables @code{host_triplet}, @code{build_triplet},
1342 @code{target_triplet}. All other variables are tool dependent, i.e.,
1343 for testing a compiler, the value for @code{CC} might be set to a
1344 freshly built binary, as opposed to one in the user's path.
1346 Here's an example local site.exp file, as used for GCC/G++ testing.
1348 @strong{Local Configuration File}
1351 ## these variables are automatically generated by make ##
1352 # Do not edit here. If you wish to override these values
1353 # add them to the last section
1354 set rootme "/build/devo-builds/i686-pc-linux-gnu/gcc"
1355 set host_triplet i686-pc-linux-gnu
1356 set build_triplet i686-pc-linux-gnu
1357 set target_triplet i686-pc-linux-gnu
1358 set target_alias i686-pc-linux-gnu
1360 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++"
1361 append LDFLAGS " -L/build/devo-builds/i686-pc-linux-gnu/gcc/../ld"
1362 set tmpdir /build/devo-builds/i686-pc-linux-gnu/gcc/testsuite
1363 set srcdir "$@{srcdir@}/testsuite"
1364 ## All variables above are generated by configure. Do Not Edit ##
1367 This file defines the required fields for a local configuration file,
1368 namely the three system triplets, and the srcdir. It also defines
1369 several other Tcl variables that are used exclusively by the GCC
1370 testsuite. For most test cases, the CXXFLAGS and LDFLAGS are supplied
1371 by DejaGnu itself for cross testing, but to test a compiler, GCC needs
1372 to manipulate these itself.
1374 @vindex test_timeout
1375 The local @file{site.exp} may also set Tcl variables such as
1376 @code{test_timeout} which can control the amount of time (in seconds)
1377 to wait for a remote test to complete. If not specified,
1378 @code{test_timeout} defaults to 120 or 300 seconds, depending on the
1379 communication protocol.
1381 @node Board configuration file, Remote host testing, Local configuration file, Customizing DejaGnu
1382 @section Board configuration file
1383 @cindex configuration file, board
1385 The board configuration file is where board-specific configuration
1386 details are stored. A board configuration file contains all the
1387 higher-level configuration settings. There is a rough inheritance
1388 scheme, where it is possible to derive a new board description file
1389 from an existing one. There are also collections of custom procedures
1390 for common environments. For more information on adding a new board
1391 config file, see @ref{Adding a new board}.
1393 An example board configuration file for a GNU simulator is as follows.
1394 @code{set_board_info} is a procedure that sets the field name to the
1395 specified value. The procedures mentioned in brackets are
1396 @emph{helper procedures}. These are used to find parts of a toolchain
1397 required to build an executable image that may reside in various
1398 locations. This is mostly of use when the startup code, the standard
1399 C libraries, or the toolchain itself is part of your build tree.
1401 @strong{Example file}
1403 # This is a list of toolchains that are supported on this board.
1404 set_board_info target_install @{sparc64-elf@}
1406 # Load the generic configuration for this board. This will define any
1407 # routines needed by the tool to communicate with the board.
1408 load_generic_config "sim"
1410 # We need this for find_gcc and *_include_flags/*_link_flags.
1411 load_base_board_description "basic-sim"
1413 # Use long64 by default.
1414 process_multilib_options "long64"
1418 # We only support newlib on this target. We assume that all multilib
1419 # options have been specified before we get here.
1421 set_board_info compiler "[find_gcc]"
1422 set_board_info cflags "[libgloss_include_flags] [newlib_include_flags]"
1423 set_board_info ldflags "[libgloss_link_flags] [newlib_link_flags]"
1425 set_board_info ldscript ""
1427 # Used by a few gcc.c-torture testcases to delimit how large the
1429 set_board_info gcc,stack_size 16384
1430 # The simulator doesn't return exit status and we need to indicate this
1431 # the standard GCC wrapper will work with this target.
1432 set_board_info needs_status_wrapper 1
1433 # We can't pass arguments to programs.
1434 set_board_info noargs 1
1437 There are five helper procedures used in this example:
1441 @code{find_gcc} looks for a copy of the GNU compiler in your build
1442 tree, or it uses the one in your path. This will also return the
1443 proper transformed name for a cross compiler if you whole build tree
1444 is configured for one. DejaGnu will use this procedure to locate a
1445 compiler if the @code{compiler} field is not set.
1448 @code{libgloss_include_flags} returns the flags to compile using
1449 @ref{Libgloss, libgloss}, the GNU board support package (BSP).
1452 @code{libgloss_link_flags} returns the flags to link an executable
1453 using @ref{Libgloss, libgloss}.
1456 @code{newlib_include_flags} returns the flags to compile using
1457 @uref{https://sourceware.org/newlib, newlib}, a re-entrant standard C
1458 library for embedded systems comprising of non-GPL'd code
1461 @code{newlib_link_flags} returns the flags to link an executable with
1462 @uref{https://sourceware.org/newlib, newlib}.
1466 @node Remote host testing, Configuration file values, Board configuration file, Customizing DejaGnu
1467 @section Remote host testing
1468 @cindex testing on remote hosts
1470 DejaGnu also supports running the tests on a remote host. To set this
1471 up, the remote host needs an FTP server, and a telnet server.
1472 Currently foreign operating systems used as remote hosts are VxWorks,
1473 VRTX, DOS/Windows 3.1, MacOS and Windows.
1475 The recommended source for a Windows-based FTP server is to get IIS
1476 (either IIS 1 or Personal Web Server) from
1477 @uref{http://www.microsoft.com,http://www.microsoft.com}. When you
1478 install it, make sure you install the FTP server - it's not selected
1479 by default. Go into the IIS manager and change the FTP server so that
1480 it does not allow anonymous FTP. Set the home directory to the root
1481 directory (i.e. c:\) of a suitable drive. Allow writing via FTP.
1483 It will create an account like IUSR_FOOBAR where foobar is the name of
1484 your machine. Go into the user editor and give that account a
1485 password that you don't mind hanging around in the clear (i.e. not the
1486 same as your admin or personal passwords). Also, add it to all the
1487 various permission groups.
1489 You'll also need a telnet server. For Windows, go to the
1490 @uref{http://ataman.com,Ataman} web site, pick up the Ataman Remote
1491 Logon Services for Windows, and install it. You can get started on
1492 the eval period anyway. Add IUSR_FOOBAR to the list of allowed users,
1493 set the HOME directory to be the same as the FTP default directory.
1494 Change the Mode prompt to simple.
1496 Now you need to pick a directory name to do all the testing in. For
1497 the sake of this example, we'll call it piggy (i.e. c:\piggy). Create
1500 You'll need a Unix machine. Create a directory for the scripts you'll
1501 need. For this example, we'll use /usr/local/swamp/testing. You'll
1502 need to have a source tree somewhere, say /usr/src/devo. Now, copy
1503 some files from releng's area in SV to your machine:
1505 @strong{Remote host setup}
1508 cd /usr/local/swamp/testing
1510 scp darkstar.welcomehome.org:/dejagnu/cst/bin/MkTestDir .
1511 scp darkstar.welcomehome.org:/dejagnu/site.exp .
1512 scp darkstar.welcomehome.org:/dejagnu/boards/useless98r2.exp boards/foobar.exp
1513 export DEJAGNU=/usr/local/swamp/testing/site.exp
1516 You must edit the boards/foobar.exp file to reflect your machine;
1517 change the hostname (foobar.com), username (iusr_foobar), password,
1518 and ftp_directory (c:/piggy) to match what you selected.
1520 Edit the global @file{ site.exp} to reflect your boards directory:
1522 @strong{Add The Board Directory}
1525 lappend boards_dir "/usr/local/swamp/testing/boards"
1528 Now run MkTestDir, which is in the contrib directory. The first
1529 parameter is the toolchain prefix, the second is the location of your
1530 devo tree. If you are testing a cross compiler (ex: you have
1531 sh-hms-gcc.exe in your PATH on the PC), do something like this:
1533 @strong{Setup Cross Remote Testing}
1536 ./MkTestDir sh-hms /usr/dejagnu/src/devo
1539 If you are testing a native PC compiler (ex: you have gcc.exe in your
1540 PATH on the PC), do this:
1542 @strong{Setup Native Remote Testing}
1545 ./MkTestDir '' /usr/dejagnu/src/devo
1548 To test the setup, @code{ftp} to your PC using the username
1549 (iusr_foobar) and password you selected. CD to the test directory.
1550 Upload a file to the PC. Now telnet to your PC using the same
1551 username and password. CD to the test directory. Make sure the file
1552 is there. Type "set" and/or "gcc -v" (or sh-hms-gcc -v) and make sure
1553 the default PATH contains the installation you want to test.
1555 @strong{Run Test Remotely}
1558 cd /usr/local/swamp/testing
1559 make -k -w check RUNTESTFLAGS="--host_board foobar --target_board foobar -v -v" > check.out 2>&1
1562 To run a specific test, use a command like this (for this example,
1563 you'd run this from the gcc directory that MkTestDir created):
1565 @strong{Run a Test Remotely}
1568 make check RUNTESTFLAGS="--host_board sloth --target_board sloth -v compile.exp=921202-1.c"
1571 Note: if you are testing a cross-compiler, put in the correct target
1572 board. You'll also have to download more .exp files and modify them
1573 for your local configuration. The -v's are optional.
1575 @node Configuration file values, , Remote host testing, Customizing DejaGnu
1576 @section Configuration file values
1577 @cindex configuration values
1580 DejaGnu uses a Tcl associative array to hold all the info for each
1581 machine. In the case of a Canadian cross, this means host information
1582 as well as target information. The named array is called
1583 @code{target_info}, and it has two indices. The following fields are
1587 * Command line option variables::
1588 * User configuration file::
1591 @node Command line option variables, User configuration file, , Configuration file values
1592 @subsection Command line option variables
1594 In the user editable second section of the @ref{User configuration
1595 file} you can not only override the configuration variables captured
1596 in the first section, but also specify default values for all of the
1597 @code{runtest} command line options. Excepting @code{--debug},
1598 @code{--help}, and @code{--version}, each command line option has an
1599 associated Tcl variable. Use the Tcl @code{set} command to specify a
1600 new default value (as for the configuration variables). The following
1601 table describes the correspondence between command line options and
1602 variables you can set in @file{site.exp}. Refer to @ref{Invoking
1603 runtest}, for explanations of the command-line options.
1605 @multitable {--target_board} {TOOL_EXECUTABLE} {verbosity level greater than or equal to 0}
1607 Option@tab Tcl variable@tab Description
1610 -a, --all@tab all_flag@tab display all test results if set
1613 --build@tab build_triplet@tab system triplet for the build host
1616 --dir@tab cmdline_dir_to_run@tab run only tests in the specified directory
1619 --global_init@tab global_init_file@tab file name for global init file in @code{libdir}
1622 --host@tab host_triplet@tab system triplet for the host
1625 --host_board@tab host_board@tab host board definition to use
1628 --ignore@tab ignoretests @tab do not run the specified tests
1631 --local_init@tab local_init_file@tab file name for local init file in @code{objdir}
1634 --log_dialog@tab log_dialog@tab emit Expect output to standard output
1637 --outdir@tab outdir@tab directory for @file{.sum} and @file{.log} files
1640 --objdir@tab objdir@tab directory for pre-compiled binaries
1643 --reboot@tab reboot@tab reboot the target if set to 1
1646 --srcdir@tab srcdir@tab directory of test subdirectories
1649 --target@tab target_triplet@tab system triplet for the target
1652 --target_board@tab target_list@tab list of target boards to run tests on
1655 --tool@tab tool@tab name of tool to test (selects tests to run)
1658 --tool_exec@tab TOOL_EXECUTABLE@tab path to the executable to test
1661 --tool_opts@tab TOOL_OPTIONS@tab additional options to pass to the tool
1664 --tool_root_dir@tab tool_root_dir@tab tool root directory
1667 -v, --verbose@tab verbose@tab verbosity level greater than or equal to 0
1671 @node User configuration file, , Command line option variables, Configuration file values
1672 @subsection Per-user configuration file (.dejagnurc)
1674 The per-user configuration file is named @file{.dejagnurc} in the
1675 user's home directory. It is used to customize the behaviour of
1676 @code{runtest} for each user -- typically the user's preference for
1677 log verbosity, and for storing any experimental Tcl procedures. An
1678 example @file{~/.dejagnurc} file looks like:
1680 @strong{Example .dejagnurc}
1684 set RLOGIN /usr/ucb/rlogin
1685 set RSH /usr/local/sbin/ssh
1688 Here @code{all_flag} is set so that I see all the test cases that PASS
1689 along with the ones that FAIL. I also set @code{RLOGIN} to the BSD
1690 (non-Kerberos) version. I also set @code{RSH} to the SSH secure
1691 shell, as rsh is mostly used to test Unix machines within a local
1694 @node Extending DejaGnu, Unit testing, Customizing DejaGnu, Top
1695 @chapter Extending DejaGnu
1697 @cindex extending DejaGnu
1699 This chapter describes how to extend DejaGnu with new testsuites, new
1700 tools, new targets and new boards.
1703 * Adding a new testsuite::
1704 * Adding a new tool::
1705 * Adding a new target::
1706 * Adding a new board::
1707 * Board file values::
1708 * Writing a test case::
1709 * Debugging a test case::
1710 * Adding a test case to a testsuite::
1711 * Test case special variables: Test case variables.
1714 @node Adding a new testsuite, Adding a new tool, , Extending DejaGnu
1715 @section Adding a new testsuite
1716 @cindex adding, testsuite
1718 The testsuite for a new package should always be located in the source
1719 directory of that package. DejaGnu requires this directory to be
1720 named @file{testsuite}. Under this directory, the test cases go in
1721 various subdirectories whose name begins with the tool name. The
1722 organization of the various testsuite subdirectories is up to you.
1723 For a tool named @code{gdb}, for instance, each subdirectory
1724 containing tests must start with @samp{gdb.}.
1726 @node Adding a new tool, Adding a new target, Adding a new testsuite, Extending DejaGnu
1727 @section Adding a new tool
1729 In general, the best way to learn how to write code, or even prose, is
1730 to read something similar. This principle applies to test cases and
1731 to testsuites. Unfortunately, well-established testsuites have a way
1732 of developing their own conventions: as test writers become more
1733 experienced with DejaGnu and with Tcl, they accumulate more utilities,
1734 and take advantage of more and more features of Expect and Tcl in
1735 general. Inspecting such established testsuites may make the prospect
1736 of creating an entirely new testsuite appear overwhelming.
1737 Nevertheless, it is straightforward to start a new testsuite.
1739 To help orient you further in this task, here is an outline of the
1740 steps to begin building a testsuite for a program example.
1742 Create or select a directory to contain your new collection of tests.
1743 Change into that directory (shown here as @file{testsuite}):
1745 Create a @file{configure.in} file in this directory, to control
1746 configuration-dependent choices for your tests. So far as DejaGnu is
1747 concerned, the important thing is to set a value for the variable
1748 @code{target_abbrev}; this value is the link to the init file you will
1749 write soon. (For simplicity, we assume the environment is Unix, and
1750 use @emph{unix} as the value.)
1752 What else is needed in @file{configure.in} depends on the requirements
1753 of your tool, your intended test environments, and which configure
1754 system you use. This example is a minimal @file{configure.ac} for use
1757 @subsection Sample Makefile.in Fragment
1759 Create @file{Makefile.in} (if using Autoconf), or @file{Makefile.am}
1760 (if using Automake), the source file used by configure to build your
1761 @file{Makefile}. If you are using GNU Automake.just add the keyword
1762 @emph{dejagnu} to the @emph{AUTOMAKE_OPTIONS} variable in your
1763 @file{Makefile.am} file. This will add all the @file{Makefile}
1764 support needed to run DejaGnu, and support the @ref{Make Check, make
1767 You also need to include two targets important to DejaGnu:
1768 @emph{check}, to run the tests, and @emph{site.exp}, to set up the Tcl
1769 copies of configuration-dependent values. This is called the
1770 @ref{Local configuration file} The @emph{check} target must invoke the
1771 @code{runtest} program to run the tests.
1773 The @emph{site.exp} target should usually set up (among other things)
1774 the @emph{$tool} variable for the name of your program. If the local
1775 @file{site.exp} file is setup correctly, it is possible to execute the
1776 tests by merely typing @code{runtest} on the command line.
1779 # Look for a local version of DejaGnu, otherwise use one in the path
1780 RUNTEST = `if test -f $(top_srcdir)/../dejagnu/runtest; then \
1781 echo $(top_srcdir) ../dejagnu/runtest; \
1786 # Flags to pass to runtest
1791 @ $(RUNTEST) $(RUNTESTFLAGS) --tool $@{example@} --srcdir $(srcdir)
1793 # Make the local config file
1794 site.exp: ./config.status Makefile
1795 @ @@echo "Making a new config file..."
1799 @ -@@mv site.exp site.bak
1800 @ @@echo "## these variables are automatically generated by make ##" > ./tmp0
1801 @ @@echo "# Do not edit here. If you wish to override these values" >> ./tmp0
1802 @ @@echo "# add them to the last section" >> ./tmp0
1803 @ @@echo "set host_os $@{host_os@}" >> ./tmp0
1804 @ @@echo "set host_alias $@{host_alias@}" >> ./tmp0
1805 @ @@echo "set host_cpu $@{host_cpu@}" >> ./tmp0
1806 @ @@echo "set host_vendor $@{host_vendor@}" >> ./tmp0
1807 @ @@echo "set target_os $@{target_os@}" >> ./tmp0
1808 @ @@echo "set target_alias $@{target_alias@}" >> ./tmp0
1809 @ @@echo "set target_cpu $@{target_cpu@}" >> ./tmp0
1810 @ @@echo "set target_vendor $@{target_vendor@}" >> ./tmp0
1811 @ @@echo "set host_triplet $@{host_canonical@}" >> ./tmp0
1812 @ @@echo "set target_triplet $@{target_canonical@}">>./tmp0
1813 @ @@echo "set tool binutils" >> ./tmp0
1814 @ @@echo "set srcdir $@{srcdir@}" >> ./tmp0
1815 @ @@echo "set objdir `pwd`" >> ./tmp0
1816 @ @@echo "set $@{examplename@} $@{example@}" >> ./tmp0
1817 @ @@echo "## All variables above are generated by configure. Do Not Edit ##" >> ./tmp0
1818 @ @@cat ./tmp0 > site.exp
1819 @ @@sed < site.bak \
1820 @ -e '1,/^## All variables above are.*##/ d' \
1825 @subsection Simple tool init file for batch programs
1827 The tool init file may be placed in @file{testsuite/lib} or in
1828 @file{testsuite/lib/tool} and must be named @file{@var{tool}.exp},
1829 where @var{tool} is the name of the tool to be tested. For this
1830 example, we will use the name @samp{example} for the tool name, which
1831 means that the tool init file must be named @file{example.exp}. If the
1832 program being tested is not interactive, you can get away with this
1833 minimal tool init file to begin with:
1836 proc example_exit @{@} @{@}
1837 proc example_version @{@} @{@}
1840 By convention, the file name for the executable for a tool should be
1841 stored in a global variable with the same name as the tool, but in all
1842 uppercase. For our example program @samp{example}, the name of the
1843 program under test should be stored in @samp{EXAMPLE}.
1845 @subsection Simple tool init file for interactive programs
1847 If the program being tested is interactive, however, you might as well
1848 define a @emph{start} routine and invoke it by using a tool init file
1852 proc example_exit @{@} @{@}
1853 proc example_version @{@} @{@}
1855 proc example_start @{@} @{
1863 # Start the program running we want to test
1867 Create a directory whose name begins with your tool's name, to contain
1868 tests. For example, if the tool name is @samp{example}, then the
1869 directories all need to start with @samp{example.}. Create a sample
1870 test file ending in @file{.exp}. You can name the file
1871 @file{first-try.exp}. To begin with, just write one line of Tcl code
1875 send_user "Testing: one, two...\n"
1878 @subsection Testing A New Tool Config
1880 Back in the @file{testsuite} (top level) directory, run
1881 @code{configure}. Typically you do this while in the build directory.
1882 You are now ready to type @code{make check} or @code{runtest}. You
1883 should see something like this:
1886 Test Run By bje on Sat Nov 14 15:08:54 AEDT 2015
1888 @ === example tests ===
1890 Running ./example.0/first-try.exp ...
1891 Testing: one, two...
1893 @ === example Summary ===
1896 There is no output in the summary, because so far the example does not
1897 call any of the procedures that report a test outcome.
1899 Write some real tests. For an interactive tool, you should probably
1900 write a real exit routine in fairly short order. In any case, you
1901 should also write a real version routine soon.
1903 @node Adding a new target, Adding a new board, Adding a new tool, Extending DejaGnu
1904 @section Adding a new target
1905 @cindex adding, target
1907 DejaGnu has some additional requirements for target support, beyond
1908 the general-purpose provisions of a @code{configure} script. DejaGnu
1909 must actively communicate with the target, rather than simply
1910 generating or managing code for the target architecture. Therefore,
1911 each tool requires an initialization module for each target. For new
1912 targets, you must supply a few Tcl procedures to adapt DejaGnu to the
1915 Usually the best way to write a new initialization module is to edit
1916 an existing initialization module; some trial and error will be
1917 required. If necessary, you can use the @code{--debug} option to see
1918 what is really going on.
1920 When you code an initialization module, be generous in printing
1921 information using the @code{verbose} procedure. In cross-development
1922 environments, most of the work is in getting the communications right.
1923 Code for communicating via TCP/IP networks or serial lines is
1924 available in a DejaGnu library files such as @file{lib/telnet.exp}.
1926 If you suspect a communication problem, try running the connection
1927 interactively from Expect. (There are three ways of running Expect as
1928 an interactive interpreter. You can run Expect with no arguments, and
1929 control it completely interactively; or you can use @code{expect -i}
1930 together with other command-line options and arguments; or you can run
1931 the command @code{interpreter} from any Expect procedure. Use
1932 @code{return} to get back to the calling procedure (if any), or
1933 @code{return -tcl} to make the calling procedure itself return to its
1934 caller; use @code{exit} or end-of-file to leave Expect altogether.)
1935 Run the program whose name is recorded in @code{$connectmode}, with
1936 the arguments in @code{$targetname}, to establish a connection. You
1937 should at least be able to get a prompt from any target that is
1938 physically connected.
1940 @node Adding a new board, Board file values, Adding a new target, Extending DejaGnu
1941 @section Adding a new board
1942 @cindex adding, board
1944 Adding a new board consists of creating a new board configuration
1945 file. Examples are in @file{dejagnu/baseboards}. Usually to make a
1946 new board file, it's easiest to copy an existing one. It is also
1947 possible to have your file be based on a @emph{baseboard} file with
1948 only one or two changes needed. Typically, this can be as simple as
1949 just changing the linker script. Once the new baseboard file is done,
1950 add it to the @code{boards_DATA} list in the
1951 @file{dejagnu/baseboards/Makefile.am}, and regenerate the Makefile.in
1952 using automake. Then just rebuild and install DejaGnu. You can test
1955 There is a crude inheritance scheme going on with board files, so you
1956 can include one board file into another, The two main procedures used
1957 to do this are @code{load_generic_config} and
1958 @code{load_base_board_description}. The generic configuration file
1959 contains other procedures used for a certain class of target. The
1960 board description file is where the board specific settings go.
1961 Commonly there are similar target environments with just different
1964 @strong{Testing a New Board Configuration File}
1967 make check RUNTESTFLAGS="--target_board=newboardfile".
1970 Here's an example of a board configuration file. There are several
1971 @emph{helper procedures} used in this example. A helper procedure is
1972 one that look for a tool of files in commonly installed locations.
1973 These are mostly used when testing in the build tree, because the
1974 executables to be tested are in the same tree as the new DejaGnu
1975 files. The helper procedures are the ones in brackets, which
1976 indicates a Tcl procedure call.
1978 @strong{Example Board Configuration File}
1981 # Load the generic configuration for this board. This will define a basic
1982 # set of routines needed by the tool to communicate with the board.
1983 load_generic_config "sim"
1985 # basic-sim.exp is a basic description for the standard Cygnus simulator.
1986 load_base_board_description "basic-sim"
1988 # The compiler used to build for this board. This has *nothing* to do
1989 # with what compiler is tested if we're testing gcc. Further, this is
1990 # the default, so this line is optional for most boards.
1991 set_board_info compiler "[find_gcc]"
1993 # We only support newlib on this target.
1994 # However, we include libgloss so we can find the linker scripts.
1995 set_board_info cflags "[newlib_include_flags] [libgloss_include_flags]"
1996 set_board_info ldflags "[newlib_link_flags]"
1998 # No linker script for this board.
1999 set_board_info ldscript "-Tsim.ld"
2001 # The simulator doesn't return exit statuses and we need to indicate this.
2002 set_board_info needs_status_wrapper 1
2004 # Can't pass arguments to this target.
2005 set_board_info noargs 1
2008 set_board_info gdb,nosignals 1
2010 # And it can't call functions.
2011 set_board_info gdb,cannot_call_functions 1
2014 @node Board file values, Writing a test case, Adding a new board, Extending DejaGnu
2015 @section Board configuration file values
2017 The following fields are in the @code{board_info} array. These are
2018 set by the @code{set_board_info} procedure (or @code{add_board_info}
2019 procedure for appending to lists). Both procedures take a field name
2020 and a value for the field (or is added to the field), respectively.
2021 Some common board info fields are shown below.
2023 @multitable @columnfractions 0.2 0.2 0.6
2025 @strong{Field} @tab @strong{Example value} @tab @strong{Description}
2027 compiler@tab @code{[find_gcc]}@tab The path to the compiler to use.
2029 cflags@tab @code{-mca}@tab Compilation flags for the compiler.
2031 ldflags@tab @code{[libgloss_link_flags] [newlib_link_flags]}@tab Linking flags for the compiler.
2033 ldscript@tab @code{-Wl,-Tidt.ld}@tab The linker script to use when cross compiling.
2035 libs@tab @code{-lgcc}@tab Any additional libraries to link in.
2037 shell_prompt@tab @code{cygmon>}@tab The command prompt of the remote shell.
2039 hex_startaddr@tab @code{0xa0020000}@tab The Starting address as a string.
2041 start_addr@tab 0xa0008000@tab The starting address as a value.
2043 startaddr@tab @code{a0020000}@tab
2045 exit_statuses_bad@tab 1@tab Whether there is an accurate exit status.
2047 reboot_delay@tab 10@tab The delay between power off and power on.
2049 unreliable@tab 1@tab Whether communication with the board is unreliable.
2051 sim@tab [find_sim]@tab The path to the simulator to use.
2053 objcopy@tab $tempfil@tab The path to the @code{objcopy} program.
2055 support_libs@tab @code{$@{prefix_dir@}/i386-coff/}@tab Support libraries needed for cross compiling.
2057 addl_link_flags@tab @code{-N}@tab Additional link flags, rarely used.
2059 remotedir@tab @code{/tmp/runtest.[pid]}@tab Directory on the remote target in which executables are downloaded and executed.
2062 These fields are used by the GCC and GDB tests, and are mostly only
2063 useful to somewhat trying to debug a new board file for one of these
2064 tools. Many of these are used only by a few testcases, and their
2065 purpose is esoteric. These are listed with sample values as a guide
2066 to better guessing if you need to change any of these.
2068 @strong{Board Info Fields For GCC & GDB}
2070 @multitable @columnfractions 0.333333333333333 0.333333333333333 0.333333333333333
2072 Field@tab Sample Value@tab Description
2074 strip@tab $tempfile@tab Strip the executable of symbols.
2076 gdb_load_offset@tab "0x40050000"@tab
2078 gdb_protocol@tab "remote"@tab The GDB debugging protocol to use.
2080 gdb_sect_offset@tab "0x41000000";@tab
2082 gdb_stub_ldscript@tab "-Wl,-Teva-stub.ld"@tab The linker script to use with a GDB stub.
2084 gdb,noargs@tab 1@tab Whether the target can take command line arguments.
2086 gdb,nosignals@tab 1@tab Whether there are signals on the target.
2088 gdb,short_int@tab 1@tab
2090 gdb,target_sim_options@tab "-sparclite"@tab Special options to pass to the simulator.
2092 gdb,timeout@tab 540@tab Timeout value to use for remote communication.
2094 gdb_init_command@tab "set mipsfpu none"@tab A single command to send to GDB before the program being
2095 debugged is started.
2097 gdb_init_commands@tab "print/x \$fsr = 0x0"@tab Same as @emph{gdb_init_command}, except
2098 that this is a list, more commands can be added.
2100 gdb_load_offset@tab "0x12020000"@tab
2102 gdb_opts@tab "--command gdbinit"@tab
2104 gdb_prompt@tab "\\(gdb960\\)"@tab The prompt GDB is using.
2106 gdb_run_command@tab "jump start"@tab
2108 gdb_stub_offset@tab "0x12010000"@tab
2110 use_gdb_stub@tab 1@tab Whether to use a GDB stub.
2112 wrap_m68k_aout@tab 1@tab
2114 gcc,no_label_values@tab 1@tab
2116 gcc,no_trampolines@tab 1@tab
2118 gcc,no_varargs@tab 1@tab
2120 gcc,stack_size@tab 16384@tab Stack size to use with some GCC testcases.
2122 ieee_multilib_flags@tab "-mieee"@tab
2124 is_simulator@tab 1@tab
2126 needs_status_wrapper@tab 1@tab
2130 no_long_long@tab 1@tab
2134 target_install@tab @{sh-hms@}@tab
2137 @node Writing a test case, Debugging a test case, Board file values, Extending DejaGnu
2138 @section Writing a test case
2139 @cindex Writing a test case
2141 The easiest way to prepare a new test case is to base it on an
2142 existing one for a similar situation. There are two major categories
2143 of tests: batch-oriented and interactive. Batch-oriented tests are
2144 usually easier to write.
2146 The GCC tests are a good example of batch-oriented tests. All GCC
2147 tests consist primarily of a call to a single common procedure, since
2148 all the tests either have no output, or only have a few warning
2149 messages when successfully compiled. Any non-warning output
2150 constitutes a test failure. All the C code needed is kept in the test
2151 directory. The test driver, written in Tcl, need only get a listing
2152 of all the C files in the directory, and compile them all using a
2153 generic procedure. This procedure and a few others supporting for
2154 these tests are kept in the library module @file{lib/c-torture.exp} of
2155 the GCC testsuite. Most tests of this kind use very few Expect
2156 features, and are coded almost purely in Tcl.
2158 Writing the complete suite of C tests, then, consisted of these steps:
2162 Copying all the C code into the test directory. These tests were
2163 based on the C-torture test created by Torbjorn Granlund (on behalf of
2164 the Free Software Foundation) for GCC development.
2167 Writing (and debugging) the generic Tcl procedures for compilation.
2170 Writing the simple test driver: its main task is to search the
2171 directory (using the Tcl procedure @emph{glob} for filename expansion
2172 with wildcards) and call a Tcl procedure with each filename. It also
2173 checks for a few errors from the testing procedure.
2176 Testing interactive programs is intrinsically more complex. Tests for
2177 most interactive programs require some trial and error before they are
2180 However, some interactive programs can be tested in a simple fashion
2181 reminiscent of batch tests. For example, prior to the creation of
2182 DejaGnu, the GDB distribution already included a wide-ranging testing
2183 procedure. This procedure was very robust, and had already undergone
2184 much more debugging and error checking than many recent DejaGnu test
2185 cases. Accordingly, the best approach was simply to encapsulate the
2186 existing GDB tests, for reporting purposes. Thereafter, new GDB tests
2187 built up a family of Tcl procedures specialized for GDB testing.
2189 @subsection Hints on writing a test case
2190 @cindex hints on writing a test case
2191 @cindex test cases, writing
2193 To preserve basic sanity, no should test ever pass if there was any
2194 kind of problem in the test case. To take an extreme case, tests that
2195 pass even when the tool will not spawn are misleading. Ideally, a
2196 test in this sort of situation should not fail either. Instead, print
2197 an error message by calling one of the DejaGnu procedures
2198 @code{perror} or @code{warning}. Note that using @code{perror} will
2199 cause the next text result to be reported as @samp{UNRESOLVED}, so
2200 printing an error and allowing the test to fail is a good option.
2202 If you have trouble understanding why a pattern does not match the
2203 program output, try using the @code{--debug} option to @code{runtest},
2204 and examine the debug log carefully.
2206 If you use glob patterns, you will need to escape any @samp{*},
2207 @samp{?}, @samp{[}, @samp{]}, and @samp{\} characters that are meant
2208 to match literally. If you use regular expressions, see the
2209 @cite{re_syntax(n)} manual page from Tcl for the syntax details, and
2210 be sure to understand what punctuation characters match literally and
2211 what characters have special meanings in regular expressions.
2213 Tcl has a few options for quoting; the most notable are @samp{@{@}}
2214 and @samp{""}. These quotes behave differently: @samp{@{@}} must
2215 balance, while @samp{""} performs various interpolations. In
2216 @samp{@{@}} quotes, unbalanced @samp{@{} or @samp{@}} characters must
2217 be escaped with @samp{\} and these escapes are @emph{not} removed;
2218 fortunately, backslash-escaped braces match literal braces in Tcl
2219 regular expressions. In @samp{""} quotes, any embedded @samp{"}
2220 characters must be escaped, a literal @samp{$} begins a variable
2221 substitution, and unescaped @samp{[]} introduce a Tcl command
2224 @subsubheading Synchronization with the tested program
2226 A DejaGnu testsuite executes concurrently with the programs that it
2227 tests. As a result, DejaGnu may see parts of the tested program's
2228 output while the tested program is still producing more output.
2229 Expect patterns must be written to handle the possibility that
2230 incomplete output from the tested program will be considered for
2233 Expect reads the output from the tested program into an internal
2234 matching buffer and removes everything from the start of the buffer to
2235 the end of the match when a match is found. Any given character can
2236 be matched at most once, or skipped if a match is found starting later
2237 in the buffer or the buffer reaches its capacity. Anything left in
2238 the buffer after the end of the match remains in the buffer and is
2239 considered for the next @code{expect} command. If @code{expect} is
2240 invoked and no patterns match, Expect waits for more text to arrive.
2241 New text is appended to the buffer as it is read. If the buffer
2242 reaches its capacity, the entire contents of the buffer are discarded
2243 and Expect resumes reading.
2245 In Expect patterns, the regular expression anchors @samp{^} and
2246 @samp{$} match at the beginning and end of the @emph{buffer}, not at
2247 line boundaries. The @samp{$} anchor must be used with care because
2248 it will match at the end of what Expect @emph{has} read, but the
2249 program may have produced more output that Expect @emph{has not yet}
2250 read. Similarly, regular expressions ending with the @samp{*}
2251 quantifier can potentially match a prefix of the intended text, only
2252 for the rest to arrive shortly thereafter.
2254 Maintaining synchronization with the tested program is easier if the
2255 patterns match all of the output generated by the tested program; this
2258 For interactive programs, a prompt is usually a good synchronization
2259 point, provided that the program's prompt can be uniquely recognized.
2260 Since the prompt is usually the last output until the program receives
2261 further input, the @samp{$} anchor can be useful here.
2263 If the output from the tested program is organized into lines,
2264 matching end-of-line using @samp{\n} is usually a good way to process
2265 one line at a time. Note that terminal settings may result in the
2266 insertion of additional @samp{\r} characters, usually translating
2267 @samp{\n} to @samp{\r\n}.
2269 Be careful not to neglect output generated by setup rather than by the
2270 interesting parts of a test case. For example, while testing GDB, a
2271 @samp{set height 0\n} command is issued. The purpose is simply to
2272 make sure GDB never calls a paging program. The @samp{set height}
2273 command in GDB does not generate any output; but running any command
2274 makes GDB issue a new @samp{(gdb) } prompt. If there were no
2275 @code{expect} command to match this prompt, the @samp{(gdb) } prompt
2276 will remain in the buffer and begin the text seen by the next
2277 @code{expect} command---which might make that pattern fail to match.
2279 @subsubheading Priority of Expect patterns
2281 Be particularly careful about how you write the patterns. Expect
2282 attempts to match each pattern in the order that they are written in
2283 the @code{expect} command. Unless a regexp pattern is anchored at the
2284 beginning of the buffer, Expect can search ahead for a match for a
2285 pattern that appears earlier in the @code{expect} command and skip
2286 over text that would match a later pattern. @emph{The text thus
2287 skipped is discarded.} This is a source of very hard to trace bugs,
2288 especially when reading input from batch-oriented unit tests.
2290 For example, consider a simple model once used by the DejaGnu
2291 testsuite for unit testing. In this example, a test has failed, but
2292 the tests before and after it have passed. First the relevant input
2301 The test script is reading this with two Expect patterns, simplified
2302 for this example by omitting handling of the actual messages and other
2307 -re @{PASSED: [^\r\n]+[\r\n]+@} @{ pass ... @}
2308 -re @{FAILED: [^\r\n]+[\r\n]+@} @{ fail ... @}
2312 At every cycle, Expect attempts to match each pattern in the order
2313 that they are written against the available input. If DejaGnu is
2314 processing the input as quickly as it arrives, this example will
2315 actually work. However, if the system scheduler sets DejaGnu aside
2316 for a bit, or the external program produces output in a burst, Expect
2317 can find that its input buffer contains the text in the first example
2318 above all at once as the cycle begins.
2320 If this occurs, Expect will first attempt to match @code{@{PASSED:
2321 [^\r\n]+[\r\n]+@}} against the input and will succeed, since the input
2322 begins with @samp{PASSED: foo}. The @code{pass} procedure is called
2323 and the test result recorded. Expect then starts a new matching
2326 If the input had been presented one line at a time, the expected
2327 result would occur: the @code{@{FAILED: [^\r\n]+[\r\n]+@}} pattern
2328 would match and the test driver would work correctly. But we are
2329 considering the case where all three lines arrived ``at once'' so we
2330 must examine what Expect will do in this case. After the first line
2331 has been processed, the Expect buffer now contains:
2338 Expect again attempts to match each pattern in order. Expect will
2339 attempt to match @code{@{PASSED: [^\r\n]+[\r\n]+@}} before attempting
2340 to match @code{@{FAILED: [^\r\n]+[\r\n]+@}} and the first attempt
2341 succeeds because the pattern is not anchored. The @samp{FAILED: bar}
2342 message is simply discarded when Expect finds the later
2343 @samp{PASSED:baz} message in the buffer.
2345 How to prevent this? There are two ways: either group all of your
2346 test matches into a single regexp using alternation, or ensure that
2347 all patterns can match only at the start of Expect's buffer. Both
2348 options can be made to work. Grouping all status results into a
2349 single regexp allows some other unspecified text to still be silently
2350 discarded, while ensuring that all patterns are anchored absolutely
2351 requires closure, as any unmatched text will cause Expect to run out
2352 of buffer space. Expect discards the entire buffer when this occurs.
2354 @node Debugging a test case, Adding a test case to a testsuite, Writing a test case, Extending DejaGnu
2355 @section Debugging a test case
2356 @cindex test cases, debugging
2358 These are the kinds of debugging information available from DejaGnu:
2363 Output controlled by test scripts themselves, explicitly allowed for
2364 by the test author. This kind of debugging output appears in the
2365 detailed output recorded in the DejaGnu log file. To do the same for
2366 new tests, use the @code{verbose} procedure (which in turn uses the
2367 Tcl variable @samp{verbose}) to control how much output to generate.
2368 This will make it easier for other people running the test to debug it
2369 if necessary. If @samp{verbose} is zero, there should be no output
2370 other than the output from the framework (eg. FAIL). Then, to
2371 whatever extent is appropriate for the particular test, allow
2372 successively higher values of @samp{verbose} to generate more
2373 information. Be kind to other programmers who use your tests --
2374 provide plenty of debugging information.
2377 Output from the internal debugging functions of Tcl and Expect. There
2378 is a command line options for each; both forms of debugging output are
2379 recorded in the file @file{dbg.log} in the current directory.
2381 Use @code{--debug} for information from Expect. It logs how Expect
2382 attempts to match the tool output with the patterns specified. This
2383 can be very helpful while developing test scripts, since it shows
2384 precisely the characters received. Iterating between the latest
2385 attempt at a new test script and the corresponding @file{dbg.log} can
2386 allow you to create the final patterns by ``cut and paste''. This is
2387 sometimes the best way to write a test case.
2390 Use @code{--strace} to see more detail from Tcl. This logs how Tcl
2391 procedure definitions are expanded as they execute. The trace level
2392 argument controls the depth of definitions expanded.
2395 If the value of @samp{verbose} is 3 or greater (@code{runtest -v -v
2396 -v}), DejaGnu activates the Expect command @code{log_user}. This
2397 command prints all Expect actions to standard output, to the
2398 @file{.log} file and, if @code{--debug} is given, to @file{dbg.log}.
2401 @node Adding a test case to a testsuite, Test case variables, Debugging a test case, Extending DejaGnu
2402 @section Adding a test case to a testsuite
2403 @cindex test cases, adding
2405 There are two slightly different ways to add a test case. One is to
2406 add the test case to an existing directory. The other is to create a
2407 new directory to hold your test. The existing test directories
2408 represent several styles of testing, all of which are slightly
2409 different. Examine the testsuite subdirectories for the tool of
2410 interest to see which approach is most suitable.
2412 Adding a GCC test may be very simple: just add the source file to any
2413 test directory beginning with @file{gcc.} and it will be tested on the
2416 Adding a test by creating a new directory involves:
2420 Create the new directory. All subdirectory names begin with the name
2421 of the tool to test; e.g. G++ tests might be in a directory called
2422 @file{g++.other}. There can be multiple testsuite subdirectories with
2423 the same tool name prefix.
2426 Add the new test case to the directory, as above.
2429 @node Test case variables, , Adding a test case to a testsuite, Extending DejaGnu
2430 @section Test case special variables
2432 There are special variables that contain other information from
2433 DejaGnu. Your test cases can inspect these variables, as well as the
2434 variables saved in @file{site.exp}. These variables should never be
2441 The bug tracking system (eg. PRMS/GNATS) number identifying a
2442 corresponding bug report (@emph{0} if you do not specify it).
2446 An optional bug ID, perhaps a bug identification number from another
2447 organization (@emph{0} if you do not specify it).
2451 The subdirectory for the current test case.
2455 This is the output from a @code{$@{tool@}_load} command. This only
2456 applies to tools like GCC and GAS which produce an object file that
2457 must in turn be executed to complete a test.
2461 This is the output from a @code{$@{tool@}_start} command. This is
2462 conventionally used for batch-oriented programs, like GCC and GAS,
2463 that may produce interesting output (warnings, errors) without further
2466 @item $expect_out(buffer)
2467 @vindex expect_out(buffer)
2468 The output from the last command. This is an internal variable set by
2469 Expect. More information can be found in the Expect manual.
2472 @node Unit testing, Built-in Procedures, Extending DejaGnu, Top
2473 @chapter Unit testing
2476 * What is unit testing?:: Unit testing and system testing.
2477 * Running unit tests::
2478 * DejaGnu unit test protocol:: DejaGnu native unit testing protocol.
2479 * C unit testing API::
2480 * C++ unit testing API::
2483 @node What is unit testing?, Running unit tests, Unit testing, Unit testing
2484 @section What is unit testing?
2485 @cindex unit testing
2487 Most regression testing as done by DejaGnu is system testing: the
2488 complete application is tested all at once. Unit testing is for
2489 testing single files, or small libraries. In this case, each file is
2490 linked with a test case in C or C++, and each function or class and
2491 method is tested in turn, with the test case having to check private
2492 data or global variables to see if the function or method worked.
2494 This works particularly well for testing APIs at a level where it is
2495 easier to debug them, than by needing to trace through the entire
2496 application. Also if there is a specification for the API to be
2497 tested, the testcase can also function as a compliance test.
2499 @node Running unit tests, DejaGnu unit test protocol, What is unit testing?, Unit testing
2500 @section Running unit tests
2501 @findex host_execute
2503 The native DejaGnu unit testing support is provided by a library
2504 module @file{dejagnu.exp} and the procedure @code{host_execute} is
2505 called by testsuite code to run unit tests.
2508 @t{@b{host_execute} @i{program} @i{arguments}}
2511 The @code{host_execute} procedure runs @i{program}, passing
2512 @i{arguments} on the command line, and examines the output for test
2513 result messages according to the DejaGnu unit testing protocol.
2515 If successful, the return value is an empty string. Otherwise, an
2516 error message is returned.
2518 @node DejaGnu unit test protocol, C unit testing API, Running unit tests, Unit testing
2519 @section DejaGnu unit test protocol
2521 DejaGnu spawns a unit test program and reads that program's output.
2522 Arguments for the unit test program can be specified in the testsuite.
2524 Unit test programs may produce any output for the benefit of a
2525 developer running them directly or reading the DejaGnu log, but output
2526 matching the Tcl regexp @code{@{\n\t[][[:upper:]]*:@}} (a tab character
2527 at the beginning of a line, followed by any sequence of uppercase
2528 letters and square brackets, followed by a colon) should be considered
2529 reserved for future extension. Future versions of DejaGnu will
2530 interpret more lines matching this pattern as additional unit test
2533 @print{}@t{@ @ @ @ @ @ @ @ NOTE: }@i{text}
2535 This will cause @i{text} to be printed at verbose levels 2 and higher.
2537 @print{}@t{@ @ @ @ @ @ @ @ ERROR: }@i{text}
2539 This reports a major nonfatal error detected in the unit test program.
2540 The framework will change the next test result to UNRESOLVED as a
2541 result of the error.
2543 @print{}@t{@ @ @ @ @ @ @ @ WARNING: }@i{text}
2545 This reports a minor nonfatal error detected in the unit test program.
2546 If more than @code{warning_threshold} minor errors occur between test
2547 results, the framework will change the next test result to UNRESOLVED.
2549 @print{}@t{@ @ @ @ @ @ @ @ PASSED: }@i{name}
2551 @print{}@t{@ @ @ @ @ @ @ @ FAILED: }@i{name}
2553 @print{}@t{@ @ @ @ @ @ @ @ XPASSED: }@i{name}
2555 @print{}@t{@ @ @ @ @ @ @ @ XFAILED: }@i{name}
2557 @print{}@t{@ @ @ @ @ @ @ @ UNTESTED: }@i{name}
2559 @print{}@t{@ @ @ @ @ @ @ @ UNRESOLVED: }@i{name}
2561 @print{}@t{@ @ @ @ @ @ @ @ UNSUPPORTED: }@i{name}
2563 These indicate simple test results.
2565 @print{}@t{@ @ @ @ @ @ @ @ END: }@i{text}
2567 This indicates that the test case is complete. All subsequent output
2568 from the test is ignored. A warning is produced if the test case
2569 closes its output without producing this line.
2571 Note that all output from a unit test program, including the lines
2572 recognized and interpreted by DejaGnu, appears in the log.
2574 @node C unit testing API, C++ unit testing API, DejaGnu unit test protocol, Unit testing
2575 @section C unit testing API
2576 @cindex C unit testing API
2578 The C API is provided in the @file{dejagnu.h} header file. This
2579 header provides a self-contained implementation and reserves names
2580 prefixed with @code{DG_} for future extensions and names prefixed with
2581 @code{DG__} (two underscores) for internal use.
2583 For convenience, the @code{totals()} function can be called at the end
2584 of the unit test program to output summary totals. DejaGnu counts the
2585 test results independently and will operate correctly even if
2586 @code{totals()} is never invoked.
2588 All of the functions that take a @code{msg} parameter use a C
2589 @code{char *} that is the message to be displayed. All of the
2590 functions that display a message accept a @code{printf}-style format
2591 string and variable arguments.
2595 @code{note} emits a note that will be displayed at verbose level 2 or
2599 @t{@b{note}(@i{msg}, ...);}
2603 @code{pass} prints a message for a successful test completion.
2606 @t{@b{pass}(@i{msg}, ...);}
2610 @code{fail} prints a message for an unsuccessful test completion.
2613 @t{@b{fail}(@i{msg}, ...);}
2617 @code{xfail} prints a message for an expected unsuccessful test
2621 @t{@b{xfail}(@i{msg}, ...);}
2625 @code{xpass} prints a message for an unexpected successful test
2629 @t{@b{xpass}(@i{msg}, ...);}
2633 @code{untested} prints a placeholder message for a test case that is
2634 not yet implemented or that could not be run for some reason.
2637 @t{@b{untested}(@i{msg}, ...);}
2641 @code{unresolved} prints a message for a test case that was run, but
2642 did not produce a clear result. These output states require a human
2643 to look over the results to determine what happened.
2646 @t{@b{unresolved}(@i{msg}, ...);}
2650 @code{unsupported} prints a message for a test case that depends on a
2651 facility that is not available in the testing environment.
2654 @t{@b{unsupported}(@i{msg}, ...);}
2658 @code{DG_error} prints a message for a major but nonfatal error
2659 detected in a test case.
2662 @t{@b{DG_error}(@i{msg}, ...);}
2666 @code{DG_warning} prints a message for a minor error detected in a
2670 @t{@b{DG_warning}(@i{msg}, ...);}
2674 @code{totals} prints out the total counts of all of the test results
2675 as a convenience when running the unit test program directly. DejaGnu
2676 does not use this information and instead counts the results
2685 @node C++ unit testing API, , C unit testing API, Unit testing
2686 @section C++ unit testing API
2687 @cindex C++ unit testing API
2689 The C++ API is also provided in the @file{dejagnu.h} header file.
2690 This header provides a self-contained implementation and reserves
2691 names prefixed with @code{DG_} for future extensions and names
2692 prefixed with @code{DG__} (two underscores) for internal use. In C++,
2693 @file{dejagnu.h} also reserves the C++ namespace @code{DejaGnu} for
2694 possible future use and provides a global @code{TestState} object
2695 named @code{DG}. User code may construct and use any number of
2696 @code{TestState} objects, and each object has its own notion of the
2697 last result emitted.
2699 All of the methods that take a @code{msg} parameter use a STL string
2700 as the message to be displayed. There currently is no support for
2701 formatted output in the C++ API; build the desired string before
2702 passing it to these functions.
2704 Note that the C API is also available in C++ unit test programs; all
2705 @code{TestState} objects and the C API share the same global set of
2708 The @code{TestState} class supports the following instance methods for
2713 @code{note} emits a note that will be displayed at verbose level 2 or
2717 @t{@b{TestState::note}(@i{msg});}
2721 @code{pass} prints a message for a successful test completion.
2724 @t{@b{TestState::pass}(@i{msg});}
2728 @code{fail} prints a message for an unsuccessful test completion.
2731 @t{@b{TestState::fail}(@i{msg});}
2735 @code{xfail} prints a message for an expected unsuccessful test completion.
2738 @t{@b{TestState::xfail}(@i{msg});}
2742 @code{xpass} prints a message for an unexpected successful test completion.
2745 @t{@b{TestState::xpass}(@i{msg});}
2749 @code{untested} prints a placeholder message for a test case that is
2750 not yet implemented or that could not be run for some reason.
2753 @t{@b{TestState::untested}(@i{msg});}
2757 @code{unresolved} prints a message for a test case that was run, but
2758 did not produce a clear result. These output states require a human
2759 to look over the results to determine what happened.
2762 @t{@b{TestState::unresolved}(@i{msg});}
2766 @code{unsupported} prints a message for a test case that depends on a
2767 facility that is not available in the testing environment.
2770 @t{@b{TestState::unsupported}(@i{msg});}
2774 @code{error} prints a message for a major but nonfatal error
2775 detected in a test case.
2778 @t{@b{TestState::error}(@i{msg});}
2782 @code{warning} prints a message for a minor error detected in a
2786 @t{@b{TestState::warning}(@i{msg});}
2791 The @code{TestState} class also supports these instance methods:
2795 @code{testrun} evaluates a Boolean value as a test result: if the
2796 Boolean @code{outcome} parameter is true, the test is considered to
2797 have passed, otherwise a failure is reported.
2800 @t{@b{TestState::testrun}(@i{outcome}, @i{msg});}
2804 @code{totals} prints out the total counts of all of the test results
2805 as a convenience when running the unit test program directly. DejaGnu
2806 does not use this information and instead counts the results
2809 In the C++ API, this method is automatically called when the last
2810 @code{TestState} object in the program is destroyed.
2813 @t{@b{TestState::totals}(@i{});}
2817 @code{GetState} returns the most recent result emitted by a
2818 @code{TestState} object as an integer value drawn from @code{enum
2819 DG_teststate}, which defines the following constants:
2824 @item @code{XPASSED}
2825 @item @code{XFAILED}
2826 @item @code{UNTESTED}
2827 @item @code{UNRESOLVED}
2828 @item @code{UNSUPPORTED}
2831 The numerical values of these constants are intentionally
2832 undocumented and subject to change without notice.
2835 @t{@b{TestState::GetState}(@i{});}
2839 @code{GetMsg} returns the message most recently emitted by a
2840 @code{TestState} object as a @code{std::string}.
2843 @t{@b{TestState::GetMsg}(@i{});}
2847 Lastly, a @code{TestState} object can be printed on any
2848 @code{std::ostream}, and will emit its most recent unit test protocol
2849 message, exactly as that message was sent to @code{std::cout}.
2853 @node Built-in Procedures, GNU Free Documentation License, Unit testing, Top
2854 @appendix Built-in Procedures
2856 DejaGnu provides these Tcl procedures.
2859 * Core Internal Procedures::
2860 * Procedures For Remote Communication::
2861 * Procedures For Using Utilities to Connect: connprocs.
2862 * Procedures For Target Boards::
2863 * Target Database Procedures: target database library file.
2864 * Platform Dependent Procedures: platform dependent procedures.
2865 * Utility Procedures::
2866 * Libgloss, a free board support package (BSP): Libgloss.
2867 * Debugging Procedures::
2870 @node Core Internal Procedures, Procedures For Remote Communication, , Built-in Procedures
2871 @section Core Internal Procedures
2874 * open_logs Procedure: open_logs procedure
2875 * close_logs Procedure: close_logs procedure
2876 * isbuild Procedure: isbuild procedure
2877 * isremote Procedure: isremote procedure
2878 * is_remote Procedure: is_remote procedure
2879 * is3way Procedure: is3way procedure
2880 * ishost Procedure: ishost procedure
2881 * istarget Procedure: istarget procedure
2882 * isnative Procedure: isnative procedure
2883 * log_and_exit Procedure: log_and_exit procedure
2884 * log_summary Procedure: log_summary procedure
2885 * setup_xfail Procedure: setup_xfail procedure
2886 * pass Procedure: pass procedure
2887 * fail Procedure: fail procedure
2888 * xpass Procedure: xpass procedure
2889 * xfail Procedure: xfail procedure
2890 * set_warning_threshold Procedure: set_warning_threshold procedure
2891 * get_warning_threshold Procedure: get_warning_threshold procedure
2892 * warning Procedure: warning procedure
2893 * perror Procedure: perror procedure
2894 * note Procedure: note procedure
2895 * untested Procedure: untested procedure
2896 * unresolved Procedure: unresolved procedure
2897 * unsupported Procedure: unsupported procedure
2898 * transform Procedure: transform procedure
2899 * check_conditional_xfail Procedure: check_conditional_xfail procedure
2900 * clear_xfail Procedure: clear_xfail procedure
2901 * verbose Procedure: verbose procedure
2902 * load_lib Procedure: load_lib procedure
2903 * testsuite Procedure: testsuite procedure
2904 * testcase procedure: testcase procedure
2907 @node open_logs procedure, close_logs procedure, , Core Internal Procedures
2908 @subsubheading open_logs Procedure
2911 Open the output logs.
2917 @node close_logs procedure, isbuild procedure, open_logs procedure, Core Internal Procedures
2918 @subsubheading close_logs Procedure
2921 Close the output logs.
2927 @node isbuild procedure, isremote procedure, close_logs procedure, Core Internal Procedures
2928 @subsubheading isbuild Procedure
2931 Tests for a particular build host environment. If the currently
2932 configured host matches the @code{pattern} argument, the result is
2933 @emph{1}; otherwise the result is @emph{0}. @emph{pattern} must be a
2934 full three-part configure triplet; in particular, you may not use the
2935 shorter aliases supported by @code{configure} (but you can use Tcl
2936 globbing to specify a range of triplets). If called with no arguments
2937 or an empty pattern, this procedure returns the build system triplet.
2940 @t{@b{isbuild} @i{pattern}}
2943 @node isremote procedure, is_remote procedure, isbuild procedure, Core Internal Procedures
2944 @subsubheading isremote Procedure
2947 Is @i{board} remote? Return a non-zero value, if so.
2950 @t{@b{isremote} @i{ board }}
2953 This procedure is to be used instead of @code{is_remote}.
2955 @node is_remote procedure, is3way procedure, isremote procedure, Core Internal Procedures
2956 @subsubheading is_remote Procedure
2959 Is @i{board} remote? Return a non-zero value, if so.
2962 @t{@b{is_remote} @i{ board }}
2965 Note that this procedure is now deprecated. Use @code{isremote}
2968 @node is3way procedure, ishost procedure, is_remote procedure, Core Internal Procedures
2969 @subsubheading is3way Procedure
2972 Tests for a Canadian cross. This is when the tests will be run on a
2973 remotely hosted cross-compiler. If it is a Canadian cross, then the
2974 result is @emph{1}; otherwise @emph{0}.
2980 @node ishost procedure, istarget procedure, is3way procedure, Core Internal Procedures
2981 @subsubheading ishost Procedure
2984 Tests for a particular host environment. If the currently configured
2985 host matches the argument string, the result is @emph{1}; otherwise
2986 the result is @emph{0}. @emph{pattern} must be a full three-part
2987 configure triplet; in particular, you may not use the shorter aliases
2988 supported by @code{configure} (but you can use Tcl globbing to specify
2989 a range of triplets). If called with no arguments or an empty
2990 pattern, this procedure returns the host triplet.
2993 @t{@b{ishost} @i{pattern}}
2996 @node istarget procedure, isnative procedure, ishost procedure, Core Internal Procedures
2997 @subsubheading istarget Procedure
3000 Tests for a particular target environment. If the currently
3001 configured target matches the argument string, the result is @emph{1}
3002 ; otherwise the result is @emph{0}. @emph{pattern} must be a full
3003 three-part configure triplet; in particular, you may not use the
3004 shorter aliases supported by @code{configure} (but you can use Tcl
3005 globbing to specify a range of triplets). If called with no arguments
3006 or an empty pattern, this procedure returns the target triplet.
3009 @t{@b{istarget} @i{pattern} }
3012 @node isnative procedure, log_and_exit procedure, istarget procedure, Core Internal Procedures
3013 @subsubheading isnative Procedure
3016 This procedure returns @emph{1} if the current configuration has the
3017 same host and target (ie. it is a native configuration). Otherwise it
3024 @node log_and_exit procedure, log_summary procedure, isnative procedure, Core Internal Procedures
3025 @subsubheading log_and_exit Procedure
3026 @findex log_and_exit
3029 @t{@b{log_and_exit}}
3032 This procedure writes out the end of the test log and terminates
3036 @node log_summary procedure, setup_xfail procedure, log_and_exit procedure, Core Internal Procedures
3037 @subsubheading log_summary Procedure
3041 @t{@b{log_summary} @i{args}}
3048 @node setup_xfail procedure, pass procedure, log_summary procedure, Core Internal Procedures
3049 @subsubheading setup_xfail Procedure
3052 Declares that the test is expected to fail on a particular set of
3053 configurations. The config argument must be a list of full three-part
3054 configure target name; in particular, you may not use the shorter
3055 nicknames supported by configure (but you can use the common shell
3056 wildcard characters to specify a range of triplets). The @emph{bugid}
3057 argument is optional, and used only in the logging file output; use it
3058 as a link to a bug-tracking system such as GNATS.
3060 Once you use @code{setup_xfail}, the @code{fail} and @code{pass}
3061 procedures produce the messages @emph{XFAIL} and @emph{XPASS}
3062 respectively, allowing you to distinguish expected failures (and
3063 unexpected success!) from other test outcomes.
3069 Warning you must clear the expected failure after using setup_xfail in
3070 a test case. Any call to @code{pass }or @code{fail} clears the
3071 expected failure implicitly; if the test has some other outcome,
3072 e.g. an error, you can call @code{clear_xfail} to clear the expected
3073 failure explicitly. Otherwise, the expected-failure declaration
3074 applies to whatever test runs next, leading to surprising results.
3078 @t{@b{setup_xfail} @i{config} @i{bugid}}
3083 The config triplet to trigger whether this is an unexpected or expect
3087 The optional bugid, used to tie this test case to a bug tracking
3091 @node pass procedure, fail procedure, setup_xfail procedure, Core Internal Procedures
3092 @subsubheading pass Procedure
3095 Declares a test to have passed. @code{pass} writes in the log files a
3096 message beginning with @emph{PASS} (or @emph{XPASS}, if failure was
3097 expected), appending the @code{message} argument.
3100 @t{@b{pass} @i{message} }
3103 @node fail procedure, xpass procedure, pass procedure, Core Internal Procedures
3104 @subsubheading fail Procedure
3107 Declares a test to have failed. @code{fail} writes in the log files a
3108 message beginning with @emph{FAIL} (or @emph{XFAIL}, if failure was
3109 expected), appending the @code{message} argument.
3112 @t{@b{fail} @i{message} }
3115 @node xpass procedure, xfail procedure, fail procedure, Core Internal Procedures
3116 @subsubheading xpass Procedure
3119 Declares a test to have passed when it was expected to fail.
3120 @code{xpass} writes in the log files a message beginning with
3121 @emph{XPASS} (or @emph{XFAIL} if failure was expected) and the
3122 @code{message} argument.
3125 @t{@b{xpass} @i{message} }
3128 @node xfail procedure, set_warning_threshold procedure, xpass procedure, Core Internal Procedures
3129 @subsubheading xfail Procedure
3132 Declares a test to have expectedly failed. @code{xfail} writes in the
3133 log files a message beginning with @emph{XFAIL} (or @emph{PASS}, if
3134 success was expected), appending the @code{message} argument.
3137 @t{@b{xpass} @i{message} }
3140 @node set_warning_threshold procedure, get_warning_threshold procedure, xfail procedure, Core Internal Procedures
3141 @subsubheading set_warning_threshold Procedure
3142 @findex set_warning_threshold
3144 Sets the value of @code{warning_threshold}. A value of @emph{0}
3145 disables it: calls to @code{warning} will not turn a @emph{PASS} or
3146 @emph{FAIL} into an @emph{UNRESOLVED}.
3149 @t{@b{set_warning_threshold} @i{threshold}}
3154 @item @code{threshold}
3155 This is the value of the new warning threshold.
3158 @node get_warning_threshold procedure, warning procedure, set_warning_threshold procedure, Core Internal Procedures
3159 @subsubheading get_warning_threshold Procedure
3160 @findex get_warning_threshold
3162 Returns the current value of @code{@{warning_threshold}. The default
3163 value is 3. This value controls how many @code{warning} procedures
3164 can be called before becoming @emph{UNRESOLVED}.
3167 @t{@b{get_warning_threshold}}
3170 @node warning procedure, perror procedure, get_warning_threshold procedure, Core Internal Procedures
3171 @subsubheading warning Procedure
3174 Declares detection of a minor error in the test case itself.
3175 @code{warning} writes in the log files a message beginning with
3176 @emph{WARNING}, appending the argument @code{string}. Use
3177 @code{warning} rather than @code{perror} for cases (such as
3178 communication failure to be followed by a retry) where the test case
3179 can recover from the error. If the optional @code{number} is
3180 supplied, then this is used to set the internal count of warnings to
3183 As a side effect, @code{warning_threshold} or more calls to warning in
3184 a single test case also changes the effect of the next @code{pass} or
3185 @code{fail} command: the test outcome becomes @emph{UNRESOLVED} since
3186 an automatic @emph{PASS} or @emph{FAIL} may not be trustworthy after
3187 many warnings. If the optional numeric value is @emph{0}, then there
3188 are no further side effects to calling this function, and the
3189 following test outcome doesn't become @emph{UNRESOLVED}. This can be
3190 used for errors with no known side effects.
3193 @t{@b{warning} @i{messsage} @i{number} }
3198 @item @code{message}
3199 The warning message.
3202 The optional number to set the error counter. This is only used to
3203 fake out the counter when using the @code{xfail} procedure to control
3204 when it flips the output over to @emph{UNRESOLVED} state.
3207 @node perror procedure, note procedure, warning procedure, Core Internal Procedures
3208 @subsubheading perror Procedure
3211 Declares a severe error in the testing framework itself.
3212 @code{perror} writes in the log files a message beginning with
3213 @emph{ERROR}, appending the argument @code{string}.
3215 As a side effect, perror also changes the effect of the next
3216 @code{pass} or @code{fail} command: the test outcome becomes
3217 @emph{UNRESOLVED}, since an automatic @emph{PASS} or @emph{FAIL}
3218 cannot be trusted after a severe error in the test framework. If the
3219 optional numeric value is @emph{0}, then there are no further side
3220 effects to calling this function, and the following test outcome
3221 doesn't become @emph{UNRESOLVED}. This can be used for errors with no
3225 @t{@b{perror} @i{message} @i{number} }
3229 @item @code{message}
3230 The message to be logged.
3233 The optional number to set the error counter. This is only used to
3234 fake out the counter when using the @code{xfail} procedure to control
3235 when it flips the output over to @emph{UNRESOLVED} state.
3238 @node note procedure, untested procedure, perror procedure, Core Internal Procedures
3239 @subsubheading note Procedure
3242 Appends an informational message to the log file. @code{note} writes
3243 in the log files a message beginning with @emph{NOTE}, appending the
3244 @code{message} argument. Use @code{note} sparingly. The
3245 @code{verbose} should be used for most such messages, but in cases
3246 where a message is needed in the log file regardless of the verbosity
3247 level use @code{note}.
3250 @t{@b{note} @i{messsage} }
3254 @node untested procedure, unresolved procedure, note procedure, Core Internal Procedures
3255 @subsubheading untested Procedure
3258 Declares a test was not run. @code{untested} writes in the log file a
3259 message beginning with @emph{UNTESTED}, appending the @code{message}
3260 argument. For example, you might use this in a dummy test whose only
3261 role is to record that a test does not yet exist for some feature.
3264 @t{@b{untested} @i{message} }
3268 @node unresolved procedure, unsupported procedure, untested procedure, Core Internal Procedures
3269 @subsubheading unresolved Procedure
3272 Declares a test to have an unresolved outcome. @code{unresolved}
3273 writes in the log file a message beginning with @emph{UNRESOLVED},
3274 appending the @code{message} argument. This usually means the test
3275 did not execute as expected, and a human being must go over results to
3276 determine if it passed or failed (and to improve the test case).
3279 @t{@b{unresolved} @i{message} }
3283 @node unsupported procedure, transform procedure, unresolved procedure, Core Internal Procedures
3284 @subsubheading unsupported Procedure
3287 Declares that a test case depends on some facility that does not exist
3288 in the testing environment. @code{unsupported} writes in the log file
3289 a message beginning with @emph{UNSUPPORTED}, appending the
3290 @code{message} argument.
3293 @t{@b{unsupported} @i{message} }
3297 @node transform procedure, check_conditional_xfail procedure, unsupported procedure, Core Internal Procedures
3298 @subsubheading transform Procedure
3301 Generates a string for the name of a tool as it was configured and
3302 installed, given its native name (as the argument @code{toolname}).
3303 This makes the assumption that all tools are installed using the same
3304 naming conventions: For example, for a cross compiler supporting the
3305 @emph{m68k-vxworks} configuration, the result of transform @code{gcc}
3306 is @code{m68k-vxworks-gcc}.
3309 @t{@b{transform} @i{toolname}}
3314 @item @code{toolname}
3315 The name of the cross-development program to transform.
3318 @node check_conditional_xfail procedure, clear_xfail procedure, transform procedure, Core Internal Procedures
3319 @subsubheading check_conditional_xfail Procedure
3320 @findex check_conditional_xfail
3322 This procedure adds a conditional xfail, based on compiler options
3323 used to create a test case executable. If an include options is found
3324 in the compiler flags, and it's the right architecture, it'll trigger
3325 an @emph{XFAIL}. Otherwise it'll produce an ordinary @emph{FAIL}.
3326 You can also specify flags to exclude. This makes a result be a
3327 @emph{FAIL}, even if the included options are found. To set the
3328 conditional, set the variable @code{compiler_conditional_xfail_data}
3332 "[message string] [targets list] [includes list] [excludes list]"
3335 (descriptions below). This is the checked at pass/fail decision time,
3336 so there is no need to call the procedure yourself, unless you wish to
3337 know if it gets triggered. After a pass/fail, the variable is reset,
3338 so it doesn't effect other tests. It returns @emph{1} if the
3339 conditional is true, or @emph{0} if the conditional is false.
3342 @t{@b{check_conditional_xfail} @i{message} @i{targets} @i{includes}
3348 @item @code{message}
3349 This is the message to print with the normal test result.
3351 @item @code{targets}
3352 This is a string with the list targets to activate this conditional
3355 @item @code{includes}
3356 This is a list of sets of options to search for in the compiler
3357 options to activate this conditional. If the list of sets of options
3358 is empty or if any set of the options matches, then this conditional
3359 is true. (It may be useful to specify an empty list of include sets
3360 if the conditional is always true unless one of the exclude sets
3363 @item @code{excludes}
3364 This is a list of sets of options to search for in the compiler
3365 options to activate this conditional. If any set of the options
3366 matches, (regardless of whether any of the include sets match) then
3367 this conditional is de-activated.
3370 @strong{Specifying the conditional xfail data}
3373 set compiler_conditional_xfail_data @{ \
3374 "I sure wish I knew why this was hosed" \
3375 "sparc*-sun*-* *-pc-*-*" \
3376 @{"-Wall -v" "-O3"@} \
3381 What this does is it matches only for these two targets if @code{-Wall
3382 -v} or @code{-O3} is set, but neither @code{-O1} or @code{-Map} is
3383 set. For a set to match, the options specified are searched for
3384 independently of each other, so a @code{-Wall -v} matches either
3385 @code{-Wall -v} or @code{-v -Wall}. A space separates the options in
3386 the string. Glob patterns are also permitted.
3388 @node clear_xfail procedure, verbose procedure, check_conditional_xfail procedure, Core Internal Procedures
3389 @subsubheading clear_xfail Procedure
3392 Cancel an expected failure (previously declared with
3393 @code{setup_xfail}) for a particular set of configurations. The
3394 @code{config} argument is a list of configuration target names. It is
3395 only necessary to call @code{clear_xfail} if a test case ends without
3396 calling either @code{pass} or @code{fail}, after calling
3400 @t{@b{clear_xfail} @i{config}}
3406 The system triplets to clear.
3409 @node verbose procedure, load_lib procedure, clear_xfail procedure, Core Internal Procedures
3410 @subsubheading verbose Procedure
3413 Test cases can use this procedure to issue helpful messages depending
3414 on the number of @code{-v}/@code{--verbose} options passed on the
3415 command line to @code{runtest}. It prints @i{message} if the value of
3416 the number of @code{-v} options passed is greater than or equal to the
3417 @i{loglevel} argument. The default log level is 1.
3431 Always write @i{message} to the log file, even if it won't be printed
3435 Log the @i{message} into an XML file.
3438 Print @i{message} without a trailing newline.
3441 Use this option if @i{message} begins with @samp{-}.
3443 @item @code{message}
3446 @item @code{loglevel}
3447 The specified log level. The default level is 1.
3450 @node load_lib procedure, testsuite procedure, verbose procedure, Core Internal Procedures
3451 @subsubheading load_lib Procedure
3454 @code{load_lib} loads a DejaGnu library file by searching the default
3455 fixed paths built into DejaGnu. If DejaGnu has been installed, it
3456 looks in a path starting with the installed library directory. If you
3457 are running DejaGnu directly from a source directory, without first
3458 running @code{make install}, this path defaults to the current
3459 directory. In either case, it then looks in the current directory for
3460 a directory called @file{lib}. If there are duplicate definitions,
3461 the last one loaded takes precedence over the earlier ones.
3464 @t{@b{load_lib} @i{filespec}}
3469 @item @code{filespec}
3470 The name of the DejaGnu library file to load.
3473 The global variable @code{libdirs}, handled as a list, is appended to
3474 the default fixed paths built into DejaGnu.
3476 @strong{Additional search directories for load_lib}
3479 # append a non-standard search path
3481 lappend libdirs $srcdir/../../gcc/testsuite/lib
3482 # now loading $srcdir/../../gcc/testsuite/lib/foo.exp works
3486 @node testsuite procedure, testcase procedure, load_lib procedure, Core Internal Procedures
3487 @subsubheading testsuite Procedure
3490 The @code{testsuite} procedure is a multiplex call for retrieving or
3491 providing information about the current testsuite.
3493 @subsubheading testsuite file
3495 The @code{testsuite file} command returns an absolute file name
3496 specified relative to either the testsuite source or object trees.
3499 @t{ @b{testsuite file}
3500 ?@b{-source}|@b{-object}?
3503 ?@b{--}? @i{name}... }
3506 Any number of @i{name}s are accepted and combined as if by @code{file
3507 join} with a directory relevant to the testsuite prepended.
3511 @item @code{-object}
3512 Return a file name in the object tree.
3514 @item @code{-source}
3515 Return a file name in the source tree.
3518 Prepend the @code{testsuite} directory itself.
3521 Prepend the directory containing the current test script.
3523 @item @code{-hypothetical}
3524 Allow the returned value to imply directories that do not exist.
3527 Use this option if the first @i{name} could begin with @samp{-}.
3531 One of @code{-top} or @code{-test} must be given; an error is raised
3534 Unless the @code{-hypothetical} option is given, any directories
3535 implied by the returned value will exist upon return. Implied
3536 directories are created in the object tree if needed. An error is
3537 raised if an implied directory does not exist in the source tree.
3539 @subsubheading testsuite can call
3541 The @code{testsuite can call} command is a feature test and returns a
3542 boolean value indicating if a subcommand under a multiplex point is
3543 available. This API call is needed because only the multiplex points
3544 themselves are visible to the Tcl info command.
3547 @t{ @b{testsuite can call} @i{feature}... }
3550 Any number of words are joined together into a single name, beginning
3551 with a multiplex entry point and forming the full name of an API call
3552 as documented in this manual.
3554 @node testcase procedure, , testsuite procedure, Core Internal Procedures
3555 @subsubheading testcase Procedure
3557 The @code{testcase} procedure is a multiplex call for retrieving or
3558 providing information about the state of the testing process.
3560 @subsubheading testcase group
3562 The @code{testcase group} command provides support for grouping tests
3563 into hierarchical groups within a test script.
3565 Group names are internally tracked as Tcl lists, but are reported as
3566 strings delimited using forward slash (@samp{/}) characters.
3567 Individual name elements may not contain whitespace, but may contain
3568 forward slash. A group entered by traversing intermediate levels must
3569 be left by traversing those same levels. Groups must properly nest.
3571 There are three uses:
3574 @t{ @b{testcase group}}
3577 Return the current group as a string delimited with forward slash
3578 (@samp{/}) characters.
3581 @t{ @b{testcase group begin} @i{name}}
3584 @t{ @b{testcase group end} @i{name}}
3587 These forms allow a group to be explicitly entered and left. The
3588 @i{name} parameter must be identical across a pair of these calls, and
3589 both the @code{begin} and @code{end} calls must be in the same file.
3592 @t{ @b{testcase group eval} @i{name} @{@i{code}@}}
3595 This form is available to wrap the @code{begin} and @code{end} calls
3596 around the execution of the provided @i{code}. This form is preferred
3597 for convenience in top-level scripts, but the @code{begin} and
3598 @code{end} calls are preferred in helper procedures for performance.
3600 @node Procedures For Remote Communication, connprocs, Core Internal Procedures, Built-in Procedures
3601 @section Procedures For Remote Communication
3603 The file @file{lib/remote.exp} defines procedures for establishing and
3604 managing communications. Each of these procedures tries to establish
3605 the connection up to three times before returning. Warnings (if
3606 retries will continue) or errors (if the attempt is abandoned) report
3607 on communication failures. The result for any of these procedures is
3608 either @emph{-1}, when the connection cannot be established, or the
3609 spawn ID returned by the Expect command @code{spawn}.
3611 It use the value of the @code{connect} field in the @code{target_info}
3612 array as the type of connection to make. Current supported connection
3613 types are ssh, tip, kermit, telnet, rsh, and rlogin. If the
3614 @code{--reboot} option was used on the @command{runtest} command line,
3615 then the target is rebooted before the connection is made.
3618 * call_remote Procedure: call_remote procedure
3619 * check_for_board_status Procedure: check_for_board_status procedure
3620 * file_on_build Procedure: file_on_build procedure
3621 * file_on_host Procedure: file_on_host procedure
3622 * local_exec Procedure: local_exec procedure
3623 * remote_binary Procedure: remote_binary procedure
3624 * remote_close Procedure: remote_close procedure
3625 * remote_download Procedure: remote_download procedure
3626 * remote_exec Procedure: remote_exec procedure
3627 * remote_expect Procedure: remote_expect procedure
3628 * remote_file Procedure: remote_file procedure
3629 * remote_ld Procedure: remote_ld procedure
3630 * remote_load Procedure: remote_load procedure
3631 * remote_open Procedure: remote_open procedure
3632 * remote_pop_conn Procedure: remote_pop_conn procedure
3633 * remote_push_conn Procedure: remote_push_conn procedure
3634 * remote_raw_binary Procedure: remote_raw_binary procedure
3635 * remote_raw_close Procedure: remote_raw_close procedure
3636 * remote_raw_file Procedure: remote_raw_file procedure
3637 * remote_raw_ld Procedure: remote_raw_ld procedure
3638 * remote_raw_load Procedure: remote_raw_load procedure
3639 * remote_raw_open Procedure: remote_raw_open procedure
3640 * remote_raw_send Procedure: remote_raw_send procedure
3641 * remote_raw_spawn Procedure: remote_raw_spawn procedure
3642 * remote_raw_transmit Procedure: remote_raw_transmit procedure
3643 * remote_raw_wait Procedure: remote_raw_wait procedure
3644 * remote_reboot Procedure: remote_reboot procedure
3645 * remote_send Procedure: remote_send procedure
3646 * remote_spawn Procedure: remote_spawn procedure
3647 * remote_swap_conn Procedure: remote_swap_conn procedure
3648 * remote_transmit Procedure: remote_transmit procedure
3649 * remote_upload Procedure: remote_upload procedure
3650 * remote_wait Procedure: remote_wait procedure
3651 * standard_close Procedure: standard_close procedure
3652 * standard_download Procedure: standard_download procedure
3653 * standard_exec Procedure: standard_exec procedure
3654 * standard_file Procedure: standard_file procedure
3655 * standard_load Procedure: standard_load procedure
3656 * standard_reboot Procedure: standard_reboot procedure
3657 * standard_send Procedure: standard_send procedure
3658 * standard_spawn Procedure: standard_spawn procedure
3659 * standard_transmit Procedure: standard_transmit procedure
3660 * standard_upload Procedure: standard_upload procedure
3661 * standard_wait Procedure: standard_wait procedure
3662 * unix_clean_filename Procedure: unix_clean_filename procedure
3665 @node call_remote procedure, check_for_board_status procedure, , Procedures For Remote Communication
3666 @subsubheading call_remote Procedure
3669 A standard procedure to call the appropriate @i{proc}. This proceure
3670 first looks for a board-specific version, then a protocol-specific
3671 version, and finally @code{call_remote} will call
3672 @code{standard_$proc}.
3675 @t{@b{call_remote} @i{type} @i{proc} @i{dest} @i{args}}
3684 @node check_for_board_status procedure, file_on_build procedure, call_remote procedure, Procedures For Remote Communication
3685 @subsubheading check_for_board_status Procedure
3686 @findex check_for_board_status
3688 This procedure inspected the named variable within the calling
3689 procedure for the expected output from the status wrapper. A
3690 non-negative value is returned if it exists. Otherwise, it returns
3691 -1. The output from the status wrapper is removed from the variable.
3694 @t{@b{check_for_board_status} @i{variable}}
3698 @item @code{variable}
3699 The name of the variable to check in the calling procedure. Be sure
3700 to pass the name of the variable (@code{var}) and not the value of the
3701 variable (@code{$var}).
3704 @node file_on_build procedure, file_on_host procedure, check_for_board_status procedure, Procedures For Remote Communication
3705 @subsubheading file_on_build Procedure
3706 @findex file_on_build
3709 @t{@b{file_on_build} @i{op} @i{file} @i{args}}
3718 @node file_on_host procedure, local_exec procedure, file_on_build procedure, Procedures For Remote Communication
3719 @subsubheading file_on_host Procedure
3720 @findex file_on_host
3723 @t{@b{file_on_host} @i{op} @i{file} @i{args}}
3732 @node local_exec procedure, remote_binary procedure, file_on_host procedure, Procedures For Remote Communication
3733 @subsubheading local_exec Procedure
3736 Run the specified command on the local machine, redirecting input from
3737 file @code{inp} (if non-empty), redirecting output to file @code{outp}
3738 (if non-empty), and waiting @code{timeout} seconds for the command to
3739 complete before killing it. A two-element list is returned: the exit
3740 status of the command and any output produced by the command. If
3741 output is redirected, this may or may not be empty. If output is
3742 redirected, both stdout and stderr will appear in the specified file.
3745 @t{@b{local_exec} @i{commandline} @i{inp} @i{outp} @i{timeout}}
3750 Redirect input into the input filename if not set to @code{""}.
3753 Redirect output into the output filename if not set to @code{""}.
3755 @item @code{timeout}
3760 @node remote_binary procedure, remote_close procedure, local_exec procedure, Procedures For Remote Communication
3761 @subsubheading remote_binary Procedure
3762 @findex remote_binary
3764 This procedure sets the connection into @i{binary} mode. That is,
3765 there is no processing of input characters.
3768 @t{@b{remote_binary} @i{host}}
3773 The host on which to set a binary connection.
3776 @node remote_close procedure, remote_download procedure, remote_binary procedure, Procedures For Remote Communication
3777 @subsubheading remote_close Procedure
3778 @findex remote_close
3781 @t{@b{remote_close} @i{shellid}}
3786 @item @code{shellid}
3787 This is the value returned by a call to @code{remote_open}. This
3788 closes the connection to the target so resources can be used by
3789 others. This parameter can be left off if the @code{fileid} field in
3790 the @code{target_info} array is set.
3793 @node remote_download procedure, remote_exec procedure, remote_close procedure, Procedures For Remote Communication
3794 @subsubheading remote_download Procedure
3795 @findex remote_download
3797 Download a file to a destination machine. This procedure returns
3798 either an empty string (indicating failure) or the name of the file on
3799 the destination macine.
3802 @t{@b{remote_download} @i{dest} @i{file} @i{args}}
3807 Destination machine name.
3813 If the optional destination filename is specified, that filename will
3814 be used on the destination machine.
3817 @node remote_exec procedure, remote_expect procedure, remote_download procedure, Procedures For Remote Communication
3818 @subsubheading remote_exec Procedure
3821 Execute the supplied program on a remote host. A two-element list is
3822 returned. The first element is the exit status of the program or -1
3823 if execution failed. The second element is any output produced by the
3824 program. This may be an empty string if output from the program was
3828 @t{ @b{remote_exec} @i{hostname} @i{program}
3829 ?@i{options}? ?@i{input}? ?@i{output}? ?@i{timeout}?}
3833 @item @code{hostname}
3834 Name of the host to execute the command on.
3836 @item @code{program}
3839 @item @code{options}
3840 Arguments to pass to the program.
3843 Input filename to feed to standard input of the command.
3846 Output filename where the output from the command should be written.
3848 @item @code{timeout}
3849 Timeout value in seconds.
3853 All of the optional positional arguments accept an empty string as a
3856 @node remote_expect procedure, remote_file procedure, remote_exec procedure, Procedures For Remote Communication
3857 @subsubheading remote_expect Procedure
3858 @findex remote_expect
3861 @t{@b{remote_expect} @i{board} @i{timeout} @i{args}}
3866 @item @code{timeout}
3870 @node remote_file procedure, remote_ld procedure, remote_expect procedure, Procedures For Remote Communication
3871 @subsubheading remote_file Procedure
3875 @t{@b{remote_file} @i{dest} @i{args}}
3885 @node remote_ld procedure, remote_load procedure, remote_file procedure, Procedures For Remote Communication
3886 @subsubheading remote_ld Procedure
3890 @t{@b{remote_ld} @i{dest} @i{prog}}
3898 @node remote_load procedure, remote_open procedure, remote_ld procedure, Procedures For Remote Communication
3899 @subsubheading remote_load Procedure
3903 @t{@b{remote_load} @i{dest} @i{prog} @i{args}}
3912 @node remote_open procedure, remote_pop_conn procedure, remote_load procedure, Procedures For Remote Communication
3913 @subsubheading remote_open Procedure
3916 Open connection to a remote host or target. This requires the
3917 @code{target_info} array be filled in with the proper information to
3918 work. It returns the spawn id of the process that is the connection.
3921 @t{@b{remote_open} @i{type}}
3926 This is passed @code{host} or @code{target}. Host or target refers to
3927 whether it is a connection to a remote target, or a remote host. This
3928 opens the connection to the desired target or host using the default
3929 values in the configuration system. It returns that @code{spawn_id}
3930 of the process that manages the connection. This value can be used in
3931 Expect or @code{exp_send} statements, or passed to other procedures
3932 that need the connection process's id. This also sets the
3933 @code{fileid} field in the @code{target_info} array.
3936 @node remote_pop_conn procedure, remote_push_conn procedure, remote_open procedure, Procedures For Remote Communication
3937 @subsubheading remote_pop_conn Procedure
3938 @findex remote_pop_conn
3940 Pop a previously-pushed connection from the stack. You should have
3941 closed the current connection before calling this procedure. Returns
3942 @code{pass} or @code{fail}.
3945 @t{@b{remote_pop_conn} @i{host}}
3952 @node remote_push_conn procedure, remote_raw_binary procedure, remote_pop_conn procedure, Procedures For Remote Communication
3953 @subsubheading remote_push_conn Procedure
3954 @findex remote_push_conn
3956 Pushes the current connection onto a stack. Returns @code{pass} or
3960 @t{@b{remote_push_conn} @i{host}}
3967 @node remote_raw_binary procedure, remote_raw_close procedure, remote_push_conn procedure, Procedures For Remote Communication
3968 @subsubheading remote_raw_binary Procedure
3969 @findex remote_raw_binary
3972 @t{@b{remote_raw_binary} @i{host}}
3979 @node remote_raw_close procedure, remote_raw_file procedure, remote_raw_binary procedure, Procedures For Remote Communication
3980 @subsubheading remote_raw_close Procedure
3981 @findex remote_raw_close
3984 @t{@b{remote_raw_close} @i{host}}
3991 @node remote_raw_file procedure, remote_raw_ld procedure, remote_raw_close procedure, Procedures For Remote Communication
3992 @subsubheading remote_raw_file Procedure
3993 @findex remote_raw_file
3996 @t{@b{remote_raw_file} @i{dest} @i{args}}
4005 @node remote_raw_ld procedure, remote_raw_load procedure, remote_raw_file procedure, Procedures For Remote Communication
4006 @subsubheading remote_raw_ld Procedure
4007 @findex remote_raw_ld
4010 @t{@b{remote_raw_ld} @i{dest} @i{prog}}
4018 @node remote_raw_load procedure, remote_raw_open procedure, remote_raw_ld procedure, Procedures For Remote Communication
4019 @subsubheading remote_raw_load Procedure
4020 @findex remote_raw_load
4023 @t{@b{remote_raw_load} @i{dest} @i{prog} @i{args}}
4032 @node remote_raw_open procedure, remote_raw_send procedure, remote_raw_load procedure, Procedures For Remote Communication
4033 @subsubheading remote_raw_open Procedure
4034 @findex remote_raw_open
4037 @t{@b{remote_raw_open} @i{args}}
4044 @node remote_raw_send procedure, remote_raw_spawn procedure, remote_raw_open procedure, Procedures For Remote Communication
4045 @subsubheading remote_raw_send Procedure
4046 @findex remote_raw_send
4050 @t{@b{remote_raw_send} @i{dest} @i{string}}
4058 @node remote_raw_spawn procedure, remote_raw_transmit procedure, remote_raw_send procedure, Procedures For Remote Communication
4059 @subsubheading remote_raw_spawn Procedure
4060 @findex remote_raw_spawn
4063 @t{@b{remote_raw_spawn} @i{dest} @i{commandline}}
4068 @item @code{commandline}
4071 @node remote_raw_transmit procedure, remote_raw_wait procedure, remote_raw_spawn procedure, Procedures For Remote Communication
4072 @subsubheading remote_raw_transmit Procedure
4073 @findex remote_raw_transmit
4076 @t{@b{remote_raw_transmit} @i{dest} @i{file}}
4084 @node remote_raw_wait procedure, remote_reboot procedure, remote_raw_transmit procedure, Procedures For Remote Communication
4085 @subsubheading remote_raw_wait Procedure
4086 @findex remote_raw_wait
4089 @t{@b{remote_raw_wait} @i{dest} @i{timeout}}
4094 @item @code{timeout}
4097 @node remote_reboot procedure, remote_send procedure, remote_raw_wait procedure, Procedures For Remote Communication
4098 @subsubheading remote_reboot Procedure
4099 @findex remote_reboot
4101 Reboot the host. The return value of this procedure depends on the
4102 actual implementation of reboot that will be used, in practice it is
4103 expected that @code{remote_reboot} returns @b{1} on success and @b{0}
4107 @t{@b{remote_reboot} @i{host}}
4114 @node remote_send procedure, remote_spawn procedure, remote_reboot procedure, Procedures For Remote Communication
4115 @subsubheading remote_send Procedure
4119 @t{@b{remote_send} @i{dest} @i{string}}
4127 @node remote_spawn procedure, remote_swap_conn procedure, remote_send procedure, Procedures For Remote Communication
4128 @subsubheading remote_spawn Procedure
4129 @findex remote_spawn
4131 Start a command on the destination. By default it is not possible to
4132 redirect I/O. If the command is successfully started, a positive
4133 spawn ID is returned. If the spawn fails, a negative value will be
4134 returned. Once the command has started, you can interact with it
4135 using @code{remote_expect} and @code{remote_wait} procedures.
4138 @t{@b{remote_spawn} @i{dest} @i{commandline} @i{args}}
4145 @item @code{commandline}
4146 The command to execute.
4149 If the optional keyword @code{readonly} is specified, input to the
4150 command may be redirected.
4153 @node remote_swap_conn procedure, remote_transmit procedure, remote_spawn procedure, Procedures For Remote Communication
4154 @subsubheading remote_swap_conn Procedure
4155 @findex remote_swap_conn
4157 Swap the current connection with the topmost one on the stack.
4158 Returns @code{pass} or @code{fail}.
4161 @t{@b{remote_swap_conn} @i{host}}
4168 @node remote_transmit procedure, remote_upload procedure, remote_swap_conn procedure, Procedures For Remote Communication
4169 @subsubheading remote_transmit Procedure
4170 @findex remote_transmit
4173 @t{@b{remote_transmit} @i{dest} @i{file}}
4181 @node remote_upload procedure, remote_wait procedure, remote_transmit procedure, Procedures For Remote Communication
4182 @subsubheading remote_upload Procedure
4183 @findex remote_upload
4186 @t{@b{remote_upload} @i{dest} @i{srcfile} @i{arg}}
4191 @item @code{srcfile}
4195 @node remote_wait procedure, standard_close procedure, remote_upload procedure, Procedures For Remote Communication
4196 @subsubheading remote_wait Procedure
4199 Wait for the last spawned command on the destination to complete. A
4200 list of two values is returned: the exit status (-1 if the program
4201 timed out) and any output produced by the command.
4204 @t{@b{remote_wait} @i{dest} @i{timeout}}
4209 The destination board.
4211 @item @code{timeout}
4212 The timeout in seconds.
4215 @node standard_close procedure, standard_download procedure, remote_wait procedure, Procedures For Remote Communication
4216 @subsubheading standard_close Procedure
4217 @findex standard_close
4219 This procedure closes a connection.
4222 @t{@b{standard_close} @i{host}}
4227 The host to close the connection to.
4230 @node standard_download procedure, standard_exec procedure, standard_close procedure, Procedures For Remote Communication
4231 @subsubheading standard_download Procedure
4232 @findex standard_download
4234 Downloads a file to a destination. It returns either the empty string
4235 (indicating failure) or the name of the file on the destination.
4238 @t{@b{standard_download} @i{dest} @i{file} @i{destfile}}
4246 The name of the file to download.
4248 @item @code{destfile}
4249 If the optional @i{destile} is specified, that filename will be used
4250 on the destination board.
4253 @node standard_exec procedure, standard_file procedure, standard_download procedure, Procedures For Remote Communication
4254 @subsubheading standard_exec Procedure
4255 @findex standard_exec
4258 @t{@b{standard_exec} @i{hostname} @i{args}}
4262 @item @code{hostname}
4266 @node standard_file procedure, standard_load procedure, standard_exec procedure, Procedures For Remote Communication
4267 @subsubheading standard_file Procedure
4268 @findex standard_file
4271 @t{@b{standard_file} @i{dest} @i{op} @i{args}}
4278 @node standard_load procedure, standard_reboot procedure, standard_file procedure, Procedures For Remote Communication
4279 @subsubheading standard_load Procedure
4280 @findex standard_load
4283 @t{@b{standard_load} @i{dest} @i{prog} @i{args}}
4292 @node standard_reboot procedure, standard_send procedure, standard_load procedure, Procedures For Remote Communication
4293 @subsubheading standard_reboot Procedure
4294 @findex standard_reboot
4296 It looks like that this procedure is never called, instead
4297 @code{$@{board@}_reboot} defined in @file{base-config.exp} will be
4298 used because it has higher priority and @file{base-config.exp} is
4299 always imported by @code{runtest}.
4302 @t{@b{standard_reboot} @i{host}}
4309 @node standard_send procedure, standard_spawn procedure, standard_reboot procedure, Procedures For Remote Communication
4310 @subsubheading standard_send Procedure
4311 @findex standard_send
4314 @t{@b{standard_send} @i{dest} @i{string}}
4322 @node standard_spawn procedure, standard_transmit procedure, standard_send procedure, Procedures For Remote Communication
4323 @subsubheading standard_spawn Procedure
4324 @findex standard_spawn
4327 @t{@b{standard_spawn} @i{dest} @i{commandline}}
4332 @item @code{commandline}
4335 @node standard_transmit procedure, standard_upload procedure, standard_spawn procedure, Procedures For Remote Communication
4336 @subsubheading standard_transmit Procedure
4337 @findex standard_transmit
4339 The default transmit procedure if none other exists. This feeds the
4340 file directly into the connection.
4343 @t{@b{standard_transmit} @i{dest} @i{file}}
4353 @node standard_upload procedure, standard_wait procedure, standard_transmit procedure, Procedures For Remote Communication
4354 @subsubheading standard_upload Procedure
4355 @findex standard_upload
4358 @t{@b{standard_upload} @i{dest srcfile destfile}}
4363 @item @code{srcfile}
4364 @item @code{destfile}
4367 @node standard_wait procedure, unix_clean_filename procedure, standard_upload procedure, Procedures For Remote Communication
4368 @subsubheading standard_wait Procedure
4369 @findex standard_wait
4372 @t{@b{standard_wait} @i{dest} @i{timeout}}
4377 @item @code{timeout}
4380 @node unix_clean_filename procedure, , standard_wait procedure, Procedures For Remote Communication
4381 @subsubheading unix_clean_filename Procedure
4382 @findex unix_clean_filename
4384 This procedure returns an absolute version of the filename argument
4385 with @samp{.} and @samp{..} removed.
4388 @t{@b{unix_clean_filename} @i{dest} @i{file}}
4397 @node connprocs, Procedures For Target Boards, Procedures For Remote Communication, Built-in Procedures
4398 @section Procedures For Using Utilities to Connect
4401 * kermit_open Procedure: kermit_open procedure
4402 * kermit_command Procedure: kermit_command procedure
4403 * kermit_send Procedure: kermit_send procedure
4404 * kermit_transmit Procedure: kermit_transmit procedure
4405 * telnet_open Procedure: telnet_open procedure
4406 * telnet_binary Procedure: telnet_binary procedure
4407 * tip_open Procedure: tip_open procedure
4408 * rlogin_open Procedure: rlogin_open procedure
4409 * rlogin_spawn Procedure: rlogin_spawn procedure
4410 * rsh_open Procedure: rsh_open procedure
4411 * rsh_download Procedure: rsh_download procedure
4412 * rsh_upload Procedure: rsh_upload procedure
4413 * rsh_exec Procedure: rsh_exec procedure
4414 * ssh_close Procedure: ssh_close procedure
4415 * ssh_exec Procedure: ssh_exec procedure
4416 * ssh_download Procedure: ssh_download procedure
4417 * ssh_upload Procedure: ssh_upload procedure
4418 * ftp_open Procedure: ftp_open procedure
4419 * ftp_upload Procedure: ftp_upload procedure
4420 * ftp_download Procedure: ftp_download procedure
4421 * ftp_close Procedure: ftp_close procedure
4422 * tip_download Procedure: tip_download procedure
4425 @node kermit_open procedure, kermit_command procedure, connprocs, connprocs
4426 @subsubheading kermit_open Procedure
4430 @t{@b{kermit_open} @i{dest} @i{args}}
4438 @node kermit_command procedure, kermit_send procedure, kermit_open procedure, connprocs
4439 @subsubheading kermit_command Procedure
4440 @findex kermit_command
4443 @t{@b{kermit_command} @i{dest} @i{args}}
4451 @node kermit_send procedure, kermit_transmit procedure, kermit_command procedure, connprocs
4452 @subsubheading kermit_send Procedure
4456 @t{@b{kermit_send} @i{dest string args}}
4465 @node kermit_transmit procedure, telnet_open procedure, kermit_send procedure, connprocs
4466 @subsubheading kermit_transmit Procedure
4467 @findex kermit_transmit
4470 @t{@b{kermit_transmit} @i{dest} @i{file} @i{args}}
4479 @node telnet_open procedure, telnet_binary procedure, kermit_transmit procedure, connprocs
4480 @subsubheading telnet_open Procedure
4483 This procedure opens a connection to a remote host using TELNET. This
4484 procedure sets the @code{fileid} field in the @code{board_info} array
4485 and returns the spawn id (or -1 for error).
4488 @t{@b{telnet_open} @i{hostname} @i{args}}
4492 @item @code{hostname}
4493 The host to connect to with TELNET.
4496 A list of options. Currently the only supported option is @code{raw}.
4499 @node telnet_binary procedure, tip_open procedure, telnet_open procedure, connprocs
4500 @subsubheading telnet_binary Procedure
4501 @findex telnet_binary
4503 Puts an existing TELNET connection into binary mode.
4506 @t{@b{telnet_binary} @i{hostname}}
4510 @item @code{hostname}
4511 Hostname for the connection.
4514 @node tip_open procedure, rlogin_open procedure, telnet_binary procedure, connprocs
4515 @subsubheading tip_open Procedure
4518 Connect to a host using @code{tip(1)}. This procedure sets the board
4519 @code{fileid} field with the @code{spawn_id} on success and,
4520 otherwise, returns -1.
4523 @t{@b{tip_open} @i{hostname}}
4527 @item @code{hostname}
4528 Hostname to connect to.
4531 @node rlogin_open procedure, rlogin_spawn procedure, tip_open procedure, connprocs
4532 @subsubheading rlogin_open Procedure
4536 @t{@b{rlogin_open} @i{arg}}
4543 @node rlogin_spawn procedure, rsh_open procedure, rlogin_open procedure, connprocs
4544 @subsubheading rlogin_spawn Procedure
4545 @findex rlogin_spawn
4548 @t{@b{rlogin_spawn} @i{dest} @i{cmdline}}
4553 @item @code{cmdline}
4556 @node rsh_open procedure, rsh_download procedure, rlogin_spawn procedure, connprocs
4557 @subsubheading rsh_open Procedure
4561 @t{@b{rsh_open} @i{hostname}}
4565 @item @code{hostname}
4568 @node rsh_download procedure, rsh_upload procedure, rsh_open procedure, connprocs
4569 @subsubheading rsh_download Procedure
4570 @findex rsh_download
4573 @t{@b{rsh_download} @i{desthost} @i{srcfile} @i{destfile}}
4577 @item @code{desthost}
4578 @item @code{srcfile}
4579 @item @code{destfile}
4582 @node rsh_upload procedure, rsh_exec procedure, rsh_download procedure, connprocs
4583 @subsubheading rsh_upload Procedure
4587 @t{@b{rsh_upload} @i{desthost} @i{srcfile} @i{destfile}}
4591 @item @code{desthost}
4592 @item @code{srcfile}
4593 @item @code{destfile}
4596 @node rsh_exec procedure, ssh_close procedure, rsh_upload procedure, connprocs
4597 @subsubheading rsh_exec Procedure
4601 @t{@b{rsh_exec} @i{boardname} @i{cmd} @i{args}}
4605 @item @code{boardname}
4610 @node ssh_close procedure, ssh_exec procedure, rsh_exec procedure, connprocs
4611 @subsubheading ssh_close procedure
4615 @t{@b{ssh_close} @i{desthost}}
4619 @item @code{desthost}
4622 @node ssh_exec procedure, ssh_download procedure, ssh_close procedure, connprocs
4623 @subsubheading ssh_exec procedure
4627 @t{@b{ssh_exec} @i{boardname} @i{program} @i{pargs} @i{inp} @i{outp}}
4631 @item @code{boardname}
4632 @item @code{program}
4638 @node ssh_download procedure, ssh_upload procedure, ssh_exec procedure, connprocs
4639 @subsubheading ssh_download procedure
4640 @findex ssh_download
4643 @t{@b{ssh_download} @i{desthost} @i{srcfile} @i{destfile}}
4647 @item @code{desthost}
4648 @item @code{srcfile}
4649 @item @code{destfile}
4652 @node ssh_upload procedure, ftp_open procedure, ssh_download procedure, connprocs
4653 @subsubheading ssh_upload procedure
4657 @t{@b{ssh_upload} @i{desthost} @i{srcfile} @i{destfile}}
4661 @item @code{desthost}
4662 @item @code{srcfile}
4663 @item @code{destfile}
4666 @node ftp_open procedure, ftp_upload procedure, ssh_upload procedure, connprocs
4667 @subsubheading ftp_open Procedure
4670 Open an FTP connection.
4673 @t{@b{ftp_open} @i{host}}
4678 The host to open the FTP connection to.
4681 @node ftp_upload procedure, ftp_download procedure, ftp_open procedure, connprocs
4682 @subsubheading ftp_upload Procedure
4685 Fetches a file from a remote host using FTP.
4688 @t{@b{ftp_upload} @i{host} @i{remotefile} @i{localfile}}
4693 The host to transfer the file from.
4695 @item @code{remotefile}
4696 The filename at the remote end.
4698 @item @code{localfile}
4699 The filename to store locally.
4703 @node ftp_download procedure, ftp_close procedure, ftp_upload procedure, connprocs
4704 @subsubheading ftp_download Procedure
4705 @findex ftp_download
4707 Sends a file to a remote host using FTP.
4710 @t{@b{ftp_download} @i{host} @i{localfile} @i{remotefile}}
4715 The host to transfer the file from.
4717 @item @code{localfile}
4718 The filename on the local system.
4720 @item @code{remotefile}
4721 The filename at the remote end.
4724 @node ftp_close procedure, tip_download procedure, ftp_download procedure, connprocs
4725 @subsubheading ftp_close Procedure
4728 Closes the FTP connection to a host.
4731 @t{@b{ftp_close} @i{host}}
4736 The host connection to close.
4739 @node tip_download procedure, , ftp_close procedure, connprocs
4740 @subsubheading tip_download Procedure
4741 @findex tip_download
4744 @t{@b{tip_download} @i{spawnid} @i{file}}
4749 @item @code{spawnid}
4750 Download @code{file} to the process @code{spawnid} (the value returned
4751 when the connection was established), using the @code{~put} command
4752 under tip. Most often used for single board computers that require
4753 downloading programs in ASCII S-records. Returns @emph{1} if an error
4754 occurs, @emph{0} otherwise.
4757 This is the filename to download.
4760 @node Procedures For Target Boards, target database library file, connprocs, Built-in Procedures
4761 @section Procedures For Target Boards
4764 * default_link Procedure: default_link procedure
4765 * default_target_assemble Procedure: default_target_assemble procedure
4766 * default_target_compile Procedure: default_target_compile procedure
4767 * pop_config Procedure: pop_config procedure
4768 * prune_warnings Procedure: prune_warnings procedure
4769 * push_build Procedure: push_build procedure
4770 * push_config Procedure: push_config procedure
4771 * reboot_target Procedure: reboot_target procedure
4772 * target_assemble Procedure: target_assemble procedure
4773 * target_compile Procedure: target_compile procedure
4774 * target_link Procedure: target_link procedure
4777 @node default_link procedure, default_target_assemble procedure, , Procedures For Target Boards
4778 @subsubheading default_link Procedure
4779 @findex default_link
4782 @t{@b{default_link} @i{board} @i{objects} @i{destfile} @i{flags}}
4785 This is the internal implementation for the @ref{target_link
4786 procedure}, and should not be directly called from testsuite code.
4788 @node default_target_assemble procedure, default_target_compile procedure, default_link procedure, Procedures For Target Boards
4789 @subsubheading default_target_assemble Procedure
4790 @findex default_target_assemble
4793 @t{@b{default_target_assemble} @i{source} @i{destfile} @i{flags}}
4796 This is the internal implementation for the @ref{target_assemble
4797 procedure}, and should not be directly called from testsuite code.
4799 @node default_target_compile procedure, pop_config procedure, default_target_assemble procedure, Procedures For Target Boards
4800 @subsubheading default_target_compile Procedure
4801 @findex default_target_compile
4804 @t{@b{default_target_compile} @i{source} @i{destfile} @i{type}
4808 This is the default implementation for the @ref{target_compile
4809 procedure}, and is used if the current target board does not have a
4810 special procedure for this purpose. @xref{target_compile procedure},
4811 for API details. Calling this procedure directly from testsuite code
4814 @node pop_config procedure, prune_warnings procedure, default_target_compile procedure, Procedures For Target Boards
4815 @subsubheading pop_config Procedure
4819 @t{@b{pop_config} @i{type}}
4826 @node prune_warnings procedure, push_build procedure, pop_config procedure, Procedures For Target Boards
4827 @subsubheading prune_warnings Procedure
4828 @findex prune_warnings
4831 @t{@b{prune_warnings} @i{text}}
4838 @node push_build procedure, push_config procedure, prune_warnings procedure, Procedures For Target Boards
4839 @subsubheading push_build Procedure
4843 @t{@b{push_build} @i{name}}
4850 @node push_config procedure, reboot_target procedure, push_build procedure, Procedures For Target Boards
4851 @subsubheading push_config Procedure
4855 @t{@b{push_config} @i{type} @i{name}}
4864 @node reboot_target procedure, target_assemble procedure, push_config procedure, Procedures For Target Boards
4865 @subsubheading reboot_target Procedure
4866 @findex reboot_target
4871 @t{@b{reboot_target}}
4874 @node target_assemble procedure, target_compile procedure, reboot_target procedure, Procedures For Target Boards
4875 @subsubheading target_assemble Procedure
4876 @findex target_assemble
4879 @t{@b{target_assemble} @i{source destfile flags}}
4884 @item @code{destfile}
4888 @node target_compile procedure, target_link procedure, target_assemble procedure, Procedures For Target Boards
4889 @subsubheading target_compile Procedure
4890 @findex target_compile
4893 @t{@b{target_compile} @i{source} @i{destfile} @i{type} @i{options}}
4898 Source file or other arguments if @var{type} is @code{none}.
4900 Destination file or empty string to request output as return value.
4902 Type of output that should be produced.
4903 @multitable {@code{preprocess}} {Special applications where no source is actually given.}
4905 @tab Special applications where no source is actually given.
4906 @item @code{preprocess}
4907 @tab Run the source files through the C preprocessor.
4908 @item @code{assembly}
4909 @tab Produce assembler source from the compiler.
4911 @tab Produce binary object files.
4912 @item @code{executable}
4913 @tab Produce an executable program.
4916 List of additional options:
4918 @b{Language-selection options:}
4921 Use an Ada compiler.
4925 Use a compiler for the D language.
4927 Use a compiler for Fortran 77.
4929 Use a compiler for Fortran 90.
4931 Use a compiler for Go.
4933 Use a compiler for Rust.
4935 If none of these options are given, the C compiler is used by default.
4936 Giving multiple language-selection options is an error.
4938 The @code{f77} option generally selects the @command{g77} compiler,
4939 while the @code{f90} option selects the newer @command{gfortran}
4940 frontend. Both of these can compile Fortran 77, but only
4941 @command{gfortran} supports Fortran 90.
4943 @b{Search path options:}
4945 @item incdir=@var{dir}
4946 Additional directory to search for preprocessor include files.
4947 Multiple uses of this option add multiple directories to the search
4949 @item libdir=@var{dir}
4950 Additional directory to search for libraries. Multiple uses of this
4951 option add multiple directories to the search path.
4957 Compile with debugging information. Multiple uses of this option are
4958 treated as a single use.
4959 @item dest=@var{target}
4960 Override the current target and compile for @var{target} instead. If
4961 this option is given multiple times, only the last use is significant.
4962 @item compiler=@var{command}
4963 Override the defaults and use @var{command} as the compiler. If
4964 this option is given multiple times, only the last use is significant.
4965 @item linker=@var{command}
4966 Override the defaults and use @var{command} to build executables. If
4967 this option is given multiple times, only the last use is significant.
4968 @item early_flags=@var{flags}
4969 Prepend @var{flags} to the set of arguments to be passed to the compiler.
4970 Multiple uses of this option specify additional arguments.
4971 @item additional_flags=@var{flags}
4972 Add @var{flags} to the set of arguments to be passed to the compiler.
4973 Multiple uses of this option specify additional arguments.
4974 @item optimize=@var{flags}
4975 Specify optimization flags to be passed to the compiler. Nothing
4976 enforces that the flags given with option must actually be related to
4977 optimization, however. If this option is given multiple times, only
4978 the last use is significant.
4979 @item ldflags=@var{flags}
4980 Add @var{flags} to the set of arguments to be passed to the linker.
4981 Note that these are passed literally to the compiler driver, without
4982 adding a special prefix to each option. If a @samp{-Wl,} prefix is
4983 needed with GCC, it must be included in the given @var{flags}. As a
4984 group, the linker flags are only used if an executable is requested
4985 and are given special treatment with some languages. Multiple uses of
4986 this option specify additional arguments.
4987 @item ldscript=@var{script}
4988 Specify a linker script, or more precisely, the argument to pass to
4989 the linker via the compiler driver to select a linker script. The
4990 @var{script} value is passed literally to the compiler driver. If
4991 this option is given multiple times, only the last use is significant.
4992 @item libs=@var{libs}
4993 Specify additional libraries to be included in the link. The
4994 @var{libs} value is a space-separated list of libraries to include.
4995 Each element is checked, and if a file exists with that exact name, it
4996 is added to the list of sources to be given to the compiler.
4997 Otherwise, the element is passed literally to the compiler driver
4998 after any linker flags specified with the @code{ldflags} option.
4999 Multiple uses of this option specify additional lists, which are
5000 concatenated in the order they are given.
5003 @b{Execution options:}
5005 @item timeout=@var{timeout}
5006 Abort the compile job if it is still running after @var{timeout}
5007 seconds. This is intended for compiler tests that are known to cause
5008 infinite loops upon failure.
5009 @item redirect=@var{file}
5010 Instead of returning output emitted on @code{stdout}, place it into
5015 The @code{target_compile} procedure also uses several global Tcl variables as overrides:
5017 @item CFLAGS_FOR_TARGET
5018 If @code{CFLAGS_FOR_TARGET} is set, its value is prepended to the
5019 flags otherwise prepared for the compiler, even ahead of any
5020 board-specific flags inserted as a result of a language-selection
5022 @item LDFLAGS_FOR_TARGET
5023 If @code{LDFLAGS_FOR_TARGET} is set, the set of arguments to be passed
5024 to linker is initialized to its value instead of an empty list. The
5025 @code{ldflags} option appends to this list.
5027 Override default compiler. If no other compiler is given and this
5028 variable is set, its value will be used instead of searching for a
5029 compiler or using the default from the target board configuration.
5030 The @code{compiler} option overrides this variable.
5031 @item CXX_FOR_TARGET
5032 Override C++ compiler. If the @code{c++} option is given, this
5033 compiler will be used and the @code{compiler} option ignored.
5035 Override D language compiler. If the @code{d} option is given, this
5036 compiler will be used and the @code{compiler} option ignored.
5037 @item F77_FOR_TARGET
5038 Override Fortran 77 compiler. If the @code{f77} option is given, this
5039 compiler will be used and the @code{compiler} option ignored.
5040 @item F90_FOR_TARGET
5041 Override Fortran 90 compiler. If the @code{f90} option is given, this
5042 compiler will be used and the @code{compiler} option ignored.
5044 Override Go compiler. If the @code{go} option is given, this
5045 compiler will be used and the @code{compiler} option ignored.
5046 @item GO_LD_FOR_TARGET
5047 Override Go linker. If the @code{go} option is given, this
5048 linker will be used.
5049 @item RUSTC_FOR_TARGET
5050 Override Rust compiler. If the @code{rust} option is given, this
5051 compiler will be used and the @code{compiler} option ignored.
5052 @item GNATMAKE_FOR_TARGET
5053 Override Ada compiler. If the @code{ada} option is given, this
5054 compiler will be used and the @code{compiler} option ignored.
5057 The @code{target_compile} procedure obtains most defaults from the
5058 target board configuration, but additionally inserts any flags
5059 specified as @code{cflags_for_target} on the @emph{host} board
5060 configuration. If no host is set, the @code{unix} board configuration
5061 is checked for a @code{cflags_for_target} key. If the
5062 @code{cflags_for_target} key exists, its value is inserted into the
5063 set of arguments given to the compiler after any arguments given with
5064 the @code{additional_flags} option.
5066 In DejaGnu 1.6.2 and older, this mechanism did not work reliably and
5067 the @code{unix} board configuration was always searched for the
5068 @code{cflags_for_target} key, regardless of the host board selected.
5070 Also in DejaGnu 1.6.2 and older, the @code{dest} option interacted
5071 very badly with the language-selection options. There was no correct
5072 way to combine these options because the language-specific defaults
5073 would be read from the current target board configuration instead of
5074 the board configuration specified with the @code{dest} option. The
5075 closest solution was to always specify the language-selection option
5076 first, but this results in defaults appropriate for the current
5077 target, instead of the target selected with the @code{dest} option.
5079 @node target_link procedure, , target_compile procedure, Procedures For Target Boards
5080 @subsubheading target_link Procedure
5084 @t{@b{target_link} @i{objects} @i{destfile} @i{flags}}
5088 @item @code{objects}
5089 @item @code{destfile}
5093 @node target database library file, platform dependent procedures, Procedures For Target Boards, Built-in Procedures
5094 @section Target Database Procedures
5097 * board_info Procedure: board_info procedure
5098 * host_info Procedure: host_info procedure
5099 * set_board_info Procedure: set_board_info procedure
5100 * add_board_info Procedure: add_board_info procedure
5101 * set_currtarget_info Procedure: set_currtarget_info procedure
5102 * target_info Procedure: target_info procedure
5103 * unset_board_info Procedure: unset_board_info procedure
5104 * unset_currtarget_info Procedure: unset_currtarget_info procedure
5105 * push_target Procedure: push_target procedure
5106 * pop_target Procedure: pop_target procedure
5107 * push_host Procedure: push_host procedure
5108 * pop_host Procedure: pop_host procedure
5111 @node board_info procedure, host_info procedure, , target database library file
5112 @subsubheading board_info Procedure
5115 Searches the @code{board_info} array for the specified information.
5118 @t{@b{board_info} @i{machine} @i{op} @i{args}}
5122 @item @code{machine}
5127 @node host_info procedure, set_board_info procedure, board_info procedure, target database library file
5128 @subsubheading host_info Procedure
5132 @t{@b{host_info} @i{op} @i{args}}
5140 @node set_board_info procedure, add_board_info procedure, host_info procedure, target database library file
5141 @subsubheading set_board_info Procedure
5142 @findex set_board_info
5144 This checks if the @code{board_info} array entry has been set already
5145 and, if not, sets it to given value.
5148 @t{@b{set_board_info} @i{entry} @i{value}}
5153 Field of the @code{board_info} to set.
5156 Value to set the field to.
5159 @node add_board_info procedure, set_currtarget_info procedure, set_board_info procedure, target database library file
5160 @subsubheading add_board_info Procedure
5161 @findex add_board_info
5163 This treats @code{board_info} array's field @emph{entry} as a TCL list
5164 and adds @emph{value} at the end.
5167 @t{@b{add_board_info} @i{entry} @i{value}}
5173 The name of a @code{board_info} field to operate on.
5176 The value to add to the field.
5179 @node set_currtarget_info procedure, target_info procedure, add_board_info procedure, target database library file
5180 @subsubheading set_currtarget_info Procedure
5181 @findex set_currtarget_info
5184 @t{@b{set_currtarget_info} @i{entry} @i{value}}
5192 @node target_info procedure, unset_board_info procedure, set_currtarget_info procedure, target database library file
5193 @subsubheading target_info Procedure
5197 @t{@b{target_info} @i{op} @i{args}}
5205 @node unset_board_info procedure, unset_currtarget_info procedure, target_info procedure, target database library file
5206 @subsubheading unset_board_info Procedure
5207 @findex unset_board_info
5209 This checks if @code{board_info} array's field @emph{entry} has been
5210 set and if so, then removes it.
5213 @t{@b{unset_board_info} @i{entry}}
5218 The name of a @code{board_info} field to operate on.
5221 @node unset_currtarget_info procedure, push_target procedure, unset_board_info procedure, target database library file
5222 @subsubheading unset_currtarget_info Procedure
5223 @findex unset_currtarget_info
5226 @t{@b{unset_currtarget_info} @i{entry}}
5233 @node push_target procedure, pop_target procedure, unset_currtarget_info procedure, target database library file
5234 @subsubheading push_target Procedure
5237 This makes the target named @emph{name} be the current target
5241 @t{@b{push_target} @i{name}}
5246 Name of the target to make the current connection.
5249 @node pop_target procedure, push_host procedure, push_target procedure, target database library file
5250 @subsubheading pop_target Procedure
5253 This unsets the current target connection.
5259 @node push_host procedure, pop_host procedure, pop_target procedure, target database library file
5260 @subsubheading push_host Procedure
5263 This procedure makes the host named @emph{name} be the current remote
5267 @t{@b{push_host} @i{name}}
5272 Name of the host to make the current connection.
5275 @node pop_host procedure, , push_host procedure, target database library file
5276 @subsubheading pop_host Procedure
5279 This unsets the current host connection.
5285 @node platform dependent procedures, Utility Procedures, target database library file, Built-in Procedures
5286 @section Platform Dependent Procedures
5288 Each combination of target and tool requires some target-dependent
5289 procedures. The names of these procedures have a common form: the
5290 tool name, followed by an underscore @emph{_}, and finally a suffix
5291 describing the procedure's purpose. For example, a procedure to
5292 extract the version from GDB is called @code{gdb_version}.
5294 @code{runtest} itself calls only two of these procedures,
5295 @code{$@{tool@}_exit} and @code{$@{tool@}_version}; these procedures
5298 The other two procedures, @code{$@{tool@}_start} and
5299 @code{$@{tool@}_load}, are only called by the test suites themselves
5300 (or by testsuite-specific initialization code); they may take
5301 arguments or not, depending on the conventions used within each
5304 The usual convention for return codes from any of these procedures
5305 (although it is not required by @code{runtest}) is to return @emph{0}
5306 if the procedure succeeded, @emph{1} if it failed, and @emph{-1} if
5307 there was a communication error.
5310 * $@{tool@}_start Procedure: $@{tool@}_start procedure
5311 * $@{tool@}_load Procedure: $@{tool@}_load procedure
5312 * $@{tool@}_exit Procedure: $@{tool@}_exit procedure
5313 * $@{tool@}_version Procedure: $@{tool@}_version procedure
5316 @node $@{tool@}_start procedure, $@{tool@}_load procedure, , platform dependent procedures
5317 @subsubheading $@{tool@}_start Procedure
5318 @findex $@{tool@}_start
5320 Starts a particular tool. For an interactive tool,
5321 @code{$@{tool@}_start} starts and initializes the tool, leaving the
5322 tool up and running for the test cases; an example is
5323 @code{gdb_start}, the start function for GDB. For a batch-oriented
5324 tool, @code{$@{tool@}_start} is optional; the recommended convention
5325 is to let @code{$@{tool@}_start} run the tool, leaving the output in a
5326 variable called @code{comp_output}. Test scripts can then analyze
5327 @code{$comp_output} to determine the test results. An example of this
5328 second kind of start function is @code{gcc_start}, the start function
5331 DejaGnu itself does not call @code{$@{tool@}_start}. The
5332 initialization module @code{$@{tool@}_init.exp} must call
5333 @code{$@{tool@}_start} for interactive tools; for batch-oriented
5334 tools, each individual test script calls @code{$@{tool@}_start} (or
5335 makes other arrangements to run the tool).
5338 @t{@b{$@{tool@}_start}}
5341 @node $@{tool@}_load procedure, $@{tool@}_exit procedure, $@{tool@}_start procedure, platform dependent procedures
5342 @subsubheading $@{tool@}_load Procedure
5343 @findex $@{tool@}_load
5345 Loads something into a tool. For an interactive tool, this conditions
5346 the tool for a particular test case; for example, @code{gdb_load}
5347 loads a new executable file into the debugger. For batch-oriented
5348 tools, @code{$@{tool@}_load} may do nothing---though, for example, the
5349 GCC support uses @code{gcc_load} to load and run a binary on the
5350 target environment. Conventionally, @code{$@{tool@}_load} leaves the
5351 output of any program it runs in a variable called
5352 @code{$exec_output}. Writing @code{$@{tool@}_load} can be the most
5353 complex part of extending DejaGnu to a new tool or a new target, if it
5354 requires much communication coding or file downloading. Test scripts
5355 call @code{$@{tool@}_load}.
5358 @t{@b{$@{tool@}_load}}
5361 @node $@{tool@}_exit procedure, $@{tool@}_version procedure, $@{tool@}_load procedure, platform dependent procedures
5362 @subsubheading $@{tool@}_exit Procedure
5363 @findex $@{tool@}_exit
5365 Cleans up (if necessary) before DejaGnu exits. For interactive tools,
5366 this usually ends the interactive session. You can also use
5367 @code{$@{tool@}_exit} to remove any temporary files left over from the
5368 tests. @code{runtest} calls @code{$@{tool@}_exit}.
5371 @t{@b{$@{tool@}_exit}}
5374 @node $@{tool@}_version procedure, , $@{tool@}_exit procedure, platform dependent procedures
5375 @subsubheading $@{tool@}_version Procedure
5376 @findex $@{tool@}_version
5378 Prints the version label and number for @code{$@{tool@}}. This is
5379 called by the DejaGnu procedure that prints the final summary report.
5380 The output should consist of the full path name used for the tested
5381 tool, and its version number.
5384 @t{@b{$@{tool@}_version}}
5387 @node Utility Procedures, Libgloss, platform dependent procedures, Built-in Procedures
5388 @section Utility Procedures
5391 * getdirs Procedure: getdirs procedure
5392 * relative_filename Procedure: relative_filename procedure
5393 * find Procedure: find procedure
5394 * which Procedure: which procedure
5395 * grep Procedure: grep procedure
5396 * prune Procedure: prune procedure
5397 * runtest_file_p Procedure: runtest_file_p procedure
5398 * diff Procedure: diff procedure
5399 * setenv Procedure: setenv procedure
5400 * unsetenv Procedure: unsetenv procedure
5401 * getenv Procedure: getenv procedure
5404 @node getdirs procedure, relative_filename procedure, Utility Procedures, Utility Procedures
5405 @subsubheading getdirs Procedure
5408 Returns a list of all the subdirectories in a single directory that
5409 match a glob pattern. If no directories match the pattern, then an
5410 empty list is returned.
5412 This procedure is specialized as a search for tests in testsuites:
5413 @code{getdirs} ignores directories named @samp{testsuite},
5414 @samp{config}, or @samp{lib}, and also ignores directories associated
5415 with a few revision control systems, specifically Git (@samp{.git}),
5416 Subversion (@samp{.svn}), CVS (@samp{CVS}), RCS (@samp{RCS}), and SCCS
5417 (@samp{SCCS}). These ignored directories will not appear in the
5418 returned list, nor will they be examined in a recursive search.
5421 @t{@b{getdirs} @i{-all} @i{rootdir} @i{pattern}}
5427 If this option is given, then subdirectories will be matched
5430 @item @code{rootdir}
5431 The top level directory to start the search from.
5433 @item @code{pattern}
5434 The Tcl glob pattern to match. If you do not specify @code{pattern},
5435 @code{getdirs} uses a default pattern of @code{*}.
5439 @node relative_filename procedure, find procedure, getdirs procedure, Utility Procedures
5440 @subsubheading relative_filename Procedure
5441 @findex relative_filename
5443 Return a relative file name, given a starting point.
5446 @t{@b{relative_filename} @i{base} @i{destination}}
5452 The starting point for relative file name traversal.
5454 @item @code{destination}
5455 The absolute file name that should be reached by appending the return
5459 @node find procedure, which procedure, relative_filename procedure, Utility Procedures
5460 @subsubheading find Procedure
5463 Search for files whose names match a glob pattern. Search
5464 subdirectories recursively, starting at a particular root directory.
5465 The result is the list of files whose names match. Filenames in the
5466 result include all intervening subdirectory names. If no files match
5467 the pattern, then an empty string is returned.
5470 @t{@b{find} @i{rootdir} @i{pattern}}
5474 @item @code{rootdir}
5475 The top level directory to start the search from.
5477 @item @code{pattern}
5478 A glob pattern representing the files to find.
5481 @node which procedure, grep procedure, find procedure, Utility Procedures
5482 @subsubheading which Procedure
5485 Searches the execution path for an executable file like the BSD
5486 @code{which(1)} utility. This procedure uses the shell environment
5487 variable @code{PATH}. It returns @b{0} if the binary is not in the
5488 path or if the @code{PATH} environment variable is not set. If the
5489 file is in the path, this procedure returns the full path to the file.
5492 @t{@b{which} @i{file}}
5497 The executable program or shell script to look for.
5500 @node grep procedure, prune procedure, which procedure, Utility Procedures
5501 @subsubheading grep Procedure
5504 Search a named file for lines that contain a match for a regular
5505 expression. The result is a list of all the lines that match. If no
5506 lines match, the result is an empty string. All of the Tcl regular
5507 expression syntax is supported.
5510 @t{@b{grep} @i{-n} @i{filename} @i{regexp} @b{line}}
5515 The @code{-n} option prefixes matched lines in the result with the
5516 line number, just like GNU @code{grep} does. This option should be
5517 used in preference to the @code{line} keyword documented below.
5519 @item @code{filename}
5523 The Unix style regular expression (as used by the @code{grep} UNIX
5524 utility) to search for.
5527 Use the optional keyword @code{line} to prefix matched lines in the
5528 result with the line number. This usage is deprecated.
5531 @node prune procedure, runtest_file_p procedure, grep procedure, Utility Procedures
5532 @subsubheading prune Procedure
5535 This procedure is deprecated and will be removed in a future release
5536 of DejaGnu. If a testsuite uses this procedure, a copy of the
5537 procedure should be made and placed in the @file{lib} directory of the
5540 @node runtest_file_p procedure, diff procedure, prune procedure, Utility Procedures
5541 @subsubheading runtest_file_p Procedure
5542 @findex runtest_file_p
5544 Search @emph{runtest}s for @emph{testcase} and return @b{1} if found,
5545 @b{0} if not. This is used by tools like compilers where each
5549 @t{@b{runtest_file_p} @i{runtests} @i{testcase}}
5553 @item @code{runtests}
5555 @code{runtests} is a list of two elements. The second is a copy of
5556 what was on the right side of the @code{=} if @code{foo.exp="..."} was
5557 specified, or an empty string if no such argument is present.
5559 @item @code{testcase}
5560 The filename of the current testcase under consideration.
5563 @node diff procedure, setenv procedure, runtest_file_p procedure, Utility Procedures
5564 @subsubheading diff Procedure
5567 Compares two files and returns @b{1} if they match (no differences) or
5568 @b{0} if not. If @code{verbose} is set, then it will print the
5569 differences to the console.
5572 @t{@b{diff} @i{file1} @i{file2}}
5577 First file for the comparison.
5580 Second file for the comparison.
5583 @node setenv procedure, unsetenv procedure, diff procedure, Utility Procedures
5584 @subsubheading setenv Procedure
5587 Set an environment variable.
5590 @t{@b{setenv} @i{var} @i{val}}
5595 The environment variable to set.
5598 The value to set the variable to.
5601 @node unsetenv procedure, getenv procedure, setenv procedure, Utility Procedures
5602 @subsubheading unsetenv Procedure
5605 Unset an environment variable.
5608 @t{@b{unsetenv} @i{var} }
5613 The environment variable to unset.
5616 @node getenv procedure, , unsetenv procedure, Utility Procedures
5617 @subsubheading getenv Procedure
5620 Returns the value of the envrionment variable @emph{var} if it is
5621 defined, otherwise an empty string is returned.
5624 @t{@b{getenv} @i{var} }
5629 Environment variable to retrieve.
5632 @node Libgloss, Debugging Procedures, Utility Procedures, Built-in Procedures
5633 @section Libgloss, a free board support package (BSP)
5635 Libgloss is a free board support package @dfn{BSP} commonly used with
5636 GCC and G++ to produce a fully linked executable image for an embedded
5640 * libgloss_link_flags Procedure: libgloss_link_flags procedure
5641 * libgloss_include_flags Procedure: libgloss_include_flags procedure
5642 * newlib_link_flags Procedure: newlib_link_flags procedure
5643 * newlib_include_flags Procedure: newlib_include_flags procedure
5644 * libio_include_flags Procedure: libio_include_flags procedure
5645 * libio_link_flags Procedure: libio_link_flags procedure
5646 * g++_include_flags Procedure: g++_include_flags procedure
5647 * g++_link_flags Procedure: g++_link_flags procedure
5648 * libstdc++_include_flags Procedure: libstdc++_include_flags procedure
5649 * libstdc++_link_flags Procedure: libstdc++_link_flags procedure
5650 * get_multilibs Procedure: get_multilibs procedure
5651 * find_binutils_prog Procedure: find_binutils_prog procedure
5652 * find_gcc Procedure: find_gcc procedure
5653 * find_gcj Procedure: find_gcj procedure
5654 * find_g++ Procedure: find_g++ procedure
5655 * find_g77 Procedure: find_g77 procedure
5656 * find_gfortran Procedure: find_gfortran procedure
5657 * find_go Procedure: find_go procedure
5658 * find_go_linker Procedure: find_go_linker procedure
5659 * find_rustc Procedure: find_rustc procedure
5660 * process_multilib_options Procedure: process_multilib_options procedure
5661 * add_multilib_option Procedure: add_multilib_option procedure
5662 * find_gas Procedure: find_gas procedure
5663 * find_ld Procedure: find_ld procedure
5664 * build_wrapper Procedure: build_wrapper procedure
5665 * winsup_include_flags Procedure: winsup_include_flags procedure
5666 * winsup_link_flags Procedure: winsup_link_flags procedure
5669 @node libgloss_link_flags procedure, libgloss_include_flags procedure, , Libgloss
5670 @subsubheading libgloss_link_flags Procedure
5671 @findex libgloss_link_flags
5673 Finds the pieces of @code{libgloss} needed to link a set of object
5674 files into an executable. This usually means setting the @code{-L}
5675 and @code{-B} paths correctly.
5678 @t{@b{libgloss_link_flags} @i{args} }
5686 @node libgloss_include_flags procedure, newlib_link_flags procedure, libgloss_link_flags procedure, Libgloss
5687 @subsubheading libgloss_include_flags Procedure
5688 @findex libgloss_include_flags
5690 This procedure always returns an empty string. It is provided for
5694 @t{@b{libgloss_include_flags} @i{args}}
5702 @node newlib_link_flags procedure, newlib_include_flags procedure, libgloss_include_flags procedure, Libgloss
5703 @subsubheading newlib_link_flags Procedure
5704 @findex newlib_link_flags
5706 Return the options needed to link an executable with @code{newlib}.
5707 This usually means setting the @code{-L} and @code{-B} paths
5711 @t{@b{newlib_link_flags} @i{args}}
5719 @node newlib_include_flags procedure, libio_include_flags procedure, newlib_link_flags procedure, Libgloss
5720 @subsubheading newlib_include_flags Procedure
5721 @findex newlib_include_flags
5723 Return the options needed to locate the @code{newlib} header files.
5726 @t{@b{newlib_include_flags} @i{args}}
5734 @node libio_include_flags procedure, libio_link_flags procedure, newlib_include_flags procedure, Libgloss
5735 @subsubheading libio_include_flags Procedure
5736 @findex libio_include_flags
5739 @t{@b{libio_include_flags} @i{args}}
5742 Return the options needed to locate the @code{libio} header files.
5749 @node libio_link_flags procedure, g++_include_flags procedure, libio_include_flags procedure, Libgloss
5750 @subsubheading libio_link_flags Procedure
5751 @findex libio_link_flags
5754 @t{@b{libio_link_flags} @i{args}}
5757 Return the options needed to link an executable with @code{libio}.
5758 This usually means setting the @code{-L} and @code{-B} paths
5766 @node g++_include_flags procedure, g++_link_flags procedure, libio_link_flags procedure, Libgloss
5767 @subsubheading g++_include_flags Procedure
5768 @findex g++_include_flags
5770 Return the options needed to locate the C++ stnadard library header
5774 @t{@b{g++_include_flags} @i{args}}
5782 @node g++_link_flags procedure, libstdc++_include_flags procedure, g++_include_flags procedure, Libgloss
5783 @subsubheading g++_link_flags Procedure
5784 @findex g++_link_flags
5787 @t{@b{g++_link_flags} @i{args}}
5790 Return the options needed to link an executable with @code{libg++}.
5791 This usually means setting the @code{-L} and @code{-B} paths
5799 @node libstdc++_include_flags procedure, libstdc++_link_flags procedure, g++_link_flags procedure, Libgloss
5800 @subsubheading libstdc++_include_flags Procedure
5801 @findex libstdc++_include_flags
5804 @t{@b{libstdc++_include_flags} @i{args}}
5807 Return the options needed to locate the C++ stnadard library header
5815 @node libstdc++_link_flags procedure, get_multilibs procedure, libstdc++_include_flags procedure, Libgloss
5816 @subsubheading libstdc++_link_flags Procedure
5817 @findex libstdc++_link_flags
5820 @t{@b{libstdc++_link_flags} @i{args}}
5827 @node get_multilibs procedure, find_binutils_prog procedure, libstdc++_link_flags procedure, Libgloss
5828 @subsubheading get_multilibs Procedure
5829 @findex get_multilibs
5832 @t{@b{get_multilibs} @i{args}}
5839 @node find_binutils_prog procedure, find_gcc procedure, get_multilibs procedure, Libgloss
5840 @subsubheading find_binutils_prog Procedure
5841 @findex find_binutils_prog
5844 @t{@b{find_binutils_prog} @i{name}}
5851 @node find_gcc procedure, find_gcj procedure, find_binutils_prog procedure, Libgloss
5852 @subsubheading find_gcc Procedure
5855 Looks for a copy of the GNU C compiler in the build tree and in the
5856 @code{PATH}. This will also return the proper transformed name for a
5857 cross-compiler if the build tree is configured for one.
5863 @node find_gcj procedure, find_g++ procedure, find_gcc procedure, Libgloss
5864 @subsubheading find_gcj Procedure
5867 Looks for a copy of the GNU Java compiler in the build tree and in the
5868 @code{PATH}. This will also return the proper transformed name for a
5869 cross-compiler if the build tree is configured for one.
5875 @node find_g++ procedure, find_g77 procedure, find_gcj procedure, Libgloss
5876 @subsubheading find_g++ Procedure
5879 Looks for a copy of the GNU C++ compiler in the build tree and in the
5880 @code{PATH}. This will also return the proper transformed name for a
5881 cross-compiler if the build tree is configured for one.
5887 @node find_g77 procedure, find_gfortran procedure, find_g++ procedure, Libgloss
5888 @subsubheading find_g77 Procedure
5891 Looks for a copy of the GNU Fortran 77 compiler in the build tree and
5892 in the @code{PATH}. This will also return the proper transformed name
5893 for a cross-compiler if the build tree is configured for one.
5899 @node find_gfortran procedure, find_go procedure, find_g77 procedure, Libgloss
5900 @subsubheading find_gfortran Procedure
5901 @findex find_gfortran
5903 Looks for a copy of the GNU Fortran compiler in the build tree and in
5904 the @code{PATH}. This will also return the proper transformed name
5905 for a cross-compiler if the build tree is configured for one.
5908 @t{@b{find_gfortran}}
5911 @node find_go procedure, find_go_linker procedure, find_gfortran procedure, Libgloss
5912 @subsubheading find_go Procedure
5915 Looks for a copy of the GNU compiler for the Go language in the build
5916 tree and in the @code{PATH}. This will also return the proper
5917 transformed name for a cross-compiler if the build tree is configured
5924 @node find_go_linker procedure, find_rustc procedure, find_go procedure, Libgloss
5925 @subsubheading find_go_linker Procedure
5926 @findex find_go_linker
5928 Looks for a copy of the special linker associated with the GNU
5929 compiler for the Go language in the build tree and in the @code{PATH}.
5930 This will also return the proper transformed name for a cross-compiler
5931 if the build tree is configured for one.
5934 @t{@b{find_go_linker}}
5937 @node find_rustc procedure, process_multilib_options procedure, find_go_linker procedure, Libgloss
5938 @subsubheading find_rustc Procedure
5941 Looks for a copy of a compiler for the Rust language in the build tree
5942 and in the @code{PATH}. The Rust compiler is different and this
5943 procedure also ensures that it will be called with options to suppress
5950 @node process_multilib_options procedure, add_multilib_option procedure, find_rustc procedure, Libgloss
5951 @subsubheading process_multilib_options Procedure
5952 @findex process_multilib_options
5955 @t{@b{process_multilib_options} @i{args}}
5962 @node add_multilib_option procedure, find_gas procedure, process_multilib_options procedure, Libgloss
5963 @subsubheading add_multilib_option Procedure
5964 @findex add_multilib_option
5967 @t{@b{add_multilib_option} @i{args}}
5974 @node find_gas procedure, find_ld procedure, add_multilib_option procedure, Libgloss
5975 @subsubheading find_gas Procedure
5982 @node find_ld procedure, build_wrapper procedure, find_gas procedure, Libgloss
5983 @subsubheading find_ld Procedure
5990 @node build_wrapper procedure, winsup_include_flags procedure, find_ld procedure, Libgloss
5991 @subsubheading build_wrapper Procedure
5992 @findex build_wrapper
5995 @t{@b{build_wrapper} @i{gluefile}}
5999 @item @code{gluefile}
6002 @node winsup_include_flags procedure, winsup_link_flags procedure, build_wrapper procedure, Libgloss
6003 @subsubheading winsup_include_flags Procedure
6004 @findex winsup_include_flags
6007 @t{@b{winsup_include_flags} @i{args}}
6014 @node winsup_link_flags procedure, , winsup_include_flags procedure, Libgloss
6015 @subsubheading winsup_link_flags Procedure
6016 @findex winsup_link_flags
6019 @t{@b{winsup_link_flags} @i{args}}
6026 @node Debugging Procedures, , Libgloss, Built-in Procedures
6027 @section Procedures for debugging your scripts
6030 * bt Procedure: bt procedure
6031 * dumpvars Procedure: dumpvars procedure
6032 * dumplocals Procedure: dumplocals procedure
6033 * dumprocs Procedure: dumprocs procedure
6034 * dumpwatch Procedure: dumpwatch procedure
6035 * watcharray Procedure: watcharray procedure
6036 * watchvar Procedure: watchvar procedure
6037 * watchunset Procedure: watchunset procedure
6038 * watchwrite Procedure: watchwrite procedure
6039 * watchread Procedure: watchread procedure
6040 * watchdel Procedure: watchdel procedure
6041 * print Procedure: print procedure
6042 * quit Procedure: quit procedure
6045 @node bt procedure, dumpvars procedure, Debugging Procedures, Debugging Procedures
6046 @subsubheading bt Procedure
6049 This procedure prints a backtrace using the @code{w} command from the
6056 @node dumpvars procedure, dumplocals procedure, bt procedure, Debugging Procedures
6057 @subsubheading dumpvars Procedure
6061 This procedure prints the values of the global variables that match a
6062 glob pattern. Abbreviation: @kbd{dv}.
6065 @t{@b{dumpvars} @i{pattern}}
6069 @item @code{pattern}
6070 The global variables to dump.
6073 @node dumplocals procedure, dumprocs procedure, dumpvars procedure, Debugging Procedures
6074 @subsubheading dumplocals Procedure
6078 This procedure prints the values of local variables that match a glob
6079 pattern. Abbreviation: @kbd{dl}.
6082 @t{@b{dumplocals} @i{pattern} }
6086 @item @code{pattern}
6087 The local variables to dump.
6090 @node dumprocs procedure, dumpwatch procedure, dumplocals procedure, Debugging Procedures
6091 @subsubheading dumprocs Procedure
6095 This procedure dumps the body of all procs that match a glob pattern.
6096 It is abbreviated as @kbd{dp}.
6099 @t{@b{dumprocs} @i{pattern}}
6103 @item @code{pattern}
6104 The proc bodies to dump.
6107 @node dumpwatch procedure, watcharray procedure, dumprocs procedure, Debugging Procedures
6108 @subsubheading dumpwatch Procedure
6112 This procedure prints all of the watchpoints matching a glob pattern.
6113 It is abbreviated as @kbd{dw}.
6116 @t{@b{dumpwatch} @i{pattern}}
6120 @item @code{pattern}
6121 The watchpoints to dump.
6124 @node watcharray procedure, watchvar procedure, dumpwatch procedure, Debugging Procedures
6125 @subsubheading watcharray Procedure
6129 @t{@b{watcharray} @i{array} @i{element} @i{type}}
6135 @item @code{element}
6138 The csh "glob" style pattern to look for.
6141 @node watchvar procedure, watchunset procedure, watcharray procedure, Debugging Procedures
6142 @subsubheading watchvar Procedure
6146 @t{@b{watchvar} @i{var} @i{type}}
6155 @node watchunset procedure, watchwrite procedure, watchvar procedure, Debugging Procedures
6156 @subsubheading watchunset Procedure
6160 This breaks program execution when the variable @code{var} is unset.
6161 Abbreviation: @kbd{wu}.
6164 @t{@b{watchunset} @i{pattern}}
6168 @item @code{pattern}
6171 @node watchwrite procedure, watchread procedure, watchunset procedure, Debugging Procedures
6172 @subsubheading watchwrite Procedure
6176 This breaks program execution when the variable @code{var} is written.
6177 Abbreviation: @kbd{ww}.
6180 @t{@b{watchwrite} @i{var}}
6185 The variable to watch.
6188 @node watchread procedure, watchdel procedure, watchwrite procedure, Debugging Procedures
6189 @subsubheading watchread Procedure
6193 This breaks program execution when the variable @code{var} is read.
6194 Abbreviation: @kbd{wr}.
6197 @t{@b{watchread} @i{var}}
6202 The variable to watch.
6205 @node watchdel procedure, print procedure, watchread procedure, Debugging Procedures
6206 @subsubheading watchdel Procedure
6210 This deletes a watchpoint from the watch list. Abbreviation:
6214 @t{@b{watchdel} @i{pattern}}
6218 @item @code{pattern}
6221 @node print procedure, quit procedure, watchdel procedure, Debugging Procedures
6222 @subsubheading print Procedure
6225 This prints the value of a variable. Abbreviation: @kbd{p}.
6228 @t{@b{print} @i{var}}
6233 The variable to print.
6236 @node quit procedure, , print procedure, Debugging Procedures
6237 @subsubheading quit Procedure
6240 This makes @code{runtest} exit. Abbreviation: @kbd{q}.
6246 @node GNU Free Documentation License, Concept Index, Built-in Procedures, Top
6247 @appendix GNU Free Documentation License
6250 @node Concept Index, Procedure Index, GNU Free Documentation License, Top
6251 @unnumbered Concept Index
6254 @node Procedure Index, Variable Index, Concept Index, Top
6255 @unnumbered Procedure Index
6258 @node Variable Index, , Procedure Index, Top
6259 @unnumbered Variable Index
6264 @c LocalWords: subdirectory prepend prepended testsuite filename Expect's svn
6265 @c LocalWords: DejaGnu CVS RCS SCCS prepending subcommands Tcl Awk Readline
6266 @c LocalWords: POSIX KFAIL KPASS XFAIL XPASS hostname multitable gfortran api
6267 @c LocalWords: boolean subcommand testcase eval rustc executables perror gdb
6268 @c LocalWords: interprocess lookahead XPASSED XFAILED printf TestState init