Tests for module 'mbsinit'.
[gnulib.git] / tests / test-select-in.sh
1 #!/bin/sh
2 # Test select() on file descriptors opened for reading.
3
4 tmpfiles=""
5 trap 'rm -fr $tmpfiles' 1 2 3 15
6
7 tmpfiles="$tmpfiles t-select-in.tmp"
8
9 # Regular files.
10
11 rm -f t-select-in.tmp
12 ./test-select-fd${EXEEXT} r 0 t-select-in.tmp < ./test-select-fd${EXEEXT}
13 test `cat t-select-in.tmp` = "1" || exit 1
14
15 # Pipes.
16
17 rm -f t-select-in.tmp
18 { sleep 1; echo abc; } | ./test-select-fd${EXEEXT} r 0 t-select-in.tmp
19 test `cat t-select-in.tmp` = "0" || exit 1
20
21 rm -f t-select-in.tmp
22 echo abc | { sleep 1; ./test-select-fd${EXEEXT} r 0 t-select-in.tmp; }
23 test `cat t-select-in.tmp` = "1" || exit 1
24
25 # Special files.
26
27 rm -f t-select-in.tmp
28 ./test-select-fd${EXEEXT} r 0 t-select-in.tmp < /dev/null
29 test `cat t-select-in.tmp` = "1" || exit 1
30
31 rm -fr $tmpfiles
32
33 exit 0