summaryrefslogtreecommitdiff
path: root/gl/tests/test-select-out.sh
blob: f83beeb1f580aeac3db2c2f3690fde4e9ad8027c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh
# Test select() on file descriptors opened for writing.

tmpfiles=""
trap 'rm -fr $tmpfiles' 1 2 3 15

tmpfiles="$tmpfiles t-select-out.out t-select-out.tmp"

# Regular files.

./test-select-fd${EXEEXT} w 1 > t-select-out.out 2> t-select-out.tmp
test `cat t-select-out.tmp` = "1" || exit 1

# Pipes.

( { echo abc; ./test-select-fd${EXEEXT} w 1; } | { sleep 1; cat; } ) > /dev/null 2> t-select-out.tmp
test `cat t-select-out.tmp` = "0" || exit 1

( { sleep 1; echo abc; ./test-select-fd${EXEEXT} w 1; } | cat) > /dev/null 2> t-select-out.tmp
test `cat t-select-out.tmp` = "1" || exit 1

# Special files.

./test-select-fd${EXEEXT} w 1 > /dev/null 2> t-select-out.tmp
test `cat t-select-out.tmp` = "1" || exit 1

rm -fr $tmpfiles

exit 0