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