2 # Exercise split's new --filter option.
4 # Copyright (C) 2011 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 <http://www.gnu.org/licenses/>.
19 . "${srcdir=.}/init.sh"; path_prepend_ ../src
21 xz --version || skip_test_ "xz (better than gzip/bzip2) required"
23 for total_n_lines in 5 3000 20000; do
24 seq $total_n_lines > in || framework_failure_
27 # Don't create too many files/processes.
28 # Starting 10k (or even "only" 1500) processes would take a long time,
29 # and would provide little added benefit.
30 case $i:$total_n_lines in 2:5);; *) continue;; esac
32 split -l$i --filter='xz > $FILE.xz' in out- || fail=1
33 xz -dc out-* > out || fail=1
34 compare in out || fail=1
40 # Show how --elide-empty-files works with --filter:
41 # split does not run the command (and effectively elides the file)
42 # only when the output to that command would have been empty.
43 split -e -n 10 --filter='xz > $FILE.xz' /dev/null || fail=1
44 stat x?? 2>/dev/null && fail=1
46 # Ensure SIGPIPEs sent by the children don't propagate back
47 # where they would result in a non zero exit from split.
48 yes | head -n200K | split -b1G --filter='head -c1 >/dev/null' || fail=1
50 # Ensure that endless input is ignored when all filters finish
51 timeout 10 yes | split --filter="head -c1 >/dev/null" -n r/1 || fail=1
52 timeout 10 split --filter="head -c1 >/dev/null" -n 1 /dev/zero || fail=1