1#!/bin/sh
2#
3# Blackbox test for share with preserve case options
4#
5# https://bugzilla.samba.org/show_bug.cgi?id=10650
6
7if [ $# -lt 6 ]; then
8cat <<EOF
9Usage: test_preserve_case.sh SERVER DOMAIN USERNAME PASSWORD PREFIX SMBCLIENT
10EOF
11exit 1;
12fi
13
14SERVER=$1
15DOMAIN=$2
16USERNAME=$3
17PASSWORD=$4
18PREFIX=$5
19smbclient=$6
20if [ $# -gt 6 ]; then
21	PROTOCOL_LIST=$7
22	shift 7
23else
24	PROTOCOL_LIST="NT1 SMB2 SMB3"
25	shift 6
26fi
27failed=0
28
29incdir=`dirname $0`/../../../testprogs/blackbox
30. $incdir/subunit.sh
31
32test_smbclient() {
33	name="$1"
34	share="$2"
35	cmd="$3"
36	shift
37	shift
38	subunit_start_test "$name"
39	output=$($VALGRIND $smbclient //$SERVER/$share -c "$cmd" $@ 2>&1)
40	status=$?
41	if [ x$status = x0 ]; then
42		subunit_pass_test "$name"
43	else
44		echo "$output" | subunit_fail_test "$name"
45	fi
46	return $status
47}
48
49SHARE="lowercase"
50
51for PROTOCOL in $PROTOCOL_LIST; do
52	test_smbclient "Test lowercase ls 1 ($PROTOCOL)" $SHARE "ls 1" -U$USERNAME%$PASSWORD -m$PROTOCOL || failed=`expr $failed + 1`
53	test_smbclient "Test lowercase get 1 ($PROTOCOL)" $SHARE "get 1 LOCAL_1" -U$USERNAME%$PASSWORD -m$PROTOCOL || failed=`expr $failed + 1`
54	rm -f LOCAL_1
55
56	test_smbclient "Test lowercase ls A ($PROTOCOL)"  $SHARE "ls A" -U$USERNAME%$PASSWORD -m$PROTOCOL || failed=`expr $failed + 1`
57	test_smbclient "Test lowercase get A ($PROTOCOL)" $SHARE "get A LOCAL_A" -U$USERNAME%$PASSWORD -m$PROTOCOL || failed=`expr $failed + 1`
58	rm -f LOCAL_A
59
60	test_smbclient "Test lowercase ls z ($PROTOCOL)"  $SHARE "ls z" -U$USERNAME%$PASSWORD -m$PROTOCOL || failed=`expr $failed + 1`
61	test_smbclient "Test lowercase get z ($PROTOCOL)" $SHARE "get z LOCAL_Z" -U$USERNAME%$PASSWORD -m$PROTOCOL || failed=`expr $failed + 1`
62	rm -f LOCAL_Z
63done
64
65SHARE="lowercase-30000"
66
67for PROTOCOL in $PROTOCOL_LIST; do
68	test_smbclient "Test lowercase ls 25839 ($PROTOCOL)" $SHARE "ls 25839" -U$USERNAME%$PASSWORD -m$PROTOCOL || failed=`expr $failed + 1`
69
70	test_smbclient "Test lowercase ls 1 ($PROTOCOL)" $SHARE "ls 1" -U$USERNAME%$PASSWORD -m$PROTOCOL || failed=`expr $failed + 1`
71	test_smbclient "Test lowercase get 1 ($PROTOCOL)" $SHARE "get 1 LOCAL_1" -U$USERNAME%$PASSWORD -m$PROTOCOL || failed=`expr $failed + 1`
72	rm -f LOCAL_1
73
74	test_smbclient "Test lowercase ls A ($PROTOCOL)"  $SHARE "ls A" -U$USERNAME%$PASSWORD -m$PROTOCOL || failed=`expr $failed + 1`
75	test_smbclient "Test lowercase get A ($PROTOCOL)" $SHARE "get A LOCAL_A" -U$USERNAME%$PASSWORD -m$PROTOCOL || failed=`expr $failed + 1`
76	rm -f LOCAL_A
77
78	test_smbclient "Test lowercase ls z ($PROTOCOL)"  $SHARE "ls z" -U$USERNAME%$PASSWORD -m$PROTOCOL || failed=`expr $failed + 1`
79	test_smbclient "Test lowercase get z ($PROTOCOL)" $SHARE "get z LOCAL_Z" -U$USERNAME%$PASSWORD -m$PROTOCOL || failed=`expr $failed + 1`
80	rm -f LOCAL_Z
81done
82
83exit $failed
84