The main source of information is the DejaGnu user guide by Rob Savoye [3]. The most useful section is the Unit Testing API, which lists all the procedures. Follow these instructions as closely a possible in order get a good insight into how DejaGnu works, else you might run into a lot of subtle problems. You have. DejaGnu uses the GNU autoconf to configure itself. For more info on using autoconf, read the GNU autoconf manual. To configure, execute the configure.

Author: Meramar Mulkree
Country: Mauritius
Language: English (Spanish)
Genre: Travel
Published (Last): 9 July 2013
Pages: 83
PDF File Size: 4.77 Mb
ePub File Size: 6.45 Mb
ISBN: 135-9-21840-821-7
Downloads: 37117
Price: Free* [*Free Regsitration Required]
Uploader: Zulukasa

DejaGnu is a testing framework, originally developed for the GNU project. This application note was written in response to the author’s frustration at dejaggnu up a DejaGnu test framework for the first time, using the existing documentation [3]. DejaGnu manua be used standalone, but it is most useful when integrated with the GNU autotools autoconf automake and libtool.

This application note describes both modes of use. This application note is deliberately incomplete. It only covers the most commonly used features and options. Setting up DejaGnu for the first time is a challenge. This application note is intended for software engineers putting denagnu their first test manua using DejaGnu.

The main source mnual information is the DejaGnu user guide by Rob Savoye [3]. The most useful section is the Unit Testing APIwhich lists all the procedures which can be used when writing tests. DejaGnu is implemented as the runtest command. TCL is extensively documented on its website see www. Of particular value is the TCL tutorial on that site [1].

Comprehensive documentation may be found in the book Exploring Expect by Don Libes [2]. Embecosm publishes a series of free and open source application notes, designed to help working engineers with practical problems. It comprises a command to run tests runtesta language in which to write tests expecta standard directory structure for the tests and a set of configuration files. DejaGnu is not installed by default on most Linux systems.

However most systems provide it as a standard extra. If not, it can be downloaded from www. Central to DejaGnu is the runtest command. It takes the general form:. The naming of this option is confusing. It is the name of the group of tests being carried out. This might be the name of a tool for example or1ksimbut it might equally be an indicator of a dejagnnu of test for example unit.

The toolname is important, because it is used to construct dejahnu names of other entities: This mamual a path where directories of tests may be found. A directory containing tool specific configuration files lib is also found in this directory. The actual names of the directories containing tests must be prefixed by the name of the tool, and by convention end with vejagnu suffix. Thus for the tool or1ksimthe tests might appear in directories named or1ksim. It specifies board s on which the tests should be run.

If no test is specified, runtest will run all the tests it can find, which match the specified toolname. Otherwise it will run only the test specified. Where an option is set both on the command line and in a configuration file, the command line will take precedence. There are a number of options which are not documented in the manual.


Strictly speaking, expect is a tool, rather than a language. However it is easiest to regard it as a language which dejagju TCL. Before writing code using expect you should be fully familiar with TCL [1].

Expect scripts spawn test programs, to which they supply input and check that the response is as expected. DejaGnu has some basic expectations of where it will find files, although this can be overridden with command line options to runtest.

By convention, the test framework lives within a directory testsuite. Within that directory are the following sub-directories:. The use of this directory depends on it being set up as part of the configuration.

These have the general name board.

These files are named toolname. Directories named toolname [ type ]. The optional type field allows ,anual tests to be split into several directories. For example a compiler tool named xcc might have tests both of the compiler in one directory, xcc-compile. Strictly speaking the suffix.

Command line option variables (DejaGnu)

Within each test directory, the tests, written in expectall have the file suffix. DejaGnu has a number of global variables which are set to correspond to runtest command line arguments. However they can alternatively be set in the various configuration files mnaual both are used, the command line takes precedence. The directory containing test sub-directories and the tool specific configuration directory, lib.

The degree of verbosity required. Value of the variable is incremented for each time it appears on the command line. DejaGnu has a plethora of configuration files, each of which contain expect script that is processed before each test. The historical naming of some of these files can be confusing.

Although these configuration files are all optional, runtest may complain if it can’t find them. So it’s worth setting them up, just to stop the messages. In general it is only used to set variables that control personal taste in output. This is always named site. In general it is used to set variables specific to the tool or tools being tested.

If GNU autotools autoconfautomake and libtool are being used to dejxgnu DejaGnu this file will be created automatically whenever make is run.

runtest(1) – Linux man page

It will be placed in the main manuall suite directory, but within the build directory hierarchy, not the source directory hierarchy. It is this directory from which runtest will be executed. When GNU autotools generate site. Only the first part is regenerated every time make is run, so changes may safely be made in the second kanual. This is a convenient place for quickly testing changes.

However the local config file in an autotools environment is inherently transient it is in the build directory, not the source directoryso permanent changes should be placed in one of the other config files.

This is intended as a file to allow a dejagmu testing the same product to share common settings. It is common to append additional directories to this search path in one of the earlier configuration directories typically maanual global config file to provide additional board specific information. This can be done by using the TCL lappend function. For example, to look in the config sub-directory of the main test directory for board specific settings, the following would be suitable in the global configuration file.


If multiple board configuration files are found in the different directories, they will all be used in the order they are found.

Finally DejaGnu will load code from a tool specific configuration file. This will be found in the lib sub-directory of the main test directory. When running runtestmultiple test programs may dejqgnu found in the test directory or directories. These are effectively concatenated, so they are run one after the other after running all the configurations. The important thing to remember is that this means the configuration files are only read once, not once for each test.

Each DejaGnu test is a sequence of expect commands.

Dejagnu – Free Software Directory

These are standard TCL commands with some additions, which make the language particularly suitable for testing. The most useful of these are:. This is the most important of the commands. It takes a series of pairs of patterns and actions and waits until one of the patterns matches the output of a spawned process see spawn belowor a specified time period has passed or an end of file has been seen.

When a pattern matches, its corresponding body is executed. This command is used to send data to the standard input of a spawned process see spawn below. These commands are used to send output to respectively the standard error of the user, the log file and the standard output of the user.

In other words for data that is not to go to the spawned process. There is the potential for confusion here, since expect is both the name of the language and a command within that language. Expect defines and uses a number of TCL global variables.

On top of this DejaGnu defines a number of procedures which facilitate testing. These are documented in the DejaGnu manual’s section on Unit Testing [3]. The most useful are:. These procedures all report the result of a test. The next call dejagnk one of the result procedures will behave as though unresolved had been called. The results from all the dejafnu encountered by runtest are reported in the log file and counted, for reporting on completion.

The results are triggered by calling the appropriate result procedure, which takes a string to identify the test concerned. The possible results are as follows:. Indicates that a test has failed. Triggered by calling the fail procedure.