1#!/bin/bash 2# 3# Test terminating an smbclient connection with outstanding 4# aio requests. 5# 6# Note this is designed to be run against 7# the aio_delay_inject share which is preconfigured 8# with 2 second delays on pread/pwrite. 9 10if [ $# -lt 4 ]; then 11 echo Usage: test_aio_outstanding.sh \ 12 SERVERCONFFILE SMBCLIENT IP aio_delay_inject_sharename 13exit 1 14fi 15 16CONF=$1 17SMBCLIENT=$2 18SERVER=$3 19SHARE=$4 20 21incdir=$(dirname $0)/../../../testprogs/blackbox 22. $incdir/subunit.sh 23 24failed=0 25# 26# Note if we already have any panics in the smbd log. 27# 28panic_count_0=$(grep -c PANIC $SMBD_TEST_LOG) 29 30# Create the smbclient communication pipes. 31rm -f smbclient-stdin smbclient-stdout smbclient-stderr 32mkfifo smbclient-stdin smbclient-stdout smbclient-stderr 33 34# Create a large-ish testfile 35rm aio_outstanding_testfile 36head -c 20MB /dev/zero >aio_outstanding_testfile 37 38CLI_FORCE_INTERACTIVE=1; export CLI_FORCE_INTERACTIVE 39 40${SMBCLIENT} //${SERVER}/${SHARE} ${CONF} -U${USER}%${PASSWORD} \ 41 < smbclient-stdin > smbclient-stdout 2>smbclient-stderr & 42CLIENT_PID=$! 43 44sleep 1 45 46exec 100>smbclient-stdin 101<smbclient-stdout 102<smbclient-stderr 47 48# consume the smbclient startup messages 49head -n 1 <&101 50head -n 1 <&102 51 52# Ensure we're putting a fresh file. 53echo "del aio_outstanding_testfile" >&100 54echo "put aio_outstanding_testfile" >&100 55 56sleep 2 57 58# Terminate the smbclient write to the aio_delay_inject share whilst 59# we have outstanding writes. 60kill $CLIENT_PID 61 62sleep 1 63 64# Ensure the panic count didn't change. 65# 66# BUG: https://bugzilla.samba.org/show_bug.cgi?id=14301 67# 68 69panic_count_1=$(grep -c PANIC $SMBD_TEST_LOG) 70 71# Rerun smbclient to remove the testfile on the server. 72rm -f smbclient-stdin smbclient-stdout smbclient-stderr aio_outstanding_testfile 73mkfifo smbclient-stdin smbclient-stdout 74 75${SMBCLIENT} //${SERVER}/${SHARE} ${CONF} -U${USER}%${PASSWORD} \ 76 < smbclient-stdin > smbclient-stdout & 77 78sleep 1 79 80exec 100>smbclient-stdin 101<smbclient-stdout 81 82echo "del aio_outstanding_testfile" >&100 83echo "exit" >&100 84 85sleep 2 86 87rm -f smbclient-stdin smbclient-stdout aio_outstanding_testfile 88 89testit "check_panic" test $panic_count_0 -eq $panic_count_1 || 90 failed=$(expr $failed + 1) 91 92testok $0 $failed 93