summaryrefslogtreecommitdiff
path: root/tests/misc
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2014-12-16 12:36:39 +0000
committerPádraig Brady <P@draigBrady.com>2014-12-19 11:56:20 +0000
commit6894816c653adef54f3a85becbf75a865d6d39d6 (patch)
tree82bb3126d3c8cfaeebc950bd03a52a4f5e0f056c /tests/misc
parent178f8e79dcd1e0b8bbb3b04da664d05eaae56186 (diff)
downloadcoreutils-6894816c653adef54f3a85becbf75a865d6d39d6.tar.xz
diagnose too-large numbers better
Following on from commit v8.23-82-gaddae94, consistently diagnose numbers that are too large, so as to distinguish from other errors, and make the limits obvious. * gl/modules/xdectoint: A new module implementing xdecto[iu]max(), which handles the common case of parsing a bounded integer and exiting with a diagnostic on error. * gl/lib/xdectoimax.c: The signed variant. * gl/lib/xdectoint.c: The parameterized implementation. * gl/lib/xdectoint.h: The interface. * gl/lib/xdectoumax.c: The unsigned variant. * bootstrap.conf: Reference the new module. * cfg.mk (exclude_file_name_regexp--sc_require_config_h_first): Exclude the parameterized templates. * src/csplit.c: Output EOVERFLOW or ERANGE errors if appropriate. * src/fmt.c: Likewise. * src/fold.c: Likewise. * src/head.c: Likewise. * src/ls.c: Likewise. * src/nl.c: Likewise. * src/nproc.c: Likewise. * src/shred.c: Likewise. * src/shuf.c: Likewise. * src/stdbuf.c: Likewise. * src/stty.c: Likewise. * src/tail.c: Likewise. * src/truncate.c: Likewise. * src/split.c: Likewise. * src/pr.c: Likewise. * tests/pr/pr-tests.pl: Adjust to avoid matching errno diagnostic. * tests/fmt/base.pl: Likewise. * tests/split/l-chunk.sh: Likewise. * tests/misc/shred-negative.sh: Likewise. * tests/misc/tail.pl: Likewise. Also remove the redundant existing ERR_SUBST from test err-6. * tests/ls/hex-option.sh: Check HEX/OCT options. * tests/misc/shred-size.sh: Likewise. * tests/misc/stty-row-col.sh: Likewise.
Diffstat (limited to 'tests/misc')
-rwxr-xr-xtests/misc/shred-size.sh (renamed from tests/misc/shred-negative.sh)12
-rwxr-xr-xtests/misc/stty-row-col.sh2
-rwxr-xr-xtests/misc/tail.pl12
3 files changed, 17 insertions, 9 deletions
diff --git a/tests/misc/shred-negative.sh b/tests/misc/shred-size.sh
index 86cbf3e02..9eabf606c 100755
--- a/tests/misc/shred-negative.sh
+++ b/tests/misc/shred-size.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# Exercise shred -s-3 FILE
+# Exercise shred --size
# Copyright (C) 2014 Free Software Foundation, Inc.
@@ -19,10 +19,16 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ shred
-echo 'shred: -2: invalid file size' > exp || framework_failure_
+# Negative size
+echo "shred: invalid file size: '-2'" > exp || framework_failure_
echo 1234 > f || framework_failure_
-
shred -s-2 f 2>err && fail=1
compare exp err || fail=1
+# Octal/Hex
+shred -s010 f || fail=1
+test $(stat --printf=%s f) = 8 || fail=1
+shred -s0x10 f || fail=1
+test $(stat --printf=%s f) = 16 || fail=1
+
Exit $fail
diff --git a/tests/misc/stty-row-col.sh b/tests/misc/stty-row-col.sh
index 729d6f913..1c7af1da0 100755
--- a/tests/misc/stty-row-col.sh
+++ b/tests/misc/stty-row-col.sh
@@ -47,6 +47,8 @@ tests='
7 rows_1 1_1
8 columns_80 1_80
9 rows_30 30_80
+10 rows_0x1E 30_80
+11 rows_036 30_80
NA LAST NA
'
set $tests
diff --git a/tests/misc/tail.pl b/tests/misc/tail.pl
index 6798eb05d..adeff6857 100755
--- a/tests/misc/tail.pl
+++ b/tests/misc/tail.pl
@@ -19,7 +19,7 @@
use strict;
my $prog = 'tail';
-my $normalize_filename = {ERR_SUBST => 's/^$prog: .*?:/$prog: -:/'};
+my $normalize_strerror = 's/:[^:]*$//';
# Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
@@ -59,7 +59,7 @@ my @tv = (
"$prog: cannot open '+cl' for reading: No such file or directory\n"],
['err-2', '-cl', '', '', 1,
- "$prog: l: invalid number of bytes\n"],
+ "$prog: invalid number of bytes: 'l'\n"],
['err-3', '+2cz', '', '', 1,
"$prog: cannot open '+2cz' for reading: No such file or directory\n"],
@@ -72,9 +72,9 @@ my @tv = (
# the diagnostic: 'tail: 99999999999999999999: invalid number of bytes'
# on all systems... probably, for now, maybe.
['err-5', '-c99999999999999999999', '', '', 1,
- "$prog: 99999999999999999999: invalid number of bytes\n"],
+ "$prog: invalid number of bytes: '99999999999999999999'", $normalize_strerror],
['err-6', '-c --', '', '', 1,
- "$prog: -: invalid number of bytes\n", $normalize_filename],
+ "$prog: invalid number of bytes: '-'\n"],
# Same as -n 10
['minus-1', '-', '', '', 0],
@@ -106,10 +106,10 @@ my @Tests;
foreach my $t (@tv)
{
- my ($test_name, $flags, $in, $exp, $ret, $err_msg) = @$t;
+ my ($test_name, $flags, $in, $exp, $ret, $err_msg, $err_sub) = @$t;
my $e = [$test_name, $flags, {IN=>$in}, {OUT=>$exp}];
$ret
- and push @$e, {EXIT=>$ret}, {ERR=>$err_msg};
+ and push @$e, {EXIT=>$ret}, {ERR=>$err_msg}, {ERR_SUBST=>$err_sub};
$test_name =~ /^(obs-plus-|minus-)/
and push @$e, {ENV=>'_POSIX2_VERSION=199209'};