3 # Blackbox test for smbget.
8 Usage: test_smbget SERVER SERVER_IP DOMAIN USERNAME PASSWORD WORKDIR SMBGET
19 SMBGET="$VALGRIND ${7}"
21 TMPDIR="$SRCDIR_ABS/st/tmp"
23 incdir=`dirname $0`/../../../testprogs/blackbox
29 dd if=/dev/urandom bs=1024 count=128 of=testfile
32 dd if=/dev/urandom bs=1024 count=128 of=dir1/testfile1
34 dd if=/dev/urandom bs=1024 count=128 of=dir2/testfile2
40 rm -rf dir1 dir2 testfile
42 rm -rf dir1 dir2 testfile
46 test_singlefile_guest()
48 [ -e testfile ] && rm testfile
49 echo "$SMBGET -v -a smb://$SERVER_IP/smbget/testfile"
50 $SMBGET -v -a smb://$SERVER_IP/smbget/testfile
52 echo 'ERROR: RC does not match, expected: 0'
55 cmp --silent $WORKDIR/testfile ./testfile
57 echo 'ERROR: file content does not match'
65 [ -e testfile ] && rm testfile
66 $SMBGET -v -U$USERNAME%$PASSWORD smb://$SERVER_IP/smbget/testfile
68 echo 'ERROR: RC does not match, expected: 0'
71 cmp --silent $WORKDIR/testfile ./testfile
73 echo 'ERROR: file content does not match'
79 test_singlefile_smburl()
81 [ -e testfile ] && rm testfile
82 $SMBGET -w $DOMAIN smb://$USERNAME:$PASSWORD@$SERVER_IP/smbget/testfile
84 echo 'ERROR: RC does not match, expected: 0'
87 cmp --silent $WORKDIR/testfile ./testfile
89 echo 'ERROR: file content does not match'
95 test_singlefile_rcfile()
97 [ -e testfile ] && rm testfile
98 echo "user $USERNAME%$PASSWORD" > $TMPDIR/rcfile
99 $SMBGET -vn -f $TMPDIR/rcfile smb://$SERVER_IP/smbget/testfile
102 if [ $rc -ne 0 ]; then
103 echo 'ERROR: RC does not match, expected: 0'
106 cmp --silent $WORKDIR/testfile ./testfile
107 if [ $? -ne 0 ]; then
108 echo 'ERROR: file content does not match'
116 [ -e testfile ] && rm testfile
117 [ -d dir1 ] && rm -rf dir1
118 [ -d dir2 ] && rm -rf dir2
119 $SMBGET -v -R -U$USERNAME%$PASSWORD smb://$SERVER_IP/smbget/
120 if [ $? -ne 0 ]; then
121 echo 'ERROR: RC does not match, expected: 0'
125 cmp --silent $WORKDIR/testfile ./testfile && \
126 cmp --silent $WORKDIR/dir1/testfile1 ./dir1/testfile1 && \
127 cmp --silent $WORKDIR/dir2/testfile2 ./dir2/testfile2
128 if [ $? -ne 0 ]; then
129 echo 'ERROR: file content does not match'
138 [ -e testfile ] && rm testfile
139 cp $WORKDIR/testfile .
140 truncate -s 1024 testfile
141 $SMBGET -v -r -U$USERNAME%$PASSWORD smb://$SERVER_IP/smbget/testfile
142 if [ $? -ne 0 ]; then
143 echo 'ERROR: RC does not match, expected: 0'
147 cmp --silent $WORKDIR/testfile ./testfile
148 if [ $? -ne 0 ]; then
149 echo 'ERROR: file content does not match'
156 test_resume_modified()
158 dd if=/dev/urandom bs=1024 count=2 of=testfile
159 $SMBGET -v -r -U$USERNAME%$PASSWORD smb://$SERVER_IP/smbget/testfile
160 if [ $? -ne 1 ]; then
161 echo 'ERROR: RC does not match, expected: 1'
170 [ -e testfile ] && rm testfile
171 $SMBGET -v -U$USERNAME%$PASSWORD smb://$SERVER_IP/smbget/testfile
172 if [ $? -ne 0 ]; then
173 echo 'ERROR: RC does not match, expected: 0'
177 # secondary download should pass
178 $SMBGET -v -u -U$USERNAME%$PASSWORD smb://$SERVER_IP/smbget/testfile
179 if [ $? -ne 0 ]; then
180 echo 'ERROR: RC does not match, expected: 0'
184 echo "modified" >> testfile
185 # touch source to trigger new download
187 touch -m $WORKDIR/testfile
188 $SMBGET -v -u -U$USERNAME%$PASSWORD smb://$SERVER_IP/smbget/testfile
189 if [ $? -ne 0 ]; then
190 echo 'ERROR: RC does not match, expected: 0'
194 cmp --silent $WORKDIR/testfile ./testfile
195 if [ $? -ne 0 ]; then
196 echo 'ERROR: file content does not match'
208 testit "download single file as guest" test_singlefile_guest \
209 || failed=`expr $failed + 1`
211 testit "download single file with -U" test_singlefile_U \
212 || failed=`expr $failed + 1`
214 testit "download single file with smb URL" test_singlefile_smburl \
215 || failed=`expr $failed + 1`
217 testit "download single file with rcfile" test_singlefile_rcfile \
218 || failed=`expr $failed + 1`
220 testit "recursive download" test_recursive_U \
221 || failed=`expr $failed + 1`
223 testit "resume download" test_resume \
224 || failed=`expr $failed + 1`
226 testit "resume download (modified file)" test_resume_modified \
227 || failed=`expr $failed + 1`
229 testit "update" test_update \
230 || failed=`expr $failed + 1`