588c308f9c87520030941e23e93644e5eac25d2e
[ab/samba.git/.git] / testprogs / blackbox / test_cifsdd.sh
1 #!/bin/sh
2
3 # Basic script to make sure that cifsdd can do both local and remote I/O.
4
5 if [ $# -lt 4 ]; then
6 cat <<EOF
7 Usage: test_cifsdd.sh SERVER USERNAME PASSWORD DOMAIN
8 EOF
9 exit 1;
10 fi
11
12 SERVER=$1
13 USERNAME=$2
14 PASSWORD=$3
15 DOMAIN=$4
16
17 DD=bin/cifsdd
18
19 SHARE=tmp
20 DEBUGLEVEL=1
21
22 failed=0
23
24 testit() {
25         name="$1"
26         shift
27         cmdline="$*"
28         echo "test: $name"
29         $cmdline
30         status=$?
31         if [ x$status = x0 ]; then
32                 echo "success: $name"
33         else
34                 echo "failure: $name"
35                 failed=`expr $failed + 1`
36         fi
37         return $status
38 }
39
40 runcopy() {
41         message="$1"
42         shift
43         
44         testit "$message" $VALGRIND $DD $CONFIGURATION --debuglevel=$DEBUGLEVEL -W "$DOMAIN" -U "$USERNAME"%"$PASSWORD" \
45             "$@"
46 }
47
48 compare() {
49     testit "$1" cmp "$2" "$3"
50 }
51
52 sourcepath=tempfile.src.$$
53 destpath=tempfile.dst.$$
54
55 # Create a source file with arbitrary contents
56 dd if=$DD of=$sourcepath bs=1024 count=50 > /dev/null
57
58 ls -l $sourcepath
59
60 for bs in 512 4k 48k ; do
61
62 echo "Testing $bs block size ..."
63
64 # Check whether we can do local IO
65 runcopy "Testing local -> local copy" if=$sourcepath of=$destpath bs=$bs
66 compare "Checking local differences" $sourcepath $destpath
67
68 # Check whether we can do a round trip
69 runcopy "Testing local -> remote copy" \
70             if=$sourcepath of=//$SERVER/$SHARE/$sourcepath bs=$bs 
71 runcopy "Testing remote -> local copy" \
72             if=//$SERVER/$SHARE/$sourcepath of=$destpath bs=$bs 
73 compare "Checking differences" $sourcepath $destpath 
74
75 # Check that copying within the remote server works
76 runcopy "Testing local -> remote copy" \
77             if=//$SERVER/$SHARE/$sourcepath of=//$SERVER/$SHARE/$sourcepath bs=$bs
78 runcopy "Testing remote -> remote copy" \
79             if=//$SERVER/$SHARE/$sourcepath of=//$SERVER/$SHARE/$destpath bs=$bs 
80 runcopy "Testing remote -> local copy" \
81             if=//$SERVER/$SHARE/$destpath of=$destpath bs=$bs
82 compare "Checking differences" $sourcepath $destpath
83
84 done
85
86 rm -f $sourcepath $destpath
87
88 exit $failed