| 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 | . `dirname $0`/../../../testprogs/blackbox/subunit.sh
|
|---|
| 18 |
|
|---|
| 19 | samba4bindir="$BUILDDIR/bin"
|
|---|
| 20 | DD="$samba4bindir/cifsdd$EXEEXT"
|
|---|
| 21 |
|
|---|
| 22 | SHARE=tmp
|
|---|
| 23 | DEBUGLEVEL=1
|
|---|
| 24 |
|
|---|
| 25 | runcopy() {
|
|---|
| 26 | message="$1"
|
|---|
| 27 | shift
|
|---|
| 28 |
|
|---|
| 29 | testit "$message" $VALGRIND $DD $CONFIGURATION --debuglevel=$DEBUGLEVEL -W "$DOMAIN" -U "$USERNAME"%"$PASSWORD" \
|
|---|
| 30 | "$@" || failed=`expr $failed + 1`
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | compare() {
|
|---|
| 34 | testit "$1" cmp "$2" "$3" || failed=`expr $failed + 1`
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | sourcepath=tempfile.src.$$
|
|---|
| 38 | destpath=tempfile.dst.$$
|
|---|
| 39 |
|
|---|
| 40 | # Create a source file with arbitrary contents
|
|---|
| 41 | dd if=$DD of=$sourcepath bs=1024 count=50 > /dev/null
|
|---|
| 42 |
|
|---|
| 43 | ls -l $sourcepath
|
|---|
| 44 |
|
|---|
| 45 | for bs in 512 4k 48k ; do
|
|---|
| 46 |
|
|---|
| 47 | echo "Testing $bs block size ..."
|
|---|
| 48 |
|
|---|
| 49 | # Check whether we can do local IO
|
|---|
| 50 | runcopy "Testing local -> local copy" if=$sourcepath of=$destpath bs=$bs
|
|---|
| 51 | compare "Checking local differences" $sourcepath $destpath
|
|---|
| 52 |
|
|---|
| 53 | # Check whether we can do a round trip
|
|---|
| 54 | runcopy "Testing local -> remote copy" \
|
|---|
| 55 | if=$sourcepath of=//$SERVER/$SHARE/$sourcepath bs=$bs
|
|---|
| 56 | runcopy "Testing remote -> local copy" \
|
|---|
| 57 | if=//$SERVER/$SHARE/$sourcepath of=$destpath bs=$bs
|
|---|
| 58 | compare "Checking differences" $sourcepath $destpath
|
|---|
| 59 |
|
|---|
| 60 | # Check that copying within the remote server works
|
|---|
| 61 | runcopy "Testing local -> remote copy" \
|
|---|
| 62 | if=//$SERVER/$SHARE/$sourcepath of=//$SERVER/$SHARE/$sourcepath bs=$bs
|
|---|
| 63 | runcopy "Testing remote -> remote copy" \
|
|---|
| 64 | if=//$SERVER/$SHARE/$sourcepath of=//$SERVER/$SHARE/$destpath bs=$bs
|
|---|
| 65 | runcopy "Testing remote -> local copy" \
|
|---|
| 66 | if=//$SERVER/$SHARE/$destpath of=$destpath bs=$bs
|
|---|
| 67 | compare "Checking differences" $sourcepath $destpath
|
|---|
| 68 |
|
|---|
| 69 | done
|
|---|
| 70 |
|
|---|
| 71 | rm -f $sourcepath $destpath
|
|---|
| 72 |
|
|---|
| 73 | exit $failed
|
|---|