From 9eb4c31eb78c28dd9f72d1cbb940270311be343c Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Thu, 30 Aug 2012 14:13:12 +0200 Subject: tests: add .sh and .pl suffixes to shell and perl tests, respectively Not only this shrinks the size of the generated Makefile (from > 6300 lines to ~3000), but will allow further simplifications in future changes. * tests/Makefile.am (TEST_EXTENSIONS): Add '.sh' and '.pl'. (PL_LOG_COMPILER, SH_LOG_COMPILER): New, still defined simply to $(LOG_COMPILER) for the time being. (TESTS, root_tests): Adjust as described. * All tests: Rename as described. --- tests/touch/60-seconds | 33 --------------- tests/touch/60-seconds.sh | 33 +++++++++++++++ tests/touch/dangling-symlink | 49 ----------------------- tests/touch/dangling-symlink.sh | 49 +++++++++++++++++++++++ tests/touch/dir-1 | 9 ----- tests/touch/dir-1.sh | 9 +++++ tests/touch/empty-file | 80 ------------------------------------- tests/touch/empty-file.sh | 80 +++++++++++++++++++++++++++++++++++++ tests/touch/fail-diag | 32 --------------- tests/touch/fail-diag.sh | 32 +++++++++++++++ tests/touch/fifo | 27 ------------- tests/touch/fifo.sh | 27 +++++++++++++ tests/touch/no-create-missing | 39 ------------------ tests/touch/no-create-missing.sh | 39 ++++++++++++++++++ tests/touch/no-dereference | 84 --------------------------------------- tests/touch/no-dereference.sh | 84 +++++++++++++++++++++++++++++++++++++++ tests/touch/no-rights | 40 ------------------- tests/touch/no-rights.sh | 40 +++++++++++++++++++ tests/touch/not-owner | 55 ------------------------- tests/touch/not-owner.sh | 55 +++++++++++++++++++++++++ tests/touch/now-owned-by-other | 35 ---------------- tests/touch/now-owned-by-other.sh | 35 ++++++++++++++++ tests/touch/obsolescent | 41 ------------------- tests/touch/obsolescent.sh | 41 +++++++++++++++++++ tests/touch/read-only | 31 --------------- tests/touch/read-only.sh | 31 +++++++++++++++ tests/touch/relative | 38 ------------------ tests/touch/relative.sh | 38 ++++++++++++++++++ tests/touch/trailing-slash | 66 ------------------------------ tests/touch/trailing-slash.sh | 66 ++++++++++++++++++++++++++++++ 30 files changed, 659 insertions(+), 659 deletions(-) delete mode 100755 tests/touch/60-seconds create mode 100755 tests/touch/60-seconds.sh delete mode 100755 tests/touch/dangling-symlink create mode 100755 tests/touch/dangling-symlink.sh delete mode 100755 tests/touch/dir-1 create mode 100755 tests/touch/dir-1.sh delete mode 100755 tests/touch/empty-file create mode 100755 tests/touch/empty-file.sh delete mode 100755 tests/touch/fail-diag create mode 100755 tests/touch/fail-diag.sh delete mode 100755 tests/touch/fifo create mode 100755 tests/touch/fifo.sh delete mode 100755 tests/touch/no-create-missing create mode 100755 tests/touch/no-create-missing.sh delete mode 100755 tests/touch/no-dereference create mode 100755 tests/touch/no-dereference.sh delete mode 100755 tests/touch/no-rights create mode 100755 tests/touch/no-rights.sh delete mode 100755 tests/touch/not-owner create mode 100755 tests/touch/not-owner.sh delete mode 100755 tests/touch/now-owned-by-other create mode 100755 tests/touch/now-owned-by-other.sh delete mode 100755 tests/touch/obsolescent create mode 100755 tests/touch/obsolescent.sh delete mode 100755 tests/touch/read-only create mode 100755 tests/touch/read-only.sh delete mode 100755 tests/touch/relative create mode 100755 tests/touch/relative.sh delete mode 100755 tests/touch/trailing-slash create mode 100755 tests/touch/trailing-slash.sh (limited to 'tests/touch') diff --git a/tests/touch/60-seconds b/tests/touch/60-seconds deleted file mode 100755 index 915a1d05d..000000000 --- a/tests/touch/60-seconds +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# touch -t would mistakenly reject a time specifying "60" seconds - -# Copyright (C) 2009-2012 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 . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - -echo 60.000000000 > exp || framework_failure_ - - -# Before coreutils-7.7, this would fail, complaining of -# an 'invalid date format'. Specifying 60 seconds *is* valid. -TZ=UTC0 touch -t 197001010000.60 f || fail=1 - -stat --p='%.9Y\n' f > out || fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/touch/60-seconds.sh b/tests/touch/60-seconds.sh new file mode 100755 index 000000000..915a1d05d --- /dev/null +++ b/tests/touch/60-seconds.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# touch -t would mistakenly reject a time specifying "60" seconds + +# Copyright (C) 2009-2012 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 . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + +echo 60.000000000 > exp || framework_failure_ + + +# Before coreutils-7.7, this would fail, complaining of +# an 'invalid date format'. Specifying 60 seconds *is* valid. +TZ=UTC0 touch -t 197001010000.60 f || fail=1 + +stat --p='%.9Y\n' f > out || fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/touch/dangling-symlink b/tests/touch/dangling-symlink deleted file mode 100755 index 1eb2ed38a..000000000 --- a/tests/touch/dangling-symlink +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# Make sure touch can create a file through a dangling symlink. -# This was broken in the 4.0[e-i] test releases. - -# Copyright (C) 1999-2012 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 . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - -rm -f touch-target t-symlink -ln -s touch-target t-symlink - -# This used to infloop. -touch t-symlink || fail=1 - -test -f touch-target || fail=1 -rm -f touch-target t-symlink - -if test $fail = 1; then - case $host_triplet in - *linux-gnu*) - case "$(uname -r)" in - 2.3.9[0-9]*) - skip_ \ -'**************************************************** -WARNING!!! -This version of the Linux kernel causes touch to fail -when operating on dangling symlinks. -****************************************************' - ;; - esac - ;; - esac -fi - -Exit $fail diff --git a/tests/touch/dangling-symlink.sh b/tests/touch/dangling-symlink.sh new file mode 100755 index 000000000..1eb2ed38a --- /dev/null +++ b/tests/touch/dangling-symlink.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# Make sure touch can create a file through a dangling symlink. +# This was broken in the 4.0[e-i] test releases. + +# Copyright (C) 1999-2012 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 . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + +rm -f touch-target t-symlink +ln -s touch-target t-symlink + +# This used to infloop. +touch t-symlink || fail=1 + +test -f touch-target || fail=1 +rm -f touch-target t-symlink + +if test $fail = 1; then + case $host_triplet in + *linux-gnu*) + case "$(uname -r)" in + 2.3.9[0-9]*) + skip_ \ +'**************************************************** +WARNING!!! +This version of the Linux kernel causes touch to fail +when operating on dangling symlinks. +****************************************************' + ;; + esac + ;; + esac +fi + +Exit $fail diff --git a/tests/touch/dir-1 b/tests/touch/dir-1 deleted file mode 100755 index b4c04fe41..000000000 --- a/tests/touch/dir-1 +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -# Make sure touch can operate on a directory. -# This was broken in the 4.0[efg] test releases. - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - -touch . || fail=1 -Exit $fail diff --git a/tests/touch/dir-1.sh b/tests/touch/dir-1.sh new file mode 100755 index 000000000..b4c04fe41 --- /dev/null +++ b/tests/touch/dir-1.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# Make sure touch can operate on a directory. +# This was broken in the 4.0[efg] test releases. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + +touch . || fail=1 +Exit $fail diff --git a/tests/touch/empty-file b/tests/touch/empty-file deleted file mode 100755 index a150bd58e..000000000 --- a/tests/touch/empty-file +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh -# Make sure touch can set the mtime on an empty file. - -# Copyright (C) 1998-2012 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 . - - -# Volker Borchert reported that touch 3.16r (and presumably all before that) -# fails to work on SunOS 4.1.3 with 'most of the recommended patches' when -# the empty file is on an NFS-mounted 4.2 volume. - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - -DEFAULT_SLEEP_SECONDS=2 -SLEEP_SECONDS=${SLEEP_SECONDS=$DEFAULT_SLEEP_SECONDS} - - -# FIXME: find writable directories on other partitions -# and run the test in those directories, too. - -: ${TOUCH_DIR_LIST=.} - - -for d in $TOUCH_DIR_LIST; do - rm -rf $d/a $d/b $d/c - > $d/a || framework_failure_ - test -f $d/a || framework_failure_ - > $d/b || framework_failure_ - test -f $d/b || framework_failure_ - > $d/c || framework_failure_ - test -f $d/c || framework_failure_ -done - -echo sleeping for $SLEEP_SECONDS seconds... -sleep $SLEEP_SECONDS -for d in $TOUCH_DIR_LIST; do - touch $d/a || fail=1 - set x $(ls -t $d/a $d/b) - test "$*" = "x $d/a $d/b" || fail=1 -done - -echo sleeping for $SLEEP_SECONDS seconds... -sleep $SLEEP_SECONDS -for d in $TOUCH_DIR_LIST; do - touch $d/b - set x $(ls -t $d/a $d/b) - test "$*" = "x $d/b $d/a" || fail=1 - - if touch - 1< $d/c 2> /dev/null; then - set x $(ls -t $d/a $d/c) - test "$*" = "x $d/c $d/a" || fail=1 - fi - - rm -rf $d/a $d/b $d/c -done - -if test $fail != 0; then - cat 1>&2 <. + + +# Volker Borchert reported that touch 3.16r (and presumably all before that) +# fails to work on SunOS 4.1.3 with 'most of the recommended patches' when +# the empty file is on an NFS-mounted 4.2 volume. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + +DEFAULT_SLEEP_SECONDS=2 +SLEEP_SECONDS=${SLEEP_SECONDS=$DEFAULT_SLEEP_SECONDS} + + +# FIXME: find writable directories on other partitions +# and run the test in those directories, too. + +: ${TOUCH_DIR_LIST=.} + + +for d in $TOUCH_DIR_LIST; do + rm -rf $d/a $d/b $d/c + > $d/a || framework_failure_ + test -f $d/a || framework_failure_ + > $d/b || framework_failure_ + test -f $d/b || framework_failure_ + > $d/c || framework_failure_ + test -f $d/c || framework_failure_ +done + +echo sleeping for $SLEEP_SECONDS seconds... +sleep $SLEEP_SECONDS +for d in $TOUCH_DIR_LIST; do + touch $d/a || fail=1 + set x $(ls -t $d/a $d/b) + test "$*" = "x $d/a $d/b" || fail=1 +done + +echo sleeping for $SLEEP_SECONDS seconds... +sleep $SLEEP_SECONDS +for d in $TOUCH_DIR_LIST; do + touch $d/b + set x $(ls -t $d/a $d/b) + test "$*" = "x $d/b $d/a" || fail=1 + + if touch - 1< $d/c 2> /dev/null; then + set x $(ls -t $d/a $d/c) + test "$*" = "x $d/c $d/a" || fail=1 + fi + + rm -rf $d/a $d/b $d/c +done + +if test $fail != 0; then + cat 1>&2 <. - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch -skip_if_root_ - -file=/no-such-dir/file - -touch $file > out 2>&1 && fail=1 -cat < exp -touch: cannot touch '$file': No such file or directory -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/touch/fail-diag.sh b/tests/touch/fail-diag.sh new file mode 100755 index 000000000..b74d2a5bb --- /dev/null +++ b/tests/touch/fail-diag.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# make sure touch gives reasonable diagnostics + +# Copyright (C) 2001-2012 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 . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch +skip_if_root_ + +file=/no-such-dir/file + +touch $file > out 2>&1 && fail=1 +cat < exp +touch: cannot touch '$file': No such file or directory +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/touch/fifo b/tests/touch/fifo deleted file mode 100755 index 65f4328cc..000000000 --- a/tests/touch/fifo +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# Make sure touch works on fifos without hanging. - -# Copyright (C) 2000-2012 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 . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - -mkfifo_or_skip_ fifo - - -touch fifo || fail=1 - -Exit $fail diff --git a/tests/touch/fifo.sh b/tests/touch/fifo.sh new file mode 100755 index 000000000..65f4328cc --- /dev/null +++ b/tests/touch/fifo.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# Make sure touch works on fifos without hanging. + +# Copyright (C) 2000-2012 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 . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + +mkfifo_or_skip_ fifo + + +touch fifo || fail=1 + +Exit $fail diff --git a/tests/touch/no-create-missing b/tests/touch/no-create-missing deleted file mode 100755 index 88a079a01..000000000 --- a/tests/touch/no-create-missing +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# Ensure that touch -c no-such-file no longer fails (it did in 4.1.8). - -# Copyright (C) 2002-2012 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 . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - - -touch -c no-file > /dev/null 2>&1 || fail=1 -touch -cm no-file > /dev/null 2>&1 || fail=1 -touch -ca no-file > /dev/null 2>&1 || fail=1 - -test="$abs_top_builddir/src/test" - -# If >&- works, test "touch -c -" etc. -# >&- apparently does not work in HP-UX 11.23. -# This test is ineffective unless /dev/stdout also works. -if "$test" -w /dev/stdout >/dev/null && - "$test" ! -w /dev/stdout >&-; then - touch -c - >&- 2> /dev/null || fail=1 - touch -cm - >&- 2> /dev/null || fail=1 - touch -ca - >&- 2> /dev/null || fail=1 -fi - -Exit $fail diff --git a/tests/touch/no-create-missing.sh b/tests/touch/no-create-missing.sh new file mode 100755 index 000000000..88a079a01 --- /dev/null +++ b/tests/touch/no-create-missing.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# Ensure that touch -c no-such-file no longer fails (it did in 4.1.8). + +# Copyright (C) 2002-2012 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 . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + + +touch -c no-file > /dev/null 2>&1 || fail=1 +touch -cm no-file > /dev/null 2>&1 || fail=1 +touch -ca no-file > /dev/null 2>&1 || fail=1 + +test="$abs_top_builddir/src/test" + +# If >&- works, test "touch -c -" etc. +# >&- apparently does not work in HP-UX 11.23. +# This test is ineffective unless /dev/stdout also works. +if "$test" -w /dev/stdout >/dev/null && + "$test" ! -w /dev/stdout >&-; then + touch -c - >&- 2> /dev/null || fail=1 + touch -cm - >&- 2> /dev/null || fail=1 + touch -ca - >&- 2> /dev/null || fail=1 +fi + +Exit $fail diff --git a/tests/touch/no-dereference b/tests/touch/no-dereference deleted file mode 100755 index aee9a5cfc..000000000 --- a/tests/touch/no-dereference +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/sh -# Ensure that touch -h works. - -# Copyright (C) 2009-2012 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 . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - -ln -s nowhere dangling || framework_failure_ -touch file || framework_failure_ -ln -s file link || framework_failure_ - - -# These first tests should work on every platform. -# -h does not create files, but it warns. Use -c to silence warning. -touch -h no-file 2> err && fail=1 -test -s err || fail=1 -touch -h -c no-file 2> err || fail=1 -test -s err && fail=1 - -# -h works on regular files -touch -h file || fail=1 - -# -h coupled with -r uses timestamp of the symlink, not the referent. -touch -h -r dangling file || fail=1 -test -f nowhere && fail=1 - -# The remaining tests of -h require kernel support for changing symlink times. -grep '^#define HAVE_UTIMENSAT 1' "$CONFIG_HEADER" > /dev/null || -grep '^#define HAVE_LUTIMES 1' "$CONFIG_HEADER" > /dev/null || - skip_ 'this system lacks the utimensat function' - -# Changing time of dangling symlink is okay. -# Skip the test if this fails, but the error text corresponds to -# ENOSYS (possible with old kernel but new glibc). -touch -h dangling 2> err -case $? in - 0) test -f nowhere && fail=1 - test -s err && fail=1;; - 1) grep 'Function not implemented' err \ - && skip_ 'this system lacks the utimensat function' - fail=1;; - *) fail=1;; -esac - -# Change the mtime of a symlink. -touch -m -h -d 2009-10-10 link || fail=1 -case $(stat --format=%y link) in - 2009-10-10*) ;; - *) fail=1 ;; -esac -case $(stat --format=%y file) in - 2009-10-10*) fail=1;; -esac - -# Test interactions with -. -touch -h - > file || fail=1 - -test="$abs_top_builddir/src/test" - -# If >&- works, test "touch -ch -" etc. -# >&- apparently does not work in HP-UX 11.23. -# This test is ineffective unless /dev/stdout also works. -# If stdout is open, it is not a symlink. -if "$test" -w /dev/stdout >/dev/null && - "$test" ! -w /dev/stdout >&-; then - touch -h - >&- && fail=1 - touch -h -c - >&- || fail=1 -fi - -Exit $fail diff --git a/tests/touch/no-dereference.sh b/tests/touch/no-dereference.sh new file mode 100755 index 000000000..aee9a5cfc --- /dev/null +++ b/tests/touch/no-dereference.sh @@ -0,0 +1,84 @@ +#!/bin/sh +# Ensure that touch -h works. + +# Copyright (C) 2009-2012 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 . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + +ln -s nowhere dangling || framework_failure_ +touch file || framework_failure_ +ln -s file link || framework_failure_ + + +# These first tests should work on every platform. +# -h does not create files, but it warns. Use -c to silence warning. +touch -h no-file 2> err && fail=1 +test -s err || fail=1 +touch -h -c no-file 2> err || fail=1 +test -s err && fail=1 + +# -h works on regular files +touch -h file || fail=1 + +# -h coupled with -r uses timestamp of the symlink, not the referent. +touch -h -r dangling file || fail=1 +test -f nowhere && fail=1 + +# The remaining tests of -h require kernel support for changing symlink times. +grep '^#define HAVE_UTIMENSAT 1' "$CONFIG_HEADER" > /dev/null || +grep '^#define HAVE_LUTIMES 1' "$CONFIG_HEADER" > /dev/null || + skip_ 'this system lacks the utimensat function' + +# Changing time of dangling symlink is okay. +# Skip the test if this fails, but the error text corresponds to +# ENOSYS (possible with old kernel but new glibc). +touch -h dangling 2> err +case $? in + 0) test -f nowhere && fail=1 + test -s err && fail=1;; + 1) grep 'Function not implemented' err \ + && skip_ 'this system lacks the utimensat function' + fail=1;; + *) fail=1;; +esac + +# Change the mtime of a symlink. +touch -m -h -d 2009-10-10 link || fail=1 +case $(stat --format=%y link) in + 2009-10-10*) ;; + *) fail=1 ;; +esac +case $(stat --format=%y file) in + 2009-10-10*) fail=1;; +esac + +# Test interactions with -. +touch -h - > file || fail=1 + +test="$abs_top_builddir/src/test" + +# If >&- works, test "touch -ch -" etc. +# >&- apparently does not work in HP-UX 11.23. +# This test is ineffective unless /dev/stdout also works. +# If stdout is open, it is not a symlink. +if "$test" -w /dev/stdout >/dev/null && + "$test" ! -w /dev/stdout >&-; then + touch -h - >&- && fail=1 + touch -h -c - >&- || fail=1 +fi + +Exit $fail diff --git a/tests/touch/no-rights b/tests/touch/no-rights deleted file mode 100755 index abebc5261..000000000 --- a/tests/touch/no-rights +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# Make sure touch can update the times on a file that is neither -# readable nor writable. - -# Copyright (C) 1999-2012 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 . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - -# Make sure t2 is newer than t1. -touch -d '2000-01-01 00:00' t1 || framework_failure_ -touch -d '2000-01-02 00:00' t2 || framework_failure_ - -set x $(ls -t t1 t2) -test "$*" = "x t2 t1" || framework_failure_ - - -chmod 0 t1 -touch -d '2000-01-03 00:00' -c t1 || fail=1 - -set x $(ls -t t1 t2) -test "$*" = "x t1 t2" || fail=1 - -# Also test the combination of --no-create and -a. -touch -a --no-create t1 || fail=1 - -Exit $fail diff --git a/tests/touch/no-rights.sh b/tests/touch/no-rights.sh new file mode 100755 index 000000000..abebc5261 --- /dev/null +++ b/tests/touch/no-rights.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# Make sure touch can update the times on a file that is neither +# readable nor writable. + +# Copyright (C) 1999-2012 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 . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + +# Make sure t2 is newer than t1. +touch -d '2000-01-01 00:00' t1 || framework_failure_ +touch -d '2000-01-02 00:00' t2 || framework_failure_ + +set x $(ls -t t1 t2) +test "$*" = "x t2 t1" || framework_failure_ + + +chmod 0 t1 +touch -d '2000-01-03 00:00' -c t1 || fail=1 + +set x $(ls -t t1 t2) +test "$*" = "x t1 t2" || fail=1 + +# Also test the combination of --no-create and -a. +touch -a --no-create t1 || fail=1 + +Exit $fail diff --git a/tests/touch/not-owner b/tests/touch/not-owner deleted file mode 100755 index 63b8af249..000000000 --- a/tests/touch/not-owner +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -# Make sure that touch gives reasonable diagnostics when applied -# to an unwritable directory owned by some other user. - -# Copyright (C) 2003-2012 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 . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - -if env -- test -w /; then - skip_ you have write access to /. -fi - -if env -- test -O / || env -- test -G /; then - skip_ "you own /." -fi - -skip_if_root_ - - -# Before fileutils-4.1, we'd get the following misleading -# diagnostic instead of '...: Permission denied'. -# touch: creating '/': Is a directory -touch / > out 2>&1 && fail=1 - -# On SunOS4, EPERM is 'Not owner'. -# On some *BSD systems it's 'Operation not permitted'. -# On a system where root file system is mounted read-only -# it's 'Read-only file system'. -for msg in 'Not owner' 'Operation not permitted' 'Permission denied' \ - 'Read-only file system'; do - cat > exp < /dev/null 2>&1 && { match=1; break; } -done -test "$match" = 1 || fail=1 - -test $fail = 1 && compare exp out - -Exit $fail diff --git a/tests/touch/not-owner.sh b/tests/touch/not-owner.sh new file mode 100755 index 000000000..63b8af249 --- /dev/null +++ b/tests/touch/not-owner.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# Make sure that touch gives reasonable diagnostics when applied +# to an unwritable directory owned by some other user. + +# Copyright (C) 2003-2012 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 . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + +if env -- test -w /; then + skip_ you have write access to /. +fi + +if env -- test -O / || env -- test -G /; then + skip_ "you own /." +fi + +skip_if_root_ + + +# Before fileutils-4.1, we'd get the following misleading +# diagnostic instead of '...: Permission denied'. +# touch: creating '/': Is a directory +touch / > out 2>&1 && fail=1 + +# On SunOS4, EPERM is 'Not owner'. +# On some *BSD systems it's 'Operation not permitted'. +# On a system where root file system is mounted read-only +# it's 'Read-only file system'. +for msg in 'Not owner' 'Operation not permitted' 'Permission denied' \ + 'Read-only file system'; do + cat > exp < /dev/null 2>&1 && { match=1; break; } +done +test "$match" = 1 || fail=1 + +test $fail = 1 && compare exp out + +Exit $fail diff --git a/tests/touch/now-owned-by-other b/tests/touch/now-owned-by-other deleted file mode 100755 index 3da8d35ff..000000000 --- a/tests/touch/now-owned-by-other +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# Demonstrate that "touch -d now writable-but-owned-by-other" works. - -# Copyright (C) 2008-2012 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 . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch -require_root_ - -group_num=$(id -g $NON_ROOT_USERNAME) - -# Create a file owned by root, and writable by $NON_ROOT_USERNAME. -echo > root-owned || framework_failure_ -chgrp +$group_num . root-owned || framework_failure_ -chmod g+w root-owned - -# Ensure that the current directory is searchable by $NON_ROOT_USERNAME. -chmod g+x . - -setuidgid $NON_ROOT_USERNAME env PATH="$PATH" touch -d now root-owned || fail=1 - -Exit $fail diff --git a/tests/touch/now-owned-by-other.sh b/tests/touch/now-owned-by-other.sh new file mode 100755 index 000000000..3da8d35ff --- /dev/null +++ b/tests/touch/now-owned-by-other.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# Demonstrate that "touch -d now writable-but-owned-by-other" works. + +# Copyright (C) 2008-2012 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 . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch +require_root_ + +group_num=$(id -g $NON_ROOT_USERNAME) + +# Create a file owned by root, and writable by $NON_ROOT_USERNAME. +echo > root-owned || framework_failure_ +chgrp +$group_num . root-owned || framework_failure_ +chmod g+w root-owned + +# Ensure that the current directory is searchable by $NON_ROOT_USERNAME. +chmod g+x . + +setuidgid $NON_ROOT_USERNAME env PATH="$PATH" touch -d now root-owned || fail=1 + +Exit $fail diff --git a/tests/touch/obsolescent b/tests/touch/obsolescent deleted file mode 100755 index d403127be..000000000 --- a/tests/touch/obsolescent +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# Test touch with obsolescent 8- or 10-digit time stamps. - -# Copyright (C) 2000-2012 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 . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - -_POSIX2_VERSION=199209; export _POSIX2_VERSION -POSIXLY_CORRECT=1; export POSIXLY_CORRECT - - -yearstart=01010000 - -for ones in 11111111 1111111111; do - for args in $ones "-- $ones" "$yearstart $ones" "-- $yearstart $ones"; do - touch $args || fail=1 - test -f $ones || fail=1 - test -f $yearstart && fail=1 - rm -f $ones || fail=1 - done -done - -y2000=0101000000 -rm -f $y2000 file || fail=1 -touch $y2000 file && test -f $y2000 && test -f file || fail=1 - -Exit $fail diff --git a/tests/touch/obsolescent.sh b/tests/touch/obsolescent.sh new file mode 100755 index 000000000..d403127be --- /dev/null +++ b/tests/touch/obsolescent.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# Test touch with obsolescent 8- or 10-digit time stamps. + +# Copyright (C) 2000-2012 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 . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + +_POSIX2_VERSION=199209; export _POSIX2_VERSION +POSIXLY_CORRECT=1; export POSIXLY_CORRECT + + +yearstart=01010000 + +for ones in 11111111 1111111111; do + for args in $ones "-- $ones" "$yearstart $ones" "-- $yearstart $ones"; do + touch $args || fail=1 + test -f $ones || fail=1 + test -f $yearstart && fail=1 + rm -f $ones || fail=1 + done +done + +y2000=0101000000 +rm -f $y2000 file || fail=1 +touch $y2000 file && test -f $y2000 && test -f file || fail=1 + +Exit $fail diff --git a/tests/touch/read-only b/tests/touch/read-only deleted file mode 100755 index ee8c1d3b0..000000000 --- a/tests/touch/read-only +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# ensure that touch can operate on read-only files - -# Copyright (C) 2005-2012 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 . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch -skip_if_root_ - -: > read-only || framework_failure_ -chmod 444 read-only || framework_failure_ - - -touch read-only || fail=1 - -touch - 1< read-only 2> /dev/null && { test ! -f - || fail=1; } - -Exit $fail diff --git a/tests/touch/read-only.sh b/tests/touch/read-only.sh new file mode 100755 index 000000000..ee8c1d3b0 --- /dev/null +++ b/tests/touch/read-only.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# ensure that touch can operate on read-only files + +# Copyright (C) 2005-2012 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 . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch +skip_if_root_ + +: > read-only || framework_failure_ +chmod 444 read-only || framework_failure_ + + +touch read-only || fail=1 + +touch - 1< read-only 2> /dev/null && { test ! -f - || fail=1; } + +Exit $fail diff --git a/tests/touch/relative b/tests/touch/relative deleted file mode 100755 index ba199fce0..000000000 --- a/tests/touch/relative +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# Demonstrate using a combination of --reference and --date to -# set the time of a file back by an arbitrary amount. - -# Copyright (C) 2004-2012 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 . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - -TZ=UTC0 touch --date='2004-01-16 12:00 +0000' f || framework_failure_ - - -# Set times back by 5 days. -touch --ref f --date='-5 days' f || fail=1 - -TZ=UTC0 ls -og --time-style=+%Y-%m-%d f > out.1 || fail -sed 's/ f$//;s/.* //' out.1 > out - -cat <<\EOF > exp || fail=1 -2004-01-11 -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/touch/relative.sh b/tests/touch/relative.sh new file mode 100755 index 000000000..ba199fce0 --- /dev/null +++ b/tests/touch/relative.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# Demonstrate using a combination of --reference and --date to +# set the time of a file back by an arbitrary amount. + +# Copyright (C) 2004-2012 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 . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + +TZ=UTC0 touch --date='2004-01-16 12:00 +0000' f || framework_failure_ + + +# Set times back by 5 days. +touch --ref f --date='-5 days' f || fail=1 + +TZ=UTC0 ls -og --time-style=+%Y-%m-%d f > out.1 || fail +sed 's/ f$//;s/.* //' out.1 > out + +cat <<\EOF > exp || fail=1 +2004-01-11 +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/touch/trailing-slash b/tests/touch/trailing-slash deleted file mode 100755 index f09695c07..000000000 --- a/tests/touch/trailing-slash +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/sh -# Ensure that touch honors trailing slash. - -# Copyright (C) 2009-2012 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 . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - -ln -s nowhere dangling || framework_failure_ -ln -s loop loop || framework_failure_ -touch file || framework_failure_ -ln -s file link1 || framework_failure_ -mkdir dir || framework_failure_ -ln -s dir link2 || framework_failure_ - - -# Trailing slash can only appear on directory or symlink-to-directory. -# Up through coreutils 8.0, Solaris 9 failed these tests. -touch no-file/ && fail=1 -touch file/ && fail=1 -touch dangling/ && fail=1 -touch loop/ && fail=1 -touch link1/ && fail=1 -touch dir/ || fail=1 - -# -c silences ENOENT, but not ENOTDIR or ELOOP -touch -c no-file/ || fail=1 -touch -c file/ && fail=1 -touch -c dangling/ || fail=1 -touch -c loop/ && fail=1 -touch -c link1/ && fail=1 -touch -c dir/ || fail=1 -test -f no-file && fail=1 -test -f nowhere && fail=1 - -# Trailing slash dereferences a symlink, even with -h. -# mtime is sufficient to show pass (besides, lstat changes atime of -# symlinks and directories under Cygwin 1.5). -touch -d 2009-10-10 -h link2/ || fail=1 -touch -h -r link2/ file || fail=1 -case $(stat --format=%y dir) in - 2009-10-10*) ;; - *) fail=1 ;; -esac -case $(stat --format=%y link2) in - 2009-10-10*) fail=1 ;; -esac -case $(stat --format=%y file) in - 2009-10-10*) ;; - *) fail=1 ;; -esac - -Exit $fail diff --git a/tests/touch/trailing-slash.sh b/tests/touch/trailing-slash.sh new file mode 100755 index 000000000..f09695c07 --- /dev/null +++ b/tests/touch/trailing-slash.sh @@ -0,0 +1,66 @@ +#!/bin/sh +# Ensure that touch honors trailing slash. + +# Copyright (C) 2009-2012 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 . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + +ln -s nowhere dangling || framework_failure_ +ln -s loop loop || framework_failure_ +touch file || framework_failure_ +ln -s file link1 || framework_failure_ +mkdir dir || framework_failure_ +ln -s dir link2 || framework_failure_ + + +# Trailing slash can only appear on directory or symlink-to-directory. +# Up through coreutils 8.0, Solaris 9 failed these tests. +touch no-file/ && fail=1 +touch file/ && fail=1 +touch dangling/ && fail=1 +touch loop/ && fail=1 +touch link1/ && fail=1 +touch dir/ || fail=1 + +# -c silences ENOENT, but not ENOTDIR or ELOOP +touch -c no-file/ || fail=1 +touch -c file/ && fail=1 +touch -c dangling/ || fail=1 +touch -c loop/ && fail=1 +touch -c link1/ && fail=1 +touch -c dir/ || fail=1 +test -f no-file && fail=1 +test -f nowhere && fail=1 + +# Trailing slash dereferences a symlink, even with -h. +# mtime is sufficient to show pass (besides, lstat changes atime of +# symlinks and directories under Cygwin 1.5). +touch -d 2009-10-10 -h link2/ || fail=1 +touch -h -r link2/ file || fail=1 +case $(stat --format=%y dir) in + 2009-10-10*) ;; + *) fail=1 ;; +esac +case $(stat --format=%y link2) in + 2009-10-10*) fail=1 ;; +esac +case $(stat --format=%y file) in + 2009-10-10*) ;; + *) fail=1 ;; +esac + +Exit $fail -- cgit v1.2.3-54-g00ecf