xref: /freebsd/contrib/bmake/unit-tests/varmod-mtime.mk (revision 9f23cbd6cae82fd77edfad7173432fa8dccd0a95)
1# $NetBSD: varmod-mtime.mk,v 1.1 2023/05/09 20:14:27 sjg Exp $
2#
3# Tests for the :mtime variable modifier, which provides mtime
4# of variable value assumed to be a pathname.
5
6all:
7
8# mtime of this makefile
9mtime:= ${MAKEFILE:mtime}
10
11# if pathname does not exist and timestamp is provided
12# that is the result
13.if ${no/such:L:mtime=0} != "0"
14.  error
15.endif
16
17.if ${no/such:L:mtime=42} != "42"
18.  error
19.endif
20
21# if no timestamp is provided and stat(2) fails use current time
22.if ${no/such:L:mtime} < ${mtime}
23.   error no/such:L:mtime ${no/such:L:mtime} < ${mtime}
24.endif
25
26COOKIE = ${TMPDIR}/varmod-mtime.cookie
27x!= touch ${COOKIE}
28.if ${COOKIE:mtime=0} < ${mtime}
29.   error COOKIE:mtime=0 ${COOKIE:mtime=0} < ${mtime}
30.endif
31