| 1 |
# -*-perl-*- |
| 2 |
# Date: Tue, 11 Aug 1992 09:34:26 -0400 |
| 3 |
# From: [email protected] (Paul D. Smith) |
| 4 |
|
| 5 |
$description = "Test load balancing (-l) option."; |
| 6 |
|
| 7 |
$details = "\ |
| 8 |
This test creates a makefile where all depends on three rules |
| 9 |
which contain the same body. Each rule checks for the existence |
| 10 |
of a temporary file; if it exists an error is generated. If it |
| 11 |
doesn't exist then it is created, the rule sleeps, then deletes |
| 12 |
the temp file again. Thus if any of the rules are run in |
| 13 |
parallel the test will fail. When make is called in this test, |
| 14 |
it is given the -l option with a value of 0.0001. This ensures |
| 15 |
that the load will be above this number and make will therefore |
| 16 |
decide that it cannot run more than one job even though -j 4 was |
| 17 |
also specified on the command line."; |
| 18 |
|
| 19 |
# On Windows a very different algorithm is used. |
| 20 |
$port_type eq 'W32' and return -1; |
| 21 |
|
| 22 |
open(MAKEFILE,"> $makefile"); |
| 23 |
printf MAKEFILE subst_make_string(q! |
| 24 |
test = #HELPER# noexist test-file file test-file sleep 2 rm test-file |
| 25 |
|
| 26 |
all : ONE TWO THREE |
| 27 |
ONE : ; @$(test) |
| 28 |
TWO : ; @$(test) |
| 29 |
THREE : ; @$(test) |
| 30 |
!); |
| 31 |
close(MAKEFILE); |
| 32 |
my $ans = "noexist test-file\nfile test-file\nsleep 2\nrm test-file\n"; |
| 33 |
|
| 34 |
$mkoptions = "-l 0.0001"; |
| 35 |
$mkoptions .= " -j 4" if ($parallel_jobs); |
| 36 |
|
| 37 |
# We have to wait longer than the default (5s). |
| 38 |
&run_make_with_options($makefile, $mkoptions, &get_logfile, 0, 10); |
| 39 |
|
| 40 |
$slurp = &read_file_into_string(&get_logfile(1)); |
| 41 |
if ($slurp =~ /cannot enforce load limit/) { |
| 42 |
return -1; |
| 43 |
} |
| 44 |
&compare_output("$ans$ans$ans", &get_logfile(1)); |
| 45 |
|
| 46 |
1; |