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