| 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 | open(MAKEFILE,"> $makefile");
|
|---|
| 30 |
|
|---|
| 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
|
|---|
| 36 | EOF
|
|---|
| 37 |
|
|---|
| 38 | close(MAKEFILE);
|
|---|
| 39 |
|
|---|
| 40 | &run_make_with_options($makefile, "-j 4", &get_logfile);
|
|---|
| 41 | $answer = "ONE\nFOUR\nTHREE\nTWO\n";
|
|---|
| 42 | &compare_output($answer, &get_logfile(1));
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 | # Test parallelism with included files. Here we sleep/echo while
|
|---|
| 46 | # building the included files, to test that they are being built in
|
|---|
| 47 | # parallel.
|
|---|
| 48 |
|
|---|
| 49 | $makefile2 = &get_tmpfile;
|
|---|
| 50 |
|
|---|
| 51 | open(MAKEFILE,"> $makefile2");
|
|---|
| 52 |
|
|---|
| 53 | print MAKEFILE <<"EOF";
|
|---|
| 54 | all: 1 2; \@echo success
|
|---|
| 55 |
|
|---|
| 56 | -include 1.inc 2.inc
|
|---|
| 57 |
|
|---|
| 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" > \$\@
|
|---|
| 60 | EOF
|
|---|
| 61 |
|
|---|
| 62 | close(MAKEFILE);
|
|---|
| 63 |
|
|---|
| 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));
|
|---|
| 67 |
|
|---|
| 68 | unlink('1.inc', '2.inc');
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 | # Test parallelism with included files--this time recurse first and make
|
|---|
| 72 | # sure the jobserver works.
|
|---|
| 73 |
|
|---|
| 74 | $makefile3 = &get_tmpfile;
|
|---|
| 75 |
|
|---|
| 76 | open(MAKEFILE,"> $makefile3");
|
|---|
| 77 |
|
|---|
| 78 | print MAKEFILE <<"EOF";
|
|---|
| 79 | recurse: ; \@\$(MAKE) --no-print-directory -f $makefile3 INC=yes all
|
|---|
| 80 |
|
|---|
| 81 | all: 1 2; \@echo success
|
|---|
| 82 |
|
|---|
| 83 | INC = no
|
|---|
| 84 | ifeq (\$(INC),yes)
|
|---|
| 85 | -include 1.inc 2.inc
|
|---|
| 86 | endif
|
|---|
| 87 |
|
|---|
| 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" > \$\@
|
|---|
| 90 | EOF
|
|---|
| 91 |
|
|---|
| 92 | close(MAKEFILE);
|
|---|
| 93 |
|
|---|
| 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));
|
|---|
| 97 |
|
|---|
| 98 | unlink('1.inc', '2.inc');
|
|---|
| 99 |
|
|---|
| 100 | 1;
|
|---|