summaryrefslogtreecommitdiff
path: root/usr.bin/make/unit-tests
diff options
context:
space:
mode:
authorapb <apb@NetBSD.org>2006-02-26 22:45:46 +0000
committerapb <apb@NetBSD.org>2006-02-26 22:45:46 +0000
commitf34c12e9891a798cdb3bedffa2ee43aed79adbd7 (patch)
treefa06d1a840e8ecb1c0cf47e3e36732edc0b3a31c /usr.bin/make/unit-tests
parent3ea7f78b5754c90382f880088ad622295fe20eb8 (diff)
Make ".WAIT" apply recursively to all children of nodes on the right
hand side of the .WAIT, except when the recursive interpretation would cause a cycle in the dependency graph. Discussed in tech-toolchain. Reviewed by christos, sjg.
Diffstat (limited to 'usr.bin/make/unit-tests')
-rw-r--r--usr.bin/make/unit-tests/Makefile4
-rw-r--r--usr.bin/make/unit-tests/dotwait61
-rw-r--r--usr.bin/make/unit-tests/test.exp29
3 files changed, 93 insertions, 1 deletions
diff --git a/usr.bin/make/unit-tests/Makefile b/usr.bin/make/unit-tests/Makefile
index ac1719701cc..ef05c8a7027 100644
--- a/usr.bin/make/unit-tests/Makefile
+++ b/usr.bin/make/unit-tests/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.18 2006/02/26 21:43:01 sjg Exp $
+# $NetBSD: Makefile,v 1.19 2006/02/26 22:45:46 apb Exp $
#
# Unit tests for make(1)
# The main targets are:
@@ -21,6 +21,7 @@ UNIT_TESTS:= ${.PARSEDIR}
SUBFILES= \
comment \
cond1 \
+ dotwait \
modmatch \
modmisc \
modorder \
@@ -34,6 +35,7 @@ all: ${SUBFILES}
# the tests are actually done with sub-makes.
.PHONY: ${SUBFILES}
+.PRECIOUS: ${SUBFILES}
${SUBFILES}:
-@${.MAKE} -k -f ${UNIT_TESTS}/$@
diff --git a/usr.bin/make/unit-tests/dotwait b/usr.bin/make/unit-tests/dotwait
new file mode 100644
index 00000000000..43706afe64b
--- /dev/null
+++ b/usr.bin/make/unit-tests/dotwait
@@ -0,0 +1,61 @@
+# $NetBSD: dotwait,v 1.1 2006/02/26 22:45:46 apb Exp $
+
+THISMAKEFILE:= ${.PARSEDIR}/${.PARSEFILE}
+
+TESTS= simple recursive shared cycle
+PAUSE= sleep 1
+
+# Use a .for loop rather than dependencies here, to ensure
+# that the tests are run one by one, with parallelism
+# only within tests.
+# Ignore "--- target ---" lines printed by parallel make.
+all:
+.for t in ${TESTS}
+ @${.MAKE} -f ${THISMAKEFILE} -j4 $t | grep -v "^--- "
+.endfor
+
+#
+# Within each test, the names of the sub-targets follow these
+# conventions:
+# * If it's expected that two or more targets may be made in parallel,
+# then the target names will differ only in an alphabetic component
+# such as ".a" or ".b".
+# * If it's expected that two or more targets should be made in sequence
+# then the target names will differ in numeric components, such that
+# lexical ordering of the target names matches the expected order
+# in which the targets should be made.
+#
+# Targets may echo ${PARALLEL_TARG} to print a modified version
+# of their own name, in which alphabetic components like ".a" or ".b"
+# are converted to ".*". Two targets that are expected to
+# be made in parallel will thus print the same strings, so that the
+# output is independent of the order in which these targets are made.
+#
+PARALLEL_TARG= ${.TARGET:C/\.[a-z]/.*/g:Q}
+.DEFAULT:
+ @echo ${PARALLEL_TARG}; ${PAUSE}; echo ${PARALLEL_TARG}
+_ECHOUSE: .USE
+ @echo ${PARALLEL_TARG}; ${PAUSE}; echo ${PARALLEL_TARG}
+
+# simple: no recursion, no cycles
+simple: simple.1 .WAIT simple.2
+
+# recursive: all children of the left hand side of the .WAIT
+# must be made before any child of the right hand side.
+recursive: recursive.1.99 .WAIT recursive.2.99
+recursive.1.99: recursive.1.1.a recursive.1.1.b _ECHOUSE
+recursive.2.99: recursive.2.1.a recursive.2.1.b _ECHOUSE
+
+# shared: both shared.1.99 and shared.2.99 depend on shared.0.
+# shared.0 must be made first, even though it is a child of
+# the right hand side of the .WAIT.
+shared: shared.1.99 .WAIT shared.2.99
+shared.1.99: shared.0 _ECHOUSE
+shared.2.99: shared.2.1 shared.0 _ECHOUSE
+
+# cycle: the cyclic dependency must not cause infinite recursion
+# leading to stack overflow and a crash.
+cycle: cycle.1.99 .WAIT cycle.2.99
+cycle.2.99: cycle.2.98 _ECHOUSE
+cycle.2.98: cycle.2.97 _ECHOUSE
+cycle.2.97: cycle.2.99 _ECHOUSE
diff --git a/usr.bin/make/unit-tests/test.exp b/usr.bin/make/unit-tests/test.exp
index 0b285db97ad..be5e203c326 100644
--- a/usr.bin/make/unit-tests/test.exp
+++ b/usr.bin/make/unit-tests/test.exp
@@ -20,6 +20,35 @@ Passed:
4 is not prime
5 is prime
+simple.1
+simple.1
+simple.2
+simple.2
+recursive.1.1.*
+recursive.1.1.*
+recursive.1.1.*
+recursive.1.1.*
+recursive.1.99
+recursive.1.99
+recursive.2.1.*
+recursive.2.1.*
+recursive.2.1.*
+recursive.2.1.*
+recursive.2.99
+recursive.2.99
+shared.0
+shared.0
+shared.1.99
+shared.1.99
+shared.2.1
+shared.2.1
+shared.2.99
+shared.2.99
+make: Graph cycles through `cycle.2.99'
+make: Graph cycles through `cycle.2.98'
+make: Graph cycles through `cycle.2.97'
+cycle.1.99
+cycle.1.99
LIB=a X_LIBS:M${LIB${LIB:tu}} is "/tmp/liba.a"
LIB=a X_LIBS:M*/lib${LIB}.a is "/tmp/liba.a"
LIB=a X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBA.A"