(BWDIC!) No! Let $! be errno, and $? the sole exit status..
[s-mailx.git] / cc-test.sh
blob5099d6cd53f1369fd40ef409f1dd47e56ea81bbb
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_commandalias
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_commandalias() {
555 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
556 commandalias echo echo hoho
557 echo stop.
558 commandalias X Xx
559 commandalias Xx XxX
560 commandalias XxX XxXx
561 commandalias XxXx XxXxX
562 commandalias XxXxX XxXxXx
563 commandalias XxXxXx echo huhu
564 commandalias XxXxXxX echo huhu
566 commandalias XxXxXx XxXxXxX
568 uncommandalias echo
569 commandalias XxXxXx echo huhu
571 __EOT
572 #hoho stop.
573 #hoho huhu
574 #huhu
575 #huhu
576 cksum_test behave:commandalias "${MBOX}" '3694143612 31'
579 __behave_ifelse() {
580 # Nestable conditions test
581 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
582 if 0
583 echo 1.err
584 else
585 echo 1.ok
586 endif
587 if 1
588 echo 2.ok
589 else
590 echo 2.err
591 endif
592 if $dietcurd
593 echo 3.err
594 else
595 echo 3.ok
596 endif
597 set dietcurd=yoho
598 if $dietcurd
599 echo 4.ok
600 else
601 echo 4.err
602 endif
603 if $dietcurd == 'yoho'
604 echo 5.ok
605 else
606 echo 5.err
607 endif
608 if $dietcurd != 'yoho'
609 echo 6.err
610 else
611 echo 6.ok
612 endif
613 # Nesting
614 if faLse
615 echo 7.err1
616 if tRue
617 echo 7.err2
618 if yEs
619 echo 7.err3
620 else
621 echo 7.err4
622 endif
623 echo 7.err5
624 endif
625 echo 7.err6
626 else
627 echo 7.ok7
628 if YeS
629 echo 7.ok8
630 if No
631 echo 7.err9
632 else
633 echo 7.ok9
634 endif
635 echo 7.ok10
636 else
637 echo 7.err11
638 if yeS
639 echo 7.err12
640 else
641 echo 7.err13
642 endif
643 endif
644 echo 7.ok14
645 endif
646 if r
647 echo 8.ok1
648 if R
649 echo 8.ok2
650 else
651 echo 8.err2
652 endif
653 echo 8.ok3
654 else
655 echo 8.err1
656 endif
657 if s
658 echo 9.err1
659 else
660 echo 9.ok1
661 if S
662 echo 9.err2
663 else
664 echo 9.ok2
665 endif
666 echo 9.ok3
667 endif
668 # `elif'
669 if $dietcurd == 'yohu'
670 echo 10.err1
671 elif $dietcurd == 'yoha'
672 echo 10.err2
673 elif $dietcurd == 'yohe'
674 echo 10.err3
675 elif $dietcurd == 'yoho'
676 echo 10.ok1
677 if $dietcurd == 'yohu'
678 echo 10.err4
679 elif $dietcurd == 'yoha'
680 echo 10.err5
681 elif $dietcurd == 'yohe'
682 echo 10.err6
683 elif $dietcurd == 'yoho'
684 echo 10.ok2
685 if $dietcurd == 'yohu'
686 echo 10.err7
687 elif $dietcurd == 'yoha'
688 echo 10.err8
689 elif $dietcurd == 'yohe'
690 echo 10.err9
691 elif $dietcurd == 'yoho'
692 echo 10.ok3
693 else
694 echo 10.err10
695 endif
696 else
697 echo 10.err11
698 endif
699 else
700 echo 10.err12
701 endif
702 # integer conversion, <..>..
703 set dietcurd=10
704 if $dietcurd -lt 11
705 echo 11.ok1
706 if $dietcurd -gt 9
707 echo 11.ok2
708 else
709 echo 11.err2
710 endif
711 if $dietcurd -eq 10
712 echo 11.ok3
713 else
714 echo 11.err3
715 endif
716 if $dietcurd -ge 10
717 echo 11.ok4
718 else
719 echo 11.err4
720 endif
721 if $dietcurd -le 10
722 echo 11.ok5
723 else
724 echo 11.err5
725 endif
726 if $dietcurd -ge 11
727 echo 11.err6
728 else
729 echo 11.ok6
730 endif
731 if $dietcurd -le 9
732 echo 11.err7
733 else
734 echo 11.ok7
735 endif
736 else
737 echo 11.err1
738 endif
739 set dietcurd=Abc
740 if $dietcurd < aBd
741 echo 12.ok1
742 if $dietcurd > abB
743 echo 12.ok2
744 else
745 echo 12.err2
746 endif
747 if $dietcurd == aBC
748 echo 12.ok3
749 else
750 echo 12.err3
751 endif
752 if $dietcurd >= AbC
753 echo 12.ok4
754 else
755 echo 12.err4
756 endif
757 if $dietcurd <= ABc
758 echo 12.ok5
759 else
760 echo 12.err5
761 endif
762 if $dietcurd >= abd
763 echo 12.err6
764 else
765 echo 12.ok6
766 endif
767 if $dietcurd <= abb
768 echo 12.err7
769 else
770 echo 12.ok7
771 endif
772 else
773 echo 12.err1
774 endif
775 if $dietcurd =@ aB
776 echo 13.ok
777 else
778 echo 13.err
779 endif
780 if $dietcurd =@ bC
781 echo 14.ok
782 else
783 echo 14.err
784 endif
785 if $dietcurd !@ aB
786 echo 15.err
787 else
788 echo 15.ok
789 endif
790 if $dietcurd !@ bC
791 echo 15.err
792 else
793 echo 15.ok
794 endif
795 if $dietcurd =@ Cd
796 echo 16.err
797 else
798 echo 16.ok
799 endif
800 if $dietcurd !@ Cd
801 echo 17.ok
802 else
803 echo 17.err
804 endif
805 set diet=abc curd=abc
806 if $diet == $curd
807 echo 18.ok
808 else
809 echo 18.err
810 endif
811 set diet=abc curd=abcd
812 if $diet != $curd
813 echo 19.ok
814 else
815 echo 19.err
816 endif
817 # 1. Shitty grouping capabilities as of today
818 unset diet curd ndefined
819 if [ [ false ] || [ false ] || [ true ] ] && [ [ false ] || [ true ] ] && \
820 [ yes ]
821 echo 20.ok
822 else
823 echo 20.err
824 endif
825 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
826 echo 21.ok
827 else
828 echo 21.err
829 endif
830 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
831 echo 22.ok
832 else
833 echo 22.err
834 endif
835 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
836 echo 23.ok
837 else
838 echo 23.err
839 endif
840 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
841 echo 24.err
842 else
843 echo 24.ok
844 endif
845 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
846 && [ no ] || [ yes ]
847 echo 25.ok
848 else
849 echo 25.err
850 endif
851 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
852 echo 26.ok
853 else
854 echo 26.err
855 endif
856 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
857 echo 27.err
858 else
859 echo 27.ok
860 endif
861 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
862 echo 28.err
863 else
864 echo 28.ok
865 endif
866 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
867 echo 29.err
868 else
869 echo 29.ok
870 endif
871 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
872 echo 30.err
873 else
874 echo 30.ok
875 endif
876 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
877 echo 31.ok
878 else
879 echo 31.err
880 endif
881 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
882 echo 32.err
883 else
884 echo 32.ok
885 endif
886 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
887 echo 33.ok
888 else
889 echo 33.err
890 endif
891 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
892 echo 34.err
893 else
894 echo 34.ok
895 endif
896 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
897 echo 35.ok
898 else
899 echo 35.err
900 endif
901 set diet=yo curd=ho
902 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
903 echo 36.err
904 else
905 echo 36.ok
906 endif
907 set ndefined
908 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
909 echo 37.ok
910 else
911 echo 37.err
912 endif
913 # 2. Shitty grouping capabilities as of today
914 unset diet curd ndefined
915 if [ false || false || true ] && [ false || true ] && yes
916 echo 40.ok
917 else
918 echo 40.err
919 endif
920 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
921 echo 41.ok
922 else
923 echo 41.err
924 endif
925 if [ 1 || 0 || 0 || 0 ]
926 echo 42.ok
927 else
928 echo 42.err
929 endif
930 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
931 echo 43.ok
932 else
933 echo 43.err
934 endif
935 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
936 echo 44.err
937 else
938 echo 44.ok
939 endif
940 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
941 echo 45.ok
942 else
943 echo 45.err
944 endif
945 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
946 echo 46.ok
947 else
948 echo 46.err
949 endif
950 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
951 echo 47.err
952 else
953 echo 47.ok
954 endif
955 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
956 echo 48.err
957 else
958 echo 48.ok
959 endif
960 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
961 echo 49.err
962 else
963 echo 49.ok
964 endif
965 if 1 || 0 || 0 || 0 && 0
966 echo 50.err
967 else
968 echo 50.ok
969 endif
970 if 1 || 0 || 0 || 0 && 1
971 echo 51.ok
972 else
973 echo 51.err
974 endif
975 if 0 || 0 || 0 || 1 && 0
976 echo 52.err
977 else
978 echo 52.ok
979 endif
980 if 0 || 0 || 0 || 1 && 1
981 echo 53.ok
982 else
983 echo 53.err
984 endif
985 if 0 || 0 || 0 || 1 && 0 || 1 && 0
986 echo 54.err
987 else
988 echo 54.ok
989 endif
990 if 0 || 0 || 0 || 1 && 0 || 1 && 1
991 echo 55.ok
992 else
993 echo 55.err
994 endif
995 set diet=yo curd=ho
996 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
997 echo 56.err
998 else
999 echo 56.ok
1000 endif
1001 if $diet == 'yo' && $curd == 'ho' && $ndefined
1002 echo 57.err
1003 else
1004 echo 57.ok
1005 endif
1006 set ndefined
1007 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1008 echo 57.ok
1009 else
1010 echo 57.err
1011 endif
1012 if $diet == 'yo' && $curd == 'ho' && $ndefined
1013 echo 58.ok
1014 else
1015 echo 58.err
1016 endif
1017 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
1018 echo 59.ok
1019 else
1020 echo 59.err
1021 endif
1022 # Some more en-braced variables
1023 set diet=yo curd=ho
1024 if ${diet} == ${curd}
1025 echo 70.err
1026 else
1027 echo 70.ok
1028 endif
1029 if ${diet} != ${curd}
1030 echo 71.ok
1031 else
1032 echo 71.err
1033 endif
1034 if $diet == ${curd}
1035 echo 72.err
1036 else
1037 echo 72.ok
1038 endif
1039 if ${diet} == $curd
1040 echo 73.err
1041 else
1042 echo 73.ok
1043 endif
1044 # Unary !
1045 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
1046 echo 80.ok
1047 else
1048 echo 80.err
1049 endif
1050 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
1051 echo 81.ok
1052 else
1053 echo 81.err
1054 endif
1055 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1056 echo 82.ok
1057 else
1058 echo 82.err
1059 endif
1060 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1061 echo 83.err
1062 else
1063 echo 83.ok
1064 endif
1065 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1066 echo 84.err
1067 else
1068 echo 84.ok
1069 endif
1070 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1071 echo 85.err
1072 else
1073 echo 85.ok
1074 endif
1075 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1076 echo 86.err
1077 else
1078 echo 86.ok
1079 endif
1080 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
1081 echo 87.ok
1082 else
1083 echo 87.err
1084 endif
1085 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
1086 echo 88.ok
1087 else
1088 echo 88.err
1089 endif
1090 # Unary !, odd
1091 if ! 0 && ! ! 1 && ! ! ! 0 && 3
1092 echo 90.ok
1093 else
1094 echo 90.err
1095 endif
1096 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
1097 echo 91.ok
1098 else
1099 echo 91.err
1100 endif
1101 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
1102 echo 92.ok
1103 else
1104 echo 92.err
1105 endif
1106 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
1107 echo 93.err
1108 else
1109 echo 93.ok
1110 endif
1111 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
1112 echo 94.ok
1113 else
1114 echo 94.err
1115 endif
1116 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
1117 echo 95.err
1118 else
1119 echo 95.ok
1120 endif
1121 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
1122 echo 96.err
1123 else
1124 echo 96.ok
1125 endif
1126 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
1127 echo 97.ok
1128 else
1129 echo 97.err
1130 endif
1131 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
1132 echo 98.ok
1133 else
1134 echo 98.err
1135 endif
1136 __EOT
1137 cksum_test behave:if-normal "${MBOX}" '557629289 631'
1139 if have_feat regex; then
1140 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
1141 set dietcurd=yoho
1142 if $dietcurd =~ '^yo.*'
1143 echo 1.ok
1144 else
1145 echo 1.err
1146 endif
1147 if $dietcurd =~ '^yoho.+'
1148 echo 2.err
1149 else
1150 echo 2.ok
1151 endif
1152 if $dietcurd !~ '.*ho$'
1153 echo 3.err
1154 else
1155 echo 3.ok
1156 endif
1157 if $dietcurd !~ '.+yoho$'
1158 echo 4.ok
1159 else
1160 echo 4.err
1161 endif
1162 if [ $dietcurd !~ '.+yoho$' ]
1163 echo 5.ok
1164 else
1165 echo 5.err
1166 endif
1167 if ! [ $dietcurd =~ '.+yoho$' ]
1168 echo 6.ok
1169 else
1170 echo 6.err
1171 endif
1172 if ! ! [ $dietcurd !~ '.+yoho$' ]
1173 echo 7.ok
1174 else
1175 echo 7.err
1176 endif
1177 if ! [ ! [ $dietcurd !~ '.+yoho$' ] ]
1178 echo 8.ok
1179 else
1180 echo 8.err
1181 endif
1182 if [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1183 echo 9.ok
1184 else
1185 echo 9.err
1186 endif
1187 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1188 echo 10.err
1189 else
1190 echo 10.ok
1191 endif
1192 if ! ! ! $dietcurd !~ '.+yoho$'
1193 echo 11.err
1194 else
1195 echo 11.ok
1196 endif
1197 if ! ! ! $dietcurd =~ '.+yoho$'
1198 echo 12.ok
1199 else
1200 echo 12.err
1201 endif
1202 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1203 echo 13.ok
1204 else
1205 echo 13.err
1206 endif
1207 set diet=abc curd='^abc$'
1208 if $diet =~ $curd
1209 echo 14.ok
1210 else
1211 echo 14.err
1212 endif
1213 set diet=abc curd='^abcd$'
1214 if $diet !~ $curd
1215 echo 15.ok
1216 else
1217 echo 15.err
1218 endif
1219 __EOT
1220 cksum_test behave:if-regex "${MBOX}" '439960016 81'
1224 __behave_localopts() {
1225 # Nestable conditions test
1226 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
1227 define t2 {
1228 echo in: t2
1229 set t2=t2
1230 echo $t2
1232 define t1 {
1233 echo in: t1
1234 set gv1=gv1
1235 localopts on
1236 set lv1=lv1 lv2=lv2
1237 set lv3=lv3
1238 call t2
1239 localopts off
1240 set gv2=gv2
1241 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1243 define t0 {
1244 echo in: t0
1245 call t1
1246 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1247 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
1249 account trouble {
1250 echo in: trouble
1251 call t0
1253 call t0
1254 unset gv1 gv2
1255 account trouble
1256 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1257 account null
1258 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1259 __EOT
1260 #in: t0
1261 #in: t1
1262 #in: t2
1264 #gv1 lv1 lv2 lv3 gv2, t2
1265 #gv1 gv2,
1266 #gv1 gv2,
1267 #in: trouble
1268 #in: t0
1269 #in: t1
1270 #in: t2
1272 #gv1 lv1 lv2 lv3 gv2, t2
1273 #gv1 gv2,
1274 #gv1 gv2,
1275 #active trouble: gv1 gv2,
1276 #active null: ,
1277 cksum_test behave:localopts "${MBOX}" '1936527193 192'
1280 __behave_macro_param_shift() {
1281 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}" 2>/dev/null
1282 define t2 {
1283 echo in: t2
1284 echo t2.0 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1285 localopts on
1286 wysh set ignerr=$1
1287 shift
1288 localopts off
1289 echo t2.1 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1290 if [ $# > 1 ] || [ $ignerr == '' ]
1291 shift 2
1292 else
1293 ignerr shift 2
1294 endif
1295 echo t2.2:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1296 shift 0
1297 echo t2.3:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1298 if [ $# > 0 ]
1299 shift
1300 endif
1301 echo t2.4:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1303 define t1 {
1304 set errexit
1305 echo in: t1
1306 call t2 1 you get four args
1307 echo t1.1: $?';' ignerr ($ignerr) should not exist
1308 call t2 1 you get 'three args'
1309 echo t1.2: $?';' ignerr ($ignerr) should not exist
1310 call t2 1 you 'get two args'
1311 echo t1.3: $?';' ignerr ($ignerr) should not exist
1312 call t2 1 'you get one arg'
1313 echo t1.4: $?';' ignerr ($ignerr) should not exist
1314 ignerr call t2 '' 'you get one arg'
1315 echo t1.5: $?';' ignerr ($ignerr) should not exist
1317 call t1
1318 __EOT
1319 #in: t1
1320 #in: t2
1321 #t2.0 has 5/5 parameters: 1,you,get (1 you get four args) [1 you get four args]
1322 #t2.1 has 4/4 parameters: you,get,four (you get four args) [you get four args]
1323 #t2.2:0 has 2/2 parameters: four,args, (four args) [four args]
1324 #t2.3:0 has 2/2 parameters: four,args, (four args) [four args]
1325 #t2.4:0 has 1/1 parameters: args,, (args) [args]
1326 #t1.1: 0; ignerr () should not exist
1327 #in: t2
1328 #t2.0 has 4/4 parameters: 1,you,get (1 you get three args) [1 you get three args]
1329 #t2.1 has 3/3 parameters: you,get,three args (you get three args) [you get three args]
1330 #t2.2:0 has 1/1 parameters: three args,, (three args) [three args]
1331 #t2.3:0 has 1/1 parameters: three args,, (three args) [three args]
1332 #t2.4:0 has 0/0 parameters: ,, () []
1333 #t1.2: 0; ignerr () should not exist
1334 #in: t2
1335 #t2.0 has 3/3 parameters: 1,you,get two args (1 you get two args) [1 you get two args]
1336 #t2.1 has 2/2 parameters: you,get two args, (you get two args) [you get two args]
1337 #t2.2:0 has 0/0 parameters: ,, () []
1338 #t2.3:0 has 0/0 parameters: ,, () []
1339 #t2.4:0 has 0/0 parameters: ,, () []
1340 #t1.3: 0; ignerr () should not exist
1341 #in: t2
1342 #t2.0 has 2/2 parameters: 1,you get one arg, (1 you get one arg) [1 you get one arg]
1343 #t2.1 has 1/1 parameters: you get one arg,, (you get one arg) [you get one arg]
1344 #t2.2:0 has 1/1 parameters: you get one arg,, (you get one arg) [you get one arg]
1345 #t2.3:0 has 1/1 parameters: you get one arg,, (you get one arg) [you get one arg]
1346 #t2.4:0 has 0/0 parameters: ,, () []
1347 #t1.4: 0; ignerr () should not exist
1348 #in: t2
1349 #t2.0 has 2/2 parameters: ,you get one arg, ( you get one arg) [ you get one arg]
1350 #t2.1 has 1/1 parameters: you get one arg,, (you get one arg) [you get one arg]
1351 #t1.5: 1; ignerr () should not exist
1352 cksum_test behave:macro_param_shift "${MBOX}" '1402489146 1682'
1355 __behave_addrcodec() {
1356 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
1357 vput addrcodec res e 1 <doog@def>
1358 echo $? $res
1359 eval vput addrcodec res d $res
1360 echo $? $res
1361 vput addrcodec res e 2 . <doog@def>
1362 echo $? $res
1363 eval vput addrcodec res d $res
1364 echo $? $res
1365 vput addrcodec res e 3 Sauer Dr. <doog@def>
1366 echo $? $res
1367 eval vput addrcodec res d $res
1368 echo $? $res
1369 vput addrcodec res e 4 Sauer (Ma) Dr. <doog@def>
1370 echo $? $res
1371 eval vput addrcodec res d $res
1372 echo $? $res
1373 vput addrcodec res e 5 Sauer (Ma) Braten Dr. <doog@def>
1374 echo $? $res
1375 eval vput addrcodec res d $res
1376 echo $? $res
1377 vput addrcodec res e 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
1378 echo $? $res
1379 eval vput addrcodec res d $res
1380 echo $? $res
1381 vput addrcodec res e 7 Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu)
1382 echo $? $res
1383 eval vput addrcodec res d $res
1384 echo $? $res
1385 vput addrcodec res e 8 \
1386 Dr. Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu) Boom. Boom
1387 echo $? $res
1388 eval vput addrcodec res d $res
1389 echo $? $res
1390 vput addrcodec res e 9 Dr.Sauer(Ma)Braten Dr. (Heu) <doog@def>
1391 echo $? $res
1392 eval vput addrcodec res d $res
1393 echo $? $res
1394 vput addrcodec res e 10 (Ma)Braten Dr. (Heu) <doog@def>
1395 echo $? $res
1396 eval vput addrcodec res d $res
1397 echo $? $res
1398 vput addrcodec res e 11 (Ma)Braten Dr"." (Heu) <doog@def>
1399 echo $? $res
1400 eval vput addrcodec res d $res
1401 echo $? $res
1402 vput addrcodec res e 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
1403 echo $? $res
1404 eval vput addrcodec res d $res
1405 echo $? $res
1406 vput addrcodec res e 13(Ma)Braten Dr. (Heu) <doog@def>
1407 echo $? $res
1408 eval vput addrcodec res d $res
1409 echo $? $res
1410 vput addrcodec res e 14 Hey, Du <doog@def> Wie() findet Dr. das? ()
1411 echo $? $res
1412 eval vput addrcodec res d $res
1413 echo $? $res
1414 vput addrcodec res e 15 \
1415 Hey, Du <doog@def> Wie() findet "" Dr. "" das? ()
1416 echo $? $res
1417 eval vput addrcodec res d $res
1418 echo $? $res
1419 vput addrcodec res e 16 \
1420 "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 17 "Hey" Du <doog@def> "Wie() findet " " Dr. """ das? ()
1425 echo $? $res
1426 eval vput addrcodec res d $res
1427 echo $? $res
1428 vput addrcodec res e 18 <doog@def> "Hey" Du "Wie() findet " " Dr. """ das? ()
1429 echo $? $res
1430 eval vput addrcodec res d $res
1431 echo $? $res
1432 vput addrcodec res e 19 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1433 echo $? $res
1434 eval vput addrcodec res d $res
1435 echo $? $res
1436 vput addrcodec res +e 20 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1437 echo $? $res
1438 vput addrcodec res +e 21 Hey\,\"" <doog@def> "Wie()" findet \" Dr. \" das?
1439 echo $? $res
1440 eval vput addrcodec res d $res
1441 echo $? $res
1442 vput addrcodec res ++e 22 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1443 echo $? $res
1444 eval vput addrcodec res d $res
1445 echo $? $res
1446 __EOT
1447 #0 1 <doog@def>
1448 #0 1 <doog@def>
1449 #0 "2 ." <doog@def>
1450 #0 2 . <doog@def>
1451 #0 "3 Sauer Dr." <doog@def>
1452 #0 3 Sauer Dr. <doog@def>
1453 #0 4 Sauer (Ma) "Dr." <doog@def>
1454 #0 4 Sauer (Ma) Dr. <doog@def>
1455 #0 5 Sauer (Ma) "Braten Dr." <doog@def>
1456 #0 5 Sauer (Ma) Braten Dr. <doog@def>
1457 #0 6 Sauer (Ma) "Braten Dr." (Heu) <doog@def>
1458 #0 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
1459 #0 7 Sauer (Ma) "Braten Dr." (Heu bu) <doog@def>
1460 #0 7 Sauer (Ma) Braten Dr. (Heu bu) <doog@def>
1461 #0 "8 Dr. Sauer" (Ma) "Braten Dr." (Heu bu) "Boom. Boom" <doog@def>
1462 #0 8 Dr. Sauer (Ma) Braten Dr. (Heu bu) Boom. Boom <doog@def>
1463 #0 "9 Dr.Sauer" (Ma) "Braten Dr." (Heu) <doog@def>
1464 #0 9 Dr.Sauer (Ma) Braten Dr. (Heu) <doog@def>
1465 #0 10 (Ma) "Braten Dr." (Heu) <doog@def>
1466 #0 10 (Ma) Braten Dr. (Heu) <doog@def>
1467 #0 11 (Ma) "Braten Dr\".\"" (Heu) <doog@def>
1468 #0 11 (Ma) Braten Dr"." (Heu) <doog@def>
1469 #0 "12 Dr. Sauer" (Ma) "Braten Dr." (u) <doog@def>
1470 #0 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
1471 #0 13 (Ma) "Braten Dr." (Heu) <doog@def>
1472 #0 13 (Ma) Braten Dr. (Heu) <doog@def>
1473 #0 "14 Hey, Du Wie" () "findet Dr. das?" () <doog@def>
1474 #0 14 Hey, Du Wie () findet Dr. das? () <doog@def>
1475 #0 "15 Hey, Du Wie" () "findet \"\" Dr. \"\" das?" () <doog@def>
1476 #0 15 Hey, Du Wie () findet "" Dr. "" das? () <doog@def>
1477 #0 "16 \"Hey,\" \"Du\" \"Wie" () "\" findet \"\" Dr. \"\" das?" () <doog@def>
1478 #0 16 "Hey," "Du" "Wie () " findet "" Dr. "" das? () <doog@def>
1479 #0 "17 \"Hey\" Du \"Wie" () "findet \" \" Dr. \"\"\" das?" () <doog@def>
1480 #0 17 "Hey" Du "Wie () findet " " Dr. """ das? () <doog@def>
1481 #0 "18 \"Hey\" Du \"Wie" () "findet \" \" Dr. \"\"\" das?" () <doog@def>
1482 #0 18 "Hey" Du "Wie () findet " " Dr. """ das? () <doog@def>
1483 #0 "19 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
1484 #0 19 Hey\,\" "Wie () " findet \" Dr. \" das? <doog@def>
1485 #1 20 Hey\\,\\" <doog@def> "Wie()" findet \\" Dr. \\" das?
1486 #0 "21 Hey\\,\\ Wie() findet \\ Dr. \\ das?" <doog@def>
1487 #0 21 Hey\,\ Wie() findet \ Dr. \ das? <doog@def>
1488 #0 "22 Hey\,\" Wie() findet \" Dr. \" das?" <doog@def>
1489 #0 22 Hey," Wie() findet " Dr. " das? <doog@def>
1490 cksum_test behave:addrcodec "${MBOX}" '2804134200 2018'
1493 __behave_vexpr() {
1494 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}" 2>/dev/null
1495 vput vexpr res = 9223372036854775807
1496 echo $?/$^ERRNAME $res
1497 vput vexpr res = 9223372036854775808
1498 echo $?/$^ERRNAME $res
1499 vput vexpr res =@ 9223372036854775808
1500 echo $?/$^ERRNAME $res
1501 vput vexpr res = -9223372036854775808
1502 echo $?/$^ERRNAME $res
1503 vput vexpr res = -9223372036854775809
1504 echo $?/$^ERRNAME $res
1505 vput vexpr res =@ -9223372036854775809
1506 echo $?/$^ERRNAME $res
1507 echo ' #1'
1508 vput vexpr res ~ 0
1509 echo $?/$^ERRNAME $res
1510 vput vexpr res ~ 1
1511 echo $?/$^ERRNAME $res
1512 vput vexpr res ~ -1
1513 echo $?/$^ERRNAME $res
1514 echo ' #2'
1515 vput vexpr res + 0 0
1516 echo $?/$^ERRNAME $res
1517 vput vexpr res + 0 1
1518 echo $?/$^ERRNAME $res
1519 vput vexpr res + 1 1
1520 echo $?/$^ERRNAME $res
1521 echo ' #3'
1522 vput vexpr res + 9223372036854775807 0
1523 echo $?/$^ERRNAME $res
1524 vput vexpr res + 9223372036854775807 1
1525 echo $?/$^ERRNAME $res
1526 vput vexpr res +@ 9223372036854775807 1
1527 echo $?/$^ERRNAME $res
1528 vput vexpr res + 0 9223372036854775807
1529 echo $?/$^ERRNAME $res
1530 vput vexpr res + 1 9223372036854775807
1531 echo $?/$^ERRNAME $res
1532 vput vexpr res +@ 1 9223372036854775807
1533 echo $?/$^ERRNAME $res
1534 echo ' #4'
1535 vput vexpr res + -9223372036854775808 0
1536 echo $?/$^ERRNAME $res
1537 vput vexpr res + -9223372036854775808 -1
1538 echo $?/$^ERRNAME $res
1539 vput vexpr res +@ -9223372036854775808 -1
1540 echo $?/$^ERRNAME $res
1541 vput vexpr res + 0 -9223372036854775808
1542 echo $?/$^ERRNAME $res
1543 vput vexpr res + -1 -9223372036854775808
1544 echo $?/$^ERRNAME $res
1545 vput vexpr res +@ -1 -9223372036854775808
1546 echo $?/$^ERRNAME $res
1547 echo ' #5'
1548 vput vexpr res - 0 0
1549 echo $?/$^ERRNAME $res
1550 vput vexpr res - 0 1
1551 echo $?/$^ERRNAME $res
1552 vput vexpr res - 1 1
1553 echo $?/$^ERRNAME $res
1554 echo ' #6'
1555 vput vexpr res - 9223372036854775807 0
1556 echo $?/$^ERRNAME $res
1557 vput vexpr res - 9223372036854775807 -1
1558 echo $?/$^ERRNAME $res
1559 vput vexpr res -@ 9223372036854775807 -1
1560 echo $?/$^ERRNAME $res
1561 vput vexpr res - 0 9223372036854775807
1562 echo $?/$^ERRNAME $res
1563 vput vexpr res - -1 9223372036854775807
1564 echo $?/$^ERRNAME $res
1565 vput vexpr res - -2 9223372036854775807
1566 echo $?/$^ERRNAME $res
1567 vput vexpr res -@ -2 9223372036854775807
1568 echo $?/$^ERRNAME $res
1569 echo ' #7'
1570 vput vexpr res - -9223372036854775808 +0
1571 echo $?/$^ERRNAME $res
1572 vput vexpr res - -9223372036854775808 +1
1573 echo $?/$^ERRNAME $res
1574 vput vexpr res -@ -9223372036854775808 +1
1575 echo $?/$^ERRNAME $res
1576 vput vexpr res - 0 -9223372036854775808
1577 echo $?/$^ERRNAME $res
1578 vput vexpr res - +1 -9223372036854775808
1579 echo $?/$^ERRNAME $res
1580 vput vexpr res -@ +1 -9223372036854775808
1581 echo $?/$^ERRNAME $res
1582 echo ' #8'
1583 vput vexpr res + -13 -2
1584 echo $?/$^ERRNAME $res
1585 vput vexpr res - 0 0
1586 echo $?/$^ERRNAME $res
1587 vput vexpr res - 0 1
1588 echo $?/$^ERRNAME $res
1589 vput vexpr res - 1 1
1590 echo $?/$^ERRNAME $res
1591 vput vexpr res - -13 -2
1592 echo $?/$^ERRNAME $res
1593 echo ' #9'
1594 vput vexpr res * 0 0
1595 echo $?/$^ERRNAME $res
1596 vput vexpr res * 0 1
1597 echo $?/$^ERRNAME $res
1598 vput vexpr res * 1 1
1599 echo $?/$^ERRNAME $res
1600 vput vexpr res * -13 -2
1601 echo $?/$^ERRNAME $res
1602 echo ' #10'
1603 vput vexpr res / 0 0
1604 echo $?/$^ERRNAME $res
1605 vput vexpr res / 0 1
1606 echo $?/$^ERRNAME $res
1607 vput vexpr res / 1 1
1608 echo $?/$^ERRNAME $res
1609 vput vexpr res / -13 -2
1610 echo $?/$^ERRNAME $res
1611 echo ' #11'
1612 vput vexpr res % 0 0
1613 echo $?/$^ERRNAME $res
1614 vput vexpr res % 0 1
1615 echo $?/$^ERRNAME $res
1616 vput vexpr res % 1 1
1617 echo $?/$^ERRNAME $res
1618 vput vexpr res % -13 -2
1619 echo $?/$^ERRNAME $res
1620 __EOT
1621 #0/NONE 9223372036854775807
1622 #1/RANGE -1
1623 #0/OVERFLOW 9223372036854775807
1624 #0/NONE -9223372036854775808
1625 #1/RANGE -1
1626 #0/OVERFLOW -9223372036854775808
1627 # #1
1628 #0/NONE -1
1629 #0/NONE -2
1630 #0/NONE 0
1631 # #2
1632 #0/NONE 0
1633 #0/NONE 1
1634 #0/NONE 2
1635 # #3
1636 #0/NONE 9223372036854775807
1637 #1/OVERFLOW -1
1638 #0/OVERFLOW 9223372036854775807
1639 #0/NONE 9223372036854775807
1640 #1/OVERFLOW -1
1641 #0/OVERFLOW 9223372036854775807
1642 # #4
1643 #0/NONE -9223372036854775808
1644 #1/OVERFLOW -1
1645 #0/OVERFLOW -9223372036854775808
1646 #0/NONE -9223372036854775808
1647 #1/OVERFLOW -1
1648 #0/OVERFLOW -9223372036854775808
1649 # #5
1650 #0/NONE 0
1651 #0/NONE -1
1652 #0/NONE 0
1653 # #6
1654 #0/NONE 9223372036854775807
1655 #1/OVERFLOW -1
1656 #0/OVERFLOW 9223372036854775807
1657 #0/NONE -9223372036854775807
1658 #0/NONE -9223372036854775808
1659 #1/OVERFLOW -1
1660 #0/OVERFLOW -9223372036854775808
1661 # #7
1662 #0/NONE -9223372036854775808
1663 #1/OVERFLOW -1
1664 #0/OVERFLOW -9223372036854775808
1665 #0/NONE -9223372036854775808
1666 #1/OVERFLOW -1
1667 #0/OVERFLOW -9223372036854775808
1668 # #8
1669 #0/NONE -15
1670 #0/NONE 0
1671 #0/NONE -1
1672 #0/NONE 0
1673 #0/NONE -11
1674 # #9
1675 #0/NONE 0
1676 #0/NONE 0
1677 #0/NONE 1
1678 #0/NONE 26
1679 # #10
1680 #1/RANGE -1
1681 #0/NONE 0
1682 #0/NONE 1
1683 #0/NONE 6
1684 # #11
1685 #1/RANGE -1
1686 #0/NONE 0
1687 #0/NONE 0
1688 #0/NONE -1
1689 cksum_test behave:vexpr-numeric "${MBOX}" '1723609217 1048'
1691 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}" #2>/dev/null
1692 vput vexpr res find 'bananarama' 'nana'
1693 echo $?/$^ERRNAME :$res:
1694 vput vexpr res find 'bananarama' 'bana'
1695 echo $?/$^ERRNAME :$res:
1696 vput vexpr res find 'bananarama' 'Bana'
1697 echo $?/$^ERRNAME :$res:
1698 vput vexpr res find 'bananarama' 'rama'
1699 echo $?/$^ERRNAME :$res:
1700 echo ' #1'
1701 vput vexpr res ifind 'bananarama' 'nana'
1702 echo $?/$^ERRNAME :$res:
1703 vput vexpr res ifind 'bananarama' 'bana'
1704 echo $?/$^ERRNAME :$res:
1705 vput vexpr res ifind 'bananarama' 'Bana'
1706 echo $?/$^ERRNAME :$res:
1707 vput vexpr res ifind 'bananarama' 'rama'
1708 echo $?/$^ERRNAME :$res:
1709 echo ' #2'
1710 vput vexpr res substring 'bananarama' 1
1711 echo $?/$^ERRNAME :$res:
1712 vput vexpr res substring 'bananarama' 3
1713 echo $?/$^ERRNAME :$res:
1714 vput vexpr res substring 'bananarama' 5
1715 echo $?/$^ERRNAME :$res:
1716 vput vexpr res substring 'bananarama' 7
1717 echo $?/$^ERRNAME :$res:
1718 vput vexpr res substring 'bananarama' 9
1719 echo $?/$^ERRNAME :$res:
1720 vput vexpr res substring 'bananarama' 10
1721 echo $?/$^ERRNAME :$res:
1722 vput vexpr res substring 'bananarama' 1 3
1723 echo $?/$^ERRNAME :$res:
1724 vput vexpr res substring 'bananarama' 3 3
1725 echo $?/$^ERRNAME :$res:
1726 vput vexpr res substring 'bananarama' 5 3
1727 echo $?/$^ERRNAME :$res:
1728 vput vexpr res substring 'bananarama' 7 3
1729 echo $?/$^ERRNAME :$res:
1730 vput vexpr res substring 'bananarama' 9 3
1731 echo $?/$^ERRNAME :$res:
1732 vput vexpr res substring 'bananarama' 10 3
1733 echo $?/$^ERRNAME :$res:
1734 echo ' #3'
1735 __EOT
1736 #0/NONE :2:
1737 #0/NONE :0:
1738 #1/NODATA ::
1739 #0/NONE :6:
1740 # #1
1741 #0/NONE :2:
1742 #0/NONE :0:
1743 #0/NONE :0:
1744 #0/NONE :6:
1745 # #2
1746 #0/NONE :ananarama:
1747 #0/NONE :anarama:
1748 #0/NONE :arama:
1749 #0/NONE :ama:
1750 #0/NONE :a:
1751 #0/NONE ::
1752 #0/NONE :ana:
1753 #0/NONE :ana:
1754 #0/NONE :ara:
1755 #0/NONE :ama:
1756 #0/OVERFLOW :a:
1757 #0/OVERFLOW ::
1758 # #3
1759 cksum_test behave:vexpr-string "${MBOX}" '265398700 267'
1761 if have_feat regex; then
1762 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}" #2>/dev/null
1763 vput vexpr res regex 'bananarama' 'nana'
1764 echo $?/$^ERRNAME :$res:
1765 vput vexpr res regex 'bananarama' 'bana'
1766 echo $?/$^ERRNAME :$res:
1767 vput vexpr res regex 'bananarama' 'Bana'
1768 echo $?/$^ERRNAME :$res:
1769 vput vexpr res regex 'bananarama' 'rama'
1770 echo $?/$^ERRNAME :$res:
1771 echo ' #1'
1772 vput vexpr res iregex 'bananarama' 'nana'
1773 echo $?/$^ERRNAME :$res:
1774 vput vexpr res iregex 'bananarama' 'bana'
1775 echo $?/$^ERRNAME :$res:
1776 vput vexpr res iregex 'bananarama' 'Bana'
1777 echo $?/$^ERRNAME :$res:
1778 vput vexpr res iregex 'bananarama' 'rama'
1779 echo $?/$^ERRNAME :$res:
1780 echo ' #2'
1781 vput vexpr res regex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1782 echo $?/$^ERRNAME :$res:
1783 vput vexpr res regex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1784 echo $?/$^ERRNAME :$res:
1785 vput vexpr res regex 'bananarama' 'Bana(.+)' '\$1\$0'
1786 echo $?/$^ERRNAME :$res:
1787 vput vexpr res regex 'bananarama' '(.+)rama' '\$1\$0'
1788 echo $?/$^ERRNAME :$res:
1789 echo ' #3'
1790 vput vexpr res iregex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1791 echo $?/$^ERRNAME :$res:
1792 vput vexpr res iregex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1793 echo $?/$^ERRNAME :$res:
1794 vput vexpr res iregex 'bananarama' 'Bana(.+)' '\$1\$0'
1795 echo $?/$^ERRNAME :$res:
1796 vput vexpr res iregex 'bananarama' '(.+)rama' '\$1\$0'
1797 echo $?/$^ERRNAME :$res:
1798 echo ' #4'
1799 __EOT
1800 #0/NONE :2:
1801 #0/NONE :0:
1802 #1/NODATA ::
1803 #0/NONE :6:
1804 # #1
1805 #0/NONE :2:
1806 #0/NONE :0:
1807 #0/NONE :0:
1808 #0/NONE :6:
1809 # #2
1810 #0/NONE :baabananaramau{rama}:
1811 #0/NONE :abananaramaunarama:
1812 #1/NODATA ::
1813 #0/NONE :bananabananarama:
1814 # #3
1815 #0/NONE :baabananaramau{rama}:
1816 #0/NONE :abananaramaunarama:
1817 #0/NONE :naramabananarama:
1818 #0/NONE :bananabananarama:
1819 # #4
1820 cksum_test behave:vexpr-regex "${MBOX}" '3270360157 311'
1824 __behave_smime() { # FIXME add test/ dir, unroll tests therein
1825 TRAP_EXIT_ADDONS="./.t.conf ./.tkey.pem ./.tcert.pem ./.tpair.pem"
1826 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.VERIFY ./.DECRYPT ./.ENCRYPT"
1827 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.tsendmail.sh"
1829 printf 'behave:s/mime: .. generating test key and certificate ..\n'
1830 ${cat} <<-_EOT > ./.t.conf
1831 [ req ]
1832 default_bits = 1024
1833 default_keyfile = keyfile.pem
1834 distinguished_name = req_distinguished_name
1835 attributes = req_attributes
1836 prompt = no
1837 output_password =
1839 [ req_distinguished_name ]
1840 C = GB
1841 ST = Over the
1842 L = rainbow
1843 O = S-nail
1844 OU = S-nail.smime
1845 CN = S-nail.test
1846 emailAddress = test@localhost
1848 [ req_attributes ]
1849 challengePassword =
1850 _EOT
1851 openssl req -x509 -nodes -days 3650 -config ./.t.conf \
1852 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >/dev/null 2>&1
1853 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
1855 printf "behave:s/mime:sign/verify: "
1856 echo bla | "${SNAIL}" ${ARGS} \
1857 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
1858 -Ssmime-sign -Sfrom=test@localhost \
1859 -s 'S/MIME test' ./.VERIFY
1860 printf 'verify\nx\n' |
1861 "${SNAIL}" ${ARGS} \
1862 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
1863 -Ssmime-sign -Sfrom=test@localhost \
1864 -Serrexit -R \
1865 -f ./.VERIFY >/dev/null 2>&1
1866 if [ $? -eq 0 ]; then
1867 printf 'ok\n'
1868 else
1869 printf 'error: verification failed\n'
1870 ESTAT=1
1871 ${rm} -f ${TRAP_EXIT_ADDONS}
1872 TRAP_EXIT_ADDONS=
1873 return
1875 printf ' .. disproof via openssl smime(1): '
1876 if openssl smime -verify -CAfile ./.tcert.pem \
1877 -in ./.VERIFY >/dev/null 2>&1; then
1878 printf 'ok\n'
1879 else
1880 printf 'failed\n'
1881 ESTAT=1
1882 ${rm} -f ${TRAP_EXIT_ADDONS}
1883 TRAP_EXIT_ADDONS=
1884 return
1887 # (signing +) encryption / decryption
1888 ${cat} <<-_EOT > ./.tsendmail.sh
1889 #!/bin/sh -
1890 ${rm} -f ./.ENCRYPT
1891 (echo 'From S-Postman Thu May 10 20:40:54 2012' && ${cat}) > ./.ENCRYPT
1892 _EOT
1893 chmod 0755 ./.tsendmail.sh
1895 printf "behave:s/mime:encrypt+sign/decrypt+verify: "
1896 echo bla |
1897 "${SNAIL}" ${ARGS} \
1898 -Ssmime-force-encryption \
1899 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
1900 -Smta=./.tsendmail.sh \
1901 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
1902 -Ssmime-sign -Sfrom=test@localhost \
1903 -s 'S/MIME test' recei@ver.com
1904 # TODO CHECK
1905 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
1906 "${SNAIL}" ${ARGS} \
1907 -Ssmime-force-encryption \
1908 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
1909 -Smta=./.tsendmail.sh \
1910 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
1911 -Ssmime-sign -Sfrom=test@localhost \
1912 -Serrexit -R \
1913 -f ./.ENCRYPT >/dev/null 2>&1
1914 if [ $? -eq 0 ]; then
1915 printf 'ok\n'
1916 else
1917 ESTAT=1
1918 printf 'error: decryption+verification failed\n'
1920 printf ' ..disproof via openssl smime(1): '
1921 if (openssl smime -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT |
1922 openssl smime -verify -CAfile ./.tcert.pem) >/dev/null 2>&1; then
1923 printf 'ok\n'
1924 else
1925 printf 'failed\n'
1926 ESTAT=1
1928 ${sed} -e '/^Date:/d' -e '/^X-Decoding-Date/d' \
1929 -e \
1930 '/^Content-Disposition: attachment; filename="smime.p7s"/,/^-- /d' \
1931 < ./.DECRYPT > ./.ENCRYPT
1932 cksum_test ".. checksum of decrypted content" "./.ENCRYPT" '3090916509 510'
1934 printf "behave:s/mime:encrypt/decrypt: "
1935 ${rm} -f ./.DECRYPT
1936 echo bla | "${SNAIL}" ${ARGS} \
1937 -Ssmime-force-encryption \
1938 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
1939 -Smta=./.tsendmail.sh \
1940 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
1941 -Sfrom=test@localhost \
1942 -s 'S/MIME test' recei@ver.com
1943 printf 'decrypt ./.DECRYPT\nx\n' | "${SNAIL}" ${ARGS} \
1944 -Ssmime-force-encryption \
1945 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
1946 -Smta=./.tsendmail.sh \
1947 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
1948 -Sfrom=test@localhost \
1949 -Serrexit -R \
1950 -f ./.ENCRYPT >/dev/null 2>&1
1951 if [ $? -eq 0 ]; then
1952 printf 'ok\n'
1953 else
1954 ESTAT=1
1955 printf 'error: decryption failed\n'
1957 printf '.. disproof via openssl smime(1): '
1958 if openssl smime -decrypt -inkey ./.tkey.pem \
1959 -in ./.ENCRYPT >/dev/null 2>&1; then
1960 printf 'ok\n'
1961 else
1962 printf 'failed\n'
1963 ESTAT=1
1965 ${sed} -e '/^Date:/d' -e '/^X-Decoding-Date/d' \
1966 < ./.DECRYPT > ./.ENCRYPT
1967 cksum_test ".. checksum of decrypted content" ./.ENCRYPT '999887248 295'
1969 ${rm} -f ${TRAP_EXIT_ADDONS}
1970 TRAP_EXIT_ADDONS=
1973 # t_content()
1974 # Some basic tests regarding correct sending of mails, via STDIN / -t / -q,
1975 # including basic MIME Content-Transfer-Encoding correctness (quoted-printable)
1976 # Note we unfortunately need to place some statements without proper
1977 # indentation because of continuation problems
1978 t_content() {
1979 # MIME encoding (QP) stress message body
1980 printf \
1981 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
1982 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
1983 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
1984 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
1985 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
1986 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
1987 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
1988 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
1989 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
1990 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
1991 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
1992 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
1993 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
1994 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
1995 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
1996 "auf den zeilen vorher.\r\n"\
1997 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
1998 ".\r\n"\
1999 "Die letzte Zeile war nur ein Punkt.\r\n"\
2000 "..\r\n"\
2001 "Das waren deren zwei.\r\n"\
2002 " \r\n"\
2003 "Die letzte Zeile war ein Leerschritt.\n"\
2004 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
2005 "Prösterchen.\r\n"\
2006 ".\n"\
2007 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
2008 "..\n"\
2009 "Das waren deren zwei. ditto.\n"\
2010 "Prösterchen.\n"\
2011 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
2012 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
2013 "auf den zeilen vorher.\n"\
2014 "ditto.\n"\
2015 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
2016 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
2017 "\n"\
2018 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
2019 "\n"\
2020 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
2021 "3\n"\
2022 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
2023 "34\n"\
2024 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
2025 "345\n"\
2026 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
2027 "3456\n"\
2028 "QP am Zeilenende über soft-nl hinweg\n"\
2029 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
2030 "ö123\n"\
2031 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
2032 "1ö23\n"\
2033 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
2034 "12ö3\n"\
2035 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
2036 "123ö\n"\
2037 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
2038 " \n"\
2039 "Die letzte Zeile war ein Leerschritt.\n"\
2040 ' '\
2041 > "${BODY}"
2043 # MIME encoding (QP) stress message subject
2044 SUB="Äbrä Kä?dä=brö Fü?di=bus? \
2045 adadaddsssssssddddddddddddddddddddd\
2046 ddddddddddddddddddddddddddddddddddd\
2047 ddddddddddddddddddddddddddddddddddd\
2048 dddddddddddddddddddd Hallelulja? Od\
2049 er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
2050 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
2051 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f\
2052 fffffffffffffffffffffffffffffffffff\
2053 fffffffffffffffffffff ggggggggggggg\
2054 ggggggggggggggggggggggggggggggggggg\
2055 ggggggggggggggggggggggggggggggggggg\
2056 ggggggggggggggggggggggggggggggggggg\
2057 gggggggggggggggg"
2059 # Three tests for MIME encodign and (a bit) content classification.
2060 # At the same time testing -q FILE, < FILE and -t FILE
2062 ${rm} -f "${MBOX}"
2063 < "${BODY}" "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2064 -a "${BODY}" -s "${SUB}" "${MBOX}"
2065 cksum_test content:001 "${MBOX}" '2356108758 6413'
2067 ${rm} -f "${MBOX}"
2068 < /dev/null "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2069 -a "${BODY}" -s "${SUB}" -q "${BODY}" "${MBOX}"
2070 cksum_test content:002 "${MBOX}" '2356108758 6413'
2072 ${rm} -f "${MBOX}"
2073 ( echo "To: ${MBOX}" && echo "Subject: ${SUB}" && echo &&
2074 ${cat} "${BODY}"
2075 ) | "${SNAIL}" ${ARGS} ${ADDARG_UNI} -Snodot -a "${BODY}" -t
2076 cksum_test content:003 "${MBOX}" '2356108758 6413'
2078 # Test for [260e19d] (Juergen Daubert)
2079 ${rm} -f "${MBOX}"
2080 echo body | "${SNAIL}" ${ARGS} "${MBOX}"
2081 cksum_test content:004 "${MBOX}" '4004005686 49'
2083 # Sending of multiple mails in a single invocation
2084 ${rm} -f "${MBOX}"
2085 ( printf "m ${MBOX}\n~s subject1\nE-Mail Körper 1\n~.\n" &&
2086 printf "m ${MBOX}\n~s subject2\nEmail body 2\n~.\n" &&
2087 echo x
2088 ) | "${SNAIL}" ${ARGS} ${ADDARG_UNI}
2089 cksum_test content:005 "${MBOX}" '2157252578 260'
2091 ## $BODY CHANGED
2093 # "Test for" [d6f316a] (Gavin Troy)
2094 ${rm} -f "${MBOX}"
2095 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
2096 "${SNAIL}" ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="${cat}" > "${BODY}"
2097 ${sed} -e 1d < "${BODY}" > "${MBOX}"
2098 cksum_test content:006 "${MBOX}" '2273863401 83'
2100 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
2101 ${rm} -f "${MBOX}"
2102 ${awk} 'BEGIN{
2103 for(i = 0; i < 10000; ++i)
2104 printf "\xC3\xBC"
2105 #printf "\xF0\x90\x87\x90"
2106 }' | "${SNAIL}" ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
2107 cksum_test content:007 "${MBOX}" '1754234717 61767'
2109 ## Test some more corner cases for header bodies (as good as we can today) ##
2112 ${rm} -f "${MBOX}"
2113 echo | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2114 -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̲' \
2115 "${MBOX}"
2116 cksum_test content:008 "${MBOX}" '1563381297 326'
2118 # Single word (overlong line split -- bad standard! Requires injection of
2119 # artificial data!! Bad can be prevented by using RFC 2047 encoding)
2120 ${rm} -f "${MBOX}"
2121 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
2122 echo | "${SNAIL}" ${ARGS} -s "${i}" "${MBOX}"
2123 cksum_test content:009 "${MBOX}" '1996714851 1669'
2125 # Combination of encoded words, space and tabs of varying sort
2126 ${rm} -f "${MBOX}"
2127 echo | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2128 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
2129 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
2130 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
2131 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
2132 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
2133 "${MBOX}"
2134 cksum_test content:010 "${MBOX}" '2956039469 542'
2136 # Overlong multibyte sequence that must be forcefully split
2137 # todo This works even before v15.0, but only by accident
2138 ${rm} -f "${MBOX}"
2139 echo | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2140 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
2141 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
2142 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
2143 "${MBOX}"
2144 cksum_test content:011 "${MBOX}" '454973928 610'
2146 # Trailing WS
2147 ${rm} -f "${MBOX}"
2148 echo | "${SNAIL}" ${ARGS} \
2149 -s "1-1 B2 B3 B4 B5 B6 B\
2150 1-2 B2 B3 B4 B5 B6 B\
2151 1-3 B2 B3 B4 B5 B6 B\
2152 1-4 B2 B3 B4 B5 B6 B\
2153 1-5 B2 B3 B4 B5 B6 B\
2154 1-6 B2 B3 B4 B5 B6 " \
2155 "${MBOX}"
2156 cksum_test content:012 "${MBOX}" '1014122962 248'
2158 # Leading and trailing WS
2159 ${rm} -f "${MBOX}"
2160 echo | "${SNAIL}" ${ARGS} \
2161 -s " 2-1 B2 B3 B4 B5 B6 B\
2162 1-2 B2 B3 B4 B5 B6 B\
2163 1-3 B2 B3 B4 B5 B6 B\
2164 1-4 B2 B3 B4 B5 B6 " \
2165 "${MBOX}"
2166 cksum_test content:013 "${MBOX}" '3212167908 187'
2168 # Quick'n dirty RFC 2231 test; i had more when implementing it, but until we
2169 # have a (better) test framework materialize a quick shot
2170 ${rm} -f "${MBOX}"
2171 TRAP_EXIT_ADDONS=./.ttt
2173 mkdir ./.ttt || exit 1
2174 cd ./.ttt || exit 2
2175 : > "ma'ger.txt"
2176 : > "mä'ger.txt"
2177 : > 'diet\ is \curd.txt'
2178 : > 'diet "is" curd.txt'
2179 : > höde-tröge.txt
2180 : > 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
2181 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
2182 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
2183 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
2185 echo bla | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2186 -a "./.ttt/ma'ger.txt" -a "./.ttt/mä'ger.txt" \
2187 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
2188 -a ./.ttt/höde-tröge.txt \
2189 -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 \
2190 -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 \
2191 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
2192 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
2193 "${MBOX}"
2194 ${rm} -rf ./.ttt
2195 cksum_test content:14 "${MBOX}" '589846634 2491'
2196 # `resend' test
2197 printf "Resend ${BODY}\nx\n" | "${SNAIL}" ${ARGS} -f "${MBOX}"
2198 cksum_test content:14-2 "${MBOX}" '589846634 2491'
2201 t_all() {
2202 if have_feat devel; then
2203 ARGS="${ARGS} -Smemdebug"
2204 export ARGS
2206 t_behave
2207 t_content
2210 if [ -z "${CHECK_ONLY}" ]; then
2211 cc_all_configs
2212 else
2213 t_all
2216 [ ${ESTAT} -eq 0 ] && echo Ok || echo >&2 'Errors occurred'
2218 exit ${ESTAT}
2219 # s-sh-mode