Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests Avoid test failures when more than o...



details:   https://anonhg.NetBSD.org/src/rev/ec485016e38b
branches:  trunk
changeset: 951581:ec485016e38b
user:      sjg <sjg%NetBSD.org@localhost>
date:      Sat Feb 06 18:26:03 2021 +0000

description:
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}

diffstat:

 usr.bin/make/unit-tests/Makefile            |  29 +++++++++++++++++++----------
 usr.bin/make/unit-tests/cmdline.exp         |   4 ++--
 usr.bin/make/unit-tests/cmdline.mk          |   4 ++--
 usr.bin/make/unit-tests/export.exp          |   1 +
 usr.bin/make/unit-tests/objdir-writable.exp |   6 +++---
 5 files changed, 27 insertions(+), 17 deletions(-)

diffs (129 lines):

diff -r b23a24b4965c -r ec485016e38b usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Sat Feb 06 16:14:55 2021 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Sat Feb 06 18:26:03 2021 +0000
@@ -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 @@
 #      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 @@
        ${: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 @@
 
 # End of the configuration helpers section.
 
-.MAIN: all
-
 UNIT_TESTS:=   ${.PARSEDIR}
 .PATH: ${UNIT_TESTS}
 
@@ -623,7 +616,22 @@
 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,^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'
diff -r b23a24b4965c -r ec485016e38b usr.bin/make/unit-tests/cmdline.exp
--- a/usr.bin/make/unit-tests/cmdline.exp       Sat Feb 06 16:14:55 2021 +0000
+++ b/usr.bin/make/unit-tests/cmdline.exp       Sat Feb 06 18:26:03 2021 +0000
@@ -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
diff -r b23a24b4965c -r ec485016e38b usr.bin/make/unit-tests/cmdline.mk
--- a/usr.bin/make/unit-tests/cmdline.mk        Sat Feb 06 16:14:55 2021 +0000
+++ b/usr.bin/make/unit-tests/cmdline.mk        Sat Feb 06 18:26:03 2021 +0000
@@ -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
diff -r b23a24b4965c -r ec485016e38b usr.bin/make/unit-tests/export.exp
--- a/usr.bin/make/unit-tests/export.exp        Sat Feb 06 16:14:55 2021 +0000
+++ b/usr.bin/make/unit-tests/export.exp        Sat Feb 06 18:26:03 2021 +0000
@@ -1,4 +1,5 @@
 MAKELEVEL=1
+TMPDIR=TMPDIR
 UT_DOLLAR=This is $UT_FU
 UT_FOO=foobar is fubar
 UT_FU=fubar
diff -r b23a24b4965c -r ec485016e38b usr.bin/make/unit-tests/objdir-writable.exp
--- a/usr.bin/make/unit-tests/objdir-writable.exp       Sat Feb 06 16:14:55 2021 +0000
+++ b/usr.bin/make/unit-tests/objdir-writable.exp       Sat Feb 06 18:26:03 2021 +0000
@@ -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



Home | Main Index | Thread Index | Old Index