README: Add "Security record" section
[s-mailx.git] / cc-test.sh
blob76b784be629493c6cf0a27f1627b139720ed2edc
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 wysh 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 "wysh 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 wysh 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 "wysh 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 < 11
674 echo 11.ok1
675 if $dietcurd > 9
676 echo 11.ok2
677 else
678 echo 11.err2
679 endif
680 if $dietcurd == 10
681 echo 11.ok3
682 else
683 echo 11.err3
684 endif
685 if $dietcurd >= 10
686 echo 11.ok4
687 else
688 echo 11.err4
689 endif
690 if $dietcurd <= 10
691 echo 11.ok5
692 else
693 echo 11.err5
694 endif
695 if $dietcurd >= 11
696 echo 11.err6
697 else
698 echo 11.ok6
699 endif
700 if $dietcurd <= 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}" 2>/dev/null
1325 vput addrcodec res 1 <doog@def>
1326 echo $! $res
1327 vput addrcodec res 2 . <doog@def>
1328 echo $! $res
1329 vput addrcodec res 3 Sauer Dr. <doog@def>
1330 echo $! $res
1331 vput addrcodec res 4 Sauer (Ma) Dr. <doog@def>
1332 echo $! $res
1333 vput addrcodec res 5 Sauer (Ma) Braten Dr. <doog@def>
1334 echo $! $res
1335 vput addrcodec res 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
1336 echo $! $res
1337 vput addrcodec res 7 Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu)
1338 echo $! $res
1339 vput addrcodec res 8 \
1340 Dr. Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu) Boom. Boom
1341 echo $! $res
1342 vput addrcodec res 9 Dr.Sauer(Ma)Braten Dr. (Heu) <doog@def>
1343 echo $! $res
1344 vput addrcodec res 10 (Ma)Braten Dr. (Heu) <doog@def>
1345 echo $! $res
1346 vput addrcodec res 11 (Ma)Braten Dr'"."' (Heu) <doog@def>
1347 echo $! $res
1348 vput addrcodec res 12 \
1349 ' Dr. ' ' Sauer ' (Ma) ' Braten ' ' Dr. ' (u) <doog@def>
1350 echo $! $res
1351 vput addrcodec res 13(Ma)Braten Dr. (Heu) <doog@def>
1352 echo $! $res
1353 vput addrcodec res 14 Hey, Du <doog@def> Wie() findet Dr. das? ()
1354 echo $! $res
1355 vput addrcodec res 15 \
1356 Hey, Du <doog@def> Wie() findet '""' Dr. '""' das? ()
1357 echo $! $res
1358 vput addrcodec res 16 \
1359 \"Hey,\" \"Du\" <doog@def> \"Wie()\" findet \"\" Dr. \"\" das? ()
1360 echo $! $res
1361 vput addrcodec res 17 \
1362 \"Hey\" Du <doog@def> \"Wie() findet \" \" Dr. \"\"\" das? ()
1363 echo $! $res
1364 vput addrcodec res 18 \
1365 <doog@def> \"Hey\" Du \"Wie() findet \" \" Dr. \"\"\" das? ()
1366 echo $! $res
1367 vput addrcodec res 19 \
1368 'Hey\,\" ' <doog@def> '"Wie()" findet \" Dr. \"' das? ()
1369 echo $! $res
1370 __EOT
1371 #0 1 <doog@def>
1372 #0 "2 ." <doog@def>
1373 #0 "3 Sauer Dr." <doog@def>
1374 #0 4 Sauer (Ma) "Dr." <doog@def>
1375 #0 5 Sauer (Ma) "Braten Dr." <doog@def>
1376 #0 6 Sauer (Ma) "Braten Dr." (Heu) <doog@def>
1377 #0 7 Sauer (Ma) "Braten Dr." (Heu bu) <doog@def>
1378 #0 "8 Dr. Sauer" (Ma) "Braten Dr." (Heu bu) "Boom. Boom" <doog@def>
1379 #0 "9 Dr.Sauer" (Ma) "Braten Dr." (Heu) <doog@def>
1380 #0 10 (Ma) "Braten Dr." (Heu) <doog@def>
1381 #0 11 (Ma) "Braten Dr\".\"" (Heu) <doog@def>
1382 #0 "12 Dr. Sauer" (Ma) "Braten Dr." (u) <doog@def>
1383 #0 13 (Ma) "Braten Dr." (Heu) <doog@def>
1384 #0 "14 Hey, Du Wie" () "findet Dr. das?" () <doog@def>
1385 #0 "15 Hey, Du Wie" () "findet \"\" Dr. \"\" das?" () <doog@def>
1386 #0 "16 \"Hey,\" \"Du\" \"Wie" () "\" findet \"\" Dr. \"\" das?" () <doog@def>
1387 #0 "17 \"Hey\" Du \"Wie" () "findet \" \" Dr. \"\"\" das?" () <doog@def>
1388 #0 "18 \"Hey\" Du \"Wie" () "findet \" \" Dr. \"\"\" das?" () <doog@def>
1389 #0 "19 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" () <doog@def>
1390 cksum_test behave:addrcodec "${MBOX}" '1997352922 927'
1393 __behave_vexpr() {
1394 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}" 2>/dev/null
1395 vput vexpr res = 9223372036854775807
1396 echo $! $res
1397 vput vexpr res = 9223372036854775808
1398 echo $! $res
1399 vput vexpr res =@ 9223372036854775808
1400 echo $! $res
1401 vput vexpr res = -9223372036854775808
1402 echo $! $res
1403 vput vexpr res = -9223372036854775809
1404 echo $! $res
1405 vput vexpr res =@ -9223372036854775809
1406 echo $! $res
1407 echo ' #1'
1408 vput vexpr res ~ 0
1409 echo $! $res
1410 vput vexpr res ~ 1
1411 echo $! $res
1412 vput vexpr res ~ -1
1413 echo $! $res
1414 echo ' #2'
1415 vput vexpr res + 0 0
1416 echo $! $res
1417 vput vexpr res + 0 1
1418 echo $! $res
1419 vput vexpr res + 1 1
1420 echo $! $res
1421 echo ' #3'
1422 vput vexpr res + 9223372036854775807 0
1423 echo $! $res
1424 vput vexpr res + 9223372036854775807 1
1425 echo $! $res
1426 vput vexpr res +@ 9223372036854775807 1
1427 echo $! $res
1428 vput vexpr res + 0 9223372036854775807
1429 echo $! $res
1430 vput vexpr res + 1 9223372036854775807
1431 echo $! $res
1432 vput vexpr res +@ 1 9223372036854775807
1433 echo $! $res
1434 echo ' #4'
1435 vput vexpr res + -9223372036854775808 0
1436 echo $! $res
1437 vput vexpr res + -9223372036854775808 -1
1438 echo $! $res
1439 vput vexpr res +@ -9223372036854775808 -1
1440 echo $! $res
1441 vput vexpr res + 0 -9223372036854775808
1442 echo $! $res
1443 vput vexpr res + -1 -9223372036854775808
1444 echo $! $res
1445 vput vexpr res +@ -1 -9223372036854775808
1446 echo $! $res
1447 echo ' #5'
1448 vput vexpr res - 0 0
1449 echo $! $res
1450 vput vexpr res - 0 1
1451 echo $! $res
1452 vput vexpr res - 1 1
1453 echo $! $res
1454 echo ' #6'
1455 vput vexpr res - 9223372036854775807 0
1456 echo $! $res
1457 vput vexpr res - 9223372036854775807 -1
1458 echo $! $res
1459 vput vexpr res -@ 9223372036854775807 -1
1460 echo $! $res
1461 vput vexpr res - 0 9223372036854775807
1462 echo $! $res
1463 vput vexpr res - -1 9223372036854775807
1464 echo $! $res
1465 vput vexpr res - -2 9223372036854775807
1466 echo $! $res
1467 vput vexpr res -@ -2 9223372036854775807
1468 echo $! $res
1469 echo ' #7'
1470 vput vexpr res - -9223372036854775808 +0
1471 echo $! $res
1472 vput vexpr res - -9223372036854775808 +1
1473 echo $! $res
1474 vput vexpr res -@ -9223372036854775808 +1
1475 echo $! $res
1476 vput vexpr res - 0 -9223372036854775808
1477 echo $! $res
1478 vput vexpr res - +1 -9223372036854775808
1479 echo $! $res
1480 vput vexpr res -@ +1 -9223372036854775808
1481 echo $! $res
1482 echo ' #8'
1483 vput vexpr res + -13 -2
1484 echo $! $res
1485 vput vexpr res - 0 0
1486 echo $! $res
1487 vput vexpr res - 0 1
1488 echo $! $res
1489 vput vexpr res - 1 1
1490 echo $! $res
1491 vput vexpr res - -13 -2
1492 echo $! $res
1493 echo ' #9'
1494 vput vexpr res * 0 0
1495 echo $! $res
1496 vput vexpr res * 0 1
1497 echo $! $res
1498 vput vexpr res * 1 1
1499 echo $! $res
1500 vput vexpr res * -13 -2
1501 echo $! $res
1502 echo ' #10'
1503 vput vexpr res / 0 0
1504 echo $! $res
1505 vput vexpr res / 0 1
1506 echo $! $res
1507 vput vexpr res / 1 1
1508 echo $! $res
1509 vput vexpr res / -13 -2
1510 echo $! $res
1511 echo ' #11'
1512 vput vexpr res % 0 0
1513 echo $! $res
1514 vput vexpr res % 0 1
1515 echo $! $res
1516 vput vexpr res % 1 1
1517 echo $! $res
1518 vput vexpr res % -13 -2
1519 echo $! $res
1520 __EOT
1521 #0 9223372036854775807
1522 #1 -1
1523 #1 9223372036854775807
1524 #0 -9223372036854775808
1525 #1 -1
1526 #1 -9223372036854775808
1527 # #1
1528 #0 -1
1529 #0 -2
1530 #0 0
1531 # #2
1532 #0 0
1533 #0 1
1534 #0 2
1535 # #3
1536 #0 9223372036854775807
1537 #1 -1
1538 #1 9223372036854775807
1539 #0 9223372036854775807
1540 #1 -1
1541 #1 9223372036854775807
1542 # #4
1543 #0 -9223372036854775808
1544 #1 -1
1545 #1 -9223372036854775808
1546 #0 -9223372036854775808
1547 #1 -1
1548 #1 -9223372036854775808
1549 # #5
1550 #0 0
1551 #0 -1
1552 #0 0
1553 # #6
1554 #0 9223372036854775807
1555 #1 -1
1556 #1 9223372036854775807
1557 #0 -9223372036854775807
1558 #0 -9223372036854775808
1559 #1 -1
1560 #1 -9223372036854775808
1561 # #7
1562 #0 -9223372036854775808
1563 #1 -1
1564 #1 -9223372036854775808
1565 #0 -9223372036854775808
1566 #1 -1
1567 #1 -9223372036854775808
1568 # #8
1569 #0 -15
1570 #0 0
1571 #0 -1
1572 #0 0
1573 #0 -11
1574 # #9
1575 #0 0
1576 #0 0
1577 #0 1
1578 #0 26
1579 # #10
1580 #1 -1
1581 #0 0
1582 #0 1
1583 #0 6
1584 # #11
1585 #1 -1
1586 #0 0
1587 #0 0
1588 #0 -1
1589 cksum_test behave:vexpr-numeric "${MBOX}" '2147139513 687'
1591 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}" #2>/dev/null
1592 vput vexpr res find 'bananarama' 'nana'
1593 echo $! $res
1594 vput vexpr res find 'bananarama' 'bana'
1595 echo $! $res
1596 vput vexpr res find 'bananarama' 'Bana'
1597 echo $! $res
1598 vput vexpr res find 'bananarama' 'rama'
1599 echo $! $res
1600 echo ' #1'
1601 vput vexpr res ifind 'bananarama' 'nana'
1602 echo $! $res
1603 vput vexpr res ifind 'bananarama' 'bana'
1604 echo $! $res
1605 vput vexpr res ifind 'bananarama' 'Bana'
1606 echo $! $res
1607 vput vexpr res ifind 'bananarama' 'rama'
1608 echo $! $res
1609 echo ' #2'
1610 vput vexpr res substring 'bananarama' 1
1611 echo $! $res
1612 vput vexpr res substring 'bananarama' 3
1613 echo $! $res
1614 vput vexpr res substring 'bananarama' 5
1615 echo $! $res
1616 vput vexpr res substring 'bananarama' 7
1617 echo $! $res
1618 vput vexpr res substring 'bananarama' 9
1619 echo $! $res
1620 vput vexpr res substring 'bananarama' 10
1621 echo $! $res
1622 vput vexpr res substring 'bananarama' 1 3
1623 echo $! $res
1624 vput vexpr res substring 'bananarama' 3 3
1625 echo $! $res
1626 vput vexpr res substring 'bananarama' 5 3
1627 echo $! $res
1628 vput vexpr res substring 'bananarama' 7 3
1629 echo $! $res
1630 vput vexpr res substring 'bananarama' 9 3
1631 echo $! $res
1632 vput vexpr res substring 'bananarama' 10 3
1633 echo $! $res
1634 echo ' #3'
1635 __EOT
1636 #0 2
1637 #0 0
1638 #1 -1
1639 #0 6
1640 # #1
1641 #0 2
1642 #0 0
1643 #0 0
1644 #0 6
1645 # #2
1646 #0 ananarama
1647 #0 anarama
1648 #0 arama
1649 #0 ama
1650 #0 a
1652 #0 ana
1653 #0 ana
1654 #0 ara
1655 #0 ama
1656 #1 a
1658 # #3
1659 cksum_test behave:vexpr-string "${MBOX}" '2171181036 119'
1661 if have_feat regex; then
1662 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}" #2>/dev/null
1663 vput vexpr res regex 'bananarama' 'nana'
1664 echo $! $res
1665 vput vexpr res regex 'bananarama' 'bana'
1666 echo $! $res
1667 vput vexpr res regex 'bananarama' 'Bana'
1668 echo $! $res
1669 vput vexpr res regex 'bananarama' 'rama'
1670 echo $! $res
1671 echo ' #1'
1672 vput vexpr res iregex 'bananarama' 'nana'
1673 echo $! $res
1674 vput vexpr res iregex 'bananarama' 'bana'
1675 echo $! $res
1676 vput vexpr res iregex 'bananarama' 'Bana'
1677 echo $! $res
1678 vput vexpr res iregex 'bananarama' 'rama'
1679 echo $! $res
1680 echo ' #2'
1681 vput vexpr res regex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1682 echo $! $res
1683 vput vexpr res regex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1684 echo $! $res
1685 vput vexpr res regex 'bananarama' 'Bana(.+)' '\$1\$0'
1686 echo $! $res
1687 vput vexpr res regex 'bananarama' '(.+)rama' '\$1\$0'
1688 echo $! $res
1689 echo ' #3'
1690 vput vexpr res iregex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1691 echo $! $res
1692 vput vexpr res iregex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1693 echo $! $res
1694 vput vexpr res iregex 'bananarama' 'Bana(.+)' '\$1\$0'
1695 echo $! $res
1696 vput vexpr res iregex 'bananarama' '(.+)rama' '\$1\$0'
1697 echo $! $res
1698 echo ' #4'
1699 __EOT
1700 #0 2
1701 #0 0
1702 #1 -1
1703 #0 6
1704 # #1
1705 #0 2
1706 #0 0
1707 #0 0
1708 #0 6
1709 # #2
1710 #0 baabananaramau{rama}
1711 #0 abananaramaunarama
1712 #1 -1
1713 #0 bananabananarama
1714 # #3
1715 #0 baabananaramau{rama}
1716 #0 abananaramaunarama
1717 #0 naramabananarama
1718 #0 bananabananarama
1719 # #4
1720 cksum_test behave:vexpr-regex "${MBOX}" '3419299180 199'
1724 __behave_smime() { # FIXME add test/ dir, unroll tests therein
1725 TRAP_EXIT_ADDONS="./.t.conf ./.tkey.pem ./.tcert.pem ./.tpair.pem"
1726 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.VERIFY ./.DECRYPT ./.ENCRYPT"
1727 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.tsendmail.sh"
1729 printf 'behave:s/mime: .. generating test key and certificate ..\n'
1730 ${cat} <<-_EOT > ./.t.conf
1731 [ req ]
1732 default_bits = 1024
1733 default_keyfile = keyfile.pem
1734 distinguished_name = req_distinguished_name
1735 attributes = req_attributes
1736 prompt = no
1737 output_password =
1739 [ req_distinguished_name ]
1740 C = GB
1741 ST = Over the
1742 L = rainbow
1743 O = S-nail
1744 OU = S-nail.smime
1745 CN = S-nail.test
1746 emailAddress = test@localhost
1748 [ req_attributes ]
1749 challengePassword =
1750 _EOT
1751 openssl req -x509 -nodes -days 3650 -config ./.t.conf \
1752 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >/dev/null 2>&1
1753 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
1755 printf "behave:s/mime:sign/verify: "
1756 echo bla | "${SNAIL}" ${ARGS} \
1757 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
1758 -Ssmime-sign -Sfrom=test@localhost \
1759 -s 'S/MIME test' ./.VERIFY
1760 printf 'verify\nx\n' |
1761 "${SNAIL}" ${ARGS} \
1762 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
1763 -Ssmime-sign -Sfrom=test@localhost \
1764 -Sbatch-exit-on-error -R \
1765 -f ./.VERIFY >/dev/null 2>&1
1766 if [ $? -eq 0 ]; then
1767 printf 'ok\n'
1768 else
1769 printf 'error: verification failed\n'
1770 ESTAT=1
1771 ${rm} -f ${TRAP_EXIT_ADDONS}
1772 TRAP_EXIT_ADDONS=
1773 return
1775 printf ' .. disproof via openssl smime(1): '
1776 if openssl smime -verify -CAfile ./.tcert.pem \
1777 -in ./.VERIFY >/dev/null 2>&1; then
1778 printf 'ok\n'
1779 else
1780 printf 'failed\n'
1781 ESTAT=1
1782 ${rm} -f ${TRAP_EXIT_ADDONS}
1783 TRAP_EXIT_ADDONS=
1784 return
1787 # (signing +) encryption / decryption
1788 ${cat} <<-_EOT > ./.tsendmail.sh
1789 #!/bin/sh -
1790 ${rm} -f ./.ENCRYPT
1791 (echo 'From S-Postman Thu May 10 20:40:54 2012' && ${cat}) > ./.ENCRYPT
1792 _EOT
1793 chmod 0755 ./.tsendmail.sh
1795 printf "behave:s/mime:encrypt+sign/decrypt+verify: "
1796 echo bla |
1797 "${SNAIL}" ${ARGS} \
1798 -Ssmime-force-encryption \
1799 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
1800 -Smta=./.tsendmail.sh \
1801 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
1802 -Ssmime-sign -Sfrom=test@localhost \
1803 -s 'S/MIME test' recei@ver.com
1804 # TODO CHECK
1805 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
1806 "${SNAIL}" ${ARGS} \
1807 -Ssmime-force-encryption \
1808 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
1809 -Smta=./.tsendmail.sh \
1810 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
1811 -Ssmime-sign -Sfrom=test@localhost \
1812 -Sbatch-exit-on-error -R \
1813 -f ./.ENCRYPT >/dev/null 2>&1
1814 if [ $? -eq 0 ]; then
1815 printf 'ok\n'
1816 else
1817 ESTAT=1
1818 printf 'error: decryption+verification failed\n'
1820 printf ' ..disproof via openssl smime(1): '
1821 if (openssl smime -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT |
1822 openssl smime -verify -CAfile ./.tcert.pem) >/dev/null 2>&1; then
1823 printf 'ok\n'
1824 else
1825 printf 'failed\n'
1826 ESTAT=1
1828 ${sed} -e '/^Date:/d' -e '/^X-Decoding-Date/d' \
1829 -e \
1830 '/^Content-Disposition: attachment; filename="smime.p7s"/,/^-- /d' \
1831 < ./.DECRYPT > ./.ENCRYPT
1832 cksum_test ".. checksum of decrypted content" "./.ENCRYPT" '3090916509 510'
1834 printf "behave:s/mime:encrypt/decrypt: "
1835 ${rm} -f ./.DECRYPT
1836 echo bla | "${SNAIL}" ${ARGS} \
1837 -Ssmime-force-encryption \
1838 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
1839 -Smta=./.tsendmail.sh \
1840 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
1841 -Sfrom=test@localhost \
1842 -s 'S/MIME test' recei@ver.com
1843 printf 'decrypt ./.DECRYPT\nx\n' | "${SNAIL}" ${ARGS} \
1844 -Ssmime-force-encryption \
1845 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
1846 -Smta=./.tsendmail.sh \
1847 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
1848 -Sfrom=test@localhost \
1849 -Sbatch-exit-on-error -R \
1850 -f ./.ENCRYPT >/dev/null 2>&1
1851 if [ $? -eq 0 ]; then
1852 printf 'ok\n'
1853 else
1854 ESTAT=1
1855 printf 'error: decryption failed\n'
1857 printf '.. disproof via openssl smime(1): '
1858 if openssl smime -decrypt -inkey ./.tkey.pem \
1859 -in ./.ENCRYPT >/dev/null 2>&1; then
1860 printf 'ok\n'
1861 else
1862 printf 'failed\n'
1863 ESTAT=1
1865 ${sed} -e '/^Date:/d' -e '/^X-Decoding-Date/d' \
1866 < ./.DECRYPT > ./.ENCRYPT
1867 cksum_test ".. checksum of decrypted content" ./.ENCRYPT '999887248 295'
1869 ${rm} -f ${TRAP_EXIT_ADDONS}
1870 TRAP_EXIT_ADDONS=
1873 # t_content()
1874 # Some basic tests regarding correct sending of mails, via STDIN / -t / -q,
1875 # including basic MIME Content-Transfer-Encoding correctness (quoted-printable)
1876 # Note we unfortunately need to place some statements without proper
1877 # indentation because of continuation problems
1878 t_content() {
1879 # MIME encoding (QP) stress message body
1880 printf \
1881 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
1882 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
1883 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
1884 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
1885 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
1886 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
1887 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
1888 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
1889 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
1890 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
1891 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
1892 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
1893 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
1894 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
1895 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
1896 "auf den zeilen vorher.\r\n"\
1897 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
1898 ".\r\n"\
1899 "Die letzte Zeile war nur ein Punkt.\r\n"\
1900 "..\r\n"\
1901 "Das waren deren zwei.\r\n"\
1902 " \r\n"\
1903 "Die letzte Zeile war ein Leerschritt.\n"\
1904 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
1905 "Prösterchen.\r\n"\
1906 ".\n"\
1907 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
1908 "..\n"\
1909 "Das waren deren zwei. ditto.\n"\
1910 "Prösterchen.\n"\
1911 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
1912 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
1913 "auf den zeilen vorher.\n"\
1914 "ditto.\n"\
1915 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
1916 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
1917 "\n"\
1918 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
1919 "\n"\
1920 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
1921 "3\n"\
1922 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
1923 "34\n"\
1924 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
1925 "345\n"\
1926 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
1927 "3456\n"\
1928 "QP am Zeilenende über soft-nl hinweg\n"\
1929 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
1930 "ö123\n"\
1931 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
1932 "1ö23\n"\
1933 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
1934 "12ö3\n"\
1935 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
1936 "123ö\n"\
1937 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
1938 " \n"\
1939 "Die letzte Zeile war ein Leerschritt.\n"\
1940 ' '\
1941 > "${BODY}"
1943 # MIME encoding (QP) stress message subject
1944 SUB="Äbrä Kä?dä=brö Fü?di=bus? \
1945 adadaddsssssssddddddddddddddddddddd\
1946 ddddddddddddddddddddddddddddddddddd\
1947 ddddddddddddddddddddddddddddddddddd\
1948 dddddddddddddddddddd Hallelulja? Od\
1949 er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
1950 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
1951 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f\
1952 fffffffffffffffffffffffffffffffffff\
1953 fffffffffffffffffffff ggggggggggggg\
1954 ggggggggggggggggggggggggggggggggggg\
1955 ggggggggggggggggggggggggggggggggggg\
1956 ggggggggggggggggggggggggggggggggggg\
1957 gggggggggggggggg"
1959 # Three tests for MIME encodign and (a bit) content classification.
1960 # At the same time testing -q FILE, < FILE and -t FILE
1962 ${rm} -f "${MBOX}"
1963 < "${BODY}" "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
1964 -a "${BODY}" -s "${SUB}" "${MBOX}"
1965 cksum_test content:001 "${MBOX}" '2356108758 6413'
1967 ${rm} -f "${MBOX}"
1968 < /dev/null "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
1969 -a "${BODY}" -s "${SUB}" -q "${BODY}" "${MBOX}"
1970 cksum_test content:002 "${MBOX}" '2356108758 6413'
1972 ${rm} -f "${MBOX}"
1973 ( echo "To: ${MBOX}" && echo "Subject: ${SUB}" && echo &&
1974 ${cat} "${BODY}"
1975 ) | "${SNAIL}" ${ARGS} ${ADDARG_UNI} -Snodot -a "${BODY}" -t
1976 cksum_test content:003 "${MBOX}" '2356108758 6413'
1978 # Test for [260e19d] (Juergen Daubert)
1979 ${rm} -f "${MBOX}"
1980 echo body | "${SNAIL}" ${ARGS} "${MBOX}"
1981 cksum_test content:004 "${MBOX}" '4004005686 49'
1983 # Sending of multiple mails in a single invocation
1984 ${rm} -f "${MBOX}"
1985 ( printf "m ${MBOX}\n~s subject1\nE-Mail Körper 1\n~.\n" &&
1986 printf "m ${MBOX}\n~s subject2\nEmail body 2\n~.\n" &&
1987 echo x
1988 ) | "${SNAIL}" ${ARGS} ${ADDARG_UNI}
1989 cksum_test content:005 "${MBOX}" '2157252578 260'
1991 ## $BODY CHANGED
1993 # "Test for" [d6f316a] (Gavin Troy)
1994 ${rm} -f "${MBOX}"
1995 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
1996 "${SNAIL}" ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="${cat}" > "${BODY}"
1997 ${sed} -e 1d < "${BODY}" > "${MBOX}"
1998 cksum_test content:006 "${MBOX}" '2273863401 83'
2000 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
2001 ${rm} -f "${MBOX}"
2002 ${awk} 'BEGIN{
2003 for(i = 0; i < 10000; ++i)
2004 printf "\xC3\xBC"
2005 #printf "\xF0\x90\x87\x90"
2006 }' | "${SNAIL}" ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
2007 cksum_test content:007 "${MBOX}" '1754234717 61767'
2009 ## Test some more corner cases for header bodies (as good as we can today) ##
2012 ${rm} -f "${MBOX}"
2013 echo | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2014 -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̲' \
2015 "${MBOX}"
2016 cksum_test content:008 "${MBOX}" '1563381297 326'
2018 # Single word (overlong line split -- bad standard! Requires injection of
2019 # artificial data!! Bad can be prevented by using RFC 2047 encoding)
2020 ${rm} -f "${MBOX}"
2021 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
2022 echo | "${SNAIL}" ${ARGS} -s "${i}" "${MBOX}"
2023 cksum_test content:009 "${MBOX}" '1996714851 1669'
2025 # Combination of encoded words, space and tabs of varying sort
2026 ${rm} -f "${MBOX}"
2027 echo | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2028 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
2029 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
2030 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
2031 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
2032 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
2033 "${MBOX}"
2034 cksum_test content:010 "${MBOX}" '2956039469 542'
2036 # Overlong multibyte sequence that must be forcefully split
2037 # todo This works even before v15.0, but only by accident
2038 ${rm} -f "${MBOX}"
2039 echo | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2040 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
2041 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
2042 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
2043 "${MBOX}"
2044 cksum_test content:011 "${MBOX}" '454973928 610'
2046 # Trailing WS
2047 ${rm} -f "${MBOX}"
2048 echo | "${SNAIL}" ${ARGS} \
2049 -s "1-1 B2 B3 B4 B5 B6 B\
2050 1-2 B2 B3 B4 B5 B6 B\
2051 1-3 B2 B3 B4 B5 B6 B\
2052 1-4 B2 B3 B4 B5 B6 B\
2053 1-5 B2 B3 B4 B5 B6 B\
2054 1-6 B2 B3 B4 B5 B6 " \
2055 "${MBOX}"
2056 cksum_test content:012 "${MBOX}" '1014122962 248'
2058 # Leading and trailing WS
2059 ${rm} -f "${MBOX}"
2060 echo | "${SNAIL}" ${ARGS} \
2061 -s " 2-1 B2 B3 B4 B5 B6 B\
2062 1-2 B2 B3 B4 B5 B6 B\
2063 1-3 B2 B3 B4 B5 B6 B\
2064 1-4 B2 B3 B4 B5 B6 " \
2065 "${MBOX}"
2066 cksum_test content:013 "${MBOX}" '3212167908 187'
2068 # Quick'n dirty RFC 2231 test; i had more when implementing it, but until we
2069 # have a (better) test framework materialize a quick shot
2070 ${rm} -f "${MBOX}"
2071 TRAP_EXIT_ADDONS=./.ttt
2073 mkdir ./.ttt || exit 1
2074 cd ./.ttt || exit 2
2075 : > "ma'ger.txt"
2076 : > "mä'ger.txt"
2077 : > 'diet\ is \curd.txt'
2078 : > 'diet "is" curd.txt'
2079 : > höde-tröge.txt
2080 : > 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
2081 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
2082 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
2083 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
2085 echo bla | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2086 -a "./.ttt/ma'ger.txt" -a "./.ttt/mä'ger.txt" \
2087 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
2088 -a ./.ttt/höde-tröge.txt \
2089 -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 \
2090 -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 \
2091 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
2092 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
2093 "${MBOX}"
2094 ${rm} -rf ./.ttt
2095 cksum_test content:14 "${MBOX}" '589846634 2491'
2096 # `resend' test
2097 printf "Resend ${BODY}\nx\n" | "${SNAIL}" ${ARGS} -f "${MBOX}"
2098 cksum_test content:14-2 "${MBOX}" '589846634 2491'
2101 t_all() {
2102 if have_feat devel; then
2103 ARGS="${ARGS} -Smemdebug"
2104 export ARGS
2106 t_behave
2107 t_content
2110 if [ -z "${CHECK_ONLY}" ]; then
2111 cc_all_configs
2112 else
2113 t_all
2116 [ ${ESTAT} -eq 0 ] && echo Ok || echo >&2 'Errors occurred'
2118 exit ${ESTAT}
2119 # s-sh-mode