VirtualBox

source: kBuild/vendor/gnumake/current/tests/scripts/features/parallelism@ 3208

最後變更 在這個檔案從3208是 3138,由 bird 提交於 7 年 前

Imported make 4.2.1 (2e55f5e4abdc0e38c1d64be703b446695e70b3b6) from https://git.savannah.gnu.org/git/make.git.

  • 屬性 svn:eol-style 設為 LF
檔案大小: 5.9 KB
 
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", 0, 7);
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", 0, 7);
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_command \$(patsubst fail.%,%,\$\@)
95 \@echo Fail
96 \@exit 1
97
98ok:
99 \@$sleep_command 4
100 \@echo Ok done",
101 '-rR -j5', "Fail
102#MAKE#: *** [#MAKEFILE#:8: fail.1] Error 1
103#MAKE#: *** Waiting for unfinished jobs....
104Fail
105#MAKE#: *** [#MAKEFILE#:8: fail.2] Error 1
106Fail
107#MAKE#: *** [#MAKEFILE#:8: fail.3] Error 1
108Ok done",
109 512);
110
111
112# Test for Savannah bug #15641.
113#
114run_make_test('
115.PHONY: all
116all:; @:
117
118-include foo.d
119
120foo.d: comp
121 @echo building $@
122
123comp: mod_a.o mod_b.o; @:
124
125mod_a.o mod_b.o:
126 @exit 1
127', '-j2', '');
128
129
130# TEST #9 -- Savannah bugs 3330 and 15919
131# In earlier versions of make this will either give the wrong answer, or hang.
132
133utouch(-10, 'target');
134run_make_test('target: intermed ; touch $@
135
136.INTERMEDIATE: intermed
137intermed: | phony ; touch $@
138
139.PHONY: phony
140phony: ; : phony', '-rR -j', ': phony');
141rmfiles('target');
142
143# TEST #11: Make sure -jN from MAKEFLAGS is processed even when we re-exec
144# See Savannah bug #33873
145
146$extraENV{MAKEFLAGS} = '-j4';
147
148run_make_test(q!
149things = thing1 thing2
150all: $(things)
151thing1:; @sleep 1; echo '$@ start'; sleep 2; echo '$@ end'
152thing2:; @echo '$@ start'; sleep 2; echo '$@ end'
153-include inc.mk
154inc.mk: ; @touch $@
155!,
156 '', "thing2 start\nthing1 start\nthing2 end\nthing1 end\n");
157
158delete $extraENV{MAKEFLAGS};
159rmfiles('inc.mk');
160
161# Ensure intermediate/secondary files are not pruned incorrectly.
162# See Savannah bug #30653
163
164utouch(-15, 'file2');
165utouch(-10, 'file4');
166utouch(-5, 'file1');
167
168run_make_test(q!
169.INTERMEDIATE: file3
170file4: file3 ; @mv -f $< $@
171file3: file2 ; touch $@
172file2: file1 ; @touch $@
173!,
174 '--no-print-directory -j2', "touch file3");
175
176rmfiles('file1', 'file2', 'file3', 'file4');
177
178# Make sure that all jobserver FDs are closed if we need to re-exec the
179# master copy.
180#
181# First, find the "default" file descriptors we normally use
182# Then make sure they're still used.
183#
184# Right now we don't have a way to run a makefile and capture the output
185# without checking it, so we can't really write this test.
186
187# run_make_test('
188# submake: ; @$(MAKE) --no-print-directory -f #MAKEFILE# fdprint 5>output
189
190# dependfile: ; @echo FOO=bar > $@
191
192# INCL := true
193
194# FOO=foo
195# ifeq ($(INCL),true)
196# -include dependfile
197# endif
198
199# fdprint: ; @echo $(filter --jobserver%,$(MAKEFLAGS))
200
201# recurse: ; @$(MAKE) --no-print-directory -f #MAKEFILE# submake INCL=true',
202# '-j2 INCL=false fdprint',
203# 'bar');
204
205# rmfiles(qw(dependfile output));
206
207
208# # Do it again, this time where the include is done by the non-master make.
209# run_make_test(undef, '-j2 recurse INCL=false', 'bar');
210
211# rmfiles(qw(dependfile output));
212
2131;
214
215### Local Variables:
216### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
217### End:
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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