1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
5
>Create a minimal project, e.g. calc</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="Getting DejaGnu up and running"
18
HREF="c203.html"><LINK
20
TITLE="Our first automated tests"
21
HREF="x276.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
>Create a minimal project, e.g. calc</H1
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
90
>A simple project without the GNU autotools</H2
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
94
>The generated site.exp should like like:</P
102
CLASS="PROGRAMLISTING"
105
set objdir /home/dgt/dejagnu.test</PRE
117
>Using autoconf/autoheader/automake</H2
119
>We have to prepare some input file in order to run autocon and automake. There is book “GNU autoconf, automake and libtool” by Garry V. Vaughan, et al. NewRider, ISBN 1-57870-190-2 which describes this process thoroughly.</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
129
CLASS="PROGRAMLISTING"
130
>dgt:~/dejagnu.test$ cp -r /usr/share/doc/dejagnu/examples/calc/\
131
{configure.in,Makefile.am,calc.c,testsuite} .</PRE
136
>In Makemake.am note the presence of the AUTOMAKE_OPTIONS = dejagnu. This option is needed.</P
138
>Run aclocal to generate aclocal.m4, which is a collection of macros needed by configure.in</P
146
CLASS="PROGRAMLISTING"
147
>dgt:~/dejagnu.test$ aclocal</PRE
152
>autoconf is another part of the auto-tools.
153
Run it to generate configure based on information contained in configure.in.</P
161
CLASS="PROGRAMLISTING"
162
>dgt:~/dejagnu.test$ autoconf</PRE
167
>autoheader is another part of the auto-tools.
168
Run it to generate calc.h.in. </P
176
CLASS="PROGRAMLISTING"
177
>dgt:~/dejagnu.test$ autoheader</PRE
182
>The Makefile.am of this example was developed as port of the DejaGnu
184
Adapt Makefile.am for this test. Replace the line
185
“#noinst_PROGRAMS = calc” to
186
“bin_PROGRAMS = calc”.
187
Change the RUNTESTDEFAULTFLAGS from
188
“$$srcdir/testsuite” to
189
“./testsuite”.</P
191
>Running automake at this point contains a series of warning in its output as shown in the following example:</P
199
>Example 2. Sample output of automake with missing files</B
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
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
231
>Adapt calc to your environment by calling configure.</P
239
>Example 3. Sample output of configure</B
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
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
280
>Build the calc executable:</P
288
>Example 4. Sample output building calc</B
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
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
315
>Example 5. Creating the calc program using the GNU autotools</B
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 </PRE
336
>Play with calc and verify whether it works correctly.
337
A sample session might look like this:</P
345
CLASS="PROGRAMLISTING"
346
>dgt:~/dejagnu.test$ ./calc
369
>Look at the intentional bug that 2 times 4 equals 12.</P
371
>The tests run by DejaGnu need a file called site.exp,
372
which is automatically generated if we call “make site.exp”.
373
This was the purpose of the “AUTOMAKE_OPTIONS = dejagnu” in Makefile.am.</P
381
>Example 6. Sample output generating a site.exp</B
390
CLASS="PROGRAMLISTING"
392
dgt:~/dejagnu.test$ make site.exp
393
Making a new site.exp file...</PRE
405
SUMMARY="Footer navigation table"
418
><<< Previous</A
436
>Next >>></A
444
>Getting DejaGnu up and running</TD
458
>Our first automated tests</TD
b'\\ No newline at end of file'