mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-08-07 07:22:55 +03:00
tests: more automated quote adjustment
Relax initial regexp to match more instances, but add a filter to avoid some invalid conversions. Run this: git grep -l "\`[^']*'" tests | xargs perl -pi -e '$q=q"'\''";' \ -e '$q="$q\\$q$q"; /(= ?\`|\`expr|\`echo|\Q$q\E)/ and next;' \ -e ' s/\`([^'\''"]*?'\'')/'\''$1/g' The last disjunct in the above (...) filter is to exempt any line that contains this string: '\'' With quoting like that, converting a ` to ' is likely to cause trouble, so we'll handle those manually. Here are three examples where the exemption is required: *': `link-to-dir/'\'': hard link not allowed for directory'*) ;; printf 'creating file `%s'\''\n' $f 'mv: inter-device move failed: `%s'\'' to `%s'\'';'\
This commit is contained in:
@@ -61,7 +61,7 @@ defined $ENV{DJDIR}
|
||||
# stdout from cmd
|
||||
# {OUT => {'filename'=>[$CTOR, $DTOR]}} $CTOR and $DTOR are references to
|
||||
# functions, each which is passed the single argument 'filename'.
|
||||
# $CTOR must create `filename'.
|
||||
# $CTOR must create 'filename'.
|
||||
# DTOR may be omitted in which case 'sub{unlink @_[0]}' is used.
|
||||
# FIXME: implement this
|
||||
# {ERR => ...}
|
||||
@@ -78,7 +78,7 @@ defined $ENV{DJDIR}
|
||||
# diagnostics: Operation not permitted, Not owner, and Permission denied.
|
||||
# {EXIT => N} expect exit status of cmd to be N
|
||||
# {ENV => 'VAR=val ...'}
|
||||
# Prepend 'VAR=val ...' to the command that we execute via `system'.
|
||||
# Prepend 'VAR=val ...' to the command that we execute via 'system'.
|
||||
# {ENV_DEL => 'VAR'}
|
||||
# Remove VAR from the environment just before running the corresponding
|
||||
# command, and restore any value just afterwards.
|
||||
@@ -114,7 +114,7 @@ sub _create_file ($$$$)
|
||||
++$Global_count;
|
||||
}
|
||||
|
||||
warn "creating file `$file' with contents `$data'\n" if $debug;
|
||||
warn "creating file '$file' with contents '$data'\n" if $debug;
|
||||
|
||||
# The test spec gave a string.
|
||||
# Write it to a temp file and return tempfile name.
|
||||
@@ -183,7 +183,7 @@ sub _process_file_spec ($$$$$)
|
||||
else
|
||||
{
|
||||
# FIXME: put $srcdir in here somewhere
|
||||
warn "$program_name: $test_name: specified file `$file' does"
|
||||
warn "$program_name: $test_name: specified file '$file' does"
|
||||
. " not exist\n"
|
||||
if ! -f "$srcdir/$file";
|
||||
}
|
||||
@@ -314,7 +314,7 @@ sub run_tests ($$$$$)
|
||||
. " expected 1\n"
|
||||
if $n != 1;
|
||||
my ($type, $val) = each %$io_spec;
|
||||
die "$program_name: $test_name: invalid key `$type' in test spec\n"
|
||||
die "$program_name: $test_name: invalid key '$type' in test spec\n"
|
||||
if ! $Types{$type};
|
||||
|
||||
# Make sure there's no more than one of OUT, ERR, EXIT, etc.
|
||||
@@ -350,7 +350,7 @@ sub run_tests ($$$$$)
|
||||
or die "$program_name: $test_name: CMP spec has $n "
|
||||
. "elements -- expected 1\n";
|
||||
|
||||
# Replace any `@AUX@' in the key of %$e.
|
||||
# Replace any '@AUX@' in the key of %$e.
|
||||
my ($ff, $val) = each %$e;
|
||||
my $new_ff = _at_replace $expect, $ff;
|
||||
if ($new_ff ne $ff)
|
||||
@@ -474,7 +474,7 @@ sub run_tests ($$$$$)
|
||||
and $pushed_env{$env_sym} = $val;
|
||||
}
|
||||
|
||||
warn "Running command: `$cmd_str'\n" if $debug;
|
||||
warn "Running command: '$cmd_str'\n" if $debug;
|
||||
my $rc = 0xffff & system $cmd_str;
|
||||
|
||||
# Restore any environment setting we changed via a deletion.
|
||||
@@ -486,7 +486,7 @@ sub run_tests ($$$$$)
|
||||
if ($rc == 0xff00)
|
||||
{
|
||||
warn "$program_name: test $test_name failed: command failed:\n"
|
||||
. " `$cmd_str': $!\n";
|
||||
. " '$cmd_str': $!\n";
|
||||
$fail = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ my $dir;
|
||||
|
||||
sub skip_test($)
|
||||
{
|
||||
warn "$ME: skipping test: unsafe working directory name: `$_[0]'\n";
|
||||
warn "$ME: skipping test: unsafe working directory name: '$_[0]'\n";
|
||||
exit 77;
|
||||
}
|
||||
|
||||
|
@@ -44,11 +44,11 @@ check-am: .built-programs
|
||||
&& MAKEFLAGS= $(MAKE) -s built_programs.list) \
|
||||
> $@-t && mv $@-t $@
|
||||
|
||||
## `$f' is set by the Automake-generated test harness to the path of the
|
||||
## '$f' is set by the Automake-generated test harness to the path of the
|
||||
## current test script stripped of VPATH components, and is used by the
|
||||
## shell-or-perl script to determine the name of the temporary files to be
|
||||
## used. Note that $f is a shell variable, not a make macro, so the use of
|
||||
## `$$f' below is correct, and not a typo.
|
||||
## '$$f' below is correct, and not a typo.
|
||||
LOG_COMPILER = \
|
||||
$(SHELL) $(srcdir)/shell-or-perl \
|
||||
--test-name "$$f" --srcdir '$(srcdir)' \
|
||||
|
@@ -66,7 +66,7 @@ chown --from=:$g1 :$g2 f; test `stat --printf=%g f` = $g2 || fail=1
|
||||
|
||||
# This *should* change the group of f.
|
||||
# Though note that the diagnostic is misleading in that
|
||||
# it says the 'group of `symlink'' has been changed.
|
||||
# it says the 'group of 'symlink'' has been changed.
|
||||
chgrp $g1 symlink; test `stat --printf=%g f` = $g1 || fail=1
|
||||
chown --from=:$g1 :$g2 f; test `stat --printf=%g f` = $g2 || fail=1
|
||||
|
||||
|
@@ -52,7 +52,7 @@ set _ `ls -ln f`; g=$5; test "$g" = $g2 || fail=1
|
||||
|
||||
# This *should* change the group of f.
|
||||
# Though note that the diagnostic you'd get with -c is misleading in that
|
||||
# it says the 'group of `symlink'' has been changed.
|
||||
# it says the 'group of 'symlink'' has been changed.
|
||||
chgrp --dereference $g1 symlink
|
||||
set _ `ls -ln f`; g=$5; test "$g" = $g1 || fail=1
|
||||
set _ `ls -ln symlink`; g=$5; test "$g" = $g2 || fail=1
|
||||
|
@@ -47,7 +47,7 @@ EOF
|
||||
compare exp out || fail=1
|
||||
|
||||
cd a
|
||||
# This will fail with '`chmod: fts_read failed: Permission denied''
|
||||
# This will fail with ''chmod: fts_read failed: Permission denied''
|
||||
chmod a-x . b 2> /dev/null && fail=1
|
||||
# chmod must exit with status 1.
|
||||
# Due to a bug in coreutils-5.93's fts.c, chmod would provoke
|
||||
|
@@ -48,7 +48,7 @@ fallocate -l 600MiB space.test ||
|
||||
|
||||
# Disable this test on old BTRFS (e.g. Fedora 14)
|
||||
# which reports ordinary extents for unwritten ones.
|
||||
filefrag space.test || skip_ 'the 'filefrag` utility is missing'
|
||||
filefrag space.test || skip_ 'the 'filefrag' utility is missing'
|
||||
filefrag -v space.test | grep -F 'unwritten' > /dev/null ||
|
||||
skip_ 'this file system does not report empty extents as "unwritten"'
|
||||
|
||||
|
@@ -34,7 +34,7 @@ timeout 10 truncate -s1T f || framework_failure_
|
||||
|
||||
# Disable this test on old BTRFS (e.g. Fedora 14)
|
||||
# which reports (unwritten) extents for holes.
|
||||
filefrag f || skip_ 'the 'filefrag` utility is missing'
|
||||
filefrag f || skip_ 'the 'filefrag' utility is missing'
|
||||
filefrag f | grep -F ': 0 extents found' > /dev/null ||
|
||||
skip_ 'this file system reports extents for holes'
|
||||
|
||||
|
@@ -30,14 +30,14 @@ my @Tests =
|
||||
(
|
||||
# invalid extra command line argument
|
||||
['f-extra-arg', '--files0-from=- no-such', {IN=>"a"}, {EXIT=>1},
|
||||
{ERR => "$prog: extra operand `no-such'\n"
|
||||
{ERR => "$prog: extra operand 'no-such'\n"
|
||||
. "file operands cannot be combined with --files0-from\n"
|
||||
. "Try '$prog --help' for more information.\n"}
|
||||
],
|
||||
|
||||
# missing input file
|
||||
['missing', '--files0-from=missing', {EXIT=>1},
|
||||
{ERR => "$prog: cannot open `missing' for reading: "
|
||||
{ERR => "$prog: cannot open 'missing' for reading: "
|
||||
. "No such file or directory\n"}],
|
||||
|
||||
# input file name of '-'
|
||||
|
@@ -32,7 +32,7 @@ mkdir -p $t/1 $t/2 || framework_failure_
|
||||
test -d $t || fail=1
|
||||
du $t/1 $t/2 > /dev/null || fail=1
|
||||
|
||||
# Make sure `du . $t' and `du .. $t' work.
|
||||
# Make sure 'du . $t' and 'du .. $t' work.
|
||||
# These would fail prior to fileutils-4.0y.
|
||||
du . $t > /dev/null || fail=1
|
||||
du .. $t > /dev/null || fail=1
|
||||
|
@@ -26,7 +26,7 @@ print_ver_ ginstall
|
||||
file=file
|
||||
echo foo > $file
|
||||
|
||||
# Before 4.0q, this would mistakenly create $file, not `dest'
|
||||
# Before 4.0q, this would mistakenly create $file, not 'dest'
|
||||
# in no-dir1/no-dir2/.
|
||||
ginstall -D $file no-dir1/no-dir2/dest || fail=1
|
||||
test -d no-dir1/no-dir2 || fail=1
|
||||
|
@@ -34,7 +34,7 @@ my @Tests =
|
||||
(
|
||||
['fail-1', {ERR => "$prog: missing operand\n"
|
||||
. "Try '$prog --help' for more information.\n"}, {EXIT => '1'}],
|
||||
['fail-2', qw(a b c), {ERR => "$prog: extra operand `c'\n"
|
||||
['fail-2', qw(a b c), {ERR => "$prog: extra operand 'c'\n"
|
||||
. "Try '$prog --help' for more information.\n"}, {EXIT => '1'}],
|
||||
|
||||
['a', qw(d/f), {OUT => 'f'}],
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
# Ensure that cat -E produces same output as cat, module `$'s,
|
||||
# Ensure that cat -E produces same output as cat, module '$'s,
|
||||
# even when applied to a file in /proc.
|
||||
|
||||
# Copyright (C) 2006-2012 Free Software Foundation, Inc.
|
||||
|
@@ -57,7 +57,7 @@ my @Tests =
|
||||
|
||||
# invalid missing command line argument (1)
|
||||
['missing-arg1', $inputs[0], {EXIT=>1},
|
||||
{ERR => "$prog: missing operand after `a'\n"
|
||||
{ERR => "$prog: missing operand after 'a'\n"
|
||||
. "Try '$prog --help' for more information.\n"}],
|
||||
|
||||
# invalid missing command line argument (both)
|
||||
@@ -67,7 +67,7 @@ my @Tests =
|
||||
|
||||
# invalid extra command line argument
|
||||
['extra-arg', @inputs, 'no-such', {EXIT=>1},
|
||||
{ERR => "$prog: extra operand `no-such'\n"
|
||||
{ERR => "$prog: extra operand 'no-such'\n"
|
||||
. "Try '$prog --help' for more information.\n"}],
|
||||
|
||||
# out-of-order input
|
||||
@@ -133,7 +133,7 @@ my @Tests =
|
||||
|
||||
# invalid empty delimiter
|
||||
['delim-empty', '--output-delimiter=', @inputs, {EXIT=>1},
|
||||
{ERR => "$prog: empty `--output-delimiter' not allowed\n"}],
|
||||
{ERR => "$prog: empty '--output-delimiter' not allowed\n"}],
|
||||
|
||||
# invalid dual delimiter
|
||||
['delim-dual', '--output-delimiter=,', '--output-delimiter=+',
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
# Ensure that a command like
|
||||
# `date --date="21:04 +0100" +%S' always prints `00'.
|
||||
# `date --date="21:04 +0100" +%S' always prints '00'.
|
||||
# Before coreutils-5.2.1, it would print the seconds from the current time.
|
||||
|
||||
# Copyright (C) 2004, 2006, 2008-2012 Free Software Foundation, Inc.
|
||||
|
@@ -35,7 +35,7 @@ my @Tests =
|
||||
(
|
||||
['fail-1', {ERR => "$prog: missing operand\n"
|
||||
. "Try '$prog --help' for more information.\n"}, {EXIT => '1'}],
|
||||
['fail-2', qw(a b), {ERR => "$prog: extra operand `b'\n"
|
||||
['fail-2', qw(a b), {ERR => "$prog: extra operand 'b'\n"
|
||||
. "Try '$prog --help' for more information.\n"}, {EXIT => '1'}],
|
||||
|
||||
['a', qw(d/f), {OUT => 'd'}],
|
||||
|
@@ -63,7 +63,7 @@ my @Tests =
|
||||
{EXIT => 1}],
|
||||
['cont', 'a 4',
|
||||
{OUT => "4: 2 2\n"},
|
||||
{ERR => "$prog: `a' is not a valid positive integer\n"},
|
||||
{ERR => "$prog: 'a' is not a valid positive integer\n"},
|
||||
{EXIT => 1}],
|
||||
);
|
||||
|
||||
|
@@ -26,13 +26,13 @@ my @Tests =
|
||||
{IN=> "ça\nçb\n"},
|
||||
{OUT=>"ça b\n"}],
|
||||
['wide-1', '-w 32768',
|
||||
{ERR => "fmt: invalid width: `32768'\n"}, {EXIT => 1}],
|
||||
{ERR => "fmt: invalid width: '32768'\n"}, {EXIT => 1}],
|
||||
['wide-2', '-w 2147483647',
|
||||
{ERR => "fmt: invalid width: `2147483647'\n"}, {EXIT => 1}],
|
||||
{ERR => "fmt: invalid width: '2147483647'\n"}, {EXIT => 1}],
|
||||
['bad-suffix', '-72x', {IN=> ''},
|
||||
{ERR => "fmt: invalid width: `72x'\n"}, {EXIT => 1}],
|
||||
{ERR => "fmt: invalid width: '72x'\n"}, {EXIT => 1}],
|
||||
['no-file', 'no-such-file',
|
||||
{ERR => "fmt: cannot open `no-such-file' for reading:"
|
||||
{ERR => "fmt: cannot open 'no-such-file' for reading:"
|
||||
. " No such file or directory\n"}, {EXIT => 1}],
|
||||
['obs-1', '-c -72',
|
||||
{ERR => "fmt: invalid option -- 7; -WIDTH is recognized only when it"
|
||||
|
@@ -173,7 +173,7 @@ my @tv = (
|
||||
|
||||
# FIXME: change this to ensure the diagnostic makes sense
|
||||
['invalid-j', '-j x', {}, "", 1,
|
||||
"$prog: invalid field number: `x'\n"],
|
||||
"$prog: invalid field number: 'x'\n"],
|
||||
|
||||
# With ordering check, inputs in order
|
||||
['chkodr-1', '--check-order',
|
||||
|
@@ -61,7 +61,7 @@ my @Tests =
|
||||
['too-many-q', '-q a b', {EXIT => 1} ],
|
||||
|
||||
['too-few-x', 'foo.XX', {EXIT => 1},
|
||||
{ERR=>"$prog: too few X's in template `foo.XX'\n"}],
|
||||
{ERR=>"$prog: too few X's in template 'foo.XX'\n"}],
|
||||
['too-few-xq', '-q foo.XX', {EXIT => 1} ],
|
||||
|
||||
['1f', 'bar.XXXX', {OUT => "bar.ZZZZ\n"},
|
||||
@@ -103,11 +103,11 @@ my @Tests =
|
||||
|
||||
# Test bad templates
|
||||
['invalid-tl', '-t a/bXXXX',
|
||||
{ERR=>"$prog: invalid template, `a/bXXXX', "
|
||||
{ERR=>"$prog: invalid template, 'a/bXXXX', "
|
||||
. "contains directory separator\n"}, {EXIT => 1} ],
|
||||
|
||||
['invalid-t2', '--tmpdir=a /bXXXX',
|
||||
{ERR=>"$prog: invalid template, `/bXXXX'; "
|
||||
{ERR=>"$prog: invalid template, '/bXXXX'; "
|
||||
. "with --tmpdir, it may not be absolute\n"}, {EXIT => 1} ],
|
||||
|
||||
# Suffix after X.
|
||||
@@ -144,17 +144,17 @@ my @Tests =
|
||||
check_tmp $f, 'F'; }}],
|
||||
|
||||
['suffix5f', '--suffix /b aXXXX', {EXIT=>1},
|
||||
{ERR=>"$prog: invalid suffix `/b', contains directory separator\n"}],
|
||||
{ERR=>"$prog: invalid suffix '/b', contains directory separator\n"}],
|
||||
|
||||
['suffix6f', 'aXXXX/b', {EXIT=>1},
|
||||
{ERR=>"$prog: invalid suffix `/b', contains directory separator\n"}],
|
||||
{ERR=>"$prog: invalid suffix '/b', contains directory separator\n"}],
|
||||
['suffix6f-q', '-q aXXXX/b', {EXIT=>1}],
|
||||
|
||||
['suffix7f', '--suffix= aXXXXb', {EXIT=>1},
|
||||
{ERR=>"$prog: with --suffix, template `aXXXXb' must end in X\n"}],
|
||||
{ERR=>"$prog: with --suffix, template 'aXXXXb' must end in X\n"}],
|
||||
['suffix7f-q', '-q --suffix= aXXXXb', {EXIT=>1}],
|
||||
['suffix7d', '-d --suffix=aXXXXb ""', {EXIT=>1},
|
||||
{ERR=>"$prog: with --suffix, template `' must end in X\n"}],
|
||||
{ERR=>"$prog: with --suffix, template '' must end in X\n"}],
|
||||
|
||||
['suffix8f', 'aXXXX --suffix=b', {OUT=>"aZZZZb\n"},
|
||||
{OUT_SUBST=>'s,^a....,aZZZZ,'},
|
||||
@@ -167,9 +167,9 @@ my @Tests =
|
||||
. "Try '$prog --help' for more information.\n"}],
|
||||
|
||||
['suffix10f', 'aXXb', {EXIT => 1},
|
||||
{ERR=>"$prog: too few X's in template `aXXb'\n"}],
|
||||
{ERR=>"$prog: too few X's in template 'aXXb'\n"}],
|
||||
['suffix10d', '-d --suffix=X aXX', {EXIT => 1},
|
||||
{ERR=>"$prog: too few X's in template `aXXX'\n"}],
|
||||
{ERR=>"$prog: too few X's in template 'aXXX'\n"}],
|
||||
|
||||
['suffix11f', '--suffix=.txt', {OUT=>"./tmp.ZZZZZZZZZZ.txt\n"},
|
||||
{ENV=>"TMPDIR=."},
|
||||
|
@@ -50,9 +50,9 @@ rm -f nohup.out err exp
|
||||
# change depending on whether stderr is redirected.
|
||||
nohup sh -c 'echo stdout; echo stderr 1>&2' >out || fail=1
|
||||
if test -t 2; then
|
||||
test "`cat out|tr '\n' -`" = stdout-stderr- || fail=1
|
||||
test "'cat out|tr '\n' -`" = stdout-stderr- || fail=1
|
||||
else
|
||||
test "`cat out|tr '\n' -`" = stdout- || fail=1
|
||||
test "'cat out|tr '\n' -`" = stdout- || fail=1
|
||||
fi
|
||||
# It must *not* exist.
|
||||
test -f nohup.out && fail=1
|
||||
|
@@ -32,7 +32,7 @@ my $proc_file = '/proc/version';
|
||||
# Count the bytes in $proc_file, _by reading_.
|
||||
my $len = 0;
|
||||
open FH, '<', $proc_file
|
||||
or die "$program_name: can't open `$proc_file' for reading: $!\n";
|
||||
or die "$program_name: can't open '$proc_file' for reading: $!\n";
|
||||
while (defined (my $line = <FH>))
|
||||
{
|
||||
$len += length $line;
|
||||
|
@@ -83,7 +83,7 @@ my @Tests =
|
||||
{OUT=>"inaccurate"}, {OUT_SUBST => 's/\d+/inaccurate/'},
|
||||
{ERR=>"$prog: 9...9\n"}, {ERR_SUBST => 's/9+.*/9...9/'}],
|
||||
['excess', 'B 1', {OUT=>'B'},
|
||||
{ERR=>"$prog: warning: ignoring excess arguments, starting with `1'\n"}],
|
||||
{ERR=>"$prog: warning: ignoring excess arguments, starting with '1'\n"}],
|
||||
['percent', '%%', {OUT=>'%'}],
|
||||
['d-sp', q('% d' 33), {OUT=>' 33'}],
|
||||
['d-plus', q('%+d' 33), {OUT=>'+33'}],
|
||||
|
@@ -82,20 +82,20 @@ my @Tests =
|
||||
|
||||
# In coreutils-[6.0..6.9], this would mistakenly succeed and print "%Lg".
|
||||
['fmt-c', qw(-f %%g 1), {EXIT => 1},
|
||||
{ERR => "seq: format `%%g' has no % directive\n"}],
|
||||
{ERR => "seq: format '%%g' has no % directive\n"}],
|
||||
|
||||
# In coreutils-6.9..6.10, this would fail with an erroneous diagnostic:
|
||||
# "seq: memory exhausted". In coreutils-6.0..6.8, it would mistakenly
|
||||
# succeed and print a blank line.
|
||||
['fmt-eos1', qw(-f % 1), {EXIT => 1},
|
||||
{ERR => "seq: format `%' ends in %\n"}],
|
||||
{ERR => "seq: format '%' ends in %\n"}],
|
||||
['fmt-eos2', qw(-f %g% 1), {EXIT => 1},
|
||||
{ERR => "seq: format `%g%' has too many % directives\n"}],
|
||||
{ERR => "seq: format '%g%' has too many % directives\n"}],
|
||||
|
||||
['fmt-d', qw(-f "" 1), {EXIT => 1},
|
||||
{ERR => "seq: format `' has no % directive\n"}],
|
||||
{ERR => "seq: format '' has no % directive\n"}],
|
||||
['fmt-e', qw(-f %g%g 1), {EXIT => 1},
|
||||
{ERR => "seq: format `%g%g' has too many % directives\n"}],
|
||||
{ERR => "seq: format '%g%g' has too many % directives\n"}],
|
||||
|
||||
# With coreutils-6.12 and earlier, with a UTF8 numeric locale that uses
|
||||
# something other than "." as the decimal point, this use of seq would
|
||||
|
@@ -495,8 +495,8 @@ sub binary_expand ($$)
|
||||
defined $n && defined $b or die "$test_name: too few args\n";
|
||||
my @a = split ' ', $rest, $n + 1;
|
||||
my $caret = pop @a;
|
||||
$caret eq '^' or die "test $test_name: @a missing `^'\n";
|
||||
$b eq '1' || $b eq '0' or die "test $test_name: bad `b'=$b\n";
|
||||
$caret eq '^' or die "test $test_name: @a missing '^'\n";
|
||||
$b eq '1' || $b eq '0' or die "test $test_name: bad 'b'=$b\n";
|
||||
my $n_bad = @a;
|
||||
@a == $n or
|
||||
die "test $test_name: wrong number of args (expected $n, found $n_bad)\n";
|
||||
|
@@ -71,7 +71,7 @@ my @Tests =
|
||||
["h6", '-h', {IN=>"1GiB\n1030MiB\n"}, {OUT=>"1030MiB\n1GiB\n"}],
|
||||
# check option incompatibility
|
||||
["h7", '-hn', {IN=>""}, {OUT=>""}, {EXIT=>2},
|
||||
{ERR=>"$prog: options `-hn' are incompatible\n"}],
|
||||
{ERR=>"$prog: options '-hn' are incompatible\n"}],
|
||||
# check key processing
|
||||
["h8", '-n -k2,2h', {IN=>"1 1E\n2 2M\n"}, {OUT=>"2 2M\n1 1E\n"}],
|
||||
# SI and IEC prefixes on separate keys allowed
|
||||
@@ -105,13 +105,13 @@ my @Tests =
|
||||
["03c", '-k1 -k2', {IN=>"A b\nA a\n"}, {OUT=>"A a\nA b\n"}],
|
||||
# Fail with a diagnostic when -k specifies field == 0.
|
||||
["03d", '-k0', {EXIT=>2},
|
||||
{ERR=>"$prog: -: invalid field specification `0'\n"},
|
||||
{ERR=>"$prog: -: invalid field specification '0'\n"},
|
||||
$normalize_filename],
|
||||
# Fail with a diagnostic when -k specifies character == 0.
|
||||
["03e", '-k1.0', {EXIT=>2},
|
||||
{ERR=>"$prog: character offset is zero: invalid field specification `1.0'\n"}],
|
||||
{ERR=>"$prog: character offset is zero: invalid field specification '1.0'\n"}],
|
||||
["03f", '-k1.1,-k0', {EXIT=>2},
|
||||
{ERR=>"$prog: invalid number after `,': invalid count at start of `-k0'\n"}],
|
||||
{ERR=>"$prog: invalid number after ',': invalid count at start of '-k0'\n"}],
|
||||
# This is ok.
|
||||
["03g", '-k1.1,1.0', {IN=>''}],
|
||||
# This is equivalent to 3f.
|
||||
@@ -158,10 +158,10 @@ my @Tests =
|
||||
#
|
||||
# report an error for '.' without following char spec
|
||||
["08a", '-k 2.,3', {EXIT=>2},
|
||||
{ERR=>"$prog: invalid number after `.': invalid count at start of `,3'\n"}],
|
||||
{ERR=>"$prog: invalid number after '.': invalid count at start of ',3'\n"}],
|
||||
# report an error for ',' without following POS2
|
||||
["08b", '-k 2,', {EXIT=>2},
|
||||
{ERR=>"$prog: invalid number after `,': invalid count at start of `'\n"}],
|
||||
{ERR=>"$prog: invalid number after ',': invalid count at start of ''\n"}],
|
||||
#
|
||||
# Test new -g option.
|
||||
["09a", '-g', {IN=>"1e2\n2e1\n"}, {OUT=>"2e1\n1e2\n"}],
|
||||
@@ -334,19 +334,19 @@ my @Tests =
|
||||
|
||||
# Specifying incompatible options should evoke a failure.
|
||||
["incompat1", '-in', {EXIT=>2},
|
||||
{ERR=>"$prog: options `-in' are incompatible\n"}],
|
||||
{ERR=>"$prog: options '-in' are incompatible\n"}],
|
||||
["incompat2", '-nR', {EXIT=>2},
|
||||
{ERR=>"$prog: options `-nR' are incompatible\n"}],
|
||||
{ERR=>"$prog: options '-nR' are incompatible\n"}],
|
||||
["incompat3", '-dfgiMnR', {EXIT=>2},
|
||||
{ERR=>"$prog: options `-dfgMnR' are incompatible\n"}],
|
||||
{ERR=>"$prog: options '-dfgMnR' are incompatible\n"}],
|
||||
["incompat4", qw(-c -o /dev/null), {EXIT=>2},
|
||||
{ERR=>"$prog: options `-co' are incompatible\n"}],
|
||||
{ERR=>"$prog: options '-co' are incompatible\n"}],
|
||||
["incompat5", qw(-C -o /dev/null), {EXIT=>2},
|
||||
{ERR=>"$prog: options `-Co' are incompatible\n"}],
|
||||
{ERR=>"$prog: options '-Co' are incompatible\n"}],
|
||||
["incompat6", '-cC', {EXIT=>2},
|
||||
{ERR=>"$prog: options `-cC' are incompatible\n"}],
|
||||
{ERR=>"$prog: options '-cC' are incompatible\n"}],
|
||||
["incompat7", qw(--sort=random -n), {EXIT=>2},
|
||||
{ERR=>"$prog: options `-nR' are incompatible\n"}],
|
||||
{ERR=>"$prog: options '-nR' are incompatible\n"}],
|
||||
|
||||
# -t '\0' is accepted, as of coreutils-5.0.91
|
||||
['nul-tab', "-k2,2 -t '\\0'",
|
||||
|
@@ -35,7 +35,7 @@ EOF
|
||||
|
||||
chmod +x gzip
|
||||
|
||||
# Ensure 'sort` is immune to parent's SIGCHLD handler
|
||||
# Ensure 'sort' is immune to parent's SIGCHLD handler
|
||||
# Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh.
|
||||
(
|
||||
# ash doesn't support "trap '' CHLD"; it knows only signal numbers.
|
||||
|
@@ -30,14 +30,14 @@ my @Tests =
|
||||
(
|
||||
# invalid extra command line argument
|
||||
['f-extra-arg', '--files0-from=- no-such', {IN=>"a"}, {EXIT=>2},
|
||||
{ERR => "$prog: extra operand `no-such'\n"
|
||||
{ERR => "$prog: extra operand 'no-such'\n"
|
||||
. "file operands cannot be combined with --files0-from\n"
|
||||
. "Try '$prog --help' for more information.\n"}
|
||||
],
|
||||
|
||||
# missing input file
|
||||
['missing', '--files0-from=missing', {EXIT=>2},
|
||||
{ERR => "$prog: cannot open `missing' for reading: "
|
||||
{ERR => "$prog: cannot open 'missing' for reading: "
|
||||
. "No such file or directory\n"}],
|
||||
|
||||
# input file name of '-'
|
||||
@@ -51,7 +51,7 @@ my @Tests =
|
||||
|
||||
# empty input, from non-regular file
|
||||
['empty-nonreg', '--files0-from=/dev/null', {EXIT=>2},
|
||||
{ERR => "$prog: no input from `/dev/null'\n"}],
|
||||
{ERR => "$prog: no input from '/dev/null'\n"}],
|
||||
|
||||
# one NUL
|
||||
['nul-1', '--files0-from=-', '<', {IN=>"\0"}, {EXIT=>2},
|
||||
|
@@ -42,12 +42,12 @@ my @Tests =
|
||||
|
||||
# check validation of --batch-size option
|
||||
['nmerge-0', "-m --batch-size=0", @inputs,
|
||||
{ERR=>"$prog: invalid --batch-size argument `0'\n".
|
||||
"$prog: minimum --batch-size argument is `2'\n"}, {EXIT=>2}],
|
||||
{ERR=>"$prog: invalid --batch-size argument '0'\n".
|
||||
"$prog: minimum --batch-size argument is '2'\n"}, {EXIT=>2}],
|
||||
|
||||
['nmerge-1', "-m --batch-size=1", @inputs,
|
||||
{ERR=>"$prog: invalid --batch-size argument `1'\n".
|
||||
"$prog: minimum --batch-size argument is `2'\n"}, {EXIT=>2}],
|
||||
{ERR=>"$prog: invalid --batch-size argument '1'\n".
|
||||
"$prog: minimum --batch-size argument is '2'\n"}, {EXIT=>2}],
|
||||
|
||||
['nmerge-neg', "-m --batch-size=-1", @inputs,
|
||||
{ERR=>"$prog: invalid --batch-size argument '-1'\n"}, {EXIT=>2}],
|
||||
@@ -57,7 +57,7 @@ my @Tests =
|
||||
|
||||
['nmerge-big', "-m --batch-size=$bigint", @inputs,
|
||||
{ERR_SUBST=>'s/(current rlimit is) \d+/$1/'},
|
||||
{ERR=>"$prog: --batch-size argument `$bigint' too large\n".
|
||||
{ERR=>"$prog: --batch-size argument '$bigint' too large\n".
|
||||
"$prog: maximum --batch-size argument with current rlimit is\n"},
|
||||
{EXIT=>2}],
|
||||
|
||||
@@ -68,7 +68,7 @@ my @Tests =
|
||||
# temp files are needed
|
||||
['nmerge-no', "-m --batch-size=2 -T$badtmp", @inputs,
|
||||
{ERR_SUBST=>"s|': .*|':|"},
|
||||
{ERR=>"$prog: cannot create temporary file in `$badtmp':\n"},
|
||||
{ERR=>"$prog: cannot create temporary file in '$badtmp':\n"},
|
||||
{EXIT=>2}],
|
||||
|
||||
# This used to fail because setting batch-size without also setting
|
||||
|
@@ -96,7 +96,7 @@ retry_delay_ stdbuf_unbuffer .1 6 || fail=1
|
||||
# One could remove the need for dd (used to close the fifo to get uniq to quit
|
||||
# early), if head -n1 read stdin char by char. Note uniq | head -c2 doesn't
|
||||
# suffice due to the buffering implicit in the pipe. sed currently does read
|
||||
# stdin char by char, so we can test with 'sed 1q`. However I'm wary about
|
||||
# stdin char by char, so we can test with 'sed 1q'. However I'm wary about
|
||||
# adding this dependency on a program outside of coreutils.
|
||||
# printf '2\n' > exp
|
||||
# printf '1\n2\n' | (stdbuf -i0 sed 1q >/dev/null; cat) > out
|
||||
|
@@ -67,7 +67,7 @@ my @Tests =
|
||||
['pipe-bad-tmpdir',
|
||||
{ENV => "TMPDIR=$bad_dir"},
|
||||
{IN_PIPE => "a\n"},
|
||||
{ERR_SUBST => "s,`$bad_dir': .*,...,"},
|
||||
{ERR_SUBST => "s,'$bad_dir': .*,...,"},
|
||||
{ERR => "$prog: failed to create temporary file in ...\n"},
|
||||
{EXIT => 1}],
|
||||
|
||||
|
@@ -56,13 +56,13 @@ my @tv = (
|
||||
['obs-b', '-b', "x\n" x (512 * 10 / 2 + 1), "x\n" x (512 * 10 / 2), 0],
|
||||
|
||||
['err-1', '+cl', '', '', 1,
|
||||
"$prog: cannot open `+cl' for reading: No such file or directory\n"],
|
||||
"$prog: cannot open '+cl' for reading: No such file or directory\n"],
|
||||
|
||||
['err-2', '-cl', '', '', 1,
|
||||
"$prog: l: invalid number of bytes\n"],
|
||||
|
||||
['err-3', '+2cz', '', '', 1,
|
||||
"$prog: cannot open `+2cz' for reading: No such file or directory\n"],
|
||||
"$prog: cannot open '+2cz' for reading: No such file or directory\n"],
|
||||
|
||||
# This should get 'tail: invalid option -- 2'
|
||||
['err-4', '-2cX', '', '', 1,
|
||||
|
@@ -175,7 +175,7 @@ my @Tests =
|
||||
['lt-5', "$limits->{INTMAX_UFLOW} -lt $limits->{UINTMAX_OFLOW}"],
|
||||
|
||||
['inv-1', qw(0x0 -eq 00), {EXIT=>2},
|
||||
{ERR=>"$prog: invalid integer `0x0'\n"}],
|
||||
{ERR=>"$prog: invalid integer '0x0'\n"}],
|
||||
|
||||
['t1', "-t"],
|
||||
['t2', qw(-t 1), {EXIT=>1}],
|
||||
|
@@ -27,7 +27,7 @@ my $prog = "$ENV{abs_top_builddir}/src/test";
|
||||
my @Tests =
|
||||
(
|
||||
# In coreutils-5.93, this diagnostic lacked the newline.
|
||||
['o', '-o arg', {ERR => "test: extra argument `-o'\n"},
|
||||
['o', '-o arg', {ERR => "test: extra argument '-o'\n"},
|
||||
{ERR_SUBST => 's!^.*:!test:!'},
|
||||
{EXIT => 2}],
|
||||
);
|
||||
|
@@ -42,7 +42,7 @@ test $? = 124 || fail=1
|
||||
timeout -s0 -k1 1 sleep 10
|
||||
test $? = 124 && fail=1
|
||||
|
||||
# Ensure 'timeout` is immune to parent's SIGCHLD handler
|
||||
# Ensure 'timeout' is immune to parent's SIGCHLD handler
|
||||
# Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh.
|
||||
(
|
||||
# ash doesn't support "trap '' CHLD"; it knows only signal numbers.
|
||||
|
@@ -112,7 +112,7 @@ my @Tests =
|
||||
['rep-3', qw('a[b*513]c' '1[x*]2'), {IN=>'abc'}, {OUT=>'1x2'}],
|
||||
# Another couple octal repeat count tests.
|
||||
['o-rep-1', qw('[b*08]' '[x*]'), {IN=>''}, {OUT=>''}, {EXIT=>1},
|
||||
{ERR=>"$prog: invalid repeat count `08' in [c*n] construct\n"}],
|
||||
{ERR=>"$prog: invalid repeat count '08' in [c*n] construct\n"}],
|
||||
['o-rep-2', qw('[b*010]cd' '[a*7]BC[x*]'), {IN=>'bcd'}, {OUT=>'BCx'}],
|
||||
|
||||
['esc', qw('a\-z' A-Z), {IN=>'abc-z'}, {OUT=>'AbcBC'}],
|
||||
@@ -141,9 +141,9 @@ my @Tests =
|
||||
# Ensure that these fail.
|
||||
# Prior to 2.0.20, each would evoke a failed assertion.
|
||||
['empty-eq', qw('[==]' x), {IN=>''}, {OUT=>''}, {EXIT=>1},
|
||||
{ERR=>"$prog: missing equivalence class character `[==]'\n"}],
|
||||
{ERR=>"$prog: missing equivalence class character '[==]'\n"}],
|
||||
['empty-cc', qw('[::]' x), {IN=>''}, {OUT=>''}, {EXIT=>1},
|
||||
{ERR=>"$prog: missing character class name `[::]'\n"}],
|
||||
{ERR=>"$prog: missing character class name '[::]'\n"}],
|
||||
|
||||
# Weird repeat counts.
|
||||
['repeat-bs-9', qw(abc '[b*\9]'), {IN=>'abcd'}, {OUT=>'[b*d'}],
|
||||
|
@@ -54,7 +54,7 @@ my @Tests =
|
||||
|
||||
['only-one', {IN => {f => ""}}, {IN => {g => ""}},
|
||||
{EXIT => 1},
|
||||
{ERR => "tsort: extra operand `g'\n"
|
||||
{ERR => "tsort: extra operand 'g'\n"
|
||||
. "Try 'tsort --help' for more information.\n"}],
|
||||
);
|
||||
|
||||
|
@@ -67,7 +67,7 @@ $@
|
||||
my $exp = new Expect;
|
||||
$exp->log_user(0);
|
||||
$exp->spawn("$cmd 2> $stderr")
|
||||
or (warn "$ME: cannot run `$cmd': $!\n"), $fail=1, next;
|
||||
or (warn "$ME: cannot run '$cmd': $!\n"), $fail=1, next;
|
||||
# No input for cut -f2.
|
||||
$cmd =~ /^cut/
|
||||
or $exp->send("a b\n");
|
||||
|
@@ -30,14 +30,14 @@ my @Tests =
|
||||
(
|
||||
# invalid extra command line argument
|
||||
['f-extra-arg', '--files0-from=- no-such', {IN=>"a"}, {EXIT=>1},
|
||||
{ERR => "$prog: extra operand `no-such'\n"
|
||||
{ERR => "$prog: extra operand 'no-such'\n"
|
||||
. "file operands cannot be combined with --files0-from\n"
|
||||
. "Try '$prog --help' for more information.\n"}
|
||||
],
|
||||
|
||||
# missing input file
|
||||
['missing', '--files0-from=missing', {EXIT=>1},
|
||||
{ERR => "$prog: cannot open `missing' for reading: "
|
||||
{ERR => "$prog: cannot open 'missing' for reading: "
|
||||
. "No such file or directory\n"}],
|
||||
|
||||
# input file name of '-'
|
||||
|
@@ -39,7 +39,7 @@ my @Tests =
|
||||
{ERR=>"$prog: invalid --pages argument 'x'\n"}],
|
||||
|
||||
['inv-pg-range', "--pages=9x", {EXIT => 1},
|
||||
{ERR=>"$prog: invalid page range `9x'\n"}],
|
||||
{ERR=>"$prog: invalid page range '9x'\n"}],
|
||||
);
|
||||
|
||||
my $save_temps = $ENV{DEBUG};
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
# Ensure that using `cp --preserve=link' to copy hard-linked arguments
|
||||
# Ensure that using 'cp --preserve=link' to copy hard-linked arguments
|
||||
# onto existing destinations works, even when one of the link operations fails.
|
||||
|
||||
# Copyright (C) 2003, 2006-2012 Free Software Foundation, Inc.
|
||||
|
@@ -30,7 +30,7 @@ my @Tests =
|
||||
# Make sure a 'n' reply to 'mv -i...' aborts the move operation.
|
||||
[$test_a, '-i',
|
||||
{IN => {src => "a\n"}}, {IN => {dst => "b\n"}}, '<', {IN => "n\n"},
|
||||
{ERR => "mv: overwrite `dst'? "},
|
||||
{ERR => "mv: overwrite 'dst'? "},
|
||||
{POST => sub { -r 'src' or die "test $test_a failed\n"}},
|
||||
{EXIT => 0},
|
||||
],
|
||||
|
@@ -334,7 +334,7 @@ my @tv = (
|
||||
['14g', '-2 -S -f', [\'t_notab'], [\'2-Sf-t_notab'], 0],
|
||||
# full lines, no truncation / separator = TAB : (Input: -S"<TAB>")
|
||||
['14h', '-2 -S" " -J -f', [\'t_notab'], [\'2sf-t_notab'], 0],
|
||||
# columns, truncated = 72 / separator `:' :
|
||||
# columns, truncated = 72 / separator ':' :
|
||||
['14i', '-2 -S: -f', [\'t_notab'], [\'2-S_f-t_notab'], 0],
|
||||
# full lines, no truncation / separator = `:' :
|
||||
['14j', '-2 -S: -J -f', [\'t_notab'], [\'2s_f-t_notab'], 0],
|
||||
@@ -385,7 +385,7 @@ my @tv = (
|
||||
['col-long', '-W3 -t -1 --columns=2', "a\nb\nc\n", "a c\nb\n", 0],
|
||||
# Make sure these fail.
|
||||
['col-0', '-0', '', '', 1,
|
||||
"$prog: invalid number of columns: `0'\n"],
|
||||
"$prog: invalid number of columns: '0'\n"],
|
||||
['col-inval', '-'.'9'x100, '', '', 1,
|
||||
"$prog: invalid number of columns: `". ('9'x100) ."'\n"],
|
||||
|
||||
|
@@ -38,7 +38,7 @@ k200=$k20$k20$k20$k20$k20$k20$k20$k20$k20$k20
|
||||
k_deep=$k200$k200
|
||||
|
||||
t=t
|
||||
# Create a directory in $t with lots of `k' components.
|
||||
# Create a directory in $t with lots of 'k' components.
|
||||
deep=$t$k_deep
|
||||
mkdir -p $deep || fail=1
|
||||
|
||||
|
@@ -44,10 +44,10 @@ my @Tests =
|
||||
# test-name options input expected-output
|
||||
#
|
||||
['empty-name-1', "''", {EXIT => 1},
|
||||
{ERR => "$prog: cannot remove `': No such file or directory\n"}],
|
||||
{ERR => "$prog: cannot remove '': No such file or directory\n"}],
|
||||
|
||||
['empty-name-2', "a '' b", {EXIT => 1},
|
||||
{ERR => "$prog: cannot remove `': No such file or directory\n"},
|
||||
{ERR => "$prog: cannot remove '': No such file or directory\n"},
|
||||
{PRE => sub { mk_file qw(a b) }},
|
||||
{POST => sub {-f 'a' || -f 'b' and die "a or b remain\n" }},
|
||||
],
|
||||
|
@@ -85,7 +85,7 @@ foreach my $dir (@dir_list)
|
||||
# expected exit code and diagnostic.
|
||||
my $cmd = "$rm -f -- $target_file";
|
||||
open RM, "$cmd 2>&1 |"
|
||||
or die "$ME: cannot execute `$cmd'\n";
|
||||
or die "$ME: cannot execute '$cmd'\n";
|
||||
|
||||
my $line = <RM>;
|
||||
|
||||
@@ -99,27 +99,27 @@ foreach my $dir (@dir_list)
|
||||
if ($rc == 0)
|
||||
{
|
||||
next if ! -e $target_file;
|
||||
die "$ME: unexpected exit status from `$cmd';\n"
|
||||
die "$ME: unexpected exit status from '$cmd';\n"
|
||||
. " got 0, expected 1\n";
|
||||
}
|
||||
if (0x80 < $rc)
|
||||
{
|
||||
my $status = $rc >> 8;
|
||||
$status == 1
|
||||
or die "$ME: unexpected exit status from `$cmd';\n"
|
||||
or die "$ME: unexpected exit status from '$cmd';\n"
|
||||
. " got $status, expected 1\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
# Terminated by a signal.
|
||||
my $sig_num = $rc & 0x7F;
|
||||
die "$ME: command `$cmd' died with signal $sig_num\n";
|
||||
die "$ME: command '$cmd' died with signal $sig_num\n";
|
||||
}
|
||||
|
||||
my $exp = "rm: cannot remove `$target_file':";
|
||||
my $exp = "rm: cannot remove '$target_file':";
|
||||
$line
|
||||
or die "$ME: no output from `$cmd';\n"
|
||||
. "expected something like `$exp ...'\n";
|
||||
or die "$ME: no output from '$cmd';\n"
|
||||
. "expected something like '$exp ...'\n";
|
||||
|
||||
# Transform the actual diagnostic so that it starts with "rm:".
|
||||
# Depending on your system, it might be "rm:" already, or
|
||||
@@ -128,7 +128,7 @@ foreach my $dir (@dir_list)
|
||||
|
||||
my $regex = quotemeta $exp;
|
||||
$line =~ /^$regex/
|
||||
or die "$ME: unexpected diagnostic from `$cmd';\n"
|
||||
or die "$ME: unexpected diagnostic from '$cmd';\n"
|
||||
. " got $line"
|
||||
. " expected $exp ...\n";
|
||||
|
||||
|
@@ -29,7 +29,7 @@ chown -R $NON_ROOT_USERNAME d || framework_failure_
|
||||
chmod go=x . || framework_failure_
|
||||
|
||||
|
||||
# This must fail, since `.' is not writable by $NON_ROOT_USERNAME.
|
||||
# This must fail, since '.' is not writable by $NON_ROOT_USERNAME.
|
||||
setuidgid $NON_ROOT_USERNAME env PATH="$PATH" rm -rf d 2>/dev/null && fail=1
|
||||
|
||||
# d must remain.
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
# show that `split --lines=2' works.
|
||||
# show that 'split --lines=2' works.
|
||||
|
||||
# Copyright (C) 2002, 2006-2012 Free Software Foundation, Inc.
|
||||
|
||||
|
Reference in New Issue
Block a user