|
1 # Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 # All rights reserved. |
|
3 # This component and the accompanying materials are made available |
|
4 # under the terms of the License "Eclipse Public License v1.0" |
|
5 # which accompanies this distribution, and is available |
|
6 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 # |
|
8 # Initial Contributors: |
|
9 # Nokia Corporation - initial contribution. |
|
10 # |
|
11 # Contributors: |
|
12 # |
|
13 # Description: |
|
14 # |
|
15 |
|
16 init() |
|
17 { |
|
18 let totalno=0; |
|
19 let passno=0; |
|
20 let failno=0; |
|
21 } |
|
22 |
|
23 preamble() |
|
24 { |
|
25 mkdir cdtest |
|
26 mkdir dirstest |
|
27 } |
|
28 |
|
29 test_cd2() |
|
30 { |
|
31 let totalno=totalno+1 |
|
32 echo "Test $totalno: cd with a directory name in restricted mode" |
|
33 setopt restricted |
|
34 cd cdtest |
|
35 if [ $ret -eq 1 ] |
|
36 then |
|
37 echo "PASS" |
|
38 let passno=passno+1 |
|
39 else |
|
40 echo "FAIL: Expected return value 1, but returned $ret" |
|
41 let failno=failno+1 |
|
42 fi |
|
43 } |
|
44 |
|
45 test_cd3() |
|
46 { |
|
47 let totalno=totalno+1 |
|
48 echo "Test $totalno: cd without any argument to change to home dir" |
|
49 cwd=`pwd` |
|
50 cd |
|
51 ret=$? |
|
52 if [ $ret -eq 0 ] |
|
53 then |
|
54 if [ $PWD = "C:" ] || [ $PWD = "Z:" ] |
|
55 then |
|
56 echo "PASS" |
|
57 let passno=passno+1 |
|
58 else |
|
59 echo "FAIL: Expected C: or Z:, but returned $PWD" |
|
60 let failno=failno+1 |
|
61 fi |
|
62 cd $cwd |
|
63 else |
|
64 echo "FAIL: Expected return value 0, but returned $ret" |
|
65 let failno=failno+1 |
|
66 fi |
|
67 } |
|
68 |
|
69 test_cd4() |
|
70 { |
|
71 let totalno=totalno+1 |
|
72 echo "Test $totalno: cd with - argument to change to previous dir" |
|
73 cwd=`pwd` |
|
74 cd cdtest |
|
75 cd - |
|
76 ret=$? |
|
77 if [ $ret -eq 0 ] |
|
78 then |
|
79 if [ $PWD = $cwd ] |
|
80 then |
|
81 echo "PASS" |
|
82 let passno=passno+1 |
|
83 else |
|
84 echo "FAIL: Expected $cwd, but returned $PWD" |
|
85 let failno=failno+1 |
|
86 fi |
|
87 cd $cwd |
|
88 else |
|
89 echo "FAIL: Expected return value 0, but returned $ret" |
|
90 let failno=failno+1 |
|
91 fi |
|
92 } |
|
93 |
|
94 test_cd5() |
|
95 { |
|
96 let totalno=totalno+1 |
|
97 echo "Test $totalno: cd with arg1 arg2 to replace the strings arg1 with arg2 in the current path and tries to change to that directory" |
|
98 cd dirstest |
|
99 cd test dest |
|
100 ret=$? |
|
101 if [ $ret -eq 1 ] |
|
102 then |
|
103 echo "PASS" |
|
104 let passno=passno+1 |
|
105 else |
|
106 echo "FAIL: Expected return value 1, but returned $ret" |
|
107 let failno=failno+1 |
|
108 fi |
|
109 cd .. |
|
110 } |
|
111 |
|
112 |
|
113 test_cd6() |
|
114 { |
|
115 let totalno=totalno+1 |
|
116 echo "Test $totalno: cd with +0 to change to inedxed entry in dirs stack" |
|
117 pushd dirstest |
|
118 mkdir new |
|
119 pushd new |
|
120 mkdir old |
|
121 pushd old |
|
122 cwd=`pwd` |
|
123 cd +0 |
|
124 ret=$? |
|
125 if [ $ret -eq 0 ] |
|
126 then |
|
127 if [ $PWD = $cwd ] |
|
128 then |
|
129 echo "PASS" |
|
130 let passno=passno+1 |
|
131 else |
|
132 echo "FAIL: Expected $cwd, but returned $PWD" |
|
133 let failno=failno+1 |
|
134 fi |
|
135 else |
|
136 echo "FAIL: Expected return value 0, but returned $ret" |
|
137 let failno=failno+1 |
|
138 fi |
|
139 popd |
|
140 rmdir old |
|
141 popd |
|
142 rmdir new |
|
143 popd |
|
144 } |
|
145 |
|
146 test_cd7() |
|
147 { |
|
148 let totalno=totalno+1 |
|
149 echo "Test $totalno: cd with +1 to change to inedxed entry in dirs stack" |
|
150 pushd dirstest |
|
151 mkdir new |
|
152 pushd new |
|
153 cwd=`pwd` |
|
154 mkdir old |
|
155 pushd old |
|
156 cd +1 |
|
157 ret=$? |
|
158 if [ $ret -eq 0 ] |
|
159 then |
|
160 if [ $PWD = $cwd ] |
|
161 then |
|
162 let passno=passno+1 |
|
163 else |
|
164 let failno=failno+1 |
|
165 fi |
|
166 else |
|
167 echo "FAIL: Expected return value 0, but returned $ret" |
|
168 let failno=failno+1 |
|
169 fi |
|
170 rmdir old |
|
171 popd |
|
172 rmdir new |
|
173 popd |
|
174 } |
|
175 |
|
176 |
|
177 test_cd8() |
|
178 { |
|
179 let totalno=totalno+1 |
|
180 echo "Test $totalno: cd with -0 to change to inedxed entry in dirs stack" |
|
181 cwd=`pwd` |
|
182 pushd dirstest |
|
183 mkdir new |
|
184 pushd new |
|
185 mkdir old |
|
186 pushd old |
|
187 cd -0 |
|
188 ret=$? |
|
189 if [ $ret -eq 0 ] |
|
190 then |
|
191 if [ $PWD = $cwd ] |
|
192 then |
|
193 echo "PASS" |
|
194 let passno=passno+1 |
|
195 else |
|
196 echo "FAIL: Expected $cwd, but returned $PWD" |
|
197 let failno=failno+1 |
|
198 fi |
|
199 else |
|
200 echo "FAIL: Expected return value 0, but returned $ret" |
|
201 let failno=failno+1 |
|
202 fi |
|
203 popd |
|
204 rmdir old |
|
205 popd |
|
206 rmdir new |
|
207 popd |
|
208 cd .. |
|
209 } |
|
210 |
|
211 test_cd9() |
|
212 { |
|
213 let totalno=totalno+1 |
|
214 echo "Test $totalno: cd with -1 to change to inedxed entry in dirs stack" |
|
215 pushd dirstest |
|
216 cwd=`pwd` |
|
217 mkdir new |
|
218 pushd new |
|
219 mkdir old |
|
220 pushd old |
|
221 cd -1 |
|
222 ret=$? |
|
223 if [ $ret -eq 0 ] |
|
224 then |
|
225 if [ $PWD = $cwd ] |
|
226 then |
|
227 echo "PASS" |
|
228 let passno=passno+1 |
|
229 else |
|
230 echo "FAIL: Expected $cwd, but returned $PWD" |
|
231 let failno=failno+1 |
|
232 fi |
|
233 else |
|
234 echo "FAIL: Expected return value 0, but returned $ret" |
|
235 let failno=failno+1 |
|
236 fi |
|
237 popd |
|
238 rmdir old |
|
239 cd .. |
|
240 rmdir new |
|
241 popd |
|
242 } |
|
243 |
|
244 test_cd10() |
|
245 { |
|
246 let totalno=totalno+1 |
|
247 echo "Test $totalno: cd with a -s directory name, not symbolic link" |
|
248 cd -s dirstest |
|
249 ret=$? |
|
250 if [ $ret -eq 0 ] |
|
251 then |
|
252 echo "PASS" |
|
253 let passno=passno+1 |
|
254 cd .. |
|
255 else |
|
256 echo "FAIL: Expected return value 0, but returned $ret" |
|
257 let failno=failno+1 |
|
258 fi |
|
259 } |
|
260 |
|
261 test_cd11() |
|
262 { |
|
263 let totalno=totalno+1 |
|
264 echo "Test $totalno: cd with a -P directory name, not symbolic link" |
|
265 cd -P dirstest |
|
266 ret=$? |
|
267 if [ $ret -eq 0 ] |
|
268 then |
|
269 let passno=passno+1 |
|
270 cd .. |
|
271 else |
|
272 echo "FAIL: Expected return value 0, but returned $ret" |
|
273 let failno=failno+1 |
|
274 fi |
|
275 } |
|
276 |
|
277 test_cd12() |
|
278 { |
|
279 let totalno=totalno+1 |
|
280 echo "Test $totalno: cd with a -L directory name, CHASE_LINKS not set and dir name is not symbolic link" |
|
281 cd -L dirstest |
|
282 ret=$? |
|
283 if [ $ret -eq 0 ] |
|
284 then |
|
285 echo "PASS" |
|
286 let passno=passno+1 |
|
287 cd .. |
|
288 else |
|
289 echo "FAIL: Expected return value 0, but returned $ret" |
|
290 let failno=failno+1 |
|
291 fi |
|
292 } |
|
293 |
|
294 test_cd13() |
|
295 { |
|
296 let totalno=totalno+1 |
|
297 echo "Test $totalno: cd with a -L directory name, CHASE_LINKS set and dir name is not symbolic link" |
|
298 setopt CHASE_LINKS |
|
299 cd -L dirstest |
|
300 ret=$? |
|
301 if [ $ret -eq 0 ] |
|
302 then |
|
303 echo "PASS" |
|
304 let passno=passno+1 |
|
305 cd .. |
|
306 else |
|
307 echo "FAIL: Expected return value 0, but returned $ret" |
|
308 let failno=failno+1 |
|
309 fi |
|
310 unsetopt CHASE_LINKS |
|
311 } |
|
312 |
|
313 test_cd14() |
|
314 { |
|
315 let totalno=totalno+1 |
|
316 echo "Test $totalno: cd with a "." as argument, cdpath set" |
|
317 cdpath=dirstest |
|
318 cd . |
|
319 if [ $ret -eq 0 ] |
|
320 then |
|
321 echo "PASS" |
|
322 let passno=passno+1 |
|
323 else |
|
324 echo "FAIL: Expected return value 0, but returned $ret" |
|
325 let failno=failno+1 |
|
326 fi |
|
327 cdpath= |
|
328 } |
|
329 |
|
330 test_cd15() |
|
331 { |
|
332 let totalno=totalno+1 |
|
333 echo "Test $totalno: cd with a ".," as argument, cdpath set" |
|
334 cdpath=dirstest |
|
335 cd ., |
|
336 ret=$? |
|
337 if [ $ret -eq 1 ] |
|
338 then |
|
339 echo "PASS" |
|
340 let passno=passno+1 |
|
341 else |
|
342 echo "FAIL: Expected return value 1, but returned $ret" |
|
343 let failno=failno+1 |
|
344 fi |
|
345 cdpath= |
|
346 } |
|
347 |
|
348 test_cd16() |
|
349 { |
|
350 let totalno=totalno+1 |
|
351 echo "Test $totalno: cd with a "../dirstest" as argument, cdpath set" |
|
352 cdpath=dirstest |
|
353 pwd |
|
354 cd dirstest |
|
355 cwd=`pwd` |
|
356 cd ../dirstest |
|
357 ret=$? |
|
358 if [ $ret -eq 0 ] |
|
359 then |
|
360 if [ $PWD = $cwd ] |
|
361 then |
|
362 echo "PASS" |
|
363 let passno=passno+1 |
|
364 else |
|
365 echo "FAIL: Expected $cwd, but returned $PWD" |
|
366 let failno=failno+1 |
|
367 fi |
|
368 else |
|
369 echo "FAIL: Expected return value 0, but returned $ret" |
|
370 let failno=failno+1 |
|
371 fi |
|
372 cdpath= |
|
373 cd .. |
|
374 } |
|
375 |
|
376 test_cd17() |
|
377 { |
|
378 let totalno=totalno+1 |
|
379 echo "Test $totalno: cd with a "/nonexistingdir" as argument" |
|
380 cd /popfdtest |
|
381 ret=$? |
|
382 if [ $ret -eq 1 ] |
|
383 then |
|
384 echo "PASS" |
|
385 let passno=passno+1 |
|
386 else |
|
387 echo "FAIL: Expected return value 1, but returned $ret" |
|
388 let failno=failno+1 |
|
389 fi |
|
390 } |
|
391 |
|
392 test_cd18() |
|
393 { |
|
394 let totalno=totalno+1 |
|
395 echo "Test $totalno: cd with a "nonexistingdir" as argument, cdpath being set" |
|
396 cdpath=dirstest |
|
397 cd popfdtest |
|
398 ret=$? |
|
399 if [ $ret -eq 1 ] |
|
400 then |
|
401 echo "PASS" |
|
402 let passno=passno+1 |
|
403 else |
|
404 echo "FAIL: Expected return value 1, but returned $ret" |
|
405 let failno=failno+1 |
|
406 fi |
|
407 cdpath= |
|
408 } |
|
409 |
|
410 postamble() |
|
411 { |
|
412 rmdir dirstest |
|
413 rmdir cdtest |
|
414 } |
|
415 report() |
|
416 { |
|
417 echo "#############################################################################" |
|
418 echo "Total tests : $totalno" |
|
419 echo "Passed : $passno" |
|
420 echo "Failed : $failno" |
|
421 echo "#############################################################################" |
|
422 } |
|
423 |
|
424 init |
|
425 preamble |
|
426 #test_cd2 |
|
427 test_cd3 |
|
428 test_cd4 |
|
429 test_cd5 |
|
430 test_cd6 |
|
431 test_cd7 |
|
432 test_cd8 |
|
433 test_cd9 |
|
434 test_cd10 |
|
435 test_cd11 |
|
436 test_cd12 |
|
437 test_cd13 |
|
438 test_cd14 |
|
439 test_cd15 |
|
440 test_cd16 |
|
441 test_cd17 |
|
442 test_cd18 |
|
443 postamble |
|
444 report |
|
445 |