Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
srohatgi01
GitHub Repository: srohatgi01/cups
Path: blob/master/test/run-stp-tests.sh
1090 views
1
#!/bin/sh
2
#
3
# Perform the complete set of IPP compliance tests specified in the
4
# CUPS Software Test Plan.
5
#
6
# Copyright © 2020-2022 by OpenPrinting
7
# Copyright © 2007-2021 by Apple Inc.
8
# Copyright © 1997-2007 by Easy Software Products, all rights reserved.
9
#
10
# Licensed under Apache License v2.0. See the file "LICENSE" for more
11
# information.
12
#
13
14
argcount=$#
15
16
#
17
# Don't allow "make check" or "make test" to be run by root...
18
#
19
20
if test "x`id -u`" = x0; then
21
echo Please run this as a normal user. Not supported when run as root.
22
exit 1
23
fi
24
25
#
26
# Force the permissions of the files we create...
27
#
28
29
umask 022
30
31
#
32
# Make the IPP test program...
33
#
34
35
make
36
37
#
38
# Solaris has a non-POSIX grep in /bin...
39
#
40
41
if test -x /usr/xpg4/bin/grep; then
42
GREP=/usr/xpg4/bin/grep
43
else
44
GREP=grep
45
fi
46
47
#
48
# Figure out the proper echo options...
49
#
50
51
if (echo "testing\c"; echo 1,2,3) | $GREP c >/dev/null; then
52
ac_n=-n
53
ac_c=
54
else
55
ac_n=
56
ac_c='\c'
57
fi
58
59
#
60
# Greet the tester...
61
#
62
63
echo "Welcome to the CUPS Automated Test Script."
64
echo ""
65
echo "Before we begin, it is important that you understand that the larger"
66
echo "tests require significant amounts of RAM and disk space. If you"
67
echo "attempt to run one of the big tests on a system that lacks sufficient"
68
echo "disk and virtual memory, the UNIX kernel might decide to kill one or"
69
echo "more system processes that you've grown attached to, like the X"
70
echo "server. The question you may want to ask yourself before running a"
71
echo "large test is: Do you feel lucky?"
72
echo ""
73
echo "OK, now that we have the Dirty Harry quote out of the way, please"
74
echo "choose the type of test you wish to perform:"
75
echo ""
76
echo "0 - No testing, keep the scheduler running for me (all systems)"
77
echo "1 - Basic conformance test, no load testing (all systems)"
78
echo "2 - Basic conformance test, some load testing (minimum 256MB VM, 50MB disk)"
79
echo "3 - Basic conformance test, extreme load testing (minimum 1GB VM, 500MB disk)"
80
echo "4 - Basic conformance test, torture load testing (minimum 2GB VM, 1GB disk)"
81
echo ""
82
echo $ac_n "Enter the number of the test you wish to perform: [1] $ac_c"
83
84
if test $# -gt 0; then
85
testtype=$1
86
shift
87
else
88
read testtype
89
fi
90
echo ""
91
92
case "$testtype" in
93
0)
94
echo "Running in test mode (0)"
95
nprinters=0
96
pjobs=0
97
pprinters=0
98
loglevel="debug2"
99
;;
100
2)
101
echo "Running the medium tests (2)"
102
nprinters=20
103
pjobs=20
104
pprinters=10
105
loglevel="debug"
106
;;
107
3)
108
echo "Running the extreme tests (3)"
109
nprinters=1000
110
pjobs=100
111
pprinters=50
112
loglevel="debug"
113
;;
114
4)
115
echo "Running the torture tests (4)"
116
nprinters=20000
117
pjobs=200
118
pprinters=100
119
loglevel="debug"
120
;;
121
*)
122
echo "Running the timid tests (1)"
123
nprinters=0
124
pjobs=10
125
pprinters=0
126
loglevel="debug2"
127
testtype="1"
128
;;
129
esac
130
131
#
132
# See if we want to do SSL testing...
133
#
134
135
echo ""
136
echo "Now you can choose whether to create a SSL/TLS encryption key and"
137
echo "certificate for testing:"
138
echo ""
139
echo "0 - Do not do SSL/TLS encryption tests"
140
echo "1 - Test but do not require encryption"
141
echo "2 - Test and require encryption"
142
echo ""
143
echo $ac_n "Enter the number of the SSL/TLS tests to perform: [0] $ac_c"
144
145
if test $# -gt 0; then
146
ssltype=$1
147
shift
148
else
149
read ssltype
150
fi
151
echo ""
152
153
case "$ssltype" in
154
1)
155
echo "Will test but not require encryption (1)"
156
;;
157
2)
158
echo "Will test and require encryption (2)"
159
;;
160
*)
161
echo "Not using SSL/TLS (0)"
162
ssltype=0
163
;;
164
esac
165
166
#
167
# Information for the server/tests...
168
#
169
170
user="$USER"
171
if test -z "$user"; then
172
if test -x /usr/ucb/whoami; then
173
user=`/usr/ucb/whoami`
174
else
175
user=`whoami`
176
fi
177
178
if test -z "$user"; then
179
user="unknown"
180
fi
181
fi
182
183
port="${CUPS_TESTPORT:=8631}"
184
cwd=`pwd`
185
root=`dirname $cwd`
186
CUPS_TESTROOT="$root"; export CUPS_TESTROOT
187
188
BASE="${CUPS_TESTBASE:=}"
189
if test -z "$BASE"; then
190
if test -d /private/tmp; then
191
BASE=/private/tmp/cups-$user
192
else
193
BASE=/tmp/cups-$user
194
fi
195
fi
196
export BASE
197
198
#
199
# Make sure that the LPDEST and PRINTER environment variables are
200
# not included in the environment that is passed to the tests. These
201
# will usually cause tests to fail erroneously...
202
#
203
204
unset LPDEST
205
unset PRINTER
206
207
#
208
# See if we want to use valgrind...
209
#
210
211
echo ""
212
echo "This test script can use the Valgrind software from:"
213
echo ""
214
echo " http://developer.kde.org/~sewardj/"
215
echo ""
216
echo $ac_n "Enter Y to use Valgrind or N to not use Valgrind: [N] $ac_c"
217
218
if test $# -gt 0; then
219
usevalgrind=$1
220
shift
221
else
222
read usevalgrind
223
fi
224
echo ""
225
226
case "$usevalgrind" in
227
Y* | y*)
228
VALGRIND="valgrind --tool=memcheck --log-file=$BASE/log/valgrind.%p --error-limit=no --leak-check=yes --trace-children=yes"
229
if test `uname` = Darwin; then
230
VALGRIND="$VALGRIND --dsymutil=yes"
231
fi
232
export VALGRIND
233
echo "Using Valgrind; log files can be found in $BASE/log..."
234
;;
235
236
*)
237
VALGRIND=""
238
export VALGRIND
239
;;
240
esac
241
242
#
243
# See if we want to do debug logging of the libraries...
244
#
245
246
echo ""
247
echo "If CUPS was built with the --enable-debug-printfs configure option, you"
248
echo "can enable debug logging of the libraries."
249
echo ""
250
echo $ac_n "Enter Y or a number from 0 to 9 to enable debug logging or N to not: [N] $ac_c"
251
252
if test $# -gt 0; then
253
usedebugprintfs=$1
254
shift
255
else
256
read usedebugprintfs
257
fi
258
echo ""
259
260
case "$usedebugprintfs" in
261
Y* | y*)
262
echo "Enabling debug printfs (level 5); log files can be found in $BASE/log..."
263
CUPS_DEBUG_LOG="$BASE/log/debug_printfs.%d"; export CUPS_DEBUG_LOG
264
CUPS_DEBUG_LEVEL=5; export CUPS_DEBUG_LEVEL
265
CUPS_DEBUG_FILTER='^(http|_http|ipp|_ipp|cups.*Request|cupsGetResponse|cupsSend).*$'; export CUPS_DEBUG_FILTER
266
;;
267
268
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9)
269
echo "Enabling debug printfs (level $usedebugprintfs); log files can be found in $BASE/log..."
270
CUPS_DEBUG_LOG="$BASE/log/debug_printfs.%d"; export CUPS_DEBUG_LOG
271
CUPS_DEBUG_LEVEL="$usedebugprintfs"; export CUPS_DEBUG_LEVEL
272
CUPS_DEBUG_FILTER='^(http|_http|ipp|_ipp|cups.*Request|cupsGetResponse|cupsSend).*$'; export CUPS_DEBUG_FILTER
273
;;
274
275
*)
276
;;
277
esac
278
279
#
280
# Start by creating temporary directories for the tests...
281
#
282
283
echo "Creating directories for test..."
284
285
rm -rf $BASE
286
mkdir $BASE
287
mkdir $BASE/bin
288
mkdir $BASE/bin/backend
289
mkdir $BASE/bin/driver
290
mkdir $BASE/bin/filter
291
mkdir $BASE/certs
292
mkdir $BASE/share
293
mkdir $BASE/share/banners
294
mkdir $BASE/share/drv
295
mkdir $BASE/share/locale
296
for file in ../locale/cups_*.po; do
297
loc=`basename $file .po | cut -c 6-`
298
mkdir $BASE/share/locale/$loc
299
ln -s $root/locale/cups_$loc.po $BASE/share/locale/$loc
300
done
301
mkdir $BASE/share/locale/en
302
ln -s $root/locale/cups.pot $BASE/share/locale/en/cups_en.po
303
mkdir $BASE/share/mime
304
mkdir $BASE/share/model
305
mkdir $BASE/share/ppdc
306
mkdir $BASE/interfaces
307
mkdir $BASE/log
308
mkdir $BASE/ppd
309
mkdir $BASE/spool
310
mkdir $BASE/spool/temp
311
mkdir $BASE/ssl
312
313
ln -s $root/backend/dnssd $BASE/bin/backend
314
ln -s $root/backend/http $BASE/bin/backend
315
ln -s $root/backend/ipp $BASE/bin/backend
316
ln -s ipp $BASE/bin/backend/ipps
317
ln -s $root/backend/lpd $BASE/bin/backend
318
ln -s $root/backend/mdns $BASE/bin/backend
319
ln -s $root/backend/pseudo $BASE/bin/backend
320
ln -s $root/backend/snmp $BASE/bin/backend
321
ln -s $root/backend/socket $BASE/bin/backend
322
ln -s $root/backend/usb $BASE/bin/backend
323
ln -s $root/cgi-bin $BASE/bin
324
ln -s $root/monitor $BASE/bin
325
ln -s $root/notifier $BASE/bin
326
ln -s $root/scheduler $BASE/bin/daemon
327
ln -s $root/filter/commandtops $BASE/bin/filter
328
ln -s $root/filter/gziptoany $BASE/bin/filter
329
ln -s $root/filter/pstops $BASE/bin/filter
330
ln -s $root/filter/rastertoepson $BASE/bin/filter
331
ln -s $root/filter/rastertohp $BASE/bin/filter
332
ln -s $root/filter/rastertolabel $BASE/bin/filter
333
ln -s $root/filter/rastertopwg $BASE/bin/filter
334
cat >$BASE/share/banners/standard <<EOF
335
==== Cover Page ====
336
337
338
Job: {?printer-name}-{?job-id}
339
Owner: {?job-originating-user-name}
340
Name: {?job-name}
341
Pages: {?job-impressions}
342
343
344
==== Cover Page ====
345
EOF
346
cat >$BASE/share/banners/classified <<EOF
347
==== Classified - Do Not Disclose ====
348
349
350
Job: {?printer-name}-{?job-id}
351
Owner: {?job-originating-user-name}
352
Name: {?job-name}
353
Pages: {?job-impressions}
354
355
356
==== Classified - Do Not Disclose ====
357
EOF
358
ln -s $root/data $BASE/share
359
ln -s $root/ppdc/sample.drv $BASE/share/drv
360
ln -s $root/conf/cgi.types $BASE/share/mime
361
ln -s $root/conf/mime.types $BASE/share/mime
362
ln -s $root/conf/mime.convs $BASE/share/mime
363
ln -s $root/data/*.h $BASE/share/ppdc
364
ln -s $root/data/*.defs $BASE/share/ppdc
365
ln -s $root/templates $BASE/share
366
367
#
368
# Local filters and configuration files...
369
#
370
371
instfilter() {
372
# instfilter src dst format
373
#
374
# See if the filter exists in a standard location; if so, make a
375
# symlink, otherwise create a dummy script for the specified format.
376
#
377
src="$1"
378
dst="$2"
379
format="$3"
380
381
for dir in /usr/local/libexec/cups/filter /usr/libexec/cups/filter /usr/lib/cups/filter; do
382
if test -x "$dir/$src"; then
383
ln -s "$dir/$src" "$BASE/bin/filter/$dst"
384
return
385
fi
386
done
387
388
# Source filter not present, create a dummy filter
389
case $format in
390
passthru)
391
ln -s gziptoany "$BASE/bin/filter/$dst"
392
;;
393
pdf)
394
cat >"$BASE/bin/filter/$dst" <<EOF
395
#!/bin/sh
396
trap "" TERM
397
trap "" PIPE
398
gziptoany "$1" "$2" "$3" "$4" "$5" \$6 >/dev/null
399
case "\$5" in
400
*media=a4* | *media=iso_a4* | *PageSize=A4*)
401
gziptoany "$1" "$2" "$3" "$4" "$5" "$root/examples/onepage-a4.pdf"
402
;;
403
*)
404
gziptoany "$1" "$2" "$3" "$4" "$5" "$root/examples/onepage-letter.pdf"
405
;;
406
esac
407
EOF
408
chmod +x "$BASE/bin/filter/$dst"
409
;;
410
ps)
411
cat >"$BASE/bin/filter/$dst" <<EOF
412
#!/bin/sh
413
trap "" TERM
414
trap "" PIPE
415
gziptoany "$1" "$2" "$3" "$4" "$5" \$6 >/dev/null
416
case "\$5" in
417
*media=a4* | *media=iso_a4* | *PageSize=A4*)
418
gziptoany "$1" "$2" "$3" "$4" "$5" "$root/examples/onepage-a4.ps"
419
;;
420
*)
421
gziptoany "$1" "$2" "$3" "$4" "$5" "$root/examples/onepage-letter.ps"
422
;;
423
esac
424
EOF
425
chmod +x "$BASE/bin/filter/$dst"
426
;;
427
raster)
428
cat >"$BASE/bin/filter/$dst" <<EOF
429
#!/bin/sh
430
trap "" TERM
431
trap "" PIPE
432
gziptoany "$1" "$2" "$3" "$4" "$5" \$6 >/dev/null
433
case "\$5" in
434
*media=a4* | *media=iso_a4* | *PageSize=A4*)
435
gziptoany "$1" "$2" "$3" "$4" "$5" "$root/examples/onepage-a4-300-black-1.pwg"
436
;;
437
*)
438
gziptoany "$1" "$2" "$3" "$4" "$5" "$root/examples/onepage-letter-300-black-1.pwg"
439
;;
440
esac
441
EOF
442
chmod +x "$BASE/bin/filter/$dst"
443
;;
444
esac
445
}
446
447
ln -s $root/test/test.convs $BASE/share/mime
448
449
if test `uname` = Darwin; then
450
instfilter cgimagetopdf imagetopdf pdf
451
instfilter cgpdftopdf pdftopdf passthru
452
instfilter cgpdftops pdftops ps
453
instfilter cgpdftoraster pdftoraster raster
454
instfilter cgtexttopdf texttopdf pdf
455
instfilter pstocupsraster pstoraster raster
456
else
457
instfilter imagetopdf imagetopdf pdf
458
instfilter pdftopdf pdftopdf passthru
459
instfilter pdftops pdftops ps
460
instfilter pdftoraster pdftoraster raster
461
instfilter pstoraster pstoraster raster
462
instfilter texttopdf texttopdf pdf
463
464
if test -d /usr/share/cups/charsets; then
465
ln -s /usr/share/cups/charsets $BASE/share
466
fi
467
fi
468
469
#
470
# Then create the necessary config files...
471
#
472
473
echo "Creating cupsd.conf for test..."
474
475
if test $ssltype = 2; then
476
encryption="Encryption Required"
477
else
478
encryption=""
479
fi
480
481
if test $testtype = 0; then
482
jobhistory="30m"
483
jobfiles="5m"
484
else
485
jobhistory="30"
486
jobfiles="Off"
487
fi
488
489
cat >$BASE/cupsd.conf <<EOF
490
StrictConformance Yes
491
Browsing Off
492
Listen localhost:$port
493
Listen $BASE/sock
494
MaxSubscriptions 3
495
MaxLogSize 0
496
AccessLogLevel actions
497
LogLevel $loglevel
498
LogTimeFormat usecs
499
PreserveJobHistory $jobhistory
500
PreserveJobFiles $jobfiles
501
<Policy default>
502
<Limit All>
503
Order Allow,Deny
504
$encryption
505
</Limit>
506
</Policy>
507
EOF
508
509
if test $testtype = 0; then
510
echo WebInterface yes >>$BASE/cupsd.conf
511
fi
512
513
cat >$BASE/cups-files.conf <<EOF
514
FileDevice yes
515
Printcap
516
User $user
517
ServerRoot $BASE
518
StateDir $BASE
519
ServerBin $BASE/bin
520
CacheDir $BASE/share
521
DataDir $BASE/share
522
DocumentRoot $root/doc
523
RequestRoot $BASE/spool
524
TempDir $BASE/spool/temp
525
AccessLog $BASE/log/access_log
526
ErrorLog $BASE/log/error_log
527
PageLog $BASE/log/page_log
528
529
PassEnv DYLD_INSERT_LIBRARIES
530
PassEnv DYLD_LIBRARY_PATH
531
PassEnv LD_LIBRARY_PATH
532
PassEnv LD_PRELOAD
533
PassEnv LOCALEDIR
534
PassEnv ASAN_OPTIONS
535
536
Sandboxing Off
537
EOF
538
539
if test $ssltype != 0 -a `uname` = Darwin; then
540
echo "ServerKeychain $HOME/Library/Keychains/login.keychain" >> $BASE/cups-files.conf
541
fi
542
543
#
544
# Setup lots of test queues with PPD files...
545
#
546
547
echo "Creating printers.conf for test..."
548
549
i=1
550
while test $i -le $nprinters; do
551
cat >>$BASE/printers.conf <<EOF
552
<Printer test-$i>
553
Accepting Yes
554
DeviceURI file:/dev/null
555
Info Test PS printer $i
556
JobSheets none none
557
Location CUPS test suite
558
State Idle
559
StateMessage Printer $1 is idle.
560
</Printer>
561
EOF
562
563
cp testps.ppd $BASE/ppd/test-$i.ppd
564
565
i=`expr $i + 1`
566
done
567
568
if test -f $BASE/printers.conf; then
569
cp $BASE/printers.conf $BASE/printers.conf.orig
570
else
571
touch $BASE/printers.conf.orig
572
fi
573
574
#
575
# Create a helper script to run programs with...
576
#
577
578
echo "Setting up environment variables for test..."
579
580
if test "x$ASAN_OPTIONS" = x; then
581
# AddressSanitizer on Linux reports memory leaks from the main function
582
# which is basically useless - in general, programs do not need to free
583
# every object before exit since the OS will recover the process's
584
# memory.
585
ASAN_OPTIONS="detect_leaks=false"
586
export ASAN_OPTIONS
587
fi
588
589
if test -f "$root/cups/libcups.so.2"; then
590
if test "x$LD_LIBRARY_PATH" = x; then
591
LD_LIBRARY_PATH="$root/cups"
592
else
593
LD_LIBRARY_PATH="$root/cups:$LD_LIBRARY_PATH"
594
fi
595
596
LD_PRELOAD="$root/cups/libcups.so.2:$root/cups/libcupsimage.so.2"
597
if test `uname` = SunOS -a -r /usr/lib/libCrun.so.1; then
598
LD_PRELOAD="/usr/lib/libCrun.so.1:$LD_PRELOAD"
599
fi
600
fi
601
602
if test -f "$root/cups/libcups.2.dylib"; then
603
if test "x$DYLD_INSERT_LIBRARIES" = x; then
604
DYLD_INSERT_LIBRARIES="$root/cups/libcups.2.dylib:$root/cups/libcupsimage.2.dylib"
605
else
606
DYLD_INSERT_LIBRARIES="$root/cups/libcups.2.dylib:$root/cups/libcupsimage.2.dylib:$DYLD_INSERT_LIBRARIES"
607
fi
608
609
if test "x$DYLD_LIBRARY_PATH" = x; then
610
DYLD_LIBRARY_PATH="$root/cups"
611
else
612
DYLD_LIBRARY_PATH="$root/cups:$DYLD_LIBRARY_PATH"
613
fi
614
fi
615
616
# These get exported because they don't have side-effects...
617
CUPS_DISABLE_APPLE_DEFAULT=yes; export CUPS_DISABLE_APPLE_DEFAULT
618
CUPS_SERVER=localhost:$port; export CUPS_SERVER
619
CUPS_SERVERROOT=$BASE; export CUPS_SERVERROOT
620
CUPS_STATEDIR=$BASE; export CUPS_STATEDIR
621
CUPS_DATADIR=$BASE/share; export CUPS_DATADIR
622
IPP_PORT=$port; export IPP_PORT
623
LOCALEDIR=$BASE/share/locale; export LOCALEDIR
624
625
echo "Creating wrapper script..."
626
627
runcups="$BASE/runcups"; export runcups
628
629
echo "#!/bin/sh" >$runcups
630
echo "# Helper script for running CUPS test instance." >>$runcups
631
echo "" >>$runcups
632
echo "# Set required environment variables..." >>$runcups
633
echo "CUPS_DATADIR=\"$CUPS_DATADIR\"; export CUPS_DATADIR" >>$runcups
634
echo "CUPS_SERVER=\"$CUPS_SERVER\"; export CUPS_SERVER" >>$runcups
635
echo "CUPS_SERVERROOT=\"$CUPS_SERVERROOT\"; export CUPS_SERVERROOT" >>$runcups
636
echo "CUPS_STATEDIR=\"$CUPS_STATEDIR\"; export CUPS_STATEDIR" >>$runcups
637
echo "DYLD_INSERT_LIBRARIES=\"$DYLD_INSERT_LIBRARIES\"; export DYLD_INSERT_LIBRARIES" >>$runcups
638
echo "DYLD_LIBRARY_PATH=\"$DYLD_LIBRARY_PATH\"; export DYLD_LIBRARY_PATH" >>$runcups
639
# IPP_PORT=$port; export IPP_PORT
640
echo "LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH\"; export LD_LIBRARY_PATH" >>$runcups
641
echo "LD_PRELOAD=\"$LD_PRELOAD\"; export LD_PRELOAD" >>$runcups
642
echo "LOCALEDIR=\"$LOCALEDIR\"; export LOCALEDIR" >>$runcups
643
if test "x$CUPS_DEBUG_LEVEL" != x; then
644
echo "CUPS_DEBUG_FILTER='$CUPS_DEBUG_FILTER'; export CUPS_DEBUG_FILTER" >>$runcups
645
echo "CUPS_DEBUG_LEVEL=$CUPS_DEBUG_LEVEL; export CUPS_DEBUG_LEVEL" >>$runcups
646
echo "CUPS_DEBUG_LOG='$CUPS_DEBUG_LOG'; export CUPS_DEBUG_LOG" >>$runcups
647
fi
648
echo "" >>$runcups
649
echo "# Run command..." >>$runcups
650
echo "exec \"\$@\"" >>$runcups
651
652
chmod +x $runcups
653
654
#
655
# Set a new home directory to avoid getting user options mixed in...
656
#
657
658
HOME=$BASE
659
export HOME
660
661
#
662
# Force POSIX locale for tests...
663
#
664
665
LANG=C
666
export LANG
667
668
LC_MESSAGES=C
669
export LC_MESSAGES
670
671
#
672
# Start the server; run as foreground daemon in the background...
673
#
674
675
echo "Starting scheduler:"
676
echo " $runcups $VALGRIND ../scheduler/cupsd -c $BASE/cupsd.conf -f >$BASE/log/debug_log 2>&1 &"
677
echo ""
678
679
$runcups $VALGRIND ../scheduler/cupsd -c $BASE/cupsd.conf -f >$BASE/log/debug_log 2>&1 &
680
681
cupsd=$!
682
683
if test "x$testtype" = x0; then
684
# Not running tests...
685
echo "Scheduler is PID $cupsd and is listening on port $port."
686
echo ""
687
688
echo "The $runcups helper script can be used to test programs"
689
echo "with the server."
690
exit 0
691
fi
692
693
if test $argcount -eq 0; then
694
echo "Scheduler is PID $cupsd; run debugger now if you need to."
695
echo ""
696
echo $ac_n "Press ENTER to continue... $ac_c"
697
read junk
698
else
699
echo "Scheduler is PID $cupsd."
700
sleep 2
701
fi
702
703
tries=0
704
while test $tries -lt 30; do
705
running=`$runcups ../systemv/lpstat -r 2>/dev/null`
706
if test "x$running" = "xscheduler is running"; then
707
break
708
fi
709
710
echo "Waiting for scheduler to become ready..."
711
sleep 10
712
713
tries=`expr $tries + 1`
714
done
715
716
#
717
# Create the test report source file...
718
#
719
720
date=`date "+%Y-%m-%d"`
721
722
strfile=$BASE/cups-str-$date-$user.html
723
724
rm -f $strfile
725
cat str-header.html >$strfile
726
727
#
728
# Run the IPP tests...
729
#
730
731
echo ""
732
echo "Running IPP compliance tests..."
733
734
echo " <h1><a name='IPP'>1 - IPP Compliance Tests</a></h1>" >>$strfile
735
echo " <p>This section provides the results to the IPP compliance tests" >>$strfile
736
echo " outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile
737
echo " $date by $user on `hostname`." >>$strfile
738
echo " <pre>" >>$strfile
739
740
fail=0
741
for file in 4*.test ../examples/ipp-2.1.test; do
742
echo $ac_n "Performing `basename $file`: $ac_c"
743
echo "" >>$strfile
744
echo $ac_n "`date '+[%d/%b/%Y:%H:%M:%S %z]'` $ac_c" >>$strfile
745
746
if test $file = ../examples/ipp-2.1.test; then
747
uri="ipp://localhost:$port/printers/Test1"
748
options="-V 2.1 -d NOPRINT=1 -f testfile.ps"
749
else
750
uri="ipp://localhost:$port/printers"
751
options=""
752
fi
753
$runcups $VALGRIND ../tools/ipptool -tI $options $uri $file >> $strfile
754
status=$?
755
756
if test $status != 0; then
757
echo FAIL
758
fail=`expr $fail + 1`
759
else
760
echo PASS
761
fi
762
done
763
764
echo " </pre>" >>$strfile
765
766
#
767
# Run the command tests...
768
#
769
770
echo ""
771
echo "Running command tests..."
772
773
echo " <h1><a name='COMMAND'>2 - Command Tests</a></h1>" >>$strfile
774
echo " <p>This section provides the results to the command tests" >>$strfile
775
echo " outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile
776
echo " $date by $user on `hostname`." >>$strfile
777
echo " <pre>" >>$strfile
778
779
for file in 5*.sh; do
780
# Wait for jobs from the previous test to complete before running the
781
# next test...
782
if test $file != 5.1-lpadmin.sh; then
783
./waitjobs.sh 1800
784
fi
785
786
# Run the test...
787
echo $ac_n "Performing $file: $ac_c"
788
echo "" >>$strfile
789
echo "`date '+[%d/%b/%Y:%H:%M:%S %z]'` \"$file\":" >>$strfile
790
791
sh $file $pjobs $pprinters >> $strfile
792
status=$?
793
794
if test $status != 0; then
795
echo FAIL
796
fail=`expr $fail + 1`
797
else
798
echo PASS
799
fi
800
done
801
802
#
803
# Restart the server...
804
#
805
806
echo $ac_n "Performing restart test: $ac_c"
807
echo "" >>$strfile
808
echo "`date '+[%d/%b/%Y:%H:%M:%S %z]'` \"5.10-restart\":" >>$strfile
809
810
kill -HUP $cupsd
811
812
while true; do
813
sleep 10
814
815
running=`$runcups ../systemv/lpstat -r 2>/dev/null`
816
if test "x$running" = "xscheduler is running"; then
817
break
818
fi
819
done
820
821
description="`$runcups ../systemv/lpstat -l -p Test1 | grep Description | sed -e '1,$s/^[^:]*: //g'`"
822
if test "x$description" != "xTest Printer 1"; then
823
echo "Failed, printer-info for Test1 is '$description', expected 'Test Printer 1'." >>$strfile
824
echo "FAIL (got '$description', expected 'Test Printer 1')"
825
fail=`expr $fail + 1`
826
else
827
echo "Passed." >>$strfile
828
echo PASS
829
fi
830
831
832
#
833
# Perform job history test...
834
#
835
836
echo $ac_n "Starting history test: $ac_c"
837
echo "" >>$strfile
838
echo "`date '+[%d/%b/%Y:%H:%M:%S %z]'` \"5.11-history\":" >>$strfile
839
840
echo " lp -d Test1 testfile.jpg" >>$strfile
841
842
$runcups ../systemv/lp -d Test1 ../examples/testfile.jpg 2>&1 >>$strfile
843
if test $? != 0; then
844
echo "FAIL (unable to queue test job)"
845
echo " FAILED" >>$strfile
846
fail=`expr $fail + 1`
847
else
848
echo "PASS"
849
echo " PASSED" >>$strfile
850
851
sleep 5
852
./waitjobs.sh >>$strfile
853
854
echo $ac_n "Verifying that history still exists: $ac_c"
855
856
echo " ls -l $BASE/spool" >>$strfile
857
count=`ls -1 $BASE/spool | wc -l`
858
if test $count = 1; then
859
echo "FAIL (job control files not present)"
860
ls -l $BASE/spool
861
echo " FAILED (job control files not present)" >>$strfile
862
ls -l $BASE/spool >>$strfile
863
fail=`expr $fail + 1`
864
else
865
echo "PASS"
866
echo " PASSED" >>$strfile
867
868
echo $ac_n "Waiting for job history to expire: $ac_c"
869
echo "" >>$strfile
870
echo " sleep 35" >>$strfile
871
sleep 35
872
873
echo " lpstat" >>$strfile
874
$runcups ../systemv/lpstat 2>&1 >>$strfile
875
876
echo " ls -l $BASE/spool" >>$strfile
877
count=`ls -1 $BASE/spool | wc -l`
878
if test $count != 1; then
879
echo "FAIL (job control files still present)"
880
ls -l $BASE/spool
881
echo " FAILED (job control files still present)" >>$strfile
882
ls -l $BASE/spool >>$strfile
883
fail=`expr $fail + 1`
884
else
885
echo "PASS"
886
echo " PASSED" >>$strfile
887
fi
888
fi
889
fi
890
891
892
#
893
# Perform job history test with cupsd restart...
894
#
895
896
echo $ac_n "Starting history test with cupsd restart: $ac_c"
897
echo "" >>$strfile
898
echo "`date '+[%d/%b/%Y:%H:%M:%S %z]'` \"5.11-history-cupsd-restart\":" >>$strfile
899
900
echo " lp -d Test1 testfile.jpg" >>$strfile
901
902
$runcups ../systemv/lp -d Test1 ../examples/testfile.jpg 2>&1 >>$strfile
903
if test $? != 0; then
904
echo "FAIL (unable to queue test job)"
905
echo " FAILED" >>$strfile
906
fail=`expr $fail + 1`
907
else
908
echo "PASS"
909
echo " PASSED" >>$strfile
910
911
sleep 5
912
./waitjobs.sh >>$strfile
913
914
echo $ac_n "Verifying that history still exists: $ac_c"
915
916
echo " ls -l $BASE/spool" >>$strfile
917
count=`ls -1 $BASE/spool | wc -l`
918
if test $count = 1; then
919
echo "FAIL (job control files not present)"
920
ls -l $BASE/spool
921
echo " FAILED (job control files not present)" >>$strfile
922
ls -l $BASE/spool >>$strfile
923
fail=`expr $fail + 1`
924
else
925
echo "PASS"
926
echo " PASSED" >>$strfile
927
928
echo "Restarting cupsd:"
929
echo "" >>$strfile
930
kill $cupsd
931
wait $cupsd
932
933
echo " $runcups $VALGRIND ../scheduler/cupsd -c $BASE/cupsd.conf -f >>$BASE/log/debug_log 2>&1 &"
934
echo ""
935
936
$runcups $VALGRIND ../scheduler/cupsd -c $BASE/cupsd.conf -f >>$BASE/log/debug_log 2>&1 &
937
938
cupsd=$!
939
940
echo $ac_n "Waiting for job history to expire: $ac_c"
941
echo "" >>$strfile
942
echo " sleep 35" >>$strfile
943
sleep 35
944
945
echo " ls -l $BASE/spool" >>$strfile
946
count=`ls -1 $BASE/spool | wc -l`
947
if test $count != 1; then
948
echo "FAIL (job control files still present)"
949
ls -l $BASE/spool
950
echo " FAILED (job control files still present)" >>$strfile
951
ls -l $BASE/spool >>$strfile
952
fail=`expr $fail + 1`
953
else
954
echo "PASS"
955
echo " PASSED" >>$strfile
956
fi
957
fi
958
fi
959
960
961
#
962
# Stop the server...
963
#
964
965
echo " </pre>" >>$strfile
966
967
kill $cupsd
968
wait $cupsd
969
cupsdstatus=$?
970
971
#
972
# Verify counts...
973
#
974
975
echo "Test Summary"
976
echo ""
977
echo " <h1><a name='SUMMARY'>3 - Test Summary</a></h1>" >>$strfile
978
979
if test $cupsdstatus != 0; then
980
echo "FAIL: cupsd failed with exit status $cupsdstatus."
981
echo " <p>FAIL: cupsd failed with exit status $cupsdstatus.</p>" >>$strfile
982
fail=`expr $fail + 1`
983
else
984
echo "PASS: cupsd exited with no errors."
985
echo " <p>PASS: cupsd exited with no errors.</p>" >>$strfile
986
fi
987
988
# Job control files
989
count=`ls -1 $BASE/spool | wc -l`
990
count=`expr $count - 1`
991
if test $count != 0; then
992
echo "FAIL: $count job control files were not purged."
993
echo " <p>FAIL: $count job control files were not purged.</p>" >>$strfile
994
fail=`expr $fail + 1`
995
else
996
echo "PASS: All job control files purged."
997
echo " <p>PASS: All job control files purged.</p>" >>$strfile
998
fi
999
1000
# Pages printed on Test1 (within 1 page for timing-dependent cancel issues)
1001
count=`$GREP '^Test1 ' $BASE/log/page_log | awk 'BEGIN{count=0}{count=count+$7}END{print count}'`
1002
# expected numbers of pages from page ranges tests:
1003
# - 5 pages for the job with a lower limit undefined (-5)
1004
# - 4 pages for the job with a upper limit undefined (5-)
1005
expected=`expr $pjobs \* 2 + 34 + 5 + 4`
1006
expected2=`expr $expected + 2`
1007
if test $count -lt $expected -a $count -gt $expected2; then
1008
echo "FAIL: Printer 'Test1' produced $count page(s), expected $expected."
1009
echo " <p>FAIL: Printer 'Test1' produced $count page(s), expected $expected.</p>" >>$strfile
1010
fail=`expr $fail + 1`
1011
else
1012
echo "PASS: Printer 'Test1' correctly produced $count page(s)."
1013
echo " <p>PASS: Printer 'Test1' correctly produced $count page(s).</p>" >>$strfile
1014
fi
1015
1016
# Paged printed on Test2
1017
count=`$GREP '^Test2 ' $BASE/log/page_log | awk 'BEGIN{count=0}{count=count+$7}END{print count}'`
1018
expected=`expr $pjobs \* 2 + 3`
1019
if test $count != $expected; then
1020
echo "FAIL: Printer 'Test2' produced $count page(s), expected $expected."
1021
echo " <p>FAIL: Printer 'Test2' produced $count page(s), expected $expected.</p>" >>$strfile
1022
fail=`expr $fail + 1`
1023
else
1024
echo "PASS: Printer 'Test2' correctly produced $count page(s)."
1025
echo " <p>PASS: Printer 'Test2' correctly produced $count page(s).</p>" >>$strfile
1026
fi
1027
1028
# Paged printed on Test3
1029
count=`$GREP '^Test3 ' $BASE/log/page_log | awk 'BEGIN{count=0}{count=count+$7}END{print count}'`
1030
expected=2
1031
if test $count != $expected; then
1032
echo "FAIL: Printer 'Test3' produced $count page(s), expected $expected."
1033
echo " <p>FAIL: Printer 'Test3' produced $count page(s), expected $expected.</p>" >>$strfile
1034
fail=`expr $fail + 1`
1035
else
1036
echo "PASS: Printer 'Test3' correctly produced $count page(s)."
1037
echo " <p>PASS: Printer 'Test3' correctly produced $count page(s).</p>" >>$strfile
1038
fi
1039
1040
# Number of requests from 5.1-lpadmin.sh: cupsSNMP/IPPSupplies tests - total 5 in 'expected':
1041
# - 2 requests for creating a queue - CUPS-Get-PPD and CUPS-Add-Modify-Printer
1042
# - 1 request for setting cupsSNMP/IPPSupplies to True - CUPS-Add-Modify-Printer
1043
# - 1 request for setting cupsSNMP/IPPSupplies to False - CUPS-Add-Modify-Printer
1044
# - 1 request for deleting the queue - CUPS-Delete-Printer
1045
1046
# Number of requests related to undefined page range limits - total 4 in 'expected'
1047
# 2 requests (Create-Job, Send-Document) * number of jobs (2 - one for undefined
1048
# low limit, one for undefined upper limit)
1049
1050
# Requests logged
1051
count=`wc -l $BASE/log/access_log | awk '{print $1}'`
1052
expected=`expr 35 + 18 + 30 + $pjobs \* 8 + $pprinters \* $pjobs \* 4 + 2 + 2 + 5 + 4`
1053
if test $count != $expected; then
1054
echo "FAIL: $count requests logged, expected $expected."
1055
echo " <p>FAIL: $count requests logged, expected $expected.</p>" >>$strfile
1056
fail=`expr $fail + 1`
1057
else
1058
echo "PASS: $count requests logged."
1059
echo " <p>PASS: $count requests logged.</p>" >>$strfile
1060
fi
1061
1062
# Did CUPS-Get-Default get logged?
1063
if $GREP -q CUPS-Get-Default $BASE/log/access_log; then
1064
echo "FAIL: CUPS-Get-Default logged with 'AccessLogLevel actions'"
1065
echo " <p>FAIL: CUPS-Get-Default logged with 'AccessLogLevel actions'</p>" >>$strfile
1066
echo " <pre>" >>$strfile
1067
$GREP CUPS-Get-Default $BASE/log/access_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
1068
echo " </pre>" >>$strfile
1069
fail=`expr $fail + 1`
1070
else
1071
echo "PASS: CUPS-Get-Default not logged."
1072
echo " <p>PASS: CUPS-Get-Default not logged.</p>" >>$strfile
1073
fi
1074
1075
# Emergency log messages
1076
count=`$GREP '^X ' $BASE/log/error_log | wc -l | awk '{print $1}'`
1077
if test $count != 0; then
1078
echo "FAIL: $count emergency messages, expected 0."
1079
$GREP '^X ' $BASE/log/error_log
1080
echo " <p>FAIL: $count emergency messages, expected 0.</p>" >>$strfile
1081
echo " <pre>" >>$strfile
1082
$GREP '^X ' $BASE/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
1083
echo " </pre>" >>$strfile
1084
fail=`expr $fail + 1`
1085
else
1086
echo "PASS: $count emergency messages."
1087
echo " <p>PASS: $count emergency messages.</p>" >>$strfile
1088
fi
1089
1090
# Alert log messages
1091
count=`$GREP '^A ' $BASE/log/error_log | wc -l | awk '{print $1}'`
1092
if test $count != 0; then
1093
echo "FAIL: $count alert messages, expected 0."
1094
$GREP '^A ' $BASE/log/error_log
1095
echo " <p>FAIL: $count alert messages, expected 0.</p>" >>$strfile
1096
echo " <pre>" >>$strfile
1097
$GREP '^A ' $BASE/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
1098
echo " </pre>" >>$strfile
1099
fail=`expr $fail + 1`
1100
else
1101
echo "PASS: $count alert messages."
1102
echo " <p>PASS: $count alert messages.</p>" >>$strfile
1103
fi
1104
1105
# Critical log messages
1106
count=`$GREP '^C ' $BASE/log/error_log | wc -l | awk '{print $1}'`
1107
if test $count != 0; then
1108
echo "FAIL: $count critical messages, expected 0."
1109
$GREP '^C ' $BASE/log/error_log
1110
echo " <p>FAIL: $count critical messages, expected 0.</p>" >>$strfile
1111
echo " <pre>" >>$strfile
1112
$GREP '^C ' $BASE/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
1113
echo " </pre>" >>$strfile
1114
fail=`expr $fail + 1`
1115
else
1116
echo "PASS: $count critical messages."
1117
echo " <p>PASS: $count critical messages.</p>" >>$strfile
1118
fi
1119
1120
# Error log messages
1121
count=`$GREP '^E ' $BASE/log/error_log | $GREP -v 'Unknown default SystemGroup' | wc -l | awk '{print $1}'`
1122
if test $count != 33; then
1123
echo "FAIL: $count error messages, expected 33."
1124
$GREP '^E ' $BASE/log/error_log
1125
echo " <p>FAIL: $count error messages, expected 33.</p>" >>$strfile
1126
echo " <pre>" >>$strfile
1127
$GREP '^E ' $BASE/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
1128
echo " </pre>" >>$strfile
1129
fail=`expr $fail + 1`
1130
else
1131
echo "PASS: $count error messages."
1132
echo " <p>PASS: $count error messages.</p>" >>$strfile
1133
fi
1134
1135
# Warning log messages
1136
count=`$GREP '^W ' $BASE/log/error_log | $GREP -v CreateProfile | $GREP -v 'libusb error' | $GREP -v ColorManager | $GREP -v 'Avahi client failed' | wc -l | awk '{print $1}'`
1137
if test $count != 14; then
1138
echo "FAIL: $count warning messages, expected 14."
1139
$GREP '^W ' $BASE/log/error_log
1140
echo " <p>FAIL: $count warning messages, expected 14.</p>" >>$strfile
1141
echo " <pre>" >>$strfile
1142
$GREP '^W ' $BASE/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
1143
echo " </pre>" >>$strfile
1144
fail=`expr $fail + 1`
1145
else
1146
echo "PASS: $count warning messages."
1147
echo " <p>PASS: $count warning messages.</p>" >>$strfile
1148
fi
1149
1150
# Notice log messages
1151
count=`$GREP '^N ' $BASE/log/error_log | wc -l | awk '{print $1}'`
1152
if test $count != 0; then
1153
echo "FAIL: $count notice messages, expected 0."
1154
$GREP '^N ' $BASE/log/error_log
1155
echo " <p>FAIL: $count notice messages, expected 0.</p>" >>$strfile
1156
echo " <pre>" >>$strfile
1157
$GREP '^N ' $BASE/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
1158
echo " </pre>" >>$strfile
1159
fail=`expr $fail + 1`
1160
else
1161
echo "PASS: $count notice messages."
1162
echo " <p>PASS: $count notice messages.</p>" >>$strfile
1163
fi
1164
1165
# Info log messages
1166
count=`$GREP '^I ' $BASE/log/error_log | wc -l | awk '{print $1}'`
1167
if test $count = 0; then
1168
echo "FAIL: $count info messages, expected more than 0."
1169
echo " <p>FAIL: $count info messages, expected more than 0.</p>" >>$strfile
1170
fail=`expr $fail + 1`
1171
else
1172
echo "PASS: $count info messages."
1173
echo " <p>PASS: $count info messages.</p>" >>$strfile
1174
fi
1175
1176
# Debug log messages
1177
count=`$GREP '^D ' $BASE/log/error_log | wc -l | awk '{print $1}'`
1178
if test $count = 0; then
1179
echo "FAIL: $count debug messages, expected more than 0."
1180
echo " <p>FAIL: $count debug messages, expected more than 0.</p>" >>$strfile
1181
fail=`expr $fail + 1`
1182
else
1183
echo "PASS: $count debug messages."
1184
echo " <p>PASS: $count debug messages.</p>" >>$strfile
1185
fi
1186
1187
# Debug2 log messages
1188
count=`$GREP '^d ' $BASE/log/error_log | wc -l | awk '{print $1}'`
1189
if test $count = 0 -a $loglevel = debug2; then
1190
echo "FAIL: $count debug2 messages, expected more than 0."
1191
echo " <p>FAIL: $count debug2 messages, expected more than 0.</p>" >>$strfile
1192
fail=`expr $fail + 1`
1193
elif test $count != 0 -a $loglevel = debug; then
1194
echo "FAIL: $count debug2 messages, expected 0."
1195
echo " <p>FAIL: $count debug2 messages, expected 0.</p>" >>$strfile
1196
fail=`expr $fail + 1`
1197
else
1198
echo "PASS: $count debug2 messages."
1199
echo " <p>PASS: $count debug2 messages.</p>" >>$strfile
1200
fi
1201
1202
#
1203
# Log files...
1204
#
1205
1206
echo " <h1><a name='LOGS'>4 - Log Files</a></h1>" >>$strfile
1207
1208
for file in $BASE/log/*_log; do
1209
baselog=`basename $file`
1210
1211
echo " <h2><a name=\"$baselog\">$baselog</a></h2>" >>$strfile
1212
case $baselog in
1213
error_log)
1214
echo " <blockquote>Note: debug2 messages have been filtered out of the HTML report.</blockquote>" >>$strfile
1215
echo " <pre>" >>$strfile
1216
$GREP -v '^d' $BASE/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
1217
echo " </pre>" >>$strfile
1218
;;
1219
1220
*)
1221
echo " <pre>" >>$strfile
1222
sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' $file >>$strfile
1223
echo " </pre>" >>$strfile
1224
;;
1225
esac
1226
done
1227
1228
#
1229
# Format the reports and tell the user where to find them...
1230
#
1231
1232
cat str-trailer.html >>$strfile
1233
1234
echo ""
1235
for file in $BASE/log/*_log; do
1236
baselog=`basename $file`
1237
cp $file $baselog-$date-$user
1238
echo "Copied log file \"$baselog-$date-$user\" to test directory."
1239
done
1240
cp $strfile .
1241
echo "Copied report file \"cups-str-$date-$user.html\" to test directory."
1242
1243
# Clean out old failure log files after 1 week...
1244
find . -name \*_log-\*-$user -a -mtime +7 -print -exec rm -f '{}' \; | awk '{print "Removed old log file \"" substr($1,3) "\" from test directory."}'
1245
find . -name cups-str-\*-$user.html -a -mtime +7 -print -exec rm -f '{}' \; | awk '{print "Removed old report file \"" $1 "\" from test directory."}'
1246
1247
echo ""
1248
1249
if test $fail != 0; then
1250
echo "$fail tests failed."
1251
exit 1
1252
else
1253
echo "All tests were successful."
1254
fi
1255
1256