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