xref: /freebsd/contrib/bmake/unit-tests/opt-chdir.mk (revision 7695ced633498a94c26466934321782acfc69307)
1# $NetBSD: opt-chdir.mk,v 1.5 2020/11/15 05:43:56 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.
26chdir-nonexistent: .PHONY .IGNORE
27	@${MAKE} -C /nonexistent
28