selftest: more dfree command and smbclient disk usage tests
[obnox/samba/samba-obnox.git] / source3 / script / tests / test_dfree_command.sh
1 #!/bin/sh
2 #
3 # Blackbox test for 'dfree command' and smbclient "l"
4 # command disk free printout.
5 #
6
7 if [ $# -lt 6 ]; then
8 cat <<EOF
9 Usage: test_dfree_command.sh SERVER DOMAIN USERNAME PASSWORD PREFIX SMBCLIENT
10 EOF
11 exit 1;
12 fi
13
14 SERVER=$1
15 DOMAIN=$2
16 USERNAME=$3
17 PASSWORD=$4
18 PREFIX=$5
19 smbclient=$6
20 shift 6
21 failed=0
22
23 incdir=`dirname $0`/../../../testprogs/blackbox
24 . $incdir/subunit.sh
25
26 test_smbclient_dfree() {
27         name="$1"
28         share="$2"
29         cmd="$3"
30     expected="$4"
31         shift
32         shift
33     shift
34         subunit_start_test "$name"
35         output=$($VALGRIND $smbclient //$SERVER/$share -c "$cmd" $@ 2>&1)
36         status=$?
37         if [ x$status = x0 ]; then
38                 received=$(echo "$output" | awk '/blocks of size/ {print $1, $5, $6}')
39                 if [ "$expected" = "$received" ]; then
40                         subunit_pass_test "$name"
41                 else
42                         echo "$output" | subunit_fail_test "$name"
43                 fi
44         else
45                 echo "$output" | subunit_fail_test "$name"
46         fi
47         return $status
48 }
49
50
51 test_smbclient_dfree "Test dfree command share root SMB3" dfree "l" "2000 1024. 20" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=SMB3 || failed=`expr $failed + 1`
52 test_smbclient_dfree "Test dfree command share root NT1" dfree "l" "2000 1024. 20" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=NT1 || failed=`expr $failed + 1`
53 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`
54 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`
55 #SMB1 queries disk usage stat on the share's root, regardless of working directory
56 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`
57
58 exit $failed