From: Jule Anger Date: Tue, 22 Mar 2022 15:12:41 +0000 (+0100) Subject: s3:tests: Add a test to check json output of smbstatus X-Git-Tag: samba-4.17.0rc1~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=74028253e1cccdc5c140fe7e9ec5f3e411d9400e;p=thirdparty%2Fsamba.git s3:tests: Add a test to check json output of smbstatus Signed-off-by: Jule Anger Reviewed-by: Ralph Boehme --- diff --git a/source3/script/tests/test_smbstatus.sh b/source3/script/tests/test_smbstatus.sh index a7ebabd12f4..6b58580f0b9 100755 --- a/source3/script/tests/test_smbstatus.sh +++ b/source3/script/tests/test_smbstatus.sh @@ -237,6 +237,162 @@ EOF return 0 } +test_smbstatus_json() +{ + local cmdfile=$PREFIX/smbclient_commands + local tmpfile=$PREFIX/smbclient_lock_file + local file=smbclient_lock_file + local status_json=smbstatus_output_json + local status_json_long=smbstatus_output_json_long + + cat > $tmpfile < $cmdfile < $status_json +!UID_WRAPPER_INITIAL_RUID=0 UID_WRAPPER_INITIAL_EUID=0 $SMBSTATUS --json -vBN > $status_json_long +close 1 +rm $file +quit +EOF + + cmd="CLI_FORCE_INTERACTIVE=yes $SMBCLIENT -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS --quiet < $cmdfile 2>&1" + out=$(eval $cmd) + echo $out + ret=$? + + rm -f $cmdfile + rm -f $tmpfile + + if [ $ret -ne 0 ]; then + echo "Failed to run smbclient with error $ret" + echo "$out" + return 1 + fi + + echo $out | grep -c 'JSON support not available, please install lib Jansson' + ret=$? + if [ $ret -eq 0 ]; then + subunit_start_test "test_smbstatus_json" + subunit_skip_test "test_smbstatus_json" <