Natools

Check-in [9bea00c392]
Login
Overview
Comment:tools/tests.sh: add a fully-covering test suite for `sxcat` tool
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9bea00c392f8482776e0a009776964be1f8ee0cf
User & Date: nat on 2014-08-01 20:35:51
Other Links: manifest | tags
Context
2014-08-02
21:19
sxcat: abort with error status on newline encoding parse error check-in: 2e6bc3b47c user: nat tags: trunk
2014-08-01
20:35
tools/tests.sh: add a fully-covering test suite for `sxcat` tool check-in: 9bea00c392 user: nat tags: trunk
2014-07-31
19:16
s_expressions-printers-pretty: fix width of tab-only indentations check-in: 78cfd91715 user: nat tags: trunk
Changes

Modified tools/tests.sh from [a89c6587cb] to [08f2e47615].

1
2
3
4
5
6
7
8
9
10


11
12
13
14
15
16
17
#!/bin/sh

: ${BIN_DIR:=${1:-$(dirname $0)}}
: ${TMP_TEMPLATE:=/tmp/tmp.XXXXXX}

RET_VAL="0"

if ! test -x ${BIN_DIR}/hmac-md5 \
   -o -x ${BIN_DIR}/hmac-sha1 \
   -o -x ${BIN_DIR}/hmac-sha256; then


	echo "Unable to find tested executables in ${BIN_DIR}, aborting" >&2
	exit 2
fi


####################
# Test of hmac-md5 #









|
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh

: ${BIN_DIR:=${1:-$(dirname $0)}}
: ${TMP_TEMPLATE:=/tmp/tmp.XXXXXX}

RET_VAL="0"

if ! test -x ${BIN_DIR}/hmac-md5 \
   -o -x ${BIN_DIR}/hmac-sha1 \
   -o -x ${BIN_DIR}/hmac-sha256 \
   -o -x ${BIN_DIR}/sxcat
then
	echo "Unable to find tested executables in ${BIN_DIR}, aborting" >&2
	exit 2
fi


####################
# Test of hmac-md5 #
86
87
88
89
90
91
92

























































































































































93
		RET_VAL="1"
	fi;
	rm "${TMP_FILE}"
else
	echo "${BIN_DIR}/hmac-sha256 not found"
fi


























































































































































exit ${RET_VAL}







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
		RET_VAL="1"
	fi;
	rm "${TMP_FILE}"
else
	echo "${BIN_DIR}/hmac-sha256 not found"
fi


#################
# Test of sxcat #
#################

if test -x ${BIN_DIR}/sxcat; then
	TMP_SRC1=$(mktemp "${TMP_TEMPLATE}")
	TMP_SRC2=$(mktemp "${TMP_TEMPLATE}")
	TMP_DEST=$(mktemp "${TMP_TEMPLATE}")
	TMP_EXPT=$(mktemp "${TMP_TEMPLATE}")

	${BIN_DIR}/sxcat -h >"${TMP_EXPT}"

	if ${BIN_DIR}/sxcat --indent mew >/dev/null 2>/dev/null \
	    || ${BIN_DIR}/sxcat --indent 3u >/dev/null 2>/dev/null \
	    || ${BIN_DIR}/sxcat -i 999999999999999999999 >/dev/null 2>/dev/null
	then
		echo "sxcat: unexpected success with invalid indentation"
		RET_VAL="1"
	fi

	if ${BIN_DIR}/sxcat --nl-encoding gl-hf >/dev/null 2>/dev/null \
	    || ${BIN_DIR}/sxcat --nl-encoding - >/dev/null 2>/dev/null
	then
		echo "sxcat: unexpected success with invalid newline encoding"
		RET_VAL="1"
	fi

	if ${BIN_DIR}/sxcat --width mu 2>"${TMP_DEST}" \
	    || ${BIN_DIR}/sxcat --tab-stop '' >/dev/null 2>/dev/null
	then
		echo "sxcat: unexpected success with invalid natural argument"
		RET_VAL="1"
	fi

	if ! diff -u "${TMP_EXPT}" "${TMP_DEST}"; then
		echo "sxcat: unexpected errror output"
		RET_VAL="1"
	fi

	echo "The lazy fox" >"${TMP_SRC1}"
	echo 0102030405060708 | xxd -r -p >"${TMP_SRC2}"
#	echo -n '"Test""The lazy fox\n"#0102030405060708#' >"${TMP_EXPT}"

	echo -n "13:" >"${TMP_EXPT}"
	cat "${TMP_SRC1}" >>"${TMP_EXPT}"
	echo -n "4:Test8:" >>"${TMP_EXPT}"
	cat "${TMP_SRC2}" >>"${TMP_EXPT}"

	if ! echo -n Test \
	    | ${BIN_DIR}/sxcat --atom --canonical \
	      "${TMP_SRC1}" - "${TMP_SRC2}" \
	    | diff -u "${TMP_EXPT}" -
	then
		echo "sxcat atom test 1 failed"
		RET_VAL="1"
	fi

	echo -n "|VGhlIGxhenkgZm94Cg==|" >"${TMP_EXPT}"
	if ! ${BIN_DIR}/sxcat --atom --canonical --base64 "${TMP_SRC1}" \
	    | diff -u "${TMP_EXPT}" -
	then
		echo "sxcat atom test 2 failed"
		RET_VAL="1"
	fi

	dd if=/dev/zero of="${TMP_SRC2}" bs=1024 count=4 2>/dev/null
	echo -n '4096:' >"${TMP_EXPT}"
	cat "${TMP_SRC2}" >> "${TMP_EXPT}"
	if ! ${BIN_DIR}/sxcat --atom --canonical "${TMP_SRC2}" \
	    | diff -u "${TMP_EXPT}" -
	then
		echo "sxcat atom test 3 failed"
		RET_VAL="1"
	fi

	echo -n "{KDc6c25pY2tlcjM6YWJjKDE6AzM6YWJjKSk=}" >"${TMP_EXPT}"
	if ! echo '(snicker "abc" (#03# |YWJj|))' \
	    | ${BIN_DIR}/sxcat --canonical --brace \
	    | diff -u "${TMP_EXPT}" -
	then
		echo "sxcat basic expression test failed"
		RET_VAL="1"
	fi

	printf '("test"\r\n   ("mang\\303\\251"))' >"${TMP_EXPT}"
	if ! echo '(test (mangé))' \
	    | ${BIN_DIR}/sxcat --canonical --width 0 --indent 3s --ASCII \
	      --single-line --dos --newline ao --escape-octal \
	    | diff -u "${TMP_EXPT}" -
	then
		echo "sxcat encoding test failed"
		RET_VAL="1"
	fi

	printf '("rosé"x\n\r   x x x\n\r   x x)' >"${TMP_EXPT}"
	if ! echo '(rosé x x x x x x)' \
	    | ${BIN_DIR}/sxcat --canonical --token --single-line --width 8 \
	       --utf-8 --indent 3s --nl lfcr \
	    | diff -u "${TMP_EXPT}" -
	then
		echo "sxcat UTF-8 width test failed"
		RET_VAL="1"
	fi

	printf '("rosé"\r\tx x x\r\tx x x\r)' >"${TMP_EXPT}"
	if ! echo '(rosé x x x x x x)' \
	    | ${BIN_DIR}/sxcat --canonical --token --single-line --width 8 \
	       --8-bit --indent 1t --tab-stop 3 --nl cR \
	    | diff -u "${TMP_EXPT}" -
	then
		echo "sxcat latin-1 width test failed"
		RET_VAL="1"
	fi

	${BIN_DIR}/sxcat --ext-token --indent 3st --hex-atom --escape-hex \
	    --no-quoted --no-token --newline ')d,)(,oo,d(' --space 'dd' \
	    --width 80 --nl cr-lf --unix --lower --dump >"${TMP_DEST}"

	if ! ${BIN_DIR}/sxcat --config "${TMP_DEST}" --dump \
	    | diff -u "${TMP_DEST}" -
	then
		echo "sxcat configuration reload test failed"
		RET_VAL="1"
	fi

	printf '(#666f6f#\n   (# 626172# # 62617a#))' >"${TMP_EXPT}"
	if ! echo '(foo (bar baz))' \
	    | ${BIN_DIR}/sxcat --canonical --config "${TMP_DEST}" \
	    | diff -u "${TMP_EXPT}" -
	then
		echo "sxcat configuration file test failed"
		RET_VAL="1"
	fi

	printf '("hello" "0123456789" "tab\\tencoding" 2:é)' >"${TMP_EXPT}"
	if ! echo '(hello 10:0123456789 "tab	encoding" é)' \
	    | ${BIN_DIR}/sxcat --config "${TMP_DEST}" --ASCII --no-indent \
	      --quoted --verbatim --upper \
	    | diff -u "${TMP_EXPT}" -
	then
		echo "sxcat test of configuration file overwrite failed"
		RET_VAL="1"
	fi

	rm "${TMP_SRC1}"
	rm "${TMP_SRC2}"
	rm "${TMP_DEST}"
	rm "${TMP_EXPT}"
else
	echo "${BIN_DIR}/sxcat not found"
fi

exit ${RET_VAL}