Blame tests/du/files0-from-dir.sh

Packit 9e4112
#!/bin/sh
Packit 9e4112
# ensure that du and wc handle --files0-from=DIR
Packit 9e4112
Packit 9e4112
# Copyright (C) 2011-2018 Free Software Foundation, Inc.
Packit 9e4112
Packit 9e4112
# This program is free software: you can redistribute it and/or modify
Packit 9e4112
# it under the terms of the GNU General Public License as published by
Packit 9e4112
# the Free Software Foundation, either version 3 of the License, or
Packit 9e4112
# (at your option) any later version.
Packit 9e4112
Packit 9e4112
# This program is distributed in the hope that it will be useful,
Packit 9e4112
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 9e4112
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 9e4112
# GNU General Public License for more details.
Packit 9e4112
Packit 9e4112
# You should have received a copy of the GNU General Public License
Packit 9e4112
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
Packit 9e4112
Packit 9e4112
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
Packit 9e4112
print_ver_ du wc
Packit 9e4112
Packit 9e4112
mkdir dir
Packit 9e4112
Packit 9e4112
# Skip this test if reading from a directory succeeds.
Packit 9e4112
# In that case, using --files0-from=dir would yield garbage,
Packit 9e4112
# interpreting the directory entry as a sequence of
Packit 9e4112
# NUL-separated file names.
Packit 9e4112
cat dir > /dev/null && skip_ "cat dir/ succeeds"
Packit 9e4112
Packit 9e4112
for prog in du wc; do
Packit 9e4112
  $prog --files0-from=dir > /dev/null 2>err && fail=1
Packit 9e4112
  printf "$prog: dir:\n" > exp || fail=1
Packit 9e4112
  # The diagnostic string is usually "Is a directory" (ENOTDIR),
Packit 9e4112
  # but accept a different string or errno value.
Packit 9e4112
  sed "s/dir:.*/dir:/" err > k; mv k err
Packit 9e4112
  compare exp err || fail=1
Packit 9e4112
done
Packit 9e4112
Packit 9e4112
Exit $fail