]> git.ipfire.org Git - thirdparty/cups.git/blame - test/run-stp-tests.sh
Policy testing...
[thirdparty/cups.git] / test / run-stp-tests.sh
CommitLineData
a61a2be6 1#!/bin/sh
2#
5934328c 3# "$Id: run-stp-tests.sh,v 1.4.2.22 2004/06/30 21:18:32 mike Exp $"
a61a2be6 4#
74464516 5# Perform the complete set of IPP compliance tests specified in the
6# CUPS Software Test Plan.
7#
974f62b4 8# Copyright 1997-2002 by Easy Software Products, all rights reserved.
74464516 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-3111 USA
21#
22# Voice: (301) 373-9603
23# EMail: cups-info@cups.org
24# WWW: http://www.cups.org
a61a2be6 25#
26
27#
28# Make the IPP test program...
29#
30
31make
32
34271358 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 ""
3f5dfefd 50echo "0 - No testing, keep the scheduler running for me (all systems)"
254aa207 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)"
34271358 55echo ""
56echo "Please enter the number of the test you wish to perform:"
57
58read testtype
59
60case "$testtype" in
3f5dfefd 61 0)
62 echo "Running in test mode (0)"
63 nprinters1=0
64 nprinters2=0
65 pjobs=0
66 ;;
34271358 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 ;;
4d520ad4 79 4)
80 echo "Running the torture tests (4)"
81 nprinters1=10000
82 nprinters2=20000
83 pjobs=200
84 ;;
34271358 85 *)
86 echo "Running the timid tests (1)"
87 nprinters1=0
88 nprinters2=0
89 pjobs=0
90 ;;
91esac
92
a61a2be6 93#
94# Information for the server/tests...
95#
96
97user=`whoami`
98port=8631
bd917997 99cwd=`pwd`
100root=`dirname $cwd`
a61a2be6 101
4f6178db 102#
103# Make sure that the LPDEST and PRINTER environment variables are
104# not included in the environment that is passed to the tests. These
105# will usually cause tests to fail erroneously...
106#
107
108typeset +x LPDEST
109typeset +x PRINTER
110
ff40b65e 111#
112# See if we want to use valgrind...
113#
114
115echo ""
116echo "This test script can use the Valgrind software from:"
117echo ""
118echo " http://developer.kde.org/~sewardj/"
119echo ""
120echo "Please enter Y to use Valgrind or N to not use Valgrind:"
121
122read usevalgrind
123
124case "$usevalgrind" in
125 Y* | y*)
ba886a95 126 valgrind="valgrind --tool=memcheck --logfile=/tmp/$user/log/valgrind --error-limit=no --leak-check=yes --trace-children=yes"
ff40b65e 127 echo "Using Valgrind; log files can be found in /tmp/$user/log..."
128 ;;
129
130 *)
131 valgrind=""
132 ;;
133esac
134
a61a2be6 135#
bd917997 136# Start by creating temporary directories for the tests...
a61a2be6 137#
138
139rm -rf /tmp/$user
140mkdir /tmp/$user
bd917997 141mkdir /tmp/$user/bin
142mkdir /tmp/$user/bin/backend
143mkdir /tmp/$user/bin/filter
a61a2be6 144mkdir /tmp/$user/certs
bd917997 145mkdir /tmp/$user/share
146mkdir /tmp/$user/share/banners
147mkdir /tmp/$user/share/model
148mkdir /tmp/$user/interfaces
a61a2be6 149mkdir /tmp/$user/log
bd917997 150mkdir /tmp/$user/ppd
a61a2be6 151mkdir /tmp/$user/spool
152mkdir /tmp/$user/spool/temp
bd917997 153mkdir /tmp/$user/ssl
154
155ln -s $root/backend/http /tmp/$user/bin/backend
156ln -s $root/backend/ipp /tmp/$user/bin/backend
157ln -s $root/backend/lpd /tmp/$user/bin/backend
158ln -s $root/backend/parallel /tmp/$user/bin/backend
159ln -s $root/backend/serial /tmp/$user/bin/backend
160ln -s $root/backend/socket /tmp/$user/bin/backend
161ln -s $root/backend/usb /tmp/$user/bin/backend
162ln -s $root/cgi-bin /tmp/$user/bin
163ln -s $root/filter/hpgltops /tmp/$user/bin/filter
164ln -s $root/filter/imagetops /tmp/$user/bin/filter
165ln -s $root/filter/imagetoraster /tmp/$user/bin/filter
166ln -s $root/filter/pstops /tmp/$user/bin/filter
167ln -s $root/filter/rastertoepson /tmp/$user/bin/filter
168ln -s $root/filter/rastertohp /tmp/$user/bin/filter
169ln -s $root/filter/texttops /tmp/$user/bin/filter
50b9556e 170ln -s $root/pdftops/pdftops /tmp/$user/bin/filter
bd917997 171
172ln -s $root/data/classified /tmp/$user/share/banners
173ln -s $root/data/confidential /tmp/$user/share/banners
174ln -s $root/data/secret /tmp/$user/share/banners
175ln -s $root/data/standard /tmp/$user/share/banners
176ln -s $root/data/topsecret /tmp/$user/share/banners
177ln -s $root/data/unclassified /tmp/$user/share/banners
178ln -s $root/data /tmp/$user/share/charsets
179ln -s $root/data /tmp/$user/share
180ln -s $root/fonts /tmp/$user/share
181ln -s $root/ppd/*.ppd /tmp/$user/share/model
bd917997 182ln -s $root/templates /tmp/$user/share
a61a2be6 183
184#
185# Then create the necessary config files...
186#
187
188cat >/tmp/$user/cupsd.conf <<EOF
bd917997 189Browsing Off
9767abb4 190FileDevice yes
27d9c868 191Printcap
a61a2be6 192Listen 127.0.0.1:$port
193User $user
194ServerRoot /tmp/$user
bd917997 195ServerBin /tmp/$user/bin
196DataDir /tmp/$user/share
50b9556e 197FontPath /tmp/$user/share/fonts
bd917997 198DocumentRoot $root/doc
a61a2be6 199RequestRoot /tmp/$user/spool
200TempDir /tmp/$user/spool/temp
254aa207 201MaxLogSize 0
a61a2be6 202AccessLog /tmp/$user/log/access_log
203ErrorLog /tmp/$user/log/error_log
204PageLog /tmp/$user/log/page_log
dd63ebe2 205LogLevel debug2
bd917997 206PreserveJobHistory Yes
a61a2be6 207<Location />
208Order deny,allow
209Deny from all
210Allow from 127.0.0.1
211</Location>
212<Location /admin>
213Order deny,allow
214Deny from all
215Allow from 127.0.0.1
216Require valid-user
217</Location>
5934328c 218<Policy default>
219<Limit All>
220Order Deny,Allow
221</Limit>
222</Policy>
a61a2be6 223EOF
224
225touch /tmp/$user/classes.conf
226touch /tmp/$user/printers.conf
227
d47f8ebe 228#
229# Setup lots of test queues - 500 with PPD files, 500 without...
230#
231
232i=1
34271358 233while test $i -le $nprinters1; do
d47f8ebe 234 cat >>/tmp/$user/printers.conf <<EOF
235<Printer test-$i>
236Accepting Yes
237DeviceURI file:/dev/null
238Info Test PS printer $i
239JobSheets none none
240Location CUPS test suite
241State Idle
242StateMessage Printer $1 is idle.
243</Printer>
244EOF
245
246 cp testps.ppd /tmp/$user/ppd/test-$i.ppd
247
248 i=`expr $i + 1`
249done
250
34271358 251while test $i -le $nprinters2; do
d47f8ebe 252 cat >>/tmp/$user/printers.conf <<EOF
253<Printer test-$i>
254Accepting Yes
255DeviceURI file:/dev/null
256Info Test raw printer $i
257JobSheets none none
258Location CUPS test suite
259State Idle
260StateMessage Printer $1 is idle.
261</Printer>
262EOF
263
264 i=`expr $i + 1`
265done
266
267cp /tmp/$user/printers.conf /tmp/$user/printers.conf.orig
268
4124de73 269cp $root/conf/mime.types /tmp/$user/mime.types
270cp $root/conf/mime.convs /tmp/$user/mime.convs
a61a2be6 271
bd917997 272#
4124de73 273# Setup the paths...
bd917997 274#
275
974f62b4 276if test "x$LD_LIBRARY_PATH" = x; then
8a18d4da 277 LD_LIBRARY_PATH="$root/cups:$root/filter"
974f62b4 278else
8a18d4da 279 LD_LIBRARY_PATH="$root/cups:$root/filter:$LD_LIBRARY_PATH"
974f62b4 280fi
281
282export LD_LIBRARY_PATH
283
6f8d474c 284LD_PRELOAD="$root/cups/libcups.so:$root/filter/libcupsimage.so"
285export LD_PRELOAD
286
5f46b7d1 287if test "x$DYLD_LIBRARY_PATH" = x; then
8a18d4da 288 DYLD_LIBRARY_PATH="$root/cups:$root/filter"
5f46b7d1 289else
8a18d4da 290 DYLD_LIBRARY_PATH="$root/cups:$root/filter:$DYLD_LIBRARY_PATH"
5f46b7d1 291fi
292
8a18d4da 293export SHLIB_PATH
294
295if test "x$SHLIB_PATH" = x; then
296 SHLIB_PATH="$root/cups:$root/filter"
297else
298 SHLIB_PATH="$root/cups:$root/filter:$SHLIB_PATH"
299fi
300
301export SHLIB_PATH
5f46b7d1 302
4124de73 303CUPS_SERVERROOT=/tmp/$user; export CUPS_SERVERROOT
304CUPS_DATADIR=/tmp/$user/share; export CUPS_DATADIR
bd917997 305
74464516 306#
307# Set a new home directory to avoid getting user options mixed in...
308#
309
310HOME=/tmp/$user
311export HOME
312
a61a2be6 313#
314# Start the server; run as foreground daemon in the background...
315#
316
ba886a95 317echo "Starting scheduler:"
318echo " $valgrind ../scheduler/cupsd -c /tmp/$user/cupsd.conf -f >/tmp/$user/log/debug_log &"
3f5dfefd 319echo ""
a61a2be6 320
ff40b65e 321$valgrind ../scheduler/cupsd -c /tmp/$user/cupsd.conf -f >/tmp/$user/log/debug_log &
a61a2be6 322cupsd=$!
323
d47f8ebe 324#if test -x /usr/bin/strace; then
325# # Trace system calls in cupsd if we have strace...
326# /usr/bin/strace -tt -o /tmp/$user/log/cupsd.trace -p $cupsd &
327#fi
18fe941f 328
3f5dfefd 329if test "x$testtype" = x0; then
330 echo "Scheduler is PID $cupsd and is listening on port 8631."
331 echo ""
332 echo "Set the IPP_PORT environment variable to 8631 to test the software"
333 echo "interactively from the command-line."
334 exit 0
335fi
336
974f62b4 337echo "Scheduler is PID $cupsd; run debugger now if you need to."
338echo ""
339echo "Press ENTER to continue..."
340read junk
341
a61a2be6 342IPP_PORT=$port; export IPP_PORT
343
344while true; do
a61a2be6 345 running=`../systemv/lpstat -r 2>/dev/null`
346 if test "x$running" = "xscheduler is running"; then
347 break
348 fi
349
bd917997 350 echo "Waiting for scheduler to become ready..."
351 sleep 10
a61a2be6 352done
353
354#
74464516 355# Create the test report source file...
a61a2be6 356#
357
974f62b4 358strfile=cups-str-1.2-`date +%Y-%m-%d`-`whoami`.shtml
74464516 359
360rm -f $strfile
361cat str-header.html >$strfile
362
363#
364# Run the IPP tests...
365#
a61a2be6 366
74464516 367echo "Running IPP compliance tests..."
a61a2be6 368
74464516 369echo "<H1>IPP Compliance Tests</H1>" >>$strfile
370echo "<P>This section provides the results to the IPP compliance tests" >>$strfile
371echo "outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile
372echo `date "+%Y-%m-%d"` by `whoami` on `hostname`. >>$strfile
373echo "<PRE>" >>$strfile
a61a2be6 374
74464516 375fail=0
376for file in 4*.test; do
bd917997 377 echo "Performing $file..."
74464516 378 echo "" >>$strfile
bd917997 379
4124de73 380 ./ipptest ipp://localhost:$port/printers $file >>$strfile
bd917997 381 status=$?
382
383 if test $status != 0; then
74464516 384 echo Test failed.
974f62b4 385 fail=`expr $fail + 1`
bd917997 386 fi
a61a2be6 387done
388
74464516 389echo "</PRE>" >>$strfile
390
391#
392# Run the command tests...
393#
394
395echo "Running command tests..."
396
397echo "<H1>Command Tests</H1>" >>$strfile
398echo "<P>This section provides the results to the command tests" >>$strfile
399echo "outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile
400echo `date "+%Y-%m-%d"` by `whoami` on `hostname`. >>$strfile
401echo "<PRE>" >>$strfile
402
74464516 403for file in 5*.sh; do
404 echo "Performing $file..."
405 echo "" >>$strfile
50b9556e 406 echo "\"$file\":" >>$strfile
74464516 407
34271358 408 sh $file $pjobs >>$strfile
74464516 409 status=$?
410
411 if test $status != 0; then
412 echo Test failed.
974f62b4 413 fail=`expr $fail + 1`
74464516 414 fi
415done
416
417echo "</PRE>" >>$strfile
a61a2be6 418
bd917997 419#
420# Wait for jobs to complete...
421#
422
423while true; do
424 jobs=`../systemv/lpstat 2>/dev/null`
425 if test "x$jobs" = "x"; then
426 break
427 fi
428
429 echo "Waiting for jobs to complete..."
430 sleep 10
431done
432
a61a2be6 433#
434# Stop the server...
435#
436
437kill $cupsd
438
439#
74464516 440# Append the log files for post-mortim...
441#
442
443echo "<H1>Log Files</H1>" >>$strfile
444
445echo "<H2>access_log</H2>" >>$strfile
446echo "<PRE>" >>$strfile
447cat /tmp/$user/log/access_log >>$strfile
448echo "</PRE>" >>$strfile
449
450echo "<H2>error_log</H2>" >>$strfile
451echo "<PRE>" >>$strfile
452cat /tmp/$user/log/error_log >>$strfile
453echo "</PRE>" >>$strfile
454
455echo "<H2>page_log</H2>" >>$strfile
456echo "<PRE>" >>$strfile
457cat /tmp/$user/log/page_log >>$strfile
458echo "</PRE>" >>$strfile
459
18fe941f 460if test -f /tmp/$user/log/cupsd.trace; then
461 echo "<H2>cupsd.trace</H2>" >>$strfile
462 echo "<PRE>" >>$strfile
463 cat /tmp/$user/log/cupsd.trace >>$strfile
464 echo "</PRE>" >>$strfile
465fi
466
74464516 467#
468# Format the reports and tell the user where to find them...
469#
470
dbb05cda 471echo "Formatting reports..."
74464516 472
dbb05cda 473cat str-trailer.html >>$strfile
74464516 474
475htmlfile=`basename $strfile .shtml`.html
476pdffile=`basename $strfile .shtml`.pdf
477
478htmldoc --numbered --verbose --titleimage ../doc/images/cups-large.gif \
479 -f $htmlfile $strfile
480htmldoc --numbered --verbose --titleimage ../doc/images/cups-large.gif \
481 -f $pdffile $strfile
482
74464516 483echo ""
484
485if test $fail != 0; then
974f62b4 486 echo "$fail tests failed."
74464516 487else
974f62b4 488 echo "All tests were successful."
74464516 489fi
490
59406620 491if test "x$valgrind" != x; then
cf859e99 492 echo "Valgrind log files can be found in /tmp/$user/log."
59406620 493fi
494
74464516 495echo ""
496echo "See the following files for details:"
497echo ""
498echo " $htmlfile"
499echo " $pdffile"
500echo ""
501
502#
5934328c 503# End of "$Id: run-stp-tests.sh,v 1.4.2.22 2004/06/30 21:18:32 mike Exp $"
a61a2be6 504#