summaryrefslogtreecommitdiff
path: root/testsuite/cp.tests
blob: e81939df558848c28e3b9db609f94139538c9660 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/bin/sh
# Copyright 2010 by Denys Vlasenko
# Licensed under GPL v2, see file LICENSE for details.

. ./testing.sh

# Opening quote in "omitting directory 'dir'" message:
sq='`'  # GNU cp: `
sq="'"  # bbox cp: '

rm -rf cp.testdir >/dev/null

mkdir cp.testdir
mkdir cp.testdir/dir
> cp.testdir/dir/file
ln -s file cp.testdir/dir/file_symlink

> cp.testdir/file
ln -s file cp.testdir/file_symlink
ln -s dir cp.testdir/dir_symlink


# testing "test name" "command" "expected result" "file input" "stdin"

rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
testing "cp" '\
cd cp.testdir || exit 1; cp * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
test ! -L file         && test   -f file             || echo BAD: file
test ! -L file_symlink && test   -f file_symlink     || echo BAD: file_symlink
test ! -L dir          && test ! -e dir              || echo BAD: dir
test ! -L dir_symlink  && test ! -e dir_symlink      || echo BAD: dir_symlink
' "\
cp: omitting directory ${sq}dir'
cp: omitting directory ${sq}dir_symlink'
1
" "" ""

rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
testing "cp -d" '\
cd cp.testdir || exit 1; cp -d * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
test ! -L file         && test   -f file             || echo BAD: file
test   -L file_symlink && test   -f file_symlink     || echo BAD: file_symlink
test ! -L dir          && test ! -e dir              || echo BAD: dir
test   -L dir_symlink  && test ! -e dir_symlink      || echo BAD: dir_symlink
' "\
cp: omitting directory ${sq}dir'
1
" "" ""

rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
testing "cp -P" '\
cd cp.testdir || exit 1; cp -P * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
test ! -L file         && test   -f file             || echo BAD: file
test   -L file_symlink && test   -f file_symlink     || echo BAD: file_symlink
test ! -L dir          && test ! -e dir              || echo BAD: dir
test   -L dir_symlink  && test ! -e dir_symlink      || echo BAD: dir_symlink
' "\
cp: omitting directory ${sq}dir'
1
" "" ""

rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
testing "cp -L" '\
cd cp.testdir || exit 1; cp -L * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
test ! -L file         && test   -f file             || echo BAD: file
test ! -L file_symlink && test   -f file_symlink     || echo BAD: file_symlink
test ! -L dir          && test ! -e dir              || echo BAD: dir
test ! -L dir_symlink  && test ! -e dir_symlink      || echo BAD: dir_symlink
' "\
cp: omitting directory ${sq}dir'
cp: omitting directory ${sq}dir_symlink'
1
" "" ""

rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
testing "cp -H" '\
cd cp.testdir || exit 1; cp -H * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
test ! -L file         && test   -f file             || echo BAD: file
test ! -L file_symlink && test   -f file_symlink     || echo BAD: file_symlink
test ! -L dir          && test ! -e dir              || echo BAD: dir
test ! -L dir_symlink  && test ! -e dir_symlink      || echo BAD: dir_symlink
' "\
cp: omitting directory ${sq}dir'
cp: omitting directory ${sq}dir_symlink'
1
" "" ""

rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
testing "cp -R" '\
cd cp.testdir || exit 1; cp -R * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
test ! -L file             && test   -f file             || echo BAD: file
test   -L file_symlink     && test   -f file_symlink     || echo BAD: file_symlink
test ! -L dir              && test   -d dir              || echo BAD: dir
test   -L dir_symlink      && test   -d dir_symlink      || echo BAD: dir_symlink
test ! -L dir/file         && test   -f dir/file         || echo BAD: dir/file
test   -L dir/file_symlink && test   -f dir/file_symlink || echo BAD: dir/file_symlink
' "\
0
" "" ""

rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
testing "cp -Rd" '\
cd cp.testdir || exit 1; cp -Rd * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
test ! -L file             && test   -f file             || echo BAD: file
test   -L file_symlink     && test   -f file_symlink     || echo BAD: file_symlink
test ! -L dir              && test   -d dir              || echo BAD: dir
test   -L dir_symlink      && test   -d dir_symlink      || echo BAD: dir_symlink
test ! -L dir/file         && test   -f dir/file         || echo BAD: dir/file
test   -L dir/file_symlink && test   -f dir/file_symlink || echo BAD: dir/file_symlink
' "\
0
" "" ""

rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
testing "cp -RP" '\
cd cp.testdir || exit 1; cp -RP * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
test ! -L file             && test   -f file             || echo BAD: file
test   -L file_symlink     && test   -f file_symlink     || echo BAD: file_symlink
test ! -L dir              && test   -d dir              || echo BAD: dir
test   -L dir_symlink      && test   -d dir_symlink      || echo BAD: dir_symlink
test ! -L dir/file         && test   -f dir/file         || echo BAD: dir/file
test   -L dir/file_symlink && test   -f dir/file_symlink || echo BAD: dir/file_symlink
' "\
0
" "" ""

rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
testing "cp -RL" '\
cd cp.testdir || exit 1; cp -RL * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
test ! -L file             && test   -f file             || echo BAD: file
test ! -L file_symlink     && test   -f file_symlink     || echo BAD: file_symlink
test ! -L dir              && test   -d dir              || echo BAD: dir
test ! -L dir_symlink      && test   -d dir_symlink      || echo BAD: dir_symlink
test ! -L dir/file         && test   -f dir/file         || echo BAD: dir/file
test ! -L dir/file_symlink && test   -f dir/file_symlink || echo BAD: dir/file_symlink
' "\
0
" "" ""

rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
# GNU coreutils 7.2 says:
# cp: will not create hard link `../cp.testdir2/dir_symlink' to directory `../cp.testdir2/dir'
test x"$SKIP_KNOWN_BUGS" = x"" && \
testing "cp -RH" '\
cd cp.testdir || exit 1; cp -RH * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
test ! -L file             && test   -f file             || echo BAD: file
test ! -L file_symlink     && test   -f file_symlink     || echo BAD: file_symlink
test ! -L dir              && test   -d dir              || echo BAD: dir
test ! -L dir_symlink      && test   -d dir_symlink      || echo BAD: dir_symlink
test ! -L dir/file         && test   -f dir/file         || echo BAD: dir/file
test   -L dir/file_symlink && test   -f dir/file_symlink || echo BAD: dir/file_symlink
' "\
0
" "" ""

rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
# GNU coreutils 7.2 says:
# cp: will not create hard link `../cp.testdir2/dir_symlink' to directory `../cp.testdir2/dir'
test x"$SKIP_KNOWN_BUGS" = x"" && \
testing "cp -RHP" '\
cd cp.testdir || exit 1; cp -RHP * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
test ! -L file             && test   -f file             || echo BAD: file
test ! -L file_symlink     && test   -f file_symlink     || echo BAD: file_symlink
test ! -L dir              && test   -d dir              || echo BAD: dir
test ! -L dir_symlink      && test   -d dir_symlink      || echo BAD: dir_symlink
test ! -L dir/file         && test   -f dir/file         || echo BAD: dir/file
test   -L dir/file_symlink && test   -f dir/file_symlink || echo BAD: dir/file_symlink
' "\
0
" "" ""

rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
testing "cp -RHL" '\
cd cp.testdir || exit 1; cp -RHL * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
test ! -L file             && test   -f file             || echo BAD: file
test ! -L file_symlink     && test   -f file_symlink     || echo BAD: file_symlink
test ! -L dir              && test   -d dir              || echo BAD: dir
test ! -L dir_symlink      && test   -d dir_symlink      || echo BAD: dir_symlink
test ! -L dir/file         && test   -f dir/file         || echo BAD: dir/file
test ! -L dir/file_symlink && test   -f dir/file_symlink || echo BAD: dir/file_symlink
' "\
0
" "" ""

rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
# Wow! "cp -RLH" is not the same as "cp -RHL" (prev test)!
# GNU coreutils 7.2 says:
# cp: will not create hard link `../cp.testdir2/dir_symlink' to directory `../cp.testdir2/dir'
test x"$SKIP_KNOWN_BUGS" = x"" && \
testing "cp -RLH" '\
cd cp.testdir || exit 1; cp -RLH * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
test ! -L file             && test   -f file             || echo BAD: file
test ! -L file_symlink     && test   -f file_symlink     || echo BAD: file_symlink
test ! -L dir              && test   -d dir              || echo BAD: dir
test ! -L dir_symlink      && test   -d dir_symlink      || echo BAD: dir_symlink
test ! -L dir/file         && test   -f dir/file         || echo BAD: dir/file
test ! -L dir/file_symlink && test   -f dir/file_symlink || echo BAD: dir/file_symlink
' "\
0
" "" ""


# Clean up
rm -rf cp.testdir cp.testdir2 2>/dev/null

exit $FAILCOUNT