diff options
author | Paul Smith <psmith@gnu.org> | 1999-09-14 02:03:19 +0000 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 1999-09-14 02:03:19 +0000 |
commit | 0d366b668244112846554c42045ff1d9956276ed (patch) | |
tree | 3802242fe18a5e90d889f5d1ac66fb487361888b /tests/scripts/options | |
parent | 4121dea6a59367b4431cbe7a3c43d74fec9fd832 (diff) | |
download | gunmake-0d366b668244112846554c42045ff1d9956276ed.tar.gz |
* Added the test suite to the main distribution.
Diffstat (limited to 'tests/scripts/options')
-rw-r--r-- | tests/scripts/options/dash-C | 48 | ||||
-rw-r--r-- | tests/scripts/options/dash-I | 57 | ||||
-rw-r--r-- | tests/scripts/options/dash-e | 24 | ||||
-rw-r--r-- | tests/scripts/options/dash-f | 85 | ||||
-rw-r--r-- | tests/scripts/options/dash-k | 73 | ||||
-rw-r--r-- | tests/scripts/options/dash-l | 55 | ||||
-rw-r--r-- | tests/scripts/options/dash-n | 31 |
7 files changed, 373 insertions, 0 deletions
diff --git a/tests/scripts/options/dash-C b/tests/scripts/options/dash-C new file mode 100644 index 0000000..3f2b3a1 --- /dev/null +++ b/tests/scripts/options/dash-C @@ -0,0 +1,48 @@ +$description = "The following test creates a makefile to test the -C dir \n" + ."option in make. This option tells make to change to \n" + ."directory dir before reading the makefile."; + +$details = "This test is similar to the clean test except that this test\n" + ."creates the file to delete in the work directory instead of\n" + ."the current directory. Make is called from another directory\n" + ."using the -C workdir option so that it can both find the \n" + ."makefile and the file to delete in the work directory. "; + +$example = $workdir . $pathsep . "EXAMPLE_FILE"; + +open(MAKEFILE,"> $makefile"); + +# The Contents of the MAKEFILE ... + +print MAKEFILE "all: \n"; +print MAKEFILE "\t\@echo This makefile did not clean the dir ... good\n"; +print MAKEFILE "clean: \n"; +print MAKEFILE "\t$delete_command EXAMPLE_FILE\n"; + +# END of Contents of MAKEFILE + +close(MAKEFILE); + +&touch($example); + +&run_make_with_options("${testname}.mk", + "-C $workdir clean", + &get_logfile); + +chdir $workdir; +$wpath = &get_this_pwd; +chdir $pwd; + +# Create the answer to what should be produced by this Makefile +$answer = "$make_name: Entering directory `$wpath'\n" + . "$delete_command EXAMPLE_FILE\n" + . "$make_name: Leaving directory `$wpath'\n"; + +&compare_output($answer,&get_logfile(1)); + +if (-f $example) +{ + $test_passed = 0; +} + +1; diff --git a/tests/scripts/options/dash-I b/tests/scripts/options/dash-I new file mode 100644 index 0000000..0be0bd7 --- /dev/null +++ b/tests/scripts/options/dash-I @@ -0,0 +1,57 @@ +$description ="The following test creates a makefile to test the -I option."; + +$details = "\ +This test tests the -I option by including a filename in +another directory and giving make that directory name +under -I in the command line. Without this option, the make +would fail to find the included file. It also checks to make +sure that the -I option gets passed to recursive makes."; + +$makefile2 = &get_tmpfile; + +open(MAKEFILE,"> $makefile"); + +# The Contents of the MAKEFILE ... + +$mf2 = substr ($makefile2, index ($makefile2, $pathsep) + 1); +print MAKEFILE <<EOF; +include $mf2 +all: +\t\@echo There should be no errors for this makefile. +EOF + +# END of Contents of MAKEFILE + +close(MAKEFILE); + + +open(MAKEFILE,"> $makefile2"); + +print MAKEFILE <<EOF; +ANOTHER: +\t\@echo This is another included makefile +recurse: +\t\$(MAKE) ANOTHER -f $makefile +EOF + +close(MAKEFILE); + +&run_make_with_options($makefile,"-I $workdir all",&get_logfile); + +# Create the answer to what should be produced by this Makefile +$answer = "There should be no errors for this makefile.\n"; +&compare_output($answer,&get_logfile(1)); + + +$answer = "This is another included makefile\n"; +&run_make_with_options($makefile,"-I $workdir ANOTHER",&get_logfile); +&compare_output($answer,&get_logfile(1)); + + +$answer = "$mkpath ANOTHER -f $makefile +${make_name}[1]: Entering directory `$pwd' +This is another included makefile +${make_name}[1]: Leaving directory `$pwd'\n"; + +&run_make_with_options($makefile,"-I $workdir recurse",&get_logfile); +&compare_output($answer,&get_logfile(1)); diff --git a/tests/scripts/options/dash-e b/tests/scripts/options/dash-e new file mode 100644 index 0000000..472270d --- /dev/null +++ b/tests/scripts/options/dash-e @@ -0,0 +1,24 @@ +# -*-perl-*- + +$description = "The following test creates a makefile to ..."; + +$details = ""; + +$ENV{GOOGLE} = 'boggle'; + +open(MAKEFILE,"> $makefile"); + +print MAKEFILE <<'EOF'; +GOOGLE = bazzle +all:; @echo "$(GOOGLE)" +EOF + +close(MAKEFILE); + +&run_make_with_options($makefile, '-e' ,&get_logfile); + +$answer = "boggle\n"; + +&compare_output($answer,&get_logfile(1)); + +1; diff --git a/tests/scripts/options/dash-f b/tests/scripts/options/dash-f new file mode 100644 index 0000000..3aa4746 --- /dev/null +++ b/tests/scripts/options/dash-f @@ -0,0 +1,85 @@ +$description = "The following test tests that if you specify greater \n" + ."than one '-f makefilename' on the command line, \n" + ."that make concatenates them. This test creates three \n" + ."makefiles and specifies all of them with the -f option \n" + ."on the command line. To make sure they were concatenated, \n" + ."we then call make with the rules from the concatenated \n" + ."makefiles one at a time. Finally, it calls all three \n" + ."rules in one call to make and checks that the output\n" + ."is in the correct order."; + +$makefile2 = &get_tmpfile; +$makefile3 = &get_tmpfile; + +open(MAKEFILE,"> $makefile"); + +# The Contents of the MAKEFILE ... + +print MAKEFILE "all: \n"; +print MAKEFILE "\t\@echo This is the output from the original makefile\n"; + +# END of Contents of MAKEFILE + +close(MAKEFILE); + +# Create a second makefile +open(MAKEFILE,"> $makefile2"); +print MAKEFILE "TWO: \n"; +print MAKEFILE "\t\@echo This is the output from makefile 2\n"; +close(MAKEFILE); + +# Create a third makefile +open(MAKEFILE,"> $makefile3"); +print MAKEFILE "THREE: \n"; +print MAKEFILE "\t\@echo This is the output from makefile 3\n"; +close(MAKEFILE); + + +# Create the answer to what should be produced by this Makefile +$answer = "This is the output from the original makefile\n"; + +# Run make to catch the default rule +&run_make_with_options($makefile,"-f $makefile2 -f $makefile3",&get_logfile,0); + +&compare_output($answer,&get_logfile(1)); + + +# Run Make again with the rule from the second makefile: TWO +$answer = "This is the output from makefile 2\n"; + +&run_make_with_options($makefile,"-f $makefile2 -f $makefile3 TWO",&get_logfile,0); + +&compare_output($answer,&get_logfile(1)); + + +# Run Make again with the rule from the third makefile: THREE + +$answer = "This is the output from makefile 3\n"; +&run_make_with_options($makefile, + "-f $makefile2 -f $makefile3 THREE", + &get_logfile, + 0); +&compare_output($answer,&get_logfile(1)); + + +# Run Make again with ALL three rules in the order 2 1 3 to make sure +# that all rules are executed in the proper order + +$answer = "This is the output from makefile 2\n"; +$answer .= "This is the output from the original makefile\n"; +$answer .= "This is the output from makefile 3\n"; +&run_make_with_options($makefile, + "-f $makefile2 -f $makefile3 TWO all THREE", + &get_logfile, + 0); +&compare_output($answer,&get_logfile(1)); + + + + + + + + + + diff --git a/tests/scripts/options/dash-k b/tests/scripts/options/dash-k new file mode 100644 index 0000000..a5baaf7 --- /dev/null +++ b/tests/scripts/options/dash-k @@ -0,0 +1,73 @@ +$description = "The following test creates a makefile to test the -k option.\n" + ."Normally, make gives up immediately if an error happens \n" + ."that make has not been told to ignore. However, if the -k\n" + ."option is specified, make continues to consider the other\n" + ."dependencies of the pending targets."; + +$details = "The makefile created in this test is a simulation of building \n" + ."a small product. However, the trick to this one is that one \n" + ."of the dependencies of the main target does not exist. \n" + ."Without the -k option, make would fail immediately and not \n" + ."build any part of the target. What we are looking for here, \n" + ."is that make builds the rest of the dependencies even though \n" + ."it knows that at the end it will fail to rebuild the main target."; + +open(MAKEFILE,"> $makefile"); + +# The Contents of the MAKEFILE ... + +print MAKEFILE "VPATH = $workdir\n"; +print MAKEFILE "edit: main.o kbd.o commands.o display.o \n"; +print MAKEFILE "\t\@echo cc -o edit main.o kbd.o commands.o display.o \n"; + +print MAKEFILE "main.o : main.c defs.h\n"; +print MAKEFILE "\t\@echo cc -c main.c\n"; + +print MAKEFILE "kbd.o : kbd.c defs.h command.h\n"; +print MAKEFILE "\t\@echo cc -c kbd.c\n"; + +print MAKEFILE "commands.o : command.c defs.h command.h\n"; +print MAKEFILE "\t\@echo cc -c commands.c\n"; + +print MAKEFILE "display.o : display.c defs.h buffer.h\n"; +print MAKEFILE "\t\@echo cc -c display.c\n"; + +# END of Contents of MAKEFILE + +close(MAKEFILE); + + +@files_to_touch = ("$workdir${pathsep}main.c","$workdir${pathsep}defs.h", + "$workdir${pathsep}command.h", + "$workdir${pathsep}commands.c","$workdir${pathsep}display.c", + "$workdir${pathsep}buffer.h", + "$workdir${pathsep}command.c"); + +&touch(@files_to_touch); + +if ($vos) +{ + $error_code = 3307; +} +else +{ + $error_code = 512; +} + +&run_make_with_options($makefile,"-k",&get_logfile,$error_code); + +# Create the answer to what should be produced by this Makefile +$answer = "cc -c main.c\n" + ."$make_name: *** No rule to make target `kbd.c', needed by `kbd.o'.\n" + ."cc -c commands.c\n" + ."cc -c display.c\n" + ."$make_name: Target `edit' not remade because of errors.\n"; + +# COMPARE RESULTS + +if (&compare_output($answer,&get_logfile(1))) +{ + unlink @files_to_touch; +} + +1; diff --git a/tests/scripts/options/dash-l b/tests/scripts/options/dash-l new file mode 100644 index 0000000..445b869 --- /dev/null +++ b/tests/scripts/options/dash-l @@ -0,0 +1,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 \ + touch 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; diff --git a/tests/scripts/options/dash-n b/tests/scripts/options/dash-n new file mode 100644 index 0000000..97dac7a --- /dev/null +++ b/tests/scripts/options/dash-n @@ -0,0 +1,31 @@ +# -*-perl-*- +$description = "Test the -n option.\n"; + +$details = "Try various uses of -n and ensure they all give the correct results.\n"; + +open(MAKEFILE, "> $makefile"); + +# The Contents of the MAKEFILE ... + +print MAKEFILE <<'EOMAKE'; + +final: intermediate ; touch $@ +intermediate: orig ; touch $@ + +EOMAKE + +close(MAKEFILE); + +&touch('orig'); + +&run_make_with_options($makefile, "", &get_logfile); +$answer = "touch intermediate\ntouch final\n"; +&compare_output($answer, &get_logfile(1)); + +&run_make_with_options($makefile, "-Worig -n", &get_logfile); +$answer = "touch intermediate\ntouch final\n"; +&compare_output($answer, &get_logfile(1)); + +unlink('orig', 'intermediate', 'final'); + +1; |