C****Y BSD signal handling! Try improve ^C stability..
[s-mailx.git] / cc-test.sh
blob407b2af6db688d0b4e51edb8a29ea9227e2108e6
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
37 unset POSIXLY_CORRECT
39 # Problem: force $SHELL to be a real shell. It seems some testing environments
40 # use nologin(?), but we need a real shell for command execution
41 if { echo ${SHELL} | ${grep} nologin; } >/dev/null 2>&1; then
42 echo >&2 '$SHELL seems to be nologin, overwriting to /bin/sh!'
43 SHELL=/bin/sh
44 export SHELL
47 if [ -z "${UTF8_LOCALE}" ]; then
48 UTF8_LOCALE=
49 if command -v locale >/dev/null 2>&1; then
50 UTF8_LOCALE=`locale -a | { m=
51 while read n; do
52 if { echo ${n} | ${grep} -i 'utf-\{0,1\}8'; } >/dev/null 2>&1; then
53 m=${n}
54 if { echo ${n} | ${grep} -e POSIX -e en_EN -e en_US; }; then
55 exit 0
58 m=${n}
59 done
60 echo ${m}
65 ESTAT=0
67 usage() {
68 echo >&2 "Usage: ./cc-test.sh [--check-only [s-nail-binary]]"
69 exit 1
72 CHECK_ONLY=
73 [ ${#} -gt 0 ] && {
74 [ "${1}" = --check-only ] || usage
75 [ ${#} -gt 2 ] && usage
76 [ ${#} -eq 2 ] && SNAIL="${2}"
77 [ -x "${SNAIL}" ] || usage
78 CHECK_ONLY=1
81 TRAP_EXIT_ADDONS=
82 trap "${rm} -rf \"${BODY}\" \"${MBOX}\" \${TRAP_EXIT_ADDONS}" EXIT
83 trap "exit 1" HUP INT TERM
85 # cc_all_configs()
86 # Test all configs TODO doesn't cover all *combinations*, stupid!
87 cc_all_configs() {
88 < ${CONF} ${awk} '
89 BEGIN {
90 NOTME["OPT_AUTOCC"] = 1
91 NOTME["OPT_DEBUG"] = 1
92 NOTME["OPT_DEVEL"] = 1
93 NOTME["OPT_NOEXTMD5"] = 1
94 NOTME["OPT_NOMEMDBG"] = 1
95 NOTME["OPT_NYD2"] = 1
96 i = 0
98 /^[[:space:]]*OPT_/ {
99 sub(/^[[:space:]]*/, "")
100 # This bails for UnixWare 7.1.4 awk(1), but preceeding = with \
101 # does not seem to be a compliant escape for =
102 #sub(/=.*$/, "")
103 $1 = substr($1, 1, index($1, "=") - 1)
104 if (NOTME[$1])
105 next
106 data[i++] = $1
108 END {
109 # Doing this completely sequentially and not doing make distclean in
110 # between runs should effectively result in lesser compilations.
111 # It is completely dumb nonetheless... TODO
112 for (j = 1; j < i; ++j) {
113 for (k = 1; k < j; ++k)
114 printf data[k] "=1 "
115 for (k = j; k < i; ++k)
116 printf data[k] "=0 "
117 printf "OPT_AUTOCC=1\n"
119 for (j = 1; j < i; ++j) {
120 for (k = 1; k < j; ++k)
121 printf data[k] "=0 "
122 for (k = j; k < i; ++k)
123 printf data[k] "=1 "
124 printf "OPT_AUTOCC=1\n"
126 # With debug
127 for (j = 1; j < i; ++j) {
128 for (k = 1; k < j; ++k)
129 printf data[k] "=1 "
130 for (k = j; k < i; ++k)
131 printf data[k] "=0 "
132 printf "OPT_AUTOCC=1\n"
133 printf "OPT_DEBUG=1\n"
135 for (j = 1; j < i; ++j) {
136 for (k = 1; k < j; ++k)
137 printf data[k] "=0 "
138 for (k = j; k < i; ++k)
139 printf data[k] "=1 "
140 printf "OPT_AUTOCC=1\n"
141 printf "OPT_DEBUG=1\n"
144 printf "CONFIG=NULL OPT_AUTOCC=0\n"
145 printf "CONFIG=NULL OPT_AUTOCC=1\n"
146 printf "CONFIG=NULLI OPT_AUTOCC=0\n"
147 printf "CONFIG=NULLI OPT_AUTOCC=1\n"
148 printf "CONFIG=MINIMAL OPT_AUTOCC=0\n"
149 printf "CONFIG=MINIMAL OPT_AUTOCC=1\n"
150 printf "CONFIG=MEDIUM OPT_AUTOCC=0\n"
151 printf "CONFIG=MEDIUM OPT_AUTOCC=1\n"
152 printf "CONFIG=NETSEND OPT_AUTOCC=0\n"
153 printf "CONFIG=NETSEND OPT_AUTOCC=1\n"
154 printf "CONFIG=MAXIMAL OPT_AUTOCC=0\n"
155 printf "CONFIG=MAXIMAL OPT_AUTOCC=1\n"
156 printf "CONFIG=DEVEL OPT_AUTOCC=0\n"
157 printf "CONFIG=DEVEL OPT_AUTOCC=1\n"
158 printf "CONFIG=ODEVEL OPT_AUTOCC=0\n"
159 printf "CONFIG=ODEVEL OPT_AUTOCC=1\n"
161 ' | while read c; do
162 printf "\n\n##########\n$c\n"
163 printf "\n\n##########\n$c\n" >&2
164 sh -c "${MAKE} ${c}"
165 t_all
166 done
167 ${MAKE} distclean
170 # cksum_test()
171 # Read mailbox $2, strip non-constant headers and MIME boundaries, query the
172 # cksum(1) of the resulting data and compare against the checksum $3
173 cksum_test() {
174 tid=${1} f=${2} s=${3}
175 printf "${tid}: "
176 csum="`${sed} -e '/^From /d' \
177 -e '/^ boundary=/d' -e '/^--=-=/d' < \"${f}\" \
178 -e '/^\[-- Message/d' | ${cksum}`";
179 if [ "${csum}" = "${s}" ]; then
180 printf 'ok\n'
181 else
182 ESTAT=1
183 printf 'error: checksum mismatch (got %s)\n' "${csum}"
187 have_feat() {
188 ( "${SNAIL}" ${ARGS} -X'echo $features' -Xx | ${grep} +${1} ) >/dev/null 2>&1
191 # t_behave()
192 # Basic (easily testable) behaviour tests
193 t_behave() {
194 __behave_x_opt_input_command_stack
195 __behave_wysh
196 __behave_input_inject_semicolon_seq
197 __behave_ghost
198 __behave_ifelse
199 __behave_localopts
200 __behave_macro_param_shift
201 __behave_addrcodec
202 __behave_vexpr
203 __behave_xcall
205 # FIXME __behave_alias
207 # FIXME __behave_mlist
209 have_feat smime && __behave_smime
212 __behave_x_opt_input_command_stack() {
213 ${cat} <<- '__EOT' > "${BODY}"
214 echo 1
215 define mac0 {
216 echo mac0-1 via1 $0
218 call mac0
219 echo 2
220 source '\
221 echo "define mac1 {";\
222 echo " echo mac1-1 via1 \$0";\
223 echo " call mac0";\
224 echo " echo mac1-2";\
225 echo " call mac2";\
226 echo " echo mac1-3";\
227 echo "}";\
228 echo "echo 1-1";\
229 echo "define mac2 {";\
230 echo " echo mac2-1 via1 \$0";\
231 echo " call mac0";\
232 echo " echo mac2-2";\
233 echo "}";\
234 echo "echo 1-2";\
235 echo "call mac1";\
236 echo "echo 1-3";\
237 echo "source \"\
238 echo echo 1-1-1 via1 \$0;\
239 echo call mac0;\
240 echo echo 1-1-2;\
241 | \"";\
242 echo "echo 1-4";\
244 echo 3
245 call mac2
246 echo 4
247 undefine *
248 __EOT
250 # The -X option supports multiline arguments, and those can internally use
251 # reverse solidus newline escaping. And all -X options are joined...
252 APO=\'
253 < "${BODY}" "${SNAIL}" ${ARGS} \
254 -X 'e\' \
255 -X ' c\' \
256 -X ' h\' \
257 -X ' o \' \
258 -X 1 \
260 define mac0 {
261 echo mac0-1 via2 $0
263 call mac0
264 echo 2
267 source '${APO}'\
268 echo "define mac1 {";\
269 echo " echo mac1-1 via2 \$0";\
270 echo " call mac0";\
271 echo " echo mac1-2";\
272 echo " call mac2";\
273 echo " echo mac1-3";\
274 echo "}";\
275 echo "echo 1-1";\
276 echo "define mac2 {";\
277 echo " echo mac2-1 via2 \$0";\
278 echo " call mac0";\
279 echo " echo mac2-2";\
280 echo "}";\
281 echo "echo 1-2";\
282 echo "call mac1";\
283 echo "echo 1-3";\
284 echo "source \"\
285 echo echo 1-1-1 via2 \$0;\
286 echo call mac0;\
287 echo echo 1-1-2;\
288 | \"";\
289 echo "echo 1-4";\
290 | '${APO}'
291 echo 3
294 call mac2
295 echo 4
296 undefine *
297 ' > "${MBOX}" 2>/dev/null
299 #mac0-1 via2
301 #1-1
302 #1-2
303 #mac1-1 via2
304 #mac0-1 via2 mac1
305 #mac1-2
306 #mac2-1 via2 mac1
307 #mac0-1 via2 mac2
308 #mac2-2
309 #mac1-3
310 #1-3
311 #1-1-1 via2
312 #mac0-1 via2
313 #1-1-2
314 #1-4
316 #mac2-1 via2
317 #mac0-1 via2 mac2
318 #mac2-2
321 #mac0-1 via1
323 #1-1
324 #1-2
325 #mac1-1 via1
326 #mac0-1 via1 mac1
327 #mac1-2
328 #mac2-1 via1 mac1
329 #mac0-1 via1 mac2
330 #mac2-2
331 #mac1-3
332 #1-3
333 #1-1-1 via1
334 #mac0-1 via1
335 #1-1-2
336 #1-4
338 #mac2-1 via1
339 #mac0-1 via1 mac2
340 #mac2-2
342 cksum_test behave:x_opt_input_command_stack "${MBOX}" '1391275936 378'
345 __behave_xcall() {
346 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
347 define work {
348 echon "$1 "
349 vput vexpr i + $1 1
350 if [ $i -le 1111 ]
351 vput vexpr j '&' $i 7
352 if [ $j -eq 7 ]
353 echo .
355 \xcall work $i
357 echo ! The end for $1
359 define xwork {
360 \xcall work 0
362 call work 0
363 echo ?=$?
364 call xwork
365 echo ?=$?
366 xcall xwork
367 echo ?=$?
368 __EOT
369 cksum_test behave:xcall "${MBOX}" '1717228546 9555'
372 __behave_wysh() {
373 ${cat} <<- '__EOT' > "${BODY}"
375 echo abcd
376 echo a'b'c'd'
377 echo a"b"c"d"
378 echo a$'b'c$'d'
379 echo 'abcd'
380 echo "abcd"
381 echo $'abcd'
382 echo a\ b\ c\ d
383 echo a 'b c' d
384 echo a "b c" d
385 echo a $'b c' d
387 echo 'a$`"\'
388 echo "a\$\`'\"\\"
389 echo $'a\$`\'\"\\'
390 echo $'a\$`\'"\\'
391 # DIET=CURD TIED=
392 echo 'a${DIET}b${TIED}c\${DIET}d\${TIED}e' # COMMENT
393 echo "a${DIET}b${TIED}c\${DIET}d\${TIED}e"
394 echo $'a${DIET}b${TIED}c\${DIET}d\${TIED}e'
396 echo a$'\101\0101\x41\u0041\u41\U00000041\U41'c
397 echo a$'\u0041\u41\u0C1\U00000041\U41'c
398 echo a$'\377'c
399 echo a$'\0377'c
400 echo a$'\400'c
401 echo a$'\0400'c
402 echo a$'\U1100001'c
404 echo a$'b\0c'd
405 echo a$'b\00c'de
406 echo a$'b\000c'df
407 echo a$'b\0000c'dg
408 echo a$'b\x0c'dh
409 echo a$'b\x00c'di
410 echo a$'b\u0'dj
411 echo a$'b\u00'dk
412 echo a$'b\u000'dl
413 echo a$'b\u0000'dm
414 echo a$'b\U0'dn
415 echo a$'b\U00'do
416 echo a$'b\U000'dp
417 echo a$'b\U0000'dq
418 echo a$'b\U00000'dr
419 echo a$'b\U000000'ds
420 echo a$'b\U0000000'dt
421 echo a$'b\U00000000'du
423 echo a$'\cI'b
424 echo a$'\011'b
425 echo a$'\x9'b
426 echo a$'\u9'b
427 echo a$'\U9'b
428 echo a$'\c@'b c d
429 __EOT
431 if [ -z "${UTF8_LOCALE}" ]; then
432 echo 'Skip behave:wysh_unicode, no UTF8_LOCALE'
433 else
434 < "${BODY}" DIET=CURD TIED= \
435 LC_ALL=${UTF8_LOCALE} "${SNAIL}" ${ARGS} 2>/dev/null > "${MBOX}"
436 #abcd
437 #abcd
438 #abcd
439 #abcd
440 #abcd
441 #abcd
442 #abcd
443 #a b c d
444 #a b c d
445 #a b c d
446 #a b c d
447 #a$`"\
448 #a$`'"\
449 #a$`'"\
450 #a$`'"\
451 #a${DIET}b${TIED}c\${DIET}d\${TIED}e
452 #aCURDbc${DIET}d${TIED}e
453 #a${DIET}b${TIED}cCURDde
454 #aAAAAAAAc
455 #aAAÁAAc
456 #aÿc
457 #aÿc
458 #abd
459 #abde
460 #abdf
461 #abdg
462 #ab\fdh
463 #abdi
464 #abdj
465 #abdk
466 #abdl
467 #abdm
468 #abdn
469 #abdo
470 #abdp
471 #abdq
472 #abdr
473 #abds
474 #abdt
475 #abdu
476 #a b
477 #a b
478 #a b
479 #a b
480 #a b
482 cksum_test behave:wysh_unicode "${MBOX}" '475805847 317'
485 < "${BODY}" DIET=CURD TIED= "${SNAIL}" ${ARGS} > "${MBOX}" 2>/dev/null
486 #abcd
487 #abcd
488 #abcd
489 #abcd
490 #abcd
491 #abcd
492 #abcd
493 #a b c d
494 #a b c d
495 #a b c d
496 #a b c d
497 #a$`"\
498 #a$`'"\
499 #a$`'"\
500 #a$`'"\
501 #a${DIET}b${TIED}c\${DIET}d\${TIED}e
502 #aCURDbc${DIET}d${TIED}e
503 #a${DIET}b${TIED}cCURDde
504 #aAAAAAAAc
505 #aAA\u0C1AAc
506 #aÿc
507 #aÿc
508 #abd
509 #abde
510 #abdf
511 #abdg
512 #ab\fdh
513 #abdi
514 #abdj
515 #abdk
516 #abdl
517 #abdm
518 #abdn
519 #abdo
520 #abdp
521 #abdq
522 #abdr
523 #abds
524 #abdt
525 #abdu
526 #a b
527 #a b
528 #a b
529 #a b
530 #a b
532 cksum_test behave:wysh_c "${MBOX}" '1473887148 321'
535 __behave_input_inject_semicolon_seq() {
536 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
537 define mydeepmac {
538 echon '(mydeepmac)';
540 define mymac {
541 echon this_is_mymac;call mydeepmac;echon ';';
543 echon one';';~mymac;echon two";";call mymac;echo three$';';
544 define mymac {
545 echon this_is_mymac;call mydeepmac;echon ,TOO'!;';
547 echon one';';~mymac;echon two";";call mymac;echo three$';';
548 __EOT
549 #one;this_is_mymac(mydeepmac);two;this_is_mymac(mydeepmac);three;
550 #one;this_is_mymac(mydeepmac),TOO!;two;this_is_mymac(mydeepmac),TOO!;three;
551 cksum_test behave:input_inject_semicolon_seq "${MBOX}" '512117110 140'
554 __behave_ghost() {
555 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
556 ghost echo echo hoho
557 echo stop.
558 ghost X Xx
559 ghost Xx XxX
560 ghost XxX XxXx
561 ghost XxXx XxXxX
562 ghost XxXxX XxXxXx
563 ghost XxXxXx echo huhu
564 ghost XxXxXxX echo huhu
566 ghost XxXxXx XxXxXxX
568 __EOT
569 #hoho stop.
570 #hoho huhu
571 #huhu
572 cksum_test behave:ghost "${MBOX}" '776950759 26'
576 __behave_ifelse() {
577 # Nestable conditions test
578 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
579 if 0
580 echo 1.err
581 else
582 echo 1.ok
583 endif
584 if 1
585 echo 2.ok
586 else
587 echo 2.err
588 endif
589 if $dietcurd
590 echo 3.err
591 else
592 echo 3.ok
593 endif
594 set dietcurd=yoho
595 if $dietcurd
596 echo 4.ok
597 else
598 echo 4.err
599 endif
600 if $dietcurd == 'yoho'
601 echo 5.ok
602 else
603 echo 5.err
604 endif
605 if $dietcurd != 'yoho'
606 echo 6.err
607 else
608 echo 6.ok
609 endif
610 # Nesting
611 if faLse
612 echo 7.err1
613 if tRue
614 echo 7.err2
615 if yEs
616 echo 7.err3
617 else
618 echo 7.err4
619 endif
620 echo 7.err5
621 endif
622 echo 7.err6
623 else
624 echo 7.ok7
625 if YeS
626 echo 7.ok8
627 if No
628 echo 7.err9
629 else
630 echo 7.ok9
631 endif
632 echo 7.ok10
633 else
634 echo 7.err11
635 if yeS
636 echo 7.err12
637 else
638 echo 7.err13
639 endif
640 endif
641 echo 7.ok14
642 endif
643 if r
644 echo 8.ok1
645 if R
646 echo 8.ok2
647 else
648 echo 8.err2
649 endif
650 echo 8.ok3
651 else
652 echo 8.err1
653 endif
654 if s
655 echo 9.err1
656 else
657 echo 9.ok1
658 if S
659 echo 9.err2
660 else
661 echo 9.ok2
662 endif
663 echo 9.ok3
664 endif
665 # `elif'
666 if $dietcurd == 'yohu'
667 echo 10.err1
668 elif $dietcurd == 'yoha'
669 echo 10.err2
670 elif $dietcurd == 'yohe'
671 echo 10.err3
672 elif $dietcurd == 'yoho'
673 echo 10.ok1
674 if $dietcurd == 'yohu'
675 echo 10.err4
676 elif $dietcurd == 'yoha'
677 echo 10.err5
678 elif $dietcurd == 'yohe'
679 echo 10.err6
680 elif $dietcurd == 'yoho'
681 echo 10.ok2
682 if $dietcurd == 'yohu'
683 echo 10.err7
684 elif $dietcurd == 'yoha'
685 echo 10.err8
686 elif $dietcurd == 'yohe'
687 echo 10.err9
688 elif $dietcurd == 'yoho'
689 echo 10.ok3
690 else
691 echo 10.err10
692 endif
693 else
694 echo 10.err11
695 endif
696 else
697 echo 10.err12
698 endif
699 # integer conversion, <..>..
700 set dietcurd=10
701 if $dietcurd -lt 11
702 echo 11.ok1
703 if $dietcurd -gt 9
704 echo 11.ok2
705 else
706 echo 11.err2
707 endif
708 if $dietcurd -eq 10
709 echo 11.ok3
710 else
711 echo 11.err3
712 endif
713 if $dietcurd -ge 10
714 echo 11.ok4
715 else
716 echo 11.err4
717 endif
718 if $dietcurd -le 10
719 echo 11.ok5
720 else
721 echo 11.err5
722 endif
723 if $dietcurd -ge 11
724 echo 11.err6
725 else
726 echo 11.ok6
727 endif
728 if $dietcurd -le 9
729 echo 11.err7
730 else
731 echo 11.ok7
732 endif
733 else
734 echo 11.err1
735 endif
736 set dietcurd=Abc
737 if $dietcurd < aBd
738 echo 12.ok1
739 if $dietcurd > abB
740 echo 12.ok2
741 else
742 echo 12.err2
743 endif
744 if $dietcurd == aBC
745 echo 12.ok3
746 else
747 echo 12.err3
748 endif
749 if $dietcurd >= AbC
750 echo 12.ok4
751 else
752 echo 12.err4
753 endif
754 if $dietcurd <= ABc
755 echo 12.ok5
756 else
757 echo 12.err5
758 endif
759 if $dietcurd >= abd
760 echo 12.err6
761 else
762 echo 12.ok6
763 endif
764 if $dietcurd <= abb
765 echo 12.err7
766 else
767 echo 12.ok7
768 endif
769 else
770 echo 12.err1
771 endif
772 if $dietcurd =@ aB
773 echo 13.ok
774 else
775 echo 13.err
776 endif
777 if $dietcurd =@ bC
778 echo 14.ok
779 else
780 echo 14.err
781 endif
782 if $dietcurd !@ aB
783 echo 15.err
784 else
785 echo 15.ok
786 endif
787 if $dietcurd !@ bC
788 echo 15.err
789 else
790 echo 15.ok
791 endif
792 if $dietcurd =@ Cd
793 echo 16.err
794 else
795 echo 16.ok
796 endif
797 if $dietcurd !@ Cd
798 echo 17.ok
799 else
800 echo 17.err
801 endif
802 set diet=abc curd=abc
803 if $diet == $curd
804 echo 18.ok
805 else
806 echo 18.err
807 endif
808 set diet=abc curd=abcd
809 if $diet != $curd
810 echo 19.ok
811 else
812 echo 19.err
813 endif
814 # 1. Shitty grouping capabilities as of today
815 unset diet curd ndefined
816 if [ [ false ] || [ false ] || [ true ] ] && [ [ false ] || [ true ] ] && \
817 [ yes ]
818 echo 20.ok
819 else
820 echo 20.err
821 endif
822 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
823 echo 21.ok
824 else
825 echo 21.err
826 endif
827 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
828 echo 22.ok
829 else
830 echo 22.err
831 endif
832 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
833 echo 23.ok
834 else
835 echo 23.err
836 endif
837 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
838 echo 24.err
839 else
840 echo 24.ok
841 endif
842 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
843 && [ no ] || [ yes ]
844 echo 25.ok
845 else
846 echo 25.err
847 endif
848 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
849 echo 26.ok
850 else
851 echo 26.err
852 endif
853 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
854 echo 27.err
855 else
856 echo 27.ok
857 endif
858 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
859 echo 28.err
860 else
861 echo 28.ok
862 endif
863 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
864 echo 29.err
865 else
866 echo 29.ok
867 endif
868 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
869 echo 30.err
870 else
871 echo 30.ok
872 endif
873 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
874 echo 31.ok
875 else
876 echo 31.err
877 endif
878 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
879 echo 32.err
880 else
881 echo 32.ok
882 endif
883 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
884 echo 33.ok
885 else
886 echo 33.err
887 endif
888 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
889 echo 34.err
890 else
891 echo 34.ok
892 endif
893 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
894 echo 35.ok
895 else
896 echo 35.err
897 endif
898 set diet=yo curd=ho
899 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
900 echo 36.err
901 else
902 echo 36.ok
903 endif
904 set ndefined
905 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
906 echo 37.ok
907 else
908 echo 37.err
909 endif
910 # 2. Shitty grouping capabilities as of today
911 unset diet curd ndefined
912 if [ false || false || true ] && [ false || true ] && yes
913 echo 40.ok
914 else
915 echo 40.err
916 endif
917 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
918 echo 41.ok
919 else
920 echo 41.err
921 endif
922 if [ 1 || 0 || 0 || 0 ]
923 echo 42.ok
924 else
925 echo 42.err
926 endif
927 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
928 echo 43.ok
929 else
930 echo 43.err
931 endif
932 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
933 echo 44.err
934 else
935 echo 44.ok
936 endif
937 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
938 echo 45.ok
939 else
940 echo 45.err
941 endif
942 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
943 echo 46.ok
944 else
945 echo 46.err
946 endif
947 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
948 echo 47.err
949 else
950 echo 47.ok
951 endif
952 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
953 echo 48.err
954 else
955 echo 48.ok
956 endif
957 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
958 echo 49.err
959 else
960 echo 49.ok
961 endif
962 if 1 || 0 || 0 || 0 && 0
963 echo 50.err
964 else
965 echo 50.ok
966 endif
967 if 1 || 0 || 0 || 0 && 1
968 echo 51.ok
969 else
970 echo 51.err
971 endif
972 if 0 || 0 || 0 || 1 && 0
973 echo 52.err
974 else
975 echo 52.ok
976 endif
977 if 0 || 0 || 0 || 1 && 1
978 echo 53.ok
979 else
980 echo 53.err
981 endif
982 if 0 || 0 || 0 || 1 && 0 || 1 && 0
983 echo 54.err
984 else
985 echo 54.ok
986 endif
987 if 0 || 0 || 0 || 1 && 0 || 1 && 1
988 echo 55.ok
989 else
990 echo 55.err
991 endif
992 set diet=yo curd=ho
993 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
994 echo 56.err
995 else
996 echo 56.ok
997 endif
998 if $diet == 'yo' && $curd == 'ho' && $ndefined
999 echo 57.err
1000 else
1001 echo 57.ok
1002 endif
1003 set ndefined
1004 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1005 echo 57.ok
1006 else
1007 echo 57.err
1008 endif
1009 if $diet == 'yo' && $curd == 'ho' && $ndefined
1010 echo 58.ok
1011 else
1012 echo 58.err
1013 endif
1014 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
1015 echo 59.ok
1016 else
1017 echo 59.err
1018 endif
1019 # Some more en-braced variables
1020 set diet=yo curd=ho
1021 if ${diet} == ${curd}
1022 echo 70.err
1023 else
1024 echo 70.ok
1025 endif
1026 if ${diet} != ${curd}
1027 echo 71.ok
1028 else
1029 echo 71.err
1030 endif
1031 if $diet == ${curd}
1032 echo 72.err
1033 else
1034 echo 72.ok
1035 endif
1036 if ${diet} == $curd
1037 echo 73.err
1038 else
1039 echo 73.ok
1040 endif
1041 # Unary !
1042 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
1043 echo 80.ok
1044 else
1045 echo 80.err
1046 endif
1047 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
1048 echo 81.ok
1049 else
1050 echo 81.err
1051 endif
1052 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1053 echo 82.ok
1054 else
1055 echo 82.err
1056 endif
1057 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1058 echo 83.err
1059 else
1060 echo 83.ok
1061 endif
1062 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1063 echo 84.err
1064 else
1065 echo 84.ok
1066 endif
1067 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1068 echo 85.err
1069 else
1070 echo 85.ok
1071 endif
1072 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1073 echo 86.err
1074 else
1075 echo 86.ok
1076 endif
1077 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
1078 echo 87.ok
1079 else
1080 echo 87.err
1081 endif
1082 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
1083 echo 88.ok
1084 else
1085 echo 88.err
1086 endif
1087 # Unary !, odd
1088 if ! 0 && ! ! 1 && ! ! ! 0 && 3
1089 echo 90.ok
1090 else
1091 echo 90.err
1092 endif
1093 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
1094 echo 91.ok
1095 else
1096 echo 91.err
1097 endif
1098 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
1099 echo 92.ok
1100 else
1101 echo 92.err
1102 endif
1103 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
1104 echo 93.err
1105 else
1106 echo 93.ok
1107 endif
1108 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
1109 echo 94.ok
1110 else
1111 echo 94.err
1112 endif
1113 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
1114 echo 95.err
1115 else
1116 echo 95.ok
1117 endif
1118 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
1119 echo 96.err
1120 else
1121 echo 96.ok
1122 endif
1123 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
1124 echo 97.ok
1125 else
1126 echo 97.err
1127 endif
1128 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
1129 echo 98.ok
1130 else
1131 echo 98.err
1132 endif
1133 __EOT
1134 cksum_test behave:if-normal "${MBOX}" '557629289 631'
1136 if have_feat regex; then
1137 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
1138 set dietcurd=yoho
1139 if $dietcurd =~ '^yo.*'
1140 echo 1.ok
1141 else
1142 echo 1.err
1143 endif
1144 if $dietcurd =~ '^yoho.+'
1145 echo 2.err
1146 else
1147 echo 2.ok
1148 endif
1149 if $dietcurd !~ '.*ho$'
1150 echo 3.err
1151 else
1152 echo 3.ok
1153 endif
1154 if $dietcurd !~ '.+yoho$'
1155 echo 4.ok
1156 else
1157 echo 4.err
1158 endif
1159 if [ $dietcurd !~ '.+yoho$' ]
1160 echo 5.ok
1161 else
1162 echo 5.err
1163 endif
1164 if ! [ $dietcurd =~ '.+yoho$' ]
1165 echo 6.ok
1166 else
1167 echo 6.err
1168 endif
1169 if ! ! [ $dietcurd !~ '.+yoho$' ]
1170 echo 7.ok
1171 else
1172 echo 7.err
1173 endif
1174 if ! [ ! [ $dietcurd !~ '.+yoho$' ] ]
1175 echo 8.ok
1176 else
1177 echo 8.err
1178 endif
1179 if [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1180 echo 9.ok
1181 else
1182 echo 9.err
1183 endif
1184 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1185 echo 10.err
1186 else
1187 echo 10.ok
1188 endif
1189 if ! ! ! $dietcurd !~ '.+yoho$'
1190 echo 11.err
1191 else
1192 echo 11.ok
1193 endif
1194 if ! ! ! $dietcurd =~ '.+yoho$'
1195 echo 12.ok
1196 else
1197 echo 12.err
1198 endif
1199 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1200 echo 13.ok
1201 else
1202 echo 13.err
1203 endif
1204 set diet=abc curd='^abc$'
1205 if $diet =~ $curd
1206 echo 14.ok
1207 else
1208 echo 14.err
1209 endif
1210 set diet=abc curd='^abcd$'
1211 if $diet !~ $curd
1212 echo 15.ok
1213 else
1214 echo 15.err
1215 endif
1216 __EOT
1217 cksum_test behave:if-regex "${MBOX}" '439960016 81'
1221 __behave_localopts() {
1222 # Nestable conditions test
1223 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
1224 define t2 {
1225 echo in: t2
1226 set t2=t2
1227 echo $t2
1229 define t1 {
1230 echo in: t1
1231 set gv1=gv1
1232 localopts on
1233 set lv1=lv1 lv2=lv2
1234 set lv3=lv3
1235 call t2
1236 localopts off
1237 set gv2=gv2
1238 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1240 define t0 {
1241 echo in: t0
1242 call t1
1243 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1244 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
1246 account trouble {
1247 echo in: trouble
1248 call t0
1250 call t0
1251 unset gv1 gv2
1252 account trouble
1253 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1254 account null
1255 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1256 __EOT
1257 #in: t0
1258 #in: t1
1259 #in: t2
1261 #gv1 lv1 lv2 lv3 gv2, t2
1262 #gv1 gv2,
1263 #gv1 gv2,
1264 #in: trouble
1265 #in: t0
1266 #in: t1
1267 #in: t2
1269 #gv1 lv1 lv2 lv3 gv2, t2
1270 #gv1 gv2,
1271 #gv1 gv2,
1272 #active trouble: gv1 gv2,
1273 #active null: ,
1274 cksum_test behave:localopts "${MBOX}" '1936527193 192'
1277 __behave_macro_param_shift() {
1278 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}" 2>/dev/null
1279 define t2 {
1280 echo in: t2
1281 echo t2.0 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1282 localopts on
1283 wysh set ignerr=$1
1284 shift
1285 localopts off
1286 echo t2.1 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1287 if [ $# > 1 ] || [ $ignerr == '' ]
1288 shift 2
1289 else
1290 ignerr shift 2
1291 endif
1292 echo t2.2:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1293 shift 0
1294 echo t2.3:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1295 if [ $# > 0 ]
1296 shift
1297 endif
1298 echo t2.4:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1300 define t1 {
1301 echo in: t1
1302 call t2 1 you get four args
1303 echo t1.1: $?';' ignerr ($ignerr) should not exist
1304 call t2 1 you get 'three args'
1305 echo t1.2: $?';' ignerr ($ignerr) should not exist
1306 call t2 1 you 'get two args'
1307 echo t1.3: $?';' ignerr ($ignerr) should not exist
1308 call t2 1 'you get one arg'
1309 echo t1.4: $?';' ignerr ($ignerr) should not exist
1310 ignerr call t2 '' 'you get one arg'
1311 echo t1.5: $?';' ignerr ($ignerr) should not exist
1313 call t1
1314 __EOT
1315 #in: t1
1316 #in: t2
1317 #t2.0 has 5/5 parameters: 1,you,get (1 you get four args) [1 you get four args]
1318 #t2.1 has 4/4 parameters: you,get,four (you get four args) [you get four args]
1319 #t2.2:0 has 2/2 parameters: four,args, (four args) [four args]
1320 #t2.3:0 has 2/2 parameters: four,args, (four args) [four args]
1321 #t2.4:0 has 1/1 parameters: args,, (args) [args]
1322 #t1.1: 0; ignerr () should not exist
1323 #in: t2
1324 #t2.0 has 4/4 parameters: 1,you,get (1 you get three args) [1 you get three args]
1325 #t2.1 has 3/3 parameters: you,get,three args (you get three args) [you get three args]
1326 #t2.2:0 has 1/1 parameters: three args,, (three args) [three args]
1327 #t2.3:0 has 1/1 parameters: three args,, (three args) [three args]
1328 #t2.4:0 has 0/0 parameters: ,, () []
1329 #t1.2: 0; ignerr () should not exist
1330 #in: t2
1331 #t2.0 has 3/3 parameters: 1,you,get two args (1 you get two args) [1 you get two args]
1332 #t2.1 has 2/2 parameters: you,get two args, (you get two args) [you get two args]
1333 #t2.2:0 has 0/0 parameters: ,, () []
1334 #t2.3:0 has 0/0 parameters: ,, () []
1335 #t2.4:0 has 0/0 parameters: ,, () []
1336 #t1.3: 0; ignerr () should not exist
1337 #in: t2
1338 #t2.0 has 2/2 parameters: 1,you get one arg, (1 you get one arg) [1 you get one arg]
1339 #t2.1 has 1/1 parameters: you get one arg,, (you get one arg) [you get one arg]
1340 #t2.2:0 has 1/1 parameters: you get one arg,, (you get one arg) [you get one arg]
1341 #t2.3:0 has 1/1 parameters: you get one arg,, (you get one arg) [you get one arg]
1342 #t2.4:0 has 0/0 parameters: ,, () []
1343 #t1.4: 0; ignerr () should not exist
1344 #in: t2
1345 #t2.0 has 2/2 parameters: ,you get one arg, ( you get one arg) [ you get one arg]
1346 #t2.1 has 1/1 parameters: you get one arg,, (you get one arg) [you get one arg]
1347 #t1.5: 1; ignerr () should not exist
1348 cksum_test behave:macro_param_shift "${MBOX}" '1402489146 1682'
1351 __behave_addrcodec() {
1352 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
1353 vput addrcodec res e 1 <doog@def>
1354 echo $! $res
1355 eval vput addrcodec res d $res
1356 echo $! $res
1357 vput addrcodec res e 2 . <doog@def>
1358 echo $! $res
1359 eval vput addrcodec res d $res
1360 echo $! $res
1361 vput addrcodec res e 3 Sauer Dr. <doog@def>
1362 echo $! $res
1363 eval vput addrcodec res d $res
1364 echo $! $res
1365 vput addrcodec res e 4 Sauer (Ma) Dr. <doog@def>
1366 echo $! $res
1367 eval vput addrcodec res d $res
1368 echo $! $res
1369 vput addrcodec res e 5 Sauer (Ma) Braten Dr. <doog@def>
1370 echo $! $res
1371 eval vput addrcodec res d $res
1372 echo $! $res
1373 vput addrcodec res e 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
1374 echo $! $res
1375 eval vput addrcodec res d $res
1376 echo $! $res
1377 vput addrcodec res e 7 Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu)
1378 echo $! $res
1379 eval vput addrcodec res d $res
1380 echo $! $res
1381 vput addrcodec res e 8 \
1382 Dr. Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu) Boom. Boom
1383 echo $! $res
1384 eval vput addrcodec res d $res
1385 echo $! $res
1386 vput addrcodec res e 9 Dr.Sauer(Ma)Braten Dr. (Heu) <doog@def>
1387 echo $! $res
1388 eval vput addrcodec res d $res
1389 echo $! $res
1390 vput addrcodec res e 10 (Ma)Braten Dr. (Heu) <doog@def>
1391 echo $! $res
1392 eval vput addrcodec res d $res
1393 echo $! $res
1394 vput addrcodec res e 11 (Ma)Braten Dr"." (Heu) <doog@def>
1395 echo $! $res
1396 eval vput addrcodec res d $res
1397 echo $! $res
1398 vput addrcodec res e 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
1399 echo $! $res
1400 eval vput addrcodec res d $res
1401 echo $! $res
1402 vput addrcodec res e 13(Ma)Braten Dr. (Heu) <doog@def>
1403 echo $! $res
1404 eval vput addrcodec res d $res
1405 echo $! $res
1406 vput addrcodec res e 14 Hey, Du <doog@def> Wie() findet Dr. das? ()
1407 echo $! $res
1408 eval vput addrcodec res d $res
1409 echo $! $res
1410 vput addrcodec res e 15 \
1411 Hey, Du <doog@def> Wie() findet "" Dr. "" das? ()
1412 echo $! $res
1413 eval vput addrcodec res d $res
1414 echo $! $res
1415 vput addrcodec res e 16 \
1416 "Hey," "Du" <doog@def> "Wie()" findet "" Dr. "" das? ()
1417 echo $! $res
1418 eval vput addrcodec res d $res
1419 echo $! $res
1420 vput addrcodec res e 17 "Hey" Du <doog@def> "Wie() findet " " Dr. """ das? ()
1421 echo $! $res
1422 eval vput addrcodec res d $res
1423 echo $! $res
1424 vput addrcodec res e 18 <doog@def> "Hey" Du "Wie() findet " " Dr. """ das? ()
1425 echo $! $res
1426 eval vput addrcodec res d $res
1427 echo $! $res
1428 vput addrcodec res e 19 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1429 echo $! $res
1430 eval vput addrcodec res d $res
1431 echo $! $res
1432 vput addrcodec res +e 20 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1433 echo $! $res
1434 vput addrcodec res +e 21 Hey\,\"" <doog@def> "Wie()" findet \" Dr. \" das?
1435 echo $! $res
1436 eval vput addrcodec res d $res
1437 echo $! $res
1438 vput addrcodec res ++e 22 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1439 echo $! $res
1440 eval vput addrcodec res d $res
1441 echo $! $res
1442 __EOT
1443 #0 1 <doog@def>
1444 #0 1 <doog@def>
1445 #0 "2 ." <doog@def>
1446 #0 2 . <doog@def>
1447 #0 "3 Sauer Dr." <doog@def>
1448 #0 3 Sauer Dr. <doog@def>
1449 #0 4 Sauer (Ma) "Dr." <doog@def>
1450 #0 4 Sauer (Ma) Dr. <doog@def>
1451 #0 5 Sauer (Ma) "Braten Dr." <doog@def>
1452 #0 5 Sauer (Ma) Braten Dr. <doog@def>
1453 #0 6 Sauer (Ma) "Braten Dr." (Heu) <doog@def>
1454 #0 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
1455 #0 7 Sauer (Ma) "Braten Dr." (Heu bu) <doog@def>
1456 #0 7 Sauer (Ma) Braten Dr. (Heu bu) <doog@def>
1457 #0 "8 Dr. Sauer" (Ma) "Braten Dr." (Heu bu) "Boom. Boom" <doog@def>
1458 #0 8 Dr. Sauer (Ma) Braten Dr. (Heu bu) Boom. Boom <doog@def>
1459 #0 "9 Dr.Sauer" (Ma) "Braten Dr." (Heu) <doog@def>
1460 #0 9 Dr.Sauer (Ma) Braten Dr. (Heu) <doog@def>
1461 #0 10 (Ma) "Braten Dr." (Heu) <doog@def>
1462 #0 10 (Ma) Braten Dr. (Heu) <doog@def>
1463 #0 11 (Ma) "Braten Dr\".\"" (Heu) <doog@def>
1464 #0 11 (Ma) Braten Dr"." (Heu) <doog@def>
1465 #0 "12 Dr. Sauer" (Ma) "Braten Dr." (u) <doog@def>
1466 #0 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
1467 #0 13 (Ma) "Braten Dr." (Heu) <doog@def>
1468 #0 13 (Ma) Braten Dr. (Heu) <doog@def>
1469 #0 "14 Hey, Du Wie" () "findet Dr. das?" () <doog@def>
1470 #0 14 Hey, Du Wie () findet Dr. das? () <doog@def>
1471 #0 "15 Hey, Du Wie" () "findet \"\" Dr. \"\" das?" () <doog@def>
1472 #0 15 Hey, Du Wie () findet "" Dr. "" das? () <doog@def>
1473 #0 "16 \"Hey,\" \"Du\" \"Wie" () "\" findet \"\" Dr. \"\" das?" () <doog@def>
1474 #0 16 "Hey," "Du" "Wie () " findet "" Dr. "" das? () <doog@def>
1475 #0 "17 \"Hey\" Du \"Wie" () "findet \" \" Dr. \"\"\" das?" () <doog@def>
1476 #0 17 "Hey" Du "Wie () findet " " Dr. """ das? () <doog@def>
1477 #0 "18 \"Hey\" Du \"Wie" () "findet \" \" Dr. \"\"\" das?" () <doog@def>
1478 #0 18 "Hey" Du "Wie () findet " " Dr. """ das? () <doog@def>
1479 #0 "19 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
1480 #0 19 Hey\,\" "Wie () " findet \" Dr. \" das? <doog@def>
1481 #1 20 Hey\\,\\" <doog@def> "Wie()" findet \\" Dr. \\" das?
1482 #0 "21 Hey\\,\\ Wie() findet \\ Dr. \\ das?" <doog@def>
1483 #0 21 Hey\,\ Wie() findet \ Dr. \ das? <doog@def>
1484 #0 "22 Hey\,\" Wie() findet \" Dr. \" das?" <doog@def>
1485 #0 22 Hey," Wie() findet " Dr. " das? <doog@def>
1486 cksum_test behave:addrcodec "${MBOX}" '2804134200 2018'
1489 __behave_vexpr() {
1490 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}" 2>/dev/null
1491 vput vexpr res = 9223372036854775807
1492 echo $! $res
1493 vput vexpr res = 9223372036854775808
1494 echo $! $res
1495 vput vexpr res =@ 9223372036854775808
1496 echo $! $res
1497 vput vexpr res = -9223372036854775808
1498 echo $! $res
1499 vput vexpr res = -9223372036854775809
1500 echo $! $res
1501 vput vexpr res =@ -9223372036854775809
1502 echo $! $res
1503 echo ' #1'
1504 vput vexpr res ~ 0
1505 echo $! $res
1506 vput vexpr res ~ 1
1507 echo $! $res
1508 vput vexpr res ~ -1
1509 echo $! $res
1510 echo ' #2'
1511 vput vexpr res + 0 0
1512 echo $! $res
1513 vput vexpr res + 0 1
1514 echo $! $res
1515 vput vexpr res + 1 1
1516 echo $! $res
1517 echo ' #3'
1518 vput vexpr res + 9223372036854775807 0
1519 echo $! $res
1520 vput vexpr res + 9223372036854775807 1
1521 echo $! $res
1522 vput vexpr res +@ 9223372036854775807 1
1523 echo $! $res
1524 vput vexpr res + 0 9223372036854775807
1525 echo $! $res
1526 vput vexpr res + 1 9223372036854775807
1527 echo $! $res
1528 vput vexpr res +@ 1 9223372036854775807
1529 echo $! $res
1530 echo ' #4'
1531 vput vexpr res + -9223372036854775808 0
1532 echo $! $res
1533 vput vexpr res + -9223372036854775808 -1
1534 echo $! $res
1535 vput vexpr res +@ -9223372036854775808 -1
1536 echo $! $res
1537 vput vexpr res + 0 -9223372036854775808
1538 echo $! $res
1539 vput vexpr res + -1 -9223372036854775808
1540 echo $! $res
1541 vput vexpr res +@ -1 -9223372036854775808
1542 echo $! $res
1543 echo ' #5'
1544 vput vexpr res - 0 0
1545 echo $! $res
1546 vput vexpr res - 0 1
1547 echo $! $res
1548 vput vexpr res - 1 1
1549 echo $! $res
1550 echo ' #6'
1551 vput vexpr res - 9223372036854775807 0
1552 echo $! $res
1553 vput vexpr res - 9223372036854775807 -1
1554 echo $! $res
1555 vput vexpr res -@ 9223372036854775807 -1
1556 echo $! $res
1557 vput vexpr res - 0 9223372036854775807
1558 echo $! $res
1559 vput vexpr res - -1 9223372036854775807
1560 echo $! $res
1561 vput vexpr res - -2 9223372036854775807
1562 echo $! $res
1563 vput vexpr res -@ -2 9223372036854775807
1564 echo $! $res
1565 echo ' #7'
1566 vput vexpr res - -9223372036854775808 +0
1567 echo $! $res
1568 vput vexpr res - -9223372036854775808 +1
1569 echo $! $res
1570 vput vexpr res -@ -9223372036854775808 +1
1571 echo $! $res
1572 vput vexpr res - 0 -9223372036854775808
1573 echo $! $res
1574 vput vexpr res - +1 -9223372036854775808
1575 echo $! $res
1576 vput vexpr res -@ +1 -9223372036854775808
1577 echo $! $res
1578 echo ' #8'
1579 vput vexpr res + -13 -2
1580 echo $! $res
1581 vput vexpr res - 0 0
1582 echo $! $res
1583 vput vexpr res - 0 1
1584 echo $! $res
1585 vput vexpr res - 1 1
1586 echo $! $res
1587 vput vexpr res - -13 -2
1588 echo $! $res
1589 echo ' #9'
1590 vput vexpr res * 0 0
1591 echo $! $res
1592 vput vexpr res * 0 1
1593 echo $! $res
1594 vput vexpr res * 1 1
1595 echo $! $res
1596 vput vexpr res * -13 -2
1597 echo $! $res
1598 echo ' #10'
1599 vput vexpr res / 0 0
1600 echo $! $res
1601 vput vexpr res / 0 1
1602 echo $! $res
1603 vput vexpr res / 1 1
1604 echo $! $res
1605 vput vexpr res / -13 -2
1606 echo $! $res
1607 echo ' #11'
1608 vput vexpr res % 0 0
1609 echo $! $res
1610 vput vexpr res % 0 1
1611 echo $! $res
1612 vput vexpr res % 1 1
1613 echo $! $res
1614 vput vexpr res % -13 -2
1615 echo $! $res
1616 __EOT
1617 #0 9223372036854775807
1618 #1 -1
1619 #1 9223372036854775807
1620 #0 -9223372036854775808
1621 #1 -1
1622 #1 -9223372036854775808
1623 # #1
1624 #0 -1
1625 #0 -2
1626 #0 0
1627 # #2
1628 #0 0
1629 #0 1
1630 #0 2
1631 # #3
1632 #0 9223372036854775807
1633 #1 -1
1634 #1 9223372036854775807
1635 #0 9223372036854775807
1636 #1 -1
1637 #1 9223372036854775807
1638 # #4
1639 #0 -9223372036854775808
1640 #1 -1
1641 #1 -9223372036854775808
1642 #0 -9223372036854775808
1643 #1 -1
1644 #1 -9223372036854775808
1645 # #5
1646 #0 0
1647 #0 -1
1648 #0 0
1649 # #6
1650 #0 9223372036854775807
1651 #1 -1
1652 #1 9223372036854775807
1653 #0 -9223372036854775807
1654 #0 -9223372036854775808
1655 #1 -1
1656 #1 -9223372036854775808
1657 # #7
1658 #0 -9223372036854775808
1659 #1 -1
1660 #1 -9223372036854775808
1661 #0 -9223372036854775808
1662 #1 -1
1663 #1 -9223372036854775808
1664 # #8
1665 #0 -15
1666 #0 0
1667 #0 -1
1668 #0 0
1669 #0 -11
1670 # #9
1671 #0 0
1672 #0 0
1673 #0 1
1674 #0 26
1675 # #10
1676 #1 -1
1677 #0 0
1678 #0 1
1679 #0 6
1680 # #11
1681 #1 -1
1682 #0 0
1683 #0 0
1684 #0 -1
1685 cksum_test behave:vexpr-numeric "${MBOX}" '2147139513 687'
1687 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}" #2>/dev/null
1688 vput vexpr res find 'bananarama' 'nana'
1689 echo $! $res
1690 vput vexpr res find 'bananarama' 'bana'
1691 echo $! $res
1692 vput vexpr res find 'bananarama' 'Bana'
1693 echo $! $res
1694 vput vexpr res find 'bananarama' 'rama'
1695 echo $! $res
1696 echo ' #1'
1697 vput vexpr res ifind 'bananarama' 'nana'
1698 echo $! $res
1699 vput vexpr res ifind 'bananarama' 'bana'
1700 echo $! $res
1701 vput vexpr res ifind 'bananarama' 'Bana'
1702 echo $! $res
1703 vput vexpr res ifind 'bananarama' 'rama'
1704 echo $! $res
1705 echo ' #2'
1706 vput vexpr res substring 'bananarama' 1
1707 echo $! $res
1708 vput vexpr res substring 'bananarama' 3
1709 echo $! $res
1710 vput vexpr res substring 'bananarama' 5
1711 echo $! $res
1712 vput vexpr res substring 'bananarama' 7
1713 echo $! $res
1714 vput vexpr res substring 'bananarama' 9
1715 echo $! $res
1716 vput vexpr res substring 'bananarama' 10
1717 echo $! $res
1718 vput vexpr res substring 'bananarama' 1 3
1719 echo $! $res
1720 vput vexpr res substring 'bananarama' 3 3
1721 echo $! $res
1722 vput vexpr res substring 'bananarama' 5 3
1723 echo $! $res
1724 vput vexpr res substring 'bananarama' 7 3
1725 echo $! $res
1726 vput vexpr res substring 'bananarama' 9 3
1727 echo $! $res
1728 vput vexpr res substring 'bananarama' 10 3
1729 echo $! $res
1730 echo ' #3'
1731 __EOT
1732 #0 2
1733 #0 0
1734 #1 -1
1735 #0 6
1736 # #1
1737 #0 2
1738 #0 0
1739 #0 0
1740 #0 6
1741 # #2
1742 #0 ananarama
1743 #0 anarama
1744 #0 arama
1745 #0 ama
1746 #0 a
1748 #0 ana
1749 #0 ana
1750 #0 ara
1751 #0 ama
1752 #1 a
1754 # #3
1755 cksum_test behave:vexpr-string "${MBOX}" '2171181036 119'
1757 if have_feat regex; then
1758 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}" #2>/dev/null
1759 vput vexpr res regex 'bananarama' 'nana'
1760 echo $! $res
1761 vput vexpr res regex 'bananarama' 'bana'
1762 echo $! $res
1763 vput vexpr res regex 'bananarama' 'Bana'
1764 echo $! $res
1765 vput vexpr res regex 'bananarama' 'rama'
1766 echo $! $res
1767 echo ' #1'
1768 vput vexpr res iregex 'bananarama' 'nana'
1769 echo $! $res
1770 vput vexpr res iregex 'bananarama' 'bana'
1771 echo $! $res
1772 vput vexpr res iregex 'bananarama' 'Bana'
1773 echo $! $res
1774 vput vexpr res iregex 'bananarama' 'rama'
1775 echo $! $res
1776 echo ' #2'
1777 vput vexpr res regex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1778 echo $! $res
1779 vput vexpr res regex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1780 echo $! $res
1781 vput vexpr res regex 'bananarama' 'Bana(.+)' '\$1\$0'
1782 echo $! $res
1783 vput vexpr res regex 'bananarama' '(.+)rama' '\$1\$0'
1784 echo $! $res
1785 echo ' #3'
1786 vput vexpr res iregex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1787 echo $! $res
1788 vput vexpr res iregex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1789 echo $! $res
1790 vput vexpr res iregex 'bananarama' 'Bana(.+)' '\$1\$0'
1791 echo $! $res
1792 vput vexpr res iregex 'bananarama' '(.+)rama' '\$1\$0'
1793 echo $! $res
1794 echo ' #4'
1795 __EOT
1796 #0 2
1797 #0 0
1798 #1 -1
1799 #0 6
1800 # #1
1801 #0 2
1802 #0 0
1803 #0 0
1804 #0 6
1805 # #2
1806 #0 baabananaramau{rama}
1807 #0 abananaramaunarama
1808 #1 -1
1809 #0 bananabananarama
1810 # #3
1811 #0 baabananaramau{rama}
1812 #0 abananaramaunarama
1813 #0 naramabananarama
1814 #0 bananabananarama
1815 # #4
1816 cksum_test behave:vexpr-regex "${MBOX}" '3419299180 199'
1820 __behave_smime() { # FIXME add test/ dir, unroll tests therein
1821 TRAP_EXIT_ADDONS="./.t.conf ./.tkey.pem ./.tcert.pem ./.tpair.pem"
1822 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.VERIFY ./.DECRYPT ./.ENCRYPT"
1823 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.tsendmail.sh"
1825 printf 'behave:s/mime: .. generating test key and certificate ..\n'
1826 ${cat} <<-_EOT > ./.t.conf
1827 [ req ]
1828 default_bits = 1024
1829 default_keyfile = keyfile.pem
1830 distinguished_name = req_distinguished_name
1831 attributes = req_attributes
1832 prompt = no
1833 output_password =
1835 [ req_distinguished_name ]
1836 C = GB
1837 ST = Over the
1838 L = rainbow
1839 O = S-nail
1840 OU = S-nail.smime
1841 CN = S-nail.test
1842 emailAddress = test@localhost
1844 [ req_attributes ]
1845 challengePassword =
1846 _EOT
1847 openssl req -x509 -nodes -days 3650 -config ./.t.conf \
1848 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >/dev/null 2>&1
1849 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
1851 printf "behave:s/mime:sign/verify: "
1852 echo bla | "${SNAIL}" ${ARGS} \
1853 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
1854 -Ssmime-sign -Sfrom=test@localhost \
1855 -s 'S/MIME test' ./.VERIFY
1856 printf 'verify\nx\n' |
1857 "${SNAIL}" ${ARGS} \
1858 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
1859 -Ssmime-sign -Sfrom=test@localhost \
1860 -Sbatch-exit-on-error -R \
1861 -f ./.VERIFY >/dev/null 2>&1
1862 if [ $? -eq 0 ]; then
1863 printf 'ok\n'
1864 else
1865 printf 'error: verification failed\n'
1866 ESTAT=1
1867 ${rm} -f ${TRAP_EXIT_ADDONS}
1868 TRAP_EXIT_ADDONS=
1869 return
1871 printf ' .. disproof via openssl smime(1): '
1872 if openssl smime -verify -CAfile ./.tcert.pem \
1873 -in ./.VERIFY >/dev/null 2>&1; then
1874 printf 'ok\n'
1875 else
1876 printf 'failed\n'
1877 ESTAT=1
1878 ${rm} -f ${TRAP_EXIT_ADDONS}
1879 TRAP_EXIT_ADDONS=
1880 return
1883 # (signing +) encryption / decryption
1884 ${cat} <<-_EOT > ./.tsendmail.sh
1885 #!/bin/sh -
1886 ${rm} -f ./.ENCRYPT
1887 (echo 'From S-Postman Thu May 10 20:40:54 2012' && ${cat}) > ./.ENCRYPT
1888 _EOT
1889 chmod 0755 ./.tsendmail.sh
1891 printf "behave:s/mime:encrypt+sign/decrypt+verify: "
1892 echo bla |
1893 "${SNAIL}" ${ARGS} \
1894 -Ssmime-force-encryption \
1895 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
1896 -Smta=./.tsendmail.sh \
1897 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
1898 -Ssmime-sign -Sfrom=test@localhost \
1899 -s 'S/MIME test' recei@ver.com
1900 # TODO CHECK
1901 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
1902 "${SNAIL}" ${ARGS} \
1903 -Ssmime-force-encryption \
1904 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
1905 -Smta=./.tsendmail.sh \
1906 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
1907 -Ssmime-sign -Sfrom=test@localhost \
1908 -Sbatch-exit-on-error -R \
1909 -f ./.ENCRYPT >/dev/null 2>&1
1910 if [ $? -eq 0 ]; then
1911 printf 'ok\n'
1912 else
1913 ESTAT=1
1914 printf 'error: decryption+verification failed\n'
1916 printf ' ..disproof via openssl smime(1): '
1917 if (openssl smime -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT |
1918 openssl smime -verify -CAfile ./.tcert.pem) >/dev/null 2>&1; then
1919 printf 'ok\n'
1920 else
1921 printf 'failed\n'
1922 ESTAT=1
1924 ${sed} -e '/^Date:/d' -e '/^X-Decoding-Date/d' \
1925 -e \
1926 '/^Content-Disposition: attachment; filename="smime.p7s"/,/^-- /d' \
1927 < ./.DECRYPT > ./.ENCRYPT
1928 cksum_test ".. checksum of decrypted content" "./.ENCRYPT" '3090916509 510'
1930 printf "behave:s/mime:encrypt/decrypt: "
1931 ${rm} -f ./.DECRYPT
1932 echo bla | "${SNAIL}" ${ARGS} \
1933 -Ssmime-force-encryption \
1934 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
1935 -Smta=./.tsendmail.sh \
1936 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
1937 -Sfrom=test@localhost \
1938 -s 'S/MIME test' recei@ver.com
1939 printf 'decrypt ./.DECRYPT\nx\n' | "${SNAIL}" ${ARGS} \
1940 -Ssmime-force-encryption \
1941 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
1942 -Smta=./.tsendmail.sh \
1943 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
1944 -Sfrom=test@localhost \
1945 -Sbatch-exit-on-error -R \
1946 -f ./.ENCRYPT >/dev/null 2>&1
1947 if [ $? -eq 0 ]; then
1948 printf 'ok\n'
1949 else
1950 ESTAT=1
1951 printf 'error: decryption failed\n'
1953 printf '.. disproof via openssl smime(1): '
1954 if openssl smime -decrypt -inkey ./.tkey.pem \
1955 -in ./.ENCRYPT >/dev/null 2>&1; then
1956 printf 'ok\n'
1957 else
1958 printf 'failed\n'
1959 ESTAT=1
1961 ${sed} -e '/^Date:/d' -e '/^X-Decoding-Date/d' \
1962 < ./.DECRYPT > ./.ENCRYPT
1963 cksum_test ".. checksum of decrypted content" ./.ENCRYPT '999887248 295'
1965 ${rm} -f ${TRAP_EXIT_ADDONS}
1966 TRAP_EXIT_ADDONS=
1969 # t_content()
1970 # Some basic tests regarding correct sending of mails, via STDIN / -t / -q,
1971 # including basic MIME Content-Transfer-Encoding correctness (quoted-printable)
1972 # Note we unfortunately need to place some statements without proper
1973 # indentation because of continuation problems
1974 t_content() {
1975 # MIME encoding (QP) stress message body
1976 printf \
1977 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
1978 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
1979 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
1980 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
1981 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
1982 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
1983 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
1984 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
1985 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
1986 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
1987 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
1988 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
1989 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
1990 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
1991 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
1992 "auf den zeilen vorher.\r\n"\
1993 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
1994 ".\r\n"\
1995 "Die letzte Zeile war nur ein Punkt.\r\n"\
1996 "..\r\n"\
1997 "Das waren deren zwei.\r\n"\
1998 " \r\n"\
1999 "Die letzte Zeile war ein Leerschritt.\n"\
2000 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
2001 "Prösterchen.\r\n"\
2002 ".\n"\
2003 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
2004 "..\n"\
2005 "Das waren deren zwei. ditto.\n"\
2006 "Prösterchen.\n"\
2007 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
2008 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
2009 "auf den zeilen vorher.\n"\
2010 "ditto.\n"\
2011 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
2012 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
2013 "\n"\
2014 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
2015 "\n"\
2016 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
2017 "3\n"\
2018 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
2019 "34\n"\
2020 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
2021 "345\n"\
2022 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
2023 "3456\n"\
2024 "QP am Zeilenende über soft-nl hinweg\n"\
2025 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
2026 "ö123\n"\
2027 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
2028 "1ö23\n"\
2029 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
2030 "12ö3\n"\
2031 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
2032 "123ö\n"\
2033 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
2034 " \n"\
2035 "Die letzte Zeile war ein Leerschritt.\n"\
2036 ' '\
2037 > "${BODY}"
2039 # MIME encoding (QP) stress message subject
2040 SUB="Äbrä Kä?dä=brö Fü?di=bus? \
2041 adadaddsssssssddddddddddddddddddddd\
2042 ddddddddddddddddddddddddddddddddddd\
2043 ddddddddddddddddddddddddddddddddddd\
2044 dddddddddddddddddddd Hallelulja? Od\
2045 er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
2046 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
2047 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f\
2048 fffffffffffffffffffffffffffffffffff\
2049 fffffffffffffffffffff ggggggggggggg\
2050 ggggggggggggggggggggggggggggggggggg\
2051 ggggggggggggggggggggggggggggggggggg\
2052 ggggggggggggggggggggggggggggggggggg\
2053 gggggggggggggggg"
2055 # Three tests for MIME encodign and (a bit) content classification.
2056 # At the same time testing -q FILE, < FILE and -t FILE
2058 ${rm} -f "${MBOX}"
2059 < "${BODY}" "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2060 -a "${BODY}" -s "${SUB}" "${MBOX}"
2061 cksum_test content:001 "${MBOX}" '2356108758 6413'
2063 ${rm} -f "${MBOX}"
2064 < /dev/null "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2065 -a "${BODY}" -s "${SUB}" -q "${BODY}" "${MBOX}"
2066 cksum_test content:002 "${MBOX}" '2356108758 6413'
2068 ${rm} -f "${MBOX}"
2069 ( echo "To: ${MBOX}" && echo "Subject: ${SUB}" && echo &&
2070 ${cat} "${BODY}"
2071 ) | "${SNAIL}" ${ARGS} ${ADDARG_UNI} -Snodot -a "${BODY}" -t
2072 cksum_test content:003 "${MBOX}" '2356108758 6413'
2074 # Test for [260e19d] (Juergen Daubert)
2075 ${rm} -f "${MBOX}"
2076 echo body | "${SNAIL}" ${ARGS} "${MBOX}"
2077 cksum_test content:004 "${MBOX}" '4004005686 49'
2079 # Sending of multiple mails in a single invocation
2080 ${rm} -f "${MBOX}"
2081 ( printf "m ${MBOX}\n~s subject1\nE-Mail Körper 1\n~.\n" &&
2082 printf "m ${MBOX}\n~s subject2\nEmail body 2\n~.\n" &&
2083 echo x
2084 ) | "${SNAIL}" ${ARGS} ${ADDARG_UNI}
2085 cksum_test content:005 "${MBOX}" '2157252578 260'
2087 ## $BODY CHANGED
2089 # "Test for" [d6f316a] (Gavin Troy)
2090 ${rm} -f "${MBOX}"
2091 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
2092 "${SNAIL}" ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="${cat}" > "${BODY}"
2093 ${sed} -e 1d < "${BODY}" > "${MBOX}"
2094 cksum_test content:006 "${MBOX}" '2273863401 83'
2096 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
2097 ${rm} -f "${MBOX}"
2098 ${awk} 'BEGIN{
2099 for(i = 0; i < 10000; ++i)
2100 printf "\xC3\xBC"
2101 #printf "\xF0\x90\x87\x90"
2102 }' | "${SNAIL}" ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
2103 cksum_test content:007 "${MBOX}" '1754234717 61767'
2105 ## Test some more corner cases for header bodies (as good as we can today) ##
2108 ${rm} -f "${MBOX}"
2109 echo | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2110 -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̲' \
2111 "${MBOX}"
2112 cksum_test content:008 "${MBOX}" '1563381297 326'
2114 # Single word (overlong line split -- bad standard! Requires injection of
2115 # artificial data!! Bad can be prevented by using RFC 2047 encoding)
2116 ${rm} -f "${MBOX}"
2117 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
2118 echo | "${SNAIL}" ${ARGS} -s "${i}" "${MBOX}"
2119 cksum_test content:009 "${MBOX}" '1996714851 1669'
2121 # Combination of encoded words, space and tabs of varying sort
2122 ${rm} -f "${MBOX}"
2123 echo | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2124 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
2125 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
2126 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
2127 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
2128 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
2129 "${MBOX}"
2130 cksum_test content:010 "${MBOX}" '2956039469 542'
2132 # Overlong multibyte sequence that must be forcefully split
2133 # todo This works even before v15.0, but only by accident
2134 ${rm} -f "${MBOX}"
2135 echo | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2136 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
2137 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
2138 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
2139 "${MBOX}"
2140 cksum_test content:011 "${MBOX}" '454973928 610'
2142 # Trailing WS
2143 ${rm} -f "${MBOX}"
2144 echo | "${SNAIL}" ${ARGS} \
2145 -s "1-1 B2 B3 B4 B5 B6 B\
2146 1-2 B2 B3 B4 B5 B6 B\
2147 1-3 B2 B3 B4 B5 B6 B\
2148 1-4 B2 B3 B4 B5 B6 B\
2149 1-5 B2 B3 B4 B5 B6 B\
2150 1-6 B2 B3 B4 B5 B6 " \
2151 "${MBOX}"
2152 cksum_test content:012 "${MBOX}" '1014122962 248'
2154 # Leading and trailing WS
2155 ${rm} -f "${MBOX}"
2156 echo | "${SNAIL}" ${ARGS} \
2157 -s " 2-1 B2 B3 B4 B5 B6 B\
2158 1-2 B2 B3 B4 B5 B6 B\
2159 1-3 B2 B3 B4 B5 B6 B\
2160 1-4 B2 B3 B4 B5 B6 " \
2161 "${MBOX}"
2162 cksum_test content:013 "${MBOX}" '3212167908 187'
2164 # Quick'n dirty RFC 2231 test; i had more when implementing it, but until we
2165 # have a (better) test framework materialize a quick shot
2166 ${rm} -f "${MBOX}"
2167 TRAP_EXIT_ADDONS=./.ttt
2169 mkdir ./.ttt || exit 1
2170 cd ./.ttt || exit 2
2171 : > "ma'ger.txt"
2172 : > "mä'ger.txt"
2173 : > 'diet\ is \curd.txt'
2174 : > 'diet "is" curd.txt'
2175 : > höde-tröge.txt
2176 : > 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
2177 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
2178 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
2179 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
2181 echo bla | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2182 -a "./.ttt/ma'ger.txt" -a "./.ttt/mä'ger.txt" \
2183 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
2184 -a ./.ttt/höde-tröge.txt \
2185 -a ./.ttt/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 \
2186 -a ./.ttt/höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt \
2187 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
2188 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
2189 "${MBOX}"
2190 ${rm} -rf ./.ttt
2191 cksum_test content:14 "${MBOX}" '589846634 2491'
2192 # `resend' test
2193 printf "Resend ${BODY}\nx\n" | "${SNAIL}" ${ARGS} -f "${MBOX}"
2194 cksum_test content:14-2 "${MBOX}" '589846634 2491'
2197 t_all() {
2198 if have_feat devel; then
2199 ARGS="${ARGS} -Smemdebug"
2200 export ARGS
2202 t_behave
2203 t_content
2206 if [ -z "${CHECK_ONLY}" ]; then
2207 cc_all_configs
2208 else
2209 t_all
2212 [ ${ESTAT} -eq 0 ] && echo Ok || echo >&2 'Errors occurred'
2214 exit ${ESTAT}
2215 # s-sh-mode