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