2 #@ Usage: ./cc-test.sh [--check-only [s-nail-binary]]
5 ARGS
='-:/ -# -Sencoding=quoted-printable -Sstealthmua -Snosave -Sexpandaddr=restrict -Sdotlock-ignore-error'
10 #UTF8_LOCALE= autodetected unless set
12 if ( command -v command ) >/dev
/null
2>&1; then :; else
19 MAKE
="${MAKE:-`command -v make`}"
20 awk=${awk:-`command -v awk`}
21 cat=${cat:-`command -v cat`}
22 cksum=${cksum:-`command -v cksum`}
23 rm=${rm:-`command -v rm`}
24 sed=${sed:-`command -v sed`}
25 grep=${grep:-`command -v grep`}
29 export SNAIL ARGS CONF BODY MBOX MAIL MAKE
awk cat cksum rm sed grep
31 LC_ALL
=C LANG
=C ADDARG_UNI
=-Sttycharset=UTF-8
33 # Wed Oct 2 01:50:07 UTC 1996
34 SOURCE_DATE_EPOCH
=844221007
36 export LC_ALL LANG ADDARG_UNI TZ SOURCE_DATE_EPOCH
38 # Problem: force $SHELL to be a real shell. It seems some testing environments
39 # use nologin(?), but we need a real shell for command execution
40 if { echo ${SHELL} | ${grep} nologin; } >/dev
/null
2>&1; then
41 echo >&2 '$SHELL seems to be nologin, overwriting to /bin/sh!'
46 if [ -z "${UTF8_LOCALE}" ]; then
48 if command -v locale
>/dev
/null
2>&1; then
49 UTF8_LOCALE
=`locale -a | { m=
51 if { echo ${n} | ${grep} -i 'utf-\{0,1\}8'; } >/dev/null 2>&1; then
53 if { echo ${n} | ${grep} -e POSIX -e en_EN -e en_US; }; then
67 echo >&2 "Usage: ./cc-test.sh [--check-only [s-nail-binary]]"
73 [ "${1}" = --check-only ] || usage
74 [ ${#} -gt 2 ] && usage
75 [ ${#} -eq 2 ] && SNAIL
="${2}"
76 [ -x "${SNAIL}" ] || usage
81 # Test all configs TODO doesn't cover all *combinations*, stupid!
85 NOTME["OPT_AUTOCC"] = 1
86 NOTME["OPT_DEBUG"] = 1
87 NOTME["OPT_DEVEL"] = 1
88 NOTME["OPT_NOEXTMD5"] = 1
89 NOTME["OPT_NOMEMDBG"] = 1
94 sub(/^[[:space:]]*/, "")
95 # This bails for UnixWare 7.1.4 awk(1), but preceeding = with \
96 # does not seem to be a compliant escape for =
98 $1 = substr($1, 1, index($1, "=") - 1)
104 # Doing this completely sequentially and not doing make distclean in
105 # between runs should effectively result in lesser compilations.
106 # It is completely dumb nonetheless... TODO
107 for (j = 1; j < i; ++j) {
108 for (k = 1; k < j; ++k)
110 for (k = j; k < i; ++k)
112 printf "OPT_AUTOCC=1\n"
114 for (j = 1; j < i; ++j) {
115 for (k = 1; k < j; ++k)
117 for (k = j; k < i; ++k)
119 printf "OPT_AUTOCC=1\n"
122 for (j = 1; j < i; ++j) {
123 for (k = 1; k < j; ++k)
125 for (k = j; k < i; ++k)
127 printf "OPT_AUTOCC=1\n"
128 printf "OPT_DEBUG=1\n"
130 for (j = 1; j < i; ++j) {
131 for (k = 1; k < j; ++k)
133 for (k = j; k < i; ++k)
135 printf "OPT_AUTOCC=1\n"
136 printf "OPT_DEBUG=1\n"
139 printf "CONFIG=NULL OPT_AUTOCC=0\n"
140 printf "CONFIG=NULL OPT_AUTOCC=1\n"
141 printf "CONFIG=NULLI OPT_AUTOCC=0\n"
142 printf "CONFIG=NULLI OPT_AUTOCC=1\n"
143 printf "CONFIG=MINIMAL OPT_AUTOCC=0\n"
144 printf "CONFIG=MINIMAL OPT_AUTOCC=1\n"
145 printf "CONFIG=MEDIUM OPT_AUTOCC=0\n"
146 printf "CONFIG=MEDIUM OPT_AUTOCC=1\n"
147 printf "CONFIG=NETSEND OPT_AUTOCC=0\n"
148 printf "CONFIG=NETSEND OPT_AUTOCC=1\n"
149 printf "CONFIG=MAXIMAL OPT_AUTOCC=0\n"
150 printf "CONFIG=MAXIMAL OPT_AUTOCC=1\n"
151 printf "CONFIG=DEVEL OPT_AUTOCC=0\n"
152 printf "CONFIG=DEVEL OPT_AUTOCC=1\n"
153 printf "CONFIG=ODEVEL OPT_AUTOCC=0\n"
154 printf "CONFIG=ODEVEL OPT_AUTOCC=1\n"
157 printf "\n\n##########\n$c\n"
158 printf "\n\n##########\n$c\n" >&2
166 # Read mailbox $2, strip non-constant headers and MIME boundaries, query the
167 # cksum(1) of the resulting data and compare against the checksum $3
169 tid
=${1} f=${2} s=${3}
171 csum
="`${sed} -e '/^From /d' \
172 -e '/^ boundary=/d' -e '/^--=-=/d' < \"${f}\" \
173 -e '/^\[-- Message/d' | ${cksum}`";
174 if [ "${csum}" = "${s}" ]; then
178 printf 'error: checksum mismatch (got %s)\n' "${csum}"
183 ( "${SNAIL}" ${ARGS} -X'echo $features' -Xx | ${grep} +${1} ) >/dev/null 2>&1
187 # Basic (easily testable) behaviour tests
189 __behave_x_opt_input_command_stack
194 # FIXME __behave_alias
196 # FIXME __behave_mlist
198 have_feat smime && __behave_smime
201 __behave_x_opt_input_command_stack() {
202 ${rm} -f "${BODY}" "${MBOX}"
203 ${cat} <<- '__EOT' > "${BODY}"
211 echo "define mac1 {";\
212 echo " echo mac1-1";\
214 echo " echo mac1-2";\
216 echo " echo mac1-3";\
219 echo "define mac2 {";\
220 echo " echo mac2-1";\
222 echo " echo mac2-2";\
227 echo "wysh source \"\
240 # The -X option supports multiline arguments, and those can internally use
241 # reverse solidus newline escaping. And all -X options are joined...
243 < "${BODY}" "${SNAIL}" ${ARGS} \
257 wysh source '${APO}'\
258 echo "define mac1 {";\
259 echo " echo mac1-1";\
261 echo " echo mac1-2";\
263 echo " echo mac1-3";\
266 echo "define mac2 {";\
267 echo " echo mac2-1";\
269 echo " echo mac2-2";\
274 echo "wysh source \"\
287 ' > "${MBOX}" 2>/dev/null
288 cksum_test behave:x_opt_input_command_stack "${MBOX}" '270940651 240'
292 # Nestable conditions test
293 ${rm} -f "${BODY}" "${MBOX}"
294 ${cat} <<- '__EOT' > "${BODY}"
313 echo 'a${DIET}b${TIED}c\${DIET}d\${TIED}e' # COMMENT
314 echo "a${DIET}b${TIED}c\${DIET}d\${TIED}e"
315 echo $'a${DIET}b${TIED}c\${DIET}d\${TIED}e'
317 echo a$'\101\0101\x41\u0041\u41\U00000041\U41'c
318 echo a$'\u0041\u41\u0C1\U00000041\U41'c
341 echo a$'b\U0000000'dt
342 echo a$'b\U00000000'du
352 if [ -z "${UTF8_LOCALE}" ]; then
353 echo 'Skip behave:wysh_unicode, no UTF8_LOCALE'
355 < "${BODY}" DIET=CURD TIED= \
356 LC_ALL=${UTF8_LOCALE} "${SNAIL}" ${ARGS} 2>/dev/null > "${MBOX}"
372 #a${DIET}b${TIED}c\${DIET}d\${TIED}e
373 #aCURDbc${DIET}d${TIED}e
374 #a${DIET}b${TIED}cCURDde
403 cksum_test behave:wysh_unicode "${MBOX}" '475805847 317'
406 < "${BODY}" DIET=CURD TIED= "${SNAIL}" ${ARGS} > "${MBOX}" 2>/dev/null
422 #a${DIET}b${TIED}c\${DIET}d\${TIED}e
423 #aCURDbc${DIET}d${TIED}e
424 #a${DIET}b${TIED}cCURDde
453 cksum_test behave:wysh_c "${MBOX}" '1473887148 321'
454 ${rm} -f "${BODY}" "${MBOX}"
458 # Nestable conditions test
460 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
482 if $dietcurd == 'yoho'
487 if $dietcurd != 'yoho'
548 if $dietcurd == 'yohu'
550 elif $dietcurd == 'yoha'
552 elif $dietcurd == 'yohe'
554 elif $dietcurd == 'yoho'
556 if $dietcurd == 'yohu'
558 elif $dietcurd == 'yoha'
560 elif $dietcurd == 'yohe'
562 elif $dietcurd == 'yoho'
564 if $dietcurd == 'yohu'
566 elif $dietcurd == 'yoha'
568 elif $dietcurd == 'yohe'
570 elif $dietcurd == 'yoho'
581 # integer conversion, <..>..
684 set diet=abc curd=abc
690 set diet=abc curd=abcd
696 # 1. Shitty grouping capabilities as of today
697 unset diet curd ndefined
698 if [ [ false ] || [ false ] || [ true ] ] && [ [ false ] || [ true ] ] && \
704 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
709 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
714 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
719 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
724 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
730 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
735 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
740 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
745 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
750 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
755 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
760 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
765 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
770 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
775 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
781 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
787 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
792 # 2. Shitty grouping capabilities as of today
793 unset diet curd ndefined
794 if [ false || false || true ] && [ false || true ] && yes
799 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
804 if [ 1 || 0 || 0 || 0 ]
809 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
814 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
819 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
824 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
829 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
834 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
839 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
844 if 1 || 0 || 0 || 0 && 0
849 if 1 || 0 || 0 || 0 && 1
854 if 0 || 0 || 0 || 1 && 0
859 if 0 || 0 || 0 || 1 && 1
864 if 0 || 0 || 0 || 1 && 0 || 1 && 0
869 if 0 || 0 || 0 || 1 && 0 || 1 && 1
875 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
880 if $diet == 'yo' && $curd == 'ho' && $ndefined
886 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
891 if $diet == 'yo' && $curd == 'ho' && $ndefined
896 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
901 # Some more en-braced variables
903 if ${diet} == ${curd}
908 if ${diet} != ${curd}
924 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
929 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
934 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
939 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
944 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
949 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
954 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
959 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
964 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
970 if ! 0 && ! ! 1 && ! ! ! 0 && 3
975 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
980 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
985 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
990 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
995 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
1000 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
1005 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
1010 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
1016 cksum_test behave:if-normal "${MBOX}" '557629289 631'
1018 if have_feat regex; then
1020 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
1022 if $dietcurd =~ '^yo.*'
1027 if $dietcurd =~ '^yoho.+'
1032 if $dietcurd !~ '.*ho$'
1037 if $dietcurd !~ '.+yoho$'
1042 if [ $dietcurd !~ '.+yoho$' ]
1047 if ! [ $dietcurd =~ '.+yoho$' ]
1052 if ! ! [ $dietcurd !~ '.+yoho$' ]
1057 if ! [ ! [ $dietcurd !~ '.+yoho$' ] ]
1062 if [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1067 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1072 if ! ! ! $dietcurd !~ '.+yoho$'
1077 if ! ! ! $dietcurd =~ '.+yoho$'
1082 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1087 set diet=abc curd='^abc$'
1093 set diet=abc curd='^abcd$'
1100 cksum_test behave:if-regex "${MBOX}" '439960016 81'
1104 __behave_localopts() {
1105 # Nestable conditions test
1107 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
1122 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1127 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1128 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
1137 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1139 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1145 #gv1 lv1 lv2 lv3 gv2, t2
1153 #gv1 lv1 lv2 lv3 gv2, t2
1156 #active trouble: gv1 gv2,
1158 cksum_test behave:localopts "${MBOX}" '1936527193 192'
1161 __behave_smime() { # FIXME add test/ dir, unroll tests therein, regular enable!
1162 printf 'behave:s/mime: .. generating test key and certificate ..\n'
1163 ${cat} <<-_EOT > ./t.conf
1166 default_keyfile = keyfile.pem
1167 distinguished_name = req_distinguished_name
1168 attributes = req_attributes
1172 [ req_distinguished_name ]
1179 emailAddress = test@localhost
1184 openssl req -x509 -nodes -days 3650 -config ./t.conf \
1185 -newkey rsa:1024 -keyout ./tkey.pem -out ./tcert.pem >/dev/null 2>&1
1187 ${cat} ./tkey.pem ./tcert.pem > ./tpair.pem
1189 printf "behave:s/mime:sign/verify: "
1190 echo bla | "${SNAIL}" ${ARGS} \
1191 -Ssmime-ca-file=./tcert.pem -Ssmime-sign-cert=./tpair.pem \
1192 -Ssmime-sign -Sfrom=test@localhost \
1193 -s 'S/MIME test' ./VERIFY
1194 printf 'verify\nx\n' |
1195 "${SNAIL}" ${ARGS} \
1196 -Ssmime-ca-file=./tcert.pem -Ssmime-sign-cert=./tpair.pem \
1197 -Ssmime-sign -Sfrom=test@localhost \
1198 -Sbatch-exit-on-error -R \
1199 -f ./VERIFY >/dev/null 2>&1
1200 if [ $? -eq 0 ]; then
1203 printf 'error: verification failed\n'
1205 ${rm} -f ./VERIFY ./tkey.pem ./tcert.pem ./tpair.pem
1208 printf ' .. disproof via openssl smime(1): '
1209 if openssl smime -verify -CAfile ./tcert.pem \
1210 -in ./VERIFY >/dev/null 2>&1; then
1215 ${rm} -f ./VERIFY ./tkey.pem ./tcert.pem ./tpair.pem
1220 # (signing +) encryption / decryption
1221 ${cat} <<-_EOT > ./tsendmail.sh
1223 (echo 'From S-Postman Thu May 10 20:40:54 2012' && ${cat}) > .
/ENCRYPT
1225 chmod 0755 .
/tsendmail.sh
1227 printf "behave:s/mime:encrypt+sign/decrypt+verify: "
1229 "${SNAIL}" ${ARGS} \
1230 -Ssmime-force-encryption \
1231 -Ssmime-encrypt-recei@ver.com
=.
/tpair.pem \
1232 -Smta=.
/tsendmail.sh \
1233 -Ssmime-ca-file=.
/tcert.pem
-Ssmime-sign-cert=.
/tpair.pem \
1234 -Ssmime-sign -Sfrom=test@localhost \
1235 -s 'S/MIME test' recei@ver.com
1237 printf 'decrypt ./DECRYPT\nfi ./DECRYPT\nverify\nx\n' |
1238 "${SNAIL}" ${ARGS} \
1239 -Ssmime-force-encryption \
1240 -Ssmime-encrypt-recei@ver.com
=.
/tpair.pem \
1241 -Smta=.
/tsendmail.sh \
1242 -Ssmime-ca-file=.
/tcert.pem
-Ssmime-sign-cert=.
/tpair.pem \
1243 -Ssmime-sign -Sfrom=test@localhost \
1244 -Sbatch-exit-on-error -R \
1245 -f .
/ENCRYPT
>/dev
/null
2>&1
1246 if [ $?
-eq 0 ]; then
1250 printf 'error: decryption+verification failed\n'
1252 printf ' ..disproof via openssl smime(1): '
1253 if (openssl smime
-decrypt -inkey .
/tkey.pem
-in .
/ENCRYPT |
1254 openssl smime
-verify -CAfile .
/tcert.pem
) >/dev
/null
2>&1; then
1260 ${sed} -e '/^Date:/d' -e '/^X-Decoding-Date/d' \
1262 '/^Content-Disposition: attachment; filename="smime.p7s"/,/^-- /d' \
1263 < .
/DECRYPT
> .
/ENCRYPT
1264 cksum_test
".. checksum of decrypted content" "./ENCRYPT" '82649489 454'
1267 printf "behave:s/mime:encrypt/decrypt: "
1268 echo bla |
"${SNAIL}" ${ARGS} \
1269 -Ssmime-force-encryption \
1270 -Ssmime-encrypt-recei@ver.com
=.
/tpair.pem \
1271 -Smta=.
/tsendmail.sh \
1272 -Ssmime-ca-file=.
/tcert.pem
-Ssmime-sign-cert=.
/tpair.pem \
1273 -Sfrom=test@localhost \
1274 -s 'S/MIME test' recei@ver.com
1275 printf 'decrypt ./DECRYPT\nx\n' |
"${SNAIL}" ${ARGS} \
1276 -Ssmime-force-encryption \
1277 -Ssmime-encrypt-recei@ver.com
=.
/tpair.pem \
1278 -Smta=.
/tsendmail.sh \
1279 -Ssmime-ca-file=.
/tcert.pem
-Ssmime-sign-cert=.
/tpair.pem \
1280 -Sfrom=test@localhost \
1281 -Sbatch-exit-on-error -R \
1282 -f .
/ENCRYPT
>/dev
/null
2>&1
1283 if [ $?
-eq 0 ]; then
1287 printf 'error: decryption failed\n'
1289 printf '.. disproof via openssl smime(1): '
1290 if openssl smime
-decrypt -inkey .
/tkey.pem \
1291 -in .
/ENCRYPT
>/dev
/null
2>&1; then
1297 ${sed} -e '/^Date:/d' -e '/^X-Decoding-Date/d' \
1298 < .
/DECRYPT
> .
/ENCRYPT
1299 cksum_test
".. checksum of decrypted content" "./ENCRYPT" '2694938815 239'
1301 ${rm} -f .
/tsendmail.sh .
/ENCRYPT .
/DECRYPT \
1302 .
/tkey.pem .
/tcert.pem .
/tpair.pem
1306 # Some basic tests regarding correct sending of mails, via STDIN / -t / -q,
1307 # including basic MIME Content-Transfer-Encoding correctness (quoted-printable)
1308 # Note we unfortunately need to place some statements without proper
1309 # indentation because of continuation problems
1311 ${rm} -f "${BODY}" "${MBOX}"
1313 # MIME encoding (QP) stress message body
1315 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
1316 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
1317 "wasde willst
, gelle
, gelle
, gelle
, gelle
, gelle.
\r\n"\
1318 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst
\r\n"\
1319 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst
1\r\n"\
1320 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst
12\r\n"\
1321 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst
123\r\n"\
1322 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst
1234\r\n"\
1323 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst
12345\r\n"\
1324 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst
123456\r\n"\
1325 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst
1234567\r\n"\
1326 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst
12345678\r\n"\
1327 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst
123456789\r\n"\
1328 "Unn ausserdem habe ich trailing SP
/HT
/SP
/HT whitespace
\r\n"\
1329 "Unn ausserdem habe ich trailing HT
/SP
/HT
/SP whitespace
\r\n"\
1330 "auf den zeilen vorher.
\r\n"\
1331 "From am Zeilenbeginn und From der Mitte gibt es auch.
\r\n"\
1333 "Die letzte Zeile war nur ein Punkt.
\r\n"\
1335 "Das waren deren zwei.
\r\n"\
1337 "Die letzte Zeile war ein Leerschritt.
\n"\
1338 "=VIER
= EQUAL SIGNS
=ON A LINE
=\r\n"\
1341 "Die letzte Zeile war nur ein Punkt
, mit Unix Zeilenende.
\n"\
1343 "Das waren deren zwei. ditto.
\n"\
1345 "Unn ausseerdem habe ich trailing SP
/HT
/SP
/HT whitespace
\n"\
1346 "Unn ausseerdem habe ich trailing HT
/SP
/HT
/SP whitespace
\n"\
1347 "auf den zeilen vorher.
\n"\
1349 "Ich bin eine ziemlich lange
, steile
, scharfe Zeile mit Unix Zeilenende.
\n"\
1350 "Ich bin eine ziemlich lange
, steile
, scharfe Zeile mit Unix Zeilenende
.1"\
1352 "Ich bin eine ziemlich lange
, steile
, scharfe Zeile mit Unix Zeilenende
.12"\
1354 "Ich bin eine ziemlich lange
, steile
, scharfe Zeile mit Unix Zeilenende
.12"\
1356 "Ich bin eine ziemlich lange
, steile
, scharfe Zeile mit Unix Zeilenende
.12"\
1358 "Ich bin eine ziemlich lange
, steile
, scharfe Zeile mit Unix Zeilenende
.12"\
1360 "Ich bin eine ziemlich lange
, steile
, scharfe Zeile mit Unix Zeilenende
.12"\
1362 "QP am Zeilenende über soft-nl hinweg
\n"\
1363 "Ich bin eine ziemlich lange
, steile
, scharfe Zeile mit Unix Zeilenende.
"\
1365 "Ich bin eine ziemlich lange
, steile
, scharfe Zeile mit Unix Zeilenende.
"\
1367 "Ich bin eine ziemlich lange
, steile
, scharfe Zeile mit Unix Zeilenende.
"\
1369 "Ich bin eine ziemlich lange
, steile
, scharfe Zeile mit Unix Zeilenende.
"\
1371 "=VIER
= EQUAL SIGNS
=ON A LINE
=\n"\
1373 "Die letzte Zeile war ein Leerschritt.
\n"\
1377 # MIME encoding (QP) stress message subject
1378 SUB="Äbrä Kä?dä
=brö Fü?di
=bus? \
1379 adadaddsssssssddddddddddddddddddddd\
1380 ddddddddddddddddddddddddddddddddddd\
1381 ddddddddddddddddddddddddddddddddddd\
1382 dddddddddddddddddddd Hallelulja? Od\
1383 er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
1384 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
1385 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f\
1386 fffffffffffffffffffffffffffffffffff\
1387 fffffffffffffffffffff ggggggggggggg\
1388 ggggggggggggggggggggggggggggggggggg\
1389 ggggggggggggggggggggggggggggggggggg\
1390 ggggggggggggggggggggggggggggggggggg\
1393 # Three tests for MIME encodign and (a bit) content classification.
1394 # At the same time testing -q FILE, < FILE and -t FILE
1397 < "${BODY}" "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
1398 -a "${BODY}" -s "${SUB}" "${MBOX}"
1399 cksum_test content
:001 "${MBOX}" '2356108758 6413'
1402 < /dev
/null
"${SNAIL}" ${ARGS} ${ADDARG_UNI} \
1403 -a "${BODY}" -s "${SUB}" -q "${BODY}" "${MBOX}"
1404 cksum_test content:002 "${MBOX}" '2356108758 6413'
1407 ( echo "To
: ${MBOX}" && echo "Subject
: ${SUB}" && echo &&
1409 ) | "${SNAIL}" ${ARGS} ${ADDARG_UNI} -Snodot -a "${BODY}" -t
1410 cksum_test content:003 "${MBOX}" '2356108758 6413'
1412 # Test for [260e19d] (Juergen Daubert)
1414 echo body | "${SNAIL}" ${ARGS} "${MBOX}"
1415 cksum_test content:004 "${MBOX}" '4004005686 49'
1417 # Sending of multiple mails in a single invocation
1419 ( printf "m
${MBOX}\n~s subject1
\nE
-Mail Körper
1\n~.
\n" &&
1420 printf "m
${MBOX}\n~s subject2
\nEmail body
2\n~.
\n" &&
1422 ) | "${SNAIL}" ${ARGS} ${ADDARG_UNI}
1423 cksum_test content
:005 "${MBOX}" '2157252578 260'
1427 # "Test for" [d6f316a] (Gavin Troy)
1429 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
1430 "${SNAIL}" ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="${cat}" > "${BODY}"
1431 ${sed} -e 1d < "${BODY}" > "${MBOX}"
1432 cksum_test content:006 "${MBOX}" '2273863401 83'
1434 # "Test
for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
1437 for(i = 0; i < 10000; ++i)
1439 #printf "\xF0\x90\x87\x90"
1440 }' | "${SNAIL}" ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
1441 cksum_test content:007 "${MBOX}" '1754234717 61767'
1443 ## Test some more corner cases for header bodies (as good as we can today) ##
1447 echo | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
1448 -s 'a̲b̲c̲d̲e̲f̲h̲i̲k̲l̲m̲n̲o̲r̲s̲t̲u̲v̲w̲x̲z̲a̲b̲c̲d̲e̲f̲h̲i̲k̲l̲m̲n̲o̲r̲s̲t̲u̲v̲w̲x̲z̲' \
1450 cksum_test content
:008 "${MBOX}" '1563381297 326'
1452 # Single word (overlong line split -- bad standard! Requires injection of
1453 # artificial data!! Bad can be prevented by using RFC 2047 encoding)
1455 i
=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
1456 echo |
"${SNAIL}" ${ARGS} -s "${i}" "${MBOX}"
1457 cksum_test content
:009 "${MBOX}" '1996714851 1669'
1459 # Combination of encoded words, space and tabs of varying sort
1461 echo |
"${SNAIL}" ${ARGS} ${ADDARG_UNI} \
1462 -s "1Abrä Kaspas1
2Abra Katä b_kaspas2 \
1463 3Abrä Kaspas3
4Abrä Kaspas4
5Abrä Kaspas5 \
1464 6Abra Kaspas6
7Abrä Kaspas7
8Abra Kaspas8 \
1465 9Abra Kaspastäb4-3
10Abra Kaspas1 _
11Abra Katäb1 \
1466 12Abra Kadabrä
1 After Tab after Täb this is NUTS
" \
1468 cksum_test content:010 "${MBOX}" '2956039469 542'
1470 # Overlong multibyte sequence that must be forcefully split
1471 # todo This works even before v15.0, but only by accident
1473 echo | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
1474 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
1475 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
1476 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
1478 cksum_test content
:011 "${MBOX}" '454973928 610'
1482 echo |
"${SNAIL}" ${ARGS} \
1483 -s "1-1 B2 B3 B4 B5 B6 B\
1484 1-2 B2 B3 B4 B5 B6 B\
1485 1-3 B2 B3 B4 B5 B6 B\
1486 1-4 B2 B3 B4 B5 B6 B\
1487 1-5 B2 B3 B4 B5 B6 B\
1488 1-6 B2 B3 B4 B5 B6 " \
1490 cksum_test content
:012 "${MBOX}" '1497528261 248'
1492 # Leading and trailing WS
1494 echo |
"${SNAIL}" ${ARGS} \
1495 -s " 2-1 B2 B3 B4 B5 B6 B\
1496 1-2 B2 B3 B4 B5 B6 B\
1497 1-3 B2 B3 B4 B5 B6 B\
1498 1-4 B2 B3 B4 B5 B6 " \
1500 cksum_test content
:013 "${MBOX}" '1588208111 187'
1502 # Quick'n dirty RFC 2231 test; i had more when implementing it, but until we
1503 # have a (better) test framework materialize a quick shot
1507 : > 'diet\ is \curd.txt'
1508 : > 'diet "is" curd.txt'
1510 : > höde__tröge__müde__dätte__hätte__vülle__gülle__äse__äße__säuerliche__kräuter__österliche__grüße__mäh.txt
1511 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
1512 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
1513 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
1514 echo bla |
"${SNAIL}" ${ARGS} ${ADDARG_UNI} \
1515 -a "ma
'ger.txt" -a "mä'ger.txt
" \
1516 -a 'diet\ is \curd.txt' -a 'diet "is
" curd.txt' \
1518 -a höde__tröge__müde__dätte__hätte__vülle__gülle__äse__äße__säuerliche__kräuter__österliche__grüße__mäh.txt \
1519 -a höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt \
1520 -a hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
1521 -a ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
1523 ${rm} -f "ma
'ger.txt" "mä'ger.txt
" 'diet\ is \curd.txt' \
1524 'diet "is
" curd.txt' höde-tröge.txt \
1525 höde__tröge__müde__dätte__hätte__vülle__gülle__äse__äße__säuerliche__kräuter__österliche__grüße__mäh.txt \
1526 höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt \
1527 hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
1528 ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
1529 cksum_test content:14 "${MBOX}" '589846634 2491'
1531 printf "Resend
${BODY}\nx\n" | "${SNAIL}" ${ARGS} -f "${MBOX}"
1532 cksum_test content:14-2 "${MBOX}" '589846634 2491'
1534 ${rm} -f "${BODY}" "${MBOX}"
1538 if have_feat devel
; then
1539 ARGS
="${ARGS} -Smemdebug"
1546 if [ -z "${CHECK_ONLY}" ]; then
1552 [ ${ESTAT} -eq 0 ] && echo Ok ||
echo >&2 'Errors occurred'