VirtualBox

source: kBuild/trunk/src/gmake/tests/scripts/features/order_only@ 285

最後變更 在這個檔案從285是 285,由 bird 提交於 20 年 前

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

  • 屬性 svn:eol-style 設為 native
檔案大小: 3.0 KB
 
1# -*-perl-*-
2$description = "Test order-only prerequisites.";
3
4$details = "\
5Create makefiles with various combinations of normal and order-only
6prerequisites and ensure they behave properly. Test the \$| variable.";
7
8open(MAKEFILE,"> $makefile");
9
10print MAKEFILE <<'EOF';
11foo: bar | baz
12 @echo '$$^ = $^'
13 @echo '$$| = $|'
14 touch $@
15
16.PHONY: baz
17
18bar baz:
19 touch $@
20EOF
21
22close(MAKEFILE);
23
24
25# TEST #1 -- just the syntax
26
27&run_make_with_options($makefile, "", &get_logfile);
28$answer = "touch bar\ntouch baz\n\$^ = bar\n\$| = baz\ntouch foo\n";
29&compare_output($answer,&get_logfile(1));
30
31
32# TEST #2 -- now we do it again: baz is PHONY but foo should _NOT_ be updated
33
34&run_make_with_options($makefile, "", &get_logfile);
35$answer = "touch baz\n";
36&compare_output($answer,&get_logfile(1));
37
38unlink(qw(foo bar baz));
39
40# Test prereqs that are both order and non-order
41
42$makefile2 = &get_tmpfile;
43
44open(MAKEFILE,"> $makefile2");
45
46print MAKEFILE <<'EOF';
47foo: bar | baz
48 @echo '$$^ = $^'
49 @echo '$$| = $|'
50 touch $@
51
52foo: baz
53
54.PHONY: baz
55
56bar baz:
57 touch $@
58EOF
59
60close(MAKEFILE);
61
62# TEST #3 -- Make sure the order-only prereq was promoted to normal.
63
64&run_make_with_options($makefile2, "", &get_logfile);
65$answer = "touch bar\ntouch baz\n\$^ = bar baz\n\$| = \ntouch foo\n";
66&compare_output($answer,&get_logfile(1));
67
68
69# TEST #4 -- now we do it again
70
71&run_make_with_options($makefile2, "", &get_logfile);
72$answer = "touch baz\n\$^ = bar baz\n\$| = \ntouch foo\n";
73&compare_output($answer,&get_logfile(1));
74
75unlink(qw(foo bar baz));
76
77# Test empty normal prereqs
78
79$makefile3 = &get_tmpfile;
80
81open(MAKEFILE,"> $makefile3");
82
83print MAKEFILE <<'EOF';
84foo:| baz
85 @echo '$$^ = $^'
86 @echo '$$| = $|'
87 touch $@
88
89.PHONY: baz
90
91baz:
92 touch $@
93EOF
94
95close(MAKEFILE);
96
97# TEST #5 -- make sure the parser was correct.
98
99&run_make_with_options($makefile3, "", &get_logfile);
100$answer = "touch baz\n\$^ = \n\$| = baz\ntouch foo\n";
101&compare_output($answer,&get_logfile(1));
102
103
104# TEST #6 -- now we do it again: this time foo won't be built
105
106&run_make_with_options($makefile3, "", &get_logfile);
107$answer = "touch baz\n";
108&compare_output($answer,&get_logfile(1));
109
110unlink(qw(foo baz));
111
112# Test order-only in pattern rules
113
114$makefile4 = &get_tmpfile;
115
116open(MAKEFILE,"> $makefile4");
117
118print MAKEFILE <<'EOF';
119%.w : %.x | baz
120 @echo '$$^ = $^'
121 @echo '$$| = $|'
122 touch $@
123
124all: foo.w
125
126.PHONY: baz
127foo.x baz:
128 touch $@
129EOF
130
131close(MAKEFILE);
132
133# TEST #7 -- make sure the parser was correct.
134
135&run_make_with_options($makefile4, "", &get_logfile);
136$answer = "touch foo.x\ntouch baz\n\$^ = foo.x\n\$| = baz\ntouch foo.w\n";
137&compare_output($answer,&get_logfile(1));
138
139# TEST #8 -- now we do it again: this time foo.w won't be built
140
141&run_make_with_options($makefile4, "", &get_logfile);
142$answer = "touch baz\n";
143&compare_output($answer,&get_logfile(1));
144
145unlink(qw(foo.w foo.x baz));
146
147# TEST #9 -- make sure that $< is set correctly in the face of order-only
148# prerequisites in pattern rules.
149
150run_make_test('
151%r: | baz ; @echo $< $^ $|
152bar: foo
153foo:;@:
154baz:;@:
155', '', "foo foo baz\n");
156
157
1581;
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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