summaryrefslogtreecommitdiffstats
path: root/source3/script/tests/test_printing_var_exp.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 17:20:00 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 17:20:00 +0000
commit8daa83a594a2e98f39d764422bfbdbc62c9efd44 (patch)
tree4099e8021376c7d8c05bdf8503093d80e9c7bad0 /source3/script/tests/test_printing_var_exp.sh
parentInitial commit. (diff)
downloadsamba-8daa83a594a2e98f39d764422bfbdbc62c9efd44.tar.xz
samba-8daa83a594a2e98f39d764422bfbdbc62c9efd44.zip
Adding upstream version 2:4.20.0+dfsg.upstream/2%4.20.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'source3/script/tests/test_printing_var_exp.sh')
-rwxr-xr-xsource3/script/tests/test_printing_var_exp.sh93
1 files changed, 93 insertions, 0 deletions
diff --git a/source3/script/tests/test_printing_var_exp.sh b/source3/script/tests/test_printing_var_exp.sh
new file mode 100755
index 0000000..5729344
--- /dev/null
+++ b/source3/script/tests/test_printing_var_exp.sh
@@ -0,0 +1,93 @@
+#!/bin/sh
+
+if [ $# -lt 4 ]; then
+ cat <<EOF
+Usage: test_printing_var_exp.sh SERVER SERVER_IP DOMAIN USERNAME PASSWORD
+EOF
+ exit 1
+fi
+
+SERVER="$1"
+SERVER_IP="$2"
+DOMAIN="$3"
+USERNAME="$4"
+PASSWORD="$5"
+shift 5
+ADDARGS="$@"
+
+incdir=$(dirname $0)/../../../testprogs/blackbox
+. $incdir/subunit.sh
+. $incdir/common_test_fns.inc
+
+smbclient="$BINDIR/smbclient"
+rpcclient="$BINDIR/rpcclient"
+
+test_var_expansion()
+{
+ logfile="${SELFTEST_TMPDIR}/${USER}_printing_var_exp.log"
+
+ $smbclient -U $DOMAIN/$USERNAME%$PASSWORD \
+ //$SERVER_IP/print_var_exp \
+ -c "print $SRCDIR/testdata/printing/example.ps"
+ if [ $? -ne 0 ]; then
+ rm -f "$logfile"
+ return 1
+ fi
+ cat "$logfile"
+
+ grep "Windows user: $USERNAME" "$logfile"
+ if [ $? -ne 0 ]; then
+ rm -f "$logfile"
+ return 1
+ fi
+ grep "UNIX user: $USERNAME" "$logfile"
+ if [ $? -ne 0 ]; then
+ rm -f "$logfile"
+ return 1
+ fi
+ grep "Domain: $DOMAIN" "$logfile"
+ if [ $? -ne 0 ]; then
+ rm -f "$logfile"
+ return 1
+ fi
+
+ rm -f "$logfile"
+ return 0
+}
+
+test_empty_queue()
+{
+ # Try several times until the bgqd daemon updates the print queue status
+ tries="3"
+ for i in $(seq 1 $tries); do
+ echo "Try $i"
+ JOBS=$($rpcclient ncacn_np:$SERVER_IP \
+ -U $DOMAIN/$USERNAME%$PASSWORD \
+ -c "enumjobs print_var_exp 2")
+ if [ $? -ne 0 ]; then
+ return 1
+ fi
+ if [[ -z $JOBS ]]; then
+ return 0
+ fi
+ if [[ $i -gt $tries ]]; then
+ echo "Print queue not empty after $tries seconds:"
+ echo $JOBS
+ echo "Queue must be empty before leaving this test or" \
+ "following ones may fail."
+ return 1
+ fi
+ sleep 1
+ done
+ return 0
+}
+
+testit "Test variable expansion for '%U', '%u' and '%D'" \
+ test_var_expansion ||
+ failed=$(expr $failed + 1)
+
+testit "Test queue is empty" \
+ test_empty_queue ||
+ failed=$(expr $failed + 1)
+
+exit $failed