s3-selftest Add a test for 'message command'
authorAndrew Bartlett <abartlet@samba.org>
Thu, 9 Jun 2011 05:22:19 +0000 (15:22 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 9 Jun 2011 10:40:09 +0000 (12:40 +0200)
This also provides us a way to test that the -n option to smbclient
works, as that becomes part of the filename.

Andrew Bartlett

selftest/target/Samba3.pm
source3/script/tests/test_smbclient_s3.sh

index 2f65be4ae3ce108c3f26c5db51c11829255b71ee..595780aa1456cddcec1c2b7907ad15e3b42ef19a 100644 (file)
@@ -866,6 +866,8 @@ sub provision($$$$$$$)
 
         resolv:host file = $dns_host_file
 
+        message command = mv %s $shrdir/message.%m
+
        # Begin extra options
        $extra_options
        # End extra options
index 0395f3e12c6e4f947a807e9597cd52a8eb8e43e7..60c3610ee84ca36c410516508df5b62a231fd735 100755 (executable)
@@ -218,6 +218,7 @@ EOF
     if [ $ret != 0 ] ; then
        echo "$out"
        echo "failed writing into read-only directory with error $ret"
+
        false
        return
     fi
@@ -235,6 +236,49 @@ EOF
     fi
 }
 
+
+# Test sending a message
+test_message()
+{
+    tmpfile=$PREFIX/message_in.$$
+
+    cat > $tmpfile <<EOF
+Test message from pid $$
+EOF
+
+    cmd='$SMBCLIENT "$@" -U$USERNAME%$PASSWORD -M $SERVER -p 139 $ADDARGS -n msgtest < $tmpfile 2>&1'
+    eval echo "$cmd"
+    out=`eval $cmd`
+    ret=$?
+
+    if [ $ret != 0 ] ; then
+       echo "$out"
+       echo "failed sending message to $SERVER with error $ret"
+       false
+       rm -f $tmpfile
+       return
+    fi
+
+    cmd='$SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmpguest -p 139 $ADDARGS -c "get message.msgtest $PREFIX/message_out.$$" 2>&1'
+    eval echo "$cmd"
+    out=`eval $cmd`
+    ret=$?
+
+    if [ $ret != 0 ] ; then
+       echo "$out"
+       echo "failed getting sent message from $SERVER with error $ret"
+       false
+       return
+    fi
+
+    if [ cmp $PREFIX/message_out.$$ $tmpfile != 0 ] ; then
+       echo "failed comparison of message from $SERVER"
+       false
+       return
+    fi
+    true
+}
+
 # Test reading an owner-only file (logon as guest) fails.
 test_owner_only_file()
 {
@@ -444,6 +488,10 @@ testit "ccache access works for smbclient" \
     test_ccache_access || \
     failed=`expr $failed + 1`
 
+testit "sending a message to the remote server" \
+    test_message || \
+    failed=`expr $failed + 1`
+
 testit "rm -rf $LOGDIR" \
     rm -rf $LOGDIR || \
     failed=`expr $failed + 1`