~ubuntu-branches/ubuntu/saucy/dejagnu/saucy

« back to all changes in this revision

Viewing changes to doc/html/x276.html

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Jacobowitz
  • Date: 2004-02-09 15:07:58 UTC
  • Revision ID: james.westby@ubuntu.com-20040209150758-oaj7r5zrop60v8sb
Tags: upstream-1.4.4
ImportĀ upstreamĀ versionĀ 1.4.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
 
2
<HTML
 
3
><HEAD
 
4
><TITLE
 
5
>Our first automated tests</TITLE
 
6
><META
 
7
NAME="GENERATOR"
 
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
 
9
"><LINK
 
10
REL="HOME"
 
11
TITLE="DejaGnu"
 
12
HREF="book1.html"><LINK
 
13
REL="UP"
 
14
TITLE="Getting DejaGnu up and running"
 
15
HREF="c203.html"><LINK
 
16
REL="PREVIOUS"
 
17
TITLE="Create a minimal project, e.g. calc"
 
18
HREF="x227.html"><LINK
 
19
REL="NEXT"
 
20
TITLE="A first remote test"
 
21
HREF="x319.html"></HEAD
 
22
><BODY
 
23
CLASS="SECT1"
 
24
BGCOLOR="#FFFFFF"
 
25
TEXT="#000000"
 
26
LINK="#0000FF"
 
27
VLINK="#840084"
 
28
ALINK="#0000FF"
 
29
><DIV
 
30
CLASS="NAVHEADER"
 
31
><TABLE
 
32
SUMMARY="Header navigation table"
 
33
WIDTH="100%"
 
34
BORDER="0"
 
35
CELLPADDING="0"
 
36
CELLSPACING="0"
 
37
><TR
 
38
><TH
 
39
COLSPAN="3"
 
40
ALIGN="center"
 
41
>DejaGnu: The GNU Testing Framework</TH
 
42
></TR
 
43
><TR
 
44
><TD
 
45
WIDTH="10%"
 
46
ALIGN="left"
 
47
VALIGN="bottom"
 
48
><A
 
49
HREF="x227.html"
 
50
ACCESSKEY="P"
 
51
>&#60;&#60;&#60; Previous</A
 
52
></TD
 
53
><TD
 
54
WIDTH="80%"
 
55
ALIGN="center"
 
56
VALIGN="bottom"
 
57
>Getting DejaGnu up and running</TD
 
58
><TD
 
59
WIDTH="10%"
 
60
ALIGN="right"
 
61
VALIGN="bottom"
 
62
><A
 
63
HREF="x319.html"
 
64
ACCESSKEY="N"
 
65
>Next &#62;&#62;&#62;</A
 
66
></TD
 
67
></TR
 
68
></TABLE
 
69
><HR
 
70
ALIGN="LEFT"
 
71
WIDTH="100%"></DIV
 
72
><DIV
 
73
CLASS="SECT1"
 
74
><H1
 
75
CLASS="SECT1"
 
76
><A
 
77
NAME="AEN276"
 
78
></A
 
79
>Our first automated tests</H1
 
80
><DIV
 
81
CLASS="SECT2"
 
82
><H2
 
83
CLASS="SECT2"
 
84
><A
 
85
NAME="AEN278"
 
86
></A
 
87
>Running the test for the calc example</H2
 
88
><P
 
89
>Now we are ready to call the automated tests </P
 
90
><DIV
 
91
CLASS="EXAMPLE"
 
92
><A
 
93
NAME="AEN281"
 
94
></A
 
95
><P
 
96
><B
 
97
>Example 7. Sample output of runtest in a configured directory</B
 
98
></P
 
99
><TABLE
 
100
BORDER="0"
 
101
BGCOLOR="#E0E0E0"
 
102
WIDTH="100%"
 
103
><TR
 
104
><TD
 
105
><PRE
 
106
CLASS="PROGRAMLISTING"
 
107
>dgt:~/dejagnu.test$ make check
 
108
make check-DEJAGNU
 
109
make[1]: Entering directory `/home/dgt/dejagnu.test' srcdir=`cd . &#38;&#38; pwd`; export srcdir; \
 
110
EXPECT=expect; export EXPECT; \ runtest=runtest; \
 
111
if /bin/sh -c "$runtest --version" &#62; /dev/null 2&#62;&#38;1; then \
 
112
$runtest --tool calc CALC=`pwd`/calc --srcdir ./testsuite ; \
 
113
else echo "WARNING: could not find \`runtest'" 1&#62;&#38;2; :;\
 
114
fi
 
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
 
119
 
 
120
       === calc tests ===
 
121
 
 
122
Schedule of variations:
 
123
   unix
 
124
 
 
125
Running target unix
 
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)
 
131
 
 
132
=== calc Summary ===
 
133
 
 
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
 
139
></TD
 
140
></TR
 
141
></TABLE
 
142
></DIV
 
143
><P
 
144
>Did you see the  line &#8220;FAIL:&#8220;? 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
 
145
><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
 
152
></DIV
 
153
><DIV
 
154
CLASS="SECT2"
 
155
><H2
 
156
CLASS="SECT2"
 
157
><A
 
158
NAME="AEN286"
 
159
></A
 
160
>The various config files or how to avoid warnings</H2
 
161
><P
 
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
 
163
><TABLE
 
164
BORDER="0"
 
165
BGCOLOR="#E0E0E0"
 
166
WIDTH="100%"
 
167
><TR
 
168
><TD
 
169
><PRE
 
170
CLASS="PROGRAMLISTING"
 
171
>puts "I am ~/.dejagnurc"</PRE
 
172
></TD
 
173
></TR
 
174
></TABLE
 
175
><P
 
176
>Rerun make check. Test whether the output contains "I am ~/.dejagnurc".
 
177
Create ~/my_dejagnu.exp and insert the following line:</P
 
178
><TABLE
 
179
BORDER="0"
 
180
BGCOLOR="#E0E0E0"
 
181
WIDTH="100%"
 
182
><TR
 
183
><TD
 
184
><PRE
 
185
CLASS="PROGRAMLISTING"
 
186
>puts "I am ~/my_dejagnu.exp"</PRE
 
187
></TD
 
188
></TR
 
189
></TABLE
 
190
><P
 
191
>In a Bash-Shell enter</P
 
192
><TABLE
 
193
BORDER="0"
 
194
BGCOLOR="#E0E0E0"
 
195
WIDTH="100%"
 
196
><TR
 
197
><TD
 
198
><PRE
 
199
CLASS="PROGRAMLISTING"
 
200
>dgt:~/dejagnu.test$ export DEJAGNU=~/my_dejagnu.exp</PRE
 
201
></TD
 
202
></TR
 
203
></TABLE
 
204
><P
 
205
>Run &#8220;make check&#8221; again. The output should not contain
 
206
&#8220;WARNING: Couldn't find the global config file.&#8221;.
 
207
Create the sub-directory lib. Create the file &#8220;calc.exp&#8221; in it and insert the following line:</P
 
208
><TABLE
 
209
BORDER="0"
 
210
BGCOLOR="#E0E0E0"
 
211
WIDTH="100%"
 
212
><TR
 
213
><TD
 
214
><PRE
 
215
CLASS="PROGRAMLISTING"
 
216
>puts "I am lib/calc.exp"</PRE
 
217
></TD
 
218
></TR
 
219
></TABLE
 
220
><P
 
221
>The last warning &#8220;WARNING: Couldn't find tool init file&#8221;
 
222
should not be part of the output of make check.
 
223
Create the directory &#732;/boards. Create the file &#732;/boards/standard.exp and insert the following line:</P
 
224
><TABLE
 
225
BORDER="0"
 
226
BGCOLOR="#E0E0E0"
 
227
WIDTH="100%"
 
228
><TR
 
229
><TD
 
230
><PRE
 
231
CLASS="PROGRAMLISTING"
 
232
>puts "I am boards/standard.exp"</PRE
 
233
></TD
 
234
></TR
 
235
></TABLE
 
236
><P
 
237
>If the variable DEJAGNU is still not empty then the (abbreviated) output of &#8220;make check&#8221; should look like this:</P
 
238
><DIV
 
239
CLASS="EXAMPLE"
 
240
><A
 
241
NAME="AEN299"
 
242
></A
 
243
><P
 
244
><B
 
245
>Example 8. Sample output of runtest with the usual configuration files</B
 
246
></P
 
247
><TABLE
 
248
BORDER="0"
 
249
BGCOLOR="#E0E0E0"
 
250
WIDTH="100%"
 
251
><TR
 
252
><TD
 
253
><PRE
 
254
CLASS="PROGRAMLISTING"
 
255
>dgt:~/dejagnu.test$ make check
 
256
&#60;...&#62;
 
257
fi
 
258
I am ~/.dejagnurc
 
259
I am ~/my_dejagnu.exp
 
260
I am lib/calc.exp
 
261
Test Run By dgt on Sun Nov 25 22:19:14 2001
 
262
Native configuration is i586-pc-linux-gnu
 
263
 
 
264
     === calc tests ===
 
265
Using /home/Dgt/boards/standard.exp as standard board description\
 
266
file for build.
 
267
I am ~/boards/standard.exp
 
268
Using /home/Dgt/boards/standard.exp as standard board description\
 
269
 file for host.
 
270
I am ~/boards/standard.exp
 
271
 
 
272
Schedule of variations:
 
273
  unix
 
274
 
 
275
Running target unix
 
276
Using /home/Dgt/boards/standard.exp as standard board description\
 
277
 file for target.
 
278
I am ~/boards/standard.exp
 
279
Using /usr/share/dejagnu/baseboards/unix.exp as board description file\
 
280
for target.
 
281
&#60;...&#62;</PRE
 
282
></TD
 
283
></TR
 
284
></TABLE
 
285
></DIV
 
286
><P
 
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
 
290
files are run.</P
 
291
></DIV
 
292
><DIV
 
293
CLASS="SECT2"
 
294
><H2
 
295
CLASS="SECT2"
 
296
><A
 
297
NAME="AEN303"
 
298
></A
 
299
>When trouble strikes</H2
 
300
><P
 
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
 
302
><DIV
 
303
CLASS="EXAMPLE"
 
304
><A
 
305
NAME="AEN306"
 
306
></A
 
307
><P
 
308
><B
 
309
>Example 9. Displaying details about runtest execution</B
 
310
></P
 
311
><TABLE
 
312
BORDER="0"
 
313
BGCOLOR="#E0E0E0"
 
314
WIDTH="100%"
 
315
><TR
 
316
><TD
 
317
><PRE
 
318
CLASS="PROGRAMLISTING"
 
319
>runtest -v -v -v --tool calc CALC=`pwd`/calc --srcdir ./testsuite</PRE
 
320
></TD
 
321
></TR
 
322
></TABLE
 
323
></DIV
 
324
><P
 
325
>Calling runtest with the '--debug'-flag logs a lot of details to dbg.log where you can analyse it afterwards. </P
 
326
><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
 
329
><TABLE
 
330
BORDER="0"
 
331
BGCOLOR="#E0E0E0"
 
332
WIDTH="100%"
 
333
><TR
 
334
><TD
 
335
><PRE
 
336
CLASS="PROGRAMLISTING"
 
337
>set verbose 9</PRE
 
338
></TD
 
339
></TR
 
340
></TABLE
 
341
></DIV
 
342
><DIV
 
343
CLASS="SECT2"
 
344
><H2
 
345
CLASS="SECT2"
 
346
><A
 
347
NAME="AEN312"
 
348
></A
 
349
>Testing &#8220;Hello world&#8221; locally</H2
 
350
><P
 
351
>This test checks, whether the built-in shell command &#8220;echo Hello world&#8221;
 
352
 will really write &#8220;Hello world&#8221; on the console.
 
353
Create the file ~/dejagnu.test/testsuite/calc.test/local_echo.exp.
 
354
It should contain the following lines</P
 
355
><DIV
 
356
CLASS="EXAMPLE"
 
357
><A
 
358
NAME="AEN315"
 
359
></A
 
360
><P
 
361
><B
 
362
>Example 10. A first (local) test case</B
 
363
></P
 
364
><TABLE
 
365
BORDER="0"
 
366
BGCOLOR="#E0E0E0"
 
367
WIDTH="100%"
 
368
><TR
 
369
><TD
 
370
><PRE
 
371
CLASS="PROGRAMLISTING"
 
372
>set test "Local Hello World"
 
373
send "echo Hello World"
 
374
expect {
 
375
   -re "Hello World"  { pass "$test" }
 
376
}</PRE
 
377
></TD
 
378
></TR
 
379
></TABLE
 
380
></DIV
 
381
><P
 
382
>Run runtest again and verify the output &#8220;calc.log&#8221;</P
 
383
></DIV
 
384
></DIV
 
385
><DIV
 
386
CLASS="NAVFOOTER"
 
387
><HR
 
388
ALIGN="LEFT"
 
389
WIDTH="100%"><TABLE
 
390
SUMMARY="Footer navigation table"
 
391
WIDTH="100%"
 
392
BORDER="0"
 
393
CELLPADDING="0"
 
394
CELLSPACING="0"
 
395
><TR
 
396
><TD
 
397
WIDTH="33%"
 
398
ALIGN="left"
 
399
VALIGN="top"
 
400
><A
 
401
HREF="x227.html"
 
402
ACCESSKEY="P"
 
403
>&#60;&#60;&#60; Previous</A
 
404
></TD
 
405
><TD
 
406
WIDTH="34%"
 
407
ALIGN="center"
 
408
VALIGN="top"
 
409
><A
 
410
HREF="book1.html"
 
411
ACCESSKEY="H"
 
412
>Home</A
 
413
></TD
 
414
><TD
 
415
WIDTH="33%"
 
416
ALIGN="right"
 
417
VALIGN="top"
 
418
><A
 
419
HREF="x319.html"
 
420
ACCESSKEY="N"
 
421
>Next &#62;&#62;&#62;</A
 
422
></TD
 
423
></TR
 
424
><TR
 
425
><TD
 
426
WIDTH="33%"
 
427
ALIGN="left"
 
428
VALIGN="top"
 
429
>Create a minimal project, e.g. calc</TD
 
430
><TD
 
431
WIDTH="34%"
 
432
ALIGN="center"
 
433
VALIGN="top"
 
434
><A
 
435
HREF="c203.html"
 
436
ACCESSKEY="U"
 
437
>Up</A
 
438
></TD
 
439
><TD
 
440
WIDTH="33%"
 
441
ALIGN="right"
 
442
VALIGN="top"
 
443
>A first remote test</TD
 
444
></TR
 
445
></TABLE
 
446
></DIV
 
447
></BODY
 
448
></HTML
 
449
>
 
 
b'\\ No newline at end of file'