# Date: Tue, 11 Aug 1992 09:34:26 -0400
# From: pds@lemming.webo.dg.com (Paul D. Smith)

$description = "The following test creates a makefile to test the -l option\n"
              ."which tells make to limit the number of jobs to run at once.\n"
              ."Based on the load average at the time, make will not start\n"
              ."more than one job if the load average is above the number \n"
              ."specified with the -l option.";

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

open(MAKEFILE,"> $makefile");

# The Contents of the MAKEFILE ...

print MAKEFILE "define test\n"
              ."if [ ! -f test-file ]; then \\\n"
              ."  touch test-file; sleep 2; rm -f test-file; \\\n"
              ."else \\\n"
              ."  echo \$@ FAILED; \\\n"
              ."fi\n"
              ."endef\n\n"
              ."all : ONE TWO THREE\n"
              ."ONE : ; @\$(test)\n"
              ."TWO : ; @\$(test)\n"
              ."THREE : ; @\$(test)\n";


# END of Contents of MAKEFILE

close(MAKEFILE);

&run_make_with_options($makefile,"-j 4 -l 0.0001",&get_logfile);

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

1;





