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 | $delete_command = "delete_file -no_ask";
|
---|
22 | $sleep_command = "sleep -seconds";
|
---|
23 | }
|
---|
24 | else {
|
---|
25 | $delete_command = "rm -f";
|
---|
26 | $sleep_command = "sleep";
|
---|
27 | }
|
---|
28 |
|
---|
29 |
|
---|
30 | run_make_test("
|
---|
31 | all : def_1 def_2 def_3
|
---|
32 | def_1 : ; \@echo ONE; $sleep_command 3 ; echo TWO
|
---|
33 | def_2 : ; \@$sleep_command 2 ; echo THREE
|
---|
34 | def_3 : ; \@$sleep_command 1 ; echo FOUR",
|
---|
35 | '-j4', "ONE\nFOUR\nTHREE\nTWO");
|
---|
36 |
|
---|
37 | # Test parallelism with included files. Here we sleep/echo while
|
---|
38 | # building the included files, to test that they are being built in
|
---|
39 | # parallel.
|
---|
40 | run_make_test("
|
---|
41 | all: 1 2; \@echo success
|
---|
42 | -include 1.inc 2.inc
|
---|
43 | 1.inc: ; \@echo ONE.inc; $sleep_command 2; echo TWO.inc; echo '1: ; \@echo ONE; $sleep_command 2; echo TWO' > \$\@
|
---|
44 | 2.inc: ; \@$sleep_command 1; echo THREE.inc; echo '2: ; \@$sleep_command 1; echo THREE' > \$\@",
|
---|
45 | "-j4",
|
---|
46 | "ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n");
|
---|
47 |
|
---|
48 | unlink('1.inc', '2.inc');
|
---|
49 |
|
---|
50 |
|
---|
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");
|
---|
66 |
|
---|
67 | unlink('1.inc', '2.inc');
|
---|
68 |
|
---|
69 | # Grant Taylor reports a problem where tokens can be lost (not written back
|
---|
70 | # to the pipe when they should be): this happened when there is a $(shell ...)
|
---|
71 | # function in an exported recursive variable. I added some code to check
|
---|
72 | # for this situation and print a message if it occurred. This test used
|
---|
73 | # to trigger this code when I added it but no longer does after the fix.
|
---|
74 |
|
---|
75 | run_make_test("
|
---|
76 | export HI = \$(shell \$(\$\@.CMD))
|
---|
77 | first.CMD = echo hi
|
---|
78 | second.CMD = $sleep_command 4; echo hi
|
---|
79 |
|
---|
80 | .PHONY: all first second
|
---|
81 | all: first second
|
---|
82 |
|
---|
83 | first second: ; \@echo \$\@; $sleep_command 1; echo \$\@",
|
---|
84 | '-j2', "first\nfirst\nsecond\nsecond");
|
---|
85 |
|
---|
86 | 1;
|
---|