]> git.ipfire.org Git - thirdparty/cups.git/blob - test/run-stp-tests.sh
659a68a3a81446bb62fae7a9dc26a743c3bcc562
[thirdparty/cups.git] / test / run-stp-tests.sh
1 #!/bin/sh
2 #
3 # "$Id: run-stp-tests.sh 177 2006-06-21 00:20:03Z jlovell $"
4 #
5 # Perform the complete set of IPP compliance tests specified in the
6 # CUPS Software Test Plan.
7 #
8 # Copyright 1997-2006 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 USA
21 #
22 # Voice: (301) 373-9600
23 # EMail: cups-info@cups.org
24 # WWW: http://www.cups.org
25 #
26
27 argcount=$#
28
29 #
30 # Make the IPP test program...
31 #
32
33 make
34
35 #
36 # Figure out the proper echo options...
37 #
38
39 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
40 ac_n=-n
41 ac_c=
42 else
43 ac_n=
44 ac_c='\c'
45 fi
46
47 #
48 # Greet the tester...
49 #
50
51 echo "Welcome to the CUPS Automated Test Script."
52 echo ""
53 echo "Before we begin, it is important that you understand that the larger"
54 echo "tests require significant amounts of RAM and disk space. If you"
55 echo "attempt to run one of the big tests on a system that lacks sufficient"
56 echo "disk and virtual memory, the UNIX kernel might decide to kill one or"
57 echo "more system processes that you've grown attached to, like the X"
58 echo "server. The question you may want to ask yourself before running a"
59 echo "large test is: Do you feel lucky?"
60 echo ""
61 echo "OK, now that we have the Dirty Harry quote out of the way, please"
62 echo "choose the type of test you wish to perform:"
63 echo ""
64 echo "0 - No testing, keep the scheduler running for me (all systems)"
65 echo "1 - Basic conformance test, no load testing (all systems)"
66 echo "2 - Basic conformance test, some load testing (minimum 256MB VM, 50MB disk)"
67 echo "3 - Basic conformance test, extreme load testing (minimum 1GB VM, 500MB disk)"
68 echo "4 - Basic conformance test, torture load testing (minimum 2GB VM, 1GB disk)"
69 echo ""
70 echo $ac_n "Enter the number of the test you wish to perform: [1] $ac_c"
71
72 if test $# -gt 0; then
73 testtype=$1
74 shift
75 else
76 read testtype
77 fi
78 echo ""
79
80 case "$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 ;;
111 esac
112
113 #
114 # See if we want to do SSL testing...
115 #
116
117 echo ""
118 echo "Now you can choose whether to create a SSL/TLS encryption key and"
119 echo "certificate for testing; these tests currently require the OpenSSL"
120 echo "tools:"
121 echo ""
122 echo "0 - Do not do SSL/TLS encryption tests"
123 echo "1 - Create a SSL/TLS certificate and key, but do not require encryption"
124 echo "2 - Create a SSL/TLS certificate and key and require encryption"
125 echo ""
126 echo $ac_n "Enter the number of the SSL/TLS tests to perform: [0] $ac_c"
127
128 if test $# -gt 0; then
129 ssltype=$1
130 shift
131 else
132 read ssltype
133 fi
134 echo ""
135
136 case "$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
143 ZZ
144 Testland
145 Testville
146 Test Company
147
148 `hostname`
149 test@domain.com
150 EOF
151 fi
152 ;;
153
154 *)
155 echo "Not using SSL/TLS..."
156 ssltype=0
157 ;;
158 esac
159
160 #
161 # Information for the server/tests...
162 #
163
164 user="$USER"
165 if 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
175 fi
176
177 port=8631
178 cwd=`pwd`
179 root=`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
187 typeset +x LPDEST
188 typeset +x PRINTER
189
190 #
191 # See if we want to use valgrind...
192 #
193
194 echo ""
195 echo "This test script can use the Valgrind software from:"
196 echo ""
197 echo " http://developer.kde.org/~sewardj/"
198 echo ""
199 echo $ac_n "Enter Y to use Valgrind or N to not use Valgrind: [N] $ac_c"
200
201 if test $# -gt 0; then
202 usevalgrind=$1
203 shift
204 else
205 read usevalgrind
206 fi
207 echo ""
208
209 case "$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 ;;
218 esac
219
220 #
221 # Start by creating temporary directories for the tests...
222 #
223
224 echo "Creating directories for test..."
225
226 rm -rf /tmp/cups-$user
227 mkdir /tmp/cups-$user
228 mkdir /tmp/cups-$user/bin
229 mkdir /tmp/cups-$user/bin/backend
230 mkdir /tmp/cups-$user/bin/filter
231 mkdir /tmp/cups-$user/certs
232 mkdir /tmp/cups-$user/share
233 mkdir /tmp/cups-$user/share/banners
234 mkdir /tmp/cups-$user/share/model
235 mkdir /tmp/cups-$user/interfaces
236 mkdir /tmp/cups-$user/log
237 mkdir /tmp/cups-$user/ppd
238 mkdir /tmp/cups-$user/spool
239 mkdir /tmp/cups-$user/spool/temp
240 mkdir /tmp/cups-$user/ssl
241
242 ln -s $root/backend/http /tmp/cups-$user/bin/backend
243 ln -s $root/backend/ipp /tmp/cups-$user/bin/backend
244 ln -s $root/backend/lpd /tmp/cups-$user/bin/backend
245 ln -s $root/backend/parallel /tmp/cups-$user/bin/backend
246 ln -s $root/backend/serial /tmp/cups-$user/bin/backend
247 ln -s $root/backend/snmp /tmp/cups-$user/bin/backend
248 ln -s $root/backend/socket /tmp/cups-$user/bin/backend
249 ln -s $root/backend/usb /tmp/cups-$user/bin/backend
250 ln -s $root/cgi-bin /tmp/cups-$user/bin
251 ln -s $root/monitor /tmp/cups-$user/bin
252 ln -s $root/notifier /tmp/cups-$user/bin
253 ln -s $root/scheduler /tmp/cups-$user/bin/daemon
254 ln -s $root/filter/hpgltops /tmp/cups-$user/bin/filter
255 ln -s $root/filter/imagetops /tmp/cups-$user/bin/filter
256 ln -s $root/filter/imagetoraster /tmp/cups-$user/bin/filter
257 ln -s $root/filter/pstops /tmp/cups-$user/bin/filter
258 ln -s $root/filter/rastertoepson /tmp/cups-$user/bin/filter
259 ln -s $root/filter/rastertohp /tmp/cups-$user/bin/filter
260 ln -s $root/filter/texttops /tmp/cups-$user/bin/filter
261 ln -s $root/pdftops/pdftops /tmp/cups-$user/bin/filter
262
263 ln -s $root/data/classified /tmp/cups-$user/share/banners
264 ln -s $root/data/confidential /tmp/cups-$user/share/banners
265 ln -s $root/data/secret /tmp/cups-$user/share/banners
266 ln -s $root/data/standard /tmp/cups-$user/share/banners
267 ln -s $root/data/topsecret /tmp/cups-$user/share/banners
268 ln -s $root/data/unclassified /tmp/cups-$user/share/banners
269 ln -s $root/data /tmp/cups-$user/share/charmaps
270 ln -s $root/data /tmp/cups-$user/share/charsets
271 ln -s $root/data /tmp/cups-$user/share
272 ln -s $root/fonts /tmp/cups-$user/share
273 ln -s $root/ppd/*.ppd /tmp/cups-$user/share/model
274 ln -s $root/templates /tmp/cups-$user/share
275
276 if test $ssltype != 0; then
277 mkdir $root/ssl
278 cp server.* $root/ssl
279 fi
280
281 #
282 # Then create the necessary config files...
283 #
284
285 echo "Creating cupsd.conf for test..."
286
287 if test $ssltype = 2; then
288 encryption="Encryption Required"
289 else
290 encryption=""
291 fi
292
293 cat >/tmp/cups-$user/cupsd.conf <<EOF
294 Browsing Off
295 FileDevice yes
296 Printcap
297 Listen 127.0.0.1:$port
298 User $user
299 ServerRoot /tmp/cups-$user
300 StateDir /tmp/cups-$user
301 ServerBin /tmp/cups-$user/bin
302 CacheDir /tmp/cups-$user/share
303 DataDir /tmp/cups-$user/share
304 FontPath /tmp/cups-$user/share/fonts
305 DocumentRoot $root/doc
306 RequestRoot /tmp/cups-$user/spool
307 TempDir /tmp/cups-$user/spool/temp
308 MaxLogSize 0
309 AccessLog /tmp/cups-$user/log/access_log
310 ErrorLog /tmp/cups-$user/log/error_log
311 PageLog /tmp/cups-$user/log/page_log
312 LogLevel debug2
313 PreserveJobHistory Yes
314 <Policy default>
315 <Limit All>
316 Order Deny,Allow
317 Deny from all
318 Allow from 127.0.0.1
319 $encryption
320 </Limit>
321 </Policy>
322 EOF
323
324 touch /tmp/cups-$user/classes.conf
325 touch /tmp/cups-$user/printers.conf
326
327 #
328 # Setup lots of test queues - 500 with PPD files, 500 without...
329 #
330
331 echo "Creating printers.conf for test..."
332
333 i=1
334 while test $i -le $nprinters1; do
335 cat >>/tmp/cups-$user/printers.conf <<EOF
336 <Printer test-$i>
337 Accepting Yes
338 DeviceURI file:/dev/null
339 Info Test PS printer $i
340 JobSheets none none
341 Location CUPS test suite
342 State Idle
343 StateMessage Printer $1 is idle.
344 </Printer>
345 EOF
346
347 cp testps.ppd /tmp/cups-$user/ppd/test-$i.ppd
348
349 i=`expr $i + 1`
350 done
351
352 while test $i -le $nprinters2; do
353 cat >>/tmp/cups-$user/printers.conf <<EOF
354 <Printer test-$i>
355 Accepting Yes
356 DeviceURI file:/dev/null
357 Info Test raw printer $i
358 JobSheets none none
359 Location CUPS test suite
360 State Idle
361 StateMessage Printer $1 is idle.
362 </Printer>
363 EOF
364
365 i=`expr $i + 1`
366 done
367
368 cp /tmp/cups-$user/printers.conf /tmp/cups-$user/printers.conf.orig
369
370 cp $root/conf/mime.types /tmp/cups-$user/mime.types
371 cp $root/conf/mime.convs /tmp/cups-$user/mime.convs
372
373 #
374 # Setup the paths...
375 #
376
377 echo "Setting up environment variables for test..."
378
379 if test "x$LD_LIBRARY_PATH" = x; then
380 LD_LIBRARY_PATH="$root/cups:$root/filter"
381 else
382 LD_LIBRARY_PATH="$root/cups:$root/filter:$LD_LIBRARY_PATH"
383 fi
384
385 export LD_LIBRARY_PATH
386
387 LD_PRELOAD="$root/cups/libcups.so.2:$root/filter/libcupsimage.so.2"
388 export LD_PRELOAD
389
390 if test "x$DYLD_LIBRARY_PATH" = x; then
391 DYLD_LIBRARY_PATH="$root/cups:$root/filter"
392 else
393 DYLD_LIBRARY_PATH="$root/cups:$root/filter:$DYLD_LIBRARY_PATH"
394 fi
395
396 export DYLD_LIBRARY_PATH
397
398 if test "x$SHLIB_PATH" = x; then
399 SHLIB_PATH="$root/cups:$root/filter"
400 else
401 SHLIB_PATH="$root/cups:$root/filter:$SHLIB_PATH"
402 fi
403
404 export SHLIB_PATH
405
406 CUPS_SERVER=localhost; export CUPS_SERVER
407 CUPS_SERVERROOT=/tmp/cups-$user; export CUPS_SERVERROOT
408 CUPS_STATEDIR=/tmp/cups-$user; export CUPS_STATEDIR
409 CUPS_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
415 HOME=/tmp/cups-$user
416 export HOME
417
418 #
419 # Start the server; run as foreground daemon in the background...
420 #
421
422 echo "Starting scheduler:"
423 echo " $valgrind ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &"
424 echo ""
425
426 $valgrind ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &
427 cupsd=$!
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
434 if 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
440 fi
441
442 if 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
447 else
448 echo "Scheduler is PID $cupsd."
449 sleep 2
450 fi
451
452 IPP_PORT=$port; export IPP_PORT
453
454 while 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
462 done
463
464 #
465 # Create the test report source file...
466 #
467
468 strfile=cups-str-1.2-`date +%Y-%m-%d`-$user.html
469
470 rm -f $strfile
471 cat str-header.html >$strfile
472
473 #
474 # Run the IPP tests...
475 #
476
477 echo ""
478 echo "Running IPP compliance tests..."
479
480 echo "<H1>1 - IPP Compliance Tests</H1>" >>$strfile
481 echo "<P>This section provides the results to the IPP compliance tests" >>$strfile
482 echo "outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile
483 echo `date "+%Y-%m-%d"` by $user on `hostname`. >>$strfile
484 echo "<PRE>" >>$strfile
485
486 fail=0
487 for 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
498 done
499
500 echo "</PRE>" >>$strfile
501
502 #
503 # Run the command tests...
504 #
505
506 echo ""
507 echo "Running command tests..."
508
509 echo "<H1>2 - Command Tests</H1>" >>$strfile
510 echo "<P>This section provides the results to the command tests" >>$strfile
511 echo "outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile
512 echo `date "+%Y-%m-%d"` by $user on `hostname`. >>$strfile
513 echo "<PRE>" >>$strfile
514
515 for 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
527 done
528
529 echo "</PRE>" >>$strfile
530
531 #
532 # Wait for jobs to complete...
533 #
534
535 while 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
543 done
544
545 #
546 # Stop the server...
547 #
548
549 kill $cupsd
550
551 #
552 # Append the log files for post-mortim...
553 #
554
555 echo "<H1>3 - Log Files</H1>" >>$strfile
556
557 echo "<H2>access_log</H2>" >>$strfile
558 echo "<PRE>" >>$strfile
559 cat /tmp/cups-$user/log/access_log >>$strfile
560 echo "</PRE>" >>$strfile
561
562 echo "<H2>error_log</H2>" >>$strfile
563 echo "<PRE>" >>$strfile
564 cat /tmp/cups-$user/log/error_log >>$strfile
565 echo "</PRE>" >>$strfile
566
567 echo "<H2>page_log</H2>" >>$strfile
568 echo "<PRE>" >>$strfile
569 cat /tmp/cups-$user/log/page_log >>$strfile
570 echo "</PRE>" >>$strfile
571
572 if 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
577 fi
578
579 #
580 # Format the reports and tell the user where to find them...
581 #
582
583 cat str-trailer.html >>$strfile
584
585 echo ""
586
587 if test $fail != 0; then
588 echo "$fail tests failed."
589 else
590 echo "All tests were successful."
591 fi
592
593 echo "Log files can be found in /tmp/cups-$user/log."
594 echo "A HTML report was created in test/$strfile."
595 echo ""
596
597 #
598 # End of "$Id: run-stp-tests.sh 177 2006-06-21 00:20:03Z jlovell $"
599 #