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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
202
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
1 #!/bin/bash
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
2
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
3 [ -f testing.sh ] && . testing.sh
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
4
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
5 #testing "name" "command" "result" "infile" "stdin"
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
6
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
7 testing "readlink missing" "readlink notfound || echo yes" "yes\n" "" ""
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
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
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
11 touch file
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
12 testing "readlink file" "readlink file || echo yes" "yes\n" "" ""
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
13 testing "readlink -f dir" "readlink -f ." "$(pwd)\n" "" ""
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 testing "readlink -f missing" "readlink -f notfound" "$(pwd)/notfound\n" "" ""
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
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
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
17 ln -s notfound link
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
18 testing "readlink link" "readlink link" "notfound\n" "" ""
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
19 testing "readlink link->missing" "readlink -f link" "$(pwd)/notfound\n" "" ""
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
20 ln -sf file link
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
21 testing "readlink -f link->file" "readlink -f link" "$(pwd)/file\n" "" ""
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
22 ln -sf . link
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
23 testing "readlink -f link->dir" "readlink -f link" "$(pwd)\n" "" ""
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
24 ln -snf link link
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
25 testing "readlink link->link (recursive)" "readlink link" "link\n" "" ""
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
26 testing "readlink -f link->link (recursive)" "readlink -f link || echo yes" \
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
27 "yes\n" "" ""
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
28 rm file link
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
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
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
32 ln -s link1 link2
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
33 ln -s link2 link1
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
34 testing "readlink follow recursive2" "readlink -f link1 || echo yes" \
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
35 "yes\n" "" ""
9134f2c1deb4 Basic tests for readlink.
Rob Landley <rob@landley.net>
parents:
diff changeset
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