2006-06-05 00:36:52 +04:00
#!/bin/sh
2006-01-31 09:09:18 +03:00
# Basic script to make sure that cifsdd can do both local and remote I/O.
if [ $# -lt 4 ] ; then
cat <<EOF
Usage: test_cifsdd.sh SERVER USERNAME PASSWORD DOMAIN
EOF
exit 1;
fi
SERVER = $1
USERNAME = $2
PASSWORD = $3
DOMAIN = $4
DD = bin/cifsdd
SHARE = tmp
2006-09-22 19:14:53 +04:00
DEBUGLEVEL = 1
2006-01-31 09:09:18 +03:00
failed = 0
2007-01-14 04:39:34 +03:00
testit( ) {
name = " $1 "
shift
cmdline = " $* "
echo " test: $name "
$cmdline
status = $?
if [ x$status = x0 ] ; then
echo " success: $name "
else
echo " failure: $name "
failed = ` expr $failed + 1`
fi
return $status
2006-01-31 09:09:18 +03:00
}
runcopy( ) {
message = " $1 "
shift
2006-10-17 00:20:03 +04:00
testit " $message " $VALGRIND $DD $CONFIGURATION --debuglevel= $DEBUGLEVEL -W " $DOMAIN " -U " $USERNAME " %" $PASSWORD " \
2006-01-31 09:09:18 +03:00
" $@ "
}
compare( ) {
2007-01-25 15:39:13 +03:00
testit " $1 " cmp " $2 " " $3 "
2006-01-31 09:09:18 +03:00
}
sourcepath = tempfile.src.$$
destpath = tempfile.dst.$$
# Create a source file with arbitrary contents
2006-09-22 19:14:53 +04:00
dd if = $DD of = $sourcepath bs = 1024 count = 50 > /dev/null
ls -l $sourcepath
2006-01-31 09:09:18 +03:00
for bs in 512 4k 48k ; do
echo " Testing $bs block size ... "
# Check whether we can do local IO
2007-01-14 04:39:34 +03:00
runcopy "Testing local -> local copy" if = $sourcepath of = $destpath bs = $bs
compare "Checking local differences" $sourcepath $destpath
2006-01-31 09:09:18 +03:00
# Check whether we can do a round trip
runcopy "Testing local -> remote copy" \
2007-01-14 04:39:34 +03:00
if = $sourcepath of = //$SERVER /$SHARE /$sourcepath bs = $bs
2006-07-13 20:11:38 +04:00
runcopy "Testing remote -> local copy" \
2007-01-14 04:39:34 +03:00
if = //$SERVER /$SHARE /$sourcepath of = $destpath bs = $bs
compare "Checking differences" $sourcepath $destpath
2006-01-31 09:09:18 +03:00
# Check that copying within the remote server works
runcopy "Testing local -> remote copy" \
2007-01-14 04:39:34 +03:00
if = //$SERVER /$SHARE /$sourcepath of = //$SERVER /$SHARE /$sourcepath bs = $bs
2006-01-31 09:09:18 +03:00
runcopy "Testing remote -> remote copy" \
2007-01-14 04:39:34 +03:00
if = //$SERVER /$SHARE /$sourcepath of = //$SERVER /$SHARE /$destpath bs = $bs
2006-07-13 20:11:38 +04:00
runcopy "Testing remote -> local copy" \
2007-01-14 04:39:34 +03:00
if = //$SERVER /$SHARE /$destpath of = $destpath bs = $bs
compare "Checking differences" $sourcepath $destpath
2006-01-31 09:09:18 +03:00
done
rm -f $sourcepath $destpath
2007-01-14 04:39:34 +03:00
exit $failed