diff options
author | Jim Meyering <jim@meyering.net> | 2007-01-26 11:15:31 +0100 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2007-01-26 11:15:31 +0100 |
commit | ebc2235bd7e61b22e345ac6adaf4fdb03c753b3a (patch) | |
tree | 0ae1632cc746c808eeb8108387927c4c15af595b /tests | |
parent | cece28a8bc805789bba926b928d3fe61488b8a07 (diff) | |
download | coreutils-ebc2235bd7e61b22e345ac6adaf4fdb03c753b3a.tar.xz |
merge from trunk
Diffstat (limited to 'tests')
-rw-r--r-- | tests/misc/Makefile.am | 5 | ||||
-rwxr-xr-x | tests/misc/pwd-long | 38 | ||||
-rwxr-xr-x | tests/misc/sort-compress | 92 | ||||
-rw-r--r-- | tests/sort/Makefile.am | 72 | ||||
-rwxr-xr-x | tests/sort/Test.pm | 4 |
5 files changed, 170 insertions, 41 deletions
diff --git a/tests/misc/Makefile.am b/tests/misc/Makefile.am index 4ad145c4b..c4c279d67 100644 --- a/tests/misc/Makefile.am +++ b/tests/misc/Makefile.am @@ -1,7 +1,6 @@ # Make miscellaneous coreutils tests. -*-Makefile-*- -# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software -# Foundation, Inc. +# Copyright (C) 200-2007 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -22,6 +21,7 @@ EXTRA_DIST = $(TESTS) TESTS_ENVIRONMENT = \ top_srcdir=$(top_srcdir) \ + abs_top_builddir=$(abs_top_builddir) \ srcdir=$(srcdir) \ PACKAGE_VERSION=$(PACKAGE_VERSION) \ PERL="$(PERL)" \ @@ -69,6 +69,7 @@ TESTS = \ sha384sum \ sha512sum \ shuf \ + sort-compress \ sort-merge \ sort-rand \ split-a \ diff --git a/tests/misc/pwd-long b/tests/misc/pwd-long index 546550ef2..1306b327a 100755 --- a/tests/misc/pwd-long +++ b/tests/misc/pwd-long @@ -1,7 +1,7 @@ #!/bin/sh # Ensure that pwd works even when run from a very deep directory. -# Copyright (C) 2006 Free Software Foundation, Inc. +# Copyright (C) 2006-2007 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -51,18 +51,39 @@ $PERL -Tw -- - <<\EOF # Show that pwd works even when the length of the resulting # directory name is longer than PATH_MAX. use strict; -use Cwd; (my $ME = $ENV{ARGV_0}) =~ s|.*/||; +sub normalize_to_cwd_relative ($$$) +{ + my ($dir, $dev, $ino) = @_; + my $slash = -1; + my $next_slash; + while (1) + { + $slash = index $dir, '/', $slash + 1; + $slash <= -1 + 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; + } +} + # Set up a safe, well-known environment delete @ENV{qw(BASH_ENV CDPATH ENV PATH)}; $ENV{IFS} = ''; -my $cwd = $ENV{CWD}; +# Save CWD's device and inode numbers. +my ($dev, $ino) = (stat '.')[0, 1]; + +# Construct the expected "."-relative part of pwd's output. my $z = 'z' x 31; my $n = 256; -my $expected = $cwd . ("/$z" x $n); +my $expected = "/$z" x $n; +# Remove the leading "/". +substr ($expected, 0, 1) = ''; my $i = 0; do @@ -89,6 +110,15 @@ my $pwd_binary = "$build_src_dir/pwd"; -x $pwd_binary or die "$ME: $pwd_binary is not an executable file\n"; chomp (my $actual = `$pwd_binary`); + +# Convert the absolute name from pwd into a $CWD-relative name. +# This is necessary in order to avoid a spurious failure when run +# from a directory in a bind-mounted partition. What happens is +# pwd reads a ".." that contains two or more entries with identical +# dev,ino that match the ones we're looking for, and it chooses a +# name that does not correspond to the one already recorded in $CWD. +$actual = normalize_to_cwd_relative $actual, $dev, $ino; + if ($expected ne $actual) { my $e_len = length $expected; diff --git a/tests/misc/sort-compress b/tests/misc/sort-compress new file mode 100755 index 000000000..af961d202 --- /dev/null +++ b/tests/misc/sort-compress @@ -0,0 +1,92 @@ +#!/bin/sh +# Test use of compression by sort + +# Copyright (C) 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + sort --version +fi + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 +seq -w 2000 > exp || framework_failure=1 +tac exp > in || framework_failure=1 +SORT=$abs_top_builddir/src/sort + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +# This should force the use of temp files compressed with the default gzip +sort -S 1k in > out || fail=1 +cmp exp out || fail=1 +test $fail = 1 && diff out exp 2> /dev/null + +# Create our own gzip program that will be used as the default +cat <<\EOF > gzip || fail=1 +#!/bin/sh +tr 41 14 +touch ok +EOF + +chmod +x gzip + +# This will find our new gzip in PATH +PATH=.:$PATH sort -S 1k in > out || fail=1 +cmp exp out || fail=1 +test $fail = 1 && diff out exp 2> /dev/null +test -f ok || fail=1 +rm -f ok + +# This is to make sure we can disable compression +PATH=.:$PATH GNUSORT_COMPRESSOR= sort -S 1k in > out || fail=1 +cmp exp out || fail=1 +test $fail = 1 && diff out exp 2> /dev/null +test -f ok && fail=1 + +# This is to make sure we can use something other than gzip +mv gzip dzip || fail=1 +GNUSORT_COMPRESSOR=./dzip sort -S 1k in > out || fail=1 +cmp exp out || fail=1 +test $fail = 1 && diff out exp 2> /dev/null +test -f ok || fail=1 +rm -f ok + +# Make sure it can find other programs in PATH correctly +PATH=.:$PATH GNUSORT_COMPRESSOR=dzip sort -S 1k in > out || fail=1 +cmp exp out || fail=1 +test $fail = 1 && diff out exp 2> /dev/null +test -f ok || fail=1 +rm -f dzip ok + +# This is to make sure sort functions if it can't find the default gzip +PATH=. "$SORT" -S 1k in > out || fail=1 +cmp exp out || fail=1 +test $fail = 1 && diff out exp 2> /dev/null + +(exit $fail); exit $fail diff --git a/tests/sort/Makefile.am b/tests/sort/Makefile.am index 2a91a5cbb..66600e5a2 100644 --- a/tests/sort/Makefile.am +++ b/tests/sort/Makefile.am @@ -24,44 +24,46 @@ explicit = maint_gen = n1.I n1.X n2.I n2.X n3.I n3.X n4.I n4.X n5.I n5.X n6.I n6.X n7.I \ n7.X n8a.I n8a.X n8b.I n8b.X n9a.I n9a.X n9b.I n9b.X n10a.I n10a.X n10b.I \ n10b.X n11a.I n11a.X n11b.I n11b.X 01a.I 01a.X 02a.I 02a.X 02b.I 02b.X 02c.I \ -02c.X 02m.I 02m.X 02n.I 02n.X 02o.I 02o.X 02p.I 02p.X 03a.I 03a.X 03b.I 03b.X \ -03c.I 03c.X 03d.I 03d.X 03e.I 03e.X 03f.I 03f.X 03g.I 03g.X 03h.I 03h.X 03i.I \ -03i.X 04a.I 04a.X 04b.I 04b.X 04c.I 04c.X 04d.I 04d.X 04e.I 04e.X 05a.I 05a.X \ -05b.I 05b.X 05c.I 05c.X 05d.I 05d.X 05e.I 05e.X 05f.I 05f.X 06a.I 06a.X 06b.I \ -06b.X 06c.I 06c.X 06d.I 06d.X 06e.I 06e.X 06f.I 06f.X 07a.I 07a.X 07b.I 07b.X \ -07c.I 07c.X 07d.I 07d.X 08a.I 08a.X 08b.I 08b.X 09a.I 09a.X 09b.I 09b.X 09c.I \ -09c.X 09d.I 09d.X 10a.I 10a.X 10b.I 10b.X 10c.I 10c.X 10d.I 10d.X 10a0.I \ -10a0.X 10a1.I 10a1.X 10a2.I 10a2.X 10e.I 10e.X 10f.I 10f.X 10g.I 10g.X 11a.I \ -11a.X 11b.I 11b.X 11c.I 11c.X 11d.I 11d.X 12a.I 12a.X 12b.I 12b.X 12c.I 12c.X \ -12d.I 12d.X 13a.I 13a.X 13b.I 13b.X 14a.I 14a.X 14b.I 14b.X 15a.I 15a.X 15b.I \ -15b.X 15c.I 15c.X 15d.I 15d.X 15e.I 15e.X 16a.I 16a.X 17.I 17.X 18a.I 18a.X \ -18b.I 18b.X 18c.I 18c.X 18d.I 18d.X 18e.I 18e.X 19a.I 19a.X 19b.I 19b.X 20a.I \ -20a.X 21a.I 21a.X 21b.I 21b.X 21c.I 21c.X 21d.I 21d.X 21e.I 21e.X 21f.I 21f.X \ -21g.I 21g.X 22a.I 22a.X 22b.I 22b.X no-file1.X o-no-file1.X create-empty.X \ -neg-nls.I neg-nls.X nul-nls.I nul-nls.X use-nl.I use-nl.X o2.I o2.X \ -incompat1.I incompat1.X incompat2.I incompat2.X incompat3.I incompat3.X \ -incompat4.I incompat4.X nul-tab.I nul-tab.X bigfield.I bigfield.X +02c.X 02d.I 02d.X 02e.I 02e.X 02m.I 02m.X 02n.I 02n.X 02o.I 02o.X 02p.I 02p.X \ +03a.I 03a.X 03b.I 03b.X 03c.I 03c.X 03d.I 03d.X 03e.I 03e.X 03f.I 03f.X 03g.I \ +03g.X 03h.I 03h.X 03i.I 03i.X 04a.I 04a.X 04b.I 04b.X 04c.I 04c.X 04d.I 04d.X \ +04e.I 04e.X 05a.I 05a.X 05b.I 05b.X 05c.I 05c.X 05d.I 05d.X 05e.I 05e.X 05f.I \ +05f.X 06a.I 06a.X 06b.I 06b.X 06c.I 06c.X 06d.I 06d.X 06e.I 06e.X 06f.I 06f.X \ +07a.I 07a.X 07b.I 07b.X 07c.I 07c.X 07d.I 07d.X 08a.I 08a.X 08b.I 08b.X 09a.I \ +09a.X 09b.I 09b.X 09c.I 09c.X 09d.I 09d.X 10a.I 10a.X 10b.I 10b.X 10c.I 10c.X \ +10d.I 10d.X 10a0.I 10a0.X 10a1.I 10a1.X 10a2.I 10a2.X 10e.I 10e.X 10f.I 10f.X \ +10g.I 10g.X 11a.I 11a.X 11b.I 11b.X 11c.I 11c.X 11d.I 11d.X 12a.I 12a.X 12b.I \ +12b.X 12c.I 12c.X 12d.I 12d.X 13a.I 13a.X 13b.I 13b.X 14a.I 14a.X 14b.I 14b.X \ +15a.I 15a.X 15b.I 15b.X 15c.I 15c.X 15d.I 15d.X 15e.I 15e.X 16a.I 16a.X 17.I \ +17.X 18a.I 18a.X 18b.I 18b.X 18c.I 18c.X 18d.I 18d.X 18e.I 18e.X 19a.I 19a.X \ +19b.I 19b.X 20a.I 20a.X 21a.I 21a.X 21b.I 21b.X 21c.I 21c.X 21d.I 21d.X 21e.I \ +21e.X 21f.I 21f.X 21g.I 21g.X 22a.I 22a.X 22b.I 22b.X no-file1.X o-no-file1.X \ +create-empty.X neg-nls.I neg-nls.X nul-nls.I nul-nls.X use-nl.I use-nl.X o2.I \ +o2.X incompat1.I incompat1.X incompat2.I incompat2.X incompat3.I incompat3.X \ +incompat4.I incompat4.X incompat5.I incompat5.X incompat6.I incompat6.X \ +nul-tab.I nul-tab.X bigfield.I bigfield.X run_gen = n1.O n1.E n2.O n2.E n3.O n3.E n4.O n4.E n5.O n5.E n6.O n6.E n7.O \ n7.E n8a.O n8a.E n8b.O n8b.E n9a.O n9a.E n9b.O n9b.E n10a.O n10a.E n10b.O \ n10b.E n11a.O n11a.E n11b.O n11b.E 01a.O 01a.E 02a.O 02a.E 02b.O 02b.E 02c.O \ -02c.E 02m.O 02m.E 02n.O 02n.E 02o.O 02o.E 02p.O 02p.E 03a.O 03a.E 03b.O 03b.E \ -03c.O 03c.E 03d.O 03d.E 03e.O 03e.E 03f.O 03f.E 03g.O 03g.E 03h.O 03h.E 03i.O \ -03i.E 04a.O 04a.E 04b.O 04b.E 04c.O 04c.E 04d.O 04d.E 04e.O 04e.E 05a.O 05a.E \ -05b.O 05b.E 05c.O 05c.E 05d.O 05d.E 05e.O 05e.E 05f.O 05f.E 06a.O 06a.E 06b.O \ -06b.E 06c.O 06c.E 06d.O 06d.E 06e.O 06e.E 06f.O 06f.E 07a.O 07a.E 07b.O 07b.E \ -07c.O 07c.E 07d.O 07d.E 08a.O 08a.E 08b.O 08b.E 09a.O 09a.E 09b.O 09b.E 09c.O \ -09c.E 09d.O 09d.E 10a.O 10a.E 10b.O 10b.E 10c.O 10c.E 10d.O 10d.E 10a0.O \ -10a0.E 10a1.O 10a1.E 10a2.O 10a2.E 10e.O 10e.E 10f.O 10f.E 10g.O 10g.E 11a.O \ -11a.E 11b.O 11b.E 11c.O 11c.E 11d.O 11d.E 12a.O 12a.E 12b.O 12b.E 12c.O 12c.E \ -12d.O 12d.E 13a.O 13a.E 13b.O 13b.E 14a.O 14a.E 14b.O 14b.E 15a.O 15a.E 15b.O \ -15b.E 15c.O 15c.E 15d.O 15d.E 15e.O 15e.E 16a.O 16a.E 17.O 17.E 18a.O 18a.E \ -18b.O 18b.E 18c.O 18c.E 18d.O 18d.E 18e.O 18e.E 19a.O 19a.E 19b.O 19b.E 20a.O \ -20a.E 21a.O 21a.E 21b.O 21b.E 21c.O 21c.E 21d.O 21d.E 21e.O 21e.E 21f.O 21f.E \ -21g.O 21g.E 22a.O 22a.E 22b.O 22b.E no-file1.O no-file1.E o-no-file1.O \ -o-no-file1.E create-empty.O create-empty.E neg-nls.O neg-nls.E nul-nls.O \ -nul-nls.E use-nl.O use-nl.E o2.O o2.E incompat1.O incompat1.E incompat2.O \ -incompat2.E incompat3.O incompat3.E incompat4.O incompat4.E nul-tab.O \ -nul-tab.E bigfield.O bigfield.E +02c.E 02d.O 02d.E 02e.O 02e.E 02m.O 02m.E 02n.O 02n.E 02o.O 02o.E 02p.O 02p.E \ +03a.O 03a.E 03b.O 03b.E 03c.O 03c.E 03d.O 03d.E 03e.O 03e.E 03f.O 03f.E 03g.O \ +03g.E 03h.O 03h.E 03i.O 03i.E 04a.O 04a.E 04b.O 04b.E 04c.O 04c.E 04d.O 04d.E \ +04e.O 04e.E 05a.O 05a.E 05b.O 05b.E 05c.O 05c.E 05d.O 05d.E 05e.O 05e.E 05f.O \ +05f.E 06a.O 06a.E 06b.O 06b.E 06c.O 06c.E 06d.O 06d.E 06e.O 06e.E 06f.O 06f.E \ +07a.O 07a.E 07b.O 07b.E 07c.O 07c.E 07d.O 07d.E 08a.O 08a.E 08b.O 08b.E 09a.O \ +09a.E 09b.O 09b.E 09c.O 09c.E 09d.O 09d.E 10a.O 10a.E 10b.O 10b.E 10c.O 10c.E \ +10d.O 10d.E 10a0.O 10a0.E 10a1.O 10a1.E 10a2.O 10a2.E 10e.O 10e.E 10f.O 10f.E \ +10g.O 10g.E 11a.O 11a.E 11b.O 11b.E 11c.O 11c.E 11d.O 11d.E 12a.O 12a.E 12b.O \ +12b.E 12c.O 12c.E 12d.O 12d.E 13a.O 13a.E 13b.O 13b.E 14a.O 14a.E 14b.O 14b.E \ +15a.O 15a.E 15b.O 15b.E 15c.O 15c.E 15d.O 15d.E 15e.O 15e.E 16a.O 16a.E 17.O \ +17.E 18a.O 18a.E 18b.O 18b.E 18c.O 18c.E 18d.O 18d.E 18e.O 18e.E 19a.O 19a.E \ +19b.O 19b.E 20a.O 20a.E 21a.O 21a.E 21b.O 21b.E 21c.O 21c.E 21d.O 21d.E 21e.O \ +21e.E 21f.O 21f.E 21g.O 21g.E 22a.O 22a.E 22b.O 22b.E no-file1.O no-file1.E \ +o-no-file1.O o-no-file1.E create-empty.O create-empty.E neg-nls.O neg-nls.E \ +nul-nls.O nul-nls.E use-nl.O use-nl.E o2.O o2.E incompat1.O incompat1.E \ +incompat2.O incompat2.E incompat3.O incompat3.E incompat4.O incompat4.E \ +incompat5.O incompat5.E incompat6.O incompat6.E nul-tab.O nul-tab.E \ +bigfield.O bigfield.E ##test-files-end EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen) diff --git a/tests/sort/Test.pm b/tests/sort/Test.pm index 6bed61b7f..dc41d9212 100755 --- a/tests/sort/Test.pm +++ b/tests/sort/Test.pm @@ -51,6 +51,8 @@ my @tv = ( ["02a", '-c', "A\nB\nC\n", '', 0], ["02b", '-c', "A\nC\nB\n", '', 1], ["02c", '-c -k1,1', "a\na b\n", '', 0], +["02d", '-C', "A\nB\nC\n", '', 0], +["02e", '-C', "A\nC\nB\n", '', 1], # This should fail because there are duplicate keys ["02m", '-cu', "A\nA\n", '', 1], ["02n", '-cu', "A\nB\n", '', 0], @@ -272,6 +274,8 @@ my @tv = ( ["incompat2", '-fR', '', '', 2], ["incompat3", '-dfgiMnR', '', '', 2], ["incompat4", '-c -o /dev/null', '', '', 2], +["incompat5", '-C -o /dev/null', '', '', 2], +["incompat6", '-cC', '', '', 2], # -t '\0' is accepted, as of coreutils-5.0.91 ['nul-tab', "-k2,2 -t '\\0'", "a\0z\01\nb\0y\02\n", "b\0y\02\na\0z\01\n", 0], |