VirtualBox

source: kBuild/trunk/src/kmk/tests/scripts/targets/SECONDARY@ 969

Last change on this file since 969 was 969, checked in by bird, 18 years ago

Fixing some svn props.

  • Property svn:eol-style set to LF
File size: 2.7 KB
Line 
1#! -*-perl-*-
2
3$description = "Test the behaviour of the .SECONDARY target.";
4
5$details = "\
6Test the behavior of the .SECONDARY special target.
7Create a makefile where a file would not normally be considered
8intermediate, then specify it as .SECONDARY. Build and note that it's
9not automatically deleted. Delete the file. Rebuild to ensure that
10it's not created if it doesn't exist but doesn't need to be built.
11Change the original and ensure that the secondary file and the ultimate
12target are both rebuilt, and that the secondary file is not deleted.
13
14Try this with implicit rules and explicit rules: both should work.\n";
15
16open(MAKEFILE,"> $makefile");
17
18print MAKEFILE <<'EOF';
19
20.SECONDARY: foo.e
21
22# Implicit rule test
23%.d : %.e ; cp $< $@
24%.e : %.f ; cp $< $@
25
26foo.d: foo.e
27
28# Explicit rule test
29foo.c: foo.e ; cp $< $@
30EOF
31
32close(MAKEFILE);
33
34# TEST #1
35
36&utouch(-20, 'foo.f');
37
38&run_make_with_options($makefile,'foo.d',&get_logfile);
39$answer = "cp foo.f foo.e\ncp foo.e foo.d\n";
40&compare_output($answer, &get_logfile(1));
41
42# TEST #2
43
44unlink('foo.e');
45
46&run_make_with_options($makefile,'foo.d',&get_logfile);
47$answer = "$make_name: `foo.d' is up to date.\n";
48&compare_output($answer, &get_logfile(1));
49
50# TEST #3
51
52&utouch(-10, 'foo.d');
53&touch('foo.f');
54
55&run_make_with_options($makefile,'foo.d',&get_logfile);
56$answer = "cp foo.f foo.e\ncp foo.e foo.d\n";
57&compare_output($answer, &get_logfile(1));
58
59# TEST #4
60
61&run_make_with_options($makefile,'foo.c',&get_logfile);
62$answer = "cp foo.e foo.c\n";
63&compare_output($answer, &get_logfile(1));
64
65# TEST #5
66
67unlink('foo.e');
68
69&run_make_with_options($makefile,'foo.c',&get_logfile);
70$answer = "$make_name: `foo.c' is up to date.\n";
71&compare_output($answer, &get_logfile(1));
72
73# TEST #6
74
75&utouch(-10, 'foo.c');
76&touch('foo.f');
77
78&run_make_with_options($makefile,'foo.c',&get_logfile);
79$answer = "cp foo.f foo.e\ncp foo.e foo.c\n";
80&compare_output($answer, &get_logfile(1));
81
82unlink('foo.f', 'foo.e', 'foo.d', 'foo.c');
83
84# TEST #7 -- test the "global" .SECONDARY, with no targets.
85
86$makefile2 = &get_tmpfile;
87
88open(MAKEFILE, "> $makefile2");
89
90print MAKEFILE <<'EOF';
91.SECONDARY:
92
93final: intermediate
94intermediate: source
95
96final intermediate source:
97 echo $< > $@
98EOF
99
100close(MAKEFILE);
101
102&utouch(-10, 'source');
103touch('final');
104
105&run_make_with_options($makefile2, '', &get_logfile);
106$answer = "$make_name: `final' is up to date.\n";
107&compare_output($answer, &get_logfile(1));
108
109unlink('source', 'final', 'intermediate');
110
111
112# TEST #8 -- test the "global" .SECONDARY, with .PHONY.
113
114touch('version2');
115run_make_test('
116.PHONY: version
117.SECONDARY:
118version2: version ; @echo GOOD
119all: version2',
120 'all', 'GOOD');
121
122unlink('version2');
123
124# This tells the test driver that the perl test script executed properly.
1251;
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