]> 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#
f7deaa1a 3# "$Id: run-stp-tests.sh 6297 2007-02-21 02:24:16Z 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"
411affcf 123echo "1 - Test but do not require encryption"
124echo "2 - Test and require encryption"
ef416fc2 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
411affcf 137 1)
138 echo "Will test but not require encryption (1)"
139 ;;
140 2)
141 echo "Will test and require encryption (2)"
ef416fc2 142 ;;
ef416fc2 143 *)
411affcf 144 echo "Not using SSL/TLS (0)"
ef416fc2 145 ssltype=0
146 ;;
147esac
148
149#
150# Information for the server/tests...
151#
152
e1d6a774 153user="$USER"
154if test -z "$user"; then
155 if test -x /usr/ucb/whoami; then
156 user=`/usr/ucb/whoami`
157 else
158 user=`whoami`
159 fi
160
161 if test -z "$user"; then
162 user="unknown"
163 fi
164fi
165
ef416fc2 166port=8631
167cwd=`pwd`
168root=`dirname $cwd`
169
170#
171# Make sure that the LPDEST and PRINTER environment variables are
172# not included in the environment that is passed to the tests. These
173# will usually cause tests to fail erroneously...
174#
175
176typeset +x LPDEST
177typeset +x PRINTER
178
179#
180# See if we want to use valgrind...
181#
182
183echo ""
184echo "This test script can use the Valgrind software from:"
185echo ""
186echo " http://developer.kde.org/~sewardj/"
187echo ""
bd7854cb 188echo $ac_n "Enter Y to use Valgrind or N to not use Valgrind: [N] $ac_c"
ef416fc2 189
a74454a7 190if test $# -gt 0; then
191 usevalgrind=$1
192 shift
193else
194 read usevalgrind
195fi
bd7854cb 196echo ""
ef416fc2 197
198case "$usevalgrind" in
199 Y* | y*)
200 valgrind="valgrind --tool=memcheck --log-file=/tmp/cups-$user/log/valgrind --error-limit=no --leak-check=yes --trace-children=yes"
201 echo "Using Valgrind; log files can be found in /tmp/cups-$user/log..."
202 ;;
203
204 *)
205 valgrind=""
206 ;;
207esac
208
209#
210# Start by creating temporary directories for the tests...
211#
212
a74454a7 213echo "Creating directories for test..."
214
ef416fc2 215rm -rf /tmp/cups-$user
216mkdir /tmp/cups-$user
217mkdir /tmp/cups-$user/bin
218mkdir /tmp/cups-$user/bin/backend
219mkdir /tmp/cups-$user/bin/filter
220mkdir /tmp/cups-$user/certs
221mkdir /tmp/cups-$user/share
222mkdir /tmp/cups-$user/share/banners
223mkdir /tmp/cups-$user/share/model
224mkdir /tmp/cups-$user/interfaces
225mkdir /tmp/cups-$user/log
226mkdir /tmp/cups-$user/ppd
227mkdir /tmp/cups-$user/spool
228mkdir /tmp/cups-$user/spool/temp
229mkdir /tmp/cups-$user/ssl
230
231ln -s $root/backend/http /tmp/cups-$user/bin/backend
232ln -s $root/backend/ipp /tmp/cups-$user/bin/backend
233ln -s $root/backend/lpd /tmp/cups-$user/bin/backend
234ln -s $root/backend/parallel /tmp/cups-$user/bin/backend
235ln -s $root/backend/serial /tmp/cups-$user/bin/backend
a74454a7 236ln -s $root/backend/snmp /tmp/cups-$user/bin/backend
ef416fc2 237ln -s $root/backend/socket /tmp/cups-$user/bin/backend
238ln -s $root/backend/usb /tmp/cups-$user/bin/backend
239ln -s $root/cgi-bin /tmp/cups-$user/bin
bd7854cb 240ln -s $root/monitor /tmp/cups-$user/bin
ef416fc2 241ln -s $root/notifier /tmp/cups-$user/bin
242ln -s $root/scheduler /tmp/cups-$user/bin/daemon
243ln -s $root/filter/hpgltops /tmp/cups-$user/bin/filter
244ln -s $root/filter/imagetops /tmp/cups-$user/bin/filter
245ln -s $root/filter/imagetoraster /tmp/cups-$user/bin/filter
246ln -s $root/filter/pstops /tmp/cups-$user/bin/filter
247ln -s $root/filter/rastertoepson /tmp/cups-$user/bin/filter
248ln -s $root/filter/rastertohp /tmp/cups-$user/bin/filter
249ln -s $root/filter/texttops /tmp/cups-$user/bin/filter
250ln -s $root/pdftops/pdftops /tmp/cups-$user/bin/filter
251
252ln -s $root/data/classified /tmp/cups-$user/share/banners
253ln -s $root/data/confidential /tmp/cups-$user/share/banners
254ln -s $root/data/secret /tmp/cups-$user/share/banners
255ln -s $root/data/standard /tmp/cups-$user/share/banners
256ln -s $root/data/topsecret /tmp/cups-$user/share/banners
257ln -s $root/data/unclassified /tmp/cups-$user/share/banners
a74454a7 258ln -s $root/data /tmp/cups-$user/share/charmaps
ef416fc2 259ln -s $root/data /tmp/cups-$user/share/charsets
260ln -s $root/data /tmp/cups-$user/share
261ln -s $root/fonts /tmp/cups-$user/share
262ln -s $root/ppd/*.ppd /tmp/cups-$user/share/model
263ln -s $root/templates /tmp/cups-$user/share
264
265if test $ssltype != 0; then
266 mkdir $root/ssl
267 cp server.* $root/ssl
268fi
269
270#
271# Then create the necessary config files...
272#
273
a74454a7 274echo "Creating cupsd.conf for test..."
275
ef416fc2 276if test $ssltype = 2; then
277 encryption="Encryption Required"
278else
279 encryption=""
280fi
281
282cat >/tmp/cups-$user/cupsd.conf <<EOF
283Browsing Off
284FileDevice yes
285Printcap
286Listen 127.0.0.1:$port
287User $user
288ServerRoot /tmp/cups-$user
289StateDir /tmp/cups-$user
290ServerBin /tmp/cups-$user/bin
291CacheDir /tmp/cups-$user/share
292DataDir /tmp/cups-$user/share
293FontPath /tmp/cups-$user/share/fonts
294DocumentRoot $root/doc
295RequestRoot /tmp/cups-$user/spool
296TempDir /tmp/cups-$user/spool/temp
297MaxLogSize 0
298AccessLog /tmp/cups-$user/log/access_log
299ErrorLog /tmp/cups-$user/log/error_log
300PageLog /tmp/cups-$user/log/page_log
a74454a7 301LogLevel debug2
ef416fc2 302PreserveJobHistory Yes
303<Policy default>
304<Limit All>
305Order Deny,Allow
306Deny from all
307Allow from 127.0.0.1
308$encryption
309</Limit>
310</Policy>
311EOF
312
313touch /tmp/cups-$user/classes.conf
314touch /tmp/cups-$user/printers.conf
315
316#
317# Setup lots of test queues - 500 with PPD files, 500 without...
318#
319
a74454a7 320echo "Creating printers.conf for test..."
321
ef416fc2 322i=1
323while test $i -le $nprinters1; do
324 cat >>/tmp/cups-$user/printers.conf <<EOF
325<Printer test-$i>
326Accepting Yes
327DeviceURI file:/dev/null
328Info Test PS printer $i
329JobSheets none none
330Location CUPS test suite
331State Idle
332StateMessage Printer $1 is idle.
333</Printer>
334EOF
335
336 cp testps.ppd /tmp/cups-$user/ppd/test-$i.ppd
337
338 i=`expr $i + 1`
339done
340
341while test $i -le $nprinters2; do
342 cat >>/tmp/cups-$user/printers.conf <<EOF
343<Printer test-$i>
344Accepting Yes
345DeviceURI file:/dev/null
346Info Test raw printer $i
347JobSheets none none
348Location CUPS test suite
349State Idle
350StateMessage Printer $1 is idle.
351</Printer>
352EOF
353
354 i=`expr $i + 1`
355done
356
357cp /tmp/cups-$user/printers.conf /tmp/cups-$user/printers.conf.orig
358
359cp $root/conf/mime.types /tmp/cups-$user/mime.types
360cp $root/conf/mime.convs /tmp/cups-$user/mime.convs
361
362#
363# Setup the paths...
364#
365
a74454a7 366echo "Setting up environment variables for test..."
367
ef416fc2 368if test "x$LD_LIBRARY_PATH" = x; then
369 LD_LIBRARY_PATH="$root/cups:$root/filter"
370else
371 LD_LIBRARY_PATH="$root/cups:$root/filter:$LD_LIBRARY_PATH"
372fi
373
374export LD_LIBRARY_PATH
375
376LD_PRELOAD="$root/cups/libcups.so.2:$root/filter/libcupsimage.so.2"
377export LD_PRELOAD
378
379if test "x$DYLD_LIBRARY_PATH" = x; then
380 DYLD_LIBRARY_PATH="$root/cups:$root/filter"
381else
382 DYLD_LIBRARY_PATH="$root/cups:$root/filter:$DYLD_LIBRARY_PATH"
383fi
384
385export DYLD_LIBRARY_PATH
386
387if test "x$SHLIB_PATH" = x; then
388 SHLIB_PATH="$root/cups:$root/filter"
389else
390 SHLIB_PATH="$root/cups:$root/filter:$SHLIB_PATH"
391fi
392
393export SHLIB_PATH
394
395CUPS_SERVER=localhost; export CUPS_SERVER
396CUPS_SERVERROOT=/tmp/cups-$user; export CUPS_SERVERROOT
397CUPS_STATEDIR=/tmp/cups-$user; export CUPS_STATEDIR
398CUPS_DATADIR=/tmp/cups-$user/share; export CUPS_DATADIR
399
400#
401# Set a new home directory to avoid getting user options mixed in...
402#
403
404HOME=/tmp/cups-$user
405export HOME
406
407#
408# Start the server; run as foreground daemon in the background...
409#
410
411echo "Starting scheduler:"
a74454a7 412echo " $valgrind ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &"
ef416fc2 413echo ""
414
a74454a7 415$valgrind ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &
ef416fc2 416cupsd=$!
417
418#if test -x /usr/bin/strace; then
419# # Trace system calls in cupsd if we have strace...
420# /usr/bin/strace -tt -o /tmp/cups-$user/log/cupsd.trace -p $cupsd &
421#fi
422
423if test "x$testtype" = x0; then
424 echo "Scheduler is PID $cupsd and is listening on port 8631."
425 echo ""
426 echo "Set the IPP_PORT environment variable to 8631 to test the software"
427 echo "interactively from the command-line."
428 exit 0
429fi
430
a74454a7 431if test $argcount -eq 0; then
432 echo "Scheduler is PID $cupsd; run debugger now if you need to."
433 echo ""
434 echo $ac_n "Press ENTER to continue... $ac_c"
435 read junk
436else
437 echo "Scheduler is PID $cupsd."
438 sleep 2
439fi
ef416fc2 440
441IPP_PORT=$port; export IPP_PORT
442
443while true; do
444 running=`../systemv/lpstat -r 2>/dev/null`
445 if test "x$running" = "xscheduler is running"; then
446 break
447 fi
448
449 echo "Waiting for scheduler to become ready..."
450 sleep 10
451done
452
453#
454# Create the test report source file...
455#
456
f7deaa1a 457strfile=cups-str-1.3-`date +%Y-%m-%d`-$user.html
ef416fc2 458
459rm -f $strfile
460cat str-header.html >$strfile
461
462#
463# Run the IPP tests...
464#
465
a74454a7 466echo ""
ef416fc2 467echo "Running IPP compliance tests..."
468
bd7854cb 469echo "<H1>1 - IPP Compliance Tests</H1>" >>$strfile
ef416fc2 470echo "<P>This section provides the results to the IPP compliance tests" >>$strfile
471echo "outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile
e1d6a774 472echo `date "+%Y-%m-%d"` by $user on `hostname`. >>$strfile
ef416fc2 473echo "<PRE>" >>$strfile
474
475fail=0
476for file in 4*.test; do
477 echo "Performing $file..."
478 echo "" >>$strfile
479
480 ./ipptest ipp://localhost:$port/printers $file >>$strfile
481 status=$?
482
483 if test $status != 0; then
484 echo Test failed.
485 fail=`expr $fail + 1`
486 fi
487done
488
489echo "</PRE>" >>$strfile
490
491#
492# Run the command tests...
493#
494
a74454a7 495echo ""
ef416fc2 496echo "Running command tests..."
497
bd7854cb 498echo "<H1>2 - Command Tests</H1>" >>$strfile
ef416fc2 499echo "<P>This section provides the results to the command tests" >>$strfile
500echo "outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile
e1d6a774 501echo `date "+%Y-%m-%d"` by $user on `hostname`. >>$strfile
ef416fc2 502echo "<PRE>" >>$strfile
503
504for file in 5*.sh; do
505 echo "Performing $file..."
506 echo "" >>$strfile
507 echo "\"$file\":" >>$strfile
508
509 sh $file $pjobs >>$strfile
510 status=$?
511
512 if test $status != 0; then
513 echo Test failed.
514 fail=`expr $fail + 1`
515 fi
516done
517
518echo "</PRE>" >>$strfile
519
520#
521# Wait for jobs to complete...
522#
523
524while true; do
525 jobs=`../systemv/lpstat 2>/dev/null`
526 if test "x$jobs" = "x"; then
527 break
528 fi
529
530 echo "Waiting for jobs to complete..."
531 sleep 10
532done
533
534#
535# Stop the server...
536#
537
538kill $cupsd
539
540#
541# Append the log files for post-mortim...
542#
543
bd7854cb 544echo "<H1>3 - Log Files</H1>" >>$strfile
ef416fc2 545
546echo "<H2>access_log</H2>" >>$strfile
547echo "<PRE>" >>$strfile
548cat /tmp/cups-$user/log/access_log >>$strfile
549echo "</PRE>" >>$strfile
550
551echo "<H2>error_log</H2>" >>$strfile
552echo "<PRE>" >>$strfile
553cat /tmp/cups-$user/log/error_log >>$strfile
554echo "</PRE>" >>$strfile
555
556echo "<H2>page_log</H2>" >>$strfile
557echo "<PRE>" >>$strfile
558cat /tmp/cups-$user/log/page_log >>$strfile
559echo "</PRE>" >>$strfile
560
561if test -f /tmp/cups-$user/log/cupsd.trace; then
562 echo "<H2>cupsd.trace</H2>" >>$strfile
563 echo "<PRE>" >>$strfile
564 cat /tmp/cups-$user/log/cupsd.trace >>$strfile
565 echo "</PRE>" >>$strfile
566fi
567
568#
569# Format the reports and tell the user where to find them...
570#
571
ef416fc2 572cat str-trailer.html >>$strfile
573
ef416fc2 574echo ""
575
576if test $fail != 0; then
577 echo "$fail tests failed."
578else
579 echo "All tests were successful."
580fi
581
a74454a7 582echo "Log files can be found in /tmp/cups-$user/log."
583echo "A HTML report was created in test/$strfile."
ef416fc2 584echo ""
585
586#
f7deaa1a 587# End of "$Id: run-stp-tests.sh 6297 2007-02-21 02:24:16Z mike $"
ef416fc2 588#