26 |
$sleep_command = "sleep"; |
$sleep_command = "sleep"; |
27 |
} |
} |
28 |
|
|
|
open(MAKEFILE,"> $makefile"); |
|
29 |
|
|
30 |
print MAKEFILE <<"EOF"; |
run_make_test(" |
31 |
all : def_1 def_2 def_3 |
all : def_1 def_2 def_3 |
32 |
def_1 : ; \@echo ONE; $sleep_command 3 ; echo TWO |
def_1 : ; \@echo ONE; $sleep_command 3 ; echo TWO |
33 |
def_2 : ; \@$sleep_command 2 ; echo THREE |
def_2 : ; \@$sleep_command 2 ; echo THREE |
34 |
def_3 : ; \@$sleep_command 1 ; echo FOUR |
def_3 : ; \@$sleep_command 1 ; echo FOUR", |
35 |
EOF |
'-j4', "ONE\nFOUR\nTHREE\nTWO"); |
|
|
|
|
close(MAKEFILE); |
|
|
|
|
|
&run_make_with_options($makefile, "-j 4", &get_logfile); |
|
|
$answer = "ONE\nFOUR\nTHREE\nTWO\n"; |
|
|
&compare_output($answer, &get_logfile(1)); |
|
|
|
|
36 |
|
|
37 |
# Test parallelism with included files. Here we sleep/echo while |
# Test parallelism with included files. Here we sleep/echo while |
38 |
# building the included files, to test that they are being built in |
# building the included files, to test that they are being built in |
39 |
# parallel. |
# parallel. |
40 |
|
run_make_test(" |
|
$makefile2 = &get_tmpfile; |
|
|
|
|
|
open(MAKEFILE,"> $makefile2"); |
|
|
|
|
|
print MAKEFILE <<"EOF"; |
|
41 |
all: 1 2; \@echo success |
all: 1 2; \@echo success |
|
|
|
42 |
-include 1.inc 2.inc |
-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 |
1.inc: ; \@echo ONE.inc; $sleep_command 2; echo TWO.inc; echo "1: ; \@echo ONE; $sleep_command 2; echo TWO" > \$\@ |
2.inc: ; \@$sleep_command 1; echo THREE.inc; echo '2: ; \@$sleep_command 1; echo THREE' > \$\@", |
45 |
2.inc: ; \@$sleep_command 1; echo THREE.inc; echo "2: ; \@$sleep_command 1; echo THREE" > \$\@ |
"-j4", |
46 |
EOF |
"ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n"); |
|
|
|
|
close(MAKEFILE); |
|
|
|
|
|
&run_make_with_options("$makefile2", "-j 4", &get_logfile); |
|
|
$answer = "ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n"; |
|
|
&compare_output($answer, &get_logfile(1)); |
|
47 |
|
|
48 |
unlink('1.inc', '2.inc'); |
unlink('1.inc', '2.inc'); |
49 |
|
|
50 |
|
|
51 |
# Test parallelism with included files--this time recurse first and make |
# Test parallelism with included files--this time recurse first and make |
52 |
# sure the jobserver works. |
# sure the jobserver works. |
53 |
|
run_make_test(" |
54 |
$makefile3 = &get_tmpfile; |
recurse: ; \@\$(MAKE) --no-print-directory -f #MAKEFILE# INC=yes all |
|
|
|
|
open(MAKEFILE,"> $makefile3"); |
|
|
|
|
|
print MAKEFILE <<"EOF"; |
|
|
recurse: ; \@\$(MAKE) --no-print-directory -f $makefile3 INC=yes all |
|
|
|
|
55 |
all: 1 2; \@echo success |
all: 1 2; \@echo success |
56 |
|
|
57 |
INC = no |
INC = no |
59 |
-include 1.inc 2.inc |
-include 1.inc 2.inc |
60 |
endif |
endif |
61 |
|
|
62 |
1.inc: ; \@echo ONE.inc; $sleep_command 2; echo TWO.inc; echo "1: ; \@echo ONE; $sleep_command 2; echo TWO" > \$\@ |
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" > \$\@ |
2.inc: ; \@$sleep_command 1; echo THREE.inc; echo '2: ; \@$sleep_command 1; echo THREE' > \$\@", |
64 |
EOF |
"-j4", |
65 |
|
"ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n"); |
|
close(MAKEFILE); |
|
|
|
|
|
&run_make_with_options("$makefile3", "-j 4", &get_logfile); |
|
|
$answer = "ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n"; |
|
|
&compare_output($answer, &get_logfile(1)); |
|
66 |
|
|
67 |
unlink('1.inc', '2.inc'); |
unlink('1.inc', '2.inc'); |
68 |
|
|
69 |
# Test shell functions within commands: make sure they're not reducing our |
# Grant Taylor reports a problem where tokens can be lost (not written back |
70 |
# parallelism. |
# 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 |
run_make_test('.PHONY: all |
first second: ; \@echo \$\@; $sleep_command 1; echo \$\@", |
84 |
all: ; @echo $(shell echo hi) |
'-j2', "first\nfirst\nsecond\nsecond"); |
|
','','hi'); |
|
85 |
|
|
86 |
1; |
1; |