#! /bin/sh
-# Copyright (C) 2011-2012 Free Software Foundation, Inc.
+# Copyright (C) 2011-2013 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
# Sanity check for the automake testsuite: the 'is_newest' subroutine.
-. ./defs || Exit 1
+. test-init.sh
plan_ 21
Y () { command_ok_ "is_newest $*" is_newest "$@"; }
N () { command_ok_ "not is_newest $*" not is_newest "$@"; }
+# A simple "touch -r" might not work, since on some file systems, and/or
+# with some 'touch' versions, it might truncate the timestamp (or even
+# rounded it upwards maybe). So the first (apparently redundant) 'touch'
+# invocation below ensures that the timestamp gets "normalized" in a way
+# that allows it to be correctly copied by the second 'touch' invocation.
+copy_timestamp ()
+{
+ touch -r "$1" "$1" && touch -r "$1" "$2"
+}
+
: > a
$sleep
: > b
Y c c
Y c a b c
-touch -r c d
+copy_timestamp c d
stat c d || : # For debugging.
Y x/foo x
N x x/foo
-touch -r x u
+copy_timestamp x u
Y x u
Y u x