1*69606e3fSchristos# -*-perl-*- 2*69606e3fSchristos$description = "Test handling of double-colon rules."; 3*69606e3fSchristos 4*69606e3fSchristos$details = "\ 5*69606e3fSchristosWe test these features: 6*69606e3fSchristos 7*69606e3fSchristos - Multiple commands for the same (double-colon) target 8*69606e3fSchristos - Different prerequisites for targets: only out-of-date 9*69606e3fSchristos ones are rebuilt. 10*69606e3fSchristos - Double-colon targets that aren't the goal target. 11*69606e3fSchristos 12*69606e3fSchristosThen we do the same thing for parallel builds: double-colon 13*69606e3fSchristostargets should always be built serially."; 14*69606e3fSchristos 15*69606e3fSchristos# The Contents of the MAKEFILE ... 16*69606e3fSchristos 17*69606e3fSchristosopen(MAKEFILE,"> $makefile"); 18*69606e3fSchristos 19*69606e3fSchristosprint MAKEFILE <<'EOF'; 20*69606e3fSchristos 21*69606e3fSchristosall: baz 22*69606e3fSchristos 23*69606e3fSchristosfoo:: f1.h ; @echo foo FIRST 24*69606e3fSchristosfoo:: f2.h ; @echo foo SECOND 25*69606e3fSchristos 26*69606e3fSchristosbar:: ; @echo aaa; sleep 1; echo aaa done 27*69606e3fSchristosbar:: ; @echo bbb 28*69606e3fSchristos 29*69606e3fSchristosbaz:: ; @echo aaa 30*69606e3fSchristosbaz:: ; @echo bbb 31*69606e3fSchristos 32*69606e3fSchristosbiz:: ; @echo aaa 33*69606e3fSchristosbiz:: two ; @echo bbb 34*69606e3fSchristos 35*69606e3fSchristostwo: ; @echo two 36*69606e3fSchristos 37*69606e3fSchristosf1.h f2.h: ; @echo $@ 38*69606e3fSchristos 39*69606e3fSchristosd :: ; @echo ok 40*69606e3fSchristosd :: d ; @echo oops 41*69606e3fSchristos 42*69606e3fSchristosEOF 43*69606e3fSchristos 44*69606e3fSchristosclose(MAKEFILE); 45*69606e3fSchristos 46*69606e3fSchristos# TEST 0: A simple double-colon rule that isn't the goal target. 47*69606e3fSchristos 48*69606e3fSchristos&run_make_with_options($makefile, "all", &get_logfile, 0); 49*69606e3fSchristos$answer = "aaa\nbbb\n"; 50*69606e3fSchristos&compare_output($answer, &get_logfile(1)); 51*69606e3fSchristos 52*69606e3fSchristos# TEST 1: As above, in parallel 53*69606e3fSchristos 54*69606e3fSchristosif ($parallel_jobs) { 55*69606e3fSchristos &run_make_with_options($makefile, "-j10 all", &get_logfile, 0); 56*69606e3fSchristos $answer = "aaa\nbbb\n"; 57*69606e3fSchristos &compare_output($answer, &get_logfile(1)); 58*69606e3fSchristos} 59*69606e3fSchristos 60*69606e3fSchristos# TEST 2: A simple double-colon rule that is the goal target 61*69606e3fSchristos 62*69606e3fSchristos&run_make_with_options($makefile, "bar", &get_logfile, 0); 63*69606e3fSchristos$answer = "aaa\naaa done\nbbb\n"; 64*69606e3fSchristos&compare_output($answer, &get_logfile(1)); 65*69606e3fSchristos 66*69606e3fSchristos# TEST 3: As above, in parallel 67*69606e3fSchristos 68*69606e3fSchristosif ($parallel_jobs) { 69*69606e3fSchristos &run_make_with_options($makefile, "-j10 bar", &get_logfile, 0); 70*69606e3fSchristos $answer = "aaa\naaa done\nbbb\n"; 71*69606e3fSchristos &compare_output($answer, &get_logfile(1)); 72*69606e3fSchristos} 73*69606e3fSchristos 74*69606e3fSchristos# TEST 4: Each double-colon rule is supposed to be run individually 75*69606e3fSchristos 76*69606e3fSchristos&utouch(-5, 'f2.h'); 77*69606e3fSchristos&touch('foo'); 78*69606e3fSchristos 79*69606e3fSchristos&run_make_with_options($makefile, "foo", &get_logfile, 0); 80*69606e3fSchristos$answer = "f1.h\nfoo FIRST\n"; 81*69606e3fSchristos&compare_output($answer, &get_logfile(1)); 82*69606e3fSchristos 83*69606e3fSchristos# TEST 5: Again, in parallel. 84*69606e3fSchristos 85*69606e3fSchristosif ($parallel_jobs) { 86*69606e3fSchristos &run_make_with_options($makefile, "-j10 foo", &get_logfile, 0); 87*69606e3fSchristos $answer = "f1.h\nfoo FIRST\n"; 88*69606e3fSchristos &compare_output($answer, &get_logfile(1)); 89*69606e3fSchristos} 90*69606e3fSchristos 91*69606e3fSchristos# TEST 6: Each double-colon rule is supposed to be run individually 92*69606e3fSchristos 93*69606e3fSchristos&utouch(-5, 'f1.h'); 94*69606e3fSchristosunlink('f2.h'); 95*69606e3fSchristos&touch('foo'); 96*69606e3fSchristos 97*69606e3fSchristos&run_make_with_options($makefile, "foo", &get_logfile, 0); 98*69606e3fSchristos$answer = "f2.h\nfoo SECOND\n"; 99*69606e3fSchristos&compare_output($answer, &get_logfile(1)); 100*69606e3fSchristos 101*69606e3fSchristos# TEST 7: Again, in parallel. 102*69606e3fSchristos 103*69606e3fSchristosif ($parallel_jobs) { 104*69606e3fSchristos &run_make_with_options($makefile, "-j10 foo", &get_logfile, 0); 105*69606e3fSchristos $answer = "f2.h\nfoo SECOND\n"; 106*69606e3fSchristos &compare_output($answer, &get_logfile(1)); 107*69606e3fSchristos} 108*69606e3fSchristos 109*69606e3fSchristos# TEST 8: Test circular dependency check; PR/1671 110*69606e3fSchristos 111*69606e3fSchristos&run_make_with_options($makefile, "d", &get_logfile, 0); 112*69606e3fSchristos$answer = "ok\n$make_name: Circular d <- d dependency dropped.\noops\n"; 113*69606e3fSchristos&compare_output($answer, &get_logfile(1)); 114*69606e3fSchristos 115*69606e3fSchristos# TEST 8: I don't grok why this is different than the above, but it is... 116*69606e3fSchristos# 117*69606e3fSchristos# Hmm... further testing indicates this might be timing-dependent? 118*69606e3fSchristos# 119*69606e3fSchristos#if ($parallel_jobs) { 120*69606e3fSchristos# &run_make_with_options($makefile, "-j10 biz", &get_logfile, 0); 121*69606e3fSchristos# $answer = "aaa\ntwo\nbbb\n"; 122*69606e3fSchristos# &compare_output($answer, &get_logfile(1)); 123*69606e3fSchristos#} 124*69606e3fSchristos 125*69606e3fSchristosunlink('foo','f1.h','f2.h'); 126*69606e3fSchristos 127*69606e3fSchristos 128*69606e3fSchristos# TEST 9: make sure all rules in s double colon family get executed 129*69606e3fSchristos# (Savannah bug #14334). 130*69606e3fSchristos# 131*69606e3fSchristos 132*69606e3fSchristos&touch('one'); 133*69606e3fSchristos&touch('two'); 134*69606e3fSchristos 135*69606e3fSchristosrun_make_test(' 136*69606e3fSchristos.PHONY: all 137*69606e3fSchristosall: result 138*69606e3fSchristos 139*69606e3fSchristosresult:: one 140*69606e3fSchristos @echo $^ >>$@ 141*69606e3fSchristos @echo $^ 142*69606e3fSchristos 143*69606e3fSchristosresult:: two 144*69606e3fSchristos @echo $^ >>$@ 145*69606e3fSchristos @echo $^ 146*69606e3fSchristos 147*69606e3fSchristos', 148*69606e3fSchristos'', 149*69606e3fSchristos'one 150*69606e3fSchristostwo'); 151*69606e3fSchristos 152*69606e3fSchristosunlink('result','one','two'); 153*69606e3fSchristos 154*69606e3fSchristos# This tells the test driver that the perl test script executed properly. 155*69606e3fSchristos1; 156