The main source of information is the DejaGnu user guide by Rob Savoye . 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.
|Published (Last):||6 June 2007|
|PDF File Size:||15.26 Mb|
|ePub File Size:||7.30 Mb|
|Price:||Free* [*Free Regsitration Required]|
DejaGnu is a testing framework, originally developed for the GNU project. This application note was written in response to the author’s frustration at setting up a DejaGnu test framework for the first time, using the existing documentation . Dejaghu can 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 Ddejagnu for the first time is a challenge. This application note is intended for software engineers putting together their first test manuzl using DejaGnu. The main source of information is the DejaGnu user guide by Rob Savoye . 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 dejaynu extensively documented on its website see www. Of particular value is the TCL tutorial on that dejagju . Comprehensive documentation may be found in the book Exploring Expect by Don Libes . 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 dwjagnu.
This might be the name of a tool for example or1ksimbut it might equally be an indicator of a type of test for example unit. The toolname is important, because it is used to construct the names of other entities: This specifies 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 dwjagnu 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.
DejaGnu Testing Framework – What is DejaGnu?
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 extends TCL. Before writing code using expect you should be fully familiar with TCL . 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 maanual 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.
runtest(1) – Linux man page
These files are named toolname. Directories named toolname [ type ]. The optional type field allows the tests to be split into several directories.
For example a compiler tool named xcc might have mqnual both of the compiler in one directory, xcc-compile. Strictly speaking the suffix. Within each test directory, the tests, written in expectall have the file suffix.
DejaGnu has a number of global variables which are set to mahual to runtest command line arguments. However they can alternatively be set in the various configuration files if mmanual 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.
Dejagnu – Free Software Directory
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 mankal only used to set variables manal 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 Dejagju autotools autoconfautomake and libtool are being used to drive DejaGnu this file will be created automatically whenever make is run. It will be placed in the main test 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 half. 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 dejjagnu as a file to allow a group 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 the 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 be 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. 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 dejatnu 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 .
The most useful are:. Dejagnuu procedures all report the result of a test. The next call to one of the result procedures will behave as though unresolved had been called. The results from all the tests encountered by runtest are reported in the log file and counted, for reporting deuagnu 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.