~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to tests/misc/stty-row-col

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

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