[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-diffutils] [PATCH 01/19] tests: add the first script; hook up gnuli
From: |
Jim Meyering |
Subject: |
[bug-diffutils] [PATCH 01/19] tests: add the first script; hook up gnulib-tests |
Date: |
Fri, 20 Nov 2009 10:12:10 +0100 |
From: Jim Meyering <address@hidden>
* configure.ac (AC_CONFIG_FILES): Add tests/Makefile and
gnulib-tests/Makefile.
* tests/help-version: New file, from coreutils.
* tests/test-lib.sh: Likewise.
* tests/Makefile.am: New file, from gzip.
* Makefile.am (SUBDIRS): Add tests and gnulib-tests.
* tests/t-local.sh: New, empty(for now) file.
---
.gitignore | 2 +
Makefile.am | 2 +-
configure.ac | 13 ++-
tests/Makefile.am | 54 +++++++
tests/help-version | 211 +++++++++++++++++++++++++++
tests/test-lib.sh | 408 ++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 686 insertions(+), 4 deletions(-)
create mode 100644 tests/Makefile.am
create mode 100755 tests/help-version
create mode 100644 tests/t-local.sh
create mode 100644 tests/test-lib.sh
diff --git a/.gitignore b/.gitignore
index e0f99dd..78b4daa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,6 +41,7 @@ Makefile
Makefile.in
autom4te.cache
build-aux
+gnulib-tests/*.log
man/*.1
po/*.gmo
po/*.po
@@ -49,3 +50,4 @@ src/diff
src/diff3
src/paths.h
src/sdiff
+tests/*.log
diff --git a/Makefile.am b/Makefile.am
index ec51c32..be74dae 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
EXTRA_DIST = bootstrap exgettext ChangeLog-2008
-SUBDIRS = lib ms src doc man po
+SUBDIRS = lib src tests doc man po ms gnulib-tests
ACLOCAL_AMFLAGS = -I m4
diff --git a/configure.ac b/configure.ac
index 05000e2..697bb27 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,7 +67,14 @@ AM_GNU_GETTEXT([external], [need-ngettext])
AM_GNU_GETTEXT_VERSION([0.17])
XGETTEXT="AWK='$AWK' \$(SHELL) \$(top_srcdir)/exgettext $XGETTEXT"
-AC_CONFIG_FILES([Makefile doc/Makefile \
- lib/Makefile man/Makefile \
- ms/Makefile po/Makefile.in src/Makefile])
+AC_CONFIG_FILES([
+ Makefile doc/Makefile
+ lib/Makefile
+ src/Makefile
+ tests/Makefile
+ gnulib-tests/Makefile
+ man/Makefile
+ po/Makefile.in
+ ms/Makefile
+])
AC_OUTPUT
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..daec940
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,54 @@
+TESTS = \
+ help-version
+
+EXTRA_DIST = \
+ $(TESTS) test-lib.sh t-local.sh
+
+# Note that the first lines are statements. They ensure that environment
+# variables that can perturb tests are unset or set to expected values.
+# The rest are envvar settings that propagate build-related Makefile
+# variables to test scripts.
+TESTS_ENVIRONMENT = \
+ tmp__=$$TMPDIR; test -d "$$tmp__" || tmp__=.; \
+ TMPDIR=$$tmp__; export TMPDIR; \
+ exec 9>&2; \
+ shell_or_perl_() { \
+ if grep '^\#!/usr/bin/perl' "$$1" > /dev/null; then
\
+ if $(PERL) -e 'use warnings' > /dev/null 2>&1; then \
+ grep '^\#!/usr/bin/perl -T' "$$1" > /dev/null && T_=T || T_=; \
+ $(PERL) -w$$T_ -I$(srcdir) -MCoreutils \
+ -M"CuTmpdir qw($$f)" -- "$$1"; \
+ else \
+ echo 1>&2 "$$tst: configure did not find a usable version of Perl," \
+ "so skipping this test"; \
+ (exit 77); \
+ fi; \
+ else \
+ $(SHELL) "$$1"; \
+ fi; \
+ }; \
+ export \
+ abs_top_builddir='$(abs_top_builddir)' \
+ abs_top_srcdir='$(abs_top_srcdir)' \
+ abs_srcdir='$(abs_srcdir)' \
+ built_programs="`$(built_programs)`" \
+ srcdir='$(srcdir)' \
+ top_srcdir='$(top_srcdir)' \
+ CC='$(CC)' \
+ MAKE=$(MAKE) \
+ PACKAGE_BUGREPORT='$(PACKAGE_BUGREPORT)' \
+ PACKAGE_VERSION=$(PACKAGE_VERSION) \
+ CONFIG_HEADER='$(abs_top_builddir)/lib/config.h' \
+ ENABLE_DEVICE_MAPPER=$(ENABLE_DEVICE_MAPPER) \
+ PERL='$(PERL)' \
+ PREFERABLY_POSIX_SHELL='$(PREFERABLY_POSIX_SHELL)' \
+ REPLACE_GETCWD=$(REPLACE_GETCWD) \
+ PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'"$$PATH" \
+ ; shell_or_perl_
+
+built_programs = \
+ echo 'spy:;@echo $$(PROGRAMS)' \
+ | MAKEFLAGS= $(MAKE) -s -C $(builddir)/../src -f Makefile -f - spy \
+ | fmt -1 | sort -u
+
+VERBOSE = yes
diff --git a/tests/help-version b/tests/help-version
new file mode 100755
index 0000000..2ab0865
--- /dev/null
+++ b/tests/help-version
@@ -0,0 +1,211 @@
+#! /bin/sh
+# Make sure all these programs work properly
+# when invoked with --help or --version.
+
+# Copyright (C) 2000-2009 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 3 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, see <http://www.gnu.org/licenses/>.
+
+test "$VERBOSE" = yes && set -x
+
+# Ensure that $SHELL is set to *some* value and exported.
+# This is required for dircolors, which would fail e.g., when
+# invoked via debuild (which removes SHELL from the environment).
+test "x$SHELL" = x && SHELL=/bin/sh
+export SHELL
+
+. $srcdir/test-lib.sh
+
+expected_failure_status_chroot=125
+expected_failure_status_env=125
+expected_failure_status_nice=125
+expected_failure_status_nohup=125
+expected_failure_status_stdbuf=125
+expected_failure_status_su=125
+expected_failure_status_timeout=125
+expected_failure_status_printenv=2
+expected_failure_status_tty=3
+expected_failure_status_sort=2
+expected_failure_status_expr=3
+expected_failure_status_lbracket=2
+expected_failure_status_dir=2
+expected_failure_status_ls=2
+expected_failure_status_vdir=2
+
+expected_failure_status_cmp=2
+expected_failure_status_sdiff=2
+expected_failure_status_diff3=2
+expected_failure_status_diff=2
+
+test "$built_programs" \
+ || { echo "$this_test: no programs built!?!" 1>&2; Exit 1; }
+
+for lang in C fr da; do
+ for i in $built_programs; do
+
+ # Skip `test'; it doesn't accept --help or --version.
+ test $i = test && continue;
+
+ # false fails even when invoked with --help or --version.
+ if test $i = false; then
+ env LC_MESSAGES=$lang $i --help >/dev/null && fail=1
+ env LC_MESSAGES=$lang $i --version >/dev/null && fail=1
+ continue
+ fi
+
+ # The just-built install executable is always named `ginstall'.
+ test $i = install && i=ginstall
+
+ # Make sure they exit successfully, under normal conditions.
+ env $i --help > h-$i || fail=1
+ env $i --version >/dev/null || fail=1
+
+ # Make sure they mention the bug-reporting address in --help output.
+ grep "$PACKAGE_BUGREPORT" h-$i > /dev/null || fail=1
+ rm -f h-$i
+
+ # Make sure they fail upon `disk full' error.
+ if test -w /dev/full && test -c /dev/full; then
+ env $i --help >/dev/full 2>/dev/null && fail=1
+ env $i --version >/dev/full 2>/dev/null && fail=1
+ status=$?
+ test $i = [ && prog=lbracket || prog=$i
+ eval "expected=\$expected_failure_status_$prog"
+ test x$expected = x && expected=1
+ if test $status = $expected; then
+ : # ok
+ else
+ fail=1
+ echo "*** $i: bad exit status \`$status' (expected $expected)," 1>&2
+ echo " with --help or --version output redirected to /dev/full" 1>&2
+ fi
+ fi
+ done
+done
+
+tmp=tmp-$$
+tmp_in=in-$$
+tmp_in2=in2-$$
+tmp_dir=dir-$$
+tmp_out=out-$$
+mkdir $tmp || fail=1
+cd $tmp || fail=1
+
+comm_args="$tmp_in $tmp_in"
+csplit_args="$tmp_in //"
+cut_args='-f 1'
+join_args="$tmp_in $tmp_in"
+tr_args='a a'
+
+chmod_args="a+x $tmp_in"
+# Punt on these.
+chgrp_args=--version
+chown_args=--version
+mkfifo_args=--version
+mknod_args=--version
+# Punt on uptime, since it fails (e.g., failing to get boot time)
+# on some systems, and we shouldn't let that stop `make check'.
+uptime_args=--version
+
+# Create a file in the current directory, not in $TMPDIR.
+mktemp_args=mktemp.XXXX
+
+cmp_args="$tmp_in $tmp_in2"
+
+# Tell dd not to print the line with transfer rate and total.
+# The transfer rate would vary between runs.
+dd_args=status=noxfer
+
+diff_args="$tmp_in $tmp_in2"
+sdiff_args="$tmp_in $tmp_in2"
+diff3_args="$tmp_in $tmp_in2 $tmp_in2"
+cp_args="$tmp_in $tmp_in2"
+ln_args="$tmp_in ln-target"
+ginstall_args="$tmp_in $tmp_in2"
+mv_args="$tmp_in $tmp_in2"
+mkdir_args=$tmp_dir/subdir
+rmdir_args=$tmp_dir
+rm_args=$tmp_in
+shred_args=$tmp_in
+touch_args=$tmp_in2
+truncate_args="--reference=$tmp_in $tmp_in2"
+
+basename_args=$tmp_in
+dirname_args=$tmp_in
+expr_args=foo
+
+# Punt, in case GNU `id' hasn't been installed yet.
+groups_args=--version
+
+pathchk_args=$tmp_in
+yes_args=--version
+logname_args=--version
+nohup_args=--version
+printf_args=foo
+seq_args=10
+sleep_args=0
+su_args=--version
+stdbuf_args="-oL true"
+timeout_args=--version
+
+# I'd rather not run sync, since it spins up disks that I've
+# deliberately caused to spin down (but not unmounted).
+sync_args=--version
+
+test_args=foo
+
+# This is necessary in the unusual event that there is
+# no valid entry in /etc/mtab.
+df_args=/
+
+# This is necessary in the unusual event that getpwuid (getuid ()) fails.
+id_args=-u
+
+# Use env to avoid invoking built-in sleep of Solaris 11's /bin/sh.
+env sleep 10m &
+kill_args=$!
+
+link_args="$tmp_in link-target"
+unlink_args=$tmp_in
+
+ln -s . slink
+readlink_args=slink
+
+stat_args=$tmp_in
+unlink_args=$tmp_in
+lbracket_args=": ]"
+
+# Ensure that each program "works" (exits successfully) when doing
+# something more than --help or --version.
+for i in $built_programs; do
+ # Skip these.
+ case $i in chroot|stty|tty|false|chcon|runcon) continue;; esac
+
+ rm -rf $tmp_in $tmp_in2 $tmp_dir $tmp_out
+ echo > $tmp_in
+ echo > $tmp_in2
+ mkdir $tmp_dir
+ # echo ================== $i
+ test $i = [ && prog=lbracket || prog=$i
+ eval "args=\$${prog}_args"
+ if env $i $args < $tmp_in > $tmp_out; then
+ : # ok
+ else
+ echo FAIL: $i
+ fail=1
+ fi
+ rm -rf $tmp_in $tmp_in2 $tmp_out $tmp_dir
+done
+
+Exit $fail
diff --git a/tests/t-local.sh b/tests/t-local.sh
new file mode 100644
index 0000000..e69de29
diff --git a/tests/test-lib.sh b/tests/test-lib.sh
new file mode 100644
index 0000000..b39d06c
--- /dev/null
+++ b/tests/test-lib.sh
@@ -0,0 +1,408 @@
+# source this file; set up for tests
+
+# Copyright (C) 2009 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 3 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, see <http://www.gnu.org/licenses/>.
+
+# Skip this test if the shell lacks support for functions.
+unset function_test
+eval 'function_test() { return 11; }; function_test'
+if test $? != 11; then
+ echo "$0: /bin/sh lacks support for functions; skipping this test." 1>&2
+ Exit 77
+fi
+
+skip_test_()
+{
+ echo "$0: skipping test: $@" | head -1 1>&9
+ echo "$0: skipping test: $@" 1>&2
+ Exit 77
+}
+
+getlimits_()
+{
+ eval $(getlimits)
+ test "$INT_MAX" ||
+ error_ "Error running getlimits"
+}
+
+require_acl_()
+{
+ getfacl --version < /dev/null > /dev/null 2>&1 \
+ && setfacl --version < /dev/null > /dev/null 2>&1 \
+ || skip_test_ "This test requires getfacl and setfacl."
+
+ id -u bin > /dev/null 2>&1 \
+ || skip_test_ "This test requires a local user named bin."
+}
+
+# Skip this test if we're not in SELinux "enforcing" mode.
+require_selinux_enforcing_()
+{
+ test "$(getenforce)" = Enforcing \
+ || skip_test_ "This test is useful only with SELinux in Enforcing mode."
+}
+
+
+require_openat_support_()
+{
+ # Skip this test if your system has neither the openat-style functions
+ # nor /proc/self/fd support with which to emulate them.
+ test -z "$CONFIG_HEADER" \
+ && skip_test_ 'internal error: CONFIG_HEADER not defined'
+
+ _skip=yes
+ grep '^#define HAVE_OPENAT' "$CONFIG_HEADER" > /dev/null && _skip=no
+ test -d /proc/self/fd && _skip=no
+ if test $_skip = yes; then
+ skip_test_ 'this system lacks openat support'
+ fi
+}
+
+require_ulimit_()
+{
+ ulimit_works=yes
+ # Expect to be able to exec a program in 10MB of virtual memory,
+ # but not in 20KB. I chose "date". It must not be a shell built-in
+ # function, so you can't use echo, printf, true, etc.
+ # Of course, in coreutils, I could use $top_builddir/src/true,
+ # but this should be able to work for other projects, too.
+ ( ulimit -v 10000; date ) > /dev/null 2>&1 || ulimit_works=no
+ ( ulimit -v 20; date ) > /dev/null 2>&1 && ulimit_works=no
+
+ test $ulimit_works = no \
+ && skip_test_ "this shell lacks ulimit support"
+}
+
+require_readable_root_()
+{
+ test -r / || skip_test_ "/ is not readable"
+}
+
+# Skip the current test if strace is not available or doesn't work
+# with the named syscall. Usage: require_strace_ unlink
+require_strace_()
+{
+ test $# = 1 || framework_failure
+
+ strace -V < /dev/null > /dev/null 2>&1 ||
+ skip_test_ 'no strace program'
+
+ strace -qe "$1" echo > /dev/null 2>&1 ||
+ skip_test_ 'strace -qe "'"$1"'" does not work'
+}
+
+# Require a controlling input `terminal'.
+require_controlling_input_terminal_()
+{
+ tty -s || have_input_tty=no
+ test -t 0 || have_input_tty=no
+ if test "$have_input_tty" = no; then
+ skip_test_ 'requires controlling input terminal
+This test must have a controlling input "terminal", so it may not be
+run via "batch", "at", or "ssh". On some systems, it may not even be
+run in the background.'
+ fi
+}
+
+require_built_()
+{
+ skip_=no
+ for i in "$@"; do
+ case " $built_programs " in
+ *" $i "*) ;;
+ *) echo "$i: not built" 1>&2; skip_=yes ;;
+ esac
+ done
+
+ test $skip_ = yes && skip_test_ "required program(s) not built"
+}
+
+uid_is_privileged_()
+{
+ # Make sure id -u succeeds.
+ my_uid=$(id -u) \
+ || { echo "$0: cannot run \`id -u'" 1>&2; return 1; }
+
+ # Make sure it gives valid output.
+ case $my_uid in
+ 0) ;;
+ *[!0-9]*)
+ echo "$0: invalid output (\`$my_uid') from \`id -u'" 1>&2
+ return 1 ;;
+ *) return 1 ;;
+ esac
+}
+
+get_process_status_()
+{
+ sed -n '/^State:[ ]*\([[:alpha:]]\).*/s//\1/p' /proc/$1/status
+}
+
+# Convert an ls-style permission string, like drwxr----x and -rw-r-x-wx
+# to the equivalent chmod --mode (-m) argument, (=,u=rwx,g=r,o=x and
+# =,u=rw,g=rx,o=wx). Ignore ACLs.
+rwx_to_mode_()
+{
+ case $# in
+ 1) rwx=$1;;
+ *) echo "$0: wrong number of arguments" 1>&2
+ echo "Usage: $0 ls-style-mode-string" 1>&2
+ return;;
+ esac
+
+ case $rwx in
+ [ld-][rwx-][rwx-][rwxsS-][rwx-][rwx-][rwxsS-][rwx-][rwx-][rwxtT-]) ;;
+ [ld-][rwx-][rwx-][rwxsS-][rwx-][rwx-][rwxsS-][rwx-][rwx-][rwxtT-][+.]) ;;
+ *) echo "$0: invalid mode string: $rwx" 1>&2; return;;
+ esac
+
+ # Perform these conversions:
+ # S s
+ # s xs
+ # T t
+ # t xt
+ # The `T' and `t' ones are only valid for `other'.
+ s='s/S/@/;s/s/x@/;s/@/s/'
+ t='s/T/@/;s/t/x@/;s/@/t/'
+
+ u=`echo $rwx|sed 's/^.\(...\).*/,u=\1/;s/-//g;s/^,u=$//;'$s`
+ g=`echo $rwx|sed 's/^....\(...\).*/,g=\1/;s/-//g;s/^,g=$//;'$s`
+ o=`echo $rwx|sed 's/^.......\(...\).*/,o=\1/;s/-//g;s/^,o=$//;'$s';'$t`
+ echo "=$u$g$o"
+}
+
+skip_if_()
+{
+ case $1 in
+ root) skip_test_ must be run as root ;;
+ non-root) skip_test_ must be run as non-root ;;
+ *) ;; # FIXME?
+ esac
+}
+
+require_selinux_()
+{
+ case `ls -Zd .` in
+ '? .'|'unlabeled .')
+ skip_test_ "this system (or maybe just" \
+ "the current file system) lacks SELinux support"
+ ;;
+ esac
+}
+
+very_expensive_()
+{
+ if test "$RUN_VERY_EXPENSIVE_TESTS" != yes; then
+ skip_test_ 'very expensive: disabled by default
+This test is very expensive, so it is disabled by default.
+To run it anyway, rerun make check with the RUN_VERY_EXPENSIVE_TESTS
+environment variable set to yes. E.g.,
+
+ env RUN_VERY_EXPENSIVE_TESTS=yes make check
+'
+ fi
+}
+
+expensive_()
+{
+ if test "$RUN_EXPENSIVE_TESTS" != yes; then
+ skip_test_ 'expensive: disabled by default
+This test is relatively expensive, so it is disabled by default.
+To run it anyway, rerun make check with the RUN_EXPENSIVE_TESTS
+environment variable set to yes. E.g.,
+
+ env RUN_EXPENSIVE_TESTS=yes make check
+'
+ fi
+}
+
+require_root_()
+{
+ uid_is_privileged_ || skip_test_ "must be run as root"
+ NON_ROOT_USERNAME=${NON_ROOT_USERNAME=nobody}
+ NON_ROOT_GROUP=${NON_ROOT_GROUP=$(id -g $NON_ROOT_USERNAME)}
+}
+
+skip_if_root_() { uid_is_privileged_ && skip_test_ "must be run as non-root"; }
+error_() { echo "$0: $@" 1>&2; Exit 1; }
+framework_failure() { error_ 'failure in testing framework'; }
+
+# Set `groups' to a space-separated list of at least two groups
+# of which the user is a member.
+require_membership_in_two_groups_()
+{
+ test $# = 0 || framework_failure
+
+ groups=${COREUTILS_GROUPS-`(id -G || /usr/xpg4/bin/id -G) 2>/dev/null`}
+ case "$groups" in
+ *' '*) ;;
+ *) skip_test_ 'requires membership in two groups
+this test requires that you be a member of more than one group,
+but running `id -G'\'' either failed or found just one. If you really
+are a member of at least two groups, then rerun this test with
+COREUTILS_GROUPS set in your environment to the space-separated list
+of group names or numbers. E.g.,
+
+ env COREUTILS_GROUPS='users cdrom' make check
+
+'
+ ;;
+ esac
+}
+
+# Is /proc/$PID/status supported?
+require_proc_pid_status_()
+{
+ sleep 2 &
+ local pid=$!
+ sleep .5
+ grep '^State:[ ]*[S]' /proc/$pid/status > /dev/null 2>&1 ||
+ skip_test_ "/proc/$pid/status: missing or 'different'"
+ kill $pid
+}
+
+# Does the current (working-dir) file system support sparse files?
+require_sparse_support_()
+{
+ test $# = 0 || framework_failure
+ # Test whether we can create a sparse file.
+ # For example, on Darwin6.5 with a file system of type hfs, it's not
possible.
+ # NTFS requires 128K before a hole appears in a sparse file.
+ t=sparse.$$
+ dd bs=1 seek=128K of=$t < /dev/null 2> /dev/null
+ set x `du -sk $t`
+ kb_size=$2
+ rm -f $t
+ if test $kb_size -ge 128; then
+ skip_test_ 'this file system does not support sparse files'
+ fi
+}
+
+mkfifo_or_skip_()
+{
+ test $# = 1 || framework_failure
+ if ! mkfifo "$1"; then
+ # Make an exception of this case -- usually we interpret framework-creation
+ # failure as a test failure. However, in this case, when running on a
SunOS
+ # system using a disk NFS mounted from OpenBSD, the above fails like this:
+ # mkfifo: cannot make fifo `fifo-10558': Not owner
+ skip_test_ 'NOTICE: unable to create test prerequisites'
+ fi
+}
+
+# Disable the current test if the working directory seems to have
+# the setgid bit set.
+skip_if_setgid_()
+{
+ setgid_tmpdir=setgid-$$
+ (umask 77; mkdir $setgid_tmpdir)
+ perms=$(stat --printf %A $setgid_tmpdir)
+ rmdir $setgid_tmpdir
+ case $perms in
+ drwx------);;
+ drwxr-xr-x);; # Windows98 + DJGPP 2.03
+ *) skip_test_ 'this directory has the setgid bit set';;
+ esac
+}
+
+skip_if_mcstransd_is_running_()
+{
+ test $# = 0 || framework_failure
+
+ # When mcstransd is running, you'll see only the 3-component
+ # version of file-system context strings. Detect that,
+ # and if it's running, skip this test.
+ __ctx=$(stat --printf='%C\n' .) || framework_failure
+ case $__ctx in
+ *:*:*:*) ;; # four components is ok
+ *) # anything else probably means mcstransd is running
+ skip_test_ "unexpected context '$__ctx'; turn off mcstransd" ;;
+ esac
+}
+
+# Skip the current test if umask doesn't work as usual.
+# This test should be run in the temporary directory that ends
+# up being removed via the trap commands.
+working_umask_or_skip_()
+{
+ umask 022
+ touch file1 file2
+ chmod 644 file2
+ perms=`ls -l file1 file2 | sed 's/ .*//' | uniq`
+ rm -f file1 file2
+
+ case $perms in
+ *'
+ '*) skip_test_ 'your build directory has unusual umask semantics'
+ esac
+}
+
+# We use a trap below for cleanup. This requires us to go through
+# hoops to get the right exit status transported through the signal.
+# So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
+# Turn off errexit here so that we don't trip the bug with OSF1/Tru64
+# sh inside this function.
+Exit ()
+{
+ set +e
+ (exit $1)
+ exit $1
+}
+
+test_dir_=$(pwd)
+
+this_test_() { echo "./$0" | sed 's,.*/,,'; }
+this_test=$(this_test_)
+
+# This is a stub function that is run upon trap (upon regular exit and
+# interrupt). Override it with a per-test function, e.g., to unmount
+# a partition, or to undo any other global state changes.
+cleanup_() { :; }
+
+t_=$(mktemp -d --tmp="$test_dir_" di-$this_test.XXXXXXXXXX)\
+ || error_ "failed to create temporary directory in $test_dir_"
+
+# Eval the following upon cleanup.
+# This is useful if you have more than than one cleanup function,
+# and for encapsulated cleanup functions; append any addition.
+cleanup_eval_=':'
+
+remove_tmp_()
+{
+ __st=$?
+ cleanup_
+ test -n "$cleanup_eval_" && eval "$cleanup_eval_"
+ cd "$test_dir_" && chmod -R u+rwx "$t_" && rm -rf "$t_" && exit $__st
+}
+
+. $srcdir/t-local.sh
+
+# Run each test from within a temporary sub-directory named after the
+# test itself, and arrange to remove it upon exception or normal exit.
+trap remove_tmp_ 0
+trap 'Exit $?' 1 2 13 15
+
+cd "$t_" || error_ "failed to cd to $t_"
+
+if ( diff --version < /dev/null 2>&1 | grep GNU ) 2>&1 > /dev/null; then
+ compare() { diff -u "$@"; }
+elif ( cmp --version < /dev/null 2>&1 | grep GNU ) 2>&1 > /dev/null; then
+ compare() { cmp -s "$@"; }
+else
+ compare() { cmp "$@"; }
+fi
+
+# Initialize; all bourne shell scripts end with "Exit $fail".
+fail=0
--
1.6.5.3.433.g11067
- [bug-diffutils] [PATCH 01/19] tests: add the first script; hook up gnulib-tests,
Jim Meyering <=
- [bug-diffutils] [PATCH 06/19] build: avoid link failure when libsigsegv is used, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 05/19] maint: define/use PROGRAM_NAME and AUTHORS; use propername module, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 14/19] build: enable many warnings, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 02/19] sdiff, diff3: exec diff, not $(bindir)/diff, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 19/19] maint: remove hard-coded macro definitions provided by intprops.h, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 04/19] maint: no longer define *_FILENO constants, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 12/19] build: update gnulib submodule to latest, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 17/19] build: suppress warnings about bindtextdomain and textdomain, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 15/19] use xfreopen rather than freopen, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 10/19] build: let automake generate better man-installation rules, Jim Meyering, 2009/11/20