From be23f60132655a40bc65fc8437509ec02663d1be Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 10 Sep 2007 08:00:39 +0200 Subject: [PATCH] Convert tests/mkdir/ to use test-lib.sh. --- tests/mkdir/Makefile.am | 2 ++ tests/mkdir/concurrent-1 | 37 ------------------------------------- tests/mkdir/p-1 | 13 +++++-------- tests/mkdir/p-2 | 13 +++++-------- tests/mkdir/p-3 | 22 +++++----------------- tests/mkdir/p-slashdot | 16 ++-------------- tests/mkdir/p-thru-slink | 18 +++--------------- tests/mkdir/p-v | 25 +++---------------------- tests/mkdir/parents | 30 ++++++------------------------ tests/mkdir/perm | 28 ++++------------------------ tests/mkdir/special-1 | 7 +++---- tests/mkdir/t-slash | 16 ++-------------- 12 files changed, 40 insertions(+), 187 deletions(-) delete mode 100755 tests/mkdir/concurrent-1 diff --git a/tests/mkdir/Makefile.am b/tests/mkdir/Makefile.am index fc2ab777d..2cf08b257 100644 --- a/tests/mkdir/Makefile.am +++ b/tests/mkdir/Makefile.am @@ -7,3 +7,5 @@ TESTS_ENVIRONMENT = \ srcdir=$(srcdir) \ CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \ PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH" + +include $(top_srcdir)/tests/check.mk diff --git a/tests/mkdir/concurrent-1 b/tests/mkdir/concurrent-1 deleted file mode 100755 index 5daba11b1..000000000 --- a/tests/mkdir/concurrent-1 +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -# Test whether "mkdir -p" works concurrently. - -# Copyright (C) 1999, 2000, 2002, 2006 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 . - -# TMPDIR should be an absolute dir for this test. -# FIXME: enforce it -: ${TMPDIR=/tmp} - -if test "$VERBOSE" = yes; then - set -x - mkdir --version -fi - -pwd=`pwd` -tmp=`echo "$0"|sed 's,.*/,,'`.tmp -trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0 -trap '(exit $?); exit' 1 2 13 15 - -mkdir --parents "$pwd/$tmp/a/b/c" || fail=1 - -test -d $tmp || fail=1 - -exit $fail diff --git a/tests/mkdir/p-1 b/tests/mkdir/p-1 index 43e180571..7ef63be52 100755 --- a/tests/mkdir/p-1 +++ b/tests/mkdir/p-1 @@ -1,7 +1,7 @@ #!/bin/sh # Test "mkdir -p". -# Copyright (C) 1997, 2000, 2002, 2006 Free Software Foundation, Inc. +# Copyright (C) 1997, 2000, 2002, 2006, 2007 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 @@ -21,13 +21,10 @@ if test "$VERBOSE" = yes; then mkdir --version fi -pwd=`pwd` -tmp=`echo "$0"|sed 's,.*/,,'`.tmp -trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0 -trap '(exit $?); exit' 1 2 13 15 +. $srcdir/../test-lib.sh -mkdir --parents "$pwd/$tmp" || fail=1 - -test -d $tmp || fail=1 +fail=0 +mkdir --parents "`pwd`/t" || fail=1 +test -d t || fail=1 exit $fail diff --git a/tests/mkdir/p-2 b/tests/mkdir/p-2 index d7b9554fa..f19a50cde 100755 --- a/tests/mkdir/p-2 +++ b/tests/mkdir/p-2 @@ -1,7 +1,7 @@ #!/bin/sh # Just like p-1, but with an absolute path. -# Copyright (C) 1997, 2000, 2002, 2006 Free Software Foundation, Inc. +# Copyright (C) 1997, 2000, 2002, 2006, 2007 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 @@ -21,13 +21,10 @@ if test "$VERBOSE" = yes; then mkdir --version fi -pwd=`pwd` -tmp=`echo "$0"|sed 's,.*/,,'`.tmp -trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0 -trap '(exit $?); exit' 1 2 13 15 +. $srcdir/../test-lib.sh -mkdir --parents $tmp || fail=1 - -test -d $tmp || fail=1 +fail=0 +mkdir --parents "`pwd`/t/u" || fail=1 +test -d t/u || fail=1 exit $fail diff --git a/tests/mkdir/p-3 b/tests/mkdir/p-3 index 88b53ee7f..ff011e60f 100755 --- a/tests/mkdir/p-3 +++ b/tests/mkdir/p-3 @@ -24,25 +24,13 @@ if test "$VERBOSE" = yes; then fi PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check +. $srcdir/../test-lib.sh -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 +mkdir no-access || framework_failure +mkdir no-acce2s || framework_failure +mkdir -p no-acce3s/d || framework_failure -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 -mkdir no-access || framework_failure=1 -mkdir no-acce2s || framework_failure=1 -mkdir -p no-acce3s/d || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi - -p=$pwd/$tmp +p=`pwd` (cd no-access && chmod 0 . && mkdir -p "$p/a/b" u/v) 2> /dev/null && fail=1 test -d "$p/a/b" || fail=1 diff --git a/tests/mkdir/p-slashdot b/tests/mkdir/p-slashdot index 51237301f..b35ce19cf 100755 --- a/tests/mkdir/p-slashdot +++ b/tests/mkdir/p-slashdot @@ -1,7 +1,7 @@ #!/bin/sh # Ensure that mkdir -p works with arguments specified with a trailing "/.". -# Copyright (C) 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 2005-2007 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 @@ -21,19 +21,7 @@ if test "$VERBOSE" = yes; then mkdir --version fi -pwd=`pwd` -tmp=`echo "$0"|sed 's,.*/,,'`.tmp -trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0 -trap '(exit $?); exit' 1 2 13 15 - -framework_failure=0 -mkdir $tmp || framework_failure=1 -cd $tmp || framework_failure=1 - -if test $framework_failure = 1; then - echo 'failure in testing framework' - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh fail=0 diff --git a/tests/mkdir/p-thru-slink b/tests/mkdir/p-thru-slink index c3c84991d..8607a935e 100755 --- a/tests/mkdir/p-thru-slink +++ b/tests/mkdir/p-thru-slink @@ -1,7 +1,7 @@ #!/bin/sh # Ensure that mkdir -p foo/bar works when foo is a symbolic link to a directory -# Copyright (C) 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 2005-2007 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 @@ -21,23 +21,11 @@ if test "$VERBOSE" = yes; then mkdir --version fi -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 +. $srcdir/../test-lib.sh -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 -ln -s . slink || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +ln -s . slink || framework_failure fail=0 - mkdir -p slink/x || fail=1 test -d x || fail=1 diff --git a/tests/mkdir/p-v b/tests/mkdir/p-v index 3ec9110c4..2c84b41d6 100755 --- a/tests/mkdir/p-v +++ b/tests/mkdir/p-v @@ -1,7 +1,7 @@ #!/bin/sh # Test mkdir -pv. -# Copyright (C) 2006 Free Software Foundation, Inc. +# Copyright (C) 2006, 2007 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 @@ -21,27 +21,8 @@ if test "$VERBOSE" = yes; then mkdir --version fi -# Make sure we get English translations. -LANGUAGE=C -export LANGUAGE -LC_ALL=C -export LC_ALL -LANG=C -export LANG - -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 - -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +. $srcdir/../lang-default +. $srcdir/../test-lib.sh mkdir -pv foo/a/b/c/d 2>out || exit diff --git a/tests/mkdir/parents b/tests/mkdir/parents index 27e0d0af3..81302745f 100755 --- a/tests/mkdir/parents +++ b/tests/mkdir/parents @@ -1,7 +1,7 @@ #!/bin/sh # make sure mkdir's -p options works properly -# Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc. +# Copyright (C) 2000, 2004, 2006, 2007 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 @@ -21,28 +21,10 @@ if test "$VERBOSE" = yes; then mkdir --version fi -pwd=`pwd` -tmp=parents-$$ -trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0 -trap '(exit $?); exit' 1 2 13 15 +. $srcdir/../test-lib.sh +. "$abs_top_srcdir/tests/setgid-check" -framework_failure=0 - -# Record absolute path of srcdir. -cd $srcdir || framework_failure=1 -abs_srcdir=`pwd` - -cd "$pwd" || framework_failure=1 -mkdir $tmp || framework_failure=1 -cd $tmp || framework_failure=1 -mkdir -m 700 e-dir || framework_failure=1 - -if test $framework_failure = 1; then - echo 'failure in testing framework' - (exit 1); exit 1 -fi - -. "$abs_srcdir/../setgid-check" +mkdir -m 700 e-dir || framework_failure fail=0 @@ -54,12 +36,12 @@ mkdir e-dir > /dev/null 2>&1 && fail=1 # Create an existing directory. umask 077 mode_str=drwxr-x-wx -mode_arg=`"$abs_srcdir/../rwx-to-mode" $mode_str` +mode_arg=`"$abs_top_srcdir/tests/rwx-to-mode" $mode_str` mkdir -m $mode_arg a || fail=1 # this `mkdir -p ...' shouldn't change perms of existing dir `a'. d_mode_str=drwx-w--wx -d_mode_arg=`"$abs_srcdir/../rwx-to-mode" $d_mode_str` +d_mode_arg=`"$abs_top_srcdir/tests/rwx-to-mode" $d_mode_str` mkdir -p -m $d_mode_arg a/b/c/d # Make sure the permissions of `a' haven't been changed. diff --git a/tests/mkdir/perm b/tests/mkdir/perm index e70993024..a10d5f6c1 100755 --- a/tests/mkdir/perm +++ b/tests/mkdir/perm @@ -2,8 +2,7 @@ # Verify that mkdir's `-m MODE' option works properly # with various umask settings. -# Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006 Free Software -# Foundation, Inc. +# Copyright (C) 2000, 2002-2007 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 @@ -23,28 +22,9 @@ if test "$VERBOSE" = yes; then mkdir --version fi -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit' 1 2 13 15 - -framework_failure=0 - -# Record absolute path of srcdir and cd back to current dir. -cd $srcdir || framework_failure=1 -abs_srcdir=`pwd` -cd "$pwd" || framework_failure=1 - -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 - -if test $framework_failure = 1; then - echo 'failure in testing framework' - (exit 1); exit 1 -fi - -. "$abs_srcdir/../setgid-check" -. "$abs_srcdir/../umask-check" +. $srcdir/../test-lib.sh +. "$abs_top_srcdir/tests/setgid-check" +. "$abs_top_srcdir/tests/umask-check" fail=0 diff --git a/tests/mkdir/special-1 b/tests/mkdir/special-1 index 842899f15..f65d2ae01 100755 --- a/tests/mkdir/special-1 +++ b/tests/mkdir/special-1 @@ -1,7 +1,7 @@ #!/bin/sh # verify that mkdir honors special bits in MODE -# Copyright (C) 2000, 2006 Free Software Foundation, Inc. +# Copyright (C) 2000, 2006, 2007 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 @@ -21,13 +21,12 @@ if test "$VERBOSE" = yes; then mkdir --version fi -tmp=mkdir-sp-$$ -trap 'status=$?; rm -rf $tmp && exit $status' 0 -trap 'exit $?' 1 2 13 15 +. $srcdir/../test-lib.sh set_mode_string=u=rwx,g=rx,o=w,-s,+t output_mode_string=drwxr-x-wT +tmp=t mkdir -m$set_mode_string $tmp || fail=1 test -d $tmp || fail=1 diff --git a/tests/mkdir/t-slash b/tests/mkdir/t-slash index 289b3d123..a6fab5cc2 100755 --- a/tests/mkdir/t-slash +++ b/tests/mkdir/t-slash @@ -2,7 +2,7 @@ # Ensure that mkdir works with arguments specified with and without # a trailing slash. -# Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc. +# Copyright (C) 2000, 2004, 2006, 2007 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 @@ -22,19 +22,7 @@ if test "$VERBOSE" = yes; then mkdir --version fi -pwd=`pwd` -tmp=t-slash.$$ -trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0 -trap '(exit $?); exit' 1 2 13 15 - -framework_failure=0 -mkdir $tmp || framework_failure=1 -cd $tmp || framework_failure=1 - -if test $framework_failure = 1; then - echo 'failure in testing framework' - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh fail=0 -- 2.34.1