(linenum→info "unix/slp.c:2238")

coreutils/6.9/tests/help-version

    1: #! /bin/sh
    2: # Make sure all these programs work properly
    3: # when invoked with --help or --version.
    4: 
    5: # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
    6: # Foundation, Inc.
    7: 
    8: # This program is free software; you can redistribute it and/or modify
    9: # it under the terms of the GNU General Public License as published by
   10: # the Free Software Foundation; either version 2 of the License, or
   11: # (at your option) any later version.
   12: 
   13: # This program is distributed in the hope that it will be useful,
   14: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   15: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   16: # GNU General Public License for more details.
   17: 
   18: # You should have received a copy of the GNU General Public License
   19: # along with this program; if not, write to the Free Software
   20: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
   21: # 02110-1301, USA.
   22: 
   23: test "$VERBOSE" = yes && set -x
   24: 
   25: # Ensure that $SHELL is set to *some* value and exported.
   26: # This is required for dircolors, which would fail e.g., when
   27: # invoked via debuild (which removes SHELL from the environment).
   28: test "x$SHELL" = x && SHELL=/bin/sh
   29: export SHELL
   30: 
   31: . $srcdir/envvar-check
   32: 
   33: expected_failure_status_nohup=127
   34: expected_failure_status_printenv=2
   35: expected_failure_status_tty=3
   36: expected_failure_status_sort=2
   37: expected_failure_status_expr=3
   38: expected_failure_status_lbracket=2
   39: expected_failure_status_dir=2
   40: expected_failure_status_ls=2
   41: expected_failure_status_vdir=2
   42: 
   43: case "$all_programs" in
   44:   *groups*)
   45:     if test -w /dev/full && test -c /dev/full \
   46:         && echo > /dev/full 2>/dev/null; then
   47:       cat 1>&2 <<\EOF
   48: ************************************************
   49: WARNING: On this system, the built-in echo function of /bin/sh
   50: does not report failure when writing to a full device.
   51: To demonstrate, run this command:
   52: 
   53:   /bin/sh -c 'echo hello > /dev/full; echo status=$?'
   54: 
   55: Notice that the failing echo leaves its exit status set to zero
   56: and does not produce a diagnostic.
   57: 
   58: That bug in /bin/sh would cause the test of the groups
   59: scripts to fail, so it is being removed from the list of
   60: programs checked by this test.
   61: ************************************************
   62: EOF
   63:       all_programs=`echo $all_programs | tr ' ' '\n' | grep -v '^groups$'`
   64:     fi
   65:   ;;
   66: esac
   67: 
   68: fail=0
   69: 
   70: for lang in C fr da; do
   71:   for i in $all_programs; do
   72: 
   73:     # Skip `test'; it doesn't accept --help or --version.
   74:     test $i = test && continue;
   75: 
   76:     # false fails even when invoked with --help or --version.
   77:     if test $i = false; then
   78:       env LC_MESSAGES=$lang ../src/$i --help    >/dev/null && fail=1
   79:       env LC_MESSAGES=$lang ../src/$i --version >/dev/null && fail=1
   80:       continue
   81:     fi
   82: 
   83:     # The just-built install executable is always named `ginstall'.
   84:     test $i = install && i=ginstall
   85: 
   86:     # Make sure they exit successfully, under normal conditions.
   87:     ../src/$i --help    > h-$i     || fail=1
   88:     ../src/$i --version >/dev/null || fail=1
   89: 
   90:     # Make sure they mention the bug-reporting address in --help output.
   91:     grep "$PACKAGE_BUGREPORT" h-$i > /dev/null || fail=1
   92:     rm -f h-$i
   93: 
   94:     # Make sure they fail upon `disk full' error.
   95:     if test -w /dev/full && test -c /dev/full; then
   96:       ../src/$i --help    >/dev/full 2>/dev/null && fail=1
   97:       ../src/$i --version >/dev/full 2>/dev/null && fail=1
   98:       status=$?
   99:       test $i = [ && prog=lbracket || prog=$i
  100:       eval "expected=\$expected_failure_status_$prog"
  101:       test x$expected = x && expected=1
  102:       if test $status = $expected; then
  103:         : # ok
  104:       else
  105:         fail=1
  106:         echo "*** $i: bad exit status \`$status' (expected $expected)," 1>&2
  107:         echo "  with --help or --version output redirected to /dev/full" 1>&2
  108:       fi
  109:     fi
  110:   done
  111: done
  112: 
  113: tmp=tmp-$$
  114: tmp_in=in-$$
  115: tmp_in2=in2-$$
  116: tmp_dir=dir-$$
  117: tmp_out=out-$$
  118: mkdir $tmp || fail=1
  119: cd $tmp || fail=1
  120: 
  121: comm_args="$tmp_in $tmp_in"
  122: csplit_args="$tmp_in //"
  123: cut_args='-f 1'
  124: join_args="$tmp_in $tmp_in"
  125: tr_args='a a'
  126: 
  127: chmod_args="a+x $tmp_in"
  128: # Punt on these.
  129: chgrp_args=--version
  130: chown_args=--version
  131: mkfifo_args=--version
  132: mknod_args=--version
  133: # Punt on uptime, since it fails (e.g., failing to get boot time)
  134: # on some systems, and we shouldn't let that stop `make check'.
  135: uptime_args=--version
  136: 
  137: cmp_args="$tmp_in $tmp_in2"
  138: 
  139: # Tell dd not to print the line with transfer rate and total.
  140: # The transfer rate would vary between runs.
  141: dd_args=status=noxfer
  142: 
  143: diff_args="$tmp_in $tmp_in2"
  144: sdiff_args="$tmp_in $tmp_in2"
  145: diff3_args="$tmp_in $tmp_in2 $tmp_in2"
  146: cp_args="$tmp_in $tmp_in2"
  147: ln_args="$tmp_in ln-target"
  148: ginstall_args="$tmp_in $tmp_in2"
  149: mv_args="$tmp_in $tmp_in2"
  150: mkdir_args=$tmp_dir/subdir
  151: rmdir_args=$tmp_dir
  152: rm_args=$tmp_in
  153: shred_args=$tmp_in
  154: touch_args=$tmp_in2
  155: 
  156: basename_args=$tmp_in
  157: dirname_args=$tmp_in
  158: expr_args=foo
  159: 
  160: # Punt, in case GNU `id' hasn't been installed yet.
  161: groups_args=--version
  162: 
  163: pathchk_args=$tmp_in
  164: yes_args=--version
  165: logname_args=--version
  166: nohup_args=--version
  167: printf_args=foo
  168: seq_args=10
  169: sleep_args=0
  170: su_args=--version
  171: 
  172: # I'd rather not run sync, since it spins up disks that I've
  173: # deliberately caused to spin down (but not unmounted).
  174: sync_args=--version
  175: 
  176: test_args=foo
  177: 
  178: # This is necessary in the unusual event that there is
  179: # no valid entry in /etc/mtab.
  180: df_args=/
  181: 
  182: # This is necessary in the unusual event that getpwuid (getuid ()) fails.
  183: id_args=-u
  184: 
  185: sleep 10m &
  186: kill_args=$!
  187: 
  188: link_args="$tmp_in link-target"
  189: unlink_args=$tmp_in
  190: 
  191: ln -s . slink
  192: readlink_args=slink
  193: 
  194: stat_args=$tmp_in
  195: unlink_args=$tmp_in
  196: lbracket_args=": ]"
  197: 
  198: for i in $all_programs; do
  199:   # Skip these.
  200:   case $i in chroot|stty|tty|false) continue;; esac
  201: 
  202:   rm -rf $tmp_in $tmp_in2 $tmp_dir $tmp_out
  203:   echo > $tmp_in
  204:   echo > $tmp_in2
  205:   mkdir $tmp_dir
  206:   # echo ================== $i
  207:   test $i = [ && prog=lbracket || prog=$i
  208:   eval "args=\$${prog}_args"
  209:   if ../../src/$i $args < $tmp_in > $tmp_out; then
  210:     : # ok
  211:   else
  212:     echo FAIL: $i
  213:     fail=1
  214:   fi
  215:   rm -rf $tmp_in $tmp_in2 $tmp_out $tmp_dir
  216: done
  217: 
  218: # FIXME: trap
  219: cd ..
  220: rm -rf $tmp
  221: 
  222: exit $fail
Syntax (Markdown)