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