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