~ubuntu-branches/ubuntu/raring/findutils/raring

« back to all changes in this revision

Viewing changes to tests/test-yesno.sh

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2008-05-06 11:32:24 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 23.
  • Revision ID: james.westby@ubuntu.com-20080506113224-gy4ecmxu48tnvva4
Tags: upstream-4.4.0
ImportĀ upstreamĀ versionĀ 4.4.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
tmpfiles=
 
4
trap 'rm -fr $tmpfiles' 1 2 3 15
 
5
 
 
6
p=t-yesno-
 
7
tmpfiles="${p}in.tmp ${p}xout.tmp ${p}out.tmp ${p}err.tmp"
 
8
 
 
9
# For now, only test with C locale
 
10
LC_ALL=C
 
11
export LC_ALL
 
12
 
 
13
# Test with seekable stdin; followon process must see remaining data
 
14
cat <<EOF > ${p}in.tmp
 
15
nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn - entire line consumed
 
16
yn - backspace does not change result
 
17
y
 
18
does not match either yesexpr or noexpr
 
19
n
 
20
EOF
 
21
cat <<EOF > ${p}xout.tmp
 
22
N
 
23
Y
 
24
Y
 
25
N
 
26
n
 
27
EOF
 
28
(./test-yesno${EXEEXT}; ./test-yesno${EXEEXT} 3; cat) \
 
29
  < ${p}in.tmp > ${p}out.tmp || exit 1
 
30
cmp ${p}xout.tmp ${p}out.tmp || exit 1
 
31
 
 
32
(./test-yesno${EXEEXT} 3; ./test-yesno${EXEEXT}; cat) \
 
33
  < ${p}in.tmp > ${p}out.tmp || exit 1
 
34
cmp ${p}xout.tmp ${p}out.tmp || exit 1
 
35
 
 
36
# Test for behavior on pipe
 
37
cat <<EOF > ${p}xout.tmp
 
38
Y
 
39
N
 
40
EOF
 
41
echo yes | ./test-yesno${EXEEXT} 2 > ${p}out.tmp || exit 1
 
42
cmp ${p}xout.tmp ${p}out.tmp || exit 1
 
43
 
 
44
# Test for behavior on EOF
 
45
cat <<EOF > ${p}xout.tmp
 
46
N
 
47
EOF
 
48
./test-yesno${EXEEXT} </dev/null > ${p}out.tmp || exit 1
 
49
cmp ${p}xout.tmp ${p}out.tmp || exit 1
 
50
 
 
51
# Test for behavior when stdin is closed
 
52
./test-yesno${EXEEXT} 0 <&- > ${p}out.tmp 2> ${p}err.tmp && exit 1
 
53
cmp ${p}xout.tmp ${p}out.tmp || exit 1
 
54
test -s ${p}err.tmp || exit 1
 
55
 
 
56
# Cleanup
 
57
rm -fr $tmpfiles
 
58
 
 
59
exit 0