Debian Codegraph @

tests/scripts/features/parallelism

raw
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 # Test #0
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 #1
36 # Test parallelism with included files. Here we sleep/echo while
37 # building the included files, to test that they are being built in
38 # parallel.
39 run_make_test("
40 all: 1 2; \@echo success
41 -include 1.inc 2.inc
42 1.inc: ; \@echo ONE.inc; $sleep_command 2; echo TWO.inc; echo '1: ; \@echo ONE; $sleep_command 2; echo TWO' > \$\@
43 2.inc: ; \@$sleep_command 1; echo THREE.inc; echo '2: ; \@$sleep_command 1; echo THREE' > \$\@",
44 "-j4",
45 "ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n", 0, 7);
46
47 rmfiles(qw(1.inc 2.inc));
48
49
50 # Test #2
51 # Test parallelism with included files--this time recurse first and make
52 # sure the jobserver works.
53 run_make_test("
54 recurse: ; \@\$(MAKE) --no-print-directory -f #MAKEFILE# INC=yes all
55 all: 1 2; \@echo success
56
57 INC = no
58 ifeq (\$(INC),yes)
59 -include 1.inc 2.inc
60 endif
61
62 1.inc: ; \@echo ONE.inc; $sleep_command 2; echo TWO.inc; echo '1: ; \@echo ONE; $sleep_command 2; echo TWO' > \$\@
63 2.inc: ; \@$sleep_command 1; echo THREE.inc; echo '2: ; \@$sleep_command 1; echo THREE' > \$\@",
64 "-j4",
65 "ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n", 0, 7);
66
67 rmfiles(qw(1.inc 2.inc));
68
69 # Test #3
70 # Grant Taylor reports a problem where tokens can be lost (not written back
71 # to the pipe when they should be): this happened when there is a $(shell ...)
72 # function in an exported recursive variable. I added some code to check
73 # for this situation and print a message if it occurred. This test used
74 # to trigger this code when I added it but no longer does after the fix.
75 # We have to increase the timeout from the default (5s) on this test.
76
77 run_make_test("
78 export HI = \$(shell \$(\$\@.CMD))
79 first.CMD = echo hi
80 second.CMD = $sleep_command 4; echo hi
81
82 .PHONY: all first second
83 all: first second
84
85 first second: ; \@echo \$\@; $sleep_command 1; echo \$\@",
86 '-j2', "first\nfirst\nsecond\nsecond", 0, 7);
87
88 # # Test #4
89 # # Michael Matz <[email protected]> reported a bug where if make is running in
90 # # parallel without -k and two jobs die in a row, but not too close to each
91 # # other, then make will quit without waiting for the rest of the jobs to die.
92
93 # run_make_test("
94 # .PHONY: all fail.1 fail.2 fail.3 ok
95 # all: fail.1 ok fail.2 fail.3
96
97 # fail.1 fail.2 fail.3:
98 # \@$sleep_command \$(patsubst fail.%,%,\$\@)
99 # \@echo Fail
100 # \@exit 1
101
102 # ok:
103 # > \@#HELPER# sleep 4
104 # > \@#HELPER# out OK",
105 # '-rR -j5', "sleep 1\nFail\nfail 1
106 # make: directory '$fulltestdir'
107 # #MAKE#: *** [fail.1] error 1
108 # #MAKE#: *** Waiting for unfinished jobs....
109 # sleep 2\nFail\nfail 1
110 # make: directory '$fulltestdir'
111 # #MAKE#: *** [fail.2] error 1
112 # sleep 3\nFail\nfail 1
113 # make: directory '$fulltestdir'
114 # #MAKE#: *** [fail.3] error 1
115 # sleep 4\nOK",
116 # 512);
117
118
119 # # Test for Savannah bug #15641.
120 # #
121 # run_make_test('
122 # .PHONY: all
123 # all:; @:
124
125 # -include foo.d
126
127 # foo.d: comp
128 # @echo building $@
129
130 # comp: mod_a.o mod_b.o; @:
131
132 # mod_a.o mod_b.o: ; @#HELPER# fail 1
133 # ', '-j2', "fail 1\nfail 1\n");
134
135
136 # TEST #5 -- Savannah bugs 3330 and 15919
137 # In earlier versions of make this will either give the wrong answer, or hang.
138
139 utouch(-10, 'target');
140 run_make_test('target: intermed ; touch $@
141
142 .INTERMEDIATE: intermed
143 intermed: | phony ; touch $@
144
145 .PHONY: phony
146 phony: ; : phony', '-rR -j', ': phony');
147 rmfiles('target');
148
149 # # TEST #11: Make sure -jN from MAKEFLAGS is processed even when we re-exec
150 # # See Savannah bug #33873
151
152 # $extraENV{MAKEFLAGS} = '-j4';
153
154 # run_make_test(q!
155 # things = thing1 thing2
156 # all: $(things)
157 # thing1:; @#HELPER# wait thing2start file $@start wait thing2end out $@end
158 # thing2:; @#HELPER# file $@start wait thing1start file $@end
159 # -include inc.mk
160 # inc.mk: ; @touch $@
161 # !,
162 # '', "thing2 start\nthing1 start\nthing2 end\nthing1 end\n");
163
164 # delete $extraENV{MAKEFLAGS};
165 # rmfiles('inc.mk');
166
167 # # Ensure intermediate/secondary files are not pruned incorrectly.
168 # # See Savannah bug #30653
169
170 # utouch(-15, 'file2');
171 # utouch(-10, 'file4');
172 # utouch(-5, 'file1');
173
174 # run_make_test(q!
175 # .INTERMEDIATE: file3
176 # file4: file3 ; @mv -f $< $@
177 # file3: file2 ; touch $@
178 # file2: file1 ; @touch $@
179 # !,
180 # '--no-print-directory -j2', "touch file3");
181
182 # rmfiles('file1', 'file2', 'file3', 'file4');
183
184 # Make sure that all jobserver FDs are closed if we need to re-exec the
185 # master copy.
186 #
187 # First, find the "default" file descriptors we normally use
188 # Then make sure they're still used.
189 #
190 # Right now we don't have a way to run a makefile and capture the output
191 # without checking it, so we can't really write this test.
192
193 # run_make_test('
194 # submake: ; @$(MAKE) --no-print-directory -f #MAKEFILE# fdprint 5>output
195
196 # dependfile: ; @echo FOO=bar > $@
197
198 # INCL := true
199
200 # FOO=foo
201 # ifeq ($(INCL),true)
202 # -include dependfile
203 # endif
204
205 # fdprint: ; @echo $(filter --jobserver%,$(MAKEFLAGS))
206
207 # recurse: ; @$(MAKE) --no-print-directory -f #MAKEFILE# submake INCL=true',
208 # '-j2 INCL=false fdprint',
209 # 'bar');
210
211 # rmfiles(qw(dependfile output));
212
213
214 # # Do it again, this time where the include is done by the non-master make.
215 # run_make_test(undef, '-j2 recurse INCL=false', 'bar');
216
217 # rmfiles(qw(dependfile output));
218
219 1;
220
221 ### Local Variables:
222 ### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
223 ### End: