mk-release.inc: auto-append checksum file to announcement mail
[s-mailx.git] / cc-test.sh
blobaed8cf15c5f4b4da8bb5986f4053048d24e9c3d6
1 #!/bin/sh -
2 #@ Usage: ./cc-test.sh [--check-only [s-nail-binary]]
4 SNAIL=./s-nail
5 ARGS='-:/ -# -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_NOALLOCA"] = 1
90 NOTME["OPT_NOMEMDBG"] = 1
91 NOTME["OPT_NYD2"] = 1
92 i = 0
94 /^[[:space:]]*OPT_/ {
95 sub(/^[[:space:]]*/, "")
96 # This bails for UnixWare 7.1.4 awk(1), but preceeding = with \
97 # does not seem to be a compliant escape for =
98 #sub(/=.*$/, "")
99 $1 = substr($1, 1, index($1, "=") - 1)
100 if (NOTME[$1])
101 next
102 data[i++] = $1
104 END {
105 # Doing this completely sequentially and not doing make distclean in
106 # between runs should effectively result in lesser compilations.
107 # It is completely dumb nonetheless... TODO
108 for (j = 1; j < i; ++j) {
109 for (k = 1; k < j; ++k)
110 printf data[k] "=1 "
111 for (k = j; k < i; ++k)
112 printf data[k] "=0 "
113 printf "OPT_AUTOCC=1\n"
115 for (j = 1; j < i; ++j) {
116 for (k = 1; k < j; ++k)
117 printf data[k] "=0 "
118 for (k = j; k < i; ++k)
119 printf data[k] "=1 "
120 printf "OPT_AUTOCC=1\n"
122 # With debug
123 for (j = 1; j < i; ++j) {
124 for (k = 1; k < j; ++k)
125 printf data[k] "=1 "
126 for (k = j; k < i; ++k)
127 printf data[k] "=0 "
128 printf "OPT_AUTOCC=1\n"
129 printf "OPT_DEBUG=1\n"
131 for (j = 1; j < i; ++j) {
132 for (k = 1; k < j; ++k)
133 printf data[k] "=0 "
134 for (k = j; k < i; ++k)
135 printf data[k] "=1 "
136 printf "OPT_AUTOCC=1\n"
137 printf "OPT_DEBUG=1\n"
140 printf "CONFIG=NULL OPT_AUTOCC=0\n"
141 printf "CONFIG=NULL OPT_AUTOCC=1\n"
142 printf "CONFIG=NULLI OPT_AUTOCC=0\n"
143 printf "CONFIG=NULLI OPT_AUTOCC=1\n"
144 printf "CONFIG=MINIMAL OPT_AUTOCC=0\n"
145 printf "CONFIG=MINIMAL OPT_AUTOCC=1\n"
146 printf "CONFIG=MEDIUM OPT_AUTOCC=0\n"
147 printf "CONFIG=MEDIUM OPT_AUTOCC=1\n"
148 printf "CONFIG=NETSEND OPT_AUTOCC=0\n"
149 printf "CONFIG=NETSEND OPT_AUTOCC=1\n"
150 printf "CONFIG=MAXIMAL OPT_AUTOCC=0\n"
151 printf "CONFIG=MAXIMAL OPT_AUTOCC=1\n"
152 printf "CONFIG=DEVEL OPT_AUTOCC=0\n"
153 printf "CONFIG=DEVEL OPT_AUTOCC=1\n"
154 printf "CONFIG=ODEVEL OPT_AUTOCC=0\n"
155 printf "CONFIG=ODEVEL OPT_AUTOCC=1\n"
157 ' | while read c; do
158 printf "\n\n##########\n$c\n"
159 printf "\n\n##########\n$c\n" >&2
160 sh -c "${MAKE} ${c}"
161 t_all
162 done
163 ${MAKE} distclean
166 # cksum_test()
167 # Read mailbox $2, strip non-constant headers and MIME boundaries, query the
168 # cksum(1) of the resulting data and compare against the checksum $3
169 cksum_test() {
170 tid=${1} f=${2} s=${3}
171 printf "${tid}: "
172 csum="`${sed} -e '/^From /d' \
173 -e '/^ boundary=/d' -e '/^--=-=/d' < \"${f}\" \
174 -e '/^\[-- Message/d' | ${cksum}`";
175 if [ "${csum}" = "${s}" ]; then
176 printf 'ok\n'
177 else
178 ESTAT=1
179 printf 'error: checksum mismatch (got %s)\n' "${csum}"
183 have_feat() {
184 ( "${SNAIL}" ${ARGS} -X'echo $features' -Xx | ${grep} +${1} ) >/dev/null 2>&1
187 # t_behave()
188 # Basic (easily testable) behaviour tests
189 t_behave() {
190 __behave_x_opt_input_command_stack
191 __behave_wysh
192 __behave_ifelse
193 __behave_localopts
195 # FIXME __behave_alias
197 # FIXME __behave_mlist
199 have_feat smime && __behave_smime
202 __behave_x_opt_input_command_stack() {
203 ${rm} -f "${BODY}" "${MBOX}"
204 ${cat} <<- '__EOT' > "${BODY}"
205 echo 1
206 define mac0 {
207 echo mac0-1
209 call mac0
210 echo 2
211 wysh source '\
212 echo "define mac1 {";\
213 echo " echo mac1-1";\
214 echo " call mac0";\
215 echo " echo mac1-2";\
216 echo " call mac2";\
217 echo " echo mac1-3";\
218 echo "}";\
219 echo "echo 1-1";\
220 echo "define mac2 {";\
221 echo " echo mac2-1";\
222 echo " call mac0";\
223 echo " echo mac2-2";\
224 echo "}";\
225 echo "echo 1-2";\
226 echo "call mac1";\
227 echo "echo 1-3";\
228 echo "wysh source \"\
229 echo echo 1-1-1;\
230 echo call mac0;\
231 echo echo 1-1-2;\
232 | \"";\
233 echo "echo 1-4";\
235 echo 3
236 call mac2
237 echo 4
238 undefine *
239 __EOT
241 # The -X option supports multiline arguments, and those can internally use
242 # reverse solidus newline escaping. And all -X options are joined...
243 APO=\'
244 < "${BODY}" "${SNAIL}" ${ARGS} \
245 -X 'e\' \
246 -X ' c\' \
247 -X ' h\' \
248 -X ' o \' \
249 -X 1 \
251 define mac0 {
252 echo mac0-1
254 call mac0
255 echo 2
258 wysh source '${APO}'\
259 echo "define mac1 {";\
260 echo " echo mac1-1";\
261 echo " call mac0";\
262 echo " echo mac1-2";\
263 echo " call mac2";\
264 echo " echo mac1-3";\
265 echo "}";\
266 echo "echo 1-1";\
267 echo "define mac2 {";\
268 echo " echo mac2-1";\
269 echo " call mac0";\
270 echo " echo mac2-2";\
271 echo "}";\
272 echo "echo 1-2";\
273 echo "call mac1";\
274 echo "echo 1-3";\
275 echo "wysh source \"\
276 echo echo 1-1-1;\
277 echo call mac0;\
278 echo echo 1-1-2;\
279 | \"";\
280 echo "echo 1-4";\
281 | '${APO}'
282 echo 3
285 call mac2
286 echo 4
287 undefine *
288 ' > "${MBOX}" 2>/dev/null
289 cksum_test behave:x_opt_input_command_stack "${MBOX}" '270940651 240'
292 __behave_wysh() {
293 # Nestable conditions test
294 ${rm} -f "${BODY}" "${MBOX}"
295 ${cat} <<- '__EOT' > "${BODY}"
297 echo abcd
298 echo a'b'c'd'
299 echo a"b"c"d"
300 echo a$'b'c$'d'
301 echo 'abcd'
302 echo "abcd"
303 echo $'abcd'
304 echo a\ b\ c\ d
305 echo a 'b c' d
306 echo a "b c" d
307 echo a $'b c' d
309 echo 'a$`"\'
310 echo "a\$\`'\"\\"
311 echo $'a\$`\'\"\\'
312 echo $'a\$`\'"\\'
313 # DIET=CURD TIED=
314 echo 'a${DIET}b${TIED}c\${DIET}d\${TIED}e' # COMMENT
315 echo "a${DIET}b${TIED}c\${DIET}d\${TIED}e"
316 echo $'a${DIET}b${TIED}c\${DIET}d\${TIED}e'
318 echo a$'\101\0101\x41\u0041\u41\U00000041\U41'c
319 echo a$'\u0041\u41\u0C1\U00000041\U41'c
320 echo a$'\377'c
321 echo a$'\0377'c
322 echo a$'\400'c
323 echo a$'\0400'c
324 echo a$'\U1100001'c
326 echo a$'b\0c'd
327 echo a$'b\00c'de
328 echo a$'b\000c'df
329 echo a$'b\0000c'dg
330 echo a$'b\x0c'dh
331 echo a$'b\x00c'di
332 echo a$'b\u0'dj
333 echo a$'b\u00'dk
334 echo a$'b\u000'dl
335 echo a$'b\u0000'dm
336 echo a$'b\U0'dn
337 echo a$'b\U00'do
338 echo a$'b\U000'dp
339 echo a$'b\U0000'dq
340 echo a$'b\U00000'dr
341 echo a$'b\U000000'ds
342 echo a$'b\U0000000'dt
343 echo a$'b\U00000000'du
345 echo a$'\cI'b
346 echo a$'\011'b
347 echo a$'\x9'b
348 echo a$'\u9'b
349 echo a$'\U9'b
350 echo a$'\c@'b c d
351 __EOT
353 if [ -z "${UTF8_LOCALE}" ]; then
354 echo 'Skip behave:wysh_unicode, no UTF8_LOCALE'
355 else
356 < "${BODY}" DIET=CURD TIED= \
357 LC_ALL=${UTF8_LOCALE} "${SNAIL}" ${ARGS} 2>/dev/null > "${MBOX}"
358 #abcd
359 #abcd
360 #abcd
361 #abcd
362 #abcd
363 #abcd
364 #abcd
365 #a b c d
366 #a b c d
367 #a b c d
368 #a b c d
369 #a$`"\
370 #a$`'"\
371 #a$`'"\
372 #a$`'"\
373 #a${DIET}b${TIED}c\${DIET}d\${TIED}e
374 #aCURDbc${DIET}d${TIED}e
375 #a${DIET}b${TIED}cCURDde
376 #aAAAAAAAc
377 #aAAÁAAc
378 #aÿc
379 #aÿc
380 #abd
381 #abde
382 #abdf
383 #abdg
384 #ab\fdh
385 #abdi
386 #abdj
387 #abdk
388 #abdl
389 #abdm
390 #abdn
391 #abdo
392 #abdp
393 #abdq
394 #abdr
395 #abds
396 #abdt
397 #abdu
398 #a b
399 #a b
400 #a b
401 #a b
402 #a b
404 cksum_test behave:wysh_unicode "${MBOX}" '475805847 317'
407 < "${BODY}" DIET=CURD TIED= "${SNAIL}" ${ARGS} > "${MBOX}" 2>/dev/null
408 #abcd
409 #abcd
410 #abcd
411 #abcd
412 #abcd
413 #abcd
414 #abcd
415 #a b c d
416 #a b c d
417 #a b c d
418 #a b c d
419 #a$`"\
420 #a$`'"\
421 #a$`'"\
422 #a$`'"\
423 #a${DIET}b${TIED}c\${DIET}d\${TIED}e
424 #aCURDbc${DIET}d${TIED}e
425 #a${DIET}b${TIED}cCURDde
426 #aAAAAAAAc
427 #aAA\u0C1AAc
428 #aÿc
429 #aÿc
430 #abd
431 #abde
432 #abdf
433 #abdg
434 #ab\fdh
435 #abdi
436 #abdj
437 #abdk
438 #abdl
439 #abdm
440 #abdn
441 #abdo
442 #abdp
443 #abdq
444 #abdr
445 #abds
446 #abdt
447 #abdu
448 #a b
449 #a b
450 #a b
451 #a b
452 #a b
454 cksum_test behave:wysh_c "${MBOX}" '1473887148 321'
455 ${rm} -f "${BODY}" "${MBOX}"
458 __behave_ifelse() {
459 # Nestable conditions test
460 ${rm} -f "${MBOX}"
461 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
462 if 0
463 echo 1.err
464 else
465 echo 1.ok
466 endif
467 if 1
468 echo 2.ok
469 else
470 echo 2.err
471 endif
472 if $dietcurd
473 echo 3.err
474 else
475 echo 3.ok
476 endif
477 set dietcurd=yoho
478 if $dietcurd
479 echo 4.ok
480 else
481 echo 4.err
482 endif
483 if $dietcurd == 'yoho'
484 echo 5.ok
485 else
486 echo 5.err
487 endif
488 if $dietcurd != 'yoho'
489 echo 6.err
490 else
491 echo 6.ok
492 endif
493 # Nesting
494 if faLse
495 echo 7.err1
496 if tRue
497 echo 7.err2
498 if yEs
499 echo 7.err3
500 else
501 echo 7.err4
502 endif
503 echo 7.err5
504 endif
505 echo 7.err6
506 else
507 echo 7.ok7
508 if YeS
509 echo 7.ok8
510 if No
511 echo 7.err9
512 else
513 echo 7.ok9
514 endif
515 echo 7.ok10
516 else
517 echo 7.err11
518 if yeS
519 echo 7.err12
520 else
521 echo 7.err13
522 endif
523 endif
524 echo 7.ok14
525 endif
526 if r
527 echo 8.ok1
528 if R
529 echo 8.ok2
530 else
531 echo 8.err2
532 endif
533 echo 8.ok3
534 else
535 echo 8.err1
536 endif
537 if s
538 echo 9.err1
539 else
540 echo 9.ok1
541 if S
542 echo 9.err2
543 else
544 echo 9.ok2
545 endif
546 echo 9.ok3
547 endif
548 # `elif'
549 if $dietcurd == 'yohu'
550 echo 10.err1
551 elif $dietcurd == 'yoha'
552 echo 10.err2
553 elif $dietcurd == 'yohe'
554 echo 10.err3
555 elif $dietcurd == 'yoho'
556 echo 10.ok1
557 if $dietcurd == 'yohu'
558 echo 10.err4
559 elif $dietcurd == 'yoha'
560 echo 10.err5
561 elif $dietcurd == 'yohe'
562 echo 10.err6
563 elif $dietcurd == 'yoho'
564 echo 10.ok2
565 if $dietcurd == 'yohu'
566 echo 10.err7
567 elif $dietcurd == 'yoha'
568 echo 10.err8
569 elif $dietcurd == 'yohe'
570 echo 10.err9
571 elif $dietcurd == 'yoho'
572 echo 10.ok3
573 else
574 echo 10.err10
575 endif
576 else
577 echo 10.err11
578 endif
579 else
580 echo 10.err12
581 endif
582 # integer conversion, <..>..
583 set dietcurd=10
584 if $dietcurd < 11
585 echo 11.ok1
586 if $dietcurd > 9
587 echo 11.ok2
588 else
589 echo 11.err2
590 endif
591 if $dietcurd == 10
592 echo 11.ok3
593 else
594 echo 11.err3
595 endif
596 if $dietcurd >= 10
597 echo 11.ok4
598 else
599 echo 11.err4
600 endif
601 if $dietcurd <= 10
602 echo 11.ok5
603 else
604 echo 11.err5
605 endif
606 if $dietcurd >= 11
607 echo 11.err6
608 else
609 echo 11.ok6
610 endif
611 if $dietcurd <= 9
612 echo 11.err7
613 else
614 echo 11.ok7
615 endif
616 else
617 echo 11.err1
618 endif
619 set dietcurd=Abc
620 if $dietcurd < aBd
621 echo 12.ok1
622 if $dietcurd > abB
623 echo 12.ok2
624 else
625 echo 12.err2
626 endif
627 if $dietcurd == aBC
628 echo 12.ok3
629 else
630 echo 12.err3
631 endif
632 if $dietcurd >= AbC
633 echo 12.ok4
634 else
635 echo 12.err4
636 endif
637 if $dietcurd <= ABc
638 echo 12.ok5
639 else
640 echo 12.err5
641 endif
642 if $dietcurd >= abd
643 echo 12.err6
644 else
645 echo 12.ok6
646 endif
647 if $dietcurd <= abb
648 echo 12.err7
649 else
650 echo 12.ok7
651 endif
652 else
653 echo 12.err1
654 endif
655 if $dietcurd =@ aB
656 echo 13.ok
657 else
658 echo 13.err
659 endif
660 if $dietcurd =@ bC
661 echo 14.ok
662 else
663 echo 14.err
664 endif
665 if $dietcurd !@ aB
666 echo 15.err
667 else
668 echo 15.ok
669 endif
670 if $dietcurd !@ bC
671 echo 15.err
672 else
673 echo 15.ok
674 endif
675 if $dietcurd =@ Cd
676 echo 16.err
677 else
678 echo 16.ok
679 endif
680 if $dietcurd !@ Cd
681 echo 17.ok
682 else
683 echo 17.err
684 endif
685 set diet=abc curd=abc
686 if $diet == $curd
687 echo 18.ok
688 else
689 echo 18.err
690 endif
691 set diet=abc curd=abcd
692 if $diet != $curd
693 echo 19.ok
694 else
695 echo 19.err
696 endif
697 # 1. Shitty grouping capabilities as of today
698 unset diet curd ndefined
699 if [ [ false ] || [ false ] || [ true ] ] && [ [ false ] || [ true ] ] && \
700 [ yes ]
701 echo 20.ok
702 else
703 echo 20.err
704 endif
705 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
706 echo 21.ok
707 else
708 echo 21.err
709 endif
710 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
711 echo 22.ok
712 else
713 echo 22.err
714 endif
715 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
716 echo 23.ok
717 else
718 echo 23.err
719 endif
720 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
721 echo 24.err
722 else
723 echo 24.ok
724 endif
725 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
726 && [ no ] || [ yes ]
727 echo 25.ok
728 else
729 echo 25.err
730 endif
731 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
732 echo 26.ok
733 else
734 echo 26.err
735 endif
736 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
737 echo 27.err
738 else
739 echo 27.ok
740 endif
741 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
742 echo 28.err
743 else
744 echo 28.ok
745 endif
746 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
747 echo 29.err
748 else
749 echo 29.ok
750 endif
751 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
752 echo 30.err
753 else
754 echo 30.ok
755 endif
756 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
757 echo 31.ok
758 else
759 echo 31.err
760 endif
761 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
762 echo 32.err
763 else
764 echo 32.ok
765 endif
766 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
767 echo 33.ok
768 else
769 echo 33.err
770 endif
771 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
772 echo 34.err
773 else
774 echo 34.ok
775 endif
776 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
777 echo 35.ok
778 else
779 echo 35.err
780 endif
781 set diet=yo curd=ho
782 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
783 echo 36.err
784 else
785 echo 36.ok
786 endif
787 set ndefined
788 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
789 echo 37.ok
790 else
791 echo 37.err
792 endif
793 # 2. Shitty grouping capabilities as of today
794 unset diet curd ndefined
795 if [ false || false || true ] && [ false || true ] && yes
796 echo 40.ok
797 else
798 echo 40.err
799 endif
800 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
801 echo 41.ok
802 else
803 echo 41.err
804 endif
805 if [ 1 || 0 || 0 || 0 ]
806 echo 42.ok
807 else
808 echo 42.err
809 endif
810 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
811 echo 43.ok
812 else
813 echo 43.err
814 endif
815 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
816 echo 44.err
817 else
818 echo 44.ok
819 endif
820 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
821 echo 45.ok
822 else
823 echo 45.err
824 endif
825 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
826 echo 46.ok
827 else
828 echo 46.err
829 endif
830 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
831 echo 47.err
832 else
833 echo 47.ok
834 endif
835 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
836 echo 48.err
837 else
838 echo 48.ok
839 endif
840 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
841 echo 49.err
842 else
843 echo 49.ok
844 endif
845 if 1 || 0 || 0 || 0 && 0
846 echo 50.err
847 else
848 echo 50.ok
849 endif
850 if 1 || 0 || 0 || 0 && 1
851 echo 51.ok
852 else
853 echo 51.err
854 endif
855 if 0 || 0 || 0 || 1 && 0
856 echo 52.err
857 else
858 echo 52.ok
859 endif
860 if 0 || 0 || 0 || 1 && 1
861 echo 53.ok
862 else
863 echo 53.err
864 endif
865 if 0 || 0 || 0 || 1 && 0 || 1 && 0
866 echo 54.err
867 else
868 echo 54.ok
869 endif
870 if 0 || 0 || 0 || 1 && 0 || 1 && 1
871 echo 55.ok
872 else
873 echo 55.err
874 endif
875 set diet=yo curd=ho
876 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
877 echo 56.err
878 else
879 echo 56.ok
880 endif
881 if $diet == 'yo' && $curd == 'ho' && $ndefined
882 echo 57.err
883 else
884 echo 57.ok
885 endif
886 set ndefined
887 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
888 echo 57.ok
889 else
890 echo 57.err
891 endif
892 if $diet == 'yo' && $curd == 'ho' && $ndefined
893 echo 58.ok
894 else
895 echo 58.err
896 endif
897 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
898 echo 59.ok
899 else
900 echo 59.err
901 endif
902 # Some more en-braced variables
903 set diet=yo curd=ho
904 if ${diet} == ${curd}
905 echo 70.err
906 else
907 echo 70.ok
908 endif
909 if ${diet} != ${curd}
910 echo 71.ok
911 else
912 echo 71.err
913 endif
914 if $diet == ${curd}
915 echo 72.err
916 else
917 echo 72.ok
918 endif
919 if ${diet} == $curd
920 echo 73.err
921 else
922 echo 73.ok
923 endif
924 # Unary !
925 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
926 echo 80.ok
927 else
928 echo 80.err
929 endif
930 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
931 echo 81.ok
932 else
933 echo 81.err
934 endif
935 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
936 echo 82.ok
937 else
938 echo 82.err
939 endif
940 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
941 echo 83.err
942 else
943 echo 83.ok
944 endif
945 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
946 echo 84.err
947 else
948 echo 84.ok
949 endif
950 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
951 echo 85.err
952 else
953 echo 85.ok
954 endif
955 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
956 echo 86.err
957 else
958 echo 86.ok
959 endif
960 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
961 echo 87.ok
962 else
963 echo 87.err
964 endif
965 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
966 echo 88.ok
967 else
968 echo 88.err
969 endif
970 # Unary !, odd
971 if ! 0 && ! ! 1 && ! ! ! 0 && 3
972 echo 90.ok
973 else
974 echo 90.err
975 endif
976 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
977 echo 91.ok
978 else
979 echo 91.err
980 endif
981 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
982 echo 92.ok
983 else
984 echo 92.err
985 endif
986 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
987 echo 93.err
988 else
989 echo 93.ok
990 endif
991 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
992 echo 94.ok
993 else
994 echo 94.err
995 endif
996 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
997 echo 95.err
998 else
999 echo 95.ok
1000 endif
1001 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
1002 echo 96.err
1003 else
1004 echo 96.ok
1005 endif
1006 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
1007 echo 97.ok
1008 else
1009 echo 97.err
1010 endif
1011 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
1012 echo 98.ok
1013 else
1014 echo 98.err
1015 endif
1016 __EOT
1017 cksum_test behave:if-normal "${MBOX}" '557629289 631'
1019 if have_feat regex; then
1020 ${rm} -f "${MBOX}"
1021 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
1022 set dietcurd=yoho
1023 if $dietcurd =~ '^yo.*'
1024 echo 1.ok
1025 else
1026 echo 1.err
1027 endif
1028 if $dietcurd =~ '^yoho.+'
1029 echo 2.err
1030 else
1031 echo 2.ok
1032 endif
1033 if $dietcurd !~ '.*ho$'
1034 echo 3.err
1035 else
1036 echo 3.ok
1037 endif
1038 if $dietcurd !~ '.+yoho$'
1039 echo 4.ok
1040 else
1041 echo 4.err
1042 endif
1043 if [ $dietcurd !~ '.+yoho$' ]
1044 echo 5.ok
1045 else
1046 echo 5.err
1047 endif
1048 if ! [ $dietcurd =~ '.+yoho$' ]
1049 echo 6.ok
1050 else
1051 echo 6.err
1052 endif
1053 if ! ! [ $dietcurd !~ '.+yoho$' ]
1054 echo 7.ok
1055 else
1056 echo 7.err
1057 endif
1058 if ! [ ! [ $dietcurd !~ '.+yoho$' ] ]
1059 echo 8.ok
1060 else
1061 echo 8.err
1062 endif
1063 if [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1064 echo 9.ok
1065 else
1066 echo 9.err
1067 endif
1068 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1069 echo 10.err
1070 else
1071 echo 10.ok
1072 endif
1073 if ! ! ! $dietcurd !~ '.+yoho$'
1074 echo 11.err
1075 else
1076 echo 11.ok
1077 endif
1078 if ! ! ! $dietcurd =~ '.+yoho$'
1079 echo 12.ok
1080 else
1081 echo 12.err
1082 endif
1083 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1084 echo 13.ok
1085 else
1086 echo 13.err
1087 endif
1088 set diet=abc curd='^abc$'
1089 if $diet =~ $curd
1090 echo 14.ok
1091 else
1092 echo 14.err
1093 endif
1094 set diet=abc curd='^abcd$'
1095 if $diet !~ $curd
1096 echo 15.ok
1097 else
1098 echo 15.err
1099 endif
1100 __EOT
1101 cksum_test behave:if-regex "${MBOX}" '439960016 81'
1105 __behave_localopts() {
1106 # Nestable conditions test
1107 ${rm} -f "${MBOX}"
1108 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
1109 define t2 {
1110 echo in: t2
1111 set t2=t2
1112 echo $t2
1114 define t1 {
1115 echo in: t1
1116 set gv1=gv1
1117 localopts on
1118 set lv1=lv1 lv2=lv2
1119 set lv3=lv3
1120 call t2
1121 localopts off
1122 set gv2=gv2
1123 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1125 define t0 {
1126 echo in: t0
1127 call t1
1128 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1129 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
1131 account trouble {
1132 echo in: trouble
1133 call t0
1135 call t0
1136 unset gv1 gv2
1137 account trouble
1138 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1139 account null
1140 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1141 __EOT
1142 #in: t0
1143 #in: t1
1144 #in: t2
1146 #gv1 lv1 lv2 lv3 gv2, t2
1147 #gv1 gv2,
1148 #gv1 gv2,
1149 #in: trouble
1150 #in: t0
1151 #in: t1
1152 #in: t2
1154 #gv1 lv1 lv2 lv3 gv2, t2
1155 #gv1 gv2,
1156 #gv1 gv2,
1157 #active trouble: gv1 gv2,
1158 #active null: ,
1159 cksum_test behave:localopts "${MBOX}" '1936527193 192'
1162 __behave_smime() { # FIXME add test/ dir, unroll tests therein, regular enable!
1163 printf 'behave:s/mime: .. generating test key and certificate ..\n'
1164 ${cat} <<-_EOT > ./t.conf
1165 [ req ]
1166 default_bits = 1024
1167 default_keyfile = keyfile.pem
1168 distinguished_name = req_distinguished_name
1169 attributes = req_attributes
1170 prompt = no
1171 output_password =
1173 [ req_distinguished_name ]
1174 C = GB
1175 ST = Over the
1176 L = rainbow
1177 O = S-nail
1178 OU = S-nail.smime
1179 CN = S-nail.test
1180 emailAddress = test@localhost
1182 [ req_attributes ]
1183 challengePassword =
1184 _EOT
1185 openssl req -x509 -nodes -days 3650 -config ./t.conf \
1186 -newkey rsa:1024 -keyout ./tkey.pem -out ./tcert.pem >/dev/null 2>&1
1187 ${rm} -f ./t.conf
1188 ${cat} ./tkey.pem ./tcert.pem > ./tpair.pem
1190 printf "behave:s/mime:sign/verify: "
1191 echo bla | "${SNAIL}" ${ARGS} \
1192 -Ssmime-ca-file=./tcert.pem -Ssmime-sign-cert=./tpair.pem \
1193 -Ssmime-sign -Sfrom=test@localhost \
1194 -s 'S/MIME test' ./VERIFY
1195 printf 'verify\nx\n' |
1196 "${SNAIL}" ${ARGS} \
1197 -Ssmime-ca-file=./tcert.pem -Ssmime-sign-cert=./tpair.pem \
1198 -Ssmime-sign -Sfrom=test@localhost \
1199 -Sbatch-exit-on-error -R \
1200 -f ./VERIFY >/dev/null 2>&1
1201 if [ $? -eq 0 ]; then
1202 printf 'ok\n'
1203 else
1204 ESTAT=1
1205 printf 'error: verification failed\n'
1206 ${rm} -f ./VERIFY ./tkey.pem ./tcert.pem ./tpair.pem
1207 return
1209 ${rm} -rf ./VERIFY
1211 # (signing +) encryption / decryption
1212 ${cat} <<-_EOT > ./tsendmail.sh
1213 #!/bin/sh -
1214 (echo 'From S-Postman Thu May 10 20:40:54 2012' && ${cat}) > ./ENCRYPT
1215 _EOT
1216 chmod 0755 ./tsendmail.sh
1218 printf "behave:s/mime:encrypt+sign/decrypt+verify: "
1219 echo bla |
1220 "${SNAIL}" ${ARGS} \
1221 -Ssmime-force-encryption \
1222 -Ssmime-encrypt-recei@ver.com=./tpair.pem \
1223 -Smta=./tsendmail.sh \
1224 -Ssmime-ca-file=./tcert.pem -Ssmime-sign-cert=./tpair.pem \
1225 -Ssmime-sign -Sfrom=test@localhost \
1226 -s 'S/MIME test' recei@ver.com
1227 # TODO CHECK
1228 printf 'decrypt ./DECRYPT\nfi ./DECRYPT\nverify\nx\n' |
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 -Sbatch-exit-on-error -R \
1236 -f ./ENCRYPT >/dev/null 2>&1
1237 if [ $? -eq 0 ]; then
1238 printf 'ok\n'
1239 else
1240 ESTAT=1
1241 printf 'error: decryption+verification failed\n'
1243 ${sed} -e '/^Date:/d' -e '/^X-Decoding-Date/d' \
1244 -e \
1245 '/^Content-Disposition: attachment; filename="smime.p7s"/,/^-- /d' \
1246 < ./DECRYPT > ./ENCRYPT
1247 cksum_test ".. checksum of decrypted content" "./ENCRYPT" '82649489 454'
1249 ${rm} -f ./DECRYPT
1250 printf "behave:s/mime:encrypt/decrypt: "
1251 echo bla | "${SNAIL}" ${ARGS} \
1252 -Ssmime-force-encryption \
1253 -Ssmime-encrypt-recei@ver.com=./tpair.pem \
1254 -Smta=./tsendmail.sh \
1255 -Ssmime-ca-file=./tcert.pem -Ssmime-sign-cert=./tpair.pem \
1256 -Sfrom=test@localhost \
1257 -s 'S/MIME test' recei@ver.com
1258 printf 'decrypt ./DECRYPT\nx\n' | "${SNAIL}" ${ARGS} \
1259 -Ssmime-force-encryption \
1260 -Ssmime-encrypt-recei@ver.com=./tpair.pem \
1261 -Smta=./tsendmail.sh \
1262 -Ssmime-ca-file=./tcert.pem -Ssmime-sign-cert=./tpair.pem \
1263 -Sfrom=test@localhost \
1264 -Sbatch-exit-on-error -R \
1265 -f ./ENCRYPT >/dev/null 2>&1
1266 if [ $? -eq 0 ]; then
1267 printf 'ok\n'
1268 else
1269 ESTAT=1
1270 printf 'error: decryption failed\n'
1271 # FALLTHRU
1273 ${sed} -e '/^Date:/d' -e '/^X-Decoding-Date/d' \
1274 < ./DECRYPT > ./ENCRYPT
1275 cksum_test ".. checksum of decrypted content" "./ENCRYPT" '2694938815 239'
1277 ${rm} -f ./tsendmail.sh ./ENCRYPT ./DECRYPT \
1278 ./tkey.pem ./tcert.pem ./tpair.pem
1281 # t_content()
1282 # Some basic tests regarding correct sending of mails, via STDIN / -t / -q,
1283 # including basic MIME Content-Transfer-Encoding correctness (quoted-printable)
1284 # Note we unfortunately need to place some statements without proper
1285 # indentation because of continuation problems
1286 t_content() {
1287 ${rm} -f "${BODY}" "${MBOX}"
1289 # MIME encoding (QP) stress message body
1290 printf \
1291 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
1292 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
1293 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
1294 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
1295 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
1296 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
1297 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
1298 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
1299 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
1300 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
1301 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
1302 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
1303 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
1304 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
1305 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
1306 "auf den zeilen vorher.\r\n"\
1307 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
1308 ".\r\n"\
1309 "Die letzte Zeile war nur ein Punkt.\r\n"\
1310 "..\r\n"\
1311 "Das waren deren zwei.\r\n"\
1312 " \r\n"\
1313 "Die letzte Zeile war ein Leerschritt.\n"\
1314 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
1315 "Prösterchen.\r\n"\
1316 ".\n"\
1317 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
1318 "..\n"\
1319 "Das waren deren zwei. ditto.\n"\
1320 "Prösterchen.\n"\
1321 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
1322 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
1323 "auf den zeilen vorher.\n"\
1324 "ditto.\n"\
1325 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
1326 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
1327 "\n"\
1328 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
1329 "\n"\
1330 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
1331 "3\n"\
1332 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
1333 "34\n"\
1334 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
1335 "345\n"\
1336 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
1337 "3456\n"\
1338 "QP am Zeilenende über soft-nl hinweg\n"\
1339 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
1340 "ö123\n"\
1341 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
1342 "1ö23\n"\
1343 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
1344 "12ö3\n"\
1345 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
1346 "123ö\n"\
1347 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
1348 " \n"\
1349 "Die letzte Zeile war ein Leerschritt.\n"\
1350 ' '\
1351 > "${BODY}"
1353 # MIME encoding (QP) stress message subject
1354 SUB="Äbrä Kä?dä=brö Fü?di=bus? \
1355 adadaddsssssssddddddddddddddddddddd\
1356 ddddddddddddddddddddddddddddddddddd\
1357 ddddddddddddddddddddddddddddddddddd\
1358 dddddddddddddddddddd Hallelulja? Od\
1359 er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
1360 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
1361 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f\
1362 fffffffffffffffffffffffffffffffffff\
1363 fffffffffffffffffffff ggggggggggggg\
1364 ggggggggggggggggggggggggggggggggggg\
1365 ggggggggggggggggggggggggggggggggggg\
1366 ggggggggggggggggggggggggggggggggggg\
1367 gggggggggggggggg"
1369 # Three tests for MIME encodign and (a bit) content classification.
1370 # At the same time testing -q FILE, < FILE and -t FILE
1372 ${rm} -f "${MBOX}"
1373 < "${BODY}" "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
1374 -a "${BODY}" -s "${SUB}" "${MBOX}"
1375 cksum_test content:001 "${MBOX}" '2886124440 6413'
1377 ${rm} -f "${MBOX}"
1378 < /dev/null "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
1379 -a "${BODY}" -s "${SUB}" -q "${BODY}" "${MBOX}"
1380 cksum_test content:002 "${MBOX}" '2886124440 6413'
1382 ${rm} -f "${MBOX}"
1383 ( echo "To: ${MBOX}" && echo "Subject: ${SUB}" && echo &&
1384 ${cat} "${BODY}"
1385 ) | "${SNAIL}" ${ARGS} ${ADDARG_UNI} -Snodot -a "${BODY}" -t
1386 cksum_test content:003 "${MBOX}" '2886124440 6413'
1388 # Test for [260e19d] (Juergen Daubert)
1389 ${rm} -f "${MBOX}"
1390 echo body | "${SNAIL}" ${ARGS} "${MBOX}"
1391 cksum_test content:004 "${MBOX}" '4004005686 49'
1393 # Sending of multiple mails in a single invocation
1394 ${rm} -f "${MBOX}"
1395 ( printf "m ${MBOX}\n~s subject1\nE-Mail Körper 1\n~.\n" &&
1396 printf "m ${MBOX}\n~s subject2\nEmail body 2\n~.\n" &&
1397 echo x
1398 ) | "${SNAIL}" ${ARGS} ${ADDARG_UNI}
1399 cksum_test content:005 "${MBOX}" '2157252578 260'
1401 ## $BODY CHANGED
1403 # "Test for" [d6f316a] (Gavin Troy)
1404 ${rm} -f "${MBOX}"
1405 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
1406 "${SNAIL}" ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="${cat}" > "${BODY}"
1407 ${sed} -e 1d < "${BODY}" > "${MBOX}"
1408 cksum_test content:006 "${MBOX}" '2273863401 83'
1410 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
1411 ${rm} -f "${MBOX}"
1412 ${awk} 'BEGIN{
1413 for(i = 0; i < 10000; ++i)
1414 printf "\xC3\xBC"
1415 #printf "\xF0\x90\x87\x90"
1416 }' | "${SNAIL}" ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
1417 cksum_test content:007 "${MBOX}" '1754234717 61767'
1419 ## Test some more corner cases for header bodies (as good as we can today) ##
1422 ${rm} -f "${MBOX}"
1423 echo | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
1424 -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̲' \
1425 "${MBOX}"
1426 cksum_test content:008 "${MBOX}" '4279661351 326'
1428 # Single word (overlong line split -- bad standard! Requires injection of
1429 # artificial data!! Bad can be prevented by using RFC 2047 encoding)
1430 ${rm} -f "${MBOX}"
1431 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
1432 echo | "${SNAIL}" ${ARGS} -s "${i}" "${MBOX}"
1433 cksum_test content:009 "${MBOX}" '223283022 1669'
1435 # Combination of encoded words, space and tabs of varying sort
1436 ${rm} -f "${MBOX}"
1437 echo | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
1438 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
1439 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
1440 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
1441 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
1442 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
1443 "${MBOX}"
1444 cksum_test content:010 "${MBOX}" '2637105063 542'
1446 # Overlong multibyte sequence that must be forcefully split
1447 # todo This works even before v15.0, but only by accident
1448 ${rm} -f "${MBOX}"
1449 echo | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
1450 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
1451 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
1452 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
1453 "${MBOX}"
1454 cksum_test content:011 "${MBOX}" '979048840 610'
1456 # Trailing WS
1457 ${rm} -f "${MBOX}"
1458 echo | "${SNAIL}" ${ARGS} \
1459 -s "1-1 B2 B3 B4 B5 B6 B\
1460 1-2 B2 B3 B4 B5 B6 B\
1461 1-3 B2 B3 B4 B5 B6 B\
1462 1-4 B2 B3 B4 B5 B6 B\
1463 1-5 B2 B3 B4 B5 B6 B\
1464 1-6 B2 B3 B4 B5 B6 " \
1465 "${MBOX}"
1466 cksum_test content:012 "${MBOX}" '1497528261 248'
1468 # Leading and trailing WS
1469 ${rm} -f "${MBOX}"
1470 echo | "${SNAIL}" ${ARGS} \
1471 -s " 2-1 B2 B3 B4 B5 B6 B\
1472 1-2 B2 B3 B4 B5 B6 B\
1473 1-3 B2 B3 B4 B5 B6 B\
1474 1-4 B2 B3 B4 B5 B6 " \
1475 "${MBOX}"
1476 cksum_test content:013 "${MBOX}" '1588208111 187'
1478 # Quick'n dirty RFC 2231 test; i had more when implementing it, but until we
1479 # have a (better) test framework materialize a quick shot
1480 ${rm} -f "${MBOX}"
1481 : > "ma'ger.txt"
1482 : > "mä'ger.txt"
1483 : > 'diet\ is \curd.txt'
1484 : > 'diet "is" curd.txt'
1485 : > höde-tröge.txt
1486 : > 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
1487 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
1488 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
1489 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
1490 echo bla | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
1491 -a "ma'ger.txt" -a "mä'ger.txt" \
1492 -a 'diet\ is \curd.txt' -a 'diet "is" curd.txt' \
1493 -a höde-tröge.txt \
1494 -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 \
1495 -a höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt \
1496 -a hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
1497 -a ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
1498 "${MBOX}"
1499 ${rm} -f "ma'ger.txt" "mä'ger.txt" 'diet\ is \curd.txt' \
1500 'diet "is" curd.txt' höde-tröge.txt \
1501 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 \
1502 höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt \
1503 hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
1504 ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
1505 cksum_test content:14 "${MBOX}" '589846634 2491'
1506 # `resend' test
1507 printf "Resend ${BODY}\nx\n" | "${SNAIL}" ${ARGS} -f "${MBOX}"
1508 cksum_test content:14-2 "${MBOX}" '589846634 2491'
1510 ${rm} -f "${BODY}" "${MBOX}"
1513 t_all() {
1514 if have_feat devel; then
1515 ARGS="${ARGS} -Smemdebug"
1516 export ARGS
1518 t_behave
1519 t_content
1522 if [ -z "${CHECK_ONLY}" ]; then
1523 cc_all_configs
1524 else
1525 t_all
1528 [ ${ESTAT} -eq 0 ] && echo Ok || echo >&2 'Errors occurred'
1530 exit ${ESTAT}
1531 # s-sh-mode