1 AT_BANNER([test dir_name and base_name functions])
3 m4_define([CHECK_FILE_NAME],
4 [AT_SETUP([components of "$1" are "$2", "$3"])
5 AT_KEYWORDS([dir_name base_name])
6 AT_CHECK([test-file_name "AS_ESCAPE($1)"], [0], [$2
11 # These are the test cases given in POSIX for dirname() and basename().
12 CHECK_FILE_NAME([/usr/lib], [/usr], [lib])
13 CHECK_FILE_NAME([/usr/], [/], [usr])
14 CHECK_FILE_NAME([usr], [.], [usr])
15 CHECK_FILE_NAME([/], [/], [/])
16 CHECK_FILE_NAME([.], [.], [.])
17 CHECK_FILE_NAME([..], [.], [..])
18 CHECK_FILE_NAME([//], [//], [//]) # / is also allowed
19 CHECK_FILE_NAME([//foo], [//], [foo]) # / is also allowed for dirname
20 CHECK_FILE_NAME([], [.], [.])
22 # Additional test cases.
23 CHECK_FILE_NAME([dir/file], [dir], [file])
24 CHECK_FILE_NAME([dir/file/], [dir], [file])
25 CHECK_FILE_NAME([dir/file//], [dir], [file])
26 CHECK_FILE_NAME([///foo], [/], [foo])
28 AT_BANNER([test follow_symlinks function])
30 m4_define([CHECK_FOLLOW],
31 [echo "check $1 -> $2"
32 AT_CHECK_UNQUOTED([test-util follow-symlinks "$1"], [0], [$2
36 AT_SETUP([follow_symlinks - relative symlinks])
39 AT_SKIP_IF([test ! -h source])
40 CHECK_FOLLOW([source], [target])
43 ln -s target2 dir/source2
44 CHECK_FOLLOW([dir/source2], [dir/target2])
50 CHECK_FOLLOW([a], [dir/dir2/d])
53 AT_SETUP([follow_symlinks - absolute symlinks])
55 ln -s "`pwd`/target" source
56 AT_SKIP_IF([test ! -h source])
57 CHECK_FOLLOW([source], [`pwd`/target])
60 ln -s "`pwd`/dir/target2" dir/source2
61 CHECK_FOLLOW([dir/source2], [`pwd`/dir/target2])
65 ln -s "`pwd`/dir/c" dir/b
66 ln -s "`pwd`/dir/dir2/d" dir/c
67 CHECK_FOLLOW([a], [`pwd`/dir/dir2/d])
70 AT_SETUP([follow_symlinks - symlinks to directories])
73 AT_SKIP_IF([test ! -h source])
75 CHECK_FOLLOW([source], [target])
76 CHECK_FOLLOW([source2], [target/])
78 # follow_symlinks() doesn't expand symlinks in the middle of a name.
80 CHECK_FOLLOW([source/x], [source/x])
83 AT_SETUP([follow_symlinks - nonexistent targets])
85 AT_SKIP_IF([test ! -h source])
86 CHECK_FOLLOW([source], [target])
87 CHECK_FOLLOW([target], [target])
88 CHECK_FOLLOW([target], [target])
91 AT_SETUP([follow_symlinks - regular files])
93 CHECK_FOLLOW([x], [x])
96 AT_SETUP([follow_symlinks - device targets])
97 AT_SKIP_IF([test ! -e /dev/null])
98 AT_SKIP_IF([test ! -e /dev/full])
101 CHECK_FOLLOW([x], [/dev/null])
102 CHECK_FOLLOW([y], [/dev/full])
105 AT_SETUP([follow_symlinks - nonexistent files])
106 CHECK_FOLLOW([nonexistent], [nonexistent])
107 CHECK_FOLLOW([a/b/c], [a/b/c])
108 CHECK_FOLLOW([/a/b/c], [/a/b/c])
109 CHECK_FOLLOW([//a/b/c], [//a/b/c])
112 AT_SETUP([follow_symlinks - symlink loop])
114 AT_SKIP_IF([test ! -h b])
116 AT_SKIP_IF([test ! -h a])
118 AT_CHECK([test-util follow-symlinks a], [0], [a
120 AT_CHECK([sed 's/^[[^|]]*|//' stderr], [0],
121 [00001|util|WARN|a: too many levels of symlinks