2 #@ Usage: ./cc-test.sh [--check-only [s-nail-binary]]
5 ARGS
='-n# -Sstealthmua -Snosave -Sexpandaddr=restrict -Sdotlock-ignore-error'
10 MAKE
="${MAKE:-`command -v make`}"
11 awk=${awk:-`command -v awk`}
12 cat=${cat:-`command -v cat`}
13 cksum=${cksum:-`command -v cksum`}
14 rm=${rm:-`command -v rm`}
15 sed=${sed:-`command -v sed`}
16 grep=${grep:-`command -v grep`}
20 export SNAIL ARGS CONF BODY MBOX MAKE
awk cat cksum rm sed grep
22 # NOTE! UnixWare 7.1.4 gives ISO-10646-Minimum-European-Subset for
23 # nl_langinfo(CODESET), then, so also overwrite ttycharset.
24 # (In addition this setup allows us to succeed on TinyCore 4.4 that has no
25 # other locales than C/POSIX installed by default!)
27 LC_ALL
=${LC} LANG
=${LC}
29 export LC_ALL LANG ttycharset
31 # Problem: force $SHELL to be a real shell. It seems some testing environments
32 # use nologin(?), but we need a real shell for command execution
33 if { echo ${SHELL} | ${grep} nologin; } >/dev
/null
2>&1; then
34 echo >&2 '$SHELL seems to be nologin, overwriting to /bin/sh!'
42 echo >&2 "Usage: ./cc-test.sh [--check-only [s-nail-binary]]"
48 [ "${1}" = --check-only ] || usage
49 [ ${#} -gt 2 ] && usage
50 [ ${#} -eq 2 ] && SNAIL
="${2}"
51 [ -x "${SNAIL}" ] || usage
56 # Test all configs TODO doesn't cover all *combinations*, stupid!
60 NOTME["WANT_AUTOCC"] = 1
61 NOTME["WANT_DEBUG"] = 1
62 NOTME["WANT_NOEXTMD5"] = 1
63 NOTME["WANT_NOALLOCA"] = 1
64 NOTME["WANT_DEVEL"] = 1
65 NOTME["WANT_NYD2"] = 1
68 /^[[:space:]]*WANT_/ {
69 sub(/^[[:space:]]*/, "")
70 # This bails for UnixWare 7.1.4 awk(1), but preceeding = with \
71 # does not seem to be a compliant escape for =
73 $1 = substr($1, 1, index($1, "=") - 1)
79 # Doing this completely sequentially and not doing make distclean in
80 # between runs should effectively result in lesser compilations.
81 # It is completely dumb nonetheless... TODO
82 for (j = 1; j < i; ++j) {
83 for (k = 1; k < j; ++k)
85 for (k = j; k < i; ++k)
87 printf "WANT_AUTOCC=1\n"
89 for (j = 1; j < i; ++j) {
90 for (k = 1; k < j; ++k)
92 for (k = j; k < i; ++k)
94 printf "WANT_AUTOCC=1\n"
97 for (j = 1; j < i; ++j) {
98 for (k = 1; k < j; ++k)
100 for (k = j; k < i; ++k)
102 printf "WANT_AUTOCC=1\n"
103 printf "WANT_DEBUG=1\n"
105 for (j = 1; j < i; ++j) {
106 for (k = 1; k < j; ++k)
108 for (k = j; k < i; ++k)
110 printf "WANT_AUTOCC=1\n"
111 printf "WANT_DEBUG=1\n"
114 printf "CONFIG=NULL WANT_AUTOCC=0\n"
115 printf "CONFIG=NULL WANT_AUTOCC=1\n"
116 printf "CONFIG=NULLI WANT_AUTOCC=0\n"
117 printf "CONFIG=NULLI WANT_AUTOCC=1\n"
118 printf "CONFIG=MINIMAL WANT_AUTOCC=0\n"
119 printf "CONFIG=MINIMAL WANT_AUTOCC=1\n"
120 printf "CONFIG=MEDIUM WANT_AUTOCC=0\n"
121 printf "CONFIG=MEDIUM WANT_AUTOCC=1\n"
122 printf "CONFIG=NETSEND WANT_AUTOCC=0\n"
123 printf "CONFIG=NETSEND WANT_AUTOCC=1\n"
124 printf "CONFIG=MAXIMAL WANT_AUTOCC=0\n"
125 printf "CONFIG=MAXIMAL WANT_AUTOCC=1\n"
126 printf "CONFIG=DEVEL WANT_AUTOCC=0\n"
127 printf "CONFIG=DEVEL WANT_AUTOCC=1\n"
128 printf "CONFIG=ODEVEL WANT_AUTOCC=0\n"
129 printf "CONFIG=ODEVEL WANT_AUTOCC=1\n"
132 printf "\n\n##########\n$c\n"
133 printf "\n\n##########\n$c\n" >&2
141 # Read mailbox $2, strip non-constant headers and MIME boundaries, query the
142 # cksum(1) of the resulting data and compare against the checksum $3
144 tid
=${1} f=${2} s=${3}
146 csum
="`${sed} -e '/^From /d' -e '/^Date: /d' \
147 -e '/^ boundary=/d' -e '/^--=-=/d' < \"${f}\" \
148 -e '/^\[-- Message/d' | ${cksum}`";
149 if [ "${csum}" = "${s}" ]; then
153 printf 'error: checksum mismatch (got %s)\n' "${csum}"
160 MAILRC
=/dev
/null
"${SNAIL}" ${ARGS} |
166 # Basic (easily testable) behaviour tests
170 printf 'echo +nix\nset folder=/\necho +nix\nset nofolder\necho +nix\nx' |
171 MAILRC
=/dev
/null
"${SNAIL}" ${ARGS} > "${MBOX}"
172 cksum_test behave
:001 "${MBOX}" '4214021069 15'
174 # POSIX: setting *noprompt*/prompt='' shall prevent prompting TODO
175 # TODO for this to be testable we need a way to echo a variable
176 # TODO or to force echo of the prompt
180 # FIXME __behave_alias
182 # FIXME __behave_mlist
184 have_feat SSL
/TLS
&& have_feat S
/MIME
&& __behave_smime
188 # Nestable conditions test
190 ${cat} <<- '__EOT' | MAILRC=/dev/null "${SNAIL}" ${ARGS} > "${MBOX}"
212 if $dietcurd == 'yoho'
217 if $dietcurd != 'yoho'
278 if $dietcurd == 'yohu'
280 elif $dietcurd == 'yoha'
282 elif $dietcurd == 'yohe'
284 elif $dietcurd == 'yoho'
286 if $dietcurd == 'yohu'
288 elif $dietcurd == 'yoha'
290 elif $dietcurd == 'yohe'
292 elif $dietcurd == 'yoho'
294 if $dietcurd == 'yohu'
296 elif $dietcurd == 'yoha'
298 elif $dietcurd == 'yohe'
300 elif $dietcurd == 'yoho'
311 # integer conversion, <..>..
414 set diet=abc curd=abc
420 set diet=abc curd=abcd
426 # 1. Shitty grouping capabilities as of today
427 unset diet curd ndefined
428 if [ [ false ] || [ false ] || [ true ] ] && [ [ false ] || [ true ] ] && \
434 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
439 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
444 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
449 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
454 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
460 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
465 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
470 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
475 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
480 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
485 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
490 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
495 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
500 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
505 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
511 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
517 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
522 # 2. Shitty grouping capabilities as of today
523 unset diet curd ndefined
524 if [ false || false || true ] && [ false || true ] && yes
529 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
534 if [ 1 || 0 || 0 || 0 ]
539 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
544 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
549 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
554 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
559 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
564 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
569 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
574 if 1 || 0 || 0 || 0 && 0
579 if 1 || 0 || 0 || 0 && 1
584 if 0 || 0 || 0 || 1 && 0
589 if 0 || 0 || 0 || 1 && 1
594 if 0 || 0 || 0 || 1 && 0 || 1 && 0
599 if 0 || 0 || 0 || 1 && 0 || 1 && 1
605 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
610 if $diet == 'yo' && $curd == 'ho' && $ndefined
616 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
621 if $diet == 'yo' && $curd == 'ho' && $ndefined
626 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
632 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
637 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
642 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
647 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
652 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
657 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
662 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
667 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
672 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
678 if ! 0 && ! ! 1 && ! ! ! 0 && 3
683 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
688 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
693 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
698 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
703 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
708 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
713 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
718 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
724 cksum_test behave:if-normal "${MBOX}" '3542193361 607'
726 if have_feat REGEX; then
728 ${cat} <<- '__EOT' | MAILRC=/dev/null "${SNAIL}" ${ARGS} > "${MBOX}"
730 if $dietcurd =~
'^yo.*'
735 if $dietcurd =~
'^yoho.+'
740 if $dietcurd !~
'.*ho$'
745 if $dietcurd !~
'.+yoho$'
750 if [ $dietcurd !~
'.+yoho$' ]
755 if ! [ $dietcurd =~
'.+yoho$' ]
760 if ! ! [ $dietcurd !~
'.+yoho$' ]
765 if ! [ ! [ $dietcurd !~
'.+yoho$' ] ]
770 if [ ! [ ! [ $dietcurd !~
'.+yoho$' ] ] ]
775 if ! [ ! [ ! [ $dietcurd !~
'.+yoho$' ] ] ]
780 if ! ! ! $dietcurd !~
'.+yoho$'
785 if ! ! ! $dietcurd =~
'.+yoho$'
790 if ! [ ! ! [ ! [ $dietcurd !~
'.+yoho$' ] ] ]
795 set diet
=abc curd
='^abc$'
801 set diet
=abc curd
='^abcd$'
808 cksum_test behave
:if-regex
"${MBOX}" '439960016 81'
812 __behave_smime
() { # FIXME add test/ dir, unroll tests therein, regular enable!
813 printf 'behave:s/mime: .. generating test key and certificate ..\n'
814 ${cat} <<-_EOT > ./t.conf
817 default_keyfile = keyfile.pem
818 distinguished_name = req_distinguished_name
819 attributes = req_attributes
823 [ req_distinguished_name ]
830 emailAddress = test@localhost
835 openssl req
-x509 -nodes -days 3650 -config .
/t.conf \
836 -newkey rsa
:1024 -keyout .
/tkey.pem
-out .
/tcert.pem
>/dev
/null
2>&1
838 ${cat} .
/tkey.pem .
/tcert.pem
> .
/tpair.pem
840 printf "behave:s/mime:sign/verify: "
842 MAILRC
=/dev
/null
"${SNAIL}" ${ARGS} \
843 -Ssmime-ca-file=.
/tcert.pem
-Ssmime-sign-cert=.
/tpair.pem \
844 -Ssmime-sign -Sfrom=test@localhost \
845 -s 'S/MIME test' .
/VERIFY
847 printf 'verify\nx\n' |
848 MAILRC
=/dev
/null
"${SNAIL}" ${ARGS} \
849 -Ssmime-ca-file=.
/tcert.pem
-Ssmime-sign-cert=.
/tpair.pem \
850 -Ssmime-sign -Sfrom=test@localhost \
851 -Sbatch-exit-on-error -R \
852 -f .
/VERIFY
>/dev
/null
2>&1
853 if [ $?
-eq 0 ]; then
857 printf 'error: verification failed\n'
858 ${rm} -f .
/VERIFY .
/tkey.pem .
/tcert.pem .
/tpair.pem
863 # (signing +) encryption / decryption
864 ${cat} <<-_EOT > ./tsendmail.sh
866 (echo 'From S-Postman Thu May 10 20:40:54 2012' && ${cat}) > ./ENCRYPT
868 chmod 0755 .
/tsendmail.sh
870 printf "behave:s/mime:encrypt+sign/decrypt+verify: "
872 MAILRC
=/dev
/null
"${SNAIL}" ${ARGS} \
873 -Ssmime-force-encryption \
874 -Ssmime-encrypt-recei@ver.com
=.
/tpair.pem \
875 -Ssendmail=.
/tsendmail.sh \
876 -Ssmime-ca-file=.
/tcert.pem
-Ssmime-sign-cert=.
/tpair.pem \
877 -Ssmime-sign -Sfrom=test@localhost \
878 -s 'S/MIME test' recei@ver.com
880 printf 'decrypt ./DECRYPT\nfi ./DECRYPT\nverify\nx\n' |
881 MAILRC
=/dev
/null
"${SNAIL}" ${ARGS} \
882 -Ssmime-force-encryption \
883 -Ssmime-encrypt-recei@ver.com
=.
/tpair.pem \
884 -Ssendmail=.
/tsendmail.sh \
885 -Ssmime-ca-file=.
/tcert.pem
-Ssmime-sign-cert=.
/tpair.pem \
886 -Ssmime-sign -Sfrom=test@localhost \
887 -Sbatch-exit-on-error -R \
888 -f .
/ENCRYPT
>/dev
/null
2>&1
889 if [ $?
-eq 0 ]; then
893 printf 'error: decryption+verification failed\n'
895 ${sed} -e '/^X-Decoding-Date/d' \
897 '/^Content-Disposition: attachment; filename="smime.p7s"/,/^-- /d' \
898 < .
/DECRYPT
> .
/ENCRYPT
899 cksum_test
".. checksum of decrypted content" "./ENCRYPT" '82649489 454'
902 printf "behave:s/mime:encrypt/decrypt: "
904 MAILRC
=/dev
/null
"${SNAIL}" ${ARGS} \
905 -Ssmime-force-encryption \
906 -Ssmime-encrypt-recei@ver.com
=.
/tpair.pem \
907 -Ssendmail=.
/tsendmail.sh \
908 -Ssmime-ca-file=.
/tcert.pem
-Ssmime-sign-cert=.
/tpair.pem \
909 -Sfrom=test@localhost \
910 -s 'S/MIME test' recei@ver.com
911 printf 'decrypt ./DECRYPT\nx\n' |
912 MAILRC
=/dev
/null
"${SNAIL}" ${ARGS} \
913 -Ssmime-force-encryption \
914 -Ssmime-encrypt-recei@ver.com
=.
/tpair.pem \
915 -Ssendmail=.
/tsendmail.sh \
916 -Ssmime-ca-file=.
/tcert.pem
-Ssmime-sign-cert=.
/tpair.pem \
917 -Sfrom=test@localhost \
918 -Sbatch-exit-on-error -R \
919 -f .
/ENCRYPT
>/dev
/null
2>&1
920 if [ $?
-eq 0 ]; then
924 printf 'error: decryption failed\n'
927 ${sed} -e '/^X-Decoding-Date/d' \
928 < .
/DECRYPT
> .
/ENCRYPT
929 cksum_test
".. checksum of decrypted content" "./ENCRYPT" '2694938815 239'
931 ${rm} -f .
/tsendmail.sh .
/ENCRYPT .
/DECRYPT \
932 .
/tkey.pem .
/tcert.pem .
/tpair.pem
936 # Some basic tests regarding correct sending of mails, via STDIN / -t / -q,
937 # including basic MIME Content-Transfer-Encoding correctness (quoted-printable)
938 # Note we unfortunately need to place some statements without proper
939 # indentation because of continuation problems
941 ${rm} -f "${BODY}" "${MBOX}"
943 # MIME encoding (QP) stress message body
945 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
946 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
947 "wasde willst
, gelle
, gelle
, gelle
, gelle
, gelle.
\r\n"\
948 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst
\r\n"\
949 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst
1\r\n"\
950 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst
12\r\n"\
951 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst
123\r\n"\
952 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst
1234\r\n"\
953 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst
12345\r\n"\
954 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst
123456\r\n"\
955 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst
1234567\r\n"\
956 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst
12345678\r\n"\
957 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst
123456789\r\n"\
958 "Unn ausserdem habe ich trailing SP
/HT
/SP
/HT whitespace
\r\n"\
959 "Unn ausserdem habe ich trailing HT
/SP
/HT
/SP whitespace
\r\n"\
960 "auf den zeilen vorher.
\r\n"\
961 "From am Zeilenbeginn und From der Mitte gibt es auch.
\r\n"\
963 "Die letzte Zeile war nur ein Punkt.
\r\n"\
965 "Das waren deren zwei.
\r\n"\
967 "Die letzte Zeile war ein Leerschritt.
\n"\
968 "=VIER
= EQUAL SIGNS
=ON A LINE
=\r\n"\
971 "Die letzte Zeile war nur ein Punkt
, mit Unix Zeilenende.
\n"\
973 "Das waren deren zwei. ditto.
\n"\
975 "Unn ausseerdem habe ich trailing SP
/HT
/SP
/HT whitespace
\n"\
976 "Unn ausseerdem habe ich trailing HT
/SP
/HT
/SP whitespace
\n"\
977 "auf den zeilen vorher.
\n"\
979 "Ich bin eine ziemlich lange
, steile
, scharfe Zeile mit Unix Zeilenende.
\n"\
980 "Ich bin eine ziemlich lange
, steile
, scharfe Zeile mit Unix Zeilenende
.1"\
982 "Ich bin eine ziemlich lange
, steile
, scharfe Zeile mit Unix Zeilenende
.12"\
984 "Ich bin eine ziemlich lange
, steile
, scharfe Zeile mit Unix Zeilenende
.12"\
986 "Ich bin eine ziemlich lange
, steile
, scharfe Zeile mit Unix Zeilenende
.12"\
988 "Ich bin eine ziemlich lange
, steile
, scharfe Zeile mit Unix Zeilenende
.12"\
990 "Ich bin eine ziemlich lange
, steile
, scharfe Zeile mit Unix Zeilenende
.12"\
992 "QP am Zeilenende über soft-nl hinweg
\n"\
993 "Ich bin eine ziemlich lange
, steile
, scharfe Zeile mit Unix Zeilenende.
"\
995 "Ich bin eine ziemlich lange
, steile
, scharfe Zeile mit Unix Zeilenende.
"\
997 "Ich bin eine ziemlich lange
, steile
, scharfe Zeile mit Unix Zeilenende.
"\
999 "Ich bin eine ziemlich lange
, steile
, scharfe Zeile mit Unix Zeilenende.
"\
1001 "=VIER
= EQUAL SIGNS
=ON A LINE
=\n"\
1003 "Die letzte Zeile war ein Leerschritt.
\n"\
1007 # MIME encoding (QP) stress message subject
1008 SUB="Äbrä Kä?dä
=brö Fü?di
=bus? \
1009 adadaddsssssssddddddddddddddddddddd\
1010 ddddddddddddddddddddddddddddddddddd\
1011 ddddddddddddddddddddddddddddddddddd\
1012 dddddddddddddddddddd Hallelulja? Od\
1013 er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
1014 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
1015 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f\
1016 fffffffffffffffffffffffffffffffffff\
1017 fffffffffffffffffffff ggggggggggggg\
1018 ggggggggggggggggggggggggggggggggggg\
1019 ggggggggggggggggggggggggggggggggggg\
1020 ggggggggggggggggggggggggggggggggggg\
1023 # Three tests for MIME encodign and (a bit) content classification.
1024 # At the same time testing -q FILE, < FILE and -t FILE
1026 # TODO Note: because of our weird putline() handling in <-> collect.c
1028 < "${BODY}" MAILRC=/dev/null \
1029 "${SNAIL}" -nSstealthmua -Sexpandaddr -a "${BODY}" -s "${SUB}" "${MBOX}"
1030 cksum_test content:001-0 "${MBOX}" '3310338268 6375'
1033 < "${BODY}" MAILRC=/dev/null \
1034 "${SNAIL}" ${ARGS} -Snodot -a "${BODY}" -s "${SUB}" "${MBOX}"
1035 cksum_test content:001 "${MBOX}" '62505451 6374'
1038 < /dev/null MAILRC=/dev/null \
1039 "${SNAIL}" ${ARGS} -a "${BODY}" -s "${SUB}" \
1040 -q "${BODY}" "${MBOX}"
1041 cksum_test content:002 "${MBOX}" '3310338268 6375'
1044 ( echo "To
: ${MBOX}" && echo "Subject
: ${SUB}" && echo &&
1046 ) | MAILRC=/dev/null "${SNAIL}" ${ARGS} -Snodot -a "${BODY}" -t
1047 cksum_test content:003 "${MBOX}" '62505451 6374'
1049 # Test for [260e19d] (Juergen Daubert)
1051 echo body | MAILRC=/dev/null "${SNAIL}" ${ARGS} "${MBOX}"
1052 cksum_test content:004 "${MBOX}" '3729232114 11'
1054 # Sending of multiple mails in a single invocation
1056 ( printf "m
${MBOX}\n~s subject1
\nE
-Mail Körper
1\n.
\n" &&
1057 printf "m
${MBOX}\n~s subject2
\nEmail body
2\n.
\n" &&
1059 ) | MAILRC=/dev/null "${SNAIL}" ${ARGS}
1060 cksum_test content:005 "${MBOX}" '773028641 184'
1064 # "Test
for" [d6f316a] (Gavin Troy)
1066 printf "m
${MBOX}\n~s subject1
\nEmail body
\n.
\nfi
${MBOX}\np
\nx
\n" |
1067 MAILRC=/dev/null "${SNAIL}" ${ARGS} \
1068 -Spipe-text/plain="${cat}" > "${BODY}"
1069 ${sed} -e 1d < "${BODY}" > "${MBOX}"
1070 cksum_test content
:006 "${MBOX}" '654030565 45'
1072 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
1073 # TODO Note: because of our weird putline() handling in <-> collect.c
1075 LC_ALL
=C
${awk} 'BEGIN{
1076 for(i = 0; i < 10000; ++i)
1078 #printf "\xF0\x90\x87\x90"
1080 MAILRC
=/dev
/null
"${SNAIL}" -nSstealthmua -Sexpandaddr \
1081 -s TestSubject
"${MBOX}"
1082 cksum_test content
:007-0 "${MBOX}" '2747333583 61729'
1085 LC_ALL
=C
${awk} 'BEGIN{
1086 for(i = 0; i < 10000; ++i)
1088 #printf "\xF0\x90\x87\x90"
1090 MAILRC
=/dev
/null
"${SNAIL}" ${ARGS} -s TestSubject "${MBOX}"
1091 cksum_test content
:007 "${MBOX}" '3343002941 61728'
1093 ## Test some more corner cases for header bodies (as good as we can today) ##
1098 MAILRC
=/dev
/null
"${SNAIL}" ${ARGS} \
1099 -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̲' \
1101 cksum_test content
:008 "${MBOX}" '3872015771 288'
1103 # Single word (overlong line split -- bad standard! Requires injection of
1104 # artificial data!! Bad can be prevented by using RFC 2047 encoding)
1106 i
=`LC_ALL=C ${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
1107 echo | MAILRC
=/dev
/null
"${SNAIL}" ${ARGS} -s "${i}" "${MBOX}"
1108 cksum_test content
:009 "${MBOX}" '2048460448 1631'
1110 # Combination of encoded words, space and tabs of varying sort
1112 echo | MAILRC
=/dev
/null
"${SNAIL}" ${ARGS} \
1113 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
1114 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
1115 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
1116 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
1117 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
1119 cksum_test content
:010 "${MBOX}" '1272213842 504'
1121 # Overlong multibyte sequence that must be forcefully split
1122 # todo This works even before v15.0, but only by accident
1124 echo | MAILRC
=/dev
/null
"${SNAIL}" ${ARGS} \
1125 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
1126 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
1127 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
1129 cksum_test content
:011 "${MBOX}" '2972351879 572'
1134 MAILRC
=/dev
/null
"${SNAIL}" ${ARGS} \
1135 -s "1-1 B2 B3 B4 B5 B6 B\
1136 1-2 B2 B3 B4 B5 B6 B\
1137 1-3 B2 B3 B4 B5 B6 B\
1138 1-4 B2 B3 B4 B5 B6 B\
1139 1-5 B2 B3 B4 B5 B6 B\
1140 1-6 B2 B3 B4 B5 B6 " \
1142 cksum_test content
:012 "${MBOX}" '2467265470 210'
1144 # Leading and trailing WS
1147 MAILRC
=/dev
/null
"${SNAIL}" ${ARGS} \
1148 -s " 2-1 B2 B3 B4 B5 B6 B\
1149 1-2 B2 B3 B4 B5 B6 B\
1150 1-3 B2 B3 B4 B5 B6 B\
1151 1-4 B2 B3 B4 B5 B6 " \
1153 cksum_test content
:013 "${MBOX}" '4119922611 149'
1155 # Quick'n dirty RFC 2231 test; i had more when implementing it, but until we
1156 # have a (better) test framework materialize a quick shot
1160 : > 'diet\ is \curd.txt'
1161 : > diet
\"is
\" curd.txt
1163 : > 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
1164 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
1165 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
1166 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
1168 MAILRC
=/dev
/null
"${SNAIL}" ${ARGS} -Snodot \
1169 -a "ma'ger.txt" -a "mä'ger.txt" \
1170 -a 'diet\\\ is\ \\curd.txt' -a diet
\"is
\" curd.txt \
1172 -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 \
1173 -a höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt \
1174 -a hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
1175 -a ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
1177 ${rm} -f "ma'ger.txt" "mä'ger.txt" 'diet\ is \curd.txt' \
1178 diet
\"is
\" curd.txt höde-tröge.txt \
1179 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 \
1180 höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt \
1181 hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
1182 ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
1183 cksum_test content
:14 "${MBOX}" '1106643854 2453'
1185 printf "Resend ${BODY}\nx\n" |
1186 MAILRC
=/dev
/null
"${SNAIL}" ${ARGS} -f "${MBOX}"
1187 cksum_test content
:14-2 "${MBOX}" '1106643854 2453'
1189 ${rm} -f "${BODY}" "${MBOX}"
1193 if have_feat DEVEL; then
1194 ARGS="${ARGS} -Smemdebug"
1201 if [ -z "${CHECK_ONLY}" ]; then
1207 [ ${ESTAT} -eq 0 ] && echo Ok || echo >&2 'Errors occurred'