1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-06-07 18:26:35 +02:00
Files
coreutils/tests/ls/time-1
T

128 lines
2.8 KiB
Bash
Raw Normal View History

1998-01-10 11:00:46 +00:00
#!/bin/sh
1998-01-10 11:54:39 +00:00
# Test some of ls's sorting options.
1998-01-10 11:00:46 +00:00
if test "$VERBOSE" = yes; then
set -x
1999-11-20 10:39:19 +00:00
ls --version
1998-01-10 11:00:46 +00:00
fi
2001-05-20 20:43:52 +00:00
# Avoid any possible glitches due to daylight-saving changes near the
# time stamps used during the test.
TZ=UTC0
export TZ
# Avoid glitches due to the environment specifying `ls' styles.
unset QUOTING_STYLE
unset TIME_STYLE
2000-10-28 12:36:17 +00:00
1998-01-10 11:00:46 +00:00
tmp=t-ls.$$
1999-12-08 16:50:22 +00:00
framework_failure=0
mkdir $tmp || framework_failure=1
cd $tmp || framework_failure=1
1998-01-10 11:24:51 +00:00
t1='1998-01-15 21:00'
t2='1998-01-15 22:00'
t3='1998-01-15 23:00'
u1='1998-01-14 11:00'
u2='1998-01-14 12:00'
u3='1998-01-14 13:00'
1999-12-08 16:50:22 +00:00
touch -m -d "$t3" a || framework_failure=1
touch -m -d "$t2" b || framework_failure=1
touch -m -d "$t1" c || framework_failure=1
1999-12-08 16:50:22 +00:00
touch -a -d "$u3" c || framework_failure=1
touch -a -d "$u2" b || framework_failure=1
# Make sure A has ctime at least 1 second more recent than C's.
sleep 2
1999-12-08 16:50:22 +00:00
touch -a -d "$u1" a || framework_failure=1
fail=0
# A has ctime more recent than C.
1999-11-20 10:39:19 +00:00
set `ls -c a c`
test "$*" = 'a c' || fail=1
# Sleep so long in an attempt to avoid spurious failures
# due to NFS caching and/or clock skew.
sleep 2
1998-01-10 11:54:39 +00:00
# Create a link, updating c's ctime.
1999-12-08 16:50:22 +00:00
ln c d || framework_failure=1
1998-01-10 11:00:46 +00:00
# Before we go any further, verify that touch's -m option works.
set -- `ls --full -l a`
case "$*" in
2001-05-20 20:43:52 +00:00
*" $t3:00.000000000 +0000 a") ;;
*)
# This might be what's making HPUX 11 systems fail this test.
2001-05-20 20:43:52 +00:00
cat >&2 << EOF
A basic test of touch -m has just failed, so the subsequent
tests in this file will not be run.
2000-09-23 19:27:33 +00:00
2001-05-20 20:43:52 +00:00
In the output below, the date of last modification for \`a' should
have been $t3.
EOF
2000-09-23 19:27:33 +00:00
#`
ls --full -l a
framework_failure=1
;;
esac
# Now test touch's -a option.
set -- `ls --full -lu a`
case "$*" in
2001-05-20 20:43:52 +00:00
*" $u1:00.000000000 +0000 a") ;;
*)
# This might be what's making HPUX 11 systems fail this test.
2001-05-20 20:43:52 +00:00
cat >&2 << EOF
A basic test of touch -a has just failed, so the subsequent
tests in this file will not be run.
2000-09-23 19:27:33 +00:00
2001-05-20 20:43:52 +00:00
In the output below, the date of last access for \`a' should
have been $u1.
EOF
2000-09-23 19:27:33 +00:00
ls --full -lu a
framework_failure=1
;;
esac
1999-12-08 16:50:22 +00:00
if test $framework_failure = 1; then
1998-01-10 11:00:46 +00:00
echo 'failure in testing framework'
exit 1
fi
1999-12-19 09:41:08 +00:00
set `ls -ut a b c`
test "$*" = 'c b a' && : || fail=1
1999-12-04 17:31:23 +00:00
test $fail = 1 && ls -l --full-time --time=access a b c
1998-01-10 11:54:39 +00:00
1999-11-20 10:39:19 +00:00
set `ls -t a b c`
test "$*" = 'a b c' && : || fail=1
1999-12-04 17:31:23 +00:00
test $fail = 1 && ls -l --full-time a b c
1998-01-10 11:00:46 +00:00
# Now, C should have ctime more recent than A.
1999-12-19 09:41:08 +00:00
set `ls -ct a c`
if test "$*" = 'c a'; then
: ok
else
1998-01-24 16:27:26 +00:00
# In spite of documentation, (e.g., stat(2)), neither link nor chmod
# update a file's st_ctime on SunOS4.1.4.
cat >&2 << \EOF
2000-09-23 19:27:33 +00:00
failed ls ctime test -- this failure is expected at least for SunOS4.1.4
and for tmpfs file systems on Solaris 5.5.1.
2000-09-23 19:27:33 +00:00
In the output below, `c' should have had a ctime more recent than
that of `a', but does not.
EOF
2000-09-23 19:27:33 +00:00
#'
ls -ctl --full-time a c
fail=1
fi
1998-01-10 11:54:39 +00:00
1998-01-10 11:00:46 +00:00
cd ..
rm -rf $tmp
exit $fail