2 # Test use of compression by sort
4 # Copyright (C) 2007-2024 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
23 seq -w 2000 > exp || framework_failure_
24 tac exp
> in || framework_failure_
26 # This should force the use of temp files
27 sort -S 1k
in > out || fail
=1
28 compare exp out || fail
=1
30 # Create our own gzip program that will be used as the default
31 cat <<EOF > gzip || framework_failure_
39 # Ensure 'sort' is immune to parent's SIGCHLD handler
40 # Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh.
44 # This should force the use of child processes for "compression"
45 PATH
=.
:$PATH exec sort -S 1k
--compress-program=gzip in > /dev
/null
48 # This will find our new gzip in PATH
49 PATH
=.
:$PATH sort -S 1k
--compress-program=gzip in > out || fail
=1
50 compare exp out || fail
=1
54 # This is to make sure it works with no compression.
55 PATH
=.
:$PATH sort -S 1k
in > out || fail
=1
56 compare exp out || fail
=1
59 # This is to make sure we can use something other than gzip
60 mv gzip dzip || fail
=1
61 sort --compress-program=.
/dzip
-S 1k
in > out || fail
=1
62 compare exp out || fail
=1
66 # Make sure it can find other programs in PATH correctly
67 PATH
=.
:$PATH sort --compress-program=dzip
-S 1k
in > out || fail
=1
68 compare exp out || fail
=1