source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/src/etc/testcases/taskdefs/optional/unix/symlink.xml@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 11.1 KB
Line 
1<?xml version="1.0"?>
2
3<!--
4
5/*
6 * Since the initial version of this file was deveolped on the clock on
7 * an NSF grant I should say the following boilerplate:
8 *
9 * This material is based upon work supported by the National Science
10 * Foundaton under Grant No. EIA-0196404. Any opinions, findings, and
11 * conclusions or recommendations expressed in this material are those
12 * of the author and do not necessarily reflect the views of the
13 * National Science Foundation.
14 */
15
16-->
17
18<project name="symlink-test" basedir="." default="all">
19
20 <!--
21 Since the symlink task and some of these targets rely on
22 calls to exec, it may be possible for the JVM to outrun the
23 execution of the command line system calls, so this value is
24 the number of seconds we give the operating system to
25 catch up before executing a task that depends on the
26 completion of previous tasks. This delay is also added to
27 the end of each target so junit doesn't go testing things
28 before they have finnished (hopefully). Tweak if needed.
29 -->
30
31 <property name="delay" value="3"/>
32
33 <property name="tdir" value="${basedir}/test-working"/>
34
35 <target name="setup">
36 <delete dir="${tdir}"/>
37 <mkdir dir="${tdir}"/>
38 </target>
39
40 <!-- test for action = single -->
41 <!--
42 Creates:
43 File: ${tdir}/symlink.test
44 Link: ${tdir}/singletest
45 -->
46 <target name="test-single">
47 <touch file="${tdir}/symlink.test"/>
48 <symlink resource="${tdir}/symlink.test"
49 link="${tdir}/singletest"
50 failonerror="yes"/>
51 <sleep seconds="${delay}"/> <!-- make sure OS has time to catch up -->
52 <available file="${tdir}/symlink.test"
53 property="test.single.file.created"/>
54 <available file="${tdir}/singletest"
55 property="test.single.link.created"/>
56 </target>
57
58
59
60 <!-- test for action = delete (no calls to command line so no sleep) -->
61
62 <!--
63 Creates:
64 (none)
65 Deletes:
66 Link: ${tdir}/singletest
67 -->
68
69 <target name="test-delete">
70 <touch file="${tdir}/symlink.test"/>
71 <symlink resource="${tdir}/symlink.test"
72 link="${tdir}/singletest"
73 failonerror="yes"/>
74 <sleep seconds="${delay}"/> <!-- make sure OS has time to catch up -->
75
76 <symlink action="delete" link="${tdir}/singletest" failonerror="yes"/>
77 <symlink action="delete" link="${tdir}/symlink.test" failonerror="no"/>
78 <sleep seconds="${delay}"/> <!-- make sure OS has time to catch up -->
79
80 <available file="${tdir}/symlink.test"
81 property="test.delete.file.still.there"/>
82 <available file="${tdir}/singletest"
83 property="test.delete.link.still.there"
84 value="ERROR: link deletion failed"/>
85
86 </target>
87
88
89
90 <!-- test for action = record -->
91
92 <!--
93 Creates:
94 Dir: ${tdir}/symtest1
95 Dir: ${tdir}/symtest1/symtest2
96 Dir: ${tdir}/symtest1/symtest3
97 File: ${tdir}/symtest1/file1
98 File: ${tdir}/symtest1/symtest2/file2
99 File: ${tdir}/symtest1/symtest3/fileA
100 File: ${tdir}/symtest1/symtest3/fileB
101 File: ${tdir}/symtest1/symtest3/fileC
102 Link: ${tdir}/symtest1/link1==>${tdir}/symtest1/file1
103 Link: ${tdir}/symtest1/link2==>${tdir}/symtest1/symtest2/file2
104 Link: ${tdir}/symtest1/symtest2/link3==>
105 ${tdir}/symtest1/symtest2/file2
106 Link: ${tdir}/symtest1/dirlink==>${tdir}/symtest1/symtest3
107 Link: ${tdir}/symtest1/dirlink2==>${tdir}/symtest1/symtest3
108 Link: ${tdir}/symtest1/dirlink3==>${tdir}/symtest1/symtest3
109 File: ${tdir}/symtest1/recorded.links
110 File: ${tdir}/symtest1/symtest2/recorded.links
111 Deletes:
112 (none)
113 -->
114
115 <target name="test-record">
116
117 <mkdir dir="${tdir}/symtest1"/>
118 <mkdir dir="${tdir}/symtest1/symtest2"/>
119 <mkdir dir="${tdir}/symtest1/symtest3"/>
120 <touch file="${tdir}/symtest1/file1"/>
121 <touch file="${tdir}/symtest1/symtest2/file2"/>
122
123 <touch file="${tdir}/symtest1/symtest3/fileA"/>
124 <touch file="${tdir}/symtest1/symtest3/fileB"/>
125 <touch file="${tdir}/symtest1/symtest3/fileC"/>
126
127 <symlink resource="${tdir}/symtest1/file1"
128 link="${tdir}/symtest1/link1"
129 failonerror="no" />
130 <symlink resource="${tdir}/symtest1/symtest2/file2"
131 link="${tdir}/symtest1/link2"
132 failonerror="no" />
133 <symlink resource="${tdir}/symtest1/symtest2/file2"
134 link="${tdir}/symtest1/symtest2/link3"
135 failonerror="no" />
136 <symlink resource="${tdir}/symtest1/symtest3"
137 link="${tdir}/symtest1/dirlink"
138 failonerror="no" />
139 <symlink resource="${tdir}/symtest1/symtest3"
140 link="${tdir}/symtest1/dirlink2"
141 failonerror="no"/>
142 <symlink resource="${tdir}/symtest1/symtest3"
143 link="${tdir}/symtest1/dirlink3"
144 failonerror="no"/>
145
146 <sleep seconds="${delay}"/> <!-- make sure OS has time to catch up -->
147
148 <symlink action="record" linkfilename="recorded.links">
149 <fileset dir="${tdir}/symtest1" includes="**/**"/>
150 </symlink>
151
152 <sleep seconds="${delay}"/> <!-- make sure OS has time to catch up -->
153
154 <!-- Test to see if the directories were created -->
155
156 <available file="${tdir}/symtest1"
157 type="dir"
158 property="test.record.dir1.created"/>
159
160 <available file="${tdir}/symtest1/symtest2"
161 type="dir"
162 property="test.record.dir2.created"/>
163
164 <available file="${tdir}/symtest1/symtest3"
165 type="dir"
166 property="test.record.dir3.created"/>
167
168 <!-- Test to see if the Files were created -->
169
170 <available file="${tdir}/symtest1/file1"
171 property="test.record.file1.created"/>
172
173 <available file="${tdir}/symtest1/symtest2/file2"
174 property="test.record.file2.created"/>
175
176 <available file="${tdir}/symtest1/symtest3/fileA"
177 property="test.record.fileA.created"/>
178
179 <available file="${tdir}/symtest1/symtest3/fileB"
180 property="test.record.fileB.created"/>
181
182 <available file="${tdir}/symtest1/symtest3/fileC"
183 property="test.record.fileC.created"/>
184
185 <!-- Test to see if the links were created -->
186
187 <available file="${tdir}/symtest1/link1"
188 property="test.record.link1.created"/>
189
190 <available file="${tdir}/symtest1/link2"
191 property="test.record.link2.created"/>
192
193 <available file="${tdir}/symtest1/symtest2/link3"
194 property="test.record.link3.created"/>
195
196 <available file="${tdir}/symtest1/dirlink"
197 property="test.record.dirlink.created"/>
198
199 <!-- this is redundant for this test, but used in the recreate test -->
200
201 <available file="${tdir}/symtest1/dirlink2"
202 property="test.record.dirlink2.created"/>
203
204 <!-- Test to see if the linkfiles were created -->
205
206 <available file="${tdir}/symtest1/recorded.links"
207 property="test.record.dir1.recorded"/>
208
209 <available file="${tdir}/symtest1/symtest2/recorded.links"
210 property="test.record.dir2.recorded"/>
211
212 <!-- THIS should not be set -->
213
214 <available file="${tdir}/symtest1/symtest3/recorded.links"
215 property="test.record.dir3.recorded"
216 value="ERROR: symtest3/recorded.links should not exist"/>
217
218
219 </target>
220
221 <!-- test for action = recreate -->
222
223 <!--
224 Deletes:
225 Link: ${tdir}/symtest1/link1==>${tdir}/symtest1/file1
226 Link: ${tdir}/symtest1/link2==>${tdir}/symtest1/symtest2/file2
227 Link: ${tdir}/symtest1/symtest2/link3==>
228 ${tdir}/symtest1/symtest2/file2
229 Link: ${tdir}/symtest1/dirlink==>${tdir}/symtest1/symtest3
230 Link: ${tdir}/symtest1/dirlink3==>${tdir}/symtest1/symtest3
231
232 Creates
233 Link: ${tdir}/symtest1/dirlink3==>${tdir}/symtest1/symtest2
234
235 Recreates:
236 Link: ${tdir}/symtest1/link1==>${tdir}/symtest1/file1
237 Link: ${tdir}/symtest1/link2==>${tdir}/symtest1/symtest2/file2
238 Link: ${tdir}/symtest1/symtest2/link3==>
239 ${tdir}/symtest1/symtest2/file2
240 Link: ${tdir}/symtest1/dirlink==>${tdir}/symtest1/symtest3
241
242 Should Change:
243 Link: ${tdir}/symtest1/dirlink3==>${tdir}/symtest1/symtest2
244 to
245 ${tdir}/symtest1/dirlink3==>${tdir}/symtest1/symtest3
246
247 Should Not Create (bug 25181):
248 Link: ${tdir}/symtest1/symtest3/dirlink2==>${tdir}/symtest1/symtest3
249 -->
250
251 <target name="test-recreate" depends="test-record">
252
253 <symlink action="delete" link="${tdir}/symtest1/link1"/>
254 <symlink action="delete" link="${tdir}/symtest1/link2"/>
255 <symlink action="delete" link="${tdir}/symtest1/symtest2/link3"/>
256 <symlink action="delete" link="${tdir}/symtest1/dirlink"/>
257 <!-- dirlink2 intentionally not deleted to test bug 25181 -->
258 <symlink action="delete" link="${tdir}/symtest1/dirlink3"/>
259
260 <sleep seconds="${delay}"/> <!-- make sure OS has time to catch up -->
261
262 <symlink resource="${tdir}/symtest1/symtest2"
263 link="${tdir}/symtest1/dirlink3"
264 failonerror="no"/>
265
266 <sleep seconds="${delay}"/> <!-- make sure OS has time to catch up -->
267
268 <available file="${tdir}/symtest1/link1"
269 property="test.recreate.link1.not.removed"
270 value="ERROR: rm -f symtest1/link1 failed"/>
271
272 <available file="${tdir}/symtest1/link2"
273 property="test.recreate.link2.not.removed"
274 value="ERROR: rm -f symtest1/link2 failed"/>
275
276 <available file="${tdir}/symtest1/symtest2/link3"
277 property="test.recreate.link3.not.removed"
278 value="ERROR: rm -f symtest1/symtest2/link3 failed"/>
279
280 <available file="${tdir}/symtest1/zdirlink"
281 property="test.recreate.zdirlink.not.removed"
282 value="ERROR: rm -f symtest1/zdirlink failed"/>
283
284 <sleep seconds="${delay}"/> <!-- make sure OS has time to do the execs -->
285
286 <symlink action="recreate">
287 <fileset dir="${tdir}/symtest1" includes="**/recorded.links"/>
288 </symlink>
289
290 <sleep seconds="${delay}"/> <!-- make sure OS has time to catch up -->
291
292 <available file="${tdir}/symtest1/link1"
293 property="test.recreate.link1.recreated"/>
294
295 <available file="${tdir}/symtest1/link2"
296 property="test.recreate.link2.recreated"/>
297
298 <available file="${tdir}/symtest1/symtest2/link3"
299 property="test.recreate.link3.recreated"/>
300
301 <available file="${tdir}/symtest1/dirlink"
302 property="test.recreate.dirlink.recreated"/>
303
304 <!-- this should not get set -->
305 <available file="${tdir}/symtest1/symtest3/symtest3"
306 property="test.recreate.dirlink2.recreated.twice"
307 value="ERROR: dirlink2 was created a second time (bug 25181)"/>
308
309 <touch file="${tdir}/symtest1/dirlink3/WhereAmI"/>
310
311 <sleep seconds="${delay}"/> <!-- make sure OS has time to do the execs -->
312
313 <available file="${tdir}/symtest1/symtest3/WhereAmI"
314 property="test.recreate.dirlink3.was.altered"/>
315 </target>
316
317
318<!-- CALL THIS to clean things up afterwards -->
319
320 <target name="teardown">
321 <delete dir="${tdir}"/>
322 </target>
323
324</project>
Note: See TracBrowser for help on using the repository browser.