More tests for 'select' module.
[pspp] / 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 ./test-select-fd${EXEEXT} w 1 > t-select-out.out 2> t-select-out.tmp
12 test `cat t-select-out.tmp` = "1" || exit 1
13
14 # Pipes.
15
16 ( { echo abc; ./test-select-fd${EXEEXT} w 1; } | { sleep 1; cat; } ) > /dev/null 2> t-select-out.tmp
17 test `cat t-select-out.tmp` = "0" || exit 1
18
19 ( { sleep 1; echo abc; ./test-select-fd${EXEEXT} w 1; } | cat) > /dev/null 2> t-select-out.tmp
20 test `cat t-select-out.tmp` = "1" || exit 1
21
22 # Special files.
23
24 ./test-select-fd${EXEEXT} w 1 > /dev/null 2> t-select-out.tmp
25 test `cat t-select-out.tmp` = "1" || exit 1
26
27 rm -fr $tmpfiles
28
29 exit 0