Changeset 503 in kBuild for trunk/src/gmake/tests/scripts/functions
- Timestamp:
- Sep 15, 2006 5:09:38 AM (18 years ago)
- Location:
- trunk/src/gmake/tests/scripts/functions
- Files:
-
- 9 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gmake/tests/scripts/functions/abspath
r282 r503 6 6 run_make_test(' 7 7 ifneq ($(realpath $(abspath .)),$(CURDIR)) 8 $( error)8 $(warning .: abs="$(abspath .)" real="$(realpath $(abspath .))" curdir="$(CURDIR)") 9 9 endif 10 10 11 11 ifneq ($(realpath $(abspath ./)),$(CURDIR)) 12 $( error)12 $(warning ./: abs="$(abspath ./)" real="$(realpath $(abspath ./))" curdir="$(CURDIR)") 13 13 endif 14 14 15 15 ifneq ($(realpath $(abspath .///)),$(CURDIR)) 16 $( error)16 $(warning .///: abs="$(abspath .///)" real="$(realpath $(abspath .///))" curdir="$(CURDIR)") 17 17 endif 18 18 19 19 ifneq ($(abspath /),/) 20 $( error)20 $(warning /: abspath="$(abspath /)") 21 21 endif 22 22 23 23 ifneq ($(abspath ///),/) 24 $( error)24 $(warning ///: abspath="$(abspath ///)") 25 25 endif 26 26 27 27 ifneq ($(abspath /.),/) 28 $( error)28 $(warning /.: abspath="$(abspath /.)") 29 29 endif 30 30 31 31 ifneq ($(abspath ///.),/) 32 $( error)32 $(warning ///.: abspath="$(abspath ///.)") 33 33 endif 34 34 35 35 ifneq ($(abspath /./),/) 36 $( error)36 $(warning /./: abspath="$(abspath /./)") 37 37 endif 38 38 39 39 ifneq ($(abspath /.///),/) 40 $( error)40 $(warning /.///: abspath="$(abspath /.///)") 41 41 endif 42 42 43 43 ifneq ($(abspath /..),/) 44 $( error)44 $(warning /..: abspath="$(abspath /..)") 45 45 endif 46 46 47 47 ifneq ($(abspath ///..),/) 48 $( error)48 $(warning ///..: abspath="$(abspath ///..)") 49 49 endif 50 50 51 51 ifneq ($(abspath /../),/) 52 $( error)52 $(warning /../: abspath="$(abspath /../)") 53 53 endif 54 54 55 55 ifneq ($(abspath /..///),/) 56 $( error)56 $(warning /..///: abspath="$(abspath /..///)") 57 57 endif 58 58 59 59 60 60 ifneq ($(abspath /foo/bar/..),/foo) 61 $( error)61 $(warning /foo/bar/..: abspath="$(abspath /foo/bar/..)") 62 62 endif 63 63 64 64 ifneq ($(abspath /foo/bar/../../../baz),/baz) 65 $( error)65 $(warning /foo/bar/../../../baz: abspath="$(abspath /foo/bar/../../../baz)") 66 66 endif 67 67 68 68 ifneq ($(abspath /foo/bar/../ /..),/foo /) 69 $( error)69 $(warning /foo/bar/../ /..: abspath="$(abspath /foo/bar/../ /..)") 70 70 endif 71 71 -
trunk/src/gmake/tests/scripts/functions/error
r53 r503 1 # -*-Perl-*- 2 1 3 $description = "\ 2 4 The following test creates a makefile to test the error function."; … … 6 8 open(MAKEFILE,"> $makefile"); 7 9 8 print MAKEFILE <<'EOF'; 10 print MAKEFILE 'err = $(error Error found!) 11 9 12 ifdef ERROR1 10 13 $(error error is $(ERROR1)) … … 26 29 some: ; @echo Some stuff 27 30 28 EOF 31 testvar: ; @: $(err) 32 '; 29 33 30 34 close(MAKEFILE); … … 33 37 34 38 &run_make_with_options($makefile, "ERROR1=yes", &get_logfile, 512); 35 $answer = "$makefile: 2: *** error is yes. Stop.\n";39 $answer = "$makefile:4: *** error is yes. Stop.\n"; 36 40 &compare_output($answer,&get_logfile(1)); 37 41 … … 39 43 40 44 &run_make_with_options($makefile, "ERROR2=no", &get_logfile, 512); 41 $answer = "$makefile: 6: *** error is no. Stop.\n";45 $answer = "$makefile:8: *** error is no. Stop.\n"; 42 46 &compare_output($answer,&get_logfile(1)); 43 47 … … 45 49 46 50 &run_make_with_options($makefile, "ERROR3=maybe", &get_logfile, 512); 47 $answer = "Some stuff\n$makefile:1 0: *** error is maybe. Stop.\n";51 $answer = "Some stuff\n$makefile:12: *** error is maybe. Stop.\n"; 48 52 &compare_output($answer,&get_logfile(1)); 49 53 … … 51 55 52 56 &run_make_with_options($makefile, "ERROR4=definitely", &get_logfile, 512); 53 $answer = "Some stuff\n$makefile:14: *** error is definitely. Stop.\n"; 57 $answer = "Some stuff\n$makefile:16: *** error is definitely. Stop.\n"; 58 &compare_output($answer,&get_logfile(1)); 59 60 # Test #5 61 62 &run_make_with_options($makefile, "testvar", &get_logfile, 512); 63 $answer = "$makefile:22: *** Error found!. Stop.\n"; 54 64 &compare_output($answer,&get_logfile(1)); 55 65 -
trunk/src/gmake/tests/scripts/functions/eval
r285 r503 128 128 close(MAKEFILE); 129 129 130 $ ENV{EVAR} = '1';130 $extraENV{EVAR} = '1'; 131 131 &run_make_with_options($makefile4, "", &get_logfile); 132 132 $answer = "OK\n"; 133 133 &compare_output($answer,&get_logfile(1)); 134 135 delete $ENV{EVAR};136 134 137 135 … … 152 150 run_make_test(' 153 151 define FOO 154 all: ; @echo he\llo152 all: ; @echo '."'".'he\llo'."'".' 155 153 @echo world 156 154 endef 157 155 $(eval $(FOO)) 158 ', '', 'he llo156 ', '', 'he\llo 159 157 world'); 160 158 -
trunk/src/gmake/tests/scripts/functions/foreach
r53 r503 1 1 # -*-perl-*- 2 # $Id: foreach,v 1.5 2006/03/10 02:20:46 psmith Exp $ 2 3 3 # Updated 6.16.93 variable "MAKE" is default was environment override 4 # For make 3.63 and above 5 6 $description = "The following test creates a makefile to verify 7 test the foreach function."; 4 $description = "Test the foreach function."; 8 5 9 6 $details = "This is a test of the foreach function in gnu make. … … 15 12 16 13 17 open(MAKEFILE,"> $makefile"); 14 # TEST 0 18 15 19 # The Contents of the MAKEFILE ... 16 # Set an environment variable that we can test in the makefile. 17 $extraENV{FOOFOO} = 'foo foo'; 20 18 21 # On WIN32 systems, the user's path is found in %Path% ($Path) 22 # 23 $pathvar = (($port_type eq 'Windows') ? "Path" : "PATH"); 19 run_make_test("space = ' '".' 20 null := 21 auto_var = udef space CC null FOOFOO MAKE foo CFLAGS WHITE @ < 22 foo = bletch null @ garf 23 av = $(foreach var, $(auto_var), $(origin $(var)) ) 24 override WHITE := BLACK 25 for_var = $(addsuffix .c,foo $(null) $(foo) $(space) $(av) ) 26 fe = $(foreach var2, $(for_var),$(subst .c,.o, $(var2) ) ) 27 all: auto for2 28 auto : ; @echo $(av) 29 for2: ; @echo $(fe)', 30 '-e WHITE=WHITE CFLAGS=', 31 "undefined file default file environment default file command line override automatic automatic 32 foo.o bletch.o null.o @.o garf.o .o .o undefined.o file.o default.o file.o environment.o default.o file.o command.o line.o override.o automatic.o automatic.o"); 24 33 25 print MAKEFILE <<EOF; 26 foo = bletch null \@ garf 27 null := 28 space = ' ' 29 auto_var = udef space CC null $pathvar MAKE foo CFLAGS WHITE \@ < 30 av = \$(foreach var, \$(auto_var), \$(origin \$(var)) ) 31 override WHITE := BLACK 32 for_var = \$(addsuffix .c,foo \$(null) \$(foo) \$(space) \$(av) ) 33 fe = \$(foreach var2, \$(for_var),\$(subst .c,.o, \$(var2) ) ) 34 all: auto for2 35 auto : 36 \t\@echo \$(av) 37 for2: 38 \t\@echo \$(fe) 39 EOF 34 delete $extraENV{FOOFOO}; 40 35 41 close(MAKEFILE); 36 # TEST 1: Test that foreach variables take precedence over global 37 # variables in a global scope (like inside an eval). Tests bug #11913 42 38 43 &run_make_with_options($makefile, 44 "-e WHITE=WHITE CFLAGS=", 45 &get_logfile); 39 run_make_test(' 40 .PHONY: all target 41 all: target 46 42 47 # Create the answer to what should be produced by this Makefile 48 $answer = "undefined file default file environment default file command line override automatic automatic 49 foo.o bletch.o null.o @.o garf.o .o .o undefined.o file.o default.o file.o environment.o default.o file.o command.o line.o override.o automatic.o automatic.o\n"; 43 x := BAD 50 44 51 &compare_output($answer,&get_logfile(1)); 45 define mktarget 46 target: x := $(x) 47 target: ; @echo "$(x)" 48 endef 49 50 x := GLOBAL 51 52 $(foreach x,FOREACH,$(eval $(value mktarget)))', 53 '', 54 'FOREACH'); 55 56 57 # TEST 2: Check some error conditions. 58 59 run_make_test(' 60 x = $(foreach ) 61 y = $x 62 63 all: ; @echo $y', 64 '', 65 "#MAKEFILE#:2: *** insufficient number of arguments (1) to function `foreach'. Stop.", 66 512); 67 68 run_make_test(' 69 x = $(foreach ) 70 y := $x 71 72 all: ; @echo $y', 73 '', 74 "#MAKEFILE#:2: *** insufficient number of arguments (1) to function `foreach'. Stop.", 75 512); 52 76 53 77 1; -
trunk/src/gmake/tests/scripts/functions/origin
r154 r503 17 17 18 18 # Set an environment variable 19 $ ENV{MAKETEST} = 1;19 $extraENV{MAKETEST} = 1; 20 20 21 open(MAKEFILE,"> $makefile"); 22 23 print MAKEFILE <<EOF; 21 run_make_test(' 24 22 foo := bletch garf 25 auto_var = u def CC MAKETEST MAKE foo CFLAGS WHITE \@26 av = \$(foreach var, \$(auto_var), \$(origin \$(var)) )23 auto_var = undefined CC MAKETEST MAKE foo CFLAGS WHITE @ 24 av = $(foreach var, $(auto_var), $(origin $(var)) ) 27 25 override WHITE := BLACK 28 26 all: auto 29 \t\@echo \$(origin undefined)30 \t\@echo \$(origin CC)31 \t\@echo \$(origin MAKETEST)32 \t\@echo \$(origin MAKE)33 \t\@echo \$(origin foo)34 \t\@echo \$(origin CFLAGS)35 \t\@echo \$(origin WHITE)36 \t\@echo \$(origin \@)27 @echo $(origin undefined) 28 @echo $(origin CC) 29 @echo $(origin MAKETEST) 30 @echo $(origin MAKE) 31 @echo $(origin foo) 32 @echo $(origin CFLAGS) 33 @echo $(origin WHITE) 34 @echo $(origin @) 37 35 auto : 38 \t\@echo \$(av) 39 EOF 40 41 close(MAKEFILE); 42 43 &run_make_with_options($makefile, 44 "-e WHITE=WHITE CFLAGS=", 45 &get_logfile); 46 47 # Create the answer to what should be produced by this Makefile 48 $answer = "undefined default environment default file command line override automatic 36 @echo $(av)', 37 '-e WHITE=WHITE CFLAGS=', 38 'undefined default environment default file command line override automatic 49 39 undefined 50 40 default … … 54 44 command line 55 45 override 56 automatic \n";46 automatic'); 57 47 58 59 &compare_output($answer,&get_logfile(1));48 # Reset an environment variable 49 delete $extraENV{MAKETEST}; 60 50 61 51 1; -
trunk/src/gmake/tests/scripts/functions/realpath
r282 r503 21 21 endif 22 22 23 ifneq ($(realpath ///),/)24 $(error )25 endif26 27 23 ifneq ($(realpath /.),/) 28 $(error )29 endif30 31 ifneq ($(realpath ///.),/)32 24 $(error ) 33 25 endif … … 42 34 43 35 ifneq ($(realpath /..),/) 44 $(error )45 endif46 47 ifneq ($(realpath ///..),/)48 36 $(error ) 49 37 endif … … 64 52 all: ; @: 65 53 ', 66 '', 67 ''); 54 '', 55 ''); 56 57 # On Windows platforms, "//" means something special. So, don't do these 58 # tests there. 59 60 if ($port_type ne 'W32') { 61 run_make_test(' 62 ifneq ($(realpath ///),/) 63 $(error ) 64 endif 65 66 ifneq ($(realpath ///.),/) 67 $(error ) 68 endif 69 70 ifneq ($(realpath ///..),/) 71 $(error ) 72 endif 73 74 .PHONY: all 75 all: ; @:', 76 '', 77 ''); 78 } 68 79 69 80 -
trunk/src/gmake/tests/scripts/functions/warning
r53 r503 1 # -*-Perl-*- 2 1 3 $description = "\ 2 4 The following test creates a makefile to test the warning function."; -
trunk/src/gmake/tests/scripts/functions/wildcard
r285 r503 14 14 the '*' wildcard as in the first test"; 15 15 16 if ($vos)17 {18 $delete_command = "delete_file -no_ask";19 }20 else21 {22 $delete_command = "rm";23 }24 25 26 16 open(MAKEFILE,"> $makefile"); 27 17 … … 30 20 print MAKEFILE <<EOM; 31 21 .PHONY: print1 print2 clean 32 print1: ;\@echo \$( wildcard example.*)22 print1: ;\@echo \$(sort \$(wildcard example.*)) 33 23 print2: 34 \t\@echo \$( wildcard example.?)35 \t\@echo \$( wildcard example.[a-z0-9])36 \t\@echo \$( wildcard example.[!A-Za-z_\\!])24 \t\@echo \$(sort \$(wildcard example.?)) 25 \t\@echo \$(sort \$(wildcard example.[a-z0-9])) 26 \t\@echo \$(sort \$(wildcard example.[!A-Za-z_\\!])) 37 27 clean: 38 \t$delete_command \$( wildcard example.*)28 \t$delete_command \$(sort \$(wildcard example.*)) 39 29 EOM 40 30 -
trunk/src/gmake/tests/scripts/functions/word
r285 r503 47 47 # Test error conditions 48 48 49 $makefile2 = &get_tmpfile; 50 51 open(MAKEFILE, "> $makefile2"); 52 print MAKEFILE <<'EOF'; 53 FOO = foo bar biz baz 49 run_make_test('FOO = foo bar biz baz 54 50 55 51 word-e1: ; @echo $(word ,$(FOO)) … … 59 55 wordlist-e1: ; @echo $(wordlist ,,$(FOO)) 60 56 wordlist-e2: ; @echo $(wordlist abc ,,$(FOO)) 61 wordlist-e3: ; @echo $(wordlist 1, 12a ,$(FOO)) 57 wordlist-e3: ; @echo $(wordlist 1, 12a ,$(FOO))', 58 'word-e1', 59 "#MAKEFILE#:3: *** non-numeric first argument to `word' function: ''. Stop.", 60 512); 62 61 63 EOF 62 run_make_test(undef, 63 'word-e2', 64 "#MAKEFILE#:4: *** non-numeric first argument to `word' function: 'abc '. Stop.", 65 512); 64 66 65 close(MAKEFILE); 67 run_make_test(undef, 68 'word-e3', 69 "#MAKEFILE#:5: *** non-numeric first argument to `word' function: '1a'. Stop.", 70 512); 66 71 67 &run_make_with_options($makefile2, 'word-e1', &get_logfile, 512); 68 $answer = "$makefile2:3: *** non-numeric first argument to `word' function: ''. Stop.\n"; 69 &compare_output($answer, &get_logfile(1)); 72 run_make_test(undef, 73 'wordlist-e1', 74 "#MAKEFILE#:7: *** non-numeric first argument to `wordlist' function: ''. Stop.", 75 512); 70 76 71 &run_make_with_options($makefile2, 'word-e2', &get_logfile, 512); 72 $answer = "$makefile2:4: *** non-numeric first argument to `word' function: 'abc '. Stop.\n"; 73 &compare_output($answer, &get_logfile(1)); 77 run_make_test(undef, 78 'wordlist-e2', 79 "#MAKEFILE#:8: *** non-numeric first argument to `wordlist' function: 'abc '. Stop.", 80 512); 74 81 75 &run_make_with_options($makefile2, 'word-e3', &get_logfile, 512); 76 $answer = "$makefile2:5: *** non-numeric first argument to `word' function: '1a'. Stop.\n"; 77 &compare_output($answer, &get_logfile(1)); 82 run_make_test(undef, 83 'wordlist-e3', 84 "#MAKEFILE#:9: *** non-numeric second argument to `wordlist' function: ' 12a '. Stop.", 85 512); 78 86 79 &run_make_with_options($makefile2, 'wordlist-e1', &get_logfile, 512); 80 $answer = "$makefile2:7: *** non-numeric first argument to `wordlist' function: ''. Stop.\n"; 81 &compare_output($answer, &get_logfile(1)); 87 # Test error conditions again, but this time in a variable reference 82 88 83 &run_make_with_options($makefile2, 'wordlist-e2', &get_logfile, 512); 84 $answer = "$makefile2:8: *** non-numeric first argument to `wordlist' function: 'abc '. Stop.\n"; 85 &compare_output($answer, &get_logfile(1)); 89 run_make_test('FOO = foo bar biz baz 86 90 87 &run_make_with_options($makefile2, 'wordlist-e3', &get_logfile, 512); 88 $answer = "$makefile2:9: *** non-numeric second argument to `wordlist' function: ' 12a '. Stop.\n"; 89 &compare_output($answer, &get_logfile(1)); 91 W = $(word $x,$(FOO)) 92 WL = $(wordlist $s,$e,$(FOO)) 93 94 word-e: ; @echo $(W) 95 wordlist-e: ; @echo $(WL)', 96 'word-e x=', 97 "#MAKEFILE#:3: *** non-numeric first argument to `word' function: ''. Stop.", 98 512); 99 100 run_make_test(undef, 101 'word-e x=abc', 102 "#MAKEFILE#:3: *** non-numeric first argument to `word' function: 'abc'. Stop.", 103 512); 104 105 run_make_test(undef, 106 'word-e x=0', 107 "#MAKEFILE#:3: *** first argument to `word' function must be greater than 0. Stop.", 108 512); 109 110 run_make_test(undef, 111 'wordlist-e s= e=', 112 "#MAKEFILE#:4: *** non-numeric first argument to `wordlist' function: ''. Stop.", 113 512); 114 115 run_make_test(undef, 116 'wordlist-e s=abc e=', 117 "#MAKEFILE#:4: *** non-numeric first argument to `wordlist' function: 'abc'. Stop.", 118 512); 119 120 run_make_test(undef, 121 'wordlist-e s=4 e=12a', 122 "#MAKEFILE#:4: *** non-numeric second argument to `wordlist' function: '12a'. Stop.", 123 512); 124 125 run_make_test(undef, 126 'wordlist-e s=0 e=12', 127 "#MAKEFILE#:4: *** invalid first argument to `wordlist' function: `0'. Stop.", 128 512); 90 129 91 130
Note:
See TracChangeset
for help on using the changeset viewer.