VirtualBox

source: kBuild/trunk/src/kmk/tests/scripts/targets/INTERMEDIATE@ 3140

Last change on this file since 3140 was 3140, checked in by bird, 7 years ago

kmk: Merged in changes from GNU make 4.2.1 (2e55f5e4abdc0e38c1d64be703b446695e70b3b6 / https://git.savannah.gnu.org/git/make.git).

  • Property svn:eol-style set to LF
File size: 3.0 KB
Line 
1# -*-perl-*-
2
3$description = "Test the behaviour of the .INTERMEDIATE target.";
4
5$details = "\
6Test the behavior of the .INTERMEDIATE special target.
7Create a makefile where a file would not normally be considered
8intermediate, then specify it as .INTERMEDIATE. Build and ensure it's
9deleted properly. Rebuild to ensure that it's not created if it doesn't
10exist but doesn't need to be built. Change the original and ensure
11that the intermediate file and the ultimate target are both rebuilt, and
12that the intermediate file is again deleted.
13
14Try this with implicit rules and explicit rules: both should work.\n";
15
16open(MAKEFILE,"> $makefile");
17
18print MAKEFILE <<'EOF';
19
20.INTERMEDIATE: foo.e bar.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 bar.e; cat $^ > $@
30EOF
31
32close(MAKEFILE);
33
34# TEST #0
35
36&utouch(-20, 'foo.f', 'bar.f');
37
38&run_make_with_options($makefile,'foo.d',&get_logfile);
39$answer = "cp foo.f foo.e\ncp foo.e foo.d\nrm foo.e\n";
40&compare_output($answer, &get_logfile(1));
41
42# TEST #1
43
44&run_make_with_options($makefile,'foo.d',&get_logfile);
45$answer = "$make_name: 'foo.d' is up to date.\n";
46&compare_output($answer, &get_logfile(1));
47
48# TEST #2
49
50&utouch(-10, 'foo.d');
51&touch('foo.f');
52
53&run_make_with_options($makefile,'foo.d',&get_logfile);
54$answer = "cp foo.f foo.e\ncp foo.e foo.d\nrm foo.e\n";
55&compare_output($answer, &get_logfile(1));
56
57# TEST #3
58# kmk+fast: differs because of different hashing.
59
60&run_make_with_options($makefile,'foo.c',&get_logfile);
61$answer = "cp foo.f foo.e\ncp bar.f bar.e\ncat foo.e bar.e > foo.c\n"
62 . (!$is_kmk && !$is_fast ? "rm bar.e foo.e\n" : "rm foo.e bar.e\n");
63&compare_output($answer, &get_logfile(1));
64
65# TEST #4
66
67&run_make_with_options($makefile,'foo.c',&get_logfile);
68$answer = "$make_name: 'foo.c' is up to date.\n";
69&compare_output($answer, &get_logfile(1));
70
71# TEST #5
72# kmk+fast: differs because of different hashing.
73
74&utouch(-10, 'foo.c');
75&touch('foo.f');
76
77&run_make_with_options($makefile,'foo.c',&get_logfile);
78$answer = "cp foo.f foo.e\ncp bar.f bar.e\ncat foo.e bar.e > foo.c\n"
79 . (!$is_kmk && !$is_fast ? "rm bar.e foo.e\n" : "rm foo.e bar.e\n");
80&compare_output($answer, &get_logfile(1));
81
82# TEST #6 -- added for PR/1669: don't remove files mentioned on the cmd line.
83
84&run_make_with_options($makefile,'foo.e',&get_logfile);
85$answer = "cp foo.f foo.e\n";
86&compare_output($answer, &get_logfile(1));
87
88unlink('foo.f', 'foo.e', 'foo.d', 'foo.c', 'bar.f', 'bar.e', 'bar.d', 'bar.c');
89
90# TEST #7 -- added for PR/1423
91
92$makefile2 = &get_tmpfile;
93
94open(MAKEFILE, "> $makefile2");
95
96print MAKEFILE <<'EOF';
97all: foo
98foo.a: ; touch $@
99%: %.a ; touch $@
100.INTERMEDIATE: foo.a
101EOF
102
103close(MAKEFILE);
104
105&run_make_with_options($makefile2, '-R', &get_logfile);
106$answer = "touch foo.a\ntouch foo\nrm foo.a\n";
107&compare_output($answer, &get_logfile(1));
108
109unlink('foo');
110
111# This tells the test driver that the perl test script executed properly.
1121;
Note: See TracBrowser for help on using the repository browser.

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