Dejagnu the GNU Testing Framework
Total Page:16
File Type:pdf, Size:1020Kb
DejaGnu The GNU Testing Framework Rob Savoye Free Software Foundation DejaGnu: The GNU Testing Framework by Rob Savoye 1.4.4 Edition Copyright © 2002 by Free Software Foundation, Inc. Revision History Revision 0.6.2 2002-7-16 Revised by: [email protected] Add new tutorial as a new chapter. Revision 0.6.1 2001-2-16 Revised by: [email protected] Add info on the new dejagnu.h file. Revision 0.6 2001-2-16 Revised by: [email protected] Updated for new release. Revision 0.5 2000-1-24 Revised by: [email protected] Initial version after conversion to DocBook. Table of Contents Abstract................................................................................................................................... i 1. Overview ............................................................................................................................1 What is DejaGnu ?........................................................................................................1 What’s New In This Release .......................................................................................1 Windows Support...............................................................................................2 Design Goals .................................................................................................................2 A POSIX conforming test framework .......................................................................2 2. Getting DejaGnu up and running.................................................................................5 Test your installation....................................................................................................5 Windows ..............................................................................................................5 Getting the source code for the calc example .................................................5 Create a minimal project, e.g. calc .............................................................................6 A simple project without the GNU autotools.................................................6 Using autoconf/autoheader/automake..........................................................6 Our first automated tests.............................................................................................8 Running the test for the calc example..............................................................8 The various config files or how to avoid warnings .......................................9 When trouble strikes ........................................................................................10 Testing “Hello world” locally .........................................................................10 A first remote test.......................................................................................................11 Setup telnet to your own host.........................................................................11 A test case for login via telnet.........................................................................11 Remote testing “Hello world” ........................................................................12 Transferring files from/to the target..............................................................13 Preparing for crosscompilation ......................................................................13 Remote testing of calc ......................................................................................14 Using Windows as host and vxWorks as target ...........................................14 3. Running Tests..................................................................................................................15 Make check..................................................................................................................15 Runtest .........................................................................................................................15 Output States.....................................................................................................15 Invoking Runtest ..............................................................................................16 Common Options .............................................................................................19 The files DejaGnu produces......................................................................................20 Summary File ....................................................................................................20 Log File...............................................................................................................20 Debug Log File..................................................................................................21 4. Customizing DejaGnu...................................................................................................23 Local Config File.........................................................................................................23 Global Config File ......................................................................................................24 Board Config File........................................................................................................25 Remote Host Testing..................................................................................................26 Config File Values.......................................................................................................28 Command Line Option Variables...................................................................28 Personal Config File .........................................................................................29 5. Extending DejaGnu........................................................................................................31 Adding A New Testsuite...........................................................................................31 Adding A New Tool...................................................................................................31 Adding A New Target ...............................................................................................34 Adding A New Board................................................................................................34 Board Config File Values...........................................................................................35 Writing A Test Case....................................................................................................37 Debugging A Test Case .............................................................................................38 Adding A Test Case To A Testsuite..........................................................................39 Hints On Writing A Test Case ..................................................................................39 Special variables used by test cases.........................................................................40 iii 6. Unit Testing......................................................................................................................41 What Is Unit Testing ?................................................................................................41 The dejagnu.h Header File........................................................................................41 7. Reference ..........................................................................................................................43 Obtaining DejaGnu ....................................................................................................43 Installation...................................................................................................................43 Configuring DejaGnu.......................................................................................43 Installing DejaGnu............................................................................................43 Builtin Procedures......................................................................................................44 Core Internal Procedures.................................................................................44 Procedures For Remote Communication ......................................................53 Procedures For Using Utilities to Connect....................................................65 Procedures For Target Boards .........................................................................72 Target Database Procedures ............................................................................75 Platform Dependant Procedures ....................................................................78 Utility Procedures.............................................................................................80 Libgloss, A Free BSP.........................................................................................84 Procedures for debugging your Tcl code. .....................................................88 File Map .......................................................................................................................91 8. Unit Testing API..............................................................................................................93 C Unit Testing API .....................................................................................................93 Pass Function.....................................................................................................93 Fail Function......................................................................................................93