diff options
Diffstat (limited to 'regress/sftp-cmds.sh')
-rw-r--r-- | regress/sftp-cmds.sh | 109 |
1 files changed, 102 insertions, 7 deletions
diff --git a/regress/sftp-cmds.sh b/regress/sftp-cmds.sh index 462c6802f..1256aeb2d 100644 --- a/regress/sftp-cmds.sh +++ b/regress/sftp-cmds.sh | |||
@@ -1,17 +1,42 @@ | |||
1 | # $OpenBSD: sftp-cmds.sh,v 1.2 2003/01/10 07:52:41 djm Exp $ | 1 | # $OpenBSD: sftp-cmds.sh,v 1.5 2003/07/19 00:46:31 djm Exp $ |
2 | # Placed in the Public Domain. | 2 | # Placed in the Public Domain. |
3 | 3 | ||
4 | # XXX - TODO: | 4 | # XXX - TODO: |
5 | # - globbed operations | ||
6 | # - chmod / chown / chgrp | 5 | # - chmod / chown / chgrp |
7 | # - -p flag for get & put | 6 | # - -p flag for get & put |
8 | 7 | ||
9 | tid="sftp commands" | 8 | tid="sftp commands" |
10 | 9 | ||
11 | DATA=/bin/ls | 10 | DATA=/bin/ls${EXEEXT} |
12 | COPY=${OBJ}/copy | 11 | COPY=${OBJ}/copy |
13 | 12 | # test that these files are readable! | |
14 | rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${BATCH}.* | 13 | for i in `(cd /bin;echo l*)` |
14 | do | ||
15 | if [ -r $i ]; then | ||
16 | GLOBFILES="$GLOBFILES $i" | ||
17 | fi | ||
18 | done | ||
19 | |||
20 | if have_prog uname | ||
21 | then | ||
22 | case `uname` in | ||
23 | CYGWIN*) | ||
24 | os=cygwin | ||
25 | ;; | ||
26 | *) | ||
27 | os=`uname` | ||
28 | ;; | ||
29 | esac | ||
30 | else | ||
31 | os="unknown" | ||
32 | fi | ||
33 | |||
34 | # Path with embedded quote | ||
35 | QUOTECOPY=${COPY}".\"blah\"" | ||
36 | QUOTECOPY_ARG=${COPY}'.\"blah\"' | ||
37 | |||
38 | rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${COPY}.dd2 | ||
39 | mkdir ${COPY}.dd | ||
15 | 40 | ||
16 | verbose "$tid: lls" | 41 | verbose "$tid: lls" |
17 | echo "lls ${OBJ}" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 42 | echo "lls ${OBJ}" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ |
@@ -54,21 +79,91 @@ echo "get $DATA $COPY" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | |||
54 | || fail "get failed" | 79 | || fail "get failed" |
55 | cmp $DATA ${COPY} || fail "corrupted copy after get" | 80 | cmp $DATA ${COPY} || fail "corrupted copy after get" |
56 | 81 | ||
82 | rm -f ${COPY}.dd/* | ||
83 | verbose "$tid: get to directory" | ||
84 | echo "get $DATA ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | ||
85 | || fail "get failed" | ||
86 | cmp $DATA ${COPY}.dd/`basename $DATA` || fail "corrupted copy after get" | ||
87 | |||
88 | rm -f ${COPY}.dd/* | ||
89 | verbose "$tid: glob get to directory" | ||
90 | echo "get /bin/l* ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | ||
91 | || fail "get failed" | ||
92 | for x in $GLOBFILES; do | ||
93 | cmp /bin/$x ${COPY}.dd/$x || fail "corrupted copy after get" | ||
94 | done | ||
95 | |||
96 | rm -f ${COPY}.dd/* | ||
97 | verbose "$tid: get to local dir" | ||
98 | (echo "lcd ${COPY}.dd"; echo "get $DATA" ) | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | ||
99 | || fail "get failed" | ||
100 | cmp $DATA ${COPY}.dd/`basename $DATA` || fail "corrupted copy after get" | ||
101 | |||
102 | rm -f ${COPY}.dd/* | ||
103 | verbose "$tid: glob get to local dir" | ||
104 | (echo "lcd ${COPY}.dd"; echo "get /bin/l*") | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | ||
105 | || fail "get failed" | ||
106 | for x in $GLOBFILES; do | ||
107 | cmp /bin/$x ${COPY}.dd/$x || fail "corrupted copy after get" | ||
108 | done | ||
109 | |||
57 | rm -f ${COPY} | 110 | rm -f ${COPY} |
58 | verbose "$tid: put" | 111 | verbose "$tid: put" |
59 | echo "put $DATA $COPY" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 112 | echo "put $DATA $COPY" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ |
60 | || fail "put failed" | 113 | || fail "put failed" |
61 | cmp $DATA ${COPY} || fail "corrupted copy after put" | 114 | cmp $DATA ${COPY} || fail "corrupted copy after put" |
62 | 115 | ||
116 | if [ "$os" != "cygwin" ]; then | ||
117 | rm -f ${QUOTECOPY} | ||
118 | verbose "$tid: put filename with quotes" | ||
119 | echo "put $DATA \"$QUOTECOPY_ARG\"" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | ||
120 | || fail "put failed" | ||
121 | cmp $DATA ${QUOTECOPY} || fail "corrupted copy after put with quotes" | ||
122 | fi | ||
123 | |||
124 | rm -f ${COPY}.dd/* | ||
125 | verbose "$tid: put to directory" | ||
126 | echo "put $DATA ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | ||
127 | || fail "put failed" | ||
128 | cmp $DATA ${COPY}.dd/`basename $DATA` || fail "corrupted copy after put" | ||
129 | |||
130 | rm -f ${COPY}.dd/* | ||
131 | verbose "$tid: glob put to directory" | ||
132 | echo "put /bin/l* ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | ||
133 | || fail "put failed" | ||
134 | for x in $GLOBFILES; do | ||
135 | cmp /bin/$x ${COPY}.dd/$x || fail "corrupted copy after put" | ||
136 | done | ||
137 | |||
138 | rm -f ${COPY}.dd/* | ||
139 | verbose "$tid: put to local dir" | ||
140 | (echo "cd ${COPY}.dd"; echo "put $DATA") | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | ||
141 | || fail "put failed" | ||
142 | cmp $DATA ${COPY}.dd/`basename $DATA` || fail "corrupted copy after put" | ||
143 | |||
144 | rm -f ${COPY}.dd/* | ||
145 | verbose "$tid: glob put to local dir" | ||
146 | (echo "cd ${COPY}.dd"; echo "put /bin/l*") | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | ||
147 | || fail "put failed" | ||
148 | for x in $GLOBFILES; do | ||
149 | cmp /bin/$x ${COPY}.dd/$x || fail "corrupted copy after put" | ||
150 | done | ||
151 | |||
63 | verbose "$tid: rename" | 152 | verbose "$tid: rename" |
64 | echo "rename $COPY ${COPY}.1" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 153 | echo "rename $COPY ${COPY}.1" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ |
65 | || fail "rename failed" | 154 | || fail "rename failed" |
66 | test -f ${COPY}.1 || fail "missing file after rename" | 155 | test -f ${COPY}.1 || fail "missing file after rename" |
67 | cmp $DATA ${COPY}.1 >/dev/null 2>&1 || fail "corrupted copy after rename" | 156 | cmp $DATA ${COPY}.1 >/dev/null 2>&1 || fail "corrupted copy after rename" |
68 | 157 | ||
158 | verbose "$tid: rename directory" | ||
159 | echo "rename ${COPY}.dd ${COPY}.dd2" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | ||
160 | || fail "rename directory failed" | ||
161 | test -d ${COPY}.dd && fail "oldname exists after rename directory" | ||
162 | test -d ${COPY}.dd2 || fail "missing newname after rename directory" | ||
163 | |||
69 | verbose "$tid: ln" | 164 | verbose "$tid: ln" |
70 | echo "ln ${COPY}.1 ${COPY}.2" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 || fail "ln failed" | 165 | echo "ln ${COPY}.1 ${COPY}.2" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 || fail "ln failed" |
71 | test -L ${COPY}.2 || fail "missing file after ln" | 166 | test -h ${COPY}.2 || fail "missing file after ln" |
72 | 167 | ||
73 | verbose "$tid: mkdir" | 168 | verbose "$tid: mkdir" |
74 | echo "mkdir ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 169 | echo "mkdir ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ |
@@ -95,6 +190,6 @@ verbose "$tid: lchdir" | |||
95 | echo "lchdir ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 190 | echo "lchdir ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ |
96 | || fail "lchdir failed" | 191 | || fail "lchdir failed" |
97 | 192 | ||
98 | rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${BATCH}.* | 193 | rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${COPY}.dd2 |
99 | 194 | ||
100 | 195 | ||