Add *r-option-implicit* (Felipe Gasper, Martin Neitzel)..
[s-mailx.git] / cc-test.sh
blob1edc052d99e538a9772f08b91f8b5e2b4d66af61
1 #!/bin/sh -
2 #@ Usage: ./cc-test.sh [--check-only [s-nail-binary]]
4 SNAIL=./s-nail
5 ARGS='-:/ -# -Sencoding=quoted-printable -Sstealthmua -Snosave -Sexpandaddr=restrict -Sdotlock-ignore-error'
6 CONF=./make.rc
7 BODY=./.cc-body.txt
8 MBOX=./.cc-test.mbox
9 MAIL=/dev/null
10 #UTF8_LOCALE= autodetected unless set
12 if ( command -v command ) >/dev/null 2>&1; then :; else
13 command() {
14 shift
15 which "${@}"
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`}
27 ## -- >8 -- 8< -- ##
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
32 TZ=UTC
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!'
42 SHELL=/bin/sh
43 export SHELL
46 if [ -z "${UTF8_LOCALE}" ]; then
47 UTF8_LOCALE=
48 if command -v locale >/dev/null 2>&1; then
49 UTF8_LOCALE=`locale -a | { m=
50 while read n; do
51 if { echo ${n} | ${grep} -i 'utf-\{0,1\}8'; } >/dev/null 2>&1; then
52 m=${n}
53 if { echo ${n} | ${grep} -e POSIX -e en_EN -e en_US; }; then
54 exit 0
57 m=${n}
58 done
59 echo ${m}
64 ESTAT=0
66 usage() {
67 echo >&2 "Usage: ./cc-test.sh [--check-only [s-nail-binary]]"
68 exit 1
71 CHECK_ONLY=
72 [ ${#} -gt 0 ] && {
73 [ "${1}" = --check-only ] || usage
74 [ ${#} -gt 2 ] && usage
75 [ ${#} -eq 2 ] && SNAIL="${2}"
76 [ -x "${SNAIL}" ] || usage
77 CHECK_ONLY=1
80 # cc_all_configs()
81 # Test all configs TODO doesn't cover all *combinations*, stupid!
82 cc_all_configs() {
83 < ${CONF} ${awk} '
84 BEGIN {
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
90 NOTME["OPT_NYD2"] = 1
91 i = 0
93 /^[[:space:]]*OPT_/ {
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 =
97 #sub(/=.*$/, "")
98 $1 = substr($1, 1, index($1, "=") - 1)
99 if (NOTME[$1])
100 next
101 data[i++] = $1
103 END {
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)
109 printf data[k] "=1 "
110 for (k = j; k < i; ++k)
111 printf data[k] "=0 "
112 printf "OPT_AUTOCC=1\n"
114 for (j = 1; j < i; ++j) {
115 for (k = 1; k < j; ++k)
116 printf data[k] "=0 "
117 for (k = j; k < i; ++k)
118 printf data[k] "=1 "
119 printf "OPT_AUTOCC=1\n"
121 # With debug
122 for (j = 1; j < i; ++j) {
123 for (k = 1; k < j; ++k)
124 printf data[k] "=1 "
125 for (k = j; k < i; ++k)
126 printf data[k] "=0 "
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)
132 printf data[k] "=0 "
133 for (k = j; k < i; ++k)
134 printf data[k] "=1 "
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"
156 ' | while read c; do
157 printf "\n\n##########\n$c\n"
158 printf "\n\n##########\n$c\n" >&2
159 sh -c "${MAKE} ${c}"
160 t_all
161 done
162 ${MAKE} distclean
165 # cksum_test()
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
168 cksum_test() {
169 tid=${1} f=${2} s=${3}
170 printf "${tid}: "
171 csum="`${sed} -e '/^From /d' \
172 -e '/^ boundary=/d' -e '/^--=-=/d' < \"${f}\" \
173 -e '/^\[-- Message/d' | ${cksum}`";
174 if [ "${csum}" = "${s}" ]; then
175 printf 'ok\n'
176 else
177 ESTAT=1
178 printf 'error: checksum mismatch (got %s)\n' "${csum}"
182 have_feat() {
183 ( "${SNAIL}" ${ARGS} -X'echo $features' -Xx | ${grep} +${1} ) >/dev/null 2>&1
186 # t_behave()
187 # Basic (easily testable) behaviour tests
188 t_behave() {
189 __behave_x_opt_input_command_stack
190 __behave_wysh
191 __behave_ifelse
192 __behave_localopts
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}"
204 echo 1
205 define mac0 {
206 echo mac0-1
208 call mac0
209 echo 2
210 wysh source '\
211 echo "define mac1 {";\
212 echo " echo mac1-1";\
213 echo " call mac0";\
214 echo " echo mac1-2";\
215 echo " call mac2";\
216 echo " echo mac1-3";\
217 echo "}";\
218 echo "echo 1-1";\
219 echo "define mac2 {";\
220 echo " echo mac2-1";\
221 echo " call mac0";\
222 echo " echo mac2-2";\
223 echo "}";\
224 echo "echo 1-2";\
225 echo "call mac1";\
226 echo "echo 1-3";\
227 echo "wysh source \"\
228 echo echo 1-1-1;\
229 echo call mac0;\
230 echo echo 1-1-2;\
231 | \"";\
232 echo "echo 1-4";\
234 echo 3
235 call mac2
236 echo 4
237 undefine *
238 __EOT
240 # The -X option supports multiline arguments, and those can internally use
241 # reverse solidus newline escaping. And all -X options are joined...
242 APO=\'
243 < "${BODY}" "${SNAIL}" ${ARGS} \
244 -X 'e\' \
245 -X ' c\' \
246 -X ' h\' \
247 -X ' o \' \
248 -X 1 \
250 define mac0 {
251 echo mac0-1
253 call mac0
254 echo 2
257 wysh source '${APO}'\
258 echo "define mac1 {";\
259 echo " echo mac1-1";\
260 echo " call mac0";\
261 echo " echo mac1-2";\
262 echo " call mac2";\
263 echo " echo mac1-3";\
264 echo "}";\
265 echo "echo 1-1";\
266 echo "define mac2 {";\
267 echo " echo mac2-1";\
268 echo " call mac0";\
269 echo " echo mac2-2";\
270 echo "}";\
271 echo "echo 1-2";\
272 echo "call mac1";\
273 echo "echo 1-3";\
274 echo "wysh source \"\
275 echo echo 1-1-1;\
276 echo call mac0;\
277 echo echo 1-1-2;\
278 | \"";\
279 echo "echo 1-4";\
280 | '${APO}'
281 echo 3
284 call mac2
285 echo 4
286 undefine *
287 ' > "${MBOX}" 2>/dev/null
288 cksum_test behave:x_opt_input_command_stack "${MBOX}" '270940651 240'
291 __behave_wysh() {
292 # Nestable conditions test
293 ${rm} -f "${BODY}" "${MBOX}"
294 ${cat} <<- '__EOT' > "${BODY}"
296 echo abcd
297 echo a'b'c'd'
298 echo a"b"c"d"
299 echo a$'b'c$'d'
300 echo 'abcd'
301 echo "abcd"
302 echo $'abcd'
303 echo a\ b\ c\ d
304 echo a 'b c' d
305 echo a "b c" d
306 echo a $'b c' d
308 echo 'a$`"\'
309 echo "a\$\`'\"\\"
310 echo $'a\$`\'\"\\'
311 echo $'a\$`\'"\\'
312 # DIET=CURD TIED=
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
319 echo a$'\377'c
320 echo a$'\0377'c
321 echo a$'\400'c
322 echo a$'\0400'c
323 echo a$'\U1100001'c
325 echo a$'b\0c'd
326 echo a$'b\00c'de
327 echo a$'b\000c'df
328 echo a$'b\0000c'dg
329 echo a$'b\x0c'dh
330 echo a$'b\x00c'di
331 echo a$'b\u0'dj
332 echo a$'b\u00'dk
333 echo a$'b\u000'dl
334 echo a$'b\u0000'dm
335 echo a$'b\U0'dn
336 echo a$'b\U00'do
337 echo a$'b\U000'dp
338 echo a$'b\U0000'dq
339 echo a$'b\U00000'dr
340 echo a$'b\U000000'ds
341 echo a$'b\U0000000'dt
342 echo a$'b\U00000000'du
344 echo a$'\cI'b
345 echo a$'\011'b
346 echo a$'\x9'b
347 echo a$'\u9'b
348 echo a$'\U9'b
349 echo a$'\c@'b c d
350 __EOT
352 if [ -z "${UTF8_LOCALE}" ]; then
353 echo 'Skip behave:wysh_unicode, no UTF8_LOCALE'
354 else
355 < "${BODY}" DIET=CURD TIED= \
356 LC_ALL=${UTF8_LOCALE} "${SNAIL}" ${ARGS} 2>/dev/null > "${MBOX}"
357 #abcd
358 #abcd
359 #abcd
360 #abcd
361 #abcd
362 #abcd
363 #abcd
364 #a b c d
365 #a b c d
366 #a b c d
367 #a b c d
368 #a$`"\
369 #a$`'"\
370 #a$`'"\
371 #a$`'"\
372 #a${DIET}b${TIED}c\${DIET}d\${TIED}e
373 #aCURDbc${DIET}d${TIED}e
374 #a${DIET}b${TIED}cCURDde
375 #aAAAAAAAc
376 #aAAÁAAc
377 #aÿc
378 #aÿc
379 #abd
380 #abde
381 #abdf
382 #abdg
383 #ab\fdh
384 #abdi
385 #abdj
386 #abdk
387 #abdl
388 #abdm
389 #abdn
390 #abdo
391 #abdp
392 #abdq
393 #abdr
394 #abds
395 #abdt
396 #abdu
397 #a b
398 #a b
399 #a b
400 #a b
401 #a b
403 cksum_test behave:wysh_unicode "${MBOX}" '475805847 317'
406 < "${BODY}" DIET=CURD TIED= "${SNAIL}" ${ARGS} > "${MBOX}" 2>/dev/null
407 #abcd
408 #abcd
409 #abcd
410 #abcd
411 #abcd
412 #abcd
413 #abcd
414 #a b c d
415 #a b c d
416 #a b c d
417 #a b c d
418 #a$`"\
419 #a$`'"\
420 #a$`'"\
421 #a$`'"\
422 #a${DIET}b${TIED}c\${DIET}d\${TIED}e
423 #aCURDbc${DIET}d${TIED}e
424 #a${DIET}b${TIED}cCURDde
425 #aAAAAAAAc
426 #aAA\u0C1AAc
427 #aÿc
428 #aÿc
429 #abd
430 #abde
431 #abdf
432 #abdg
433 #ab\fdh
434 #abdi
435 #abdj
436 #abdk
437 #abdl
438 #abdm
439 #abdn
440 #abdo
441 #abdp
442 #abdq
443 #abdr
444 #abds
445 #abdt
446 #abdu
447 #a b
448 #a b
449 #a b
450 #a b
451 #a b
453 cksum_test behave:wysh_c "${MBOX}" '1473887148 321'
454 ${rm} -f "${BODY}" "${MBOX}"
457 __behave_ifelse() {
458 # Nestable conditions test
459 ${rm} -f "${MBOX}"
460 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
461 if 0
462 echo 1.err
463 else
464 echo 1.ok
465 endif
466 if 1
467 echo 2.ok
468 else
469 echo 2.err
470 endif
471 if $dietcurd
472 echo 3.err
473 else
474 echo 3.ok
475 endif
476 set dietcurd=yoho
477 if $dietcurd
478 echo 4.ok
479 else
480 echo 4.err
481 endif
482 if $dietcurd == 'yoho'
483 echo 5.ok
484 else
485 echo 5.err
486 endif
487 if $dietcurd != 'yoho'
488 echo 6.err
489 else
490 echo 6.ok
491 endif
492 # Nesting
493 if faLse
494 echo 7.err1
495 if tRue
496 echo 7.err2
497 if yEs
498 echo 7.err3
499 else
500 echo 7.err4
501 endif
502 echo 7.err5
503 endif
504 echo 7.err6
505 else
506 echo 7.ok7
507 if YeS
508 echo 7.ok8
509 if No
510 echo 7.err9
511 else
512 echo 7.ok9
513 endif
514 echo 7.ok10
515 else
516 echo 7.err11
517 if yeS
518 echo 7.err12
519 else
520 echo 7.err13
521 endif
522 endif
523 echo 7.ok14
524 endif
525 if r
526 echo 8.ok1
527 if R
528 echo 8.ok2
529 else
530 echo 8.err2
531 endif
532 echo 8.ok3
533 else
534 echo 8.err1
535 endif
536 if s
537 echo 9.err1
538 else
539 echo 9.ok1
540 if S
541 echo 9.err2
542 else
543 echo 9.ok2
544 endif
545 echo 9.ok3
546 endif
547 # `elif'
548 if $dietcurd == 'yohu'
549 echo 10.err1
550 elif $dietcurd == 'yoha'
551 echo 10.err2
552 elif $dietcurd == 'yohe'
553 echo 10.err3
554 elif $dietcurd == 'yoho'
555 echo 10.ok1
556 if $dietcurd == 'yohu'
557 echo 10.err4
558 elif $dietcurd == 'yoha'
559 echo 10.err5
560 elif $dietcurd == 'yohe'
561 echo 10.err6
562 elif $dietcurd == 'yoho'
563 echo 10.ok2
564 if $dietcurd == 'yohu'
565 echo 10.err7
566 elif $dietcurd == 'yoha'
567 echo 10.err8
568 elif $dietcurd == 'yohe'
569 echo 10.err9
570 elif $dietcurd == 'yoho'
571 echo 10.ok3
572 else
573 echo 10.err10
574 endif
575 else
576 echo 10.err11
577 endif
578 else
579 echo 10.err12
580 endif
581 # integer conversion, <..>..
582 set dietcurd=10
583 if $dietcurd < 11
584 echo 11.ok1
585 if $dietcurd > 9
586 echo 11.ok2
587 else
588 echo 11.err2
589 endif
590 if $dietcurd == 10
591 echo 11.ok3
592 else
593 echo 11.err3
594 endif
595 if $dietcurd >= 10
596 echo 11.ok4
597 else
598 echo 11.err4
599 endif
600 if $dietcurd <= 10
601 echo 11.ok5
602 else
603 echo 11.err5
604 endif
605 if $dietcurd >= 11
606 echo 11.err6
607 else
608 echo 11.ok6
609 endif
610 if $dietcurd <= 9
611 echo 11.err7
612 else
613 echo 11.ok7
614 endif
615 else
616 echo 11.err1
617 endif
618 set dietcurd=Abc
619 if $dietcurd < aBd
620 echo 12.ok1
621 if $dietcurd > abB
622 echo 12.ok2
623 else
624 echo 12.err2
625 endif
626 if $dietcurd == aBC
627 echo 12.ok3
628 else
629 echo 12.err3
630 endif
631 if $dietcurd >= AbC
632 echo 12.ok4
633 else
634 echo 12.err4
635 endif
636 if $dietcurd <= ABc
637 echo 12.ok5
638 else
639 echo 12.err5
640 endif
641 if $dietcurd >= abd
642 echo 12.err6
643 else
644 echo 12.ok6
645 endif
646 if $dietcurd <= abb
647 echo 12.err7
648 else
649 echo 12.ok7
650 endif
651 else
652 echo 12.err1
653 endif
654 if $dietcurd =@ aB
655 echo 13.ok
656 else
657 echo 13.err
658 endif
659 if $dietcurd =@ bC
660 echo 14.ok
661 else
662 echo 14.err
663 endif
664 if $dietcurd !@ aB
665 echo 15.err
666 else
667 echo 15.ok
668 endif
669 if $dietcurd !@ bC
670 echo 15.err
671 else
672 echo 15.ok
673 endif
674 if $dietcurd =@ Cd
675 echo 16.err
676 else
677 echo 16.ok
678 endif
679 if $dietcurd !@ Cd
680 echo 17.ok
681 else
682 echo 17.err
683 endif
684 set diet=abc curd=abc
685 if $diet == $curd
686 echo 18.ok
687 else
688 echo 18.err
689 endif
690 set diet=abc curd=abcd
691 if $diet != $curd
692 echo 19.ok
693 else
694 echo 19.err
695 endif
696 # 1. Shitty grouping capabilities as of today
697 unset diet curd ndefined
698 if [ [ false ] || [ false ] || [ true ] ] && [ [ false ] || [ true ] ] && \
699 [ yes ]
700 echo 20.ok
701 else
702 echo 20.err
703 endif
704 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
705 echo 21.ok
706 else
707 echo 21.err
708 endif
709 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
710 echo 22.ok
711 else
712 echo 22.err
713 endif
714 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
715 echo 23.ok
716 else
717 echo 23.err
718 endif
719 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
720 echo 24.err
721 else
722 echo 24.ok
723 endif
724 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
725 && [ no ] || [ yes ]
726 echo 25.ok
727 else
728 echo 25.err
729 endif
730 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
731 echo 26.ok
732 else
733 echo 26.err
734 endif
735 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
736 echo 27.err
737 else
738 echo 27.ok
739 endif
740 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
741 echo 28.err
742 else
743 echo 28.ok
744 endif
745 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
746 echo 29.err
747 else
748 echo 29.ok
749 endif
750 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
751 echo 30.err
752 else
753 echo 30.ok
754 endif
755 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
756 echo 31.ok
757 else
758 echo 31.err
759 endif
760 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
761 echo 32.err
762 else
763 echo 32.ok
764 endif
765 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
766 echo 33.ok
767 else
768 echo 33.err
769 endif
770 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
771 echo 34.err
772 else
773 echo 34.ok
774 endif
775 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
776 echo 35.ok
777 else
778 echo 35.err
779 endif
780 set diet=yo curd=ho
781 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
782 echo 36.err
783 else
784 echo 36.ok
785 endif
786 set ndefined
787 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
788 echo 37.ok
789 else
790 echo 37.err
791 endif
792 # 2. Shitty grouping capabilities as of today
793 unset diet curd ndefined
794 if [ false || false || true ] && [ false || true ] && yes
795 echo 40.ok
796 else
797 echo 40.err
798 endif
799 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
800 echo 41.ok
801 else
802 echo 41.err
803 endif
804 if [ 1 || 0 || 0 || 0 ]
805 echo 42.ok
806 else
807 echo 42.err
808 endif
809 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
810 echo 43.ok
811 else
812 echo 43.err
813 endif
814 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
815 echo 44.err
816 else
817 echo 44.ok
818 endif
819 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
820 echo 45.ok
821 else
822 echo 45.err
823 endif
824 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
825 echo 46.ok
826 else
827 echo 46.err
828 endif
829 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
830 echo 47.err
831 else
832 echo 47.ok
833 endif
834 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
835 echo 48.err
836 else
837 echo 48.ok
838 endif
839 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
840 echo 49.err
841 else
842 echo 49.ok
843 endif
844 if 1 || 0 || 0 || 0 && 0
845 echo 50.err
846 else
847 echo 50.ok
848 endif
849 if 1 || 0 || 0 || 0 && 1
850 echo 51.ok
851 else
852 echo 51.err
853 endif
854 if 0 || 0 || 0 || 1 && 0
855 echo 52.err
856 else
857 echo 52.ok
858 endif
859 if 0 || 0 || 0 || 1 && 1
860 echo 53.ok
861 else
862 echo 53.err
863 endif
864 if 0 || 0 || 0 || 1 && 0 || 1 && 0
865 echo 54.err
866 else
867 echo 54.ok
868 endif
869 if 0 || 0 || 0 || 1 && 0 || 1 && 1
870 echo 55.ok
871 else
872 echo 55.err
873 endif
874 set diet=yo curd=ho
875 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
876 echo 56.err
877 else
878 echo 56.ok
879 endif
880 if $diet == 'yo' && $curd == 'ho' && $ndefined
881 echo 57.err
882 else
883 echo 57.ok
884 endif
885 set ndefined
886 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
887 echo 57.ok
888 else
889 echo 57.err
890 endif
891 if $diet == 'yo' && $curd == 'ho' && $ndefined
892 echo 58.ok
893 else
894 echo 58.err
895 endif
896 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
897 echo 59.ok
898 else
899 echo 59.err
900 endif
901 # Some more en-braced variables
902 set diet=yo curd=ho
903 if ${diet} == ${curd}
904 echo 70.err
905 else
906 echo 70.ok
907 endif
908 if ${diet} != ${curd}
909 echo 71.ok
910 else
911 echo 71.err
912 endif
913 if $diet == ${curd}
914 echo 72.err
915 else
916 echo 72.ok
917 endif
918 if ${diet} == $curd
919 echo 73.err
920 else
921 echo 73.ok
922 endif
923 # Unary !
924 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
925 echo 80.ok
926 else
927 echo 80.err
928 endif
929 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
930 echo 81.ok
931 else
932 echo 81.err
933 endif
934 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
935 echo 82.ok
936 else
937 echo 82.err
938 endif
939 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
940 echo 83.err
941 else
942 echo 83.ok
943 endif
944 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
945 echo 84.err
946 else
947 echo 84.ok
948 endif
949 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
950 echo 85.err
951 else
952 echo 85.ok
953 endif
954 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
955 echo 86.err
956 else
957 echo 86.ok
958 endif
959 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
960 echo 87.ok
961 else
962 echo 87.err
963 endif
964 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
965 echo 88.ok
966 else
967 echo 88.err
968 endif
969 # Unary !, odd
970 if ! 0 && ! ! 1 && ! ! ! 0 && 3
971 echo 90.ok
972 else
973 echo 90.err
974 endif
975 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
976 echo 91.ok
977 else
978 echo 91.err
979 endif
980 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
981 echo 92.ok
982 else
983 echo 92.err
984 endif
985 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
986 echo 93.err
987 else
988 echo 93.ok
989 endif
990 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
991 echo 94.ok
992 else
993 echo 94.err
994 endif
995 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
996 echo 95.err
997 else
998 echo 95.ok
999 endif
1000 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
1001 echo 96.err
1002 else
1003 echo 96.ok
1004 endif
1005 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
1006 echo 97.ok
1007 else
1008 echo 97.err
1009 endif
1010 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
1011 echo 98.ok
1012 else
1013 echo 98.err
1014 endif
1015 __EOT
1016 cksum_test behave:if-normal "${MBOX}" '557629289 631'
1018 if have_feat regex; then
1019 ${rm} -f "${MBOX}"
1020 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
1021 set dietcurd=yoho
1022 if $dietcurd =~ '^yo.*'
1023 echo 1.ok
1024 else
1025 echo 1.err
1026 endif
1027 if $dietcurd =~ '^yoho.+'
1028 echo 2.err
1029 else
1030 echo 2.ok
1031 endif
1032 if $dietcurd !~ '.*ho$'
1033 echo 3.err
1034 else
1035 echo 3.ok
1036 endif
1037 if $dietcurd !~ '.+yoho$'
1038 echo 4.ok
1039 else
1040 echo 4.err
1041 endif
1042 if [ $dietcurd !~ '.+yoho$' ]
1043 echo 5.ok
1044 else
1045 echo 5.err
1046 endif
1047 if ! [ $dietcurd =~ '.+yoho$' ]
1048 echo 6.ok
1049 else
1050 echo 6.err
1051 endif
1052 if ! ! [ $dietcurd !~ '.+yoho$' ]
1053 echo 7.ok
1054 else
1055 echo 7.err
1056 endif
1057 if ! [ ! [ $dietcurd !~ '.+yoho$' ] ]
1058 echo 8.ok
1059 else
1060 echo 8.err
1061 endif
1062 if [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1063 echo 9.ok
1064 else
1065 echo 9.err
1066 endif
1067 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1068 echo 10.err
1069 else
1070 echo 10.ok
1071 endif
1072 if ! ! ! $dietcurd !~ '.+yoho$'
1073 echo 11.err
1074 else
1075 echo 11.ok
1076 endif
1077 if ! ! ! $dietcurd =~ '.+yoho$'
1078 echo 12.ok
1079 else
1080 echo 12.err
1081 endif
1082 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1083 echo 13.ok
1084 else
1085 echo 13.err
1086 endif
1087 set diet=abc curd='^abc$'
1088 if $diet =~ $curd
1089 echo 14.ok
1090 else
1091 echo 14.err
1092 endif
1093 set diet=abc curd='^abcd$'
1094 if $diet !~ $curd
1095 echo 15.ok
1096 else
1097 echo 15.err
1098 endif
1099 __EOT
1100 cksum_test behave:if-regex "${MBOX}" '439960016 81'
1104 __behave_localopts() {
1105 # Nestable conditions test
1106 ${rm} -f "${MBOX}"
1107 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
1108 define t2 {
1109 echo in: t2
1110 set t2=t2
1111 echo $t2
1113 define t1 {
1114 echo in: t1
1115 set gv1=gv1
1116 localopts on
1117 set lv1=lv1 lv2=lv2
1118 set lv3=lv3
1119 call t2
1120 localopts off
1121 set gv2=gv2
1122 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1124 define t0 {
1125 echo in: t0
1126 call t1
1127 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1128 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
1130 account trouble {
1131 echo in: trouble
1132 call t0
1134 call t0
1135 unset gv1 gv2
1136 account trouble
1137 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1138 account null
1139 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1140 __EOT
1141 #in: t0
1142 #in: t1
1143 #in: t2
1145 #gv1 lv1 lv2 lv3 gv2, t2
1146 #gv1 gv2,
1147 #gv1 gv2,
1148 #in: trouble
1149 #in: t0
1150 #in: t1
1151 #in: t2
1153 #gv1 lv1 lv2 lv3 gv2, t2
1154 #gv1 gv2,
1155 #gv1 gv2,
1156 #active trouble: gv1 gv2,
1157 #active null: ,
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
1164 [ req ]
1165 default_bits = 1024
1166 default_keyfile = keyfile.pem
1167 distinguished_name = req_distinguished_name
1168 attributes = req_attributes
1169 prompt = no
1170 output_password =
1172 [ req_distinguished_name ]
1173 C = GB
1174 ST = Over the
1175 L = rainbow
1176 O = S-nail
1177 OU = S-nail.smime
1178 CN = S-nail.test
1179 emailAddress = test@localhost
1181 [ req_attributes ]
1182 challengePassword =
1183 _EOT
1184 openssl req -x509 -nodes -days 3650 -config ./t.conf \
1185 -newkey rsa:1024 -keyout ./tkey.pem -out ./tcert.pem >/dev/null 2>&1
1186 ${rm} -f ./t.conf
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
1201 printf 'ok\n'
1202 else
1203 printf 'error: verification failed\n'
1204 ESTAT=1
1205 ${rm} -f ./VERIFY ./tkey.pem ./tcert.pem ./tpair.pem
1206 return
1208 printf ' .. disproof via openssl smime(1): '
1209 if openssl smime -verify -CAfile ./tcert.pem \
1210 -in ./VERIFY >/dev/null 2>&1; then
1211 printf 'ok\n'
1212 else
1213 printf 'failed\n'
1214 ESTAT=1
1215 ${rm} -f ./VERIFY ./tkey.pem ./tcert.pem ./tpair.pem
1216 return
1218 ${rm} -rf ./VERIFY
1220 # (signing +) encryption / decryption
1221 ${cat} <<-_EOT > ./tsendmail.sh
1222 #!/bin/sh -
1223 (echo 'From S-Postman Thu May 10 20:40:54 2012' && ${cat}) > ./ENCRYPT
1224 _EOT
1225 chmod 0755 ./tsendmail.sh
1227 printf "behave:s/mime:encrypt+sign/decrypt+verify: "
1228 echo bla |
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
1236 # TODO CHECK
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
1247 printf 'ok\n'
1248 else
1249 ESTAT=1
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
1255 printf 'ok\n'
1256 else
1257 printf 'failed\n'
1258 ESTAT=1
1260 ${sed} -e '/^Date:/d' -e '/^X-Decoding-Date/d' \
1261 -e \
1262 '/^Content-Disposition: attachment; filename="smime.p7s"/,/^-- /d' \
1263 < ./DECRYPT > ./ENCRYPT
1264 cksum_test ".. checksum of decrypted content" "./ENCRYPT" '82649489 454'
1266 ${rm} -f ./DECRYPT
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
1284 printf 'ok\n'
1285 else
1286 ESTAT=1
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
1292 printf 'ok\n'
1293 else
1294 printf 'failed\n'
1295 ESTAT=1
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
1305 # t_content()
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
1310 t_content() {
1311 ${rm} -f "${BODY}" "${MBOX}"
1313 # MIME encoding (QP) stress message body
1314 printf \
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"\
1332 ".\r\n"\
1333 "Die letzte Zeile war nur ein Punkt.\r\n"\
1334 "..\r\n"\
1335 "Das waren deren zwei.\r\n"\
1336 " \r\n"\
1337 "Die letzte Zeile war ein Leerschritt.\n"\
1338 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
1339 "Prösterchen.\r\n"\
1340 ".\n"\
1341 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
1342 "..\n"\
1343 "Das waren deren zwei. ditto.\n"\
1344 "Prösterchen.\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"\
1348 "ditto.\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"\
1351 "\n"\
1352 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
1353 "\n"\
1354 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
1355 "3\n"\
1356 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
1357 "34\n"\
1358 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
1359 "345\n"\
1360 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
1361 "3456\n"\
1362 "QP am Zeilenende über soft-nl hinweg\n"\
1363 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
1364 "ö123\n"\
1365 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
1366 "1ö23\n"\
1367 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
1368 "12ö3\n"\
1369 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
1370 "123ö\n"\
1371 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
1372 " \n"\
1373 "Die letzte Zeile war ein Leerschritt.\n"\
1374 ' '\
1375 > "${BODY}"
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\
1391 gggggggggggggggg"
1393 # Three tests for MIME encodign and (a bit) content classification.
1394 # At the same time testing -q FILE, < FILE and -t FILE
1396 ${rm} -f "${MBOX}"
1397 < "${BODY}" "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
1398 -a "${BODY}" -s "${SUB}" "${MBOX}"
1399 cksum_test content:001 "${MBOX}" '2356108758 6413'
1401 ${rm} -f "${MBOX}"
1402 < /dev/null "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
1403 -a "${BODY}" -s "${SUB}" -q "${BODY}" "${MBOX}"
1404 cksum_test content:002 "${MBOX}" '2356108758 6413'
1406 ${rm} -f "${MBOX}"
1407 ( echo "To: ${MBOX}" && echo "Subject: ${SUB}" && echo &&
1408 ${cat} "${BODY}"
1409 ) | "${SNAIL}" ${ARGS} ${ADDARG_UNI} -Snodot -a "${BODY}" -t
1410 cksum_test content:003 "${MBOX}" '2356108758 6413'
1412 # Test for [260e19d] (Juergen Daubert)
1413 ${rm} -f "${MBOX}"
1414 echo body | "${SNAIL}" ${ARGS} "${MBOX}"
1415 cksum_test content:004 "${MBOX}" '4004005686 49'
1417 # Sending of multiple mails in a single invocation
1418 ${rm} -f "${MBOX}"
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" &&
1421 echo x
1422 ) | "${SNAIL}" ${ARGS} ${ADDARG_UNI}
1423 cksum_test content:005 "${MBOX}" '2157252578 260'
1425 ## $BODY CHANGED
1427 # "Test for" [d6f316a] (Gavin Troy)
1428 ${rm} -f "${MBOX}"
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?
1435 ${rm} -f "${MBOX}"
1436 ${awk} 'BEGIN{
1437 for(i = 0; i < 10000; ++i)
1438 printf "\xC3\xBC"
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) ##
1446 ${rm} -f "${MBOX}"
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̲' \
1449 "${MBOX}"
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)
1454 ${rm} -f "${MBOX}"
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
1460 ${rm} -f "${MBOX}"
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" \
1467 "${MBOX}"
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
1472 ${rm} -f "${MBOX}"
1473 echo | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
1474 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
1475 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
1476 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
1477 "${MBOX}"
1478 cksum_test content:011 "${MBOX}" '454973928 610'
1480 # Trailing WS
1481 ${rm} -f "${MBOX}"
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 " \
1489 "${MBOX}"
1490 cksum_test content:012 "${MBOX}" '1497528261 248'
1492 # Leading and trailing WS
1493 ${rm} -f "${MBOX}"
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 " \
1499 "${MBOX}"
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
1504 ${rm} -f "${MBOX}"
1505 : > "ma'ger.txt"
1506 : > "mä'ger.txt"
1507 : > 'diet\ is \curd.txt'
1508 : > 'diet "is" curd.txt'
1509 : > höde-tröge.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' \
1517 -a höde-tröge.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 \
1522 "${MBOX}"
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'
1530 # `resend' test
1531 printf "Resend ${BODY}\nx\n" | "${SNAIL}" ${ARGS} -f "${MBOX}"
1532 cksum_test content:14-2 "${MBOX}" '589846634 2491'
1534 ${rm} -f "${BODY}" "${MBOX}"
1537 t_all() {
1538 if have_feat devel; then
1539 ARGS="${ARGS} -Smemdebug"
1540 export ARGS
1542 t_behave
1543 t_content
1546 if [ -z "${CHECK_ONLY}" ]; then
1547 cc_all_configs
1548 else
1549 t_all
1552 [ ${ESTAT} -eq 0 ] && echo Ok || echo >&2 'Errors occurred'
1554 exit ${ESTAT}
1555 # s-sh-mode