2015-07-14 16:30:35 +02:00
#!/bin/sh
#
2016-01-06 00:12:36 +02:00
# Blackbox test for 'dfree command' and smbclient "l"
# command disk free printout.
2015-07-14 16:30:35 +02:00
#
if [ $# -lt 6 ] ; then
2022-04-22 15:34:08 +02:00
cat <<EOF
2015-07-14 16:30:35 +02:00
Usage: test_dfree_command.sh SERVER DOMAIN USERNAME PASSWORD PREFIX SMBCLIENT
EOF
2022-04-22 15:34:08 +02:00
exit 1
2015-07-14 16:30:35 +02:00
fi
SERVER = $1
DOMAIN = $2
USERNAME = $3
PASSWORD = $4
PREFIX = $5
smbclient = $6
2019-11-27 19:25:49 +00:00
protocol = $7
shift 7
2015-07-14 16:30:35 +02:00
failed = 0
2022-04-22 15:34:08 +02:00
incdir = $( dirname $0 ) /../../../testprogs/blackbox
2015-07-14 16:30:35 +02:00
. $incdir /subunit.sh
2022-04-22 15:34:08 +02:00
test_smbclient_dfree( )
{
2015-07-14 16:30:35 +02:00
name = " $1 "
share = " $2 "
cmd = " $3 "
2022-04-22 15:34:08 +02:00
expected = " $4 "
shift
2015-07-14 16:30:35 +02:00
shift
shift
subunit_start_test " $name "
2022-02-24 11:39:24 +01:00
output = $( $VALGRIND $smbclient //$SERVER /$share -c " $cmd " " $@ " 2>& 1)
2015-07-14 16:30:35 +02:00
status = $?
if [ x$status = x0 ] ; then
2016-01-06 00:12:36 +02:00
received = $( echo " $output " | awk '/blocks of size/ {print $1, $5, $6}' )
if [ " $expected " = " $received " ] ; then
2015-07-14 16:30:35 +02:00
subunit_pass_test " $name "
2023-04-11 14:34:07 +12:00
return 0
2015-07-14 16:30:35 +02:00
else
echo " $output " | subunit_fail_test " $name "
2023-04-11 14:34:07 +12:00
return 1
2015-07-14 16:30:35 +02:00
fi
else
echo " $output " | subunit_fail_test " $name "
2023-04-11 14:34:07 +12:00
return $status
2015-07-14 16:30:35 +02:00
fi
}
2019-11-27 19:25:49 +00:00
if [ $protocol = "SMB3" ] ; then
2022-04-22 15:34:08 +02:00
test_smbclient_dfree "Test dfree command share root SMB3" dfree "l" "2000 1024. 20" -U$USERNAME %$PASSWORD --option= clientmaxprotocol = SMB3 || failed = $( expr $failed + 1)
test_smbclient_dfree "Test dfree command subdir1 SMB3" dfree "cd subdir1; l" "8000 1024. 80" -U$USERNAME %$PASSWORD --option= clientmaxprotocol = SMB3 || failed = $( expr $failed + 1)
test_smbclient_dfree "Test dfree command subdir2 SMB3" dfree "cd subdir2; l" "32000 1024. 320" -U$USERNAME %$PASSWORD --option= clientmaxprotocol = SMB3 || failed = $( expr $failed + 1)
2015-07-14 16:30:35 +02:00
2019-11-27 19:25:49 +00:00
elif [ $protocol = "NT1" ] ; then
2022-04-22 15:34:08 +02:00
test_smbclient_dfree "Test dfree command share root NT1" dfree "l" "2000 1024. 20" -U$USERNAME %$PASSWORD --option= clientmaxprotocol = NT1 || failed = $( expr $failed + 1)
#SMB1 queries disk usage stat on the share's root, regardless of working directory
test_smbclient_dfree "Test dfree command subdir1 NT1" dfree "cd subdir1; l" "2000 1024. 20" -U$USERNAME %$PASSWORD --option= clientmaxprotocol = NT1 || failed = $( expr $failed + 1)
2015-07-14 16:30:35 +02:00
2019-11-27 19:25:49 +00:00
else
2022-04-22 15:34:08 +02:00
echo " unsupported protocol $protocol " | subunit_fail_test "Test dfree command"
2022-02-21 11:23:27 +01:00
failed = $( expr $failed + 1)
2019-11-27 19:25:49 +00:00
fi
2015-07-14 16:30:35 +02:00
exit $failed