~ubuntu-branches/ubuntu/warty/dejagnu/warty

« back to all changes in this revision

Viewing changes to doc/html/x227.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
>Create a minimal project, e.g. calc</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="Getting DejaGnu up and running"
 
18
HREF="c203.html"><LINK
 
19
REL="NEXT"
 
20
TITLE="Our first automated tests"
 
21
HREF="x276.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="c203.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="x276.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="AEN227"
 
78
></A
 
79
>Create a minimal project, e.g. calc</H1
 
80
><P
 
81
>In this section you will to start a small project,
 
82
using the sample application calc, which is part of your DejaGnu distribution</P
 
83
><DIV
 
84
CLASS="SECT2"
 
85
><H2
 
86
CLASS="SECT2"
 
87
><A
 
88
NAME="AEN230"
 
89
></A
 
90
>A simple project without the GNU autotools</H2
 
91
><P
 
92
>The runtest program can be run standalone. All the autoconf/automake support is just cause those programs are commonly used for other GNU applications. The key to running runtest standalone is having the local site.exp file setup correctly, which automake does.</P
 
93
><P
 
94
>The generated site.exp should like like:</P
 
95
><TABLE
 
96
BORDER="0"
 
97
BGCOLOR="#E0E0E0"
 
98
WIDTH="100%"
 
99
><TR
 
100
><TD
 
101
><PRE
 
102
CLASS="PROGRAMLISTING"
 
103
>set tool calc
 
104
set srcdir .
 
105
set objdir /home/dgt/dejagnu.test</PRE
 
106
></TD
 
107
></TR
 
108
></TABLE
 
109
></DIV
 
110
><DIV
 
111
CLASS="SECT2"
 
112
><H2
 
113
CLASS="SECT2"
 
114
><A
 
115
NAME="AEN235"
 
116
></A
 
117
>Using autoconf/autoheader/automake</H2
 
118
><P
 
119
>We have to prepare some input file in order to run autocon and automake. There is book &#8220;GNU autoconf, automake and libtool&#8221; by Garry V. Vaughan, et al. NewRider, ISBN 1-57870-190-2 which describes this process thoroughly.</P
 
120
><P
 
121
>From the calc example distributed with the DejaGnu documentation you should copy the program file itself (calc.c) and some additional files, which you might examine a little bit close to derive their meanings.</P
 
122
><TABLE
 
123
BORDER="0"
 
124
BGCOLOR="#E0E0E0"
 
125
WIDTH="100%"
 
126
><TR
 
127
><TD
 
128
><PRE
 
129
CLASS="PROGRAMLISTING"
 
130
>dgt:~/dejagnu.test$ cp -r /usr/share/doc/dejagnu/examples/calc/\
 
131
{configure.in,Makefile.am,calc.c,testsuite} .</PRE
 
132
></TD
 
133
></TR
 
134
></TABLE
 
135
><P
 
136
>In Makemake.am note the presence of the AUTOMAKE_OPTIONS = dejagnu. This option is needed.</P
 
137
><P
 
138
>Run aclocal to generate aclocal.m4, which is a collection of macros needed by configure.in</P
 
139
><TABLE
 
140
BORDER="0"
 
141
BGCOLOR="#E0E0E0"
 
142
WIDTH="100%"
 
143
><TR
 
144
><TD
 
145
><PRE
 
146
CLASS="PROGRAMLISTING"
 
147
>dgt:~/dejagnu.test$ aclocal</PRE
 
148
></TD
 
149
></TR
 
150
></TABLE
 
151
><P
 
152
>autoconf is another part of the auto-tools.
 
153
Run it to generate configure based on information contained in configure.in.</P
 
154
><TABLE
 
155
BORDER="0"
 
156
BGCOLOR="#E0E0E0"
 
157
WIDTH="100%"
 
158
><TR
 
159
><TD
 
160
><PRE
 
161
CLASS="PROGRAMLISTING"
 
162
>dgt:~/dejagnu.test$ autoconf</PRE
 
163
></TD
 
164
></TR
 
165
></TABLE
 
166
><P
 
167
>autoheader is another part of the auto-tools.
 
168
Run it to generate calc.h.in. </P
 
169
><TABLE
 
170
BORDER="0"
 
171
BGCOLOR="#E0E0E0"
 
172
WIDTH="100%"
 
173
><TR
 
174
><TD
 
175
><PRE
 
176
CLASS="PROGRAMLISTING"
 
177
>dgt:~/dejagnu.test$ autoheader</PRE
 
178
></TD
 
179
></TR
 
180
></TABLE
 
181
><P
 
182
>The Makefile.am of this example was developed as port of the DejaGnu
 
183
distribution.
 
184
Adapt Makefile.am for this test. Replace the line
 
185
&#8220;#noinst_PROGRAMS = calc&#8221; to
 
186
&#8220;bin_PROGRAMS = calc&#8221;.
 
187
Change the RUNTESTDEFAULTFLAGS from
 
188
&#8220;$$srcdir/testsuite&#8221; to
 
189
&#8220;./testsuite&#8221;.</P
 
190
><P
 
191
>Running automake at this point contains a series of warning in its output as shown in the following example:</P
 
192
><DIV
 
193
CLASS="EXAMPLE"
 
194
><A
 
195
NAME="AEN249"
 
196
></A
 
197
><P
 
198
><B
 
199
>Example 2. Sample output of automake with missing files</B
 
200
></P
 
201
><TABLE
 
202
BORDER="0"
 
203
BGCOLOR="#E0E0E0"
 
204
WIDTH="100%"
 
205
><TR
 
206
><TD
 
207
><PRE
 
208
CLASS="PROGRAMLISTING"
 
209
>dgt:~/dejagnu.test$ automake --add-missing
 
210
automake: configure.in: installing `./install-sh'
 
211
automake: configure.in: installing `./mkinstalldirs'
 
212
automake: configure.in: installing `./missing'
 
213
automake: Makefile.am: installing `./INSTALL'
 
214
automake: Makefile.am: required file `./NEWS' not found
 
215
automake: Makefile.am: required file `./README' not found
 
216
automake: Makefile.am: installing `./COPYING'
 
217
automake: Makefile.am: required file `./AUTHORS' not found
 
218
automake: Makefile.am: required file `./ChangeLog' not found
 
219
configure.in: 4: required file `./calc.h.in' not found
 
220
Makefile.am:6: required directory ./doc does not exist</PRE
 
221
></TD
 
222
></TR
 
223
></TABLE
 
224
></DIV
 
225
><P
 
226
>Create a empty directory doc and empty files
 
227
INSTALL, NEWS, README, AUTHORS, ChangeLog and COPYING.
 
228
The default COPYING will point to the GNU Public License (GPL).
 
229
In a real project it would be time to add some meaningfull text in each file.</P
 
230
><P
 
231
>Adapt calc to your environment by calling configure.</P
 
232
><DIV
 
233
CLASS="EXAMPLE"
 
234
><A
 
235
NAME="AEN254"
 
236
></A
 
237
><P
 
238
><B
 
239
>Example 3. Sample output of configure</B
 
240
></P
 
241
><TABLE
 
242
BORDER="0"
 
243
BGCOLOR="#E0E0E0"
 
244
WIDTH="100%"
 
245
><TR
 
246
><TD
 
247
><PRE
 
248
CLASS="PROGRAMLISTING"
 
249
>dgt:~/dejagnu.test$ ./configure
 
250
creating cache ./config.cache
 
251
checking whether to enable maintainer-specific portions of Makefiles... no
 
252
checking for a BSD compatible install... /usr/bin/install -c
 
253
checking whether build environment is sane... yes
 
254
checking whether make sets ${MAKE}... yes
 
255
checking for working aclocal... found
 
256
checking for working autoconf... found
 
257
checking for working automake... found
 
258
checking for working autoheader... found
 
259
checking for working makeinfo... found
 
260
checking for gcc... gcc checking whether the C compiler (gcc ) works... yes
 
261
checking whether the C compiler (gcc ) is a cross-compiler... no
 
262
checking whether we are using GNU C... yes
 
263
checking whether gcc accepts -g... yes
 
264
checking for a BSD compatible install... /usr/bin/install -c
 
265
checking how to run the C preprocessor... gcc -E
 
266
checking for stdlib.h... yes
 
267
checking for strcmp... yes
 
268
updating cache ./config.cache
 
269
creating ./config.status
 
270
creating Makefile creating calc.h</PRE
 
271
></TD
 
272
></TR
 
273
></TABLE
 
274
></DIV
 
275
><P
 
276
>If you are familiar with GNU software,
 
277
this output should not contain any surprise to you.
 
278
Any errors should be easy to fix for such a simple program.</P
 
279
><P
 
280
>Build the calc executable:</P
 
281
><DIV
 
282
CLASS="EXAMPLE"
 
283
><A
 
284
NAME="AEN259"
 
285
></A
 
286
><P
 
287
><B
 
288
>Example 4. Sample output building calc</B
 
289
></P
 
290
><TABLE
 
291
BORDER="0"
 
292
BGCOLOR="#E0E0E0"
 
293
WIDTH="100%"
 
294
><TR
 
295
><TD
 
296
><PRE
 
297
CLASS="PROGRAMLISTING"
 
298
>dgt:~/dejagnu.test$ make
 
299
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c calc.c
 
300
gcc -g -O2 -o calc calc.o</PRE
 
301
></TD
 
302
></TR
 
303
></TABLE
 
304
></DIV
 
305
><P
 
306
>You prepared a few files and then called some commands.
 
307
Respecting the right order assures a automatic and correctly compiled calc program. The following example resumes the correct order.</P
 
308
><DIV
 
309
CLASS="EXAMPLE"
 
310
><A
 
311
NAME="AEN263"
 
312
></A
 
313
><P
 
314
><B
 
315
>Example 5. Creating the calc program using the GNU autotools</B
 
316
></P
 
317
><TABLE
 
318
BORDER="0"
 
319
BGCOLOR="#E0E0E0"
 
320
WIDTH="100%"
 
321
><TR
 
322
><TD
 
323
><PRE
 
324
CLASS="PROGRAMLISTING"
 
325
>dgt:~/dejagnu.test$ aclocal
 
326
dgt:~/dejagnu.test$ autoconf
 
327
dgt:~/dejagnu.test$ autoheader
 
328
dgt:~/dejagnu.test$ automake --add-missing
 
329
dgt:~/dejagnu.test$ ./configure
 
330
dgt:~/dejagnu.test$ make&#13;</PRE
 
331
></TD
 
332
></TR
 
333
></TABLE
 
334
></DIV
 
335
><P
 
336
>Play with calc and verify whether it works correctly.
 
337
A sample session might look like this:</P
 
338
><TABLE
 
339
BORDER="0"
 
340
BGCOLOR="#E0E0E0"
 
341
WIDTH="100%"
 
342
><TR
 
343
><TD
 
344
><PRE
 
345
CLASS="PROGRAMLISTING"
 
346
>dgt:~/dejagnu.test$ ./calc
 
347
calc: version
 
348
Version: 1.1
 
349
calc:<I
 
350
CLASS="EMPHASIS"
 
351
> </I
 
352
>add 3 4
 
353
7
 
354
calc: multiply 3 4<I
 
355
CLASS="EMPHASIS"
 
356
> </I
 
357
>
 
358
12
 
359
calc: multiply 2 4<I
 
360
CLASS="EMPHASIS"
 
361
> </I
 
362
>
 
363
12
 
364
calc: quit&#13;</PRE
 
365
></TD
 
366
></TR
 
367
></TABLE
 
368
><P
 
369
>Look at the intentional bug that 2 times 4 equals 12.</P
 
370
><P
 
371
>The tests run by DejaGnu need a file called site.exp,
 
372
which is automatically generated if we call &#8220;make site.exp&#8221;.
 
373
This was the purpose of the &#8220;AUTOMAKE_OPTIONS = dejagnu&#8221; in Makefile.am.</P
 
374
><DIV
 
375
CLASS="EXAMPLE"
 
376
><A
 
377
NAME="AEN273"
 
378
></A
 
379
><P
 
380
><B
 
381
>Example 6. Sample output generating a site.exp</B
 
382
></P
 
383
><TABLE
 
384
BORDER="0"
 
385
BGCOLOR="#E0E0E0"
 
386
WIDTH="100%"
 
387
><TR
 
388
><TD
 
389
><PRE
 
390
CLASS="PROGRAMLISTING"
 
391
>dgt: make site.exp
 
392
dgt:~/dejagnu.test$ make site.exp
 
393
Making a new site.exp file...</PRE
 
394
></TD
 
395
></TR
 
396
></TABLE
 
397
></DIV
 
398
></DIV
 
399
></DIV
 
400
><DIV
 
401
CLASS="NAVFOOTER"
 
402
><HR
 
403
ALIGN="LEFT"
 
404
WIDTH="100%"><TABLE
 
405
SUMMARY="Footer navigation table"
 
406
WIDTH="100%"
 
407
BORDER="0"
 
408
CELLPADDING="0"
 
409
CELLSPACING="0"
 
410
><TR
 
411
><TD
 
412
WIDTH="33%"
 
413
ALIGN="left"
 
414
VALIGN="top"
 
415
><A
 
416
HREF="c203.html"
 
417
ACCESSKEY="P"
 
418
>&#60;&#60;&#60; Previous</A
 
419
></TD
 
420
><TD
 
421
WIDTH="34%"
 
422
ALIGN="center"
 
423
VALIGN="top"
 
424
><A
 
425
HREF="book1.html"
 
426
ACCESSKEY="H"
 
427
>Home</A
 
428
></TD
 
429
><TD
 
430
WIDTH="33%"
 
431
ALIGN="right"
 
432
VALIGN="top"
 
433
><A
 
434
HREF="x276.html"
 
435
ACCESSKEY="N"
 
436
>Next &#62;&#62;&#62;</A
 
437
></TD
 
438
></TR
 
439
><TR
 
440
><TD
 
441
WIDTH="33%"
 
442
ALIGN="left"
 
443
VALIGN="top"
 
444
>Getting DejaGnu up and running</TD
 
445
><TD
 
446
WIDTH="34%"
 
447
ALIGN="center"
 
448
VALIGN="top"
 
449
><A
 
450
HREF="c203.html"
 
451
ACCESSKEY="U"
 
452
>Up</A
 
453
></TD
 
454
><TD
 
455
WIDTH="33%"
 
456
ALIGN="right"
 
457
VALIGN="top"
 
458
>Our first automated tests</TD
 
459
></TR
 
460
></TABLE
 
461
></DIV
 
462
></BODY
 
463
></HTML
 
464
>
 
 
b'\\ No newline at end of file'