about summary refs log tree commit diff
path: root/doc/TESTS
blob: 44f8675855aab650a413171748643e1264ade1d9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
Contents
========

1. Running the tests
  1.1 Standard test procedure
  1.2 Summary report
  1.3 Prerequisites
    1.3.1 Required programs
    1.3.2 Required locales
  1.4 Repeatability
  1.5 Execution time
  1.6 Testing package in designated directory
  1.7 Pre-packaging check
  1.8 Post-install check
  1.9 Testing less than everything
  1.10 Valgrind
  
2. Troubleshooting
  2.1 Missing programs
  2.2 Broken programs
  2.3 Color name file
  2.4 Multiple versions
  2.5 System dependent issues

3. Reporting test failures

------------------------------------------------------------------------------

1. Running the tests
====================

1.1 Standard test procedure
===========================

The recommended method of running the tests is after packaging:

   make
   make package
   make check

To capture the output do:

   make check 2>&1 | less

Or:

   make check > check.log  2>&1



1.2 Summary report
==================

Like most other test routines, these produce much output.  A summary will
appear at the end:

  Test summary:
  ==================
  SUCCESS 83
  FAILURE 1
  TOTAL TESTABLE 84
  ==================
  All tests done.
  Sat, 08 Jun 2013 09:30:33 +0000
  make: *** [check] Error 1



1.3 Prerequisites
=================

1.3.1 Required programs
-----------------------

The tests require the Bash command shell.  The script Execute-Tests has
some expressions unique to Bash.  Quite old versions work, at least back
to Bash v. 2.05b.

Awk is also required, but the constructs are all simple.  Gawk, Mawk and
BWK Awk (the "One True Awk") are all known to work. 

The tests use the following utilities:

 - sh
 - awk

 - basename
 - cat
 - cksum
 - cmp
 - comm
 - cp
 - cut
 - date
 - dirname
 - egrep
 - fgrep
 - file
 - grep
 - gs
 - head
 - iconv
 - mkdir
 - mktemp
 - perl
 - rm
 - sed
 - seq
 - sh
 - sort
 - tee
 - tr
 - uniq
 - wc


1.3.2 Required locales
----------------------

For full covereage the following locales must be available:

  en_US.iso88591, en_US.utf8

To check whether they are available, execute the following and see if they
are reported:

  locale -a | grep en_US

The output should contain these lines:

  en_US.iso88591
  en_US.utf8

If these locales are absent some pbmtext tests will be skipped.


1.4 Repeatability
=================

The current version of the test package produces identical results if
you run "make check" repeatedly.  The tests contain no random elements;
some Netpbm programs use randomness internally, but the tests seed
their random number generators with fixed values so that they too have
repeatable results.



1.5 Execution time
==================

Currently "make check" takes no more time to execute than "make package",
and much less than "make".



1.6 Testing package in designated directory
===========================================

If you specify the package directory when you do "make package",
you must do the same with "make check":

   make
   make package pkgdir=/tmp/package
   make check pkgdir=/tmp/package



1.7 Pre-packaging check
=======================

You can run the tests to check executables after compilation, before
packaging.  This feature is intended for developers.

   make check-tree

This test method is incompatible with merge build.

This works when Netpbm is compiled in the source tree and also when
a separate build directory is used.



1.8 Post-install check
======================

You can run the tests after installation.  Run this way, the tests are of
programs in the default search path.

  make check-install

Make sure to set RGBDEF if the color dictionary file rgb.txt is in
a non-standard location.  This must be an absolute path.  

  RGBDEF=/etc/colors/rgb.txt make check-install



1.9 Testing less than everything
================================

The file test/Test-Order is a list of tests which are run.  If you want to
skip a test, remove the line or comment it out with a "#".

If you want to run just a few of the tests, use the make variable "target", a
comma-separated list of Netpbm programs.

  make check target=giftopnm,pamtogif

    This runs only the tests of 'giftopnm' and 'pamtogif', in the package
    (staging) directory.

  make check-tree target=ppmbrighten

    This runs only the tests of 'ppmbrighten', from the build tree.


1.10 Valgrind
=============

You can run the whole test under Valgrind.  This is an advanced feature
intended for programmers who work on Netpbm code.

To turn on Valgrind, set VALGRIND_TESTS to "on":

  make check VALGRIND_TESTS="on"

Valgrind version 3.6.0 or newer is required.  For information on
valgrind, visit http://www.valgrind.org/ .

Valgrind results are output to files, one per process in the directory
/tmp/netpbm-test/valgrind .  The file name consists of the test script
name, process ID and the suffix ".vout", e.g.: "ppmmake.18420.vout" .

Valgrind errors are not reported in the summary report and do not
influence the success/failure count in any way.  The following awk
one-liner will report ".vout" files with a positive error count in
the ERROR SUMMARY line:

  awk '/ERROR SUMMARY/ && $4>0 {print FILENAME}' \
       /tmp/netpbm-test/valgrind/*.vout  


You can add or alter valgrind options by editing this line in
test/Execute-Tests:

  vg_command_base="valgrind --trace-children=yes"

To get useful information from "--trace-origins=yes", you must make
two changes to config.mk before compilation:

  - Add -g to CFLAGS
  - Turn stripping off: STRIPFLAG =

Without these changes valgrind will report how many errors were
detected, of what kind, and at what addresses (in binary).  With the
above "-g" turned on during compilation valgrind reports source file
and line numbers of detected problems.

Valgrind significantly increases execution time.  If ordinary
"make check" requires 10 seconds, "make check VALGRIND_TESTS=on"
will require roughly 12 minutes, maybe more.  You should consider
either setting "target=..." or paring down the items in Test-Order.
In the latter case, you probably don't need to run "all-in-place.test"
and "legacy-names.test"; consider commenting them out.

The option "--trace-children-skip" is used to prevent valgrind from
stepping into child processes that are not relevant.  This option
appears in valgrind v. 3.6.0.  If you wish to conduct valgrind tests
with an older version, comment out the line in Execute-Tests with
"--trace-children-skip".



2. Troubleshooting
==================

2.1 Missing programs
====================

The first two tests run, "all-in-place.test" and "legacy-names.test"
detect missing programs.

If you work around a build glitch with "make --keep-going" you
will get a few errors here.

A wholesale failure with "all-in-place.test" indicates a systemic
problem, such as a misconfigured dynamic library or a directory-wide
permission issue.  This kind of failure is known to happen when N is
set too high with "make -jN" (overambitious parallel make.) 

Configuration choices affect tests.  If a choice you make during configure
causes "make" to skip compilation of certain programs, the corresponding
test routines will be skipped and reported as NOT TESTABLE.  However,
if you override a glitch with "make --keep-going" the test programs
won't know and quite certainly you'll get failure messages.

If you run the tests as "make check-install" information about
configuration choices is deliberately ignored.  This is because the
post-install check is typically run on systems with multiple versions
of Netpbm and in this case most users would want to get a clear idea
of absent components.

For details on the effects of missing libraries, read
'Netpbm Library Prerequisites':
http://netpbm.sourceforge.net/prereq.html .



2.2 Broken programs
===================

Broken programs will invariably lead to failures.  Certain programs
(for instance, image generators 'pbmmake' and 'pgmmake') are used in
numerous test scripts.  Problems in them will lead to multiple failures.

To aid you in this situation each test routine lists the necessary programs
near the top.

Each test routine comes in two parts, a ".test" file which is a
shell script and a ".ok" file which denotes its proper output.
When a test fails, a ".out" file will be produced in the
/tmp/netpbm-test/ directory.  By comparing ".ok" and ".out" you
can tell exactly what went wrong.  Often one does not need to
go this far; the error messages tell enough.

In some cases the ".ok" file is generated dynamically.  See "2.5
System Dependent Issues."



2.3 Color dictionary file
=========================

If you get the following error message, it indicates a problem with
the color dictionary file rgb.txt.

  ppmmake: can't open color names dictionary file from the path '/usr/share/
  netpbm/rgb.txt:/usr/lib/X11/rgb.txt:/usr/share/X11/rgb.txt:/usr/X11R6/lib/
  X11/rgb.txt' and Environment variable RGBDEF not set.  Set RGBDEF to the
  pathname of your rgb.txt file or don't use color names.

This is highly unlikely to occur with "make check" right after packaging,
but may appear in the post-installation check "make check-install".

To check manually after installation, execute the following and see
whether the proper output or the error message appears:

   ppmmake red 1 1 -plain

Proper output:

   P3
   1 1
   255
   255 0 0

The simple remedy is properly setting the environment value RGBDEF to
the location of rgb.txt.

RGBDEF must be an absolute path.  The following will not work:

  RGBDEF=./lib/rgb.txt make check-install

If you want to hardcode the path, modify RGB_DB_PATH in pm_config.h
and run "make" again.  Note that running "configure" will cause
pm_config.h to be overwritten; changes by editing will be lost.



2.4 Multiple versions
=====================

If multiple versions of Netpbm executables are installed on your
system, you should do a post-installation check to ensure that
the newly built version is in place and in working condition.

The test routines can test binaries other than the intended
target, for example pre-compiled binaries distributed in .rpm
or .deb format.  If the default binary search path gives priority
to a directory that contains programs from such a source, you should
expect multiple failures due to missing features, etc. with
"make check-install".

Netpbm distributed with Debian or Ubuntu is called "Netpbm-Free" and
is based on a fork which broke off in 2002.  There are many differences.
Many tests will fail.  However, the test framework itself is valid for
these distributions.  The following procedure will allow you to run
the tests on installed Netpbm programs, regardless of the version:

   ./configure           # accept the defaults
   make check-install

As of this writing (April 2018) Debian is working on resolving the
fork.  A new version, tagged as "experimental", based on the Sourceforge
line of source files is available.



2.5 System dependent issues
===========================

The tests have worked on x86 and x86_64 GNU/Linux systems and with several
versions of GCC and Clang and also Mac OS/Clang.  Reports from users of
other systems including OS, Sun SPARC and BSD and compilers other than
GCC are highly welcome.

Floating point math precision seems to be an issue.  Some discrepancies
have been observed between x86 32 bit and 64 bit; the tests are written to
work around them as much as possible.  The use of the "--fast-math"
c compiler flag by default may also be a factor.

Another cause of discrepancies is the qsort function.  The tests are
written to circumvent this issue at some cost to accuracy and
coverage.

The test directory Makefile checks whether the random number generator
is the one from glibc or Mac OS and automatically generates the proper
".ok" files from master files with the suffix ".rand-ok".  If some other
random number generator is detected the affected tests are skipped.



3. Reporting test failures
==========================

When reporting problems with the tests, please give both
the output of "make check" and the contents of the "netpbm-test"
directory.