Merge branch 'maint'
[platform/upstream/automake.git] / tests / self-check-is_newest.tap
1 #! /bin/sh
2 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # Sanity check for the automake testsuite: the 'is_newest' subroutine.
18
19 . ./defs || Exit 1
20
21 plan_ 21
22
23 # I'm a lazy typist.
24 Y () { command_ok_ "is_newest $*" is_newest "$@"; }
25 N () { command_ok_ "not is_newest $*" not is_newest "$@"; }
26
27 : > a
28 $sleep
29 : > b
30 : > c
31
32 stat a b c || : # For debugging.
33
34 Y c a
35 Y b a
36 N a b
37 Y c b
38 Y c c
39 Y c a b c
40
41 touch -r c d
42
43 stat c d || : # For debugging.
44
45 Y c d
46
47 # Should work on directories too, both empty and not-empty.  An older
48 # implementation of 'is_newest' failed if the first argument was a
49 # directory containing files newer than itself (see automake bug#9147).
50 mkdir u x
51 touch x/foo
52 $sleep
53 touch x/foo
54 $sleep
55 mkdir v y
56 touch y/foo
57 $sleep
58 touch y/foo
59
60 stat u v x y x/foo y/foo || : # For debugging.
61
62 for older in u x; do
63   for newer in v y; do
64     Y $newer $older
65     N $older $newer
66   done
67 done
68
69 Y x/foo x
70 N x x/foo
71
72 touch -r x u
73 Y x u
74 Y u x
75
76 # A couple of mild "stress" tests.
77 Y y x u v
78 Y y u x/foo a b c
79
80 :