VirtualBox

source: kBuild/trunk/src/gmakenew/tests/scripts/variables/flavors@ 903

Last change on this file since 903 was 285, checked in by bird, 20 years ago

This commit was generated by cvs2svn to compensate for changes in r284,
which included commits to RCS files with non-trunk default branches.

  • Property svn:eol-style set to native
File size: 3.1 KB
Line 
1# -*-perl-*-
2
3$description = "Test various flavors of make variable setting.";
4
5$details = "";
6
7open(MAKEFILE, "> $makefile");
8
9# The Contents of the MAKEFILE ...
10
11print MAKEFILE <<'EOF';
12foo = $(bar)
13bar = ${ugh}
14ugh = Hello
15
16all: multi ; @echo $(foo)
17
18multi: ; $(multi)
19
20x := foo
21y := $(x) bar
22x := later
23
24nullstring :=
25space := $(nullstring) $(nullstring)
26
27next: ; @echo $x$(space)$y
28
29define multi
30@echo hi
31echo there
32endef
33
34ifdef BOGUS
35define
36@echo error
37endef
38endif
39
40define outer
41 define inner
42 A = B
43 endef
44endef
45
46$(eval $(outer))
47
48outer: ; @echo $(inner)
49
50EOF
51
52# END of Contents of MAKEFILE
53
54close(MAKEFILE);
55
56# TEST #1
57# -------
58
59&run_make_with_options($makefile, "", &get_logfile);
60$answer = "hi\necho there\nthere\nHello\n";
61&compare_output($answer, &get_logfile(1));
62
63# TEST #2
64# -------
65
66&run_make_with_options($makefile, "next", &get_logfile);
67$answer = "later foo bar\n";
68&compare_output($answer, &get_logfile(1));
69
70# TEST #3
71# -------
72
73&run_make_with_options($makefile, "BOGUS=true", &get_logfile, 512);
74$answer = "$makefile:24: *** empty variable name. Stop.\n";
75&compare_output($answer, &get_logfile(1));
76
77# TEST #4
78# -------
79
80&run_make_with_options($makefile, "outer", &get_logfile);
81$answer = "A = B\n";
82&compare_output($answer, &get_logfile(1));
83
84# Clean up from "old style" testing. If all the above tests are converted to
85# run_make_test() syntax than this line can be removed.
86$makefile = undef;
87
88# -------------------------
89# Make sure that prefix characters apply properly to define/endef values.
90#
91# There's a bit of oddness here if you try to use a variable to hold the
92# prefix character for a define. Even though something like this:
93#
94# define foo
95# echo bar
96# endef
97#
98# all: ; $(V)$(foo)
99#
100# (where V=@) can be seen by the user to be obviously different than this:
101#
102# define foo
103# $(V)echo bar
104# endef
105#
106# all: ; $(foo)
107#
108# and the user thinks it should behave the same as when the "@" is literal
109# instead of in a variable, that can't happen because by the time make
110# expands the variables for the command line and sees it begins with a "@" it
111# can't know anymore whether the prefix character came before the variable
112# reference or was included in the first line of the variable reference.
113
114# TEST #5
115# -------
116
117run_make_test('
118define FOO
119$(V1)echo hello
120$(V2)echo world
121endef
122all: ; @$(FOO)
123', '', 'hello
124world');
125
126# TEST #6
127# -------
128
129run_make_test(undef, 'V1=@ V2=@', 'hello
130world');
131
132# TEST #7
133# -------
134
135run_make_test('
136define FOO
137$(V1)echo hello
138$(V2)echo world
139endef
140all: ; $(FOO)
141', 'V1=@', 'hello
142echo world
143world');
144
145# TEST #8
146# -------
147
148run_make_test(undef, 'V2=@', 'echo hello
149hello
150world');
151
152# TEST #9
153# -------
154
155run_make_test(undef, 'V1=@ V2=@', 'hello
156world');
157
158# TEST #10
159# -------
160# Test the basics; a "@" internally to the variable applies to only one line.
161# A "@" before the variable applies to the entire variable.
162
163run_make_test('
164define FOO
165@echo hello
166echo world
167endef
168define BAR
169echo hello
170echo world
171endef
172
173all: foo bar
174foo: ; $(FOO)
175bar: ; @$(BAR)
176', '', 'hello
177echo world
178world
179hello
180world
181');
182
1831;
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette