]> git.ipfire.org Git - thirdparty/cups.git/blame - test/run-stp-tests.sh
Load cups into easysw/current.
[thirdparty/cups.git] / test / run-stp-tests.sh
CommitLineData
ef416fc2 1#!/bin/sh
2#
3# "$Id: run-stp-tests.sh 4891 2006-01-07 04:50:14Z mike $"
4#
5# Perform the complete set of IPP compliance tests specified in the
6# CUPS Software Test Plan.
7#
8# Copyright 1997-2005 by Easy Software Products, all rights reserved.
9#
10# These coded instructions, statements, and computer programs are the
11# property of Easy Software Products and are protected by Federal
12# copyright law. Distribution and use rights are outlined in the file
13# "LICENSE.txt" which should have been included with this file. If this
14# file is missing or damaged please contact Easy Software Products
15# at:
16#
17# Attn: CUPS Licensing Information
18# Easy Software Products
19# 44141 Airport View Drive, Suite 204
20# Hollywood, Maryland 20636 USA
21#
22# Voice: (301) 373-9600
23# EMail: cups-info@cups.org
24# WWW: http://www.cups.org
25#
26
27#
28# Make the IPP test program...
29#
30
31make
32
33#
34# Greet the tester...
35#
36
37echo "Welcome to the CUPS Automated Test Script."
38echo ""
39echo "Before we begin, it is important that you understand that the larger"
40echo "tests require significant amounts of RAM and disk space. If you"
41echo "attempt to run one of the big tests on a system that lacks sufficient"
42echo "disk and virtual memory, the UNIX kernel might decide to kill one or"
43echo "more system processes that you've grown attached to, like the X"
44echo "server. The question you may want to ask yourself before running a"
45echo "large test is: Do you feel lucky?"
46echo ""
47echo "OK, now that we have the Dirty Harry quote out of the way, please"
48echo "choose the type of test you wish to perform:"
49echo ""
50echo "0 - No testing, keep the scheduler running for me (all systems)"
51echo "1 - Basic conformance test, no load testing (all systems)"
52echo "2 - Basic conformance test, some load testing (minimum 256MB VM, 50MB disk)"
53echo "3 - Basic conformance test, extreme load testing (minimum 1GB VM, 500MB disk)"
54echo "4 - Basic conformance test, torture load testing (minimum 2GB VM, 1GB disk)"
55echo ""
56echo "Please enter the number of the test you wish to perform:"
57
58read testtype
59
60case "$testtype" in
61 0)
62 echo "Running in test mode (0)"
63 nprinters1=0
64 nprinters2=0
65 pjobs=0
66 ;;
67 2)
68 echo "Running the medium tests (2)"
69 nprinters1=10
70 nprinters2=20
71 pjobs=20
72 ;;
73 3)
74 echo "Running the extreme tests (3)"
75 nprinters1=500
76 nprinters2=1000
77 pjobs=100
78 ;;
79 4)
80 echo "Running the torture tests (4)"
81 nprinters1=10000
82 nprinters2=20000
83 pjobs=200
84 ;;
85 *)
86 echo "Running the timid tests (1)"
87 nprinters1=0
88 nprinters2=0
89 pjobs=0
90 ;;
91esac
92
93#
94# See if we want to do SSL testing...
95#
96
97echo ""
98echo "Now you can choose whether to create a SSL/TLS encryption key and"
99echo "certificate for testing; these tests currently require the OpenSSL"
100echo "tools:"
101echo ""
102echo "0 - Do not do SSL/TLS encryption tests"
103echo "1 - Create a SSL/TLS certificate and key, but do not require encryption"
104echo "2 - Create a SSL/TLS certificate and key and require encryption"
105echo ""
106
107read ssltype
108
109case "$ssltype" in
110 1 | 2)
111 if test -f server.key; then
112 echo "Using existing SSL/TLS certificate and key..."
113 else
114 echo "Generating SSL/TLS certificate and key..."
115 openssl req -new -x509 -keyout server.key -out server.crt -days 3650 -nodes >/dev/null <<EOF
116ZZ
117Testland
118Testville
119Test Company
120
121`hostname`
122test@domain.com
123EOF
124 fi
125 ;;
126
127 *)
128 echo "Not using SSL/TLS ($ssltype)..."
129 ssltype=0
130 ;;
131esac
132
133#
134# Information for the server/tests...
135#
136
137user=`whoami`
138port=8631
139cwd=`pwd`
140root=`dirname $cwd`
141
142#
143# Make sure that the LPDEST and PRINTER environment variables are
144# not included in the environment that is passed to the tests. These
145# will usually cause tests to fail erroneously...
146#
147
148typeset +x LPDEST
149typeset +x PRINTER
150
151#
152# See if we want to use valgrind...
153#
154
155echo ""
156echo "This test script can use the Valgrind software from:"
157echo ""
158echo " http://developer.kde.org/~sewardj/"
159echo ""
160echo "Please enter Y to use Valgrind or N to not use Valgrind:"
161
162read usevalgrind
163
164case "$usevalgrind" in
165 Y* | y*)
166 valgrind="valgrind --tool=memcheck --log-file=/tmp/cups-$user/log/valgrind --error-limit=no --leak-check=yes --trace-children=yes"
167 echo "Using Valgrind; log files can be found in /tmp/cups-$user/log..."
168 ;;
169
170 *)
171 valgrind=""
172 ;;
173esac
174
175#
176# Start by creating temporary directories for the tests...
177#
178
179rm -rf /tmp/cups-$user
180mkdir /tmp/cups-$user
181mkdir /tmp/cups-$user/bin
182mkdir /tmp/cups-$user/bin/backend
183mkdir /tmp/cups-$user/bin/filter
184mkdir /tmp/cups-$user/certs
185mkdir /tmp/cups-$user/share
186mkdir /tmp/cups-$user/share/banners
187mkdir /tmp/cups-$user/share/model
188mkdir /tmp/cups-$user/interfaces
189mkdir /tmp/cups-$user/log
190mkdir /tmp/cups-$user/ppd
191mkdir /tmp/cups-$user/spool
192mkdir /tmp/cups-$user/spool/temp
193mkdir /tmp/cups-$user/ssl
194
195ln -s $root/backend/http /tmp/cups-$user/bin/backend
196ln -s $root/backend/ipp /tmp/cups-$user/bin/backend
197ln -s $root/backend/lpd /tmp/cups-$user/bin/backend
198ln -s $root/backend/parallel /tmp/cups-$user/bin/backend
199ln -s $root/backend/serial /tmp/cups-$user/bin/backend
200ln -s $root/backend/socket /tmp/cups-$user/bin/backend
201ln -s $root/backend/usb /tmp/cups-$user/bin/backend
202ln -s $root/cgi-bin /tmp/cups-$user/bin
203ln -s $root/notifier /tmp/cups-$user/bin
204ln -s $root/scheduler /tmp/cups-$user/bin/daemon
205ln -s $root/filter/hpgltops /tmp/cups-$user/bin/filter
206ln -s $root/filter/imagetops /tmp/cups-$user/bin/filter
207ln -s $root/filter/imagetoraster /tmp/cups-$user/bin/filter
208ln -s $root/filter/pstops /tmp/cups-$user/bin/filter
209ln -s $root/filter/rastertoepson /tmp/cups-$user/bin/filter
210ln -s $root/filter/rastertohp /tmp/cups-$user/bin/filter
211ln -s $root/filter/texttops /tmp/cups-$user/bin/filter
212ln -s $root/pdftops/pdftops /tmp/cups-$user/bin/filter
213
214ln -s $root/data/classified /tmp/cups-$user/share/banners
215ln -s $root/data/confidential /tmp/cups-$user/share/banners
216ln -s $root/data/secret /tmp/cups-$user/share/banners
217ln -s $root/data/standard /tmp/cups-$user/share/banners
218ln -s $root/data/topsecret /tmp/cups-$user/share/banners
219ln -s $root/data/unclassified /tmp/cups-$user/share/banners
220ln -s $root/data /tmp/cups-$user/share/charsets
221ln -s $root/data /tmp/cups-$user/share
222ln -s $root/fonts /tmp/cups-$user/share
223ln -s $root/ppd/*.ppd /tmp/cups-$user/share/model
224ln -s $root/templates /tmp/cups-$user/share
225
226if test $ssltype != 0; then
227 mkdir $root/ssl
228 cp server.* $root/ssl
229fi
230
231#
232# Then create the necessary config files...
233#
234
235if test $ssltype = 2; then
236 encryption="Encryption Required"
237else
238 encryption=""
239fi
240
241cat >/tmp/cups-$user/cupsd.conf <<EOF
242Browsing Off
243FileDevice yes
244Printcap
245Listen 127.0.0.1:$port
246User $user
247ServerRoot /tmp/cups-$user
248StateDir /tmp/cups-$user
249ServerBin /tmp/cups-$user/bin
250CacheDir /tmp/cups-$user/share
251DataDir /tmp/cups-$user/share
252FontPath /tmp/cups-$user/share/fonts
253DocumentRoot $root/doc
254RequestRoot /tmp/cups-$user/spool
255TempDir /tmp/cups-$user/spool/temp
256MaxLogSize 0
257AccessLog /tmp/cups-$user/log/access_log
258ErrorLog /tmp/cups-$user/log/error_log
259PageLog /tmp/cups-$user/log/page_log
260LogLevel debug
261PreserveJobHistory Yes
262<Policy default>
263<Limit All>
264Order Deny,Allow
265Deny from all
266Allow from 127.0.0.1
267$encryption
268</Limit>
269</Policy>
270EOF
271
272touch /tmp/cups-$user/classes.conf
273touch /tmp/cups-$user/printers.conf
274
275#
276# Setup lots of test queues - 500 with PPD files, 500 without...
277#
278
279i=1
280while test $i -le $nprinters1; do
281 cat >>/tmp/cups-$user/printers.conf <<EOF
282<Printer test-$i>
283Accepting Yes
284DeviceURI file:/dev/null
285Info Test PS printer $i
286JobSheets none none
287Location CUPS test suite
288State Idle
289StateMessage Printer $1 is idle.
290</Printer>
291EOF
292
293 cp testps.ppd /tmp/cups-$user/ppd/test-$i.ppd
294
295 i=`expr $i + 1`
296done
297
298while test $i -le $nprinters2; do
299 cat >>/tmp/cups-$user/printers.conf <<EOF
300<Printer test-$i>
301Accepting Yes
302DeviceURI file:/dev/null
303Info Test raw printer $i
304JobSheets none none
305Location CUPS test suite
306State Idle
307StateMessage Printer $1 is idle.
308</Printer>
309EOF
310
311 i=`expr $i + 1`
312done
313
314cp /tmp/cups-$user/printers.conf /tmp/cups-$user/printers.conf.orig
315
316cp $root/conf/mime.types /tmp/cups-$user/mime.types
317cp $root/conf/mime.convs /tmp/cups-$user/mime.convs
318
319#
320# Setup the paths...
321#
322
323if test "x$LD_LIBRARY_PATH" = x; then
324 LD_LIBRARY_PATH="$root/cups:$root/filter"
325else
326 LD_LIBRARY_PATH="$root/cups:$root/filter:$LD_LIBRARY_PATH"
327fi
328
329export LD_LIBRARY_PATH
330
331LD_PRELOAD="$root/cups/libcups.so.2:$root/filter/libcupsimage.so.2"
332export LD_PRELOAD
333
334if test "x$DYLD_LIBRARY_PATH" = x; then
335 DYLD_LIBRARY_PATH="$root/cups:$root/filter"
336else
337 DYLD_LIBRARY_PATH="$root/cups:$root/filter:$DYLD_LIBRARY_PATH"
338fi
339
340export DYLD_LIBRARY_PATH
341
342if test "x$SHLIB_PATH" = x; then
343 SHLIB_PATH="$root/cups:$root/filter"
344else
345 SHLIB_PATH="$root/cups:$root/filter:$SHLIB_PATH"
346fi
347
348export SHLIB_PATH
349
350CUPS_SERVER=localhost; export CUPS_SERVER
351CUPS_SERVERROOT=/tmp/cups-$user; export CUPS_SERVERROOT
352CUPS_STATEDIR=/tmp/cups-$user; export CUPS_STATEDIR
353CUPS_DATADIR=/tmp/cups-$user/share; export CUPS_DATADIR
354
355#
356# Set a new home directory to avoid getting user options mixed in...
357#
358
359HOME=/tmp/cups-$user
360export HOME
361
362#
363# Start the server; run as foreground daemon in the background...
364#
365
366echo "Starting scheduler:"
367echo " $valgrind ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log &"
368echo ""
369
370$valgrind ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log &
371cupsd=$!
372
373#if test -x /usr/bin/strace; then
374# # Trace system calls in cupsd if we have strace...
375# /usr/bin/strace -tt -o /tmp/cups-$user/log/cupsd.trace -p $cupsd &
376#fi
377
378if test "x$testtype" = x0; then
379 echo "Scheduler is PID $cupsd and is listening on port 8631."
380 echo ""
381 echo "Set the IPP_PORT environment variable to 8631 to test the software"
382 echo "interactively from the command-line."
383 exit 0
384fi
385
386echo "Scheduler is PID $cupsd; run debugger now if you need to."
387echo ""
388echo "Press ENTER to continue..."
389read junk
390
391IPP_PORT=$port; export IPP_PORT
392
393while true; do
394 running=`../systemv/lpstat -r 2>/dev/null`
395 if test "x$running" = "xscheduler is running"; then
396 break
397 fi
398
399 echo "Waiting for scheduler to become ready..."
400 sleep 10
401done
402
403#
404# Create the test report source file...
405#
406
407strfile=cups-str-1.2-`date +%Y-%m-%d`-`whoami`.shtml
408
409rm -f $strfile
410cat str-header.html >$strfile
411
412#
413# Run the IPP tests...
414#
415
416echo "Running IPP compliance tests..."
417
418echo "<H1>IPP Compliance Tests</H1>" >>$strfile
419echo "<P>This section provides the results to the IPP compliance tests" >>$strfile
420echo "outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile
421echo `date "+%Y-%m-%d"` by `whoami` on `hostname`. >>$strfile
422echo "<PRE>" >>$strfile
423
424fail=0
425for file in 4*.test; do
426 echo "Performing $file..."
427 echo "" >>$strfile
428
429 ./ipptest ipp://localhost:$port/printers $file >>$strfile
430 status=$?
431
432 if test $status != 0; then
433 echo Test failed.
434 fail=`expr $fail + 1`
435 fi
436done
437
438echo "</PRE>" >>$strfile
439
440#
441# Run the command tests...
442#
443
444echo "Running command tests..."
445
446echo "<H1>Command Tests</H1>" >>$strfile
447echo "<P>This section provides the results to the command tests" >>$strfile
448echo "outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile
449echo `date "+%Y-%m-%d"` by `whoami` on `hostname`. >>$strfile
450echo "<PRE>" >>$strfile
451
452for file in 5*.sh; do
453 echo "Performing $file..."
454 echo "" >>$strfile
455 echo "\"$file\":" >>$strfile
456
457 sh $file $pjobs >>$strfile
458 status=$?
459
460 if test $status != 0; then
461 echo Test failed.
462 fail=`expr $fail + 1`
463 fi
464done
465
466echo "</PRE>" >>$strfile
467
468#
469# Wait for jobs to complete...
470#
471
472while true; do
473 jobs=`../systemv/lpstat 2>/dev/null`
474 if test "x$jobs" = "x"; then
475 break
476 fi
477
478 echo "Waiting for jobs to complete..."
479 sleep 10
480done
481
482#
483# Stop the server...
484#
485
486kill $cupsd
487
488#
489# Append the log files for post-mortim...
490#
491
492echo "<H1>Log Files</H1>" >>$strfile
493
494echo "<H2>access_log</H2>" >>$strfile
495echo "<PRE>" >>$strfile
496cat /tmp/cups-$user/log/access_log >>$strfile
497echo "</PRE>" >>$strfile
498
499echo "<H2>error_log</H2>" >>$strfile
500echo "<PRE>" >>$strfile
501cat /tmp/cups-$user/log/error_log >>$strfile
502echo "</PRE>" >>$strfile
503
504echo "<H2>page_log</H2>" >>$strfile
505echo "<PRE>" >>$strfile
506cat /tmp/cups-$user/log/page_log >>$strfile
507echo "</PRE>" >>$strfile
508
509if test -f /tmp/cups-$user/log/cupsd.trace; then
510 echo "<H2>cupsd.trace</H2>" >>$strfile
511 echo "<PRE>" >>$strfile
512 cat /tmp/cups-$user/log/cupsd.trace >>$strfile
513 echo "</PRE>" >>$strfile
514fi
515
516#
517# Format the reports and tell the user where to find them...
518#
519
520echo "Formatting reports..."
521
522cat str-trailer.html >>$strfile
523
524htmlfile=`basename $strfile .shtml`.html
525pdffile=`basename $strfile .shtml`.pdf
526
527htmldoc --numbered --verbose --titleimage ../doc/images/cups-large.gif \
528 -f $htmlfile $strfile
529htmldoc --numbered --verbose --titleimage ../doc/images/cups-large.gif \
530 -f $pdffile $strfile
531
532echo ""
533
534if test $fail != 0; then
535 echo "$fail tests failed."
536else
537 echo "All tests were successful."
538fi
539
540if test "x$valgrind" != x; then
541 echo "Valgrind log files can be found in /tmp/cups-$user/log."
542fi
543
544echo ""
545echo "See the following files for details:"
546echo ""
547echo " $htmlfile"
548echo " $pdffile"
549echo ""
550
551#
552# End of "$Id: run-stp-tests.sh 4891 2006-01-07 04:50:14Z mike $"
553#