diff options
Diffstat (limited to 'regress')
-rw-r--r-- | regress/sftp-cmds.sh | 47 | ||||
-rw-r--r-- | regress/sftp-glob.sh | 69 | ||||
-rw-r--r-- | regress/test-exec.sh | 17 |
3 files changed, 100 insertions, 33 deletions
diff --git a/regress/sftp-cmds.sh b/regress/sftp-cmds.sh index 78416735d..5625c5b26 100644 --- a/regress/sftp-cmds.sh +++ b/regress/sftp-cmds.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: sftp-cmds.sh,v 1.7 2006/08/29 09:44:00 djm Exp $ | 1 | # $OpenBSD: sftp-cmds.sh,v 1.8 2007/10/24 03:32:35 djm Exp $ |
2 | # Placed in the Public Domain. | 2 | # Placed in the Public Domain. |
3 | 3 | ||
4 | # XXX - TODO: | 4 | # XXX - TODO: |
@@ -34,6 +34,11 @@ fi | |||
34 | # Path with embedded quote | 34 | # Path with embedded quote |
35 | QUOTECOPY=${COPY}".\"blah\"" | 35 | QUOTECOPY=${COPY}".\"blah\"" |
36 | QUOTECOPY_ARG=${COPY}'.\"blah\"' | 36 | QUOTECOPY_ARG=${COPY}'.\"blah\"' |
37 | # File with spaces | ||
38 | SPACECOPY="${COPY} this has spaces.txt" | ||
39 | SPACECOPY_ARG="${COPY}\ this\ has\ spaces.txt" | ||
40 | # File with glob metacharacters | ||
41 | GLOBMETACOPY="${COPY} [metachar].txt" | ||
37 | 42 | ||
38 | rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${COPY}.dd2 | 43 | rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${COPY}.dd2 |
39 | mkdir ${COPY}.dd | 44 | mkdir ${COPY}.dd |
@@ -89,12 +94,27 @@ if [ "$os" != "cygwin" ]; then | |||
89 | rm -f ${QUOTECOPY} | 94 | rm -f ${QUOTECOPY} |
90 | cp $DATA ${QUOTECOPY} | 95 | cp $DATA ${QUOTECOPY} |
91 | verbose "$tid: get filename with quotes" | 96 | verbose "$tid: get filename with quotes" |
92 | echo "get \"$QUOTECOPY_ARG\" ${COPY}" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 97 | echo "get \"$QUOTECOPY_ARG\" ${COPY}" | \ |
93 | || fail "put failed" | 98 | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ || fail "get failed" |
94 | cmp ${COPY} ${QUOTECOPY} || fail "corrupted copy after get with quotes" | 99 | cmp ${COPY} ${QUOTECOPY} || fail "corrupted copy after get with quotes" |
95 | rm -f ${QUOTECOPY} ${COPY} | 100 | rm -f ${QUOTECOPY} ${COPY} |
96 | fi | 101 | fi |
97 | 102 | ||
103 | rm -f "$SPACECOPY" ${COPY} | ||
104 | cp $DATA "$SPACECOPY" | ||
105 | verbose "$tid: get filename with spaces" | ||
106 | echo "get ${SPACECOPY_ARG} ${COPY}" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | ||
107 | || fail "get failed" | ||
108 | cmp ${COPY} "$SPACECOPY" || fail "corrupted copy after get with spaces" | ||
109 | |||
110 | rm -f "$GLOBMETACOPY" ${COPY} | ||
111 | cp $DATA "$GLOBMETACOPY" | ||
112 | verbose "$tid: get filename with glob metacharacters" | ||
113 | echo "get \"${GLOBMETACOPY}\" ${COPY}" | \ | ||
114 | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 || fail "get failed" | ||
115 | cmp ${COPY} "$GLOBMETACOPY" || \ | ||
116 | fail "corrupted copy after get with glob metacharacters" | ||
117 | |||
98 | rm -f ${COPY}.dd/* | 118 | rm -f ${COPY}.dd/* |
99 | verbose "$tid: get to directory" | 119 | verbose "$tid: get to directory" |
100 | echo "get $DATA ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 120 | echo "get $DATA ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ |
@@ -125,18 +145,24 @@ done | |||
125 | 145 | ||
126 | rm -f ${COPY} | 146 | rm -f ${COPY} |
127 | verbose "$tid: put" | 147 | verbose "$tid: put" |
128 | echo "put $DATA $COPY" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 148 | echo "put $DATA $COPY" | \ |
129 | || fail "put failed" | 149 | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 || fail "put failed" |
130 | cmp $DATA ${COPY} || fail "corrupted copy after put" | 150 | cmp $DATA ${COPY} || fail "corrupted copy after put" |
131 | 151 | ||
132 | if [ "$os" != "cygwin" ]; then | 152 | if [ "$os" != "cygwin" ]; then |
133 | rm -f ${QUOTECOPY} | 153 | rm -f ${QUOTECOPY} |
134 | verbose "$tid: put filename with quotes" | 154 | verbose "$tid: put filename with quotes" |
135 | echo "put $DATA \"$QUOTECOPY_ARG\"" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 155 | echo "put $DATA \"$QUOTECOPY_ARG\"" | \ |
136 | || fail "put failed" | 156 | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 || fail "put failed" |
137 | cmp $DATA ${QUOTECOPY} || fail "corrupted copy after put with quotes" | 157 | cmp $DATA ${QUOTECOPY} || fail "corrupted copy after put with quotes" |
138 | fi | 158 | fi |
139 | 159 | ||
160 | rm -f "$SPACECOPY" | ||
161 | verbose "$tid: put filename with spaces" | ||
162 | echo "put $DATA ${SPACECOPY_ARG}" | \ | ||
163 | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 || fail "put failed" | ||
164 | cmp $DATA "$SPACECOPY" || fail "corrupted copy after put with spaces" | ||
165 | |||
140 | rm -f ${COPY}.dd/* | 166 | rm -f ${COPY}.dd/* |
141 | verbose "$tid: put to directory" | 167 | verbose "$tid: put to directory" |
142 | echo "put $DATA ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 168 | echo "put $DATA ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ |
@@ -172,8 +198,9 @@ test -f ${COPY}.1 || fail "missing file after rename" | |||
172 | cmp $DATA ${COPY}.1 >/dev/null 2>&1 || fail "corrupted copy after rename" | 198 | cmp $DATA ${COPY}.1 >/dev/null 2>&1 || fail "corrupted copy after rename" |
173 | 199 | ||
174 | verbose "$tid: rename directory" | 200 | verbose "$tid: rename directory" |
175 | echo "rename ${COPY}.dd ${COPY}.dd2" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 201 | echo "rename ${COPY}.dd ${COPY}.dd2" | \ |
176 | || fail "rename directory failed" | 202 | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 || \ |
203 | fail "rename directory failed" | ||
177 | test -d ${COPY}.dd && fail "oldname exists after rename directory" | 204 | test -d ${COPY}.dd && fail "oldname exists after rename directory" |
178 | test -d ${COPY}.dd2 || fail "missing newname after rename directory" | 205 | test -d ${COPY}.dd2 || fail "missing newname after rename directory" |
179 | 206 | ||
@@ -207,5 +234,5 @@ echo "lchdir ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | |||
207 | || fail "lchdir failed" | 234 | || fail "lchdir failed" |
208 | 235 | ||
209 | rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${COPY}.dd2 | 236 | rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${COPY}.dd2 |
210 | rm -rf ${QUOTECOPY} | 237 | rm -rf ${QUOTECOPY} "$SPACECOPY" "$GLOBMETACOPY" |
211 | 238 | ||
diff --git a/regress/sftp-glob.sh b/regress/sftp-glob.sh index e238356a2..d5ebf9fd6 100644 --- a/regress/sftp-glob.sh +++ b/regress/sftp-glob.sh | |||
@@ -1,28 +1,65 @@ | |||
1 | # $OpenBSD: sftp-glob.sh,v 1.1 2004/12/10 01:31:30 fgsch Exp $ | 1 | # $OpenBSD: sftp-glob.sh,v 1.2 2007/10/24 03:32:35 djm Exp $ |
2 | # Placed in the Public Domain. | 2 | # Placed in the Public Domain. |
3 | 3 | ||
4 | tid="sftp glob" | 4 | tid="sftp glob" |
5 | 5 | ||
6 | sftp_ls() { | ||
7 | target=$1 | ||
8 | errtag=$2 | ||
9 | expected=$3 | ||
10 | unexpected=$4 | ||
11 | verbose "$tid: $errtag" | ||
12 | $ECHOE "ls -l ${target}" | \ | ||
13 | ${SFTP} -b - -P ${SFTPSERVER} 2>/dev/null | \ | ||
14 | grep -v "^sftp>" > ${RESULTS} | ||
15 | if [ $? -ne 0 ]; then | ||
16 | fail "$errtag failed" | ||
17 | fi | ||
18 | if test "x$expected" != "x" && \ | ||
19 | ! fgrep "$expected" ${RESULTS} >/dev/null 2>&1 ; then | ||
20 | fail "$expected missing from $errtag results" | ||
21 | fi | ||
22 | if test "x$unexpected" != "x" && \ | ||
23 | fgrep "$unexpected" ${RESULTS} >/dev/null 2>&1 ; then | ||
24 | fail "$unexpected present in $errtag results" | ||
25 | fi | ||
26 | rm -f ${RESULTS} | ||
27 | } | ||
28 | |||
6 | BASE=${OBJ}/glob | 29 | BASE=${OBJ}/glob |
30 | RESULTS=${OBJ}/results | ||
7 | DIR=${BASE}/dir | 31 | DIR=${BASE}/dir |
8 | DATA=${DIR}/file | 32 | DATA=${DIR}/file |
9 | 33 | ||
34 | GLOB1="${DIR}/g-wild*" | ||
35 | GLOB2="${DIR}/g-wildx" | ||
36 | QUOTE="${DIR}/g-quote\"" | ||
37 | SLASH="${DIR}/g-sl\\ash" | ||
38 | ESLASH="${DIR}/g-slash\\" | ||
39 | QSLASH="${DIR}/g-qs\\\"" | ||
40 | SPACE="${DIR}/g-q space" | ||
41 | |||
10 | rm -rf ${BASE} | 42 | rm -rf ${BASE} |
11 | mkdir -p ${DIR} | 43 | mkdir -p ${DIR} |
12 | touch ${DATA} | 44 | touch "${DATA}" "${GLOB1}" "${GLOB2}" "${QUOTE}" |
13 | 45 | touch "${QSLASH}" "${ESLASH}" "${SLASH}" "${SPACE}" | |
14 | verbose "$tid: ls file" | 46 | |
15 | echo "ls -l ${DIR}/fil*" | ${SFTP} -P ${SFTPSERVER} 2>/dev/null | \ | 47 | # target message expected unexpected |
16 | grep ${DATA} >/dev/null 2>&1 | 48 | sftp_ls "${DIR}/fil*" "file glob" "${DATA}" "" |
17 | if [ $? -ne 0 ]; then | 49 | sftp_ls "${BASE}/d*" "dir glob" "`basename ${DATA}`" "" |
18 | fail "globbed ls file failed" | 50 | sftp_ls "${DIR}/g-wild\"*\"" "quoted glob" "g-wild*" "g-wildx" |
19 | fi | 51 | sftp_ls "${DIR}/g-wild\*" "escaped glob" "g-wild*" "g-wildx" |
20 | 52 | sftp_ls "${DIR}/g-quote\\\"" "escaped quote" "g-quote\"" "" | |
21 | verbose "$tid: ls dir" | 53 | sftp_ls "\"${DIR}/g-quote\\\"\"" "quoted quote" "g-quote\"" "" |
22 | echo "ls -l ${BASE}/d*" | ${SFTP} -P ${SFTPSERVER} 2>/dev/null | \ | 54 | sftp_ls "'${DIR}/g-quote\"'" "single-quoted quote" "g-quote\"" "" |
23 | grep file >/dev/null 2>&1 | 55 | sftp_ls "${DIR}/g-sl\\\\ash" "escaped slash" "g-sl\\ash" "" |
24 | if [ $? -ne 0 ]; then | 56 | sftp_ls "'${DIR}/g-sl\\\\ash'" "quoted slash" "g-sl\\ash" "" |
25 | fail "globbed ls dir failed" | 57 | sftp_ls "${DIR}/g-slash\\\\" "escaped slash at EOL" "g-slash\\" "" |
26 | fi | 58 | sftp_ls "'${DIR}/g-slash\\\\'" "quoted slash at EOL" "g-slash\\" "" |
59 | sftp_ls "${DIR}/g-qs\\\\\\\"" "escaped slash+quote" "g-qs\\\"" "" | ||
60 | sftp_ls "'${DIR}/g-qs\\\\\"'" "quoted slash+quote" "g-qs\\\"" "" | ||
61 | sftp_ls "${DIR}/g-q\\ space" "escaped space" "g-q space" "" | ||
62 | sftp_ls "'${DIR}/g-q space'" "quoted space" "g-q space" "" | ||
27 | 63 | ||
28 | rm -rf ${BASE} | 64 | rm -rf ${BASE} |
65 | |||
diff --git a/regress/test-exec.sh b/regress/test-exec.sh index 59ae33c08..650be419e 100644 --- a/regress/test-exec.sh +++ b/regress/test-exec.sh | |||
@@ -30,6 +30,9 @@ else | |||
30 | USER=`id -un` | 30 | USER=`id -un` |
31 | fi | 31 | fi |
32 | 32 | ||
33 | # XXX platforms that don't support -E may need a replacement | ||
34 | ECHOE="echo -E" | ||
35 | |||
33 | OBJ=$1 | 36 | OBJ=$1 |
34 | if [ "x$OBJ" = "x" ]; then | 37 | if [ "x$OBJ" = "x" ]; then |
35 | echo '$OBJ not defined' | 38 | echo '$OBJ not defined' |
@@ -156,31 +159,31 @@ cleanup () | |||
156 | 159 | ||
157 | trace () | 160 | trace () |
158 | { | 161 | { |
159 | echo "trace: $@" >>$TEST_SSH_LOGFILE | 162 | $ECHOE "trace: $@" >>$TEST_SSH_LOGFILE |
160 | if [ "X$TEST_SSH_TRACE" = "Xyes" ]; then | 163 | if [ "X$TEST_SSH_TRACE" = "Xyes" ]; then |
161 | echo "$@" | 164 | $ECHOE "$@" |
162 | fi | 165 | fi |
163 | } | 166 | } |
164 | 167 | ||
165 | verbose () | 168 | verbose () |
166 | { | 169 | { |
167 | echo "verbose: $@" >>$TEST_SSH_LOGFILE | 170 | $ECHOE "verbose: $@" >>$TEST_SSH_LOGFILE |
168 | if [ "X$TEST_SSH_QUIET" != "Xyes" ]; then | 171 | if [ "X$TEST_SSH_QUIET" != "Xyes" ]; then |
169 | echo "$@" | 172 | $ECHOE "$@" |
170 | fi | 173 | fi |
171 | } | 174 | } |
172 | 175 | ||
173 | 176 | ||
174 | fail () | 177 | fail () |
175 | { | 178 | { |
176 | echo "FAIL: $@" >>$TEST_SSH_LOGFILE | 179 | $ECHOE "FAIL: $@" >>$TEST_SSH_LOGFILE |
177 | RESULT=1 | 180 | RESULT=1 |
178 | echo "$@" | 181 | $ECHOE "$@" |
179 | } | 182 | } |
180 | 183 | ||
181 | fatal () | 184 | fatal () |
182 | { | 185 | { |
183 | echo "FATAL: $@" >>$TEST_SSH_LOGFILE | 186 | $ECHOE "FATAL: $@" >>$TEST_SSH_LOGFILE |
184 | echon "FATAL: " | 187 | echon "FATAL: " |
185 | fail "$@" | 188 | fail "$@" |
186 | cleanup | 189 | cleanup |