]> 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#
f42414bf 3# "$Id: run-stp-tests.sh 6389 2007-03-24 14:26:04Z mike $"
ef416fc2 4#
5# Perform the complete set of IPP compliance tests specified in the
6# CUPS Software Test Plan.
7#
f899b121 8# Copyright 1997-2007 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
f42414bf 407#
408# Force POSIX locale for tests...
409#
410
411LANG=C
412export LANG
413
ef416fc2 414#
415# Start the server; run as foreground daemon in the background...
416#
417
418echo "Starting scheduler:"
a74454a7 419echo " $valgrind ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &"
ef416fc2 420echo ""
421
a74454a7 422$valgrind ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &
ef416fc2 423cupsd=$!
424
425#if test -x /usr/bin/strace; then
426# # Trace system calls in cupsd if we have strace...
427# /usr/bin/strace -tt -o /tmp/cups-$user/log/cupsd.trace -p $cupsd &
428#fi
429
430if test "x$testtype" = x0; then
431 echo "Scheduler is PID $cupsd and is listening on port 8631."
432 echo ""
433 echo "Set the IPP_PORT environment variable to 8631 to test the software"
434 echo "interactively from the command-line."
435 exit 0
436fi
437
a74454a7 438if test $argcount -eq 0; then
439 echo "Scheduler is PID $cupsd; run debugger now if you need to."
440 echo ""
441 echo $ac_n "Press ENTER to continue... $ac_c"
442 read junk
443else
444 echo "Scheduler is PID $cupsd."
445 sleep 2
446fi
ef416fc2 447
448IPP_PORT=$port; export IPP_PORT
449
450while true; do
451 running=`../systemv/lpstat -r 2>/dev/null`
452 if test "x$running" = "xscheduler is running"; then
453 break
454 fi
455
456 echo "Waiting for scheduler to become ready..."
457 sleep 10
458done
459
460#
461# Create the test report source file...
462#
463
f7deaa1a 464strfile=cups-str-1.3-`date +%Y-%m-%d`-$user.html
ef416fc2 465
466rm -f $strfile
467cat str-header.html >$strfile
468
469#
470# Run the IPP tests...
471#
472
a74454a7 473echo ""
ef416fc2 474echo "Running IPP compliance tests..."
475
bd7854cb 476echo "<H1>1 - IPP Compliance Tests</H1>" >>$strfile
ef416fc2 477echo "<P>This section provides the results to the IPP compliance tests" >>$strfile
478echo "outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile
e1d6a774 479echo `date "+%Y-%m-%d"` by $user on `hostname`. >>$strfile
ef416fc2 480echo "<PRE>" >>$strfile
481
482fail=0
483for file in 4*.test; do
484 echo "Performing $file..."
485 echo "" >>$strfile
486
487 ./ipptest ipp://localhost:$port/printers $file >>$strfile
488 status=$?
489
490 if test $status != 0; then
491 echo Test failed.
492 fail=`expr $fail + 1`
493 fi
494done
495
496echo "</PRE>" >>$strfile
497
498#
499# Run the command tests...
500#
501
a74454a7 502echo ""
ef416fc2 503echo "Running command tests..."
504
bd7854cb 505echo "<H1>2 - Command Tests</H1>" >>$strfile
ef416fc2 506echo "<P>This section provides the results to the command tests" >>$strfile
507echo "outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile
e1d6a774 508echo `date "+%Y-%m-%d"` by $user on `hostname`. >>$strfile
ef416fc2 509echo "<PRE>" >>$strfile
510
511for file in 5*.sh; do
512 echo "Performing $file..."
513 echo "" >>$strfile
514 echo "\"$file\":" >>$strfile
515
516 sh $file $pjobs >>$strfile
517 status=$?
518
519 if test $status != 0; then
520 echo Test failed.
521 fail=`expr $fail + 1`
522 fi
523done
524
525echo "</PRE>" >>$strfile
526
527#
528# Wait for jobs to complete...
529#
530
531while true; do
532 jobs=`../systemv/lpstat 2>/dev/null`
533 if test "x$jobs" = "x"; then
534 break
535 fi
536
537 echo "Waiting for jobs to complete..."
538 sleep 10
539done
540
541#
542# Stop the server...
543#
544
545kill $cupsd
546
547#
548# Append the log files for post-mortim...
549#
550
bd7854cb 551echo "<H1>3 - Log Files</H1>" >>$strfile
ef416fc2 552
553echo "<H2>access_log</H2>" >>$strfile
554echo "<PRE>" >>$strfile
555cat /tmp/cups-$user/log/access_log >>$strfile
556echo "</PRE>" >>$strfile
557
558echo "<H2>error_log</H2>" >>$strfile
559echo "<PRE>" >>$strfile
560cat /tmp/cups-$user/log/error_log >>$strfile
561echo "</PRE>" >>$strfile
562
563echo "<H2>page_log</H2>" >>$strfile
564echo "<PRE>" >>$strfile
565cat /tmp/cups-$user/log/page_log >>$strfile
566echo "</PRE>" >>$strfile
567
568if test -f /tmp/cups-$user/log/cupsd.trace; then
569 echo "<H2>cupsd.trace</H2>" >>$strfile
570 echo "<PRE>" >>$strfile
571 cat /tmp/cups-$user/log/cupsd.trace >>$strfile
572 echo "</PRE>" >>$strfile
573fi
574
575#
576# Format the reports and tell the user where to find them...
577#
578
ef416fc2 579cat str-trailer.html >>$strfile
580
ef416fc2 581echo ""
582
583if test $fail != 0; then
584 echo "$fail tests failed."
585else
586 echo "All tests were successful."
587fi
588
a74454a7 589echo "Log files can be found in /tmp/cups-$user/log."
590echo "A HTML report was created in test/$strfile."
ef416fc2 591echo ""
592
593#
f42414bf 594# End of "$Id: run-stp-tests.sh 6389 2007-03-24 14:26:04Z mike $"
ef416fc2 595#