Mercurial > hg > toybox
annotate scripts/test/readlink.test @ 226:6aac63925eff
Update web pages.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 05 Jan 2008 18:09:49 -0600 |
parents | 98d1fc53b1c4 |
children | 0027cfa330da |
rev | line source |
---|---|
202 | 1 #!/bin/bash |
2 | |
3 [ -f testing.sh ] && . testing.sh | |
4 | |
5 #testing "name" "command" "result" "infile" "stdin" | |
6 | |
7 testing "readlink missing" "readlink notfound || echo yes" "yes\n" "" "" | |
8 | |
207
98d1fc53b1c4
A couple more readlink tests.
Rob Landley <rob@landley.net>
parents:
202
diff
changeset
|
9 # simple tests on a file |
98d1fc53b1c4
A couple more readlink tests.
Rob Landley <rob@landley.net>
parents:
202
diff
changeset
|
10 |
202 | 11 touch file |
12 testing "readlink file" "readlink file || echo yes" "yes\n" "" "" | |
13 testing "readlink -f dir" "readlink -f ." "$(pwd)\n" "" "" | |
14 testing "readlink -f missing" "readlink -f notfound" "$(pwd)/notfound\n" "" "" | |
15 | |
207
98d1fc53b1c4
A couple more readlink tests.
Rob Landley <rob@landley.net>
parents:
202
diff
changeset
|
16 # Test a link that points to nonexistent file |
202 | 17 ln -s notfound link |
18 testing "readlink link" "readlink link" "notfound\n" "" "" | |
19 testing "readlink link->missing" "readlink -f link" "$(pwd)/notfound\n" "" "" | |
20 ln -sf file link | |
21 testing "readlink -f link->file" "readlink -f link" "$(pwd)/file\n" "" "" | |
22 ln -sf . link | |
23 testing "readlink -f link->dir" "readlink -f link" "$(pwd)\n" "" "" | |
24 ln -snf link link | |
25 testing "readlink link->link (recursive)" "readlink link" "link\n" "" "" | |
26 testing "readlink -f link->link (recursive)" "readlink -f link || echo yes" \ | |
27 "yes\n" "" "" | |
28 rm file link | |
29 | |
207
98d1fc53b1c4
A couple more readlink tests.
Rob Landley <rob@landley.net>
parents:
202
diff
changeset
|
30 # Make sure circular links don't run away. |
98d1fc53b1c4
A couple more readlink tests.
Rob Landley <rob@landley.net>
parents:
202
diff
changeset
|
31 |
202 | 32 ln -s link1 link2 |
33 ln -s link2 link1 | |
34 testing "readlink follow recursive2" "readlink -f link1 || echo yes" \ | |
35 "yes\n" "" "" | |
36 rm link1 link2 | |
207
98d1fc53b1c4
A couple more readlink tests.
Rob Landley <rob@landley.net>
parents:
202
diff
changeset
|
37 |
98d1fc53b1c4
A couple more readlink tests.
Rob Landley <rob@landley.net>
parents:
202
diff
changeset
|
38 # Fun with relative paths |
98d1fc53b1c4
A couple more readlink tests.
Rob Landley <rob@landley.net>
parents:
202
diff
changeset
|
39 |
98d1fc53b1c4
A couple more readlink tests.
Rob Landley <rob@landley.net>
parents:
202
diff
changeset
|
40 ln -s /usr/include/sys/../sys newsys |
98d1fc53b1c4
A couple more readlink tests.
Rob Landley <rob@landley.net>
parents:
202
diff
changeset
|
41 ln -s newsys newsys2 |
98d1fc53b1c4
A couple more readlink tests.
Rob Landley <rob@landley.net>
parents:
202
diff
changeset
|
42 testing "readlink maintains relative paths" "readlink newsys" \ |
98d1fc53b1c4
A couple more readlink tests.
Rob Landley <rob@landley.net>
parents:
202
diff
changeset
|
43 "/usr/include/sys/../sys\n" "" "" |
98d1fc53b1c4
A couple more readlink tests.
Rob Landley <rob@landley.net>
parents:
202
diff
changeset
|
44 testing "readlink -f resolves relative path" "readlink -f newsys2/../stdio.h" \ |
98d1fc53b1c4
A couple more readlink tests.
Rob Landley <rob@landley.net>
parents:
202
diff
changeset
|
45 "/usr/include/stdio.h\n" "" "" |
98d1fc53b1c4
A couple more readlink tests.
Rob Landley <rob@landley.net>
parents:
202
diff
changeset
|
46 rm newsys newsys2 |