1 | # -*-perl-*-
|
---|
2 |
|
---|
3 | $description = "Test parallelism (-j) option.";
|
---|
4 |
|
---|
5 |
|
---|
6 | $details = "This test creates a makefile with two double-colon default
|
---|
7 | rules. The first rule has a series of sleep and echo commands
|
---|
8 | intended to run in series. The second and third have just an
|
---|
9 | echo statement. When make is called in this test, it is given
|
---|
10 | the -j option with a value of 4. This tells make that it may
|
---|
11 | start up to four jobs simultaneously. In this case, since the
|
---|
12 | first command is a sleep command, the output of the second
|
---|
13 | and third commands will appear before the first if indeed
|
---|
14 | make is running all of these commands in parallel.";
|
---|
15 |
|
---|
16 | if (!$parallel_jobs) {
|
---|
17 | return -1;
|
---|
18 | }
|
---|
19 |
|
---|
20 | if ($vos) {
|
---|
21 | $sleep_command = "sleep -seconds";
|
---|
22 | }
|
---|
23 | else {
|
---|
24 | $sleep_command = "sleep";
|
---|
25 | }
|
---|
26 |
|
---|
27 |
|
---|
28 | run_make_test("
|
---|
29 | all : def_1 def_2 def_3
|
---|
30 | def_1 : ; \@echo ONE; $sleep_command 3 ; echo TWO
|
---|
31 | def_2 : ; \@$sleep_command 2 ; echo THREE
|
---|
32 | def_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.
|
---|
38 | run_make_test("
|
---|
39 | all: 1 2; \@echo success
|
---|
40 | -include 1.inc 2.inc
|
---|
41 | 1.inc: ; \@echo ONE.inc; $sleep_command 2; echo TWO.inc; echo '1: ; \@echo ONE; $sleep_command 2; echo TWO' > \$\@
|
---|
42 | 2.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 |
|
---|
46 | rmfiles(qw(1.inc 2.inc));
|
---|
47 |
|
---|
48 |
|
---|
49 | # Test parallelism with included files--this time recurse first and make
|
---|
50 | # sure the jobserver works.
|
---|
51 | run_make_test("
|
---|
52 | recurse: ; \@\$(MAKE) --no-print-directory -f #MAKEFILE# INC=yes all
|
---|
53 | all: 1 2; \@echo success
|
---|
54 |
|
---|
55 | INC = no
|
---|
56 | ifeq (\$(INC),yes)
|
---|
57 | -include 1.inc 2.inc
|
---|
58 | endif
|
---|
59 |
|
---|
60 | 1.inc: ; \@echo ONE.inc; $sleep_command 2; echo TWO.inc; echo '1: ; \@echo ONE; $sleep_command 2; echo TWO' > \$\@
|
---|
61 | 2.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 |
|
---|
65 | rmfiles(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 |
|
---|
74 | run_make_test("
|
---|
75 | export HI = \$(shell \$(\$\@.CMD))
|
---|
76 | first.CMD = echo hi
|
---|
77 | second.CMD = $sleep_command 4; echo hi
|
---|
78 |
|
---|
79 | .PHONY: all first second
|
---|
80 | all: first second
|
---|
81 |
|
---|
82 | first 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 |
|
---|
89 | run_make_test("
|
---|
90 | .PHONY: all fail.1 fail.2 fail.3 ok
|
---|
91 | all: fail.1 ok fail.2 fail.3
|
---|
92 |
|
---|
93 | fail.1 fail.2 fail.3:
|
---|
94 | \@$sleep_command \$(patsubst fail.%,%,\$\@)
|
---|
95 | \@echo Fail
|
---|
96 | \@exit 1
|
---|
97 |
|
---|
98 | ok:
|
---|
99 | \@$sleep_command 4
|
---|
100 | \@echo Ok done",
|
---|
101 | '-rR -j5', (!$is_kmk) ? "Fail
|
---|
102 | #MAKE#: *** [#MAKEFILE#:8: fail.1] Error 1
|
---|
103 | #MAKE#: *** Waiting for unfinished jobs....
|
---|
104 | Fail
|
---|
105 | #MAKE#: *** [#MAKEFILE#:8: fail.2] Error 1
|
---|
106 | Fail
|
---|
107 | #MAKE#: *** [#MAKEFILE#:8: fail.3] Error 1
|
---|
108 | Ok done" : 'Fail
|
---|
109 | #MAKE#: *** [fail.1] Error 1
|
---|
110 | The failing command:
|
---|
111 | @exit 1
|
---|
112 | #MAKE#: *** Waiting for unfinished jobs....
|
---|
113 | Fail
|
---|
114 | #MAKE#: *** [fail.2] Error 1
|
---|
115 | The failing command:
|
---|
116 | @exit 1
|
---|
117 | Fail
|
---|
118 | #MAKE#: *** [fail.3] Error 1
|
---|
119 | The failing command:
|
---|
120 | @exit 1
|
---|
121 | Ok done
|
---|
122 | #MAKE#: *** Exiting with status 2',
|
---|
123 | 512);
|
---|
124 |
|
---|
125 |
|
---|
126 | # Test for Savannah bug #15641.
|
---|
127 | #
|
---|
128 | run_make_test('
|
---|
129 | .PHONY: all
|
---|
130 | all:; @:
|
---|
131 |
|
---|
132 | -include foo.d
|
---|
133 |
|
---|
134 | foo.d: comp
|
---|
135 | @echo building $@
|
---|
136 |
|
---|
137 | comp: mod_a.o mod_b.o; @:
|
---|
138 |
|
---|
139 | mod_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 |
|
---|
147 | utouch(-10, 'target');
|
---|
148 | run_make_test('target: intermed ; touch $@
|
---|
149 |
|
---|
150 | .INTERMEDIATE: intermed
|
---|
151 | intermed: | phony ; touch $@
|
---|
152 |
|
---|
153 | .PHONY: phony
|
---|
154 | phony: ; : phony', '-rR -j', ': phony');
|
---|
155 | rmfiles('target');
|
---|
156 |
|
---|
157 | # TEST #11: Make sure -jN from MAKEFLAGS is processed even when we re-exec
|
---|
158 | # See Savannah bug #33873
|
---|
159 |
|
---|
160 | $extraENV{MAKEFLAGS} = '-j4';
|
---|
161 |
|
---|
162 | run_make_test(q!
|
---|
163 | things = thing1 thing2
|
---|
164 | all: $(things)
|
---|
165 | thing1:; @sleep 1; echo '$@ start'; sleep 2; echo '$@ end'
|
---|
166 | thing2:; @echo '$@ start'; sleep 2; echo '$@ end'
|
---|
167 | -include inc.mk
|
---|
168 | inc.mk: ; @touch $@
|
---|
169 | !,
|
---|
170 | '', "thing2 start\nthing1 start\nthing2 end\nthing1 end\n");
|
---|
171 |
|
---|
172 | delete $extraENV{MAKEFLAGS};
|
---|
173 | rmfiles('inc.mk');
|
---|
174 |
|
---|
175 | # Ensure intermediate/secondary files are not pruned incorrectly.
|
---|
176 | # See Savannah bug #30653
|
---|
177 |
|
---|
178 | utouch(-15, 'file2');
|
---|
179 | utouch(-10, 'file4');
|
---|
180 | utouch(-5, 'file1');
|
---|
181 |
|
---|
182 | run_make_test(q!
|
---|
183 | .INTERMEDIATE: file3
|
---|
184 | file4: file3 ; @mv -f $< $@
|
---|
185 | file3: file2 ; touch $@
|
---|
186 | file2: file1 ; @touch $@
|
---|
187 | !,
|
---|
188 | '--no-print-directory -j2', "touch file3");
|
---|
189 |
|
---|
190 | rmfiles('file1', 'file2', 'file3', 'file4');
|
---|
191 |
|
---|
192 | # Make sure that all jobserver FDs are closed if we need to re-exec the
|
---|
193 | # master copy.
|
---|
194 | #
|
---|
195 | # First, find the "default" file descriptors we normally use
|
---|
196 | # Then make sure they're still used.
|
---|
197 | #
|
---|
198 | # Right now we don't have a way to run a makefile and capture the output
|
---|
199 | # without checking it, so we can't really write this test.
|
---|
200 |
|
---|
201 | # run_make_test('
|
---|
202 | # submake: ; @$(MAKE) --no-print-directory -f #MAKEFILE# fdprint 5>output
|
---|
203 |
|
---|
204 | # dependfile: ; @echo FOO=bar > $@
|
---|
205 |
|
---|
206 | # INCL := true
|
---|
207 |
|
---|
208 | # FOO=foo
|
---|
209 | # ifeq ($(INCL),true)
|
---|
210 | # -include dependfile
|
---|
211 | # endif
|
---|
212 |
|
---|
213 | # fdprint: ; @echo $(filter --jobserver%,$(MAKEFLAGS))
|
---|
214 |
|
---|
215 | # recurse: ; @$(MAKE) --no-print-directory -f #MAKEFILE# submake INCL=true',
|
---|
216 | # '-j2 INCL=false fdprint',
|
---|
217 | # 'bar');
|
---|
218 |
|
---|
219 | # rmfiles(qw(dependfile output));
|
---|
220 |
|
---|
221 |
|
---|
222 | # # Do it again, this time where the include is done by the non-master make.
|
---|
223 | # run_make_test(undef, '-j2 recurse INCL=false', 'bar');
|
---|
224 |
|
---|
225 | # rmfiles(qw(dependfile output));
|
---|
226 |
|
---|
227 | 1;
|
---|
228 |
|
---|
229 | ### Local Variables:
|
---|
230 | ### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
|
---|
231 | ### End:
|
---|