r20746: Don't report each individual test in test_smbclient as a single testsuite.
[ira/wip.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
41
42 runcopy() {
43         message="$1"
44         shift
45         
46         testit "$message" $VALGRIND $DD $CONFIGURATION --debuglevel=$DEBUGLEVEL -W "$DOMAIN" -U "$USERNAME"%"$PASSWORD" \
47             "$@"
48 }
49
50 compare() {
51     tesit "$1" cmp "$2" "$3"
52 }
53
54 sourcepath=tempfile.src.$$
55 destpath=tempfile.dst.$$
56
57 # Create a source file with arbitrary contents
58 dd if=$DD of=$sourcepath bs=1024 count=50 > /dev/null
59
60 ls -l $sourcepath
61
62 for bs in 512 4k 48k ; do
63
64 echo "Testing $bs block size ..."
65
66 # Check whether we can do local IO
67 runcopy "Testing local -> local copy" if=$sourcepath of=$destpath bs=$bs
68 compare "Checking local differences" $sourcepath $destpath
69
70 # Check whether we can do a round trip
71 runcopy "Testing local -> remote copy" \
72             if=$sourcepath of=//$SERVER/$SHARE/$sourcepath bs=$bs 
73 runcopy "Testing remote -> local copy" \
74             if=//$SERVER/$SHARE/$sourcepath of=$destpath bs=$bs 
75 compare "Checking differences" $sourcepath $destpath 
76
77 # Check that copying within the remote server works
78 runcopy "Testing local -> remote copy" \
79             if=//$SERVER/$SHARE/$sourcepath of=//$SERVER/$SHARE/$sourcepath bs=$bs
80 runcopy "Testing remote -> remote copy" \
81             if=//$SERVER/$SHARE/$sourcepath of=//$SERVER/$SHARE/$destpath bs=$bs 
82 runcopy "Testing remote -> local copy" \
83             if=//$SERVER/$SHARE/$destpath of=$destpath bs=$bs
84 compare "Checking differences" $sourcepath $destpath
85
86 done
87
88 rm -f $sourcepath $destpath
89
90 exit $failed