437934d1cd7c1da65a876a88516bee131591b617
[samba.git] / source3 / script / tests / test_open_eintr.sh
1 #!/bin/bash
2 #
3 # Test smbd handling when open returns EINTR
4 #
5 # Copyright (C) 2020 Volker Lendecke
6
7 if [ $# -lt 5 ]; then
8     echo Usage: test_open_eintr.sh \
9          --configfile=SERVERCONFFILE SMBCLIENT SMBCONTROL SERVER SHARE
10 exit 1
11 fi
12
13 CONF=$1; shift 1
14 SMBCLIENT=$1; shift 1
15 SMBCONTROL=$1; shift 1
16 SERVER=$1; shift 1
17 SHARE=$1; shift 1
18
19 error_inject_conf=$(dirname ${SERVERCONFFILE})/error_inject.conf
20 > ${error_inject_conf}
21
22 incdir=$(dirname $0)/../../../testprogs/blackbox
23 . $incdir/subunit.sh
24
25 failed=0
26
27 rm -f smbclient-stdin smbclient-stdout smbclient-stderr
28 mkfifo smbclient-stdin smbclient-stdout smbclient-stderr
29
30 CLI_FORCE_INTERACTIVE=1; export CLI_FORCE_INTERACTIVE
31
32 ${SMBCLIENT} //${SERVER}/${SHARE} ${CONF} -U${USER}%${PASSWORD} \
33              < smbclient-stdin > smbclient-stdout 2>smbclient-stderr &
34 CLIENT_PID=$!
35
36 sleep 1
37
38 exec 100>smbclient-stdin 101<smbclient-stdout 102<smbclient-stderr
39
40 # consume the smbclient startup messages
41 head -n 1 <&101
42 head -n 1 <&102
43
44 echo "error_inject:openat = EINTR" > ${error_inject_conf}
45 ${SMBCONTROL} ${CONF} 0 reload-config
46
47 sleep 1
48 > ${error_inject_conf}
49
50 echo 'get badnames/blank.txt -' >&100
51
52 sleep 1
53
54 > ${error_inject_conf}
55 ${SMBCONTROL} ${CONF} 0 reload-config
56
57 head -n 1 <&102 | grep 'getting file' > /dev/null
58 GREP_RET=$?
59
60 kill ${CLIENT_PID}
61 rm -f smbclient-stdin smbclient-stdout smbclient-stderr
62
63 testit "Verify that we could get the file" \
64        test $GREP_RET -eq 0 || failed=$(expr $failed + 1)
65
66 testok $0 $failed