1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
5
>Our first automated tests</TITLE
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
12
HREF="book1.html"><LINK
14
TITLE="Getting DejaGnu up and running"
15
HREF="c203.html"><LINK
17
TITLE="Create a minimal project, e.g. calc"
18
HREF="x227.html"><LINK
20
TITLE="A first remote test"
21
HREF="x319.html"></HEAD
32
SUMMARY="Header navigation table"
41
>DejaGnu: The GNU Testing Framework</TH
51
><<< Previous</A
57
>Getting DejaGnu up and running</TD
65
>Next >>></A
79
>Our first automated tests</H1
87
>Running the test for the calc example</H2
89
>Now we are ready to call the automated tests </P
97
>Example 7. Sample output of runtest in a configured directory</B
106
CLASS="PROGRAMLISTING"
107
>dgt:~/dejagnu.test$ make check
109
make[1]: Entering directory `/home/dgt/dejagnu.test' srcdir=`cd . && pwd`; export srcdir; \
110
EXPECT=expect; export EXPECT; \ runtest=runtest; \
111
if /bin/sh -c "$runtest --version" > /dev/null 2>&1; then \
112
$runtest --tool calc CALC=`pwd`/calc --srcdir ./testsuite ; \
113
else echo "WARNING: could not find \`runtest'" 1>&2; :;\
115
WARNING: Couldn't find the global config file.
116
WARNING: Couldn't find tool init file
117
Test Run By dgt on Sun Nov 25 21:42:21 2001
118
Native configuration is i586-pc-linux-gnu
122
Schedule of variations:
126
Using /usr/share/dejagnu/baseboards/unix.exp as board description file for target.
127
Using /usr/share/dejagnu/config/unix.exp as generic interface file for target.
128
Using ./testsuite/config/unix.exp as tool-and-target-specific interface file.
129
Running ./testsuite/calc.test/calc.exp ...
130
FAIL: multiply2 (bad match)
134
# of expected passes 5
135
# of unexpected failures 1
136
/home/Dgt/dejagnu.test/calc version Version: 1.1
137
make[1]: *** [check-DEJAGNU] Fehler 1
138
make[1]: Leaving directory `/home/Dgt/dejagnu.test' make: *** [check-am] Fehler 2</PRE
144
>Did you see the line “FAIL:“? The test cases for calc catch the bug in the calc.c file. Fix the error in calc.c later as the following examples assume a unchanged calc.c.</P
146
>Examine the output files calc.sum and calc.log.
147
Try to understand the testcases written in ~/dejagnu.test/testsuite/calc.test/calc.exp.
148
To understand Expect you might take a look at the book "Exploring Expect",
149
which is an excellent resource for learning and using Expect. (Pub: O'Reilly, ISBN 1-56592-090-2)
150
The book contains hundreds of examples and also includes a tutorial on Tcl.
151
Exploring Expect is 602 pages long.ļæ½</P
160
>The various config files or how to avoid warnings</H2
162
>DejaGnu may be customized by each user. It first searches for a file called ~/.dejagnurc. Create the file ~/.dejagnurc and insert the following line:</P
170
CLASS="PROGRAMLISTING"
171
>puts "I am ~/.dejagnurc"</PRE
176
>Rerun make check. Test whether the output contains "I am ~/.dejagnurc".
177
Create ~/my_dejagnu.exp and insert the following line:</P
185
CLASS="PROGRAMLISTING"
186
>puts "I am ~/my_dejagnu.exp"</PRE
191
>In a Bash-Shell enter</P
199
CLASS="PROGRAMLISTING"
200
>dgt:~/dejagnu.test$ export DEJAGNU=~/my_dejagnu.exp</PRE
205
>Run “make check” again. The output should not contain
206
“WARNING: Couldn't find the global config file.”.
207
Create the sub-directory lib. Create the file “calc.exp” in it and insert the following line:</P
215
CLASS="PROGRAMLISTING"
216
>puts "I am lib/calc.exp"</PRE
221
>The last warning “WARNING: Couldn't find tool init file”
222
should not be part of the output of make check.
223
Create the directory ˜/boards. Create the file ˜/boards/standard.exp and insert the following line:</P
231
CLASS="PROGRAMLISTING"
232
>puts "I am boards/standard.exp"</PRE
237
>If the variable DEJAGNU is still not empty then the (abbreviated) output of “make check” should look like this:</P
245
>Example 8. Sample output of runtest with the usual configuration files</B
254
CLASS="PROGRAMLISTING"
255
>dgt:~/dejagnu.test$ make check
259
I am ~/my_dejagnu.exp
261
Test Run By dgt on Sun Nov 25 22:19:14 2001
262
Native configuration is i586-pc-linux-gnu
265
Using /home/Dgt/boards/standard.exp as standard board description\
267
I am ~/boards/standard.exp
268
Using /home/Dgt/boards/standard.exp as standard board description\
270
I am ~/boards/standard.exp
272
Schedule of variations:
276
Using /home/Dgt/boards/standard.exp as standard board description\
278
I am ~/boards/standard.exp
279
Using /usr/share/dejagnu/baseboards/unix.exp as board description file\
287
>It is up to you to decide when and where to use any of the above
288
mentioned config files for customizing.
289
This chapters showed you where and in which order the different config
299
>When trouble strikes</H2
301
>Calling runtest with the '-v'-flag shows you in even more details which files are searched in which order. Passing it several times gives more and more details. </P
309
>Example 9. Displaying details about runtest execution</B
318
CLASS="PROGRAMLISTING"
319
>runtest -v -v -v --tool calc CALC=`pwd`/calc --srcdir ./testsuite</PRE
325
>Calling runtest with the '--debug'-flag logs a lot of details to dbg.log where you can analyse it afterwards. </P
327
>In all test cases you can temporary adjust the verbosity of information by adding the following Tcl-command to any tcl file that gets loaded by
328
dejagnu, for instance, ~/.dejagnurc:</P
336
CLASS="PROGRAMLISTING"
349
>Testing “Hello world” locally</H2
351
>This test checks, whether the built-in shell command “echo Hello world”
352
will really write “Hello world” on the console.
353
Create the file ~/dejagnu.test/testsuite/calc.test/local_echo.exp.
354
It should contain the following lines</P
362
>Example 10. A first (local) test case</B
371
CLASS="PROGRAMLISTING"
372
>set test "Local Hello World"
373
send "echo Hello World"
375
-re "Hello World" { pass "$test" }
382
>Run runtest again and verify the output “calc.log”</P
390
SUMMARY="Footer navigation table"
403
><<< Previous</A
421
>Next >>></A
429
>Create a minimal project, e.g. calc</TD
443
>A first remote test</TD
b'\\ No newline at end of file'