VirtualBox

source: kBuild/trunk/src/kmk/tests/scripts/features/parallelism@ 2591

Last change on this file since 2591 was 2591, checked in by bird, 13 years ago

kmk: Merged in changes from GNU make 3.82. Previous GNU make base version was gnumake-2008-10-28-CVS.

  • Property svn:eol-style set to LF
File size: 7.0 KB
Line 
1# -*-perl-*-
2
3$description = "Test parallelism (-j) option.";
4
5
6$details = "This test creates a makefile with two double-colon default
7rules. The first rule has a series of sleep and echo commands
8intended to run in series. The second and third have just an
9echo statement. When make is called in this test, it is given
10the -j option with a value of 4. This tells make that it may
11start up to four jobs simultaneously. In this case, since the
12first command is a sleep command, the output of the second
13and third commands will appear before the first if indeed
14make is running all of these commands in parallel.";
15
16if (!$parallel_jobs) {
17 return -1;
18}
19
20if ($vos) {
21 $sleep_command = "sleep -seconds";
22}
23else {
24 $sleep_command = "sleep";
25}
26
27
28run_make_test("
29all : def_1 def_2 def_3
30def_1 : ; \@echo ONE; $sleep_command 3 ; echo TWO
31def_2 : ; \@$sleep_command 2 ; echo THREE
32def_3 : ; \@$sleep_command 1 ; echo FOUR",
33 '-j4', "ONE\nFOUR\nTHREE\nTWO");
34
35# Test parallelism with included files. Here we sleep/echo while
36# building the included files, to test that they are being built in
37# parallel.
38run_make_test("
39all: 1 2; \@echo success
40-include 1.inc 2.inc
411.inc: ; \@echo ONE.inc; $sleep_command 2; echo TWO.inc; echo '1: ; \@echo ONE; $sleep_command 2; echo TWO' > \$\@
422.inc: ; \@$sleep_command 1; echo THREE.inc; echo '2: ; \@$sleep_command 1; echo THREE' > \$\@",
43 "-j4",
44 "ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n");
45
46rmfiles(qw(1.inc 2.inc));
47
48
49# Test parallelism with included files--this time recurse first and make
50# sure the jobserver works.
51run_make_test("
52recurse: ; \@\$(MAKE) --no-print-directory -f #MAKEFILE# INC=yes all
53all: 1 2; \@echo success
54
55INC = no
56ifeq (\$(INC),yes)
57-include 1.inc 2.inc
58endif
59
601.inc: ; \@echo ONE.inc; $sleep_command 2; echo TWO.inc; echo '1: ; \@echo ONE; $sleep_command 2; echo TWO' > \$\@
612.inc: ; \@$sleep_command 1; echo THREE.inc; echo '2: ; \@$sleep_command 1; echo THREE' > \$\@",
62 "-j4",
63 "ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n");
64
65rmfiles(qw(1.inc 2.inc));
66
67# Grant Taylor reports a problem where tokens can be lost (not written back
68# to the pipe when they should be): this happened when there is a $(shell ...)
69# function in an exported recursive variable. I added some code to check
70# for this situation and print a message if it occurred. This test used
71# to trigger this code when I added it but no longer does after the fix.
72# We have to increase the timeout from the default (5s) on this test.
73
74run_make_test("
75export HI = \$(shell \$(\$\@.CMD))
76first.CMD = echo hi
77second.CMD = $sleep_command 4; echo hi
78
79.PHONY: all first second
80all: first second
81
82first second: ; \@echo \$\@; $sleep_command 1; echo \$\@",
83 '-j2', "first\nfirst\nsecond\nsecond", 0, 7);
84
85# Michael Matz <[email protected]> reported a bug where if make is running in
86# parallel without -k and two jobs die in a row, but not too close to each
87# other, then make will quit without waiting for the rest of the jobs to die.
88
89run_make_test("
90.PHONY: all fail.1 fail.2 fail.3 ok
91all: fail.1 ok fail.2 fail.3
92
93fail.1 fail.2 fail.3:
94 \@sleep \$(patsubst fail.%,%,\$\@)
95 \@echo Fail
96 \@exit 1
97
98ok:
99 \@sleep 4
100 \@echo Ok done",
101 '-rR -j5', (!$is_kmk) ? 'Fail
102#MAKE#: *** [fail.1] Error 1
103#MAKE#: *** Waiting for unfinished jobs....
104Fail
105#MAKE#: *** [fail.2] Error 1
106Fail
107#MAKE#: *** [fail.3] Error 1
108Ok done' : 'Fail
109#MAKE#: *** [fail.1] Error 1
110The failing command:
111@exit 1
112#MAKE#: *** Waiting for unfinished jobs....
113Fail
114#MAKE#: *** [fail.2] Error 1
115The failing command:
116@exit 1
117Fail
118#MAKE#: *** [fail.3] Error 1
119The failing command:
120@exit 1
121Ok done
122#MAKE#: *** Exiting with status 2',
123 512);
124
125
126# Test for Savannah bug #15641.
127#
128run_make_test('
129.PHONY: all
130all:; @:
131
132-include foo.d
133
134foo.d: comp
135 @echo building $@
136
137comp: mod_a.o mod_b.o; @:
138
139mod_a.o mod_b.o:
140 @exit 1
141', '-j2', '');
142
143
144# TEST #9 -- Savannah bugs 3330 and 15919
145# In earlier versions of make this will either give the wrong answer, or hang.
146
147utouch(-10, 'target');
148run_make_test('target: intermed ; touch $@
149
150.INTERMEDIATE: intermed
151intermed: | phony ; touch $@
152
153.PHONY: phony
154phony: ; : phony', '-rR -j', ': phony');
155rmfiles('target');
156
157# TEST #10: Don't put --jobserver-fds into a re-exec'd MAKEFLAGS.
158# We can't test this directly because there's no way a makefile can
159# show the value of MAKEFLAGS we were re-exec'd with. We can intuit it
160# by looking for "disabling jobserver mode" warnings; we should only
161# get one from the original invocation and none from the re-exec.
162# See Savannah bug #18124
163
164run_make_test(q!
165-include inc.mk
166recur:
167# @echo 'MAKEFLAGS = $(MAKEFLAGS)'
168 @rm -f inc.mk
169 @$(MAKE) -j2 -f #MAKEFILE# all
170all:
171# @echo 'MAKEFLAGS = $(MAKEFLAGS)'
172 @echo $@
173inc.mk:
174# @echo 'MAKEFLAGS = $(MAKEFLAGS)'
175 @echo 'FOO = bar' > $@
176!,
177 '--no-print-directory -j2', "#MAKE#[1]: warning: -jN forced in submake: disabling jobserver mode.\nall\n");
178
179rmfiles('inc.mk');
180
181if ($all_tests) {
182 # Implicit files aren't properly recreated during parallel builds
183 # Savannah bug #26864
184
185 # The first run works fine
186 run_make_test(q!
187%.bar: %.x foo.y ; cat $^ > $@
188%.x: ; touch $@
189foo.y: foo.y.in ; cp $< $@
190foo.y.in: ; touch $@
191!,
192 '-j2 main.bar',
193 "touch foo.y.in
194touch main.x
195cp foo.y.in foo.y
196cat main.x foo.y > main.bar
197rm main.x");
198
199 # Now we touch the .in file and make sure it still works
200 touch('foo.y.in');
201
202 run_make_test(undef, '-j2 main.bar', "cp foo.y.in foo.y
203touch main.x
204cat main.x foo.y > main.bar
205rm main.x");
206
207 # Clean up
208 rmfiles(qw(foo.y foo.y.in main.bar));
209}
210
211if ($all_tests) {
212 # Jobserver FD handling is messed up in some way.
213 # Savannah bug #28189
214 # It doesn't look like that bug anymore but this is the code it runs
215
216 run_make_test(q!
217ifdef EXTRA
218vpath %.dst /
219xxx.dst: ; true
220yyy.dst: ; true
221endif
222
223M := $(MAKE)
224xx: ; $M --no-print-directory -j2 -f $(MAKEFILE_LIST) xxx.dst yyy.dst EXTRA=1
225!,
226 '-j2',
227 '#MAKE#[1]: warning: -jN forced in submake: disabling jobserver mode.
228true
229true
230');
231}
232
233# Make sure that all jobserver FDs are closed if we need to re-exec the
234# master copy.
235#
236# First, find the "default" file descriptors we normally use
237# Then make sure they're still used.
238#
239# Right now we don't have a way to run a makefile and capture the output
240# without checking it, so we can't really write this test.
241
242# run_make_test('
243# submake: ; @$(MAKE) --no-print-directory -f #MAKEFILE# fdprint 5>output
244
245# dependfile: ; @echo FOO=bar > $@
246
247# INCL := true
248
249# FOO=foo
250# ifeq ($(INCL),true)
251# -include dependfile
252# endif
253
254# fdprint: ; @echo $(filter --jobserver%,$(MAKEFLAGS))
255
256# recurse: ; @$(MAKE) --no-print-directory -f #MAKEFILE# submake INCL=true',
257# '-j2 INCL=false fdprint',
258# 'bar');
259
260# rmfiles(qw(dependfile output));
261
262
263# # Do it again, this time where the include is done by the non-master make.
264# run_make_test(undef, '-j2 recurse INCL=false', 'bar');
265
266# rmfiles(qw(dependfile output));
267
2681;
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette