3 [ -f testing.sh ] && . testing.sh
5 #testing "name" "command" "result" "infile" "stdin"
9 testing "missing" "readlink notfound || echo yes" "yes\n" "" ""
11 # simple tests on a file
14 testing "file" "readlink file || echo yes" "yes\n" "" ""
15 testing "-f dir" "readlink -f ." "$APWD\n" "" ""
16 testing "-f missing" "readlink -f notfound" "$APWD/notfound\n" "" ""
19 testing "link" "readlink link" "notfound\n" "" ""
20 testing "link->missing" "readlink -f link" "$APWD/notfound\n" "" ""
22 testing "stays relative" "readlink link" "../../\n" "" ""
25 testing "-f link->file" "readlink -f link" "$APWD/file\n" "" ""
27 testing "-f link->dir" "readlink -f link" "$APWD\n" "" ""
29 testing "link->link (recursive)" "readlink link" "link\n" "" ""
30 testing "-f link->link (recursive)" \
31 "readlink -f link 2>/dev/null || echo yes" "yes\n" "" ""
33 testing "-q notlink" "readlink -q file || echo yes" "yes\n" "" ""
34 testing "-q link" "readlink -q link && echo yes" "yes\n" "" ""
35 testing "-q notfound" "readlink -q notfound || echo yes" "yes\n" "" ""
36 testing "-e found" "readlink -e file" "$APWD/file\n" "" ""
37 testing "-e notfound" \
38 "readlink -e notfound 2>/dev/null || echo yes" "yes\n" "" ""
39 testing "-nf ." "readlink -nf ." "$APWD" "" ""
44 touch sub/bang || exit 1
45 testing "-f multi" "readlink -f dir/../here/dir/bang" \
46 "$APWD/sub/bang\n" "" ""
47 testing "-f link/missing" "readlink -f dir/boing" \
48 "$APWD/sub/boing\n" "" ""
49 testing "-f /dev/null/file" \
50 "readlink -f /dev/null/file 2>/dev/null || echo yes" "yes\n" "" ""
51 ln -sf / link || exit 1
52 testing "-f link->/" "readlink -e link/dev" "/dev\n" "" ""
53 testing "-f /dev/null/.." \
54 "readlink -f link/null/.. 2>/dev/null || echo yes" "yes\n" "" ""
55 rm -f link && ln -sf link link || exit 1
56 testing "recurse" "readlink link" "link\n" "" ""
58 rm file link sub/bang dir here
61 # Make sure circular links don't run away.
65 testing "follow recursive2" "readlink -f link1 || echo yes" \