1#!/bin/sh
2# Test select() on file descriptors opened for reading.
3
4# This test is known to fail on Solaris 2.6 and older, due to its handling
5# of /dev/null.
6
7tmpfiles=""
8trap 'rm -fr $tmpfiles' 1 2 3 15
9
10tmpfiles="$tmpfiles t-select-in.tmp"
11
12# Regular files.
13
14rm -f t-select-in.tmp
15./test-select-fd${EXEEXT} r 0 t-select-in.tmp < ./test-select-fd${EXEEXT}
16test `cat t-select-in.tmp` = "1" || exit 1
17
18# Pipes.
19
20rm -f t-select-in.tmp
21{ sleep 1; echo abc; } | \
22  { ./test-select-fd${EXEEXT} r 0 t-select-in.tmp; cat > /dev/null; }
23test `cat t-select-in.tmp` = "0" || exit 1
24
25rm -f t-select-in.tmp
26echo abc | { sleep 1; ./test-select-fd${EXEEXT} r 0 t-select-in.tmp; }
27test `cat t-select-in.tmp` = "1" || exit 1
28
29# Special files.
30# This part of the test is known to fail on Solaris 2.6 and older.
31
32rm -f t-select-in.tmp
33./test-select-fd${EXEEXT} r 0 t-select-in.tmp < /dev/null
34test `cat t-select-in.tmp` = "1" || exit 1
35
36rm -fr $tmpfiles
37
38exit 0
39