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