summaryrefslogtreecommitdiff
path: root/tests/scripts/options/dash-l
blob: 58216f9fb19eb185623ad635f48bb1034138b723 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#                                                                    -*-perl-*-
# Date: Tue, 11 Aug 1992 09:34:26 -0400
# From: pds@lemming.webo.dg.com (Paul D. Smith)

$description = "Test load balancing (-l) option.";

$details = "\
This test creates a makefile where all depends on three rules
which contain the same body.  Each rule checks for the existence
of a temporary file; if it exists an error is generated.  If it
doesn't exist then it is created, the rule sleeps, then deletes
the temp file again.  Thus if any of the rules are run in
parallel the test will fail.  When make is called in this test,
it is given the -l option with a value of 0.0001.  This ensures
that the load will be above this number and make will therefore
decide that it cannot run more than one job even though -j 4 was
also specified on the command line.";

open(MAKEFILE,"> $makefile");

# The Contents of the MAKEFILE ...

print MAKEFILE <<'EOF';
SHELL = /bin/sh

define test
if [ ! -f test-file ]; then \
  echo >> test-file; sleep 2; rm -f test-file; \
else \
  echo $@ FAILED; \
fi
endef

all : ONE TWO THREE
ONE : ; @$(test)
TWO : ; @$(test)
THREE : ; @$(test)
EOF


# END of Contents of MAKEFILE

close(MAKEFILE);

$mkoptions = "-l 0.0001";
$mkoptions .= " -j 4" if ($parallel_jobs);

&run_make_with_options($makefile, $mkoptions, &get_logfile);

$slurp = &read_file_into_string (&get_logfile(1));
if ($slurp !~ /cannot enforce load limit/) {
  &compare_output("", &get_logfile(1));
}

1;