xref: /freebsd/contrib/bmake/unit-tests/opt-chdir.mk (revision 43a5ec4eb41567cc92586503212743d89686d78f)
1# $NetBSD: opt-chdir.mk,v 1.6 2021/05/18 17:05:45 sjg Exp $
2#
3# Tests for the -C command line option, which changes the directory at the
4# beginning.
5#
6# This option has been available since 2009-08-27.
7
8.MAKEFLAGS: -d0			# switch stdout to line-buffered
9
10all: chdir-filename-too-long
11all: chdir-root
12all: chdir-nonexistent
13
14# Try to overflow the internal buffer for .CURDIR, which is curdir.
15chdir-filename-too-long: .PHONY .IGNORE
16	# 5000 slashes, separated by dots: /./././.../././
17	@${MAKE} -C ${:U:range=5000:@@/@:ts.}
18
19# Changing to another directory is possible via the command line.
20# In this test, it is the root directory since almost any other directory
21# is not guaranteed to exist on every platform.
22chdir-root: .PHONY .IGNORE
23	@MAKE_OBJDIR_CHECK_WRITABLE=no ${MAKE} -C / -V 'cwd: $${.CURDIR}'
24
25# Trying to change to a nonexistent directory exits immediately.
26# Note: just because the whole point of /nonexistent is that it should
27# not exist - doesn't mean it doesn't.
28chdir-nonexistent: .PHONY .IGNORE
29	@${MAKE} -C /nonexistent.${.MAKE.PID}
30