1999-09-14 02:03:19 +00:00
|
|
|
# -*-perl-*-
|
|
|
|
|
|
|
|
$description = "Test parallelism (-j) option.";
|
2017-10-30 16:53:49 +00:00
|
|
|
$details = "";
|
1999-09-14 02:03:19 +00:00
|
|
|
|
|
|
|
if (!$parallel_jobs) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-10-30 16:53:49 +00:00
|
|
|
run_make_test("
|
|
|
|
all : def_1 def_2 def_3
|
2019-10-12 20:22:01 +00:00
|
|
|
def_1 : ; \@#HELPER# file ONE wait THREE out TWO
|
|
|
|
def_2 : ; \@#HELPER# wait FOUR file THREE
|
|
|
|
def_3 : ; \@#HELPER# wait ONE file FOUR",
|
|
|
|
'-j4', "file ONE\nwait ONE\nfile FOUR\nwait FOUR\nfile THREE\nwait THREE\nTWO");
|
2017-10-30 16:53:49 +00:00
|
|
|
rmfiles(qw(ONE TWO THREE FOUR));
|
1999-09-14 02:03:19 +00:00
|
|
|
|
2017-10-30 16:53:49 +00:00
|
|
|
# Verify -j added to MAKEFLAGS in the makefile
|
|
|
|
run_make_test("
|
|
|
|
MAKEFLAGS += -j4
|
|
|
|
all : def_1 def_2 def_3
|
2019-10-12 20:22:01 +00:00
|
|
|
def_1 : ; \@#HELPER# file ONE wait THREE out TWO
|
|
|
|
def_2 : ; \@#HELPER# wait FOUR file THREE
|
|
|
|
def_3 : ; \@#HELPER# wait ONE file FOUR",
|
|
|
|
'', "file ONE\nwait ONE\nfile FOUR\nwait FOUR\nfile THREE\nwait THREE\nTWO");
|
2017-10-30 16:53:49 +00:00
|
|
|
rmfiles(qw(ONE TWO THREE FOUR));
|
|
|
|
|
|
|
|
# Command line should take precedence
|
2005-05-03 13:57:20 +00:00
|
|
|
run_make_test("
|
2017-10-30 16:53:49 +00:00
|
|
|
MAKEFLAGS += -j2
|
1999-09-23 18:23:33 +00:00
|
|
|
all : def_1 def_2 def_3
|
2019-10-12 20:22:01 +00:00
|
|
|
def_1 : ; \@#HELPER# file ONE wait THREE out TWO
|
|
|
|
def_2 : ; \@#HELPER# wait FOUR file THREE
|
|
|
|
def_3 : ; \@#HELPER# wait ONE file FOUR",
|
|
|
|
'-j4', "file ONE\nwait ONE\nfile FOUR\nwait FOUR\nfile THREE\nwait THREE\nTWO");
|
2017-10-30 16:53:49 +00:00
|
|
|
rmfiles(qw(ONE TWO THREE FOUR));
|
1999-09-14 02:03:19 +00:00
|
|
|
|
1999-09-23 18:23:33 +00:00
|
|
|
# Test parallelism with included files. Here we sleep/echo while
|
|
|
|
# building the included files, to test that they are being built in
|
|
|
|
# parallel.
|
2005-05-03 13:57:20 +00:00
|
|
|
run_make_test("
|
2019-10-12 20:22:01 +00:00
|
|
|
all: 1 2; \@#HELPER# out success
|
1999-09-23 18:23:33 +00:00
|
|
|
-include 1.inc 2.inc
|
2019-10-12 20:22:01 +00:00
|
|
|
1.inc:
|
|
|
|
\t\@#HELPER# file ONE.inc wait THREE.inc file TWO.inc
|
|
|
|
\t\@echo '1: ; \@#HELPER# file ONE wait THREE file TWO' > \$\@
|
|
|
|
2.inc:
|
|
|
|
\t\@#HELPER# wait ONE.inc file THREE.inc
|
|
|
|
\t\@echo '2: ; \@#HELPER# wait ONE file THREE' > \$\@",
|
2005-05-03 13:57:20 +00:00
|
|
|
"-j4",
|
2019-10-12 20:22:01 +00:00
|
|
|
"file ONE.inc\nwait ONE.inc\nfile THREE.inc\nwait THREE.inc\nfile TWO.inc\nfile ONE\nwait ONE\nfile THREE\nwait THREE\nfile TWO\nsuccess\n", 0, 7);
|
2017-10-30 16:53:49 +00:00
|
|
|
rmfiles(qw(ONE.inc TWO.inc THREE.inc ONE TWO THREE 1.inc 2.inc));
|
1999-09-23 18:23:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Test parallelism with included files--this time recurse first and make
|
|
|
|
# sure the jobserver works.
|
2005-05-03 13:57:20 +00:00
|
|
|
run_make_test("
|
|
|
|
recurse: ; \@\$(MAKE) --no-print-directory -f #MAKEFILE# INC=yes all
|
2019-10-12 20:22:01 +00:00
|
|
|
all: 1 2; \@#HELPER# out success
|
1999-09-23 18:23:33 +00:00
|
|
|
|
|
|
|
INC = no
|
|
|
|
ifeq (\$(INC),yes)
|
|
|
|
-include 1.inc 2.inc
|
|
|
|
endif
|
|
|
|
|
2019-10-12 20:22:01 +00:00
|
|
|
1.inc: ; \@#HELPER# file ONE.inc wait THREE.inc file TWO.inc; echo '1: ; \@#HELPER# file ONE wait THREE file TWO' > \$\@
|
|
|
|
2.inc: ; \@#HELPER# wait ONE.inc file THREE.inc; echo '2: ; \@#HELPER# wait ONE file THREE' > \$\@",
|
2005-05-03 13:57:20 +00:00
|
|
|
"-j4",
|
2019-10-12 20:22:01 +00:00
|
|
|
"file ONE.inc\nwait ONE.inc\nfile THREE.inc\nwait THREE.inc\nfile TWO.inc\nfile ONE\nwait ONE\nfile THREE\nwait THREE\nfile TWO\nsuccess\n", 0, 7);
|
2017-10-30 16:53:49 +00:00
|
|
|
rmfiles(qw(ONE.inc TWO.inc THREE.inc ONE TWO THREE 1.inc 2.inc));
|
1999-09-23 18:23:33 +00:00
|
|
|
|
2005-05-03 13:57:20 +00:00
|
|
|
# Grant Taylor reports a problem where tokens can be lost (not written back
|
|
|
|
# to the pipe when they should be): this happened when there is a $(shell ...)
|
|
|
|
# function in an exported recursive variable. I added some code to check
|
|
|
|
# for this situation and print a message if it occurred. This test used
|
|
|
|
# to trigger this code when I added it but no longer does after the fix.
|
2007-07-14 02:57:46 +00:00
|
|
|
# We have to increase the timeout from the default (5s) on this test.
|
1999-09-14 02:03:19 +00:00
|
|
|
|
2005-05-03 13:57:20 +00:00
|
|
|
run_make_test("
|
|
|
|
export HI = \$(shell \$(\$\@.CMD))
|
2019-10-12 20:22:01 +00:00
|
|
|
first.CMD = #HELPER# out hi
|
|
|
|
second.CMD = #HELPER# sleep 4
|
1999-09-14 02:03:19 +00:00
|
|
|
|
2005-05-03 13:57:20 +00:00
|
|
|
.PHONY: all first second
|
|
|
|
all: first second
|
2005-04-08 12:51:20 +00:00
|
|
|
|
2019-10-12 20:22:01 +00:00
|
|
|
first second: ; \@#HELPER# out \$\@ sleep 1 out \$\@",
|
|
|
|
'-j2', "first\nsleep 1\nfirst\nsecond\nsleep 1\nsecond", 0, 7);
|
2005-04-08 12:51:20 +00:00
|
|
|
|
2005-08-08 05:08:00 +00:00
|
|
|
# Michael Matz <matz@suse.de> reported a bug where if make is running in
|
|
|
|
# parallel without -k and two jobs die in a row, but not too close to each
|
|
|
|
# other, then make will quit without waiting for the rest of the jobs to die.
|
|
|
|
|
|
|
|
run_make_test("
|
|
|
|
.PHONY: all fail.1 fail.2 fail.3 ok
|
|
|
|
all: fail.1 ok fail.2 fail.3
|
|
|
|
|
2017-10-30 16:53:49 +00:00
|
|
|
.RECIPEPREFIX := >
|
|
|
|
|
2005-08-08 05:08:00 +00:00
|
|
|
fail.1 fail.2 fail.3:
|
2019-10-12 20:22:01 +00:00
|
|
|
> \@#HELPER# sleep \$(patsubst fail.%,%,\$\@)
|
|
|
|
> \@#HELPER# out Fail
|
|
|
|
> \@#HELPER# fail 1
|
2005-08-08 05:08:00 +00:00
|
|
|
|
|
|
|
ok:
|
2019-10-12 20:22:01 +00:00
|
|
|
> \@#HELPER# sleep 4
|
|
|
|
> \@#HELPER# out OK",
|
|
|
|
'-rR -j5', "sleep 1\nFail\nfail 1
|
2019-09-22 21:02:57 +00:00
|
|
|
#MAKE#: *** [#MAKEFILE#:10: fail.1] Error 1
|
2005-08-08 05:08:00 +00:00
|
|
|
#MAKE#: *** Waiting for unfinished jobs....
|
2019-10-12 20:22:01 +00:00
|
|
|
sleep 2\nFail\nfail 1
|
2019-09-22 21:02:57 +00:00
|
|
|
#MAKE#: *** [#MAKEFILE#:10: fail.2] Error 1
|
2019-10-12 20:22:01 +00:00
|
|
|
sleep 3\nFail\nfail 1
|
2019-09-22 21:02:57 +00:00
|
|
|
#MAKE#: *** [#MAKEFILE#:10: fail.3] Error 1
|
2019-10-12 20:22:01 +00:00
|
|
|
sleep 4\nOK",
|
2005-08-08 05:08:00 +00:00
|
|
|
512);
|
|
|
|
|
|
|
|
|
2006-02-08 17:29:07 +00:00
|
|
|
# Test for Savannah bug #15641.
|
|
|
|
#
|
|
|
|
run_make_test('
|
|
|
|
.PHONY: all
|
|
|
|
all:; @:
|
|
|
|
|
|
|
|
-include foo.d
|
|
|
|
|
2019-10-12 20:22:01 +00:00
|
|
|
foo.d: comp ; @#HELPER# out $@
|
2006-02-08 17:29:07 +00:00
|
|
|
|
|
|
|
comp: mod_a.o mod_b.o; @:
|
|
|
|
|
2019-10-12 20:22:01 +00:00
|
|
|
mod_a.o mod_b.o: ; @#HELPER# fail 1
|
|
|
|
', '-j2', "fail 1\nfail 1\n");
|
2006-02-08 17:29:07 +00:00
|
|
|
|
|
|
|
|
2007-08-15 13:53:53 +00:00
|
|
|
# TEST #9 -- Savannah bugs 3330 and 15919
|
|
|
|
# In earlier versions of make this will either give the wrong answer, or hang.
|
|
|
|
|
|
|
|
utouch(-10, 'target');
|
2019-10-12 20:22:01 +00:00
|
|
|
run_make_test('target: intermed ; #HELPER# file $@
|
2007-08-15 13:53:53 +00:00
|
|
|
|
|
|
|
.INTERMEDIATE: intermed
|
2019-10-12 20:22:01 +00:00
|
|
|
intermed: | phony ; #HELPER# file $@
|
2007-08-15 13:53:53 +00:00
|
|
|
|
|
|
|
.PHONY: phony
|
|
|
|
phony: ; : phony', '-rR -j', ': phony');
|
2009-10-04 19:18:16 +00:00
|
|
|
rmfiles('target');
|
2007-08-15 13:53:53 +00:00
|
|
|
|
2011-09-18 23:39:26 +00:00
|
|
|
# TEST #11: Make sure -jN from MAKEFLAGS is processed even when we re-exec
|
|
|
|
# See Savannah bug #33873
|
|
|
|
|
2020-04-01 05:58:33 +00:00
|
|
|
$ENV{MAKEFLAGS} = '-j4';
|
2011-09-18 23:39:26 +00:00
|
|
|
|
|
|
|
run_make_test(q!
|
|
|
|
things = thing1 thing2
|
|
|
|
all: $(things)
|
2019-10-12 20:22:01 +00:00
|
|
|
thing1:; @#HELPER# wait thing2start file $@start wait thing2end out $@end
|
|
|
|
thing2:; @#HELPER# file $@start wait thing1start file $@end
|
2011-09-18 23:39:26 +00:00
|
|
|
-include inc.mk
|
|
|
|
inc.mk: ; @touch $@
|
|
|
|
!,
|
2019-10-12 20:22:01 +00:00
|
|
|
'', "file thing2start\nwait thing2start\nfile thing1start\nwait thing1start\nfile thing2end\nwait thing2end\nthing1end\n");
|
2011-09-18 23:39:26 +00:00
|
|
|
|
2017-10-30 16:53:49 +00:00
|
|
|
rmfiles(qw(inc.mk thing1start thing1end thing2start thing2end));
|
2011-09-18 23:39:26 +00:00
|
|
|
|
2012-09-10 02:36:05 +00:00
|
|
|
# Ensure intermediate/secondary files are not pruned incorrectly.
|
|
|
|
# See Savannah bug #30653
|
|
|
|
|
|
|
|
utouch(-15, 'file2');
|
|
|
|
utouch(-10, 'file4');
|
|
|
|
utouch(-5, 'file1');
|
|
|
|
|
|
|
|
run_make_test(q!
|
|
|
|
.INTERMEDIATE: file3
|
|
|
|
file4: file3 ; @mv -f $< $@
|
|
|
|
file3: file2 ; touch $@
|
|
|
|
file2: file1 ; @touch $@
|
|
|
|
!,
|
|
|
|
'--no-print-directory -j2', "touch file3");
|
|
|
|
|
2012-10-29 07:05:21 +00:00
|
|
|
rmfiles('file1', 'file2', 'file3', 'file4');
|
2012-09-10 02:36:05 +00:00
|
|
|
|
2018-09-15 18:48:57 +00:00
|
|
|
# Ensure that the jobserver is preserved across make re-exec.
|
|
|
|
|
|
|
|
run_make_test(q!
|
|
|
|
all: one two
|
2019-10-12 20:22:01 +00:00
|
|
|
one: ;@ #HELPER# wait TWO file ONE
|
|
|
|
two: ;@ #HELPER# file TWO
|
2018-09-15 18:48:57 +00:00
|
|
|
include fff1.mk
|
|
|
|
fff1.mk: ; touch $@
|
|
|
|
!,
|
2019-10-12 20:22:01 +00:00
|
|
|
'-j2', "touch fff1.mk\nfile TWO\nwait TWO\nfile ONE\n");
|
2018-09-15 18:48:57 +00:00
|
|
|
|
|
|
|
unlink('fff1.mk', 'ONE', 'TWO');
|
|
|
|
|
|
|
|
# Test if a sub-make needs to re-exec and the makefile is built via
|
|
|
|
# sub-make. Reported by Masahiro Yamada <yamada.masahiro@socionext.com>
|
|
|
|
|
|
|
|
run_make_test(q!
|
|
|
|
all: ; @$(MAKE) -f #MAKEFILE# recurse
|
|
|
|
|
2019-10-12 20:22:01 +00:00
|
|
|
recurse: one two ; @#HELPER# out $@
|
|
|
|
one: ;@ #HELPER# wait TWO file ONE
|
|
|
|
two: ;@ #HELPER# file TWO
|
2018-09-15 18:48:57 +00:00
|
|
|
|
|
|
|
mkinclude: ; touch fff1.mk
|
|
|
|
|
|
|
|
ifeq ($(MAKECMDGOALS),recurse)
|
|
|
|
include fff1.mk
|
|
|
|
fff1.mk: ; @$(MAKE) -f #MAKEFILE# mkinclude
|
|
|
|
endif
|
|
|
|
!,
|
2019-10-12 20:22:01 +00:00
|
|
|
'--no-print-directory -j2', "touch fff1.mk\nfile TWO\nwait TWO\nfile ONE\nrecurse\n");
|
2018-09-15 18:48:57 +00:00
|
|
|
|
|
|
|
unlink('fff1.mk', 'ONE', 'TWO');
|
|
|
|
|
|
|
|
|
2006-03-20 02:36:36 +00:00
|
|
|
# Make sure that all jobserver FDs are closed if we need to re-exec the
|
|
|
|
# master copy.
|
2006-04-01 06:36:40 +00:00
|
|
|
#
|
|
|
|
# First, find the "default" file descriptors we normally use
|
|
|
|
# Then make sure they're still used.
|
|
|
|
#
|
|
|
|
# Right now we don't have a way to run a makefile and capture the output
|
|
|
|
# without checking it, so we can't really write this test.
|
2006-03-20 02:36:36 +00:00
|
|
|
|
2006-04-01 06:36:40 +00:00
|
|
|
# run_make_test('
|
|
|
|
# submake: ; @$(MAKE) --no-print-directory -f #MAKEFILE# fdprint 5>output
|
2006-03-20 02:36:36 +00:00
|
|
|
|
2006-04-01 06:36:40 +00:00
|
|
|
# dependfile: ; @echo FOO=bar > $@
|
2006-03-20 02:36:36 +00:00
|
|
|
|
2006-04-01 06:36:40 +00:00
|
|
|
# INCL := true
|
2006-03-20 02:36:36 +00:00
|
|
|
|
2006-04-01 06:36:40 +00:00
|
|
|
# FOO=foo
|
|
|
|
# ifeq ($(INCL),true)
|
|
|
|
# -include dependfile
|
|
|
|
# endif
|
2006-03-20 02:36:36 +00:00
|
|
|
|
2006-04-01 06:36:40 +00:00
|
|
|
# fdprint: ; @echo $(filter --jobserver%,$(MAKEFLAGS))
|
2006-03-20 02:36:36 +00:00
|
|
|
|
2006-04-01 06:36:40 +00:00
|
|
|
# recurse: ; @$(MAKE) --no-print-directory -f #MAKEFILE# submake INCL=true',
|
|
|
|
# '-j2 INCL=false fdprint',
|
|
|
|
# 'bar');
|
2006-03-20 02:36:36 +00:00
|
|
|
|
2009-10-04 19:18:16 +00:00
|
|
|
# rmfiles(qw(dependfile output));
|
2006-03-20 02:36:36 +00:00
|
|
|
|
|
|
|
|
2006-04-01 06:36:40 +00:00
|
|
|
# # Do it again, this time where the include is done by the non-master make.
|
|
|
|
# run_make_test(undef, '-j2 recurse INCL=false', 'bar');
|
2006-03-20 02:36:36 +00:00
|
|
|
|
2009-10-04 19:18:16 +00:00
|
|
|
# rmfiles(qw(dependfile output));
|
2006-03-20 02:36:36 +00:00
|
|
|
|
1999-09-14 02:03:19 +00:00
|
|
|
1;
|