diff options
Diffstat (limited to 'tests')
46 files changed, 855 insertions, 855 deletions
diff --git a/tests/Coreutils.pm b/tests/Coreutils.pm index 544747673..fb3d0a227 100644 --- a/tests/Coreutils.pm +++ b/tests/Coreutils.pm @@ -29,7 +29,7 @@ use File::Compare qw(compare); my $debug = $ENV{DEBUG}; my @Types = qw (IN IN_PIPE OUT ERR AUX CMP EXIT PRE POST OUT_SUBST - ERR_SUBST ENV ENV_DEL); + ERR_SUBST ENV ENV_DEL); my %Types = map {$_ => 1} @Types; my %Zero_one_type = map {$_ => 1} qw (OUT ERR EXIT PRE POST OUT_SUBST ERR_SUBST ENV); @@ -135,7 +135,7 @@ sub _compare_files ($$$$$) { my $info = (defined $in_or_out ? "std$in_or_out " : ''); warn "$program_name: test $test_name: ${info}mismatch, comparing " - . "$actual (actual) and $expected (expected)\n"; + . "$actual (actual) and $expected (expected)\n"; # Ignore any failure, discard stderr. system "diff -c $actual $expected 2>/dev/null"; } @@ -156,14 +156,14 @@ sub _process_file_spec ($$$$$) { my $n = keys %$file_spec; die "$program_name: $test_name: $type spec has $n elements --" - . " expected 1\n" - if $n != 1; + . " expected 1\n" + if $n != 1; ($file_name, $contents) = each %$file_spec; # This happens for the AUX hash in an io_spec like this: # {CMP=> ['zy123utsrqponmlkji', {'@AUX@'=> undef}]}, defined $contents - or return $file_name; + or return $file_name; } else { @@ -171,10 +171,10 @@ sub _process_file_spec ($$$$$) } my $is_junk_file = (! defined $file_name - || (($type eq 'IN' || $type eq 'AUX' || $type eq 'CMP') - && defined $contents)); + || (($type eq 'IN' || $type eq 'AUX' || $type eq 'CMP') + && defined $contents)); my $file = _create_file ($program_name, $test_name, - $file_name, $contents); + $file_name, $contents); if ($is_junk_file) { @@ -184,8 +184,8 @@ sub _process_file_spec ($$$$$) { # FIXME: put $srcdir in here somewhere warn "$program_name: $test_name: specified file `$file' does" - . " not exist\n" - if ! -f "$srcdir/$file"; + . " not exist\n" + if ! -f "$srcdir/$file"; } return $file; @@ -198,8 +198,8 @@ sub _at_replace ($$) { my $f = $map->{$eo}; $f - and $s =~ /\@$eo\@/ - and $s =~ s/\@$eo\@/$f/g; + and $s =~ /\@$eo\@/ + and $s =~ s/\@$eo\@/$f/g; } return $s; } @@ -241,33 +241,33 @@ sub run_tests ($$$$$) { my $test_name = $t->[0]; if ($seen{$test_name}) - { - warn "$program_name: $test_name: duplicate test name\n"; - $bad_test_name = 1; - } + { + warn "$program_name: $test_name: duplicate test name\n"; + $bad_test_name = 1; + } $seen{$test_name} = 1; if (0) - { - my $t8 = lc substr $test_name, 0, 8; - if ($seen_8dot3{$t8}) - { - warn "$program_name: 8.3 test name conflict: " - . "$test_name, $seen_8dot3{$t8}\n"; - $bad_test_name = 1; - } - $seen_8dot3{$t8} = $test_name; - } + { + my $t8 = lc substr $test_name, 0, 8; + if ($seen_8dot3{$t8}) + { + warn "$program_name: 8.3 test name conflict: " + . "$test_name, $seen_8dot3{$t8}\n"; + $bad_test_name = 1; + } + $seen_8dot3{$t8} = $test_name; + } # The test name may be no longer than 30 bytes. # Yes, this is an arbitrary limit. If it causes trouble, # consider removing it. my $max = 30; if ($max < length $test_name) - { - warn "$program_name: $test_name: test name is too long (> $max)\n"; - $bad_test_name = 1; - } + { + warn "$program_name: $test_name: test name is too long (> $max)\n"; + $bad_test_name = 1; + } } return 1 if $bad_test_name; @@ -294,150 +294,150 @@ sub run_tests ($$$$$) my $env_prefix = ''; my $input_pipe_cmd; foreach $io_spec (@$t) - { - if (!ref $io_spec) - { - push @args, $io_spec; - next; - } - - if (ref $io_spec ne 'HASH') - { - eval 'use Data::Dumper'; - die "$program_name: $test_name: invalid entry in test spec; " - . "expected HASH-ref,\nbut got this:\n" - . Data::Dumper->Dump ([\$io_spec], ['$io_spec']) . "\n"; - } - - my $n = keys %$io_spec; - die "$program_name: $test_name: spec has $n elements --" - . " expected 1\n" - if $n != 1; - my ($type, $val) = each %$io_spec; - 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. - die "$program_name: $test_name: more than one $type spec\n" - if $Zero_one_type{$type} and $seen_type{$type}++; - - if ($type eq 'PRE' or $type eq 'POST') - { - $expect->{$type} = $val; - next; - } - - if ($type eq 'CMP') - { - my $t = ref $val; - $t && $t eq 'ARRAY' - or die "$program_name: $test_name: invalid CMP spec\n"; - @$val == 2 - or die "$program_name: $test_name: invalid CMP list; must have" - . " exactly 2 elements\n"; - my @cmp_files; - foreach my $e (@$val) - { - my $r = ref $e; - $r && $r ne 'HASH' - and die "$program_name: $test_name: invalid element ($r)" - . " in CMP list; only scalars and hash references " - . "are allowed\n"; - if ($r && $r eq 'HASH') - { - my $n = keys %$e; - $n == 1 - or die "$program_name: $test_name: CMP spec has $n " - . "elements -- expected 1\n"; - - # 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) - { - $e->{$new_ff} = $val; - delete $e->{$ff}; - } - } - my $cmp_file = _process_file_spec ($program_name, $test_name, - $e, $type, \@junk_files); - push @cmp_files, $cmp_file; - } - push @post_compare, [@cmp_files]; - - $expect->{$type} = $val; - next; - } - - if ($type eq 'EXIT') - { - die "$program_name: $test_name: invalid EXIT code\n" - if $val !~ /^\d+$/; - # FIXME: make sure $data is numeric - $expect->{EXIT} = $val; - next; - } - - if ($type =~ /^(OUT|ERR)_SUBST$/) - { - $expect->{RESULT_SUBST} ||= {}; - $expect->{RESULT_SUBST}->{$1} = $val; - next; - } - - if ($type eq 'ENV') - { - $env_prefix = "$val "; - next; - } - - if ($type eq 'ENV_DEL') - { - push @env_delete, $val; - next; - } - - my $file = _process_file_spec ($program_name, $test_name, $val, - $type, \@junk_files); - - if ($type eq 'IN' || $type eq 'IN_PIPE') - { - my $quoted_file = _shell_quote $file; - if ($type eq 'IN_PIPE') - { - defined $input_pipe_cmd - and die "$program_name: $test_name: only one input" - . " may be specified with IN_PIPE\n"; - $input_pipe_cmd = "cat $quoted_file |"; - } - else - { - push @args, $quoted_file; - } - } - elsif ($type eq 'AUX' || $type eq 'OUT' || $type eq 'ERR') - { - $expect->{$type} = $file; - } - else - { - die "$program_name: $test_name: invalid type: $type\n" - } - } + { + if (!ref $io_spec) + { + push @args, $io_spec; + next; + } + + if (ref $io_spec ne 'HASH') + { + eval 'use Data::Dumper'; + die "$program_name: $test_name: invalid entry in test spec; " + . "expected HASH-ref,\nbut got this:\n" + . Data::Dumper->Dump ([\$io_spec], ['$io_spec']) . "\n"; + } + + my $n = keys %$io_spec; + die "$program_name: $test_name: spec has $n elements --" + . " expected 1\n" + if $n != 1; + my ($type, $val) = each %$io_spec; + 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. + die "$program_name: $test_name: more than one $type spec\n" + if $Zero_one_type{$type} and $seen_type{$type}++; + + if ($type eq 'PRE' or $type eq 'POST') + { + $expect->{$type} = $val; + next; + } + + if ($type eq 'CMP') + { + my $t = ref $val; + $t && $t eq 'ARRAY' + or die "$program_name: $test_name: invalid CMP spec\n"; + @$val == 2 + or die "$program_name: $test_name: invalid CMP list; must have" + . " exactly 2 elements\n"; + my @cmp_files; + foreach my $e (@$val) + { + my $r = ref $e; + $r && $r ne 'HASH' + and die "$program_name: $test_name: invalid element ($r)" + . " in CMP list; only scalars and hash references " + . "are allowed\n"; + if ($r && $r eq 'HASH') + { + my $n = keys %$e; + $n == 1 + or die "$program_name: $test_name: CMP spec has $n " + . "elements -- expected 1\n"; + + # 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) + { + $e->{$new_ff} = $val; + delete $e->{$ff}; + } + } + my $cmp_file = _process_file_spec ($program_name, $test_name, + $e, $type, \@junk_files); + push @cmp_files, $cmp_file; + } + push @post_compare, [@cmp_files]; + + $expect->{$type} = $val; + next; + } + + if ($type eq 'EXIT') + { + die "$program_name: $test_name: invalid EXIT code\n" + if $val !~ /^\d+$/; + # FIXME: make sure $data is numeric + $expect->{EXIT} = $val; + next; + } + + if ($type =~ /^(OUT|ERR)_SUBST$/) + { + $expect->{RESULT_SUBST} ||= {}; + $expect->{RESULT_SUBST}->{$1} = $val; + next; + } + + if ($type eq 'ENV') + { + $env_prefix = "$val "; + next; + } + + if ($type eq 'ENV_DEL') + { + push @env_delete, $val; + next; + } + + my $file = _process_file_spec ($program_name, $test_name, $val, + $type, \@junk_files); + + if ($type eq 'IN' || $type eq 'IN_PIPE') + { + my $quoted_file = _shell_quote $file; + if ($type eq 'IN_PIPE') + { + defined $input_pipe_cmd + and die "$program_name: $test_name: only one input" + . " may be specified with IN_PIPE\n"; + $input_pipe_cmd = "cat $quoted_file |"; + } + else + { + push @args, $quoted_file; + } + } + elsif ($type eq 'AUX' || $type eq 'OUT' || $type eq 'ERR') + { + $expect->{$type} = $file; + } + else + { + die "$program_name: $test_name: invalid type: $type\n" + } + } # Expect an exit status of zero if it's not specified. $expect->{EXIT} ||= 0; # Allow ERR to be omitted -- in that case, expect no error output. foreach my $eo (qw (OUT ERR)) - { - if (!exists $expect->{$eo}) - { - $expect->{$eo} = _create_file ($program_name, $test_name, - undef, ''); - push @junk_files, $expect->{$eo}; - } - } + { + if (!exists $expect->{$eo}) + { + $expect->{$eo} = _create_file ($program_name, $test_name, + undef, ''); + push @junk_files, $expect->{$eo}; + } + } # FIXME: Does it ever make sense to specify a filename *and* contents # in OUT or ERR spec? @@ -445,10 +445,10 @@ sub run_tests ($$$$$) # FIXME: this is really suboptimal... my @new_args; foreach my $a (@args) - { - $a = _at_replace $expect, $a; - push @new_args, $a; - } + { + $a = _at_replace $expect, $a; + push @new_args, $a; + } @args = @new_args; warn "$test_name...\n" if $verbose; @@ -459,112 +459,112 @@ sub run_tests ($$$$$) push @junk_files, $actual{OUT}, $actual{ERR}; my @cmd = (@prog, @args, "> $actual{OUT}", "2> $actual{ERR}"); $env_prefix - and unshift @cmd, $env_prefix; + and unshift @cmd, $env_prefix; defined $input_pipe_cmd - and unshift @cmd, $input_pipe_cmd; + and unshift @cmd, $input_pipe_cmd; my $cmd_str = join (' ', @cmd); # Delete from the environment any symbols specified by syntax # like this: {ENV_DEL => 'TZ'}. my %pushed_env; foreach my $env_sym (@env_delete) - { - my $val = delete $ENV{$env_sym}; - defined $val - and $pushed_env{$env_sym} = $val; - } + { + my $val = delete $ENV{$env_sym}; + defined $val + and $pushed_env{$env_sym} = $val; + } warn "Running command: `$cmd_str'\n" if $debug; my $rc = 0xffff & system $cmd_str; # Restore any environment setting we changed via a deletion. foreach my $env_sym (keys %pushed_env) - { - $ENV{$env_sym} = $pushed_env{$env_sym}; - } + { + $ENV{$env_sym} = $pushed_env{$env_sym}; + } if ($rc == 0xff00) - { - warn "$program_name: test $test_name failed: command failed:\n" - . " `$cmd_str': $!\n"; - $fail = 1; - goto cleanup; - } + { + warn "$program_name: test $test_name failed: command failed:\n" + . " `$cmd_str': $!\n"; + $fail = 1; + goto cleanup; + } $rc >>= 8 if $rc > 0x80; if ($expect->{EXIT} != $rc) - { - warn "$program_name: test $test_name failed: exit status mismatch:" - . " expected $expect->{EXIT}, got $rc\n"; - $fail = 1; - goto cleanup; - } + { + warn "$program_name: test $test_name failed: exit status mismatch:" + . " expected $expect->{EXIT}, got $rc\n"; + $fail = 1; + goto cleanup; + } my %actual_data; # Record actual stdout and stderr contents, if POST may need them. if ($expect->{POST}) - { - foreach my $eo (qw (OUT ERR)) - { - my $out_file = $actual{$eo}; - open IN, $out_file - or (warn "$program_name: cannot open $out_file for reading: $!\n"), - $fail = 1, next; - $actual_data{$eo} = <IN>; - close IN - or (warn "$program_name: failed to read $out_file: $!\n"), - $fail = 1; - } - } + { + foreach my $eo (qw (OUT ERR)) + { + my $out_file = $actual{$eo}; + open IN, $out_file + or (warn "$program_name: cannot open $out_file for reading: $!\n"), + $fail = 1, next; + $actual_data{$eo} = <IN>; + close IN + or (warn "$program_name: failed to read $out_file: $!\n"), + $fail = 1; + } + } foreach my $eo (qw (OUT ERR)) - { - my $subst_expr = $expect->{RESULT_SUBST}->{$eo}; - if (defined $subst_expr) - { - my $out = $actual{$eo}; - my $orig = "$out.orig"; - - # Move $out aside (to $orig), then recreate $out - # by transforming each line of $orig via $subst_expr. - rename $out, $orig - or (warn "$program_name: cannot rename $out to $orig: $!\n"), - $fail = 1, next; - open IN, $orig - or (warn "$program_name: cannot open $orig for reading: $!\n"), - $fail = 1, (unlink $orig), next; - unlink $orig - or (warn "$program_name: cannot unlink $orig: $!\n"), - $fail = 1; - open OUT, ">$out" - or (warn "$program_name: cannot open $out for writing: $!\n"), - $fail = 1, next; - while (defined (my $line = <IN>)) - { - eval "\$_ = \$line; $subst_expr; \$line = \$_"; - print OUT $line; - } - close IN; - close OUT - or (warn "$program_name: failed to write $out: $!\n"), - $fail = 1, next; - } - - my $eo_lower = lc $eo; - _compare_files ($program_name, $test_name, $eo_lower, - $actual{$eo}, $expect->{$eo}) - and $fail = 1; - } + { + my $subst_expr = $expect->{RESULT_SUBST}->{$eo}; + if (defined $subst_expr) + { + my $out = $actual{$eo}; + my $orig = "$out.orig"; + + # Move $out aside (to $orig), then recreate $out + # by transforming each line of $orig via $subst_expr. + rename $out, $orig + or (warn "$program_name: cannot rename $out to $orig: $!\n"), + $fail = 1, next; + open IN, $orig + or (warn "$program_name: cannot open $orig for reading: $!\n"), + $fail = 1, (unlink $orig), next; + unlink $orig + or (warn "$program_name: cannot unlink $orig: $!\n"), + $fail = 1; + open OUT, ">$out" + or (warn "$program_name: cannot open $out for writing: $!\n"), + $fail = 1, next; + while (defined (my $line = <IN>)) + { + eval "\$_ = \$line; $subst_expr; \$line = \$_"; + print OUT $line; + } + close IN; + close OUT + or (warn "$program_name: failed to write $out: $!\n"), + $fail = 1, next; + } + + my $eo_lower = lc $eo; + _compare_files ($program_name, $test_name, $eo_lower, + $actual{$eo}, $expect->{$eo}) + and $fail = 1; + } foreach my $pair (@post_compare) - { - my ($expected, $actual) = @$pair; - _compare_files $program_name, $test_name, undef, $actual, $expected - and $fail = 1; - } + { + my ($expected, $actual) = @$pair; + _compare_files $program_name, $test_name, undef, $actual, $expected + and $fail = 1; + } cleanup: $expect->{POST} - and &{$expect->{POST}} ($actual_data{OUT}, $actual_data{ERR}); + and &{$expect->{POST}} ($actual_data{OUT}, $actual_data{ERR}); } @@ -595,19 +595,19 @@ sub triple_test($) my @args; my @list_of_hash; foreach my $e (@$t) - { - !ref $e - and push (@args, $e), next; - - ref $e && ref $e eq 'HASH' - or (warn "$0: $t->[0]: unexpected entry type\n"), next; - defined $e->{IN} - and (push @in, $e->{IN}), next; - push @list_of_hash, $e; - } + { + !ref $e + and push (@args, $e), next; + + ref $e && ref $e eq 'HASH' + or (warn "$0: $t->[0]: unexpected entry type\n"), next; + defined $e->{IN} + and (push @in, $e->{IN}), next; + push @list_of_hash, $e; + } # Add variants IFF there is exactly one input file. @in == 1 - or next; + or next; shift @args; # discard test name push @new, ["$t->[0].r", @args, '<', {IN => $in[0]}, @list_of_hash]; push @new, ["$t->[0].p", @args, {IN_PIPE => $in[0]}, @list_of_hash]; diff --git a/tests/CuTmpdir.pm b/tests/CuTmpdir.pm index 0af5d94cf..1f9f08d0c 100644 --- a/tests/CuTmpdir.pm +++ b/tests/CuTmpdir.pm @@ -78,10 +78,10 @@ sub import { my ($sig) = @_; if ($$ == $original_pid and defined $dir) { - chmod_tree; - # Older versions of File::Temp lack this method. - exists &File::Temp::cleanup - and &File::Temp::cleanup; + chmod_tree; + # Older versions of File::Temp lack this method. + exists &File::Temp::cleanup + and &File::Temp::cleanup; } $SIG{$sig} = 'DEFAULT'; kill $sig, $$; diff --git a/tests/chgrp/basic b/tests/chgrp/basic index 14df019cf..2c0d7fae6 100755 --- a/tests/chgrp/basic +++ b/tests/chgrp/basic @@ -108,7 +108,7 @@ test "`ls -C -c -t f g`" = 'f g' || \ *darwin7.9.*|*darwin8.*) echo ignoring known MacOS X-specific chgrp failure 1>&2 ;; *) echo $host_triplet: no-change chgrp failed to update ctime 1>&2; - fail=1 ;; + fail=1 ;; esac } diff --git a/tests/chmod/usage b/tests/chmod/usage index 734c447ca..1f1894427 100755 --- a/tests/chmod/usage +++ b/tests/chmod/usage @@ -81,7 +81,7 @@ for case in $cases; do # Test for misparsing args by creating all $files but $file. # chmod has a bug if it succeeds even though $file is absent. rm -f -- $all_files && touch -- $files && rm -- $file \ - || framework_failure + || framework_failure chmod $args 2>/dev/null && fail=1 done ;; diff --git a/tests/chown/separator b/tests/chown/separator index 4bcaf32d1..4ee285647 100755 --- a/tests/chown/separator +++ b/tests/chown/separator @@ -58,8 +58,8 @@ for u in $id_u "$id_un" ''; do esac for sep in $seps; do case $u$sep$g in - [0-9]*$sep) chown "$u$sep$g" . 2> /dev/null && fail=1 ;; - *) chown "$u$sep$g" . || fail=1 ;; + [0-9]*$sep) chown "$u$sep$g" . 2> /dev/null && fail=1 ;; + *) chown "$u$sep$g" . || fail=1 ;; esac done done diff --git a/tests/cp/cp-mv-backup b/tests/cp/cp-mv-backup index d179d6617..59d03a3ef 100755 --- a/tests/cp/cp-mv-backup +++ b/tests/cp/cp-mv-backup @@ -41,7 +41,7 @@ for prog in cp mv; do for initial_files in 'x' 'x y' 'x y y~' 'x y y.~1~' 'x y y~ y.~1~'; do for opt in none off numbered t existing nil simple never; do touch $initial_files - $prog --backup=$opt x y || fail=1 + $prog --backup=$opt x y || fail=1 echo $initial_files $opt: `ls [xy]*`; rm -f x y y~ y.~?~ done done diff --git a/tests/cp/perm b/tests/cp/perm index 11c4b3ba1..7cc6f419e 100755 --- a/tests/cp/perm +++ b/tests/cp/perm @@ -37,39 +37,39 @@ for u in 31 37 2; do for cmd in mv 'cp -p' cp; do for force in '' -f; do for existing_dest in yes no; do - for g_perm in r w x rw wx xr rwx; do - for o_perm in r w x rw wx xr rwx; do - touch src || exit 1 - chmod u=r,g=rx,o= src || exit 1 - expected_perms=$(stat --format=%A src) - rm -f dest - test $existing_dest = yes && { - touch dest || exit 1 - chmod u=rw,g=$g_perm,o=$o_perm dest || exit 1 - } - $cmd $force src dest || exit 1 - test "$cmd" = mv && test -f src && exit 1 - test "$cmd" = cp && { test -f src || exit 1; } - actual_perms=$(stat --format=%A dest) + for g_perm in r w x rw wx xr rwx; do + for o_perm in r w x rw wx xr rwx; do + touch src || exit 1 + chmod u=r,g=rx,o= src || exit 1 + expected_perms=$(stat --format=%A src) + rm -f dest + test $existing_dest = yes && { + touch dest || exit 1 + chmod u=rw,g=$g_perm,o=$o_perm dest || exit 1 + } + $cmd $force src dest || exit 1 + test "$cmd" = mv && test -f src && exit 1 + test "$cmd" = cp && { test -f src || exit 1; } + actual_perms=$(stat --format=%A dest) - case "$cmd:$force:$existing_dest" in - cp:*:yes) - _g_perm=`echo rwx|sed 's/[^'$g_perm']/-/g'` - _o_perm=`echo rwx|sed 's/[^'$o_perm']/-/g'` - expected_perms=-rw-$_g_perm$_o_perm - ;; - cp:*:no) - test $u = 37 && - expected_perms=`echo $expected_perms|sed 's/.....$/-----/'` - test $u = 31 && - expected_perms=`echo $expected_perms|sed 's/..\(..\).$/--\1-/'` - ;; - esac - test _$actual_perms = _$expected_perms || exit 1 - # Perform only one iteration when there's no existing destination. - test $existing_dest = no && break 3 - done - done + case "$cmd:$force:$existing_dest" in + cp:*:yes) + _g_perm=`echo rwx|sed 's/[^'$g_perm']/-/g'` + _o_perm=`echo rwx|sed 's/[^'$o_perm']/-/g'` + expected_perms=-rw-$_g_perm$_o_perm + ;; + cp:*:no) + test $u = 37 && + expected_perms=`echo $expected_perms|sed 's/.....$/-----/'` + test $u = 31 && + expected_perms=`echo $expected_perms|sed 's/..\(..\).$/--\1-/'` + ;; + esac + test _$actual_perms = _$expected_perms || exit 1 + # Perform only one iteration when there's no existing destination. + test $existing_dest = no && break 3 + done + done done done done diff --git a/tests/cp/same-file b/tests/cp/same-file index 1556011aa..6d57ebd6a 100755 --- a/tests/cp/same-file +++ b/tests/cp/same-file @@ -53,7 +53,7 @@ contents=XYZ for args in 'foo symlink' 'symlink foo' 'foo foo' 'sl1 sl2' 'foo hardlink'; do for options in '' -d -f -df --rem -b -bd -bf -bdf \ - -l -dl -fl -dfl -bl -bdl -bfl -bdfl; do + -l -dl -fl -dfl -bl -bdl -bfl -bdfl; do case $args$options in # These tests are not portable. # They all involve making a hard link to a symbolic link. @@ -61,28 +61,28 @@ for args in 'foo symlink' 'symlink foo' 'foo foo' 'sl1 sl2' 'foo hardlink'; do # by doing "continue" here and eliminating the corresponding # expected output lines below. Don't do that anymore. 'symlink foo'-dfl) - continue;; + continue;; 'symlink foo'-bdl) - continue;; + continue;; 'symlink foo'-bdfl) - continue;; + continue;; 'sl1 sl2'-dfl) - continue;; + continue;; 'sl1 sl2'-bd*l) - continue;; + continue;; 'sl1 sl2'-dl) - continue;; + continue;; esac # cont'd Instead, skip them only on systems for which link does # dereference a symlink. Detect and skip such tests here. case $hard_link_to_symlink_does_the_deref:$args:$options in 'yes:sl1 sl2:-fl') - continue ;; + continue ;; 'yes:sl1 sl2:-bl') - continue ;; + continue ;; 'yes:sl1 sl2:-bfl') - continue ;; + continue ;; esac rm -rf dir @@ -95,37 +95,37 @@ for args in 'foo symlink' 'symlink foo' 'foo foo' 'sl1 sl2' 'foo hardlink'; do case "$args" in *sl2*) ln -s foo sl2;; esac ( ( - # echo 1>&2 cp $options $args - cp $options $args 2>_err - echo $? $options - - # Normalize the program name and diagnostics in the error output, - # and put brackets around the output. - if test -s _err; then - sed ' - s/^[^:]*:\([^:]*\).*/cp:\1/ - 1s/^/[/ - $s/$/]/ - ' _err + # echo 1>&2 cp $options $args + cp $options $args 2>_err + echo $? $options + + # Normalize the program name and diagnostics in the error output, + # and put brackets around the output. + if test -s _err; then + sed ' + s/^[^:]*:\([^:]*\).*/cp:\1/ + 1s/^/[/ + $s/$/]/ + ' _err fi - # Strip off all but the file names. - ls=`ls -gG --ignore=_err . \ - | sed \ - -e '/^total /d' \ - -e 's/^[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *//'` - echo "($ls)" - # Make sure the original is unchanged and that - # the destination is a copy. - for f in $args; do - if test -f $f; then - case "`cat $f`" in - "$contents") ;; - *) echo cp FAILED;; - esac - else - echo symlink-loop - fi - done + # Strip off all but the file names. + ls=`ls -gG --ignore=_err . \ + | sed \ + -e '/^total /d' \ + -e 's/^[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *//'` + echo "($ls)" + # Make sure the original is unchanged and that + # the destination is a copy. + for f in $args; do + if test -f $f; then + case "`cat $f`" in + "$contents") ;; + *) echo cp FAILED;; + esac + else + echo symlink-loop + fi + done ) | tr '\n' ' ' echo ) | sed 's/ *$//' diff --git a/tests/df/total-verify b/tests/df/total-verify index 809f70d02..7b6273d2d 100755 --- a/tests/df/total-verify +++ b/tests/df/total-verify @@ -39,13 +39,13 @@ while (<>) or die "$0: invalid input line\n: $_"; if ($1 eq 'total' && $5 eq '') { - $total == $2 or die "$total != $2"; - $used == $3 or die "$used != $3"; - $avail == $4 or die "$avail != $4"; - my $line = <>; - defined $line - and die "$0: extra line(s) after totals\n"; - exit 0; + $total == $2 or die "$total != $2"; + $used == $3 or die "$used != $3"; + $avail == $4 or die "$avail != $4"; + my $line = <>; + defined $line + and die "$0: extra line(s) after totals\n"; + exit 0; } $total += $2 unless $2 eq '-'; $used += $3 unless $3 eq '-'; diff --git a/tests/du/files0-from b/tests/du/files0-from index ada0a8903..3e36d5ae5 100755 --- a/tests/du/files0-from +++ b/tests/du/files0-from @@ -31,7 +31,7 @@ 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" - . "file operands cannot be combined with --files0-from\n" + . "file operands cannot be combined with --files0-from\n" . "Try `$prog --help' for more information.\n"} ], diff --git a/tests/ls/stat-vs-dirent b/tests/ls/stat-vs-dirent index e8d2118ad..c1d7ff55a 100755 --- a/tests/ls/stat-vs-dirent +++ b/tests/ls/stat-vs-dirent @@ -45,9 +45,9 @@ while :; do # buggy file systems, at mount points. if test "$d_ino" != "$st_ino"; then echo "$0: test failed: $t/$file: d_ino($d_ino) != st_ino($st_ino) - This may indicate a flaw in your kernel or file system implementation. - The flaw isn't serious for coreutils, but it might break other tools, - so you should report it to your operating system vendor." 1>&2 + This may indicate a flaw in your kernel or file system implementation. + The flaw isn't serious for coreutils, but it might break other tools, + so you should report it to your operating system vendor." 1>&2 # This test fails too often, and we don't want to be distracted # with reports, since the code that could be affected by the losing diff --git a/tests/misc/base64 b/tests/misc/base64 index a9c088805..7439ff738 100755 --- a/tests/misc/base64 +++ b/tests/misc/base64 @@ -114,25 +114,25 @@ foreach my $t (@Tests) foreach my $e (@$t) { ref $e && ref $e eq 'HASH' - or next; + or next; defined $e->{EXIT} - and $exit_val = $e->{EXIT}; - defined $e->{IN} - and $in = $e->{IN}; - if (defined $e->{OUT}) - { - my $t = $e->{OUT}; - push @out, $t; - my $len = length $t; - foreach my $i (0..$len) - { - my $u = $t; - substr ($u, $i, 0) = "\n"; - push @out, $u; - 10 <= $i - and last; - } - } + and $exit_val = $e->{EXIT}; + defined $e->{IN} + and $in = $e->{IN}; + if (defined $e->{OUT}) + { + my $t = $e->{OUT}; + push @out, $t; + my $len = length $t; + foreach my $i (0..$len) + { + my $u = $t; + substr ($u, $i, 0) = "\n"; + push @out, $u; + 10 <= $i + and last; + } + } } $exit_val and next; @@ -140,8 +140,8 @@ foreach my $t (@Tests) my $i = 0; foreach my $o (@out) { - push @new, ["d$i-$t->[0]", '--decode', {IN => $o}, {OUT => $in}]; - ++$i; + push @new, ["d$i-$t->[0]", '--decode', {IN => $o}, {OUT => $in}]; + ++$i; } } push @Tests, @new; diff --git a/tests/misc/basename b/tests/misc/basename index 1fad8b273..48b11afc3 100755 --- a/tests/misc/basename +++ b/tests/misc/basename @@ -26,7 +26,7 @@ use File::stat; my $stat_single = stat('/'); my $stat_double = stat('//'); my $double_slash = ($stat_single->dev == $stat_double->dev - && $stat_single->ino == $stat_double->ino) ? '/' : '//'; + && $stat_single->ino == $stat_double->ino) ? '/' : '//'; my $prog = 'basename'; @@ -67,8 +67,8 @@ foreach $t (@Tests) my $e; foreach $e (@$t) { - $e->{OUT} = "$e->{OUT}\n" - if ref $e eq 'HASH' and exists $e->{OUT}; + $e->{OUT} = "$e->{OUT}\n" + if ref $e eq 'HASH' and exists $e->{OUT}; } } diff --git a/tests/misc/comm b/tests/misc/comm index 80a0c2dd3..1f2e82722 100755 --- a/tests/misc/comm +++ b/tests/misc/comm @@ -58,17 +58,17 @@ my @Tests = # invalid missing command line argument (1) ['missing-arg1', $inputs[0], {EXIT=>1}, {ERR => "$prog: missing operand after `a'\n" - . "Try `$prog --help' for more information.\n"}], + . "Try `$prog --help' for more information.\n"}], # invalid missing command line argument (both) ['missing-arg2', {EXIT=>1}, {ERR => "$prog: missing operand\n" - . "Try `$prog --help' for more information.\n"}], + . "Try `$prog --help' for more information.\n"}], # invalid extra command line argument ['extra-arg', @inputs, 'no-such', {EXIT=>1}, {ERR => "$prog: extra operand `no-such'\n" - . "Try `$prog --help' for more information.\n"}], + . "Try `$prog --help' for more information.\n"}], # out-of-order input ['ooo', {IN=>{a=>"1\n3"}}, {IN=>{b=>"3\n2"}}, {EXIT=>1}, @@ -88,13 +88,13 @@ my @Tests = ['ooo4', {IN=>{a=>"3\n1\n0"}}, {IN=>{b=>"3\n2\n0"}}, {EXIT=>1}, {OUT => "\t\t3\n1\n0\n\t2\n\t0\n"}, {ERR => "$prog: file 1 is not in sorted order\n". - "$prog: file 2 is not in sorted order\n" }], + "$prog: file 2 is not in sorted order\n" }], # both inputs out-of-order on last pair ['ooo5', {IN=>{a=>"3\n1"}}, {IN=>{b=>"3\n2"}}, {EXIT=>1}, {OUT => "\t\t3\n1\n\t2\n"}, {ERR => "$prog: file 1 is not in sorted order\n". - "$prog: file 2 is not in sorted order\n" }], + "$prog: file 2 is not in sorted order\n" }], # first input out-of-order extended ['ooo5b', {IN=>{a=>"0\n3\n1"}}, {IN=>{b=>"2\n3"}}, {EXIT=>1}, diff --git a/tests/misc/date b/tests/misc/date index 78b7bc569..1d8767a1c 100755 --- a/tests/misc/date +++ b/tests/misc/date @@ -128,7 +128,7 @@ my @Tests = ['next-y', "-d '$d1 next year' '+%Y-%m-%d %T'", {OUT=>"$dy $t0"}], ['utc-0', "-u -d '08/01/97 6:00' '+%D,%H:%M'", {OUT=>"08/01/97,06:00"}, - {ENV => 'TZ=UTC+4'}], + {ENV => 'TZ=UTC+4'}], ['utc-0a', "-u -d '08/01/97 6:00 UTC +4 hours' '+%D,%H:%M'", {OUT=>"08/01/97,10:00"}], @@ -189,7 +189,7 @@ my @Tests = # Relative days, no time, across time zones. ['relative-3', "-I -d '2006-04-23 21 days ago'", {OUT=>"2006-04-02"}, - {ENV=>'TZ=PST8PDT,M4.1.0,M10.5.0'}], + {ENV=>'TZ=PST8PDT,M4.1.0,M10.5.0'}], # This would infloop (or appear to) prior to coreutils-4.5.5, # due to a bug in strftime.c. @@ -243,8 +243,8 @@ my @Tests = # Unfortunately (for ease of testing), if you set TZ at all, this # failure is not triggered, hence the removal of TZ from the environment. ['cross-dst', "-d'2005-03-27 +1 day'", '+%Y', {OUT=>"2005"}, - {ENV_DEL => 'TZ'}, - ], + {ENV_DEL => 'TZ'}, + ], ['empty-fmt', '+', {OUT=>""}], @@ -284,9 +284,9 @@ my @Tests = foreach my $i (1..364) { push @Tests, ["cross-dst$i", - "-d'2005-01-01 +$i day'", '+%Y', {OUT=>"2005"}, - {ENV_DEL => 'TZ'}, - ]; + "-d'2005-01-01 +$i day'", '+%Y', {OUT=>"2005"}, + {ENV_DEL => 'TZ'}, + ]; } # Append "\n" to each OUT=> RHS if the expected exit value is either @@ -297,12 +297,12 @@ foreach my $t (@Tests) foreach my $e (@$t) { ref $e && ref $e eq 'HASH' && defined $e->{EXIT} - and $exit_val = $e->{EXIT}; + and $exit_val = $e->{EXIT}; } foreach my $e (@$t) { ref $e && ref $e eq 'HASH' && defined $e->{OUT} && ! $exit_val - and $e->{OUT} .= "\n"; + and $e->{OUT} .= "\n"; } } diff --git a/tests/misc/date-next-dow b/tests/misc/date-next-dow index 0809c65d0..9abdb62e9 100755 --- a/tests/misc/date-next-dow +++ b/tests/misc/date-next-dow @@ -55,12 +55,12 @@ foreach my $t (@Tests) foreach my $e (@$t) { ref $e && ref $e eq 'HASH' && defined $e->{EXIT} - and $exit_val = $e->{EXIT}; + and $exit_val = $e->{EXIT}; } foreach my $e (@$t) { ref $e && ref $e eq 'HASH' && defined $e->{OUT} && ! $exit_val - and $e->{OUT} .= "\n"; + and $e->{OUT} .= "\n"; } } diff --git a/tests/misc/dirname b/tests/misc/dirname index d7a1f34be..3358d1099 100755 --- a/tests/misc/dirname +++ b/tests/misc/dirname @@ -27,7 +27,7 @@ use File::stat; my $stat_single = stat('/'); my $stat_double = stat('//'); my $double_slash = ($stat_single->dev == $stat_double->dev - && $stat_single->ino == $stat_double->ino) ? '/' : '//'; + && $stat_single->ino == $stat_double->ino) ? '/' : '//'; my $prog = 'dirname'; @@ -61,8 +61,8 @@ foreach $t (@Tests) my $e; foreach $e (@$t) { - $e->{OUT} = "$e->{OUT}\n" - if ref $e eq 'HASH' and exists $e->{OUT}; + $e->{OUT} = "$e->{OUT}\n" + if ref $e eq 'HASH' and exists $e->{OUT}; } } diff --git a/tests/misc/expr b/tests/misc/expr index 4f1191903..ec1b51ff4 100755 --- a/tests/misc/expr +++ b/tests/misc/expr @@ -159,7 +159,7 @@ my @Tests = ['fail-b', '9 9', {ERR => "$prog: syntax error\n"}, {EXIT => 2}], ['fail-c', {ERR => "$prog: missing operand\n" - . "Try `$prog --help' for more information.\n"}, + . "Try `$prog --help' for more information.\n"}, {EXIT => 2}], ['bignum-add', "$big + 1", {OUT => $big_p1}], @@ -182,8 +182,8 @@ foreach $t (@Tests) my $e; foreach $e (@$t) { - $e->{OUT} .= "\n" - if ref $e eq 'HASH' and exists $e->{OUT}; + $e->{OUT} .= "\n" + if ref $e eq 'HASH' and exists $e->{OUT}; } } diff --git a/tests/misc/factor b/tests/misc/factor index dcf6bc00e..9c640b33b 100755 --- a/tests/misc/factor +++ b/tests/misc/factor @@ -79,14 +79,14 @@ foreach $t (@Tests) # Don't fiddle with expected OUT string if there's a nonzero exit status. foreach my $e (@$t) { - ref $e eq 'HASH' && exists $e->{EXIT} && $e->{EXIT} - and next Test; + ref $e eq 'HASH' && exists $e->{EXIT} && $e->{EXIT} + and next Test; } foreach my $e (@$t) { - ref $e eq 'HASH' && exists $e->{OUT} - and $e->{OUT} = "$arg1: $e->{OUT}\n" + ref $e eq 'HASH' && exists $e->{OUT} + and $e->{OUT} = "$arg1: $e->{OUT}\n" } } diff --git a/tests/misc/head-elide-tail b/tests/misc/head-elide-tail index 089ae76c6..8fc8686b5 100755 --- a/tests/misc/head-elide-tail +++ b/tests/misc/head-elide-tail @@ -63,39 +63,39 @@ if ($ENV{RUN_EXPENSIVE_TESTS}) my $s = "abcdefghijklmnopqrst"; for my $file_size (0..20) { - for my $n_elide (0..20) - { - my $input = substr $s, 0, $file_size; - my $out_len = $n_elide < $file_size ? $file_size - $n_elide : 0; - my $output = substr $input, 0, $out_len; - my $t = ["elideb$file_size-$n_elide", "--bytes=-$n_elide", - {IN=>$input}, {OUT=>$output}]; - push @Tests, $t; - my @u = @$t; - # Insert the ---presume-input-pipe option. - $u[0] .= 'p'; - $u[1] .= ' ---presume-input-pipe'; - push @Tests, \@u; - } + for my $n_elide (0..20) + { + my $input = substr $s, 0, $file_size; + my $out_len = $n_elide < $file_size ? $file_size - $n_elide : 0; + my $output = substr $input, 0, $out_len; + my $t = ["elideb$file_size-$n_elide", "--bytes=-$n_elide", + {IN=>$input}, {OUT=>$output}]; + push @Tests, $t; + my @u = @$t; + # Insert the ---presume-input-pipe option. + $u[0] .= 'p'; + $u[1] .= ' ---presume-input-pipe'; + push @Tests, \@u; + } } $s =~ s/(.)/$1\n/g; for my $file_size (0..20) { - for my $n_elide (0..20) - { - my $input = substr $s, 0, 2 * $file_size; - my $out_len = $n_elide < $file_size ? $file_size - $n_elide : 0; - my $output = substr $input, 0, 2 * $out_len; - my $t = ["elidel$file_size-$n_elide", "--lines=-$n_elide", - {IN=>$input}, {OUT=>$output}]; - push @Tests, $t; - my @u = @$t; - # Insert the ---presume-input-pipe option. - $u[0] .= 'p'; - $u[1] .= ' ---presume-input-pipe'; - push @Tests, \@u; - } + for my $n_elide (0..20) + { + my $input = substr $s, 0, 2 * $file_size; + my $out_len = $n_elide < $file_size ? $file_size - $n_elide : 0; + my $output = substr $input, 0, 2 * $out_len; + my $t = ["elidel$file_size-$n_elide", "--lines=-$n_elide", + {IN=>$input}, {OUT=>$output}]; + push @Tests, $t; + my @u = @$t; + # Insert the ---presume-input-pipe option. + $u[0] .= 'p'; + $u[1] .= ' ---presume-input-pipe'; + push @Tests, \@u; + } } } diff --git a/tests/misc/help-version b/tests/misc/help-version index d03a38c01..9afe8af8b 100755 --- a/tests/misc/help-version +++ b/tests/misc/help-version @@ -77,11 +77,11 @@ for lang in C fr da; do eval "expected=\$expected_failure_status_$prog" test x$expected = x && expected=1 if test $status = $expected; then - : # ok + : # ok else - fail=1 - echo "*** $i: bad exit status \`$status' (expected $expected)," 1>&2 - echo " with --help or --version output redirected to /dev/full" 1>&2 + fail=1 + echo "*** $i: bad exit status \`$status' (expected $expected)," 1>&2 + echo " with --help or --version output redirected to /dev/full" 1>&2 fi fi done diff --git a/tests/misc/ls-misc b/tests/misc/ls-misc index bcd64e34c..63810a559 100755 --- a/tests/misc/ls-misc +++ b/tests/misc/ls-misc @@ -57,12 +57,12 @@ sub setuid_setup() { my $test = shell_quote "$ENV{abs_top_builddir}/src/test"; system (qq(touch setuid && chmod u+s setuid && $test -u setuid && - touch setgid && chmod g+s setgid && $test -g setgid && - mkdir sticky && chmod +t sticky && $test -k sticky && - mkdir owt && chmod +t,o+w owt && $test -k owt && - mkdir owr && chmod o+w owr)) == 0 - or (warn "$program_name: cannot create setuid/setgid/sticky files," - . "so can't run this test\n"), exit 77; + touch setgid && chmod g+s setgid && $test -g setgid && + mkdir sticky && chmod +t sticky && $test -k sticky && + mkdir owt && chmod +t,o+w owt && $test -k owt && + mkdir owr && chmod o+w owr)) == 0 + or (warn "$program_name: cannot create setuid/setgid/sticky files," + . "so can't run this test\n"), exit 77; } sub mk_file(@) @@ -70,7 +70,7 @@ sub mk_file(@) foreach my $f (@_) { open (F, '>', $f) && close F - or die "creating $f: $!\n"; + or die "creating $f: $!\n"; } } @@ -80,31 +80,31 @@ my $mkdir = {PRE => sub {mkdir_d}}; my $rmdir = {POST => sub {rmdir_d}}; my $mkdir_reg = {PRE => sub {mkdir_d; mk_file 'd/f' }}; my $rmdir_reg = {POST => sub {unlink 'd/f' or die "d/f: $!\n"; - rmdir 'd' or die "d: $!\n"}}; + rmdir 'd' or die "d: $!\n"}}; my $mkdir2 = {PRE => sub {mkdir 'd',0755 or die "d: $!\n"; - mkdir 'd/e',0755 or die "d/e: $!\n" }}; + mkdir 'd/e',0755 or die "d/e: $!\n" }}; my $rmdir2 = {POST => sub {rmdir 'd/e' or die "d/e: $!\n"; - rmdir 'd' or die "d: $!\n" }}; + rmdir 'd' or die "d: $!\n" }}; my $target = {PRE => sub { - mkdir 'd',0755 or die "d: $!\n"; - symlink '.', 'd/X' or die "d/X: $!\n"; - push_ls_colors('ln=target') - }}; + mkdir 'd',0755 or die "d: $!\n"; + symlink '.', 'd/X' or die "d/X: $!\n"; + push_ls_colors('ln=target') + }}; my $target2 = {POST => sub {unlink 'd/X' or die "d/X: $!\n"; - rmdir 'd' or die "d: $!\n"; - restore_ls_colors - }}; + rmdir 'd' or die "d: $!\n"; + restore_ls_colors + }}; my $slink_d = {PRE => sub {symlink '/', 'd' or die "d: $!\n"; push_ls_colors('ln=01;36:di=01;34:or=40;31;01') }}; my $unlink_d = {POST => sub {unlink 'd' or die "d: $!\n"; restore_ls_colors}}; my $mkdir_d_slink = {PRE => sub {mkdir 'd',0755 or die "d: $!\n"; - symlink '/', 'd/s' or die "d/s: $!\n" }}; + symlink '/', 'd/s' or die "d/s: $!\n" }}; my $rmdir_d_slink = {POST => sub {unlink 'd/s' or die "d/s: $!\n"; - rmdir 'd' or die "d: $!\n" }}; + rmdir 'd' or die "d: $!\n" }}; sub make_j_d () { @@ -118,7 +118,7 @@ my @v_files = ((map { ".$_" } @v1), @v1); my $exe_in_subdir = {PRE => sub { make_j_d (); push_ls_colors('ex=01;32') }}; my $remove_j = {POST => sub {unlink 'j/d' or die "j/d: $!\n"; rmdir 'j' or die "j: $!\n"; - restore_ls_colors }}; + restore_ls_colors }}; my $e = "\e[0m"; my $q_bell = {IN => {"q\a" => ''}}; @@ -156,11 +156,11 @@ my @Tests = # Test for a bug that was fixed in coreutils-4.5.4. ['sl-F-color', '-F --color=always d', - {OUT => "$e\e[01;36md$e\@\n\e[m"}, - $slink_d, $unlink_d], + {OUT => "$e\e[01;36md$e\@\n\e[m"}, + $slink_d, $unlink_d], ['sl-dF-color', '-dF --color=always d', - {OUT => "$e\e[01;36md$e\@\n\e[m"}, - $slink_d, $unlink_d], + {OUT => "$e\e[01;36md$e\@\n\e[m"}, + $slink_d, $unlink_d], # A listing with no output should have no color sequences at all. ['no-c-empty', '--color=always d', {OUT => ""}, $mkdir, $rmdir], @@ -176,44 +176,44 @@ my @Tests = ['sl-dangle', '--color=always d', {OUT => "$e\e[40;31;01mX$e\n\e[m"}, {PRE => sub { - mkdir 'd',0755 or die "d: $!\n"; - symlink 'non-existent', 'd/X' or die "d/X: $!\n"; - push_ls_colors('or=40;31;01') - }}, + mkdir 'd',0755 or die "d: $!\n"; + symlink 'non-existent', 'd/X' or die "d/X: $!\n"; + push_ls_colors('or=40;31;01') + }}, {POST => sub {unlink 'd/X' or die "d/X: $!\n"; - rmdir 'd' or die "d: $!\n"; - restore_ls_colors; }}, + rmdir 'd' or die "d: $!\n"; + restore_ls_colors; }}, ], # Test for a bug that was introduced in coreutils-4.5.4; fixed in 4.5.5. # To demonstrate it, the file in question (with executable bit set) # must not be a command line argument. ['color-exe1', '--color=always j', - {OUT => "$e\e[01;32md$e\n\e[m"}, - $exe_in_subdir, $remove_j], + {OUT => "$e\e[01;32md$e\n\e[m"}, + $exe_in_subdir, $remove_j], # From Stéphane Chazelas. ['no-a-isdir-b', 'no-dir d', - {OUT => "d:\n"}, - {ERR => "ls: cannot access no-dir: No such file or directory\n"}, - $mkdir, $rmdir, {EXIT => 2}], + {OUT => "d:\n"}, + {ERR => "ls: cannot access no-dir: No such file or directory\n"}, + $mkdir, $rmdir, {EXIT => 2}], ['recursive-2', '-R d', {OUT => "d:\ne\n\nd/e:\n"}, $mkdir2, $rmdir2], ['setuid-etc', '-1 -d --color=always owr owt setgid setuid sticky', - {OUT => - "$e\e[34;42mowr$e\n" - . "\e[30;42mowt$e\n" - . "\e[30;43msetgid$e\n" - . "\e[37;41msetuid$e\n" - . "\e[37;44msticky$e\n" - . "\e[m" - }, - - {POST => sub { + {OUT => + "$e\e[34;42mowr$e\n" + . "\e[30;42mowt$e\n" + . "\e[30;43msetgid$e\n" + . "\e[37;41msetuid$e\n" + . "\e[37;44msticky$e\n" + . "\e[m" + }, + + {POST => sub { unlink qw(setuid setgid); - foreach my $dir (qw(owr owt sticky)) {rmdir $dir} }}, - ], + foreach my $dir (qw(owr owt sticky)) {rmdir $dir} }}, + ], # For 5.97 and earlier, --file-type acted like --indicator-style=slash. ['file-type', '--file-type d', {OUT => "s@\n"}, diff --git a/tests/misc/md5sum b/tests/misc/md5sum index c19a50405..2fb024d16 100755 --- a/tests/misc/md5sum +++ b/tests/misc/md5sum @@ -31,42 +31,42 @@ my @Tests = ['2', {IN=> {f=> 'a'}}, {OUT=>"0cc175b9c0f1b6a831c399e269772661 f\n"}], ['3', {IN=> {f=> 'abc'}}, {OUT=>"900150983cd24fb0d6963f7d28e17f72 f\n"}], ['4', {IN=> {f=> 'message digest'}}, - {OUT=>"f96b697d7cb7938d525a2f31aaf161d0 f\n"}], + {OUT=>"f96b697d7cb7938d525a2f31aaf161d0 f\n"}], ['5', {IN=> {f=> 'abcdefghijklmnopqrstuvwxyz'}}, - {OUT=>"c3fcd3d76192e4007dfb496cca67e13b f\n"}], + {OUT=>"c3fcd3d76192e4007dfb496cca67e13b f\n"}], ['6', {IN=> {f=> join ('', 'A'..'Z', 'a'..'z', '0'..'9')}}, - {OUT=>"d174ab98d277d9f5a5611c2c9f419d9f f\n"}], + {OUT=>"d174ab98d277d9f5a5611c2c9f419d9f f\n"}], ['7', {IN=> {f=> '1234567890' x 8}}, - {OUT=>"57edf4a22be3c955ac49da2e2107b67a f\n"}], + {OUT=>"57edf4a22be3c955ac49da2e2107b67a f\n"}], ['backslash', {IN=> {".\\foo"=> ''}}, - {OUT=>"\\$degenerate .\\\\foo\n"}], + {OUT=>"\\$degenerate .\\\\foo\n"}], ['check-1', '--check', {AUX=> {f=> ''}}, - {IN=> {'f.md5' => "$degenerate f\n"}}, - {OUT=>"f: OK\n"}], + {IN=> {'f.md5' => "$degenerate f\n"}}, + {OUT=>"f: OK\n"}], ['check-2', '--check', '--status', {IN=>{'f.md5' => "$degenerate f\n"}}, - {AUX=> {f=> 'foo'}}, {EXIT=> 1}], + {AUX=> {f=> 'foo'}}, {EXIT=> 1}], ['check-quiet1', '--check', '--quiet', {AUX=> {f=> ''}}, - {IN=> {'f.md5' => "$degenerate f\n"}}, - {OUT=>""}], + {IN=> {'f.md5' => "$degenerate f\n"}}, + {OUT=>""}], ['check-quiet2', '--check', '--quiet', - {IN=>{'f.md5' => "$degenerate f\n"}}, - {AUX=> {f=> 'foo'}}, {OUT=>"f: FAILED\n"}, - {ERR=>"md5sum: WARNING: 1 of 1 computed" - . " checksum did NOT match\n"}, - {EXIT=> 1}], + {IN=>{'f.md5' => "$degenerate f\n"}}, + {AUX=> {f=> 'foo'}}, {OUT=>"f: FAILED\n"}, + {ERR=>"md5sum: WARNING: 1 of 1 computed" + . " checksum did NOT match\n"}, + {EXIT=> 1}], # The sha1sum and md5sum drivers share a lot of code. # Ensure that md5sum does *not* share the part that makes # sha1sum accept BSD format. ['check-bsd', '--check', {IN=> {'f.sha1' => "SHA1 (f) = $degenerate\n"}}, - {AUX=> {f=> ''}}, - {ERR=>"md5sum: f.sha1: no properly formatted " - . "MD5 checksum lines found\n"}, - {EXIT=> 1}], + {AUX=> {f=> ''}}, + {ERR=>"md5sum: f.sha1: no properly formatted " + . "MD5 checksum lines found\n"}, + {EXIT=> 1}], ['check-bsd2', '--check', {IN=> {'f.md5' => "MD5 (f) = $degenerate\n"}}, - {AUX=> {f=> ''}}, {OUT=>"f: OK\n"}], + {AUX=> {f=> ''}}, {OUT=>"f: OK\n"}], ['check-bsd3', '--check', '--status', - {IN=> {'f.md5' => "MD5 (f) = $degenerate\n"}}, - {AUX=> {f=> 'bar'}}, {EXIT=> 1}], + {IN=> {'f.md5' => "MD5 (f) = $degenerate\n"}}, + {AUX=> {f=> 'bar'}}, {EXIT=> 1}], ['bsd-segv', '--check', {IN=> {'z' => "MD5 ("}}, {EXIT=> 1}, {ERR=> "$prog: z: no properly formatted MD5 checksum lines found\n"}], diff --git a/tests/misc/od b/tests/misc/od index 538bce8a0..a83fe4c8c 100755 --- a/tests/misc/od +++ b/tests/misc/od @@ -51,7 +51,7 @@ my @Tests = {IN=>{i=>'c'}}, {OUT=>''}], # Skip the sum of the lengths of the first three inputs, printing the 4th. ['j-bug4', '-c -j 3 -An', {IN=>{g=>'a'}}, {IN=>{h=>'b'}}, - {IN=>{i=>'c'}}, {IN=>{j=>'d'}}, {OUT=>" d\n"}], + {IN=>{i=>'c'}}, {IN=>{j=>'d'}}, {OUT=>" d\n"}], # Ensure that od -j doesn't fseek across a nonempty file in /proc, # even if the kernel reports that the file has stat.st_size = 0. diff --git a/tests/misc/pwd-long b/tests/misc/pwd-long index b3ddd083a..207e7549c 100755 --- a/tests/misc/pwd-long +++ b/tests/misc/pwd-long @@ -45,11 +45,11 @@ sub normalize_to_cwd_relative ($$$) { $slash = index $dir, '/', $slash + 1; $slash <= -1 - and die "$ME: $dir does not contain old CWD\n"; + and die "$ME: $dir does not contain old CWD\n"; my $dir_prefix = $slash ? substr ($dir, 0, $slash) : '/'; my ($d, $i) = (stat $dir_prefix)[0, 1]; $d == $dev && $i == $ino - and return substr $dir, $slash + 1; + and return substr $dir, $slash + 1; } } diff --git a/tests/misc/seq b/tests/misc/seq index b34833da2..21eafcf0a 100755 --- a/tests/misc/seq +++ b/tests/misc/seq @@ -102,7 +102,7 @@ my @Tests = # fail to print the "2,0" endpoint. ['locale-dec-pt', qw(-0.1 0.1 2), {OUT => [qw(-0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 - 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0)]}, + 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0)]}, {ENV => "LC_ALL=$locale"}, {OUT_SUBST => 's/,/./g'}, @@ -116,8 +116,8 @@ foreach $t (@Tests) my $e; foreach $e (@$t) { - $e->{OUT} = join ("\n", @{$e->{OUT}}) . "\n" - if ref $e eq 'HASH' and exists $e->{OUT}; + $e->{OUT} = join ("\n", @{$e->{OUT}}) . "\n" + if ref $e eq 'HASH' and exists $e->{OUT}; } } diff --git a/tests/misc/sha1sum b/tests/misc/sha1sum index 043c5904a..3f09abaae 100755 --- a/tests/misc/sha1sum +++ b/tests/misc/sha1sum @@ -28,38 +28,38 @@ my $sha_degenerate = "da39a3ee5e6b4b0d3255bfef95601890afd80709"; my @Tests = ( ['s1', {IN=> {f=> ''}}, - {OUT=>"$sha_degenerate f\n"}], + {OUT=>"$sha_degenerate f\n"}], ['s2', {IN=> {f=> 'a'}}, - {OUT=>"86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 f\n"}], + {OUT=>"86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 f\n"}], ['s3', {IN=> {f=> 'abc'}}, - {OUT=>"a9993e364706816aba3e25717850c26c9cd0d89d f\n"}], + {OUT=>"a9993e364706816aba3e25717850c26c9cd0d89d f\n"}], ['s4', {IN=> {f=> 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'}}, - {OUT=>"84983e441c3bd26ebaae4aa1f95129e5e54670f1 f\n"}], + {OUT=>"84983e441c3bd26ebaae4aa1f95129e5e54670f1 f\n"}], ['s5', {IN=> {f=> 'abcdefghijklmnopqrstuvwxyz'}}, - {OUT=>"32d10c7b8cf96570ca04ce37f2a19d84240d3a89 f\n"}], + {OUT=>"32d10c7b8cf96570ca04ce37f2a19d84240d3a89 f\n"}], ['s6', {IN=> {f=> join ('', 'A'..'Z', 'a'..'z', '0'..'9')}}, - {OUT=>"761c457bf73b14d27e9e9265c46f4b4dda11f940 f\n"}], + {OUT=>"761c457bf73b14d27e9e9265c46f4b4dda11f940 f\n"}], ['s7', {IN=> {f=> '1234567890' x 8}}, - {OUT=>"50abf5706a150990a08b2c5ea40fa0e585554732 f\n"}], + {OUT=>"50abf5706a150990a08b2c5ea40fa0e585554732 f\n"}], ['million-a', {IN=> {f=> 'a' x 1000000}}, - {OUT=>"34aa973cd4c4daa4f61eeb2bdbad27316534016f f\n"}], + {OUT=>"34aa973cd4c4daa4f61eeb2bdbad27316534016f f\n"}], ['bs-sha', {IN=> {".\\foo"=> ''}}, - {OUT=>"\\$sha_degenerate .\\\\foo\n"}], + {OUT=>"\\$sha_degenerate .\\\\foo\n"}], # The sha1sum and md5sum drivers share a lot of code. # Ensure that sha1sum does *not* share the part that makes # md5sum accept BSD format. ['check-bsd', '--check', {IN=> {'f.md5' => "MD5 (f) = $sha_degenerate\n"}}, - {AUX=> {f=> ''}}, - {ERR=>"sha1sum: f.md5: no properly formatted " - . "SHA1 checksum lines found\n"}, - {EXIT=> 1}], + {AUX=> {f=> ''}}, + {ERR=>"sha1sum: f.md5: no properly formatted " + . "SHA1 checksum lines found\n"}, + {EXIT=> 1}], ['check-bsd2', '--check', - {IN=> {'f.sha1' => "SHA1 (f) = $sha_degenerate\n"}}, - {AUX=> {f=> ''}}, {OUT=>"f: OK\n"}], + {IN=> {'f.sha1' => "SHA1 (f) = $sha_degenerate\n"}}, + {AUX=> {f=> ''}}, {OUT=>"f: OK\n"}], ['check-bsd3', '--check', '--status', - {IN=> {'f.sha1' => "SHA1 (f) = $sha_degenerate\n"}}, - {AUX=> {f=> 'bar'}}, {EXIT=> 1}], + {IN=> {'f.sha1' => "SHA1 (f) = $sha_degenerate\n"}}, + {AUX=> {f=> 'bar'}}, {EXIT=> 1}], ['bsd-segv', '--check', {IN=> {'z' => "SHA1 ("}}, {EXIT=> 1}, {ERR=> "$prog: z: no properly formatted SHA1 checksum lines found\n"}], ); diff --git a/tests/misc/sha224sum b/tests/misc/sha224sum index f9e9ac0d3..aace96c96 100755 --- a/tests/misc/sha224sum +++ b/tests/misc/sha224sum @@ -26,12 +26,12 @@ use strict; my @Tests = ( ['s3', {IN=> {f=> 'abc'}}, - {OUT=>"23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7 f\n"}], + {OUT=>"23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7 f\n"}], ['s4', {IN=> {f=> 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'}}, - {OUT=>"75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525 f\n"}], + {OUT=>"75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525 f\n"}], ['s8', {IN=> {f=> 'a' x 1000000}}, - {OUT=>"20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67 f\n"}], + {OUT=>"20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67 f\n"}], ); # Insert the `--text' argument for each test. diff --git a/tests/misc/sha256sum b/tests/misc/sha256sum index 99c5e1ebd..d85f24884 100755 --- a/tests/misc/sha256sum +++ b/tests/misc/sha256sum @@ -28,16 +28,16 @@ my $sha_degenerate = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b78 my @Tests = ( ['s1', {IN=> {f=> ''}}, - {OUT=>"$sha_degenerate f\n"}], + {OUT=>"$sha_degenerate f\n"}], ['s2', {IN=> {f=> 'a'}}, - {OUT=>"ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb f\n"}], + {OUT=>"ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb f\n"}], ['s3', {IN=> {f=> 'abc'}}, - {OUT=>"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad f\n"}], + {OUT=>"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad f\n"}], ['s4', {IN=> {f=> 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'}}, - {OUT=>"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1 f\n"}], + {OUT=>"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1 f\n"}], ['s8', {IN=> {f=> 'a' x 1000000}}, - {OUT=>"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0 f\n"}], + {OUT=>"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0 f\n"}], ); # Insert the `--text' argument for each test. diff --git a/tests/misc/sha384sum b/tests/misc/sha384sum index 858949166..c5818e263 100755 --- a/tests/misc/sha384sum +++ b/tests/misc/sha384sum @@ -28,16 +28,16 @@ my $sha_degenerate = "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63 my @Tests = ( ['s1', {IN=> {f=> ''}}, - {OUT=>"$sha_degenerate f\n"}], + {OUT=>"$sha_degenerate f\n"}], ['s2', {IN=> {f=> 'a'}}, - {OUT=>"54a59b9f22b0b80880d8427e548b7c23abd873486e1f035dce9cd697e85175033caa88e6d57bc35efae0b5afd3145f31 f\n"}], + {OUT=>"54a59b9f22b0b80880d8427e548b7c23abd873486e1f035dce9cd697e85175033caa88e6d57bc35efae0b5afd3145f31 f\n"}], ['s3', {IN=> {f=> 'abc'}}, - {OUT=>"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7 f\n"}], + {OUT=>"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7 f\n"}], ['s4', {IN=> {f=> 'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'}}, - {OUT=>"09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039 f\n"}], + {OUT=>"09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039 f\n"}], ['s8', {IN=> {f=> 'a' x 1000000}}, - {OUT=>"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985 f\n"}], + {OUT=>"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985 f\n"}], ); # Insert the `--text' argument for each test. diff --git a/tests/misc/sha512sum b/tests/misc/sha512sum index f9f8e5d6f..9a45602c4 100755 --- a/tests/misc/sha512sum +++ b/tests/misc/sha512sum @@ -28,16 +28,16 @@ my $sha_degenerate = "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d3 my @Tests = ( ['s1', {IN=> {f=> ''}}, - {OUT=>"$sha_degenerate f\n"}], + {OUT=>"$sha_degenerate f\n"}], ['s2', {IN=> {f=> 'a'}}, - {OUT=>"1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f5302860c652bf08d560252aa5e74210546f369fbbbce8c12cfc7957b2652fe9a75 f\n"}], + {OUT=>"1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f5302860c652bf08d560252aa5e74210546f369fbbbce8c12cfc7957b2652fe9a75 f\n"}], ['s3', {IN=> {f=> 'abc'}}, - {OUT=>"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f f\n"}], + {OUT=>"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f f\n"}], ['s4', {IN=> {f=> 'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'}}, - {OUT=>"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909 f\n"}], + {OUT=>"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909 f\n"}], ['s8', {IN=> {f=> 'a' x 1000000}}, - {OUT=>"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b f\n"}], + {OUT=>"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b f\n"}], ); # Insert the `--text' argument for each test. diff --git a/tests/misc/sort-files0-from b/tests/misc/sort-files0-from index 50ad0909c..6ac1e6b4f 100755 --- a/tests/misc/sort-files0-from +++ b/tests/misc/sort-files0-from @@ -31,8 +31,8 @@ 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" - . "file operands cannot be combined with --files0-from\n" - . "Try `$prog --help' for more information.\n"} + . "file operands cannot be combined with --files0-from\n" + . "Try `$prog --help' for more information.\n"} ], # missing input file diff --git a/tests/misc/sort-merge b/tests/misc/sort-merge index c10a59db2..aedd64c64 100755 --- a/tests/misc/sort-merge +++ b/tests/misc/sort-merge @@ -43,11 +43,11 @@ 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}], + "$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}], + "$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}], @@ -56,9 +56,9 @@ my @Tests = {ERR=>"$prog: invalid --batch-size argument `a'\n"}, {EXIT=>2}], ['nmerge-big', "-m --batch-size=$bigint", @inputs, - {ERR_SUBST=>'s/(current rlimit is) \d+/$1/'}, + {ERR_SUBST=>'s/(current rlimit is) \d+/$1/'}, {ERR=>"$prog: --batch-size argument `$bigint' too large\n". - "$prog: maximum --batch-size argument with current rlimit is\n"}, + "$prog: maximum --batch-size argument with current rlimit is\n"}, {EXIT=>2}], # This should work since nmerge >= the number of input files @@ -69,12 +69,12 @@ my @Tests = ['nmerge-no', "-m --batch-size=2 -T$badtmp", @inputs, {ERR_SUBST=>"s|': .*|':|"}, {ERR=>"$prog: cannot create temporary file in `$badtmp':\n"}, - {EXIT=>2}], + {EXIT=>2}], # This used to fail because setting batch-size without also setting # buffer size would cause the buffer size to be set to the minimum. ['batch-size', "--batch-size=16 -T$badtmp", {IN=> {big=> $big_input}}, - {OUT=>$big_input}], + {OUT=>$big_input}], ); my $save_temps = $ENV{DEBUG}; diff --git a/tests/misc/sort-version b/tests/misc/sort-version index 401262bcd..32b0ed258 100755 --- a/tests/misc/sort-version +++ b/tests/misc/sort-version @@ -24,86 +24,86 @@ fi . $srcdir/test-lib.sh cat > in <<- _EOF_ - gcc-c++-10.fc9.tar.gz - gcc-c++-10.8.12-0.7rc2.fc9.tar.bz2 - glibc-2-0.1.beta1.fc10.rpm - glibc-common-5-0.2.beta2.fc9.ebuild - glibc-common-5-0.2b.deb - glibc-common-11b.ebuild - glibc-common-11-0.6rc2.ebuild - libstdc++-0.5.8.11-0.7rc2.fc10.tar.gz - libstdc++-4a.fc8.tar.gz - libstdc++-4.10.4.20040204svn.rpm - libstdc++-devel-3.fc8.ebuild - libstdc++-devel-3a.fc9.tar.gz - libstdc++-devel-8.fc8.deb - libstdc++-devel-8.6.2-0.4b.fc8 - nss_ldap-1-0.2b.fc9.tar.bz2 - nss_ldap-1-0.6rc2.fc8.tar.gz - nss_ldap-1.0-0.1a.tar.gz - nss_ldap-10beta1.fc8.tar.gz - nss_ldap-10.11.8.6.20040204cvs.fc10.ebuild - string start 5.0.0 end of str - string start 5.1.0 end of str - string start 5.10.0 end of str - string start 5.2.0 end of str - string start 5.20.0 end of str - string start 5.3.0 end of str - string start 5.30.0 end of str - string start 5.4.0 end of str - string start 5.40.0 end of str - string start 5.5.0 end of str - string start 5.50.0 end of str - string start 5.6.0 end of str - string start 5.60.0 end of str - string start 5.7.0 end of str - string start 5.70.0 end of str - string start 5.8.0 end of str - string start 5.80.0 end of str - string start 5.9.0 end of str - string start 5.90.0 end of str - _EOF_ + gcc-c++-10.fc9.tar.gz + gcc-c++-10.8.12-0.7rc2.fc9.tar.bz2 + glibc-2-0.1.beta1.fc10.rpm + glibc-common-5-0.2.beta2.fc9.ebuild + glibc-common-5-0.2b.deb + glibc-common-11b.ebuild + glibc-common-11-0.6rc2.ebuild + libstdc++-0.5.8.11-0.7rc2.fc10.tar.gz + libstdc++-4a.fc8.tar.gz + libstdc++-4.10.4.20040204svn.rpm + libstdc++-devel-3.fc8.ebuild + libstdc++-devel-3a.fc9.tar.gz + libstdc++-devel-8.fc8.deb + libstdc++-devel-8.6.2-0.4b.fc8 + nss_ldap-1-0.2b.fc9.tar.bz2 + nss_ldap-1-0.6rc2.fc8.tar.gz + nss_ldap-1.0-0.1a.tar.gz + nss_ldap-10beta1.fc8.tar.gz + nss_ldap-10.11.8.6.20040204cvs.fc10.ebuild + string start 5.0.0 end of str + string start 5.1.0 end of str + string start 5.10.0 end of str + string start 5.2.0 end of str + string start 5.20.0 end of str + string start 5.3.0 end of str + string start 5.30.0 end of str + string start 5.4.0 end of str + string start 5.40.0 end of str + string start 5.5.0 end of str + string start 5.50.0 end of str + string start 5.6.0 end of str + string start 5.60.0 end of str + string start 5.7.0 end of str + string start 5.70.0 end of str + string start 5.8.0 end of str + string start 5.80.0 end of str + string start 5.9.0 end of str + string start 5.90.0 end of str + _EOF_ cat > exp <<- _EOF_ - gcc-c++-10.fc9.tar.gz - gcc-c++-10.8.12-0.7rc2.fc9.tar.bz2 - glibc-2-0.1.beta1.fc10.rpm - glibc-common-5-0.2.beta2.fc9.ebuild - glibc-common-5-0.2b.deb - glibc-common-11b.ebuild - glibc-common-11-0.6rc2.ebuild - libstdc++-0.5.8.11-0.7rc2.fc10.tar.gz - libstdc++-4a.fc8.tar.gz - libstdc++-4.10.4.20040204svn.rpm - libstdc++-devel-3.fc8.ebuild - libstdc++-devel-3a.fc9.tar.gz - libstdc++-devel-8.fc8.deb - libstdc++-devel-8.6.2-0.4b.fc8 - nss_ldap-1-0.2b.fc9.tar.bz2 - nss_ldap-1-0.6rc2.fc8.tar.gz - nss_ldap-1.0-0.1a.tar.gz - nss_ldap-10beta1.fc8.tar.gz - nss_ldap-10.11.8.6.20040204cvs.fc10.ebuild - string start 5.0.0 end of str - string start 5.1.0 end of str - string start 5.2.0 end of str - string start 5.3.0 end of str - string start 5.4.0 end of str - string start 5.5.0 end of str - string start 5.6.0 end of str - string start 5.7.0 end of str - string start 5.8.0 end of str - string start 5.9.0 end of str - string start 5.10.0 end of str - string start 5.20.0 end of str - string start 5.30.0 end of str - string start 5.40.0 end of str - string start 5.50.0 end of str - string start 5.60.0 end of str - string start 5.70.0 end of str - string start 5.80.0 end of str - string start 5.90.0 end of str - _EOF_ + gcc-c++-10.fc9.tar.gz + gcc-c++-10.8.12-0.7rc2.fc9.tar.bz2 + glibc-2-0.1.beta1.fc10.rpm + glibc-common-5-0.2.beta2.fc9.ebuild + glibc-common-5-0.2b.deb + glibc-common-11b.ebuild + glibc-common-11-0.6rc2.ebuild + libstdc++-0.5.8.11-0.7rc2.fc10.tar.gz + libstdc++-4a.fc8.tar.gz + libstdc++-4.10.4.20040204svn.rpm + libstdc++-devel-3.fc8.ebuild + libstdc++-devel-3a.fc9.tar.gz + libstdc++-devel-8.fc8.deb + libstdc++-devel-8.6.2-0.4b.fc8 + nss_ldap-1-0.2b.fc9.tar.bz2 + nss_ldap-1-0.6rc2.fc8.tar.gz + nss_ldap-1.0-0.1a.tar.gz + nss_ldap-10beta1.fc8.tar.gz + nss_ldap-10.11.8.6.20040204cvs.fc10.ebuild + string start 5.0.0 end of str + string start 5.1.0 end of str + string start 5.2.0 end of str + string start 5.3.0 end of str + string start 5.4.0 end of str + string start 5.5.0 end of str + string start 5.6.0 end of str + string start 5.7.0 end of str + string start 5.8.0 end of str + string start 5.9.0 end of str + string start 5.10.0 end of str + string start 5.20.0 end of str + string start 5.30.0 end of str + string start 5.40.0 end of str + string start 5.50.0 end of str + string start 5.60.0 end of str + string start 5.70.0 end of str + string start 5.80.0 end of str + string start 5.90.0 end of str + _EOF_ fail=0 sort --sort=version -o out in || fail=1 diff --git a/tests/misc/stat-printf b/tests/misc/stat-printf index b459e3bd1..05ff5a23c 100755 --- a/tests/misc/stat-printf +++ b/tests/misc/stat-printf @@ -40,7 +40,7 @@ my @Tests = ['hex-1', q!--printf='\x34\xf' .!, {OUT=>"\x34\xf"}], ['hex-2', q!--printf='.\x18p\xfq' .!, {OUT=>".\x18p\x0fq"}], ['hex-3', q!--printf='\x' .!, {OUT=>'x'}, - {ERR=>"$prog: warning: unrecognized escape `\\x'\n"}], + {ERR=>"$prog: warning: unrecognized escape `\\x'\n"}], # With --format, there *is* a trailing newline. ['f-nl', "--format=%n .", {OUT=>".\n"}], @@ -49,12 +49,12 @@ my @Tests = ['end-pct', "--printf=% .", {OUT=>"%"}], ['pct-pct', "--printf=%% .", {OUT=>"%"}], ['end-bs', "--printf='\\' .", {OUT=>'\\'}, - {ERR=>"$prog: warning: backslash at end of format\n"}], + {ERR=>"$prog: warning: backslash at end of format\n"}], ['err-1', "--printf=%9% .", {EXIT => 1}, - {ERR=>"$prog: %9%: invalid directive\n"}], + {ERR=>"$prog: %9%: invalid directive\n"}], ['err-2', "--printf=%9 .", {EXIT => 1}, - {ERR=>"$prog: %9: invalid directive\n"}], + {ERR=>"$prog: %9: invalid directive\n"}], ); my $save_temps = $ENV{DEBUG}; diff --git a/tests/misc/stty b/tests/misc/stty index b607ec08c..a7f93ca75 100755 --- a/tests/misc/stty +++ b/tests/misc/stty @@ -87,13 +87,13 @@ if test -n "$RUN_LONG_TESTS"; then rev1=`eval echo "\\\$REV_$opt1"` rev2=`eval echo "\\\$REV_$opt2"` if test -n "$rev1"; then - stty -$opt1 $opt2 || fail=1 + stty -$opt1 $opt2 || fail=1 fi if test -n "$rev2"; then - stty $opt1 -$opt2 || fail=1 + stty $opt1 -$opt2 || fail=1 fi if test "$rev1$rev2" = 11; then - stty -$opt1 -$opt2 || fail=1 + stty -$opt1 -$opt2 || fail=1 fi done done diff --git a/tests/misc/sum b/tests/misc/sum index 875960753..af3d7f80f 100755 --- a/tests/misc/sum +++ b/tests/misc/sum @@ -34,7 +34,7 @@ my @Tests = ['4', {IN=> {f=> 'message digest'}}, {OUT=>"26423 1\n"}], ['5', {IN=> {f=> 'abcdefghijklmnopqrstuvwxyz'}}, {OUT=>"53553 1\n"}], ['6', {IN=> {f=> join ('', 'A'..'Z', 'a'..'z', '0'..'9')}}, - {OUT=>"25587 1\n"}], + {OUT=>"25587 1\n"}], ['7', {IN=> {f=> '1234567890' x 8}}, {OUT=>"21845 1\n"}], ['a-r-1k', '-r', {IN=> {f=> $in_1k}}, {OUT=>"65409 1\n"}], @@ -49,7 +49,7 @@ my @Tests = ['5s', '-s', {IN=> {f=> 'abcdefghijklmnopqrstuvwxyz'}}, {OUT=>"2847 1 f\n"}], ['6s', '-s', {IN=> {f=> join ('', 'A'..'Z', 'a'..'z', '0'..'9')}}, - {OUT=>"5387 1 f\n"}], + {OUT=>"5387 1 f\n"}], ['7s', '-s', {IN=> {f=> '1234567890' x 8}}, {OUT=>"4200 1 f\n"}], ); diff --git a/tests/misc/tee b/tests/misc/tee index 1701b1430..86eca7d05 100755 --- a/tests/misc/tee +++ b/tests/misc/tee @@ -28,12 +28,12 @@ nums=`seq 9` || framework_failure fail=0 for n in 0 $nums; do - files=`seq $n` - rm -f $files - tee $files <sample >out || fail=1 - for f in out $files; do - compare sample $f || fail=1 - done + files=`seq $n` + rm -f $files + tee $files <sample >out || fail=1 + for f in out $files; do + compare sample $f || fail=1 + done done Exit $fail diff --git a/tests/misc/test b/tests/misc/test index dc20261d4..ff66261aa 100755 --- a/tests/misc/test +++ b/tests/misc/test @@ -33,12 +33,12 @@ sub digest_test ($) foreach my $e (@$t) { !ref $e - and push (@args, $e), next; + and push (@args, $e), next; ref $e eq 'HASH' - or (warn "$0: $t->[0]: unexpected entry type\n"), next; + or (warn "$0: $t->[0]: unexpected entry type\n"), next; exists $e->{EXIT} - and $ret = $e->{EXIT}, next; + and $ret = $e->{EXIT}, next; push @list_of_hashref, $e; } @@ -70,16 +70,16 @@ sub add_inverse_op_tests($) # Generate corresponding tests of inverse ops. # E.g. generate tests of `-ge' from those of `-lt'. foreach my $op (qw(gt lt eq)) - { - if ($test_name =~ /$op-/ && $flags =~ / -$op /) - { - my $inv = $inverse_op{$op}; - $test_name =~ s/$op/$inv/; - $flags =~ s/-$op/-$inv/; - $ret = 1 - $ret; - push (@new, [$test_name, $flags, {EXIT=>$ret}, @$LoH]); - } - } + { + if ($test_name =~ /$op-/ && $flags =~ / -$op /) + { + my $inv = $inverse_op{$op}; + $test_name =~ s/$op/$inv/; + $flags =~ s/-$op/-$inv/; + $ret = 1 - $ret; + push (@new, [$test_name, $flags, {EXIT=>$ret}, @$LoH]); + } + } } return @new; } @@ -93,8 +93,8 @@ sub add_pn_tests($) # There are a few exceptions. my %not_N = map {$_ => 1} qw (1a); my %not_P = map {$_ => 1} qw (1a - streq-6 strne-6 - paren-1 paren-2 paren-3 paren-4 paren-5); + streq-6 strne-6 + paren-1 paren-2 paren-3 paren-4 paren-5); foreach my $t (@$tests) { push @new, $t; @@ -104,13 +104,13 @@ sub add_pn_tests($) next if $ret == 2; push (@new, ["N-$test_name", "! $flags", {EXIT=>1-$ret}, @$LoH]) - unless $not_N{$test_name}; + unless $not_N{$test_name}; push (@new, ["P-$test_name", "'(' $flags ')'", {EXIT=>$ret}, @$LoH]) - unless $not_P{$test_name}; + unless $not_P{$test_name}; push (@new, ["NP-$test_name", "! '(' $flags ')'", {EXIT=>1-$ret}, @$LoH]) - unless $not_P{$test_name}; + unless $not_P{$test_name}; push (@new, ["NNP-$test_name", "! ! '(' $flags ')'", {EXIT=>$ret, @$LoH}]) - unless $not_P{$test_name}; + unless $not_P{$test_name}; } return @new; diff --git a/tests/misc/tty-eof b/tests/misc/tty-eof index ee33864d9..13ddbc8a3 100755 --- a/tests/misc/tty-eof +++ b/tests/misc/tty-eof @@ -67,10 +67,10 @@ $@ and (warn "$ME: this script requires Perl's Expect package >=1.11\n"), 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"); + or $exp->send("a b\n"); $exp->send("\cD"); # This is Control-D. FIXME: what if that's not EOF? $exp->expect (0, '-re', "^a b\\r?\$"); my $found = $exp->expect (1, '-re', "^.+\$"); @@ -78,32 +78,32 @@ $@ and (warn "$ME: this script requires Perl's Expect package >=1.11\n"), $exp->expect(1, 'eof'); # Expect no output from cut, since we gave it no input. defined $found || $cmd =~ /^cut/ - or (warn "$ME: $cmd didn't produce expected output\n"), - $fail=1, next; + or (warn "$ME: $cmd didn't produce expected output\n"), + $fail=1, next; defined $exp->exitstatus - or (warn "$ME: $cmd didn't exit after ^D from standard input\n"), - $fail=1, next; + or (warn "$ME: $cmd didn't exit after ^D from standard input\n"), + $fail=1, next; my $s = $exp->exitstatus; $s == 0 - or (warn "$ME: $cmd exited with status $s (expected 0)\n"), - $fail=1; + or (warn "$ME: $cmd exited with status $s (expected 0)\n"), + $fail=1; $exp->hard_close(); # dd normally writes to stderr. If it exits successfully, we're done. $cmd eq 'dd' && $s == 0 - and next; + and next; if (-s $stderr) - { - warn "$ME: $cmd wrote to stderr:\n"; - system "cat $stderr"; - $fail = 1; - } + { + warn "$ME: $cmd wrote to stderr:\n"; + system "cat $stderr"; + $fail = 1; + } } continue { unlink $stderr - or warn "$ME: failed to remove stderr file from $cmd, $stderr: $!\n"; + or warn "$ME: failed to remove stderr file from $cmd, $stderr: $!\n"; } exit $fail diff --git a/tests/misc/uniq b/tests/misc/uniq index 3153581fe..689115aa9 100755 --- a/tests/misc/uniq +++ b/tests/misc/uniq @@ -38,42 +38,42 @@ sub add_z_variants($) # skip the obsolete-syntax tests $t->[0] =~ /^obs-plus/ - and next; + and next; my @args; my @list_of_hash; foreach my $e (@$t) - { - !ref $e - and push (@args, $e), next; - - ref $e && ref $e eq 'HASH' - or (warn "$0: $t->[0]: unexpected entry type\n"), next; - my $tmp = $e; - foreach my $k (qw(IN OUT)) - { - my $val = $e->{$k}; - # skip any test whose input or output already contains a NUL byte - if (defined $val) - { - $val =~ /\0/ - and next TEST; - - # Convert each NL in input or output to \0. - $val =~ s/\n/\0/g; - $tmp = {$k => $val}; - last; - } - } - push @list_of_hash, $tmp; - } + { + !ref $e + and push (@args, $e), next; + + ref $e && ref $e eq 'HASH' + or (warn "$0: $t->[0]: unexpected entry type\n"), next; + my $tmp = $e; + foreach my $k (qw(IN OUT)) + { + my $val = $e->{$k}; + # skip any test whose input or output already contains a NUL byte + if (defined $val) + { + $val =~ /\0/ + and next TEST; + + # Convert each NL in input or output to \0. + $val =~ s/\n/\0/g; + $tmp = {$k => $val}; + last; + } + } + push @list_of_hash, $tmp; + } shift @args; # discard test name # skip any test that uses the -z option grep /z/, @args - and next; + and next; push @new, ["$t->[0]-z", '-z', @args, @list_of_hash]; } diff --git a/tests/misc/wc-files0-from b/tests/misc/wc-files0-from index b247c54c6..4dbfd7bca 100755 --- a/tests/misc/wc-files0-from +++ b/tests/misc/wc-files0-from @@ -31,8 +31,8 @@ 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" - . "file operands cannot be combined with --files0-from\n" - . "Try `$prog --help' for more information.\n"} + . "file operands cannot be combined with --files0-from\n" + . "Try `$prog --help' for more information.\n"} ], # missing input file diff --git a/tests/mkdir/perm b/tests/mkdir/perm index 146a88e29..af2bdcd63 100755 --- a/tests/mkdir/perm +++ b/tests/mkdir/perm @@ -66,8 +66,8 @@ for p in empty -p; do # and adjust expectations accordingly. test x$p = x && \ { - mkdir -m =,u=rwx parent || fail=1 - parent_perms=drwx------ + mkdir -m =,u=rwx parent || fail=1 + parent_perms=drwx------ } mkdir $p $mode parent/sub || fail=1 diff --git a/tests/mv/part-symlink b/tests/mv/part-symlink index 78da70a39..71788b905 100755 --- a/tests/mv/part-symlink +++ b/tests/mv/part-symlink @@ -83,67 +83,67 @@ for copy in cp mv; do actual_args=`eval echo $actual_args` ( - ( - # echo 1>&2 cp $options $args - $copy $options $actual_args 2>.err - copy_status=$? - echo $copy_status $copy $options $args - - # Normalize the program name in the error output, - # remove any site-dependent part of other-partition file name, - # and put brackets around the output. - test -s .err && { - echo '[' | tr -d '\n' - sed 's/^[^:][^:]*\(..\):/\1:/;s,'$other_partition_tmpdir/,, .err - echo ']' | tr -d '\n' - } - # Strip off all but the file names. - # Remove any site-dependent part of each file name. - ls=`ls -gG --ignore=.err . \ - | sed \ - -e '/^total /d' \ - -e s,$other_partition_tmpdir/,, \ - -e "s,$pwd_tmp/,," \ - -e 's/^[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *//'` - ls2=`cd $other_partition_tmpdir && ls -gG --ignore=.err . \ - | sed \ - -e '/^total /d' \ - -e s,$other_partition_tmpdir/,, \ - -e "s,$pwd_tmp/,," \ - -e 's/^[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *//'` - echo "($ls) ($ls2)" - - # If the command failed, then it must not have changed the files. - if test $copy_status != 0; then - for f in $actual_args; do - test -f $f || - { echo "$copy FAILED but removed $f"; continue; } - case "`cat $f`" in - "$contents") ;; - *) echo "$copy FAILED but modified $f";; - esac - done - fi - - if test $copy = cp; then - # Make sure the original is unchanged and that - # the destination is a copy. - for f in $actual_args; do - if test -f $f; then - if test $copy_status != 0; then - test - fi - case "`cat $f`" in - "$contents") ;; - *) echo $copy FAILED;; - esac - else - echo symlink-loop - fi - done - fi - ) | tr '\n' ' ' - echo + ( + # echo 1>&2 cp $options $args + $copy $options $actual_args 2>.err + copy_status=$? + echo $copy_status $copy $options $args + + # Normalize the program name in the error output, + # remove any site-dependent part of other-partition file name, + # and put brackets around the output. + test -s .err && { + echo '[' | tr -d '\n' + sed 's/^[^:][^:]*\(..\):/\1:/;s,'$other_partition_tmpdir/,, .err + echo ']' | tr -d '\n' + } + # Strip off all but the file names. + # Remove any site-dependent part of each file name. + ls=`ls -gG --ignore=.err . \ + | sed \ + -e '/^total /d' \ + -e s,$other_partition_tmpdir/,, \ + -e "s,$pwd_tmp/,," \ + -e 's/^[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *//'` + ls2=`cd $other_partition_tmpdir && ls -gG --ignore=.err . \ + | sed \ + -e '/^total /d' \ + -e s,$other_partition_tmpdir/,, \ + -e "s,$pwd_tmp/,," \ + -e 's/^[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *//'` + echo "($ls) ($ls2)" + + # If the command failed, then it must not have changed the files. + if test $copy_status != 0; then + for f in $actual_args; do + test -f $f || + { echo "$copy FAILED but removed $f"; continue; } + case "`cat $f`" in + "$contents") ;; + *) echo "$copy FAILED but modified $f";; + esac + done + fi + + if test $copy = cp; then + # Make sure the original is unchanged and that + # the destination is a copy. + for f in $actual_args; do + if test -f $f; then + if test $copy_status != 0; then + test + fi + case "`cat $f`" in + "$contents") ;; + *) echo $copy FAILED;; + esac + else + echo symlink-loop + fi + done + fi + ) | tr '\n' ' ' + echo ) | sed 's/ *$//' cd .. done diff --git a/tests/rm/fail-eperm b/tests/rm/fail-eperm index 20ce77040..9ccb913a6 100755 --- a/tests/rm/fail-eperm +++ b/tests/rm/fail-eperm @@ -51,89 +51,89 @@ foreach my $dir (@dir_list) { if (-d $dir && -k _ && -r _ && -w _ && -x _) { - $found_dir = 1; - - # Find a non-directory there that is owned by some other user. - opendir DIR_HANDLE, $dir - or die "$ME: couldn't open $dir: $!\n"; - - foreach my $f (readdir DIR_HANDLE) - { - # Consider only names containing "safe" characters. - $f =~ /^([-\@\w.]+)$/ - or next; - $f = $1; # untaint $f - - my $target_file = "$dir/$f"; - $verbose - and warn "$ME: considering $target_file\n"; - - # Skip files owned by self, symlinks, and directories. - # It's not technically necessary to skip symlinks, but it's simpler. - # SVR4-like systems (e.g., Solaris 9) let you unlink files that - # you can write, so skip writable files too. - -l $target_file || -o _ || -d _ || -w _ - and next; - - $found_file = 1; - - # Invoke rm on this file and ensure that we get the - # expected exit code and diagnostic. - my $cmd = "$rm -f -- $target_file"; - open RM, "$cmd 2>&1 |" - or die "$ME: cannot execute `$cmd'\n"; - - my $line = <RM>; - - close RM; - my $rc = $?; - # This test opportunistically looks for files that can't - # be removed but those files may already have been removed - # by their owners by the time we get to them. It is a - # race condition. If so then the rm is successful and our - # test is thwarted. Detect this case and ignore. - if ($rc == 0) - { - next if ! -e $target_file; - 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" - . " 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"; - } - - my $exp = "rm: cannot remove `$target_file':"; - $line - 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 - # "../../src/rm:". - $line =~ s,^\Q$rm\E:,rm:,; - - my $regex = quotemeta $exp; - $line =~ /^$regex/ - or die "$ME: unexpected diagnostic from `$cmd';\n" - . " got $line" - . " expected $exp ...\n"; - - last; - } - - closedir DIR_HANDLE; - $found_file - and last; + $found_dir = 1; + + # Find a non-directory there that is owned by some other user. + opendir DIR_HANDLE, $dir + or die "$ME: couldn't open $dir: $!\n"; + + foreach my $f (readdir DIR_HANDLE) + { + # Consider only names containing "safe" characters. + $f =~ /^([-\@\w.]+)$/ + or next; + $f = $1; # untaint $f + + my $target_file = "$dir/$f"; + $verbose + and warn "$ME: considering $target_file\n"; + + # Skip files owned by self, symlinks, and directories. + # It's not technically necessary to skip symlinks, but it's simpler. + # SVR4-like systems (e.g., Solaris 9) let you unlink files that + # you can write, so skip writable files too. + -l $target_file || -o _ || -d _ || -w _ + and next; + + $found_file = 1; + + # Invoke rm on this file and ensure that we get the + # expected exit code and diagnostic. + my $cmd = "$rm -f -- $target_file"; + open RM, "$cmd 2>&1 |" + or die "$ME: cannot execute `$cmd'\n"; + + my $line = <RM>; + + close RM; + my $rc = $?; + # This test opportunistically looks for files that can't + # be removed but those files may already have been removed + # by their owners by the time we get to them. It is a + # race condition. If so then the rm is successful and our + # test is thwarted. Detect this case and ignore. + if ($rc == 0) + { + next if ! -e $target_file; + 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" + . " 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"; + } + + my $exp = "rm: cannot remove `$target_file':"; + $line + 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 + # "../../src/rm:". + $line =~ s,^\Q$rm\E:,rm:,; + + my $regex = quotemeta $exp; + $line =~ /^$regex/ + or die "$ME: unexpected diagnostic from `$cmd';\n" + . " got $line" + . " expected $exp ...\n"; + + last; + } + + closedir DIR_HANDLE; + $found_file + and last; } } diff --git a/tests/touch/dangling-symlink b/tests/touch/dangling-symlink index 1c4d73c13..f3ea29a7f 100755 --- a/tests/touch/dangling-symlink +++ b/tests/touch/dangling-symlink @@ -39,13 +39,13 @@ if test $fail = 1; then *linux-gnu*) case "`uname -r`" in 2.3.9[0-9]*) - skip_test_ \ + skip_test_ \ '**************************************************** WARNING!!! This version of the Linux kernel causes touch to fail when operating on dangling symlinks. ****************************************************' - ;; + ;; esac ;; esac |