1#!/bin/sh
2#
3# Test the lpr command.
4#
5# Copyright © 2007-2019 by Apple Inc.
6# Copyright © 1997-2005 by Easy Software Products, all rights reserved.
7#
8# Licensed under Apache License v2.0.  See the file "LICENSE" for more
9# information.
10#
11
12echo "LPR Default Test"
13echo ""
14echo "    lpr testfile.pdf"
15$runcups $VALGRIND ../berkeley/lpr ../examples/testfile.pdf 2>&1
16if test $? != 0; then
17	echo "    FAILED"
18	exit 1
19else
20	echo "    PASSED"
21fi
22echo ""
23
24echo "LPR Destination Test"
25echo ""
26echo "    lpr -P Test3 -o fit-to-page testfile.jpg"
27$runcups $VALGRIND ../berkeley/lpr -P Test3 -o fit-to-page ../examples/testfile.jpg 2>&1
28if test $? != 0; then
29	echo "    FAILED"
30	exit 1
31else
32	echo "    PASSED"
33fi
34echo ""
35
36echo "LPR Options Test"
37echo ""
38echo "    lpr -P Test1 -o number-up=4 -o job-sheets=standard,none testfile.pdf"
39$runcups $VALGRIND ../berkeley/lpr -P Test1 -o number-up=4 -o job-sheets=standard,none ../examples/testfile.pdf 2>&1
40if test $? != 0; then
41	echo "    FAILED"
42	exit 1
43else
44	echo "    PASSED"
45fi
46echo ""
47
48echo "LPR Flood Test ($1 times in parallel)"
49echo ""
50echo "    lpr -P Test1 testfile.jpg"
51echo "    lpr -P Test2 testfile.jpg"
52i=0
53pids=""
54while test $i -lt $1; do
55	j=1
56	while test $j -le $2; do
57		$runcups $VALGRIND ../berkeley/lpr -P test-$j ../examples/testfile.jpg 2>&1
58		j=`expr $j + 1`
59	done
60
61	$runcups $VALGRIND ../berkeley/lpr -P Test1 ../examples/testfile.jpg 2>&1 &
62	pids="$pids $!"
63	$runcups $VALGRIND ../berkeley/lpr -P Test2 ../examples/testfile.jpg 2>&1 &
64	pids="$pids $!"
65
66	i=`expr $i + 1`
67done
68wait $pids
69if test $? != 0; then
70	echo "    FAILED"
71	exit 1
72else
73	echo "    PASSED"
74fi
75echo ""
76
77./waitjobs.sh
78