Tizen 2.0 Release
[external/tizen-coreutils.git] / tests / stty / row-col-1
1 #! /bin/sh
2 # Test "stty" with rows and columns.
3
4 # Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006 Free
5 # Software Foundation, Inc.
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 # 02110-1301, USA.
21
22
23 # This script takes no arguments.
24
25 if test "$VERBOSE" = yes; then
26   set -x
27   stty --version
28 fi
29
30 # Setting this envvar to a very small value used to cause e.g., `stty size'
31 # to generate slightly different output on certain systems.
32 COLUMNS=80
33 export COLUMNS
34
35 # Make sure we get English-language behavior.
36 # See the report about a possibly-related Solaris problem by Alexandre Peshansky
37 # <http://lists.gnu.org/archive/html/bug-coreutils/2004-10/msg00035.html>.
38 # Currently stty isn't localized, but it might be in the future.
39 LC_ALL=C
40 export LC_ALL
41
42 # Make sure there's a tty on stdin.
43 . $srcdir/../input-tty
44
45 # Versions of GNU stty from shellutils-1.9.2c and earlier failed
46 # tests #2 and #4 when run on SunOS 4.1.3.
47
48 tests='
49 1 rows_40_columns_80 40_80
50 2 rows_1_columns_1 1_1
51 3 rows_40_columns_80 40_80
52 4 rows_1 1_80
53 5 columns_1 1_1
54 6 rows_40 40_1
55 7 rows_1 1_1
56 8 columns_80 1_80
57 9 rows_30 30_80
58 NA LAST NA
59 '
60 set $tests
61
62 saved_size=`stty size` && test -n "$saved_size" \
63   || { echo "$0: skipping this test: can't get window size" 1>&2;
64        exit 77; exit; }
65
66 fail=0
67 while :; do
68   test_name=$1
69   args=$2
70   expected_result="`echo $3|tr _ ' '`"
71   test "$args" = empty && args=''
72   test "x$args" = xLAST && break
73   args=`echo x$args|tr _ ' '|sed 's/^x//'`
74   if test "$VERBOSE" = yes; then
75     # echo "testing \`stty $args; stty size\` = $expected_result ..."
76     echo "test $test_name... " | tr -d '\n'
77   fi
78   stty $args || exit 1
79   test x"`stty size 2> /dev/null`" = "x$expected_result" \
80     && ok=ok || ok=FAIL fail=1
81   test "$VERBOSE" = yes && echo $ok
82   shift; shift; shift
83 done
84
85 set x $saved_size
86 stty rows $2 columns $3 || exit 1
87
88 exit $fail