| 1 |
# -*-perl-*- |
| 2 |
$description = "Test handling of double-colon rules."; |
| 3 |
|
| 4 |
$details = "\ |
| 5 |
We test these features: |
| 6 |
|
| 7 |
- Multiple commands for the same (double-colon) target |
| 8 |
- Different prerequisites for targets: only out-of-date |
| 9 |
ones are rebuilt. |
| 10 |
- Double-colon targets that aren't the goal target. |
| 11 |
|
| 12 |
Then we do the same thing for parallel builds: double-colon |
| 13 |
targets should always be built serially."; |
| 14 |
|
| 15 |
# The Contents of the MAKEFILE ... |
| 16 |
|
| 17 |
open(MAKEFILE,"> $makefile"); |
| 18 |
|
| 19 |
print MAKEFILE <<'EOF'; |
| 20 |
|
| 21 |
all: baz |
| 22 |
|
| 23 |
foo:: f1.h ; @echo foo FIRST |
| 24 |
foo:: f2.h ; @echo foo SECOND |
| 25 |
|
| 26 |
bar:: ; @echo aaa; sleep 1; echo aaa done |
| 27 |
bar:: ; @echo bbb |
| 28 |
|
| 29 |
baz:: ; @echo aaa |
| 30 |
baz:: ; @echo bbb |
| 31 |
|
| 32 |
biz:: ; @echo aaa |
| 33 |
biz:: two ; @echo bbb |
| 34 |
|
| 35 |
two: ; @echo two |
| 36 |
|
| 37 |
f1.h f2.h: ; @echo $@ |
| 38 |
|
| 39 |
d :: ; @echo ok |
| 40 |
d :: d ; @echo oops |
| 41 |
|
| 42 |
EOF |
| 43 |
|
| 44 |
close(MAKEFILE); |
| 45 |
|
| 46 |
# TEST 0: A simple double-colon rule that isn't the goal target. |
| 47 |
|
| 48 |
&run_make_with_options($makefile, "all", &get_logfile, 0); |
| 49 |
$answer = "aaa\nbbb\n"; |
| 50 |
&compare_output($answer, &get_logfile(1)); |
| 51 |
|
| 52 |
# TEST 1: As above, in parallel |
| 53 |
|
| 54 |
if ($parallel_jobs) { |
| 55 |
&run_make_with_options($makefile, "-j10 all", &get_logfile, 0); |
| 56 |
$answer = "aaa\nbbb\n"; |
| 57 |
&compare_output($answer, &get_logfile(1)); |
| 58 |
} |
| 59 |
|
| 60 |
# TEST 2: A simple double-colon rule that is the goal target |
| 61 |
|
| 62 |
&run_make_with_options($makefile, "bar", &get_logfile, 0); |
| 63 |
$answer = "aaa\naaa done\nbbb\n"; |
| 64 |
&compare_output($answer, &get_logfile(1)); |
| 65 |
|
| 66 |
# TEST 3: As above, in parallel |
| 67 |
|
| 68 |
if ($parallel_jobs) { |
| 69 |
&run_make_with_options($makefile, "-j10 bar", &get_logfile, 0); |
| 70 |
$answer = "aaa\naaa done\nbbb\n"; |
| 71 |
&compare_output($answer, &get_logfile(1)); |
| 72 |
} |
| 73 |
|
| 74 |
# TEST 4: Each double-colon rule is supposed to be run individually |
| 75 |
|
| 76 |
&utouch(-5, 'f2.h'); |
| 77 |
&touch('foo'); |
| 78 |
|
| 79 |
&run_make_with_options($makefile, "foo", &get_logfile, 0); |
| 80 |
$answer = "f1.h\nfoo FIRST\n"; |
| 81 |
&compare_output($answer, &get_logfile(1)); |
| 82 |
|
| 83 |
# TEST 5: Again, in parallel. |
| 84 |
|
| 85 |
if ($parallel_jobs) { |
| 86 |
&run_make_with_options($makefile, "-j10 foo", &get_logfile, 0); |
| 87 |
$answer = "f1.h\nfoo FIRST\n"; |
| 88 |
&compare_output($answer, &get_logfile(1)); |
| 89 |
} |
| 90 |
|
| 91 |
# TEST 6: Each double-colon rule is supposed to be run individually |
| 92 |
|
| 93 |
&utouch(-5, 'f1.h'); |
| 94 |
unlink('f2.h'); |
| 95 |
&touch('foo'); |
| 96 |
|
| 97 |
&run_make_with_options($makefile, "foo", &get_logfile, 0); |
| 98 |
$answer = "f2.h\nfoo SECOND\n"; |
| 99 |
&compare_output($answer, &get_logfile(1)); |
| 100 |
|
| 101 |
# TEST 7: Again, in parallel. |
| 102 |
|
| 103 |
if ($parallel_jobs) { |
| 104 |
&run_make_with_options($makefile, "-j10 foo", &get_logfile, 0); |
| 105 |
$answer = "f2.h\nfoo SECOND\n"; |
| 106 |
&compare_output($answer, &get_logfile(1)); |
| 107 |
} |
| 108 |
|
| 109 |
# TEST 8: Test circular dependency check; PR/1671 |
| 110 |
|
| 111 |
&run_make_with_options($makefile, "d", &get_logfile, 0); |
| 112 |
$answer = "ok\n$make_name: Circular d <- d dependency dropped.\noops\n"; |
| 113 |
&compare_output($answer, &get_logfile(1)); |
| 114 |
|
| 115 |
# TEST 8: I don't grok why this is different than the above, but it is... |
| 116 |
# |
| 117 |
# Hmm... further testing indicates this might be timing-dependent? |
| 118 |
# |
| 119 |
#if ($parallel_jobs) { |
| 120 |
# &run_make_with_options($makefile, "-j10 biz", &get_logfile, 0); |
| 121 |
# $answer = "aaa\ntwo\nbbb\n"; |
| 122 |
# &compare_output($answer, &get_logfile(1)); |
| 123 |
#} |
| 124 |
|
| 125 |
unlink('foo','f1.h','f2.h'); |
| 126 |
|
| 127 |
|
| 128 |
# TEST 9: make sure all rules in s double colon family get executed |
| 129 |
# (Savannah bug #14334). |
| 130 |
# |
| 131 |
|
| 132 |
&touch('one'); |
| 133 |
&touch('two'); |
| 134 |
|
| 135 |
run_make_test(' |
| 136 |
.PHONY: all |
| 137 |
all: result |
| 138 |
|
| 139 |
result:: one |
| 140 |
@echo $^ >>$@ |
| 141 |
@echo $^ |
| 142 |
|
| 143 |
result:: two |
| 144 |
@echo $^ >>$@ |
| 145 |
@echo $^ |
| 146 |
|
| 147 |
', |
| 148 |
'', |
| 149 |
'one |
| 150 |
two'); |
| 151 |
|
| 152 |
unlink('result','one','two'); |
| 153 |
|
| 154 |
# TEST 10: SV 33399 : check for proper backslash handling |
| 155 |
|
| 156 |
run_make_test(' |
| 157 |
a\ xb :: ; @echo one |
| 158 |
a\ xb :: ; @echo two |
| 159 |
', |
| 160 |
'', "one\ntwo\n"); |
| 161 |
|
| 162 |
# Test 11: SV 44742 : All double-colon rules should be run in parallel build. |
| 163 |
|
| 164 |
run_make_test('result :: 01 |
| 165 |
@echo update |
| 166 |
@touch $@ |
| 167 |
result :: 02 |
| 168 |
@echo update |
| 169 |
@touch $@ |
| 170 |
result :: 03 |
| 171 |
@echo update |
| 172 |
@touch $@ |
| 173 |
result :: 04 |
| 174 |
@echo update |
| 175 |
@touch $@ |
| 176 |
result :: 05 |
| 177 |
@echo update |
| 178 |
@touch $@ |
| 179 |
01 02 03 04 05: |
| 180 |
@touch 01 02 03 04 05 |
| 181 |
', |
| 182 |
'-j10 result', "update\nupdate\nupdate\nupdate\nupdate\n"); |
| 183 |
|
| 184 |
unlink('result', '01', '02', '03', '04', '05'); |
| 185 |
|
| 186 |
# Test 12: SV 44742 : Double-colon rules with parallelism |
| 187 |
|
| 188 |
run_make_test(' |
| 189 |
root: all |
| 190 |
echo root |
| 191 |
all:: |
| 192 |
echo all_one |
| 193 |
all:: 3 |
| 194 |
echo all_two |
| 195 |
%: |
| 196 |
sleep $* |
| 197 |
', |
| 198 |
'-rs -j2 1 2 root', "all_one\nall_two\nroot\n"); |
| 199 |
|
| 200 |
# SV 47995 : Parallel double-colon rules with FORCE |
| 201 |
|
| 202 |
run_make_test(' |
| 203 |
all:: ; @echo one |
| 204 |
|
| 205 |
all:: joe ; @echo four |
| 206 |
|
| 207 |
joe: FORCE ; touch joe-is-forced |
| 208 |
|
| 209 |
FORCE: |
| 210 |
', |
| 211 |
'-j5', "one\ntouch joe-is-forced\nfour\n"); |
| 212 |
|
| 213 |
unlink('joe-is-forced'); |
| 214 |
|
| 215 |
# This tells the test driver that the perl test script executed properly. |
| 216 |
1; |
| 217 |
|
| 218 |
### Local Variables: |
| 219 |
### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action)) |
| 220 |
### End: |