Module Name:    src
Committed By:   sjg
Date:           Sat Feb  6 18:26:03 UTC 2021

Modified Files:
        src/usr.bin/make/unit-tests: Makefile cmdline.exp cmdline.mk export.exp
            objdir-writable.exp

Log Message:
Avoid test failures when more than one user run them.

Use a private  TMPDIR
a subdir of .OBJDIR if using it
otherwise /tmp/uid${.MAKE.UID}


To generate a diff of this commit:
cvs rdiff -u -r1.268 -r1.269 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/cmdline.exp \
    src/usr.bin/make/unit-tests/objdir-writable.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cmdline.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/export.exp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.268 src/usr.bin/make/unit-tests/Makefile:1.269
--- src/usr.bin/make/unit-tests/Makefile:1.268	Thu Feb  4 00:16:03 2021
+++ src/usr.bin/make/unit-tests/Makefile	Sat Feb  6 18:26:03 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.268 2021/02/04 00:16:03 rillig Exp $
+# $NetBSD: Makefile,v 1.269 2021/02/06 18:26:03 sjg Exp $
 #
 # Unit tests for make(1)
 #
@@ -31,6 +31,8 @@
 # src/tests/usr.bin/make/t_make.sh.
 #
 
+.MAIN: all
+
 # we use these below but we might be an older make
 .MAKE.OS?= ${uname -s:L:sh}
 .MAKE.UID?= ${id -u:L:sh}
@@ -441,16 +443,10 @@ TESTS+=		varquote
 #	escape-for-item.mk
 #	posix-*.mk (see posix.mk and posix1.mk)
 
-.if ${.OBJDIR} != ${.CURDIR}
-RO_OBJDIR:=	${.OBJDIR}/roobj
-.else
-RO_OBJDIR:=	${TMPDIR:U/tmp}/roobj
-.endif
 # Additional environment variables for some of the tests.
 # The base environment is -i PATH="$PATH".
 ENV.depsrc-optional+=   TZ=UTC
 ENV.envfirst=		FROM_ENV=value-from-env
-ENV.objdir-writable+=	RO_OBJDIR=${RO_OBJDIR}
 ENV.varmisc=		FROM_ENV=env
 ENV.varmisc+=		FROM_ENV_BEFORE=env
 ENV.varmisc+=		FROM_ENV_AFTER=env
@@ -486,7 +482,6 @@ SED_CMDS.job-output-long-lines= \
 	${:D marker should always be at the beginning of the line. } \
 	-e '/^aa*--- job-b ---$$/d' \
 	-e '/^bb*--- job-a ---$$/d'
-SED_CMDS.objdir-writable=	-e 's,${RO_OBJDIR},OBJDIR/roobj,g'
 SED_CMDS.opt-debug-graph1=	${STD_SED_CMDS.dg1}
 SED_CMDS.opt-debug-graph2=	${STD_SED_CMDS.dg2}
 SED_CMDS.opt-debug-graph3=	${STD_SED_CMDS.dg3}
@@ -593,8 +588,6 @@ STD_SED_CMDS.shell+=		-e 's,^${.SHELL:T}
 
 # End of the configuration helpers section.
 
-.MAIN: all
-
 UNIT_TESTS:=	${.PARSEDIR}
 .PATH: ${UNIT_TESTS}
 
@@ -623,7 +616,22 @@ LC_ALL=		C
 LANG=		C
 .export LANG LC_ALL
 
+
+# for many tests we need a TMPDIR that will not collide
+# with other users.
+.if ${.OBJDIR} != ${.CURDIR}
+# easy
+TMPDIR:=	${.OBJDIR}/tmp
+.else
+TMPDIR:=	${TMPDIR:U/tmp}/uid${.MAKE.UID}
+.endif
+# make sure it exists
+.if !exist(${TMPDIR})
+x!= echo; mkdir -p ${TMPDIR}
+.endif
+
 MAKE_TEST_ENV?=	MALLOC_OPTIONS="JA"	# for jemalloc
+MAKE_TEST_ENV+= TMPDIR=${TMPDIR}
 
 .if ${.MAKE.OS} == "NetBSD"
 LIMIT_RESOURCES?=	ulimit -v 200000
@@ -657,6 +665,7 @@ _SED_CMDS+=	-e 's,${TEST_MAKE:T:S,.,\\.,
 _SED_CMDS+=	-e 's,^usage: ${TEST_MAKE:T:S,.,\\.,g} ,usage: make ,'
 # replace anything after 'stopped in' with unit-tests
 _SED_CMDS+=	-e '/stopped/s, /.*, unit-tests,'
+_SED_CMDS+=	-e 's,${TMPDIR},TMPDIR,g'
 # strip ${.CURDIR}/ from the output
 _SED_CMDS+=	-e 's,${.CURDIR:S,.,\\.,g}/,,g'
 _SED_CMDS+=	-e 's,${UNIT_TESTS:S,.,\\.,g}/,,g'

Index: src/usr.bin/make/unit-tests/cmdline.exp
diff -u src/usr.bin/make/unit-tests/cmdline.exp:1.1 src/usr.bin/make/unit-tests/cmdline.exp:1.2
--- src/usr.bin/make/unit-tests/cmdline.exp:1.1	Tue Jul 28 22:44:44 2020
+++ src/usr.bin/make/unit-tests/cmdline.exp	Sat Feb  6 18:26:03 2021
@@ -1,5 +1,5 @@
 makeobjdir-direct:
-show-objdir: /tmp/6a8899d2-d227-4b55-9b6b-f3c8eeb83fd5
+show-objdir: TMPDIR/6a8899d2-d227-4b55-9b6b-f3c8eeb83fd5
 makeobjdir-indirect:
-show-objdir: /tmp/a7b41170-53f8-4cc2-bc5c-e4c3dd93ec45/
+show-objdir: TMPDIR/a7b41170-53f8-4cc2-bc5c-e4c3dd93ec45/
 exit status 0
Index: src/usr.bin/make/unit-tests/objdir-writable.exp
diff -u src/usr.bin/make/unit-tests/objdir-writable.exp:1.1 src/usr.bin/make/unit-tests/objdir-writable.exp:1.2
--- src/usr.bin/make/unit-tests/objdir-writable.exp:1.1	Thu Nov 12 23:35:21 2020
+++ src/usr.bin/make/unit-tests/objdir-writable.exp	Sat Feb  6 18:26:03 2021
@@ -1,5 +1,5 @@
-make warning: OBJDIR/roobj: Permission denied.
+make warning: TMPDIR/roobj: Permission denied.
 /tmp
-OBJDIR/roobj
-OBJDIR/roobj
+TMPDIR/roobj
+TMPDIR/roobj
 exit status 0

Index: src/usr.bin/make/unit-tests/cmdline.mk
diff -u src/usr.bin/make/unit-tests/cmdline.mk:1.2 src/usr.bin/make/unit-tests/cmdline.mk:1.3
--- src/usr.bin/make/unit-tests/cmdline.mk:1.2	Sun Nov 15 14:07:53 2020
+++ src/usr.bin/make/unit-tests/cmdline.mk	Sat Feb  6 18:26:03 2021
@@ -1,8 +1,8 @@
-# $NetBSD: cmdline.mk,v 1.2 2020/11/15 14:07:53 rillig Exp $
+# $NetBSD: cmdline.mk,v 1.3 2021/02/06 18:26:03 sjg Exp $
 #
 # Tests for command line parsing and related special variables.
 
-TMPBASE?=	/tmp
+TMPBASE?=	${TMPDIR:U/tmp/uid${.MAKE.UID}}
 SUB1=		a7b41170-53f8-4cc2-bc5c-e4c3dd93ec45	# just a random UUID
 SUB2=		6a8899d2-d227-4b55-9b6b-f3c8eeb83fd5	# just a random UUID
 MAKE_CMD=	env TMPBASE=${TMPBASE}/${SUB1} ${.MAKE} -f ${MAKEFILE} -r

Index: src/usr.bin/make/unit-tests/export.exp
diff -u src/usr.bin/make/unit-tests/export.exp:1.5 src/usr.bin/make/unit-tests/export.exp:1.6
--- src/usr.bin/make/unit-tests/export.exp:1.5	Sat Oct 10 19:25:19 2020
+++ src/usr.bin/make/unit-tests/export.exp	Sat Feb  6 18:26:03 2021
@@ -1,4 +1,5 @@
 MAKELEVEL=1
+TMPDIR=TMPDIR
 UT_DOLLAR=This is $UT_FU
 UT_FOO=foobar is fubar
 UT_FU=fubar

Reply via email to