Table of Contents What is DejaGnu? What is new in this release? Running existing tests What does a DejaGnu test look like? Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided also that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Author:Dutaxe Kizilkree
Language:English (Spanish)
Genre:Personal Growth
Published (Last):2 November 2010
PDF File Size:2.1 Mb
ePub File Size:8.37 Mb
Price:Free* [*Free Regsitration Required]

Written by John T. Criswell, Reid Spencer , and Tanya Lattner. This document is the reference manual for the LLVM testing infrastructure. It documents the structure of the LLVM testing infrastructure, the tools needed to use it, and how to add and run tests. Alternatively, Darwinports users can use sudo port install expect to install Expect and tcl.

The LLVM testing infrastructure contains two major categories of tests: code fragments and whole programs. The whole programs tests are referred to as the "Test suite" and are in the test-suite module in subversion.

They are usually written in LLVM assembly language, but can be written in other languages if the test targets a particular language front end. These tests are driven by the DejaGNU testing framework, which is hidden behind a few simple makefiles.

These code fragments are not complete programs. The code generated from them is never executed to determine correct behavior. Typically when a bug is found in LLVM, a regression test containing just enough code to reproduce the problem should be written and placed somewhere underneath this directory. In most cases, this will be a small piece of LLVM assembly language code, often distilled from an actual application or benchmark. The test suite contains whole programs, which are pieces of code which can be compiled and linked into a stand-alone program that can be executed.

The output of these programs is compared to ensure that LLVM is compiling the program correctly. In addition to compiling and executing programs, whole program tests serve as a way of benchmarking LLVM performance, both in terms of the efficiency of the programs generated as well as the speed with which LLVM compiles, optimizes, and generates code.

The tests are located in two separate Subversion modules. When you configure the llvm module, the test-suite directory will be automatically configured. Alternatively, you can configure the test-suite module manually. Note: If you are running the tests with objdir! To run the comprehensive test suite tests that compile and execute whole programs , first checkout and setup the test-suite module:.

Usually, running the "nightly" set of tests is a good idea, and you can also let it generate a report by running:. This directory contains a large array of small tests that exercise various features of LLVM and to ensure that regressions do not occur. The directory is broken into several sub-directories, each focused on a particular area of LLVM.

A few of the important ones are:. The DejaGNU structure is very simple, but does require some information to be set. This information is gathered via configure and is written to a file, site. In order for DejaGNU to work, each directory of tests must have a dg.

DejaGNU looks for this file to determine how to run the tests. This file is just a Tcl script and it can do anything you want, but we've standardized it for the LLVM regression tests. If you're adding a directory of tests, just copy dg. The standard dg. The names are obtained by using Tcl's glob command. Any directory that contains only directories does not need the dg. The llvm-runtests function lookas at each file that is passed to it and gathers any lines together that match "RUN:".

This are the "RUN" lines that specify how the test is to be run. So, each test script must contain RUN lines if it is to do anything. If there are no RUN lines, the llvm-runtests function will issue an error and the test will fail.

RUN lines are specified in the comments of the test program using the keyword RUN followed by a colon, and lastly the command pipeline to execute. Together, these lines form the "script" that llvm-runtests executes to run the test case. However, even though these lines may look like a shell script, they are not. RUN lines are interpreted directly by the Tcl exec command. They are never executed by a shell.

Consequently the syntax differs from normal shell script syntax in a few ways. You can specify as many RUN lines as needed. This continuation character causes the RUN line to be concatenated with the next one. In this way you can build up long pipelines of commands without making huge line lengths.

This concatenated set of RUN lines then constitutes one execution. Tcl will substitute variables and arrange for the pipeline to be executed. If any process in the pipeline fails, the entire line and test case fails too. However, the usage is slightly different than for Bash.

To check what's legal, see the documentation for the Tcl exec command and the tutorial. The major differences are:. There are some quoting rules that you must pay attention to when writing your RUN lines.

In general nothing needs to be quoted. Tcl won't strip off any ' or " so they will get passed to the invoked program. For example:. This will fail because the ' characters are passed to grep. This would instruction grep to look for 'find in the files this and string'.

To avoid this use curly braces to tell Tcl that it should treat everything enclosed as one value. So our example would become:. Additionally, the characters [ and ] are treated specially by Tcl. They tell Tcl to interpret the content as a command to execute. Since these characters are often used in regular expressions this can have disastrous results and cause the entire test run in a directory to fail.

For example, a common idiom is to look for some basicblock number:. This, however, will cause Tcl to fail because its going to try to execute a program named "". Instead, what you want is this:. This is another Tcl special character. So, suppose you had First, the ' do not get stripped off. That's not likely to match anything. With a RUN line there are a number of substitutions that are permitted.

These alternates are deprecated and may go away in a future version. To add more variables, two things need to be changed. This will "set" the variable as a global in the site. That's it, the variable can then be used in test scripts. This directory is in the PATH when running tests, so you can just call these scripts using their name. This signals that the test case should succeed if the test fails. Such test cases are counted separately by DejaGnu.

To specify an expected fail, use the XFAIL keyword in the comments of the test program followed by a colon and one or more regular expressions separated by a comma. The regular expressions following the : are matched against the target triplet or llvmgcc version number for the host machine.

If there is a match, the test is expected to fail. If not, the test is expected to succeed. When matching the llvm-gcc version, you can specify the major e. This is the syntax for specifying a PR Problem Report number that is related to the test case. This is useful to quickly get some context when a test fails.

Finally, any line that contains "END. This is generally done right after the last RUN: line. This has two side effects: a it prevents special interpretation of lines that are part of the test program, not the instructions to the test case, and b it speeds things up for really big test cases by avoiding interpretation of the remainder of the file. The test-suite module contains a number of programs that can be compiled with LLVM and executed.

These programs are compiled using the native compiler and various LLVM backends. The output from the program compiled with the native compiler is assumed correct; the results from the other programs are compared to the native program output and pass if they match.

When executing tests, it is usually a good idea to start out with a subset of the available tests or programs. This makes test run times smaller at first and later on this is useful to investigate individual test failures. To run some test only on a subset of programs, simply change directory to the programs you want tested and run gmake there.

Alternatively, you can run a different test using the TEST variable to change what tests or run on the selected programs see below for more info. In addition for testing correctness, the llvm-test directory also performs timing tests of various LLVM optimizations. It also records compilation times for the compilers and the JIT. This information can be used to compare the effectiveness of LLVM's optimizations and code generation.


The DejaGnu Testing Framework

DejaGnu is a framework for testing other programs with the flexibility and consistency that makes it easy to write tests for any program. It provides a layer of abstraction which makes all correctly written tests portable to any host or target where a program must be tested. DejaGnu is written in expect, which in turn uses tcl which is how the tests themselves are usually written. The framework has two parts: the testing module and the testsuites themselves. Selection from the FSF shop.


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 [3]. DejaGnu 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.





Related Articles