VirtualBox

source: kBuild/vendor/gnumake/2003-11-23/tests/scripts/features/parallelism@ 1158

Last change on this file since 1158 was 53, checked in by bird, 21 years ago

Initial revision

  • Property svn:eol-style set to native
File size: 2.7 KB
Line 
1# -*-perl-*-
2
3$description = "Test parallelism (-j) option.";
4
5
6$details = "This test creates a makefile with two double-colon default
7rules. The first rule has a series of sleep and echo commands
8intended to run in series. The second and third have just an
9echo statement. When make is called in this test, it is given
10the -j option with a value of 4. This tells make that it may
11start up to four jobs simultaneously. In this case, since the
12first command is a sleep command, the output of the second
13and third commands will appear before the first if indeed
14make is running all of these commands in parallel.";
15
16if (!$parallel_jobs) {
17 return -1;
18}
19
20if ($vos) {
21 $delete_command = "delete_file -no_ask";
22 $sleep_command = "sleep -seconds";
23}
24else {
25 $delete_command = "rm -f";
26 $sleep_command = "sleep";
27}
28
29open(MAKEFILE,"> $makefile");
30
31print MAKEFILE <<"EOF";
32all : def_1 def_2 def_3
33def_1 : ; \@echo ONE; $sleep_command 3 ; echo TWO
34def_2 : ; \@$sleep_command 2 ; echo THREE
35def_3 : ; \@$sleep_command 1 ; echo FOUR
36EOF
37
38close(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
51open(MAKEFILE,"> $makefile2");
52
53print MAKEFILE <<"EOF";
54all: 1 2; \@echo success
55
56-include 1.inc 2.inc
57
581.inc: ; \@echo ONE.inc; $sleep_command 2; echo TWO.inc; echo "1: ; \@echo ONE; $sleep_command 2; echo TWO" > \$\@
592.inc: ; \@$sleep_command 1; echo THREE.inc; echo "2: ; \@$sleep_command 1; echo THREE" > \$\@
60EOF
61
62close(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
68unlink('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
76open(MAKEFILE,"> $makefile3");
77
78print MAKEFILE <<"EOF";
79recurse: ; \@\$(MAKE) --no-print-directory -f $makefile3 INC=yes all
80
81all: 1 2; \@echo success
82
83INC = no
84ifeq (\$(INC),yes)
85-include 1.inc 2.inc
86endif
87
881.inc: ; \@echo ONE.inc; $sleep_command 2; echo TWO.inc; echo "1: ; \@echo ONE; $sleep_command 2; echo TWO" > \$\@
892.inc: ; \@$sleep_command 1; echo THREE.inc; echo "2: ; \@$sleep_command 1; echo THREE" > \$\@
90EOF
91
92close(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
98unlink('1.inc', '2.inc');
99
1001;
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette