3 $description = "Test parallelism (-j) option.";
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.";
16 if (!$parallel_jobs) {
21 $delete_command = "delete_file -no_ask";
22 $sleep_command = "sleep -seconds";
25 $delete_command = "rm -f";
26 $sleep_command = "sleep";
29 open(MAKEFILE,"> $makefile");
31 print MAKEFILE <<"EOF";
32 all : def_1 def_2 def_3
33 def_1 : ; \@echo ONE; $sleep_command 3 ; echo TWO
34 def_2 : ; \@$sleep_command 2 ; echo THREE
35 def_3 : ; \@$sleep_command 1 ; echo FOUR
40 &run_make_with_options($makefile, "-j 4", &get_logfile);
41 $answer = "ONE\nFOUR\nTHREE\nTWO\n";
42 &compare_output($answer, &get_logfile(1));
45 # Test parallelism with included files. Here we sleep/echo while
46 # building the included files, to test that they are being built in
49 $makefile2 = &get_tmpfile;
51 open(MAKEFILE,"> $makefile2");
53 print MAKEFILE <<"EOF";
54 all: 1 2; \@echo success
58 1.inc: ; \@echo ONE.inc; $sleep_command 2; echo TWO.inc; echo "1: ; \@echo ONE; $sleep_command 2; echo TWO" > \$\@
59 2.inc: ; \@$sleep_command 1; echo THREE.inc; echo "2: ; \@$sleep_command 1; echo THREE" > \$\@
64 &run_make_with_options("$makefile2", "-j 4", &get_logfile);
65 $answer = "ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n";
66 &compare_output($answer, &get_logfile(1));
68 unlink('1.inc', '2.inc');
71 # Test parallelism with included files--this time recurse first and make
72 # sure the jobserver works.
74 $makefile3 = &get_tmpfile;
76 open(MAKEFILE,"> $makefile3");
78 print MAKEFILE <<"EOF";
79 recurse: ; \@\$(MAKE) --no-print-directory -f $makefile3 INC=yes all
81 all: 1 2; \@echo success
88 1.inc: ; \@echo ONE.inc; $sleep_command 2; echo TWO.inc; echo "1: ; \@echo ONE; $sleep_command 2; echo TWO" > \$\@
89 2.inc: ; \@$sleep_command 1; echo THREE.inc; echo "2: ; \@$sleep_command 1; echo THREE" > \$\@
94 &run_make_with_options("$makefile3", "-j 4", &get_logfile);
95 $answer = "ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n";
96 &compare_output($answer, &get_logfile(1));
98 unlink('1.inc', '2.inc');