s3/script/tests: Test smbclient -E redirects output to stderr
authorNoel Power <noel.power@suse.com>
Mon, 23 May 2022 19:11:13 +0000 (20:11 +0100)
committerNoel Power <npower@samba.org>
Tue, 24 May 2022 09:33:31 +0000 (09:33 +0000)
Add new test to ensure smbclient is writing to stderr (with '-E')
Add knownfail for this test (will be removed when issue is fixed in
later commit)

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15075
Signed-off-by: Noel Power <noel.power@suse.com>
selftest/knownfail.d/smbclient-smb3
source3/script/tests/test_smbclient_s3.sh

index 119e93e479af8078a4639b19b84ac86fc47efc6b..4d884db50252a10dd37ee4dc4f3c6f3f5894694b 100644 (file)
@@ -1,4 +1,5 @@
 ^samba3.blackbox.smbclient_s3.SMB3.*.creating.a.bad.symlink.and.deleting.it
+^samba3.blackbox.smbclient_s3.*.smbclient output goes to stderr when -E is passed
 ^samba3.blackbox.acl_xattr.SMB3.nt_affects_posix
 ^samba3.blackbox.acl_xattr.SMB3.nt_affects_chown
 ^samba3.blackbox.acl_xattr.SMB3.nt_affects_chgrp
index 3da37e699e6ef3750ed969adeefcac50ed746f8a..fc608bdfc9b2208ddd8a730047748441f4fbb277 100755 (executable)
@@ -2043,6 +2043,47 @@ EOF
     return 0
 }
 
+test_smbclient_minus_e_stderr()
+{
+    cmd='$SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -c ls'
+    eval echo "$cmd"
+    out=`eval $cmd`
+    if [ $? != 0 ] ; then
+       echo "$out"
+       echo "command failed"
+       return 1
+    fi
+
+    # test smbclient 'ls' command output went to stdout
+    echo "$out" | grep "blocks available" >/dev/null 2>&1
+    if [ $? != 0 ] ; then
+       # didn't get output to stdout
+       echo "expected output was NOT output to stdout"
+       return 1
+    fi
+
+    # this time execute ls but redirect stdout alone to /dev/null
+    cmd='$SMBCLIENT -E "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -c "ls"  2>&1 > /dev/null'
+    eval echo "$cmd"
+    out=`eval $cmd`
+    if [ $? != 0 ] ; then
+       echo "$out"
+       echo "command failed"
+       return 1
+    fi
+
+    # test smbclient 'ls' command output went to stderr
+    echo "$out" | grep "blocks available" >/dev/null 2>&1
+    if [ $? != 0 ] ; then
+       # didn't get output to stderr
+       echo "expected output was NOT output to stderr"
+       return 1
+    fi
+
+    return 0
+
+}
+
 #
 #
 LOGDIR_PREFIX=test_smbclient_s3
@@ -2068,6 +2109,10 @@ testit "noninteractive smbclient -l does not prompt" \
    test_noninteractive_no_prompt -l $LOGDIR || \
     failed=`expr $failed + 1`
 
+testit "smbclient output goes to stderr when -E is passed" \
+    test_smbclient_minus_e_stderr || \
+    failed=`expr $failed + 1`
+
 testit "interactive smbclient prompts on stdout" \
    test_interactive_prompt_stdout || \
     failed=`expr $failed + 1`