FIX, uh!, ah!, command escape WS prefix + ignerr handling..
[s-mailx.git] / cc-test.sh
blobfa7ab8fedb485de4874358d41c5b99c9f42f3ca4
1 #!/bin/sh -
2 #@ Usage: ./cc-test.sh [--check-only] s-mailx-binary
3 #@ TODO _All_ the tests should happen in a temporary subdir.
4 # Public Domain
6 # We need *stealthmua* regardless of $SOURCE_DATE_EPOCH, the program name as
7 # such is a compile-time variable
8 ARGS='-:/ -# -Sdotlock-ignore-error -Sencoding=quoted-printable -Sstealthmua'
9 ARGS="${ARGS}"' -Snosave -Sexpandaddr=restrict'
10 ADDARG_UNI=-Sttycharset=UTF-8
11 CONF=./make.rc
12 BODY=./.cc-body.txt
13 MBOX=./.cc-test.mbox
14 MAIL=/dev/null
15 #UTF8_LOCALE= autodetected unless set
17 MEMTESTER=
18 #MEMTESTER='valgrind --leak-check=full --log-file=.vl-%p '
20 if ( command -v command ) >/dev/null 2>&1; then :; else
21 command() {
22 shift
23 which "${@}"
27 MAKE="${MAKE:-`command -v make`}"
28 awk=${awk:-`command -v awk`}
29 cat=${cat:-`command -v cat`}
30 cksum=${cksum:-`command -v cksum`}
31 rm=${rm:-`command -v rm`}
32 sed=${sed:-`command -v sed`}
33 grep=${grep:-`command -v grep`}
35 # Problem: force $SHELL to be a real shell. It seems some testing environments
36 # use nologin(?), but we need a real shell for command execution
37 if { echo ${SHELL} | ${grep} nologin; } >/dev/null 2>&1; then
38 echo >&2 '$SHELL seems to be nologin, overwriting to /bin/sh!'
39 SHELL=/bin/sh
40 export SHELL
43 # We sometimes "fake" sendmail(1) a.k.a. *mta* with a shell wrapper, and it
44 # happens that /bin/sh is often terribly slow
45 if command -v dash >/dev/null 2>&1; then
46 MYSHELL="`command -v dash`"
47 elif command -v mksh >/dev/null 2>&1; then
48 MYSHELL="`command -v mksh`"
49 else
50 MYSHELL="${SHELL}"
53 ## -- >8 -- 8< -- ##
55 export ARGS ADDARG_UNI CONF BODY MBOX MAIL MAKE awk cat cksum rm sed grep
57 LC_ALL=C LANG=C
58 TZ=UTC
59 # Wed Oct 2 01:50:07 UTC 1996
60 SOURCE_DATE_EPOCH=844221007
62 export LC_ALL LANG TZ SOURCE_DATE_EPOCH
63 unset POSIXLY_CORRECT
65 if [ -z "${UTF8_LOCALE}" ]; then
66 UTF8_LOCALE=
67 if command -v locale >/dev/null 2>&1; then
68 UTF8_LOCALE=`locale -a | { m=
69 while read n; do
70 if { echo ${n} | ${grep} -i 'utf-\{0,1\}8'; } >/dev/null 2>&1; then
71 m=${n}
72 if { echo ${n} | ${grep} -e POSIX -e en_EN -e en_US; }; then
73 exit 0
76 m=${n}
77 done
78 echo ${m}
83 ESTAT=0
85 usage() {
86 echo >&2 "Usage: ./cc-test.sh [--check-only] s-mailx-binary"
87 exit 1
90 CHECK_ONLY= MAILX=
91 while [ $# -gt 0 ]; do
92 if [ "${1}" = --check-only ]; then
93 CHECK_ONLY=1
94 else
95 MAILX=${1}
97 shift
98 done
99 [ -x "${MAILX}" ] || usage
100 RAWMAILX=${MAILX}
101 MAILX="${MEMTESTER}${MAILX}"
102 export RAWMAILX MAILX
104 TRAP_EXIT_ADDONS=
105 trap "${rm} -rf \"${BODY}\" \"${MBOX}\" \${TRAP_EXIT_ADDONS}" EXIT
106 trap "exit 1" HUP INT TERM
108 # cc_all_configs()
109 # Test all configs TODO doesn't cover all *combinations*, stupid!
110 cc_all_configs() {
111 < ${CONF} ${awk} '
112 BEGIN {
113 NOTME["OPT_AUTOCC"] = 1
114 NOTME["OPT_DEBUG"] = 1
115 NOTME["OPT_DEVEL"] = 1
116 NOTME["OPT_NOEXTMD5"] = 1
117 NOTME["OPT_NOMEMDBG"] = 1
118 NOTME["OPT_NYD2"] = 1
119 i = 0
121 /^[[:space:]]*OPT_/ {
122 sub(/^[[:space:]]*/, "")
123 # This bails for UnixWare 7.1.4 awk(1), but preceeding = with \
124 # does not seem to be a compliant escape for =
125 #sub(/=.*$/, "")
126 $1 = substr($1, 1, index($1, "=") - 1)
127 if (NOTME[$1])
128 next
129 data[i++] = $1
131 END {
132 # Doing this completely sequentially and not doing make distclean in
133 # between runs should effectively result in lesser compilations.
134 # It is completely dumb nonetheless... TODO
135 for (j = 1; j < i; ++j) {
136 for (k = 1; k < j; ++k)
137 printf data[k] "=1 "
138 for (k = j; k < i; ++k)
139 printf data[k] "=0 "
140 printf "OPT_AUTOCC=1\n"
142 for (j = 1; j < i; ++j) {
143 for (k = 1; k < j; ++k)
144 printf data[k] "=0 "
145 for (k = j; k < i; ++k)
146 printf data[k] "=1 "
147 printf "OPT_AUTOCC=1\n"
149 # With debug
150 for (j = 1; j < i; ++j) {
151 for (k = 1; k < j; ++k)
152 printf data[k] "=1 "
153 for (k = j; k < i; ++k)
154 printf data[k] "=0 "
155 printf "OPT_AUTOCC=1\n"
156 printf "OPT_DEBUG=1\n"
158 for (j = 1; j < i; ++j) {
159 for (k = 1; k < j; ++k)
160 printf data[k] "=0 "
161 for (k = j; k < i; ++k)
162 printf data[k] "=1 "
163 printf "OPT_AUTOCC=1\n"
164 printf "OPT_DEBUG=1\n"
167 printf "CONFIG=NULL OPT_AUTOCC=0\n"
168 printf "CONFIG=NULL OPT_AUTOCC=1\n"
169 printf "CONFIG=NULLI OPT_AUTOCC=0\n"
170 printf "CONFIG=NULLI OPT_AUTOCC=1\n"
171 printf "CONFIG=MINIMAL OPT_AUTOCC=0\n"
172 printf "CONFIG=MINIMAL OPT_AUTOCC=1\n"
173 printf "CONFIG=MEDIUM OPT_AUTOCC=0\n"
174 printf "CONFIG=MEDIUM OPT_AUTOCC=1\n"
175 printf "CONFIG=NETSEND OPT_AUTOCC=0\n"
176 printf "CONFIG=NETSEND OPT_AUTOCC=1\n"
177 printf "CONFIG=MAXIMAL OPT_AUTOCC=0\n"
178 printf "CONFIG=MAXIMAL OPT_AUTOCC=1\n"
179 printf "CONFIG=DEVEL OPT_AUTOCC=0\n"
180 printf "CONFIG=DEVEL OPT_AUTOCC=1\n"
181 printf "CONFIG=ODEVEL OPT_AUTOCC=0\n"
182 printf "CONFIG=ODEVEL OPT_AUTOCC=1\n"
184 ' | while read c; do
185 printf "\n\n##########\n$c\n"
186 printf "\n\n##########\n$c\n" >&2
187 sh -c "${MAKE} ${c}"
188 t_all
189 done
190 ${MAKE} distclean
193 have_feat() {
194 ( "${RAWMAILX}" ${ARGS} -X'echo $features' -Xx |
195 ${grep} +${1} ) >/dev/null 2>&1
198 t_prolog() {
199 ${rm} -rf "${BODY}" "${MBOX}" ${TRAP_EXIT_ADDONS}
200 TRAP_EXIT_ADDONS=
202 t_epilog() {
203 t_prolog
206 check() {
207 restat=${?} tid=${1} eestat=${2} f=${3} s=${4}
208 #x=`echo ${tid} | tr "/:=" "__-"`
209 #cp -f "${f}" "${TMPDIR}/${x}"
210 [ "${eestat}" != - ] && [ "${restat}" != "${eestat}" ] &&
211 err "${tid}" 'unexpected exit status: '"${restat} != ${eestat}"
212 csum="`${cksum} < ${f}`"
213 if [ "${csum}" = "${s}" ]; then
214 printf '%s: ok\n' "${tid}"
215 else
216 ESTAT=1
217 printf '%s: error: checksum mismatch (got %s)\n' "${tid}" "${csum}"
221 err() {
222 ESTAT=1
223 printf '%s: error: %s\n' ${1} "${2}"
226 ex0_test() {
227 [ $? -ne 0 ] && err $1 'unexpected non-0 exit status'
230 exn0_test() {
231 [ $? -eq 0 ] && err $1 'unexpected 0 exit status'
234 if ( [ "$((1 + 1))" = 2 ] ) >/dev/null 2>&1; then
235 add() {
236 echo "$((${1} + ${2}))"
238 elif command -v expr >/dev/null 2>&1; then
239 add() {
240 echo `expr ${1} + ${2}`
242 else
243 add() {
244 echo `${awk} 'BEGIN{print '${1}' + '${2}'}'`
248 if ( [ "$((2 % 3))" = 2 ] ) >/dev/null 2>&1; then
249 modulo() {
250 echo "$((${1} % ${2}))"
252 elif command -v expr >/dev/null 2>&1; then
253 modulo() {
254 echo `expr ${1} % ${2}`
256 else
257 modulo() {
258 echo `${awk} 'BEGIN{print '${1}' % '${2}'}'`
262 # t_behave()
263 # Basic (easily testable) behaviour tests
264 t_behave() {
265 t_behave_X_opt_input_command_stack
266 t_behave_X_errexit
267 t_behave_wysh
268 t_behave_input_inject_semicolon_seq
269 t_behave_commandalias
270 t_behave_ifelse
271 t_behave_localopts
272 t_behave_macro_param_shift
273 t_behave_addrcodec
274 t_behave_vexpr
275 t_behave_call_ret
276 t_behave_xcall
277 t_behave_vpospar
279 t_behave_mbox
281 t_behave_alias
282 # FIXME t_behave_mlist
283 t_behave_filetype
285 t_behave_record_a_resend
287 t_behave_e_H_L_opts
288 t_behave_compose_hooks
289 t_behave_mime_types_load_control
291 t_behave_smime
293 t_behave_maildir
296 t_behave_X_opt_input_command_stack() {
297 t_prolog
299 ${cat} <<- '__EOT' > "${BODY}"
300 echo 1
301 define mac0 {
302 echo mac0-1 via1 $0
304 call mac0
305 echo 2
306 source '\
307 echo "define mac1 {";\
308 echo " echo mac1-1 via1 \$0";\
309 echo " call mac0";\
310 echo " echo mac1-2";\
311 echo " call mac2";\
312 echo " echo mac1-3";\
313 echo "}";\
314 echo "echo 1-1";\
315 echo "define mac2 {";\
316 echo " echo mac2-1 via1 \$0";\
317 echo " call mac0";\
318 echo " echo mac2-2";\
319 echo "}";\
320 echo "echo 1-2";\
321 echo "call mac1";\
322 echo "echo 1-3";\
323 echo "source \"\
324 echo echo 1-1-1 via1 \$0;\
325 echo call mac0;\
326 echo echo 1-1-2;\
327 | \"";\
328 echo "echo 1-4";\
330 echo 3
331 call mac2
332 echo 4
333 undefine *
334 __EOT
336 # The -X option supports multiline arguments, and those can internally use
337 # reverse solidus newline escaping. And all -X options are joined...
338 APO=\'
339 < "${BODY}" ${MAILX} ${ARGS} \
340 -X 'e\' \
341 -X ' c\' \
342 -X ' h\' \
343 -X ' o \' \
344 -X 1 \
346 define mac0 {
347 echo mac0-1 via2 $0
349 call mac0
350 echo 2
353 source '${APO}'\
354 echo "define mac1 {";\
355 echo " echo mac1-1 via2 \$0";\
356 echo " call mac0";\
357 echo " echo mac1-2";\
358 echo " call mac2";\
359 echo " echo mac1-3";\
360 echo "}";\
361 echo "echo 1-1";\
362 echo "define mac2 {";\
363 echo " echo mac2-1 via2 \$0";\
364 echo " call mac0";\
365 echo " echo mac2-2";\
366 echo "}";\
367 echo "echo 1-2";\
368 echo "call mac1";\
369 echo "echo 1-3";\
370 echo "source \"\
371 echo echo 1-1-1 via2 \$0;\
372 echo call mac0;\
373 echo echo 1-1-2;\
374 | \"";\
375 echo "echo 1-4";\
376 | '${APO}'
377 echo 3
380 call mac2
381 echo 4
382 undefine *
383 ' > "${MBOX}"
385 check behave:x_opt_input_command_stack 0 "${MBOX}" '1786542668 416'
387 t_epilog
390 t_behave_X_errexit() {
391 t_prolog
393 ${cat} <<- '__EOT' > "${BODY}"
394 echo one
395 echos nono
396 echo two
397 __EOT
399 </dev/null ${MAILX} ${ARGS} -Snomemdebug \
400 -X'echo one' -X' echos nono ' -X'echo two' \
401 > "${MBOX}" 2>&1
402 check behave:x_errexit-1 0 "${MBOX}" '916157812 53'
404 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Snomemdebug \
405 > "${MBOX}" 2>&1
406 check behave:x_errexit-2 0 "${MBOX}" '916157812 53'
408 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Snomemdebug \
409 > "${MBOX}" 2>&1
410 check behave:x_errexit-3 0 "${MBOX}" '916157812 53'
414 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
415 -X'echo one' -X' echos nono ' -X'echo two' \
416 > "${MBOX}" 2>&1
417 check behave:x_errexit-4 1 "${MBOX}" '2118430867 49'
419 </dev/null ${MAILX} ${ARGS} -X'source '"${BODY}" -Serrexit -Snomemdebug \
420 > "${MBOX}" 2>&1
421 check behave:x_errexit-5 1 "${MBOX}" '2118430867 49'
423 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
424 > "${MBOX}" 2>&1
425 check behave:x_errexit-6 1 "${MBOX}" '12955965 172'
427 </dev/null MAILRC="${BODY}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
428 > "${MBOX}" 2>&1
429 check behave:x_errexit-7 1 "${MBOX}" '12955965 172'
431 ## Repeat 4-7 with ignerr set
433 ${sed} -e 's/^echos /ignerr echos /' < "${BODY}" > "${MBOX}"
435 </dev/null ${MAILX} ${ARGS} -Serrexit -Snomemdebug \
436 -X'echo one' -X'ignerr echos nono ' -X'echo two' \
437 > "${BODY}" 2>&1
438 check behave:x_errexit-8 0 "${BODY}" '916157812 53'
440 </dev/null ${MAILX} ${ARGS} -X'source '"${MBOX}" -Serrexit -Snomemdebug \
441 > "${BODY}" 2>&1
442 check behave:x_errexit-9 0 "${BODY}" '916157812 53'
444 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Serrexit -Snomemdebug \
445 > "${BODY}" 2>&1
446 check behave:x_errexit-10 0 "${BODY}" '916157812 53'
448 </dev/null MAILRC="${MBOX}" ${MAILX} ${ARGS} -:u -Sposix -Snomemdebug \
449 > "${BODY}" 2>&1
450 check behave:x_errexit-11 0 "${BODY}" '916157812 53'
452 t_epilog
455 t_behave_wysh() {
456 t_prolog
458 ${cat} <<- '__EOT' > "${BODY}"
460 echo abcd
461 echo a'b'c'd'
462 echo a"b"c"d"
463 echo a$'b'c$'d'
464 echo 'abcd'
465 echo "abcd"
466 echo $'abcd'
467 echo a\ b\ c\ d
468 echo a 'b c' d
469 echo a "b c" d
470 echo a $'b c' d
472 echo 'a$`"\'
473 echo "a\$\`'\"\\"
474 echo $'a\$`\'\"\\'
475 echo $'a\$`\'"\\'
476 # DIET=CURD TIED=
477 echo 'a${DIET}b${TIED}c\${DIET}d\${TIED}e' # COMMENT
478 echo "a${DIET}b${TIED}c\${DIET}d\${TIED}e"
479 echo $'a${DIET}b${TIED}c\${DIET}d\${TIED}e'
481 echo a$'\101\0101\x41\u0041\u41\U00000041\U41'c
482 echo a$'\u0041\u41\u0C1\U00000041\U41'c
483 echo a$'\377'c
484 echo a$'\0377'c
485 echo a$'\400'c
486 echo a$'\0400'c
487 echo a$'\U1100001'c
489 echo a$'b\0c'd
490 echo a$'b\00c'de
491 echo a$'b\000c'df
492 echo a$'b\0000c'dg
493 echo a$'b\x0c'dh
494 echo a$'b\x00c'di
495 echo a$'b\u0'dj
496 echo a$'b\u00'dk
497 echo a$'b\u000'dl
498 echo a$'b\u0000'dm
499 echo a$'b\U0'dn
500 echo a$'b\U00'do
501 echo a$'b\U000'dp
502 echo a$'b\U0000'dq
503 echo a$'b\U00000'dr
504 echo a$'b\U000000'ds
505 echo a$'b\U0000000'dt
506 echo a$'b\U00000000'du
508 echo a$'\cI'b
509 echo a$'\011'b
510 echo a$'\x9'b
511 echo a$'\u9'b
512 echo a$'\U9'b
513 echo a$'\c@'b c d
514 __EOT
516 if [ -z "${UTF8_LOCALE}" ]; then
517 echo 'Skip behave:wysh_unicode, no UTF8_LOCALE'
518 else
519 < "${BODY}" DIET=CURD TIED= \
520 LC_ALL=${UTF8_LOCALE} ${MAILX} ${ARGS} 2>/dev/null > "${MBOX}"
521 check behave:wysh_unicode 0 "${MBOX}" '475805847 317'
524 < "${BODY}" DIET=CURD TIED= ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
525 check behave:wysh_c 0 "${MBOX}" '1473887148 321'
527 t_epilog
530 t_behave_input_inject_semicolon_seq() {
531 t_prolog
533 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
534 define mydeepmac {
535 echon '(mydeepmac)';
537 define mymac {
538 echon this_is_mymac;call mydeepmac;echon ';';
540 echon one';';call mymac;echon two";";call mymac;echo three$';';
541 define mymac {
542 echon this_is_mymac;call mydeepmac;echon ,TOO'!;';
544 echon one';';call mymac;echon two";";call mymac;echo three$';';
545 __EOT
547 check behave:input_inject_semicolon_seq 0 "${MBOX}" '512117110 140'
549 t_epilog
552 t_behave_commandalias() {
553 t_prolog
555 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
556 commandalias echo echo hoho
557 echo stop.
558 commandalias X Xx
559 commandalias Xx XxX
560 commandalias XxX XxXx
561 commandalias XxXx XxXxX
562 commandalias XxXxX XxXxXx
563 commandalias XxXxXx echo huhu
564 commandalias XxXxXxX echo huhu
566 commandalias XxXxXx XxXxXxX
568 uncommandalias echo
569 commandalias XxXxXx echo huhu
571 __EOT
573 check behave:commandalias 0 "${MBOX}" '3694143612 31'
575 t_epilog
578 t_behave_ifelse() {
579 t_prolog
581 # Nestable conditions test
582 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
583 if 0
584 echo 1.err
585 else
586 echo 1.ok
587 endif
588 if 1
589 echo 2.ok
590 else
591 echo 2.err
592 endif
593 if $dietcurd
594 echo 3.err
595 else
596 echo 3.ok
597 endif
598 set dietcurd=yoho
599 if $dietcurd
600 echo 4.ok
601 else
602 echo 4.err
603 endif
604 if $dietcurd == 'yoho'
605 echo 5.ok
606 else
607 echo 5.err
608 endif
609 if $dietcurd @== 'Yoho'
610 echo 5-1.ok
611 else
612 echo 5-1.err
613 endif
614 if $dietcurd == 'Yoho'
615 echo 5-2.err
616 else
617 echo 5-2.ok
618 endif
619 if $dietcurd != 'yoho'
620 echo 6.err
621 else
622 echo 6.ok
623 endif
624 if $dietcurd @!= 'Yoho'
625 echo 6-1.err
626 else
627 echo 6-1.ok
628 endif
629 if $dietcurd != 'Yoho'
630 echo 6-2.ok
631 else
632 echo 6-2.err
633 endif
634 # Nesting
635 if faLse
636 echo 7.err1
637 if tRue
638 echo 7.err2
639 if yEs
640 echo 7.err3
641 else
642 echo 7.err4
643 endif
644 echo 7.err5
645 endif
646 echo 7.err6
647 else
648 echo 7.ok7
649 if YeS
650 echo 7.ok8
651 if No
652 echo 7.err9
653 else
654 echo 7.ok9
655 endif
656 echo 7.ok10
657 else
658 echo 7.err11
659 if yeS
660 echo 7.err12
661 else
662 echo 7.err13
663 endif
664 endif
665 echo 7.ok14
666 endif
667 if r
668 echo 8.ok1
669 if R
670 echo 8.ok2
671 else
672 echo 8.err2
673 endif
674 echo 8.ok3
675 else
676 echo 8.err1
677 endif
678 if s
679 echo 9.err1
680 else
681 echo 9.ok1
682 if S
683 echo 9.err2
684 else
685 echo 9.ok2
686 endif
687 echo 9.ok3
688 endif
689 # `elif'
690 if $dietcurd == 'yohu'
691 echo 10.err1
692 elif $dietcurd == 'yoha'
693 echo 10.err2
694 elif $dietcurd == 'yohe'
695 echo 10.err3
696 elif $dietcurd == 'yoho'
697 echo 10.ok1
698 if $dietcurd == 'yohu'
699 echo 10.err4
700 elif $dietcurd == 'yoha'
701 echo 10.err5
702 elif $dietcurd == 'yohe'
703 echo 10.err6
704 elif $dietcurd == 'yoho'
705 echo 10.ok2
706 if $dietcurd == 'yohu'
707 echo 10.err7
708 elif $dietcurd == 'yoha'
709 echo 10.err8
710 elif $dietcurd == 'yohe'
711 echo 10.err9
712 elif $dietcurd == 'yoho'
713 echo 10.ok3
714 else
715 echo 10.err10
716 endif
717 else
718 echo 10.err11
719 endif
720 else
721 echo 10.err12
722 endif
723 # integer
724 set dietcurd=10
725 if $dietcurd -lt 11
726 echo 11.ok1
727 if $dietcurd -gt 9
728 echo 11.ok2
729 else
730 echo 11.err2
731 endif
732 if $dietcurd -eq 10
733 echo 11.ok3
734 else
735 echo 11.err3
736 endif
737 if $dietcurd -ge 10
738 echo 11.ok4
739 else
740 echo 11.err4
741 endif
742 if $dietcurd -le 10
743 echo 11.ok5
744 else
745 echo 11.err5
746 endif
747 if $dietcurd -ge 11
748 echo 11.err6
749 else
750 echo 11.ok6
751 endif
752 if $dietcurd -le 9
753 echo 11.err7
754 else
755 echo 11.ok7
756 endif
757 else
758 echo 11.err1
759 endif
760 set dietcurd=Abc
761 if $dietcurd < aBd
762 echo 12.ok1
763 if $dietcurd @> abB
764 echo 12.ok2
765 else
766 echo 12.err2
767 endif
768 if $dietcurd @== aBC
769 echo 12.ok3
770 else
771 echo 12.err3
772 endif
773 if $dietcurd @>= AbC
774 echo 12.ok4
775 else
776 echo 12.err4
777 endif
778 if $dietcurd @<= ABc
779 echo 12.ok5
780 else
781 echo 12.err5
782 endif
783 if $dietcurd @>= abd
784 echo 12.err6
785 else
786 echo 12.ok6
787 endif
788 if $dietcurd @<= abb
789 echo 12.err7
790 else
791 echo 12.ok7
792 endif
793 else
794 echo 12.err1
795 endif
796 if $dietcurd < aBc
797 echo 12-1.ok
798 else
799 echo 12-1.err
800 endif
801 if $dietcurd @< aBc
802 echo 12-2.err
803 else
804 echo 12-2.ok
805 endif
806 if $dietcurd > ABc
807 echo 12-3.ok
808 else
809 echo 12-3.err
810 endif
811 if $dietcurd @> ABc
812 echo 12-3.err
813 else
814 echo 12-3.ok
815 endif
816 if $dietcurd @i=% aB
817 echo 13.ok
818 else
819 echo 13.err
820 endif
821 if $dietcurd =% aB
822 echo 13-1.err
823 else
824 echo 13-1.ok
825 endif
826 if $dietcurd @=% bC
827 echo 14.ok
828 else
829 echo 14.err
830 endif
831 if $dietcurd !% aB
832 echo 15-1.ok
833 else
834 echo 15-1.err
835 endif
836 if $dietcurd @!% aB
837 echo 15-2.err
838 else
839 echo 15-2.ok
840 endif
841 if $dietcurd !% bC
842 echo 15-3.ok
843 else
844 echo 15-3.err
845 endif
846 if $dietcurd @!% bC
847 echo 15-4.err
848 else
849 echo 15-4.ok
850 endif
851 if $dietcurd =% Cd
852 echo 16.err
853 else
854 echo 16.ok
855 endif
856 if $dietcurd !% Cd
857 echo 17.ok
858 else
859 echo 17.err
860 endif
861 set diet=abc curd=abc
862 if $diet == $curd
863 echo 18.ok
864 else
865 echo 18.err
866 endif
867 set diet=abc curd=abcd
868 if $diet != $curd
869 echo 19.ok
870 else
871 echo 19.err
872 endif
873 # 1. Shitty grouping capabilities as of today
874 unset diet curd ndefined
875 if [ [ false ] || [ false ] || [ true ] ] && [ [ false ] || [ true ] ] && \
876 [ yes ]
877 echo 20.ok
878 else
879 echo 20.err
880 endif
881 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
882 echo 21.ok
883 else
884 echo 21.err
885 endif
886 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
887 echo 22.ok
888 else
889 echo 22.err
890 endif
891 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
892 echo 23.ok
893 else
894 echo 23.err
895 endif
896 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
897 echo 24.err
898 else
899 echo 24.ok
900 endif
901 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
902 && [ no ] || [ yes ]
903 echo 25.ok
904 else
905 echo 25.err
906 endif
907 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
908 echo 26.ok
909 else
910 echo 26.err
911 endif
912 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
913 echo 27.err
914 else
915 echo 27.ok
916 endif
917 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
918 echo 28.err
919 else
920 echo 28.ok
921 endif
922 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
923 echo 29.err
924 else
925 echo 29.ok
926 endif
927 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
928 echo 30.err
929 else
930 echo 30.ok
931 endif
932 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
933 echo 31.ok
934 else
935 echo 31.err
936 endif
937 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
938 echo 32.err
939 else
940 echo 32.ok
941 endif
942 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
943 echo 33.ok
944 else
945 echo 33.err
946 endif
947 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
948 echo 34.err
949 else
950 echo 34.ok
951 endif
952 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
953 echo 35.ok
954 else
955 echo 35.err
956 endif
957 set diet=yo curd=ho
958 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
959 echo 36.err
960 else
961 echo 36.ok
962 endif
963 set ndefined
964 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
965 echo 37.ok
966 else
967 echo 37.err
968 endif
969 # 2. Shitty grouping capabilities as of today
970 unset diet curd ndefined
971 if [ false || false || true ] && [ false || true ] && yes
972 echo 40.ok
973 else
974 echo 40.err
975 endif
976 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
977 echo 41.ok
978 else
979 echo 41.err
980 endif
981 if [ 1 || 0 || 0 || 0 ]
982 echo 42.ok
983 else
984 echo 42.err
985 endif
986 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
987 echo 43.ok
988 else
989 echo 43.err
990 endif
991 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
992 echo 44.err
993 else
994 echo 44.ok
995 endif
996 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
997 echo 45.ok
998 else
999 echo 45.err
1000 endif
1001 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
1002 echo 46.ok
1003 else
1004 echo 46.err
1005 endif
1006 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
1007 echo 47.err
1008 else
1009 echo 47.ok
1010 endif
1011 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
1012 echo 48.err
1013 else
1014 echo 48.ok
1015 endif
1016 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
1017 echo 49.err
1018 else
1019 echo 49.ok
1020 endif
1021 if 1 || 0 || 0 || 0 && 0
1022 echo 50.err
1023 else
1024 echo 50.ok
1025 endif
1026 if 1 || 0 || 0 || 0 && 1
1027 echo 51.ok
1028 else
1029 echo 51.err
1030 endif
1031 if 0 || 0 || 0 || 1 && 0
1032 echo 52.err
1033 else
1034 echo 52.ok
1035 endif
1036 if 0 || 0 || 0 || 1 && 1
1037 echo 53.ok
1038 else
1039 echo 53.err
1040 endif
1041 if 0 || 0 || 0 || 1 && 0 || 1 && 0
1042 echo 54.err
1043 else
1044 echo 54.ok
1045 endif
1046 if 0 || 0 || 0 || 1 && 0 || 1 && 1
1047 echo 55.ok
1048 else
1049 echo 55.err
1050 endif
1051 set diet=yo curd=ho
1052 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1053 echo 56.err
1054 else
1055 echo 56.ok
1056 endif
1057 if $diet == 'yo' && $curd == 'ho' && $ndefined
1058 echo 57.err
1059 else
1060 echo 57.ok
1061 endif
1062 set ndefined
1063 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1064 echo 57.ok
1065 else
1066 echo 57.err
1067 endif
1068 if $diet == 'yo' && $curd == 'ho' && $ndefined
1069 echo 58.ok
1070 else
1071 echo 58.err
1072 endif
1073 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
1074 echo 59.ok
1075 else
1076 echo 59.err
1077 endif
1078 # Some more en-braced variables
1079 set diet=yo curd=ho
1080 if ${diet} == ${curd}
1081 echo 70.err
1082 else
1083 echo 70.ok
1084 endif
1085 if ${diet} != ${curd}
1086 echo 71.ok
1087 else
1088 echo 71.err
1089 endif
1090 if $diet == ${curd}
1091 echo 72.err
1092 else
1093 echo 72.ok
1094 endif
1095 if ${diet} == $curd
1096 echo 73.err
1097 else
1098 echo 73.ok
1099 endif
1100 # Unary !
1101 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
1102 echo 80.ok
1103 else
1104 echo 80.err
1105 endif
1106 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
1107 echo 81.ok
1108 else
1109 echo 81.err
1110 endif
1111 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1112 echo 82.ok
1113 else
1114 echo 82.err
1115 endif
1116 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1117 echo 83.err
1118 else
1119 echo 83.ok
1120 endif
1121 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1122 echo 84.err
1123 else
1124 echo 84.ok
1125 endif
1126 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1127 echo 85.err
1128 else
1129 echo 85.ok
1130 endif
1131 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1132 echo 86.err
1133 else
1134 echo 86.ok
1135 endif
1136 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
1137 echo 87.ok
1138 else
1139 echo 87.err
1140 endif
1141 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
1142 echo 88.ok
1143 else
1144 echo 88.err
1145 endif
1146 # Unary !, odd
1147 if ! 0 && ! ! 1 && ! ! ! 0 && 3
1148 echo 90.ok
1149 else
1150 echo 90.err
1151 endif
1152 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
1153 echo 91.ok
1154 else
1155 echo 91.err
1156 endif
1157 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
1158 echo 92.ok
1159 else
1160 echo 92.err
1161 endif
1162 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
1163 echo 93.err
1164 else
1165 echo 93.ok
1166 endif
1167 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
1168 echo 94.ok
1169 else
1170 echo 94.err
1171 endif
1172 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
1173 echo 95.err
1174 else
1175 echo 95.ok
1176 endif
1177 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
1178 echo 96.err
1179 else
1180 echo 96.ok
1181 endif
1182 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
1183 echo 97.ok
1184 else
1185 echo 97.err
1186 endif
1187 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
1188 echo 98.ok
1189 else
1190 echo 98.err
1191 endif
1192 __EOT
1194 check behave:if-normal 0 "${MBOX}" '1688759742 719'
1196 if have_feat regex; then
1197 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1198 set dietcurd=yoho
1199 if $dietcurd =~ '^yo.*'
1200 echo 1.ok
1201 else
1202 echo 1.err
1203 endif
1204 if $dietcurd =~ '^Yo.*'
1205 echo 1-1.err
1206 else
1207 echo 1-1.ok
1208 endif
1209 if $dietcurd @=~ '^Yo.*'
1210 echo 1-2.ok
1211 else
1212 echo 1-2.err
1213 endif
1214 if $dietcurd =~ '^yOho.+'
1215 echo 2.err
1216 else
1217 echo 2.ok
1218 endif
1219 if $dietcurd @!~ '.*Ho$'
1220 echo 3.err
1221 else
1222 echo 3.ok
1223 endif
1224 if $dietcurd !~ '.+yohO$'
1225 echo 4.ok
1226 else
1227 echo 4.err
1228 endif
1229 if [ $dietcurd @i!~ '.+yoho$' ]
1230 echo 5.ok
1231 else
1232 echo 5.err
1233 endif
1234 if ! [ $dietcurd @i=~ '.+yoho$' ]
1235 echo 6.ok
1236 else
1237 echo 6.err
1238 endif
1239 if ! ! [ $dietcurd @i!~ '.+yoho$' ]
1240 echo 7.ok
1241 else
1242 echo 7.err
1243 endif
1244 if ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ]
1245 echo 8.ok
1246 else
1247 echo 8.err
1248 endif
1249 if [ ! [ ! [ $dietcurd @i!~ '.+yoho$' ] ] ]
1250 echo 9.ok
1251 else
1252 echo 9.err
1253 endif
1254 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1255 echo 10.err
1256 else
1257 echo 10.ok
1258 endif
1259 if ! ! ! $dietcurd !~ '.+yoho$'
1260 echo 11.err
1261 else
1262 echo 11.ok
1263 endif
1264 if ! ! ! $dietcurd =~ '.+yoho$'
1265 echo 12.ok
1266 else
1267 echo 12.err
1268 endif
1269 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1270 echo 13.ok
1271 else
1272 echo 13.err
1273 endif
1274 set diet=abc curd='^abc$'
1275 if $diet =~ $curd
1276 echo 14.ok
1277 else
1278 echo 14.err
1279 endif
1280 set diet=abc curd='^abcd$'
1281 if $diet !~ $curd
1282 echo 15.ok
1283 else
1284 echo 15.err
1285 endif
1286 __EOT
1288 check behave:if-regex 0 "${MBOX}" '1115671789 95'
1289 else
1290 printf 'behave:if-regex: unsupported, skipped\n'
1293 t_epilog
1296 t_behave_localopts() {
1297 t_prolog
1299 # Nestable conditions test
1300 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1301 define t2 {
1302 echo in: t2
1303 set t2=t2
1304 echo $t2
1306 define t1 {
1307 echo in: t1
1308 set gv1=gv1
1309 localopts on
1310 set lv1=lv1 lv2=lv2
1311 set lv3=lv3
1312 call t2
1313 localopts off
1314 set gv2=gv2
1315 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1317 define t0 {
1318 echo in: t0
1319 call t1
1320 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1321 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
1323 account trouble {
1324 echo in: trouble
1325 call t0
1327 call t0
1328 unset gv1 gv2
1329 account trouble
1330 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1331 account null
1332 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1333 __EOT
1335 check behave:localopts 0 "${MBOX}" '1936527193 192'
1337 t_epilog
1340 t_behave_macro_param_shift() {
1341 t_prolog
1343 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
1344 define t2 {
1345 echo in: t2
1346 echo t2.0 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1347 localopts on
1348 wysh set ignerr=$1
1349 shift
1350 localopts off
1351 echo t2.1 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1352 if [ $# > 1 ] || [ $ignerr == '' ]
1353 shift 2
1354 else
1355 ignerr shift 2
1356 endif
1357 echo t2.2:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1358 shift 0
1359 echo t2.3:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1360 if [ $# > 0 ]
1361 shift
1362 endif
1363 echo t2.4:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1365 define t1 {
1366 set errexit
1367 echo in: t1
1368 call t2 1 you get four args
1369 echo t1.1: $?';' ignerr ($ignerr) should not exist
1370 call t2 1 you get 'three args'
1371 echo t1.2: $?';' ignerr ($ignerr) should not exist
1372 call t2 1 you 'get two args'
1373 echo t1.3: $?';' ignerr ($ignerr) should not exist
1374 call t2 1 'you get one arg'
1375 echo t1.4: $?';' ignerr ($ignerr) should not exist
1376 ignerr call t2 '' 'you get one arg'
1377 echo t1.5: $?';' ignerr ($ignerr) should not exist
1379 call t1
1380 __EOT
1382 check behave:macro_param_shift 0 "${MBOX}" '1402489146 1682'
1384 t_epilog
1387 t_behave_addrcodec() {
1388 t_prolog
1390 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}"
1391 vput addrcodec res e 1 <doog@def>
1392 echo $?/$^ERRNAME $res
1393 eval vput addrcodec res d $res
1394 echo $?/$^ERRNAME $res
1395 vput addrcodec res e 2 . <doog@def>
1396 echo $?/$^ERRNAME $res
1397 eval vput addrcodec res d $res
1398 echo $?/$^ERRNAME $res
1399 vput addrcodec res e 3 Sauer Dr. <doog@def>
1400 echo $?/$^ERRNAME $res
1401 eval vput addrcodec res d $res
1402 echo $?/$^ERRNAME $res
1403 vput addrcodec res e 3.50 Sauer (Ma) Dr. <doog@def>
1404 echo $?/$^ERRNAME $res
1405 eval vput addrcodec res d $res
1406 echo $?/$^ERRNAME $res
1407 vput addrcodec res e 3.51 Sauer (Ma) "Dr." <doog@def>
1408 echo $?/$^ERRNAME $res
1409 eval vput addrcodec res d $res
1410 echo $?/$^ERRNAME $res
1412 vput addrcodec res +e 4 Sauer (Ma) Dr. <doog@def>
1413 echo $?/$^ERRNAME $res
1414 eval vput addrcodec res d $res
1415 echo $?/$^ERRNAME $res
1416 vput addrcodec res +e 5 Sauer (Ma) Braten Dr. <doog@def>
1417 echo $?/$^ERRNAME $res
1418 eval vput addrcodec res d $res
1419 echo $?/$^ERRNAME $res
1420 vput addrcodec res +e 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
1421 echo $?/$^ERRNAME $res
1422 eval vput addrcodec res d $res
1423 echo $?/$^ERRNAME $res
1424 vput addrcodec res +e 7 Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu)
1425 echo $?/$^ERRNAME $res
1426 eval vput addrcodec res d $res
1427 echo $?/$^ERRNAME $res
1428 vput addrcodec res +e 8 \
1429 Dr. Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu) Boom. Boom
1430 echo $?/$^ERRNAME $res
1431 eval vput addrcodec res d $res
1432 echo $?/$^ERRNAME $res
1433 vput addrcodec res +e 9 Dr.Sauer(Ma)Braten Dr. (Heu) <doog@def>
1434 echo $?/$^ERRNAME $res
1435 eval vput addrcodec res d $res
1436 echo $?/$^ERRNAME $res
1437 vput addrcodec res +e 10 (Ma)Braten Dr. (Heu) <doog@def>
1438 echo $?/$^ERRNAME $res
1439 eval vput addrcodec res d $res
1440 echo $?/$^ERRNAME $res
1441 vput addrcodec res +e 11 (Ma)Braten Dr"." (Heu) <doog@def>
1442 echo $?/$^ERRNAME $res
1443 eval vput addrcodec res d $res
1444 echo $?/$^ERRNAME $res
1445 vput addrcodec res +e 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
1446 echo $?/$^ERRNAME $res
1447 eval vput addrcodec res d $res
1448 echo $?/$^ERRNAME $res
1449 vput addrcodec res +e 13(Ma)Braten Dr. (Heu) <doog@def>
1450 echo $?/$^ERRNAME $res
1451 eval vput addrcodec res d $res
1452 echo $?/$^ERRNAME $res
1453 vput addrcodec res +e 14 Hey, Du <doog@def> Wie() findet Dr. das? ()
1454 echo $?/$^ERRNAME $res
1455 eval vput addrcodec res d $res
1456 echo $?/$^ERRNAME $res
1457 vput addrcodec res +e 15 \
1458 Hey, Du <doog@def> Wie() findet "" Dr. "" das? ()
1459 echo $?/$^ERRNAME $res
1460 eval vput addrcodec res d $res
1461 echo $?/$^ERRNAME $res
1462 vput addrcodec res +e 16 \
1463 "Hey," "Du" <doog@def> "Wie()" findet "" Dr. "" das? ()
1464 echo $?/$^ERRNAME $res
1465 eval vput addrcodec res d $res
1466 echo $?/$^ERRNAME $res
1467 vput addrcodec res +e 17 \
1468 "Hey" Du <doog@def> "Wie() findet " " Dr. """ das? ()
1469 echo $?/$^ERRNAME $res
1470 eval vput addrcodec res d $res
1471 echo $?/$^ERRNAME $res
1472 vput addrcodec res +e 18 \
1473 <doog@def> "Hey" Du "Wie() findet " " Dr. """ das? ()
1474 echo $?/$^ERRNAME $res
1475 eval vput addrcodec res d $res
1476 echo $?/$^ERRNAME $res
1477 vput addrcodec res +e 19 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1478 echo $?/$^ERRNAME $res
1479 eval vput addrcodec res d $res
1480 echo $?/$^ERRNAME $res
1482 vput addrcodec res ++e 20 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1483 echo $?/$^ERRNAME $res
1484 vput addrcodec res ++e 21 Hey\,\"" <doog@def> "Wie()" findet \" Dr. \" das?
1485 echo $?/$^ERRNAME $res
1486 eval vput addrcodec res d $res
1487 echo $?/$^ERRNAME $res
1489 vput addrcodec res +++e 22 Hey\\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1490 echo $?/$^ERRNAME $res
1491 eval vput addrcodec res d $res
1492 echo $?/$^ERRNAME $res
1494 vput addrcodec res s \
1495 "23 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
1496 echo $?/$^ERRNAME $res
1497 __EOT
1499 check behave:addrcodec 0 "${MBOX}" '429099645 2414'
1501 t_epilog
1504 t_behave_vexpr() {
1505 t_prolog
1507 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>/dev/null
1508 vput vexpr res = 9223372036854775807
1509 echo $?/$^ERRNAME $res
1510 vput vexpr res = 9223372036854775808
1511 echo $?/$^ERRNAME $res
1512 vput vexpr res =@ 9223372036854775808
1513 echo $?/$^ERRNAME $res
1514 vput vexpr res = -9223372036854775808
1515 echo $?/$^ERRNAME $res
1516 vput vexpr res = -9223372036854775809
1517 echo $?/$^ERRNAME $res
1518 vput vexpr res =@ -9223372036854775809
1519 echo $?/$^ERRNAME $res
1520 echo ' #1'
1521 vput vexpr res ~ 0
1522 echo $?/$^ERRNAME $res
1523 vput vexpr res ~ 1
1524 echo $?/$^ERRNAME $res
1525 vput vexpr res ~ -1
1526 echo $?/$^ERRNAME $res
1527 echo ' #2'
1528 vput vexpr res + 0 0
1529 echo $?/$^ERRNAME $res
1530 vput vexpr res + 0 1
1531 echo $?/$^ERRNAME $res
1532 vput vexpr res + 1 1
1533 echo $?/$^ERRNAME $res
1534 echo ' #3'
1535 vput vexpr res + 9223372036854775807 0
1536 echo $?/$^ERRNAME $res
1537 vput vexpr res + 9223372036854775807 1
1538 echo $?/$^ERRNAME $res
1539 vput vexpr res +@ 9223372036854775807 1
1540 echo $?/$^ERRNAME $res
1541 vput vexpr res + 0 9223372036854775807
1542 echo $?/$^ERRNAME $res
1543 vput vexpr res + 1 9223372036854775807
1544 echo $?/$^ERRNAME $res
1545 vput vexpr res +@ 1 9223372036854775807
1546 echo $?/$^ERRNAME $res
1547 echo ' #4'
1548 vput vexpr res + -9223372036854775808 0
1549 echo $?/$^ERRNAME $res
1550 vput vexpr res + -9223372036854775808 -1
1551 echo $?/$^ERRNAME $res
1552 vput vexpr res +@ -9223372036854775808 -1
1553 echo $?/$^ERRNAME $res
1554 vput vexpr res + 0 -9223372036854775808
1555 echo $?/$^ERRNAME $res
1556 vput vexpr res + -1 -9223372036854775808
1557 echo $?/$^ERRNAME $res
1558 vput vexpr res +@ -1 -9223372036854775808
1559 echo $?/$^ERRNAME $res
1560 echo ' #5'
1561 vput vexpr res - 0 0
1562 echo $?/$^ERRNAME $res
1563 vput vexpr res - 0 1
1564 echo $?/$^ERRNAME $res
1565 vput vexpr res - 1 1
1566 echo $?/$^ERRNAME $res
1567 echo ' #6'
1568 vput vexpr res - 9223372036854775807 0
1569 echo $?/$^ERRNAME $res
1570 vput vexpr res - 9223372036854775807 -1
1571 echo $?/$^ERRNAME $res
1572 vput vexpr res -@ 9223372036854775807 -1
1573 echo $?/$^ERRNAME $res
1574 vput vexpr res - 0 9223372036854775807
1575 echo $?/$^ERRNAME $res
1576 vput vexpr res - -1 9223372036854775807
1577 echo $?/$^ERRNAME $res
1578 vput vexpr res - -2 9223372036854775807
1579 echo $?/$^ERRNAME $res
1580 vput vexpr res -@ -2 9223372036854775807
1581 echo $?/$^ERRNAME $res
1582 echo ' #7'
1583 vput vexpr res - -9223372036854775808 +0
1584 echo $?/$^ERRNAME $res
1585 vput vexpr res - -9223372036854775808 +1
1586 echo $?/$^ERRNAME $res
1587 vput vexpr res -@ -9223372036854775808 +1
1588 echo $?/$^ERRNAME $res
1589 vput vexpr res - 0 -9223372036854775808
1590 echo $?/$^ERRNAME $res
1591 vput vexpr res - +1 -9223372036854775808
1592 echo $?/$^ERRNAME $res
1593 vput vexpr res -@ +1 -9223372036854775808
1594 echo $?/$^ERRNAME $res
1595 echo ' #8'
1596 vput vexpr res + -13 -2
1597 echo $?/$^ERRNAME $res
1598 vput vexpr res - 0 0
1599 echo $?/$^ERRNAME $res
1600 vput vexpr res - 0 1
1601 echo $?/$^ERRNAME $res
1602 vput vexpr res - 1 1
1603 echo $?/$^ERRNAME $res
1604 vput vexpr res - -13 -2
1605 echo $?/$^ERRNAME $res
1606 echo ' #9'
1607 vput vexpr res * 0 0
1608 echo $?/$^ERRNAME $res
1609 vput vexpr res * 0 1
1610 echo $?/$^ERRNAME $res
1611 vput vexpr res * 1 1
1612 echo $?/$^ERRNAME $res
1613 vput vexpr res * -13 -2
1614 echo $?/$^ERRNAME $res
1615 echo ' #10'
1616 vput vexpr res / 0 0
1617 echo $?/$^ERRNAME $res
1618 vput vexpr res / 0 1
1619 echo $?/$^ERRNAME $res
1620 vput vexpr res / 1 1
1621 echo $?/$^ERRNAME $res
1622 vput vexpr res / -13 -2
1623 echo $?/$^ERRNAME $res
1624 echo ' #11'
1625 vput vexpr res % 0 0
1626 echo $?/$^ERRNAME $res
1627 vput vexpr res % 0 1
1628 echo $?/$^ERRNAME $res
1629 vput vexpr res % 1 1
1630 echo $?/$^ERRNAME $res
1631 vput vexpr res % -13 -2
1632 echo $?/$^ERRNAME $res
1633 __EOT
1635 check behave:vexpr-numeric 0 "${MBOX}" '1723609217 1048'
1637 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" #2>/dev/null
1638 vput vexpr res find 'bananarama' 'nana'
1639 echo $?/$^ERRNAME :$res:
1640 vput vexpr res find 'bananarama' 'bana'
1641 echo $?/$^ERRNAME :$res:
1642 vput vexpr res find 'bananarama' 'Bana'
1643 echo $?/$^ERRNAME :$res:
1644 vput vexpr res find 'bananarama' 'rama'
1645 echo $?/$^ERRNAME :$res:
1646 echo ' #1'
1647 vput vexpr res ifind 'bananarama' 'nana'
1648 echo $?/$^ERRNAME :$res:
1649 vput vexpr res ifind 'bananarama' 'bana'
1650 echo $?/$^ERRNAME :$res:
1651 vput vexpr res ifind 'bananarama' 'Bana'
1652 echo $?/$^ERRNAME :$res:
1653 vput vexpr res ifind 'bananarama' 'rama'
1654 echo $?/$^ERRNAME :$res:
1655 echo ' #2'
1656 vput vexpr res substring 'bananarama' 1
1657 echo $?/$^ERRNAME :$res:
1658 vput vexpr res substring 'bananarama' 3
1659 echo $?/$^ERRNAME :$res:
1660 vput vexpr res substring 'bananarama' 5
1661 echo $?/$^ERRNAME :$res:
1662 vput vexpr res substring 'bananarama' 7
1663 echo $?/$^ERRNAME :$res:
1664 vput vexpr res substring 'bananarama' 9
1665 echo $?/$^ERRNAME :$res:
1666 vput vexpr res substring 'bananarama' 10
1667 echo $?/$^ERRNAME :$res:
1668 vput vexpr res substring 'bananarama' 1 3
1669 echo $?/$^ERRNAME :$res:
1670 vput vexpr res substring 'bananarama' 3 3
1671 echo $?/$^ERRNAME :$res:
1672 vput vexpr res substring 'bananarama' 5 3
1673 echo $?/$^ERRNAME :$res:
1674 vput vexpr res substring 'bananarama' 7 3
1675 echo $?/$^ERRNAME :$res:
1676 vput vexpr res substring 'bananarama' 9 3
1677 echo $?/$^ERRNAME :$res:
1678 vput vexpr res substring 'bananarama' 10 3
1679 echo $?/$^ERRNAME :$res:
1680 echo ' #3'
1681 __EOT
1683 check behave:vexpr-string 0 "${MBOX}" '265398700 267'
1685 if have_feat regex; then
1686 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" #2>/dev/null
1687 vput vexpr res regex 'bananarama' 'nana'
1688 echo $?/$^ERRNAME :$res:
1689 vput vexpr res regex 'bananarama' 'bana'
1690 echo $?/$^ERRNAME :$res:
1691 vput vexpr res regex 'bananarama' 'Bana'
1692 echo $?/$^ERRNAME :$res:
1693 vput vexpr res regex 'bananarama' 'rama'
1694 echo $?/$^ERRNAME :$res:
1695 echo ' #1'
1696 vput vexpr res iregex 'bananarama' 'nana'
1697 echo $?/$^ERRNAME :$res:
1698 vput vexpr res iregex 'bananarama' 'bana'
1699 echo $?/$^ERRNAME :$res:
1700 vput vexpr res iregex 'bananarama' 'Bana'
1701 echo $?/$^ERRNAME :$res:
1702 vput vexpr res iregex 'bananarama' 'rama'
1703 echo $?/$^ERRNAME :$res:
1704 echo ' #2'
1705 vput vexpr res regex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1706 echo $?/$^ERRNAME :$res:
1707 vput vexpr res regex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1708 echo $?/$^ERRNAME :$res:
1709 vput vexpr res regex 'bananarama' 'Bana(.+)' '\$1\$0'
1710 echo $?/$^ERRNAME :$res:
1711 vput vexpr res regex 'bananarama' '(.+)rama' '\$1\$0'
1712 echo $?/$^ERRNAME :$res:
1713 echo ' #3'
1714 vput vexpr res iregex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1715 echo $?/$^ERRNAME :$res:
1716 vput vexpr res iregex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1717 echo $?/$^ERRNAME :$res:
1718 vput vexpr res iregex 'bananarama' 'Bana(.+)' '\$1\$0'
1719 echo $?/$^ERRNAME :$res:
1720 vput vexpr res iregex 'bananarama' '(.+)rama' '\$1\$0'
1721 echo $?/$^ERRNAME :$res:
1722 echo ' #4'
1723 __EOT
1725 check behave:vexpr-regex 0 "${MBOX}" '3270360157 311'
1726 else
1727 printf 'behave:vexpr-regex: unsupported, skipped\n'
1730 t_epilog
1733 t_behave_call_ret() {
1734 t_prolog
1736 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
1737 define w1 {
1738 echon ">$1 "
1739 vput vexpr i + $1 1
1740 if [ $i -le 42 ]
1741 vput vexpr j '&' $i 7
1742 if [ $j -eq 7 ]
1743 echo .
1745 call w1 $i
1746 wysh set i=$? k=$!
1747 vput vexpr j '&' $i 7
1748 echon "<$1/$i/$k "
1749 if [ $j -eq 7 ]
1750 echo .
1752 else
1753 echo ! The end for $1
1755 return $1
1757 # Transport $?/$! up the call chain
1758 define w2 {
1759 echon ">$1 "
1760 vput vexpr i + $1 1
1761 if [ $1 -lt 42 ]
1762 call w2 $i
1763 wysh set i=$? j=$! k=$^ERRNAME
1764 echon "<$1/$i/$k "
1765 return $i $j
1766 else
1767 echo ! The end for $1
1768 return $i $^ERR-BUSY
1770 echoerr au
1772 # Up and down it goes
1773 define w3 {
1774 echon ">$1/$2 "
1775 vput vexpr i + $1 1
1776 if [ $1 -lt 42 ]
1777 call w3 $i $2
1778 wysh set i=$? j=$!
1779 vput vexpr k - $1 $2
1780 if [ $k -eq 21 ]
1781 vput vexpr i + $1 1
1782 vput vexpr j + $2 1
1783 echo "# <$i/$j> .. "
1784 call w3 $i $j
1785 wysh set i=$? j=$!
1787 eval echon "<\$1=\$i/\$^ERRNAME-$j "
1788 return $i $j
1789 else
1790 echo ! The end for $1=$i/$2
1791 if [ "$2" != "" ]
1792 return $i $^ERR-DOM
1793 else
1794 return $i $^ERR-BUSY
1797 echoerr au
1800 call w1 0; echo ?=$? !=$!; echo -----;
1801 call w2 0; echo ?=$? !=$^ERRNAME; echo -----;
1802 call w3 0 1; echo ?=$? !=$^ERRNAME; echo -----;
1803 __EOT
1805 check behave:call_ret 0 "${MBOX}" '1572045517 5922'
1807 t_epilog
1810 t_behave_xcall() {
1811 t_prolog
1813 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
1814 define work {
1815 echon "$1 "
1816 vput vexpr i + $1 1
1817 if [ $i -le 1111 ]
1818 vput vexpr j '&' $i 7
1819 if [ $j -eq 7 ]
1820 echo .
1822 \xcall work $i $2
1824 echo ! The end for $1/$2
1825 if [ "$2" != "" ]
1826 return $i $^ERR-BUSY
1829 define xwork {
1830 \xcall work 0 $2
1832 call work 0
1833 echo ?=$? !=$!
1834 call xwork
1835 echo ?=$? !=$!
1836 xcall xwork
1837 echo ?=$? !=$^ERRNAME
1839 call work 0 yes
1840 echo ?=$? !=$^ERRNAME
1841 call xwork 0 yes
1842 echo ?=$? !=$^ERRNAME
1843 __EOT
1845 check behave:xcall-1 0 "${MBOX}" '728629184 19115'
1849 ${cat} <<- '__EOT' > "${BODY}"
1850 define __w {
1851 echon "$1 "
1852 vput vexpr i + $1 1
1853 if [ $i -le 111 ]
1854 vput vexpr j '&' $i 7
1855 if [ $j -eq 7 ]
1856 echo .
1858 \xcall __w $i $2
1860 echo ! The end for $1
1861 if [ $2 -eq 0 ]
1862 nonexistingcommand
1863 echo would be err with errexit
1864 return
1866 echo calling exit
1867 exit
1869 define work {
1870 echo eins
1871 call __w 0 0
1872 echo zwei, ?=$? !=$!
1873 localopts yes; set errexit
1874 ignerr call __w 0 0
1875 echo drei, ?=$? !=$^ERRNAME
1876 call __w 0 $1
1877 echo vier, ?=$? !=$^ERRNAME, this is an error
1879 ignerr call work 0
1880 echo outer 1, ?=$? !=$^ERRNAME
1881 xxxign call work 0
1882 echo outer 2, ?=$? !=$^ERRNAME, could be error if xxxign non-empty
1883 call work 1
1884 echo outer 3, ?=$? !=$^ERRNAME
1885 echo this is definitely an error
1886 __EOT
1888 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign ignerr' -Snomemdebug \
1889 > "${MBOX}" 2>&1
1890 check behave:xcall-2 0 "${MBOX}" '3900716531 4200'
1892 < "${BODY}" ${MAILX} ${ARGS} -X'commandalias xxxign " "' -Snomemdebug \
1893 > "${MBOX}" 2>&1
1894 check behave:xcall-3 1 "${MBOX}" '1006776201 2799'
1896 t_epilog
1899 t_behave_vpospar() {
1900 t_prolog
1902 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1903 vpospar set hey, "'you ", world!
1904 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1905 vput vpospar x quote; echo x<$x>
1906 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1907 vput vpospar y quote;echo y<$y>
1908 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1909 eval vpospar set ${y};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1910 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1912 define infun2 {
1913 echo infun2:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1914 vput vpospar z quote;echo infun2:z<$z>
1917 define infun {
1918 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1919 vput vpospar y quote;echo infun:y<$y>
1920 eval vpospar set ${x};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1921 vpospar clear;echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1922 eval call infun2 $x
1923 echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1924 eval vpospar set ${y};echo infun:$?/$^ERRNAME/$#:$*/"$@"/<$1><$2><$3><$4>
1927 call infun This "in a" fun
1928 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1929 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1930 __EOT
1931 check behave:vpospar-1 0 "${MBOX}" '155175639 866'
1934 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} > "${MBOX}" 2>&1
1935 set ifs=\'
1936 echo ifs<$ifs> ifs-ws<$ifs-ws>
1937 vpospar set hey, "'you ", world!
1938 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1939 vput vpospar x quote; echo x<$x>
1940 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1941 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1943 set ifs=,
1944 echo ifs<$ifs> ifs-ws<$ifs-ws>
1945 vpospar set hey, "'you ", world!
1946 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1947 vput vpospar x quote; echo x<$x>
1948 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1949 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1951 wysh set ifs=$',\t'
1952 echo ifs<$ifs> ifs-ws<$ifs-ws>
1953 vpospar set hey, "'you ", world!
1954 echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1955 vput vpospar x quote; echo x<$x>
1956 vpospar clear;echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1957 eval vpospar set ${x};echo $?/$^ERRNAME/$#: $* / "$@" / <$1><$2><$3><$4>
1958 __EOT
1959 check behave:vpospar-ifs 0 "${MBOX}" '2015927702 706'
1961 t_epilog
1964 t_behave_read() {
1965 t_prolog
1966 TRAP_EXIT_ADDONS="./.t*"
1968 ${cat} <<- '__EOT' > .tin
1969 hey1, "'you ", world!
1970 hey2, "'you ", bugs bunny!
1971 hey3, "'you ",
1972 hey4, "'you "
1973 __EOT
1975 ${cat} <<- '__EOT' |\
1976 ${MAILX} ${ARGS} -X'readctl create ./.tin' > "${MBOX}" 2>&1
1977 read a b c
1978 echo $?/$^ERRNAME / <$a><$b><$c>
1979 read a b c
1980 echo $?/$^ERRNAME / <$a><$b><$c>
1981 read a b c
1982 echo $?/$^ERRNAME / <$a><$b><$c>
1983 read a b c
1984 echo $?/$^ERRNAME / <$a><$b><$c>
1985 read a b c
1986 echo $?/$^ERRNAME / <$a><$b><$c>
1987 readctl remove ./.tin;echo readctl remove:$?/$^ERRNAME
1988 __EOT
1989 check behave:read-1 0 "${MBOX}" '1527910147 173'
1991 ${cat} <<- '__EOT' > .tin2
1992 hey2.0,:"'you ",:world!:mars.:
1993 hey2.1,:"'you ",:world!
1994 hey2.2,:"'you ",:bugs bunny!
1995 hey2.3,:"'you ",:
1996 hey2.4,:"'you ":
1998 __EOT
2000 ${cat} <<- '__EOT' |\
2001 6< .tin2 ${MAILX} ${ARGS} -X 'readctl create 6' > "${MBOX}" 2>&1
2002 set ifs=:
2003 read a b c
2004 echo $?/$^ERRNAME / <$a><$b><$c>
2005 read a b c
2006 echo $?/$^ERRNAME / <$a><$b><$c>
2007 read a b c
2008 echo $?/$^ERRNAME / <$a><$b><$c>
2009 read a b c
2010 echo $?/$^ERRNAME / <$a><$b><$c>
2011 read a b c
2012 echo $?/$^ERRNAME / <$a><$b><$c>
2013 read a b c
2014 echo $?/$^ERRNAME / <$a><$b><$c>
2015 read a b c
2016 echo $?/$^ERRNAME / <$a><$b><$c>
2017 read a b c
2018 echo $?/$^ERRNAME / <$a><$b><$c>
2019 readctl remove 6;echo readctl remove:$?/$^ERRNAME
2020 __EOT
2021 check behave:read-ifs 0 "${MBOX}" '890153490 298'
2023 t_epilog
2026 t_behave_mbox() {
2027 t_prolog
2028 TRAP_EXIT_ADDONS="./.t*"
2032 while [ ${i} -lt 112 ]; do
2033 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
2034 "${MBOX}" "${i}" "${i}"
2035 i=`add ${i} 1`
2036 done
2037 ) | ${MAILX} ${ARGS}
2038 check behave:mbox-1 0 "${MBOX}" '1140119864 13780'
2040 printf 'File "%s"
2041 copy * "%s"
2042 File "%s"
2043 from*
2044 ' "${MBOX}" .tmbox1 .tmbox1 |
2045 ${MAILX} ${ARGS} > .tlst
2046 check behave:mbox-2 0 .tlst '2739893312 9103'
2048 printf 'File "%s"
2049 copy * "file://%s"
2050 File "file://%s"
2051 from*
2052 ' "${MBOX}" .tmbox2 .tmbox2 |
2053 ${MAILX} ${ARGS} > .tlst
2054 check behave:mbox-3 0 .tlst '1702194178 9110'
2056 # only the odd (even)
2058 printf 'File "file://%s"
2059 copy ' .tmbox2
2061 while [ ${i} -lt 112 ]; do
2062 j=`modulo ${i} 2`
2063 [ ${j} -eq 1 ] && printf '%s ' "${i}"
2064 i=`add ${i} 1`
2065 done
2066 printf ' file://%s
2067 File "file://%s"
2068 from*
2069 ' .tmbox3 .tmbox3
2070 ) | ${MAILX} ${ARGS} > .tlst
2071 check behave:mbox-4 0 .tmbox3 '631132924 6890'
2072 check behave:mbox-5 - .tlst '2960975049 4573'
2073 # ...
2075 printf 'file "file://%s"
2076 move ' .tmbox2
2078 while [ ${i} -lt 112 ]; do
2079 j=`modulo ${i} 2`
2080 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
2081 i=`add ${i} 1`
2082 done
2083 printf ' file://%s
2084 File "file://%s"
2085 from*
2086 File "file://%s"
2087 from*
2088 ' .tmbox3 .tmbox3 .tmbox2
2089 ) | ${MAILX} ${ARGS} > .tlst
2090 check behave:mbox-6 0 .tmbox3 '1387070539 13655'
2091 ${sed} 2d < .tlst > .tlstx
2092 check behave:mbox-7 - .tlstx '2729940494 13645'
2094 t_epilog
2097 t_behave_alias() {
2098 t_prolog
2099 TRAP_EXIT_ADDONS="./.t*"
2101 ${cat} <<-_EOT > ./.tsendmail.sh
2102 #!${MYSHELL} -
2103 (echo 'From Hippocastanum Mon Jun 19 15:07:07 2017' && ${cat} && echo
2104 ) >> "${MBOX}"
2105 _EOT
2106 chmod 0755 ./.tsendmail.sh
2108 ${cat} <<- '__EOT' | ${MAILX} ${ARGS} -Smta=./.tsendmail.sh > ./.tall 2>&1
2109 alias a1 ex1@a1.ple
2110 alias a1 ex2@a1.ple "EX3 <ex3@a1.ple>"
2111 alias a1 ex4@a1.ple
2112 alias a2 ex1@a2.ple ex2@a2.ple ex3@a2.ple ex4@a2.ple
2113 alias a3 a4
2114 alias a4 a5 ex1@a4.ple
2115 alias a5 a6
2116 alias a6 a7 ex1@a6.ple
2117 alias a7 a8
2118 alias a8 ex1@a8.ple
2119 alias a1
2120 alias a2
2121 alias a3
2122 m a1
2123 ~c a2
2124 ~b a3
2125 ~r - '_EOT'
2126 This body is!
2127 This also body is!!
2128 _EOT
2129 __EOT
2130 check behave:alias-1 0 "${MBOX}" '2496925843 272'
2131 check behave:alias-2 - .tall '3548953204 152'
2133 # TODO t_behave_alias: n_ALIAS_MAXEXP is compile-time constant,
2134 # TODO need to somehow provide its contents to the test, then test
2136 t_epilog
2139 t_behave_filetype() {
2140 t_prolog
2141 TRAP_EXIT_ADDONS="./.t*"
2143 ${cat} <<-_EOT > ./.tsendmail.sh
2144 #!${MYSHELL} -
2145 (echo 'From Alchemilla Wed Apr 25 15:12:13 2017' && ${cat} && echo
2146 ) >> "${MBOX}"
2147 _EOT
2148 chmod 0755 ./.tsendmail.sh
2150 printf 'm m1@e.t\nL1\nHy1\n~.\nm m2@e.t\nL2\nHy2\n~@ ./snailmail.jpg\n~.\n' |
2151 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2152 check behave:filetype-1 0 "${MBOX}" '1645747150 13536'
2154 if command -v gzip >/dev/null 2>&1; then
2155 ${rm} -f ./.t.mbox*
2157 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
2158 copy 2 ./.t.mbox.gz' "${MBOX}" |
2159 ${MAILX} ${ARGS} \
2160 -X'filetype gz gzip\ -dc gzip\ -c'
2161 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
2162 ${MAILX} ${ARGS} \
2163 -X'filetype gz gzip\ -dc gzip\ -c'
2164 } >/dev/null 2>&1
2165 check behave:filetype-2 0 "./.t.mbox" '1645747150 13536'
2166 else
2167 echo 'behave:filetype-2: unsupported, skipped'
2171 ${rm} -f ./.t.mbox*
2172 printf 'File "%s"\ncopy 1 ./.t.mbox.gz
2173 copy 2 ./.t.mbox.gz
2174 copy 1 ./.t.mbox.gz
2175 copy 2 ./.t.mbox.gz
2176 ' "${MBOX}" |
2177 ${MAILX} ${ARGS} \
2178 -X'filetype gz gzip\ -dc gzip\ -c' \
2179 -X'filetype mbox.gz "${sed} 1,3d|${cat}" \
2180 "echo eins;echo zwei;echo und mit ${sed} bist Du dabei;${cat}"'
2181 printf 'File ./.t.mbox.gz\ncopy * ./.t.mbox\n' |
2182 ${MAILX} ${ARGS} \
2183 -X'filetype gz gzip\ -dc gzip\ -c' \
2184 -X'filetype mbox.gz "${sed} 1,3d|${cat}" kill\ 0'
2185 } >/dev/null 2>&1
2187 check behave:filetype-3 - "./.t.mbox" '238021003 27092'
2189 t_epilog
2192 t_behave_record_a_resend() {
2193 t_prolog
2194 TRAP_EXIT_ADDONS="./.t.record ./.t.resent"
2196 printf '
2197 set record=%s
2198 m %s\n~s Subject 1.\nHello.\n~.
2199 set record-files add-file-recipients
2200 m %s\n~s Subject 2.\nHello.\n~.
2201 File %s
2202 resend 2 ./.t.resent
2203 Resend 1 ./.t.resent
2204 set record-resent
2205 resend 2 ./.t.resent
2206 Resend 1 ./.t.resent
2207 ' ./.t.record "${MBOX}" "${MBOX}" "${MBOX}" |
2208 ${MAILX} ${ARGS}
2210 check behave:record_a_resend-1 0 "${MBOX}" '3057873538 256'
2211 check behave:record_a_resend-2 - .t.record '391356429 460'
2212 check behave:record_a_resend-3 - .t.resent '2685231691 648'
2214 t_epilog
2217 t_behave_e_H_L_opts() {
2218 t_prolog
2219 TRAP_EXIT_ADDONS="./.tsendmail.sh ./.t.mbox"
2221 touch ./.t.mbox
2222 ${MAILX} ${ARGS} -ef ./.t.mbox
2223 echo ${?} > "${MBOX}"
2225 ${cat} <<-_EOT > ./.tsendmail.sh
2226 #!${MYSHELL} -
2227 (echo 'From Alchemilla Wed Apr 07 17:03:33 2017' && ${cat} && echo
2228 ) >> "./.t.mbox"
2229 _EOT
2230 chmod 0755 ./.tsendmail.sh
2231 printf 'm me@exam.ple\nLine 1.\nHello.\n~.\n' |
2232 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2233 printf 'm you@exam.ple\nLine 1.\nBye.\n~.\n' |
2234 ${MAILX} ${ARGS} -Smta=./.tsendmail.sh
2236 ${MAILX} ${ARGS} -ef ./.t.mbox
2237 echo ${?} >> "${MBOX}"
2238 ${MAILX} ${ARGS} -efL @t@me ./.t.mbox
2239 echo ${?} >> "${MBOX}"
2240 ${MAILX} ${ARGS} -efL @t@you ./.t.mbox
2241 echo ${?} >> "${MBOX}"
2242 ${MAILX} ${ARGS} -efL '@>@Line 1' ./.t.mbox
2243 echo ${?} >> "${MBOX}"
2244 ${MAILX} ${ARGS} -efL '@>@Hello.' ./.t.mbox
2245 echo ${?} >> "${MBOX}"
2246 ${MAILX} ${ARGS} -efL '@>@Bye.' ./.t.mbox
2247 echo ${?} >> "${MBOX}"
2248 ${MAILX} ${ARGS} -efL '@>@Good bye.' ./.t.mbox
2249 echo ${?} >> "${MBOX}"
2251 ${MAILX} ${ARGS} -fH ./.t.mbox >> "${MBOX}"
2252 echo ${?} >> "${MBOX}"
2253 ${MAILX} ${ARGS} -fL @t@me ./.t.mbox >> "${MBOX}"
2254 echo ${?} >> "${MBOX}"
2255 ${MAILX} ${ARGS} -fL @t@you ./.t.mbox >> "${MBOX}"
2256 echo ${?} >> "${MBOX}"
2257 ${MAILX} ${ARGS} -fL '@>@Line 1' ./.t.mbox >> "${MBOX}"
2258 echo ${?} >> "${MBOX}"
2259 ${MAILX} ${ARGS} -fL '@>@Hello.' ./.t.mbox >> "${MBOX}"
2260 echo ${?} >> "${MBOX}"
2261 ${MAILX} ${ARGS} -fL '@>@Bye.' ./.t.mbox >> "${MBOX}"
2262 echo ${?} >> "${MBOX}"
2263 ${MAILX} ${ARGS} -fL '@>@Good bye.' ./.t.mbox >> "${MBOX}" 2>/dev/null
2264 echo ${?} >> "${MBOX}"
2266 check behave:e_H_L_opts - "${MBOX}" '1708955574 678'
2268 t_epilog
2271 t_behave_compose_hooks() {
2272 t_prolog
2273 TRAP_EXIT_ADDONS="./.t*"
2275 (echo line one&&echo line two&&echo line three) > ./.treadctl
2276 (echo echo four&&echo echo five&&echo echo six) > ./.tattach
2278 ${cat} <<-_EOT > ./.tsendmail.sh
2279 #!${MYSHELL} -
2280 ${rm} -f "${MBOX}"
2281 (echo 'From PrimulaVeris Wed Apr 10 22:59:00 2017' && ${cat}) > "${MBOX}"
2282 _EOT
2283 chmod 0755 ./.tsendmail.sh
2285 ${cat} <<'__EOT__' > ./.trc
2286 define xerr {
2287 vput vexpr es substr "$1" 0 1
2288 if [ "$es" != 2 ]
2289 echoerr "Failed: $2. Bailing out"; echo "~x"
2292 define read_mline_res {
2293 read hl; wysh set len=$? es=$! en=$^ERRNAME;\
2294 echo $len/$es/$^ERRNAME: $hl
2295 if [ $es -ne $^ERR-NONE ]
2296 echoerr "read_mline_res: bailing out"; echo "~x"
2297 elif [ $len -ne 0 ]
2298 \xcall read_mline_res
2301 define ins_addr {
2302 wysh set xh=$1
2303 echo "~^header list"; read hl; echo $hl;\
2304 call xerr "$hl" "in_addr ($xh) 0-1"
2306 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2307 read es; echo $es; call xerr "$es" "ins_addr $xh 1-1"
2308 echo "~^header insert $xh <${xh}2@exam.ple>";\
2309 read es; echo $es; call xerr "$es" "ins_addr $xh 1-2"
2310 echo "~^header insert $xh ${xh}3@exam.ple";\
2311 read es; echo $es; call xerr "$es" "ins_addr $xh 1-3"
2312 echo "~^header list $xh"; read hl; echo $hl;\
2313 call xerr "$hl" "ins_addr $xh 1-4"
2314 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 1-5"
2315 call read_mline_res
2317 if [ "$t_remove" == "" ]
2318 return
2321 echo "~^header remove $xh"; read es; call xerr $es "ins_addr $xh 2-1"
2322 echo "~^header remove $xh"; read es; vput vexpr es substr $es 0 3
2323 if [ $es != 501 ]
2324 echoerr "Failed: ins_addr $xh 2-2"; echo "~x"
2326 echo "~^header list $xh"; read es; vput vexpr es substr $es 0 3
2327 if [ $es != 501 ]
2328 echoerr "Failed: ins_addr $xh 2-3"; echo "~x"
2330 echo "~^header show $xh"; read es; vput vexpr es substr $es 0 3
2331 if [ $es != 501 ]
2332 echoerr "Failed: ins_addr $xh 2-4"; echo "~x"
2336 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2337 read es; echo $es; call xerr "$es" "ins_addr $xh 3-1"
2338 echo "~^header insert $xh <${xh}2@exam.ple>";\
2339 read es; echo $es; call xerr "$es" "ins_addr $xh 3-2"
2340 echo "~^header insert $xh ${xh}3@exam.ple";\
2341 read es; echo $es; call xerr "$es" "ins_addr $xh 3-3"
2342 echo "~^header list $xh"; read hl; echo $hl;\
2343 call xerr "$hl" "ins_addr $xh 3-4"
2344 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 3-5"
2345 call read_mline_res
2347 echo "~^header remove-at $xh 1"; read es;\
2348 call xerr $es "ins_addr $xh 3-6"
2349 echo "~^header remove-at $xh 1"; read es;\
2350 call xerr $es "ins_addr $xh 3-7"
2351 echo "~^header remove-at $xh 1"; read es;\
2352 call xerr $es "ins_addr $xh 3-8"
2353 echo "~^header remove-at $xh 1"; read es;\
2354 vput vexpr es substr $es 0 3
2355 if [ $es != 501 ]
2356 echoerr "Failed: ins_addr $xh 3-9"; echo "~x"
2358 echo "~^header remove-at $xh T"; read es;\
2359 vput vexpr es substr $es 0 3
2360 if [ $es != 505 ]
2361 echoerr "Failed: ins_addr $xh 3-10"; echo "~x"
2363 echo "~^header list $xh"; read es;\
2364 vput vexpr es substr $es 0 3
2365 if [ $es != 501 ]
2366 echoerr "Failed: ins_addr $xh 3-11"; echo "~x"
2368 echo "~^header show $xh"; read es;\
2369 vput vexpr es substr $es 0 3
2370 if [ $es != 501 ]
2371 echoerr "Failed: ins_addr $xh 3-12"; echo "~x"
2375 echo "~^header insert $xh diet <$xh@exam.ple> spliced";\
2376 read es; echo $es; call xerr "$es" "ins_addr $xh 4-1"
2377 echo "~^header insert $xh <${xh}2@exam.ple> (comment) \"Quot(e)d\"";\
2378 read es; echo $es; call xerr "$es" "ins_addr $xh 4-2"
2379 echo "~^header insert $xh ${xh}3@exam.ple";\
2380 read es; echo $es; call xerr "$es" "ins_addr $xh 4-3"
2381 echo "~^header list $xh"; read hl; echo $hl;\
2382 call xerr "$hl" "header list $xh 3-4"
2383 echo "~^header show $xh"; read es; call xerr $es "ins_addr $xh 4-5"
2384 call read_mline_res
2386 echo "~^header remove-at $xh 3"; read es;\
2387 call xerr $es "ins_addr $xh 4-6"
2388 echo "~^header remove-at $xh 2"; read es;\
2389 call xerr $es "ins_addr $xh 4-7"
2390 echo "~^header remove-at $xh 1"; read es;\
2391 call xerr $es "ins_addr $xh 4-8"
2392 echo "~^header remove-at $xh 1"; read es;\
2393 vput vexpr es substr $es 0 3
2394 if [ $es != 501 ]
2395 echoerr "Failed: ins_addr $xh 4-9"; echo "~x"
2397 echo "~^header remove-at $xh T"; read es;\
2398 vput vexpr es substr $es 0 3
2399 if [ $es != 505 ]
2400 echoerr "Failed: ins_addr $xh 4-10"; echo "~x"
2402 echo "~^header list $xh"; read es;\
2403 vput vexpr es substr $es 0 3
2404 if [ $es != 501 ]
2405 echoerr "Failed: ins_addr $xh 4-11"; echo "~x"
2407 echo "~^header show $xh"; read es;\
2408 vput vexpr es substr $es 0 3
2409 if [ $es != 501 ]
2410 echoerr "Failed: ins_addr $xh 4-12"; echo "~x"
2413 define ins_ref {
2414 wysh set xh=$1 mult=$2
2415 echo "~^header list"; read hl; echo $hl;\
2416 call xerr "$hl" "ins_ref ($xh) 0-1"
2418 echo "~^header insert $xh <$xh@exam.ple>";\
2419 read es; echo $es; call xerr "$es" "ins_ref $xh 1-1"
2420 if [ $mult -ne 0 ]
2421 echo "~^header insert $xh <${xh}2@exam.ple>";\
2422 read es; echo $es; call xerr "$es" "ins_ref $xh 1-2"
2423 echo "~^header insert $xh ${xh}3@exam.ple";\
2424 read es; echo $es; call xerr "$es" "ins_ref $xh 1-3"
2425 else
2426 echo "~^header insert $xh <${xh}2@exam.ple>"; read es;\
2427 vput vexpr es substr $es 0 3
2428 if [ $es != 506 ]
2429 echoerr "Failed: ins_ref $xh 1-4"; echo "~x"
2433 echo "~^header list $xh"; read hl; echo $hl;\
2434 call xerr "$hl" "ins_ref $xh 1-5"
2435 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 1-6"
2436 call read_mline_res
2438 if [ "$t_remove" == "" ]
2439 return
2442 echo "~^header remove $xh"; read es;\
2443 call xerr $es "ins_ref $xh 2-1"
2444 echo "~^header remove $xh"; read es;\
2445 vput vexpr es substr $es 0 3
2446 if [ $es != 501 ]
2447 echoerr "Failed: ins_ref $xh 2-2"; echo "~x"
2449 echo "~^header list $xh"; read es;\
2450 vput vexpr es substr $es 0 3
2451 if [ $es != 501 ]
2452 echoerr "Failed: $es ins_ref $xh 2-3"; echo "~x"
2454 echo "~^header show $xh"; read es;\
2455 vput vexpr es substr $es 0 3
2456 if [ $es != 501 ]
2457 echoerr "Failed: ins_ref $xh 2-4"; echo "~x"
2461 echo "~^header insert $xh <$xh@exam.ple>";\
2462 read es; echo $es; call xerr "$es" "ins_ref $xh 3-1"
2463 if [ $mult -ne 0 ]
2464 echo "~^header insert $xh <${xh}2@exam.ple>";\
2465 read es; echo $es; call xerr "$es" "ins_ref $xh 3-2"
2466 echo "~^header insert $xh ${xh}3@exam.ple";\
2467 read es; echo $es; call xerr "$es" "ins_ref $xh 3-3"
2469 echo "~^header list $xh";\
2470 read hl; echo $hl; call xerr "$hl" "ins_ref $xh 3-4"
2471 echo "~^header show $xh";\
2472 read es; call xerr $es "ins_ref $xh 3-5"
2473 call read_mline_res
2475 echo "~^header remove-at $xh 1"; read es;\
2476 call xerr $es "ins_ref $xh 3-6"
2477 if [ $mult -ne 0 ] && [ $xh != subject ]
2478 echo "~^header remove-at $xh 1"; read es;\
2479 call xerr $es "ins_ref $xh 3-7"
2480 echo "~^header remove-at $xh 1"; read es;\
2481 call xerr $es "ins_ref $xh 3-8"
2483 echo "~^header remove-at $xh 1"; read es;\
2484 vput vexpr es substr $es 0 3
2485 if [ $es != 501 ]
2486 echoerr "Failed: ins_ref $xh 3-9"; echo "~x"
2488 echo "~^header remove-at $xh T"; read es;\
2489 vput vexpr es substr $es 0 3
2490 if [ $es != 505 ]
2491 echoerr "Failed: ins_ref $xh 3-10"; echo "~x"
2493 echo "~^header show $xh"; read es;\
2494 vput vexpr es substr $es 0 3
2495 if [ $es != 501 ]
2496 echoerr "Failed: ins_ref $xh 3-11"; echo "~x"
2500 echo "~^header insert $xh <$xh@exam.ple> ";\
2501 read es; echo $es; call xerr "$es" "ins_ref $xh 4-1"
2502 if [ $mult -ne 0 ]
2503 echo "~^header insert $xh <${xh}2@exam.ple> ";\
2504 read es; echo $es; call xerr "$es" "ins_ref $xh 4-2"
2505 echo "~^header insert $xh ${xh}3@exam.ple";\
2506 read es; echo $es; call xerr "$es" "ins_ref $xh 4-3"
2508 echo "~^header list $xh"; read hl; echo $hl;\
2509 call xerr "$hl" "ins_ref $xh 4-4"
2510 echo "~^header show $xh"; read es; call xerr $es "ins_ref $xh 4-5"
2511 call read_mline_res
2513 if [ $mult -ne 0 ] && [ $xh != subject ]
2514 echo "~^header remove-at $xh 3"; read es;\
2515 call xerr $es "ins_ref $xh 4-6"
2516 echo "~^header remove-at $xh 2"; read es;\
2517 call xerr $es "ins_ref $xh 4-7"
2519 echo "~^header remove-at $xh 1"; read es;\
2520 call xerr $es "ins_ref $xh 4-8"
2521 echo "~^header remove-at $xh 1"; read es;\
2522 vput vexpr es substr $es 0 3
2523 if [ $es != 501 ]
2524 echoerr "Failed: ins_ref $xh 4-9"; echo "~x"
2526 echo "~^header remove-at $xh T"; read es;\
2527 vput vexpr es substr $es 0 3
2528 if [ $es != 505 ]
2529 echoerr "Failed: ins_ref $xh 4-10"; echo "~x"
2531 echo "~^header show $xh"; read es;\
2532 vput vexpr es substr $es 0 3
2533 if [ $es != 501 ]
2534 echoerr "Failed: ins_ref $xh 4-11"; echo "~x"
2537 define t_header {
2538 echo t_header ENTER
2539 # In collect.c order
2540 call ins_addr from
2541 call ins_ref sender 0 # Not a "ref", but works
2542 call ins_addr To
2543 call ins_addr cC
2544 call ins_addr bCc
2545 call ins_addr reply-To
2546 call ins_addr mail-Followup-to
2547 call ins_ref messAge-id 0
2548 call ins_ref rEfErEncEs 1
2549 call ins_ref in-Reply-to 1
2550 call ins_ref subject 1 # Not a "ref", but works (with tweaks)
2551 call ins_addr freeForm1
2552 call ins_addr freeform2
2553 echo t_header LEAVE
2555 define t_attach {
2556 echo t_attach ENTER
2558 echo "~^attachment";\
2559 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
2560 if [ "$es" != 501 ]
2561 echoerr "Failed: attach 0-1"; echo "~x"
2564 echo "~^attach attribute ./.treadctl";\
2565 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
2566 if [ "$es" != 501 ]
2567 echoerr "Failed: attach 0-2"; echo "~x"
2569 echo "~^attachment attribute-at 1";\
2570 read hl; echo $hl; vput vexpr es substr "$hl" 0 3
2571 if [ "$es" != 501 ]
2572 echoerr "Failed: attach 0-3"; echo "~x"
2575 echo "~^attachment insert ./.treadctl=ascii";\
2576 read hl; echo $hl; call xerr "$hl" "attach 1-1"
2577 echo "~^attachment list";\
2578 read es; echo $es;call xerr "$es" "attach 1-2"
2579 call read_mline_res
2580 echo "~^attachment attribute ./.treadctl";\
2581 read es; echo $es;call xerr "$es" "attach 1-3"
2582 call read_mline_res
2583 echo "~^attachment attribute .treadctl";\
2584 read es; echo $es;call xerr "$es" "attach 1-4"
2585 call read_mline_res
2586 echo "~^attachment attribute-at 1";\
2587 read es; echo $es;call xerr "$es" "attach 1-5"
2588 call read_mline_res
2590 echo "~^attachment attribute-set ./.treadctl filename rctl";\
2591 read es; echo $es;call xerr "$es" "attach 1-6"
2592 echo "~^attachment attribute-set .treadctl content-description Au";\
2593 read es; echo $es;call xerr "$es" "attach 1-7"
2594 echo "~^attachment attribute-set-at 1 content-id <10.du@ich>";\
2595 read es; echo $es;call xerr "$es" "attach 1-8"
2597 echo "~^attachment attribute ./.treadctl";\
2598 read es; echo $es;call xerr "$es" "attach 1-9"
2599 call read_mline_res
2600 echo "~^attachment attribute .treadctl";\
2601 read es; echo $es;call xerr "$es" "attach 1-10"
2602 call read_mline_res
2603 echo "~^attachment attribute rctl";\
2604 read es; echo $es;call xerr "$es" "attach 1-11"
2605 call read_mline_res
2606 echo "~^attachment attribute-at 1";\
2607 read es; echo $es;call xerr "$es" "attach 1-12"
2608 call read_mline_res
2611 echo "~^attachment insert ./.tattach=latin1";\
2612 read hl; echo $hl; call xerr "$hl" "attach 2-1"
2613 echo "~^attachment list";\
2614 read es; echo $es;call xerr "$es" "attach 2-2"
2615 call read_mline_res
2616 echo "~^attachment attribute ./.tattach";\
2617 read es; echo $es;call xerr "$es" "attach 2-3"
2618 call read_mline_res
2619 echo "~^attachment attribute .tattach";\
2620 read es; echo $es;call xerr "$es" "attach 2-4"
2621 call read_mline_res
2622 echo "~^attachment attribute-at 2";\
2623 read es; echo $es;call xerr "$es" "attach 2-5"
2624 call read_mline_res
2626 echo "~^attachment attribute-set ./.tattach filename tat";\
2627 read es; echo $es;call xerr "$es" "attach 2-6"
2628 echo \
2629 "~^attachment attribute-set .tattach content-description Au2";\
2630 read es; echo $es;call xerr "$es" "attach 2-7"
2631 echo "~^attachment attribute-set-at 2 content-id <20.du@wir>";\
2632 read es; echo $es;call xerr "$es" "attach 2-8"
2633 echo \
2634 "~^attachment attribute-set-at 2 content-type application/x-sh";\
2635 read es; echo $es;call xerr "$es" "attach 2-9"
2637 echo "~^attachment attribute ./.tattach";\
2638 read es; echo $es;call xerr "$es" "attach 2-10"
2639 call read_mline_res
2640 echo "~^attachment attribute .tattach";\
2641 read es; echo $es;call xerr "$es" "attach 2-11"
2642 call read_mline_res
2643 echo "~^attachment attribute tat";\
2644 read es; echo $es;call xerr "$es" "attach 2-12"
2645 call read_mline_res
2646 echo "~^attachment attribute-at 2";\
2647 read es; echo $es;call xerr "$es" "attach 2-13"
2648 call read_mline_res
2651 if [ "$t_remove" == "" ]
2652 return
2655 echo "~^attachment remove ./.treadctl"; read es;\
2656 call xerr $es "attach 3-1"
2657 echo "~^attachment remove ./.tattach"; read es;\
2658 call xerr $es "attach 3-2"
2659 echo "~^ attachment remove ./.treadctl"; read es;\
2660 vput vexpr es substr $es 0 3
2661 if [ $es != 501 ]
2662 echoerr "Failed: attach 3-3"; echo "~x"
2664 echo "~^ attachment remove ./.tattach"; read es;\
2665 vput vexpr es substr $es 0 3
2666 if [ $es != 501 ]
2667 echoerr "Failed: attach 3-4"; echo "~x"
2669 echo "~^attachment list"; read es;\
2670 vput vexpr es substr $es 0 3
2671 if [ $es != 501 ]
2672 echoerr "Failed: attach 3-5"; echo "~x"
2676 echo "~^attachment insert ./.tattach=latin1";\
2677 read hl; echo $hl; call xerr "$hl" "attach 4-1"
2678 echo "~^attachment insert ./.tattach=latin1";\
2679 read hl; echo $hl; call xerr "$hl" "attach 4-2"
2680 echo "~^attachment list";\
2681 read es; echo $es;call xerr "$es" "attach 4-3"
2682 call read_mline_res
2683 echo "~^ attachment remove .tattach"; read es;\
2684 vput vexpr es substr $es 0 3
2685 if [ $es != 506 ]
2686 echoerr "Failed: attach 4-4 $es"; echo "~x"
2688 echo "~^attachment remove-at T"; read es;\
2689 vput vexpr es substr $es 0 3
2690 if [ $es != 505 ]
2691 echoerr "Failed: attach 4-5"; echo "~x"
2693 echo "~^attachment remove ./.tattach"; read es;\
2694 call xerr $es "attach 4-6"
2695 echo "~^attachment remove ./.tattach"; read es;\
2696 call xerr $es "attach 4-7"
2697 echo "~^ attachment remove ./.tattach"; read es;\
2698 vput vexpr es substr $es 0 3
2699 if [ $es != 501 ]
2700 echoerr "Failed: attach 4-8 $es"; echo "~x"
2702 echo "~^attachment list"; read es;\
2703 vput vexpr es substr $es 0 3
2704 if [ $es != 501 ]
2705 echoerr "Failed: attach 4-9"; echo "~x"
2709 echo "~^attachment insert ./.tattach=latin1";\
2710 read hl; echo $hl; call xerr "$hl" "attach 5-1"
2711 echo "~^attachment insert ./.tattach=latin1";\
2712 read hl; echo $hl; call xerr "$hl" "attach 5-2"
2713 echo "~^attachment insert ./.tattach=latin1";\
2714 read hl; echo $hl; call xerr "$hl" "attach 5-3"
2715 echo "~^attachment list";\
2716 read es; echo $es;call xerr "$es" "attach 5-4"
2717 call read_mline_res
2719 echo "~^attachment remove-at 3"; read es;\
2720 call xerr $es "attach 5-5"
2721 echo "~^attachment remove-at 3"; read es;\
2722 vput vexpr es substr $es 0 3
2723 if [ $es != 501 ]
2724 echoerr "Failed: attach 5-6"; echo "~x"
2726 echo "~^attachment remove-at 2"; read es;\
2727 call xerr $es "attach 5-7"
2728 echo "~^attachment remove-at 2"; read es;\
2729 vput vexpr es substr $es 0 3
2730 if [ $es != 501 ]
2731 echoerr "Failed: attach 5-8"; echo "~x"
2733 echo "~^attachment remove-at 1"; read es;\
2734 call xerr $es "attach 5-9"
2735 echo "~^attachment remove-at 1"; read es;\
2736 vput vexpr es substr $es 0 3
2737 if [ $es != 501 ]
2738 echoerr "Failed: attach 5-10"; echo "~x"
2741 echo "~^attachment list"; read es;\
2742 vput vexpr es substr $es 0 3
2743 if [ $es != 501 ]
2744 echoerr "Failed: attach 5-11"; echo "~x"
2748 echo "~^attachment insert ./.tattach=latin1";\
2749 read hl; echo $hl; call xerr "$hl" "attach 6-1"
2750 echo "~^attachment insert ./.tattach=latin1";\
2751 read hl; echo $hl; call xerr "$hl" "attach 6-2"
2752 echo "~^attachment insert ./.tattach=latin1";\
2753 read hl; echo $hl; call xerr "$hl" "attach 6-3"
2754 echo "~^attachment list";\
2755 read es; echo $es;call xerr "$es" "attach 6-4"
2756 call read_mline_res
2758 echo "~^attachment remove-at 1"; read es;\
2759 call xerr $es "attach 6-5"
2760 echo "~^attachment remove-at 1"; read es;\
2761 call xerr $es "attach 6-6"
2762 echo "~^attachment remove-at 1"; read es;\
2763 call xerr $es "attach 6-7"
2764 echo "~^attachment remove-at 1"; read es;\
2765 vput vexpr es substr $es 0 3
2766 if [ $es != 501 ]
2767 echoerr "Failed: attach 6-8"; echo "~x"
2770 echo "~^attachment list"; read es;\
2771 vput vexpr es substr $es 0 3
2772 if [ $es != 501 ]
2773 echoerr "Failed: attach 6-9"; echo "~x"
2776 echo t_attach LEAVE
2778 define t_ocs {
2779 read ver
2780 echo t_ocs
2781 call t_header
2782 if [ "$t_remove" != "" ]
2783 echo "~^ header insert to -"; read es;\
2784 call xerr "$es" "reinstantiate of a To:"
2786 call t_attach
2788 wysh set on-compose-splice=t_ocs
2789 __EOT__
2793 ${rm} -f "${MBOX}"
2794 printf 'm this-goes@nowhere\nbody\n!.\n' |
2795 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
2796 -X'source ./.trc' -Smta=./.tsendmail.sh \
2797 2>./.terr
2798 ${cat} ./.terr >> "${MBOX}"
2799 check behave:compose_hooks-1 0 "${MBOX}" '3958208025 8236'
2801 ${rm} -f "${MBOX}"
2802 printf 'm -\nbody\n!.\n' |
2803 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! -Sstealthmua=noagent \
2804 -St_remove=1 -X'source ./.trc' -Smta=./.tsendmail.sh \
2805 > "${MBOX}" 2>./.terr
2806 ${cat} ./.terr >> "${MBOX}"
2807 check behave:compose_hooks-2 0 "${MBOX}" '231191826 11104'
2809 # Some state machine stress, shell compose hook, etc.
2810 ${rm} -f "${MBOX}"
2811 printf 'm hook-test@exam.ple\nbody\n!.\nvar t_oce t_ocs t_ocs_shell t_ocl' |
2812 ${MAILX} ${ARGS} -Snomemdebug -Sescape=! \
2813 -Smta=./.tsendmail.sh \
2815 define _work {
2816 vput vexpr i + 1 "$2"
2817 if [ $i -lt 111 ]
2818 vput vexpr j % $i 10
2819 if [ $j -ne 0 ]
2820 set j=xcall
2821 else
2822 echon "$i.. "
2823 set j=call
2825 eval \\$j _work $1 $i
2826 return $?
2828 vput vexpr i + $i "$1"
2829 return $i
2831 define _read {
2832 read line;wysh set es=$? en=$^ERRNAME ; echo read:$es/$en: $line
2833 if [ "${es}" -ne -1 ]
2834 xcall _read
2836 readctl remove $cwd/.treadctl; echo readctl remove:$?/$^ERRNAME
2838 define t_ocs {
2839 read ver
2840 echo t_ocs
2841 echo "~^header list"; read hl; echo $hl;\
2842 vput vexpr es substr "$hl" 0 1
2843 if [ "$es" != 2 ]
2844 echoerr "Failed to header list, aborting send"; echo "~x"
2845 endif
2847 call _work 1; echo $?
2848 echo "~^header insert cc splicy diet <splice@exam.ple> spliced";\
2849 read es; echo $es; vput vexpr es substr "$es" 0 1
2850 if [ "$es" != 2 ]
2851 echoerr "Failed to be diet, aborting send"; echo "~x"
2852 endif
2853 echo "~^header insert cc <splice2@exam.ple>";\
2854 read es; echo $es; vput vexpr es substr "$es" 0 1
2855 if [ "$es" != 2 ]
2856 echoerr "Failed to be diet2, aborting send"; echo "~x"
2857 endif
2859 call _work 2; echo $?
2860 echo "~^header insert bcc juicy juice <juice@exam.ple> spliced";\
2861 read es; echo $es;vput vexpr es substr "$es" 0 1
2862 if [ "$es" != 2 ]
2863 echoerr "Failed to be juicy, aborting send"; echo "~x"
2864 endif
2865 echo "~^header insert bcc juice2@exam.ple";\
2866 read es; echo $es;vput vexpr es substr "$es" 0 1
2867 if [ "$es" != 2 ]
2868 echoerr "Failed to be juicy2, aborting send"; echo "~x"
2869 endif
2870 echo "~^header insert bcc juice3 <juice3@exam.ple>";\
2871 read es; echo $es;vput vexpr es substr "$es" 0 1
2872 if [ "$es" != 2 ]
2873 echoerr "Failed to be juicy3, aborting send"; echo "~x"
2874 endif
2875 echo "~^header insert bcc juice4@exam.ple";\
2876 read es; echo $es;vput vexpr es substr "$es" 0 1
2877 if [ "$es" != 2 ]
2878 echoerr "Failed to be juicy4, aborting send"; echo "~x"
2879 endif
2881 echo "~^header remove-at bcc 3";\
2882 read es; echo $es;vput vexpr es substr "$es" 0 1
2883 if [ "$es" != 2 ]
2884 echoerr "Failed to remove juicy3, aborting send"; echo "~x"
2885 endif
2886 echo "~^header remove-at bcc 2";\
2887 read es; echo $es;vput vexpr es substr "$es" 0 1
2888 if [ "$es" != 2 ]
2889 echoerr "Failed to remove juicy2, aborting send"; echo "~x"
2890 endif
2891 echo "~^header remove-at bcc 3";\
2892 read es; echo $es;vput vexpr es substr "$es" 0 3
2893 if [ "$es" != 501 ]
2894 echoerr "Failed to failed to remove-at, aborting send"; echo "~x"
2895 endif
2896 # Add duplicates which ought to be removed!
2897 echo "~^header insert bcc juice4@exam.ple";\
2898 read es; echo $es;vput vexpr es substr "$es" 0 1
2899 if [ "$es" != 2 ]
2900 echoerr "Failed to be juicy4-1, aborting send"; echo "~x"
2901 endif
2902 echo "~^header insert bcc juice4@exam.ple";\
2903 read es; echo $es;vput vexpr es substr "$es" 0 1
2904 if [ "$es" != 2 ]
2905 echoerr "Failed to be juicy4-2, aborting send"; echo "~x"
2906 endif
2907 echo "~^header insert bcc juice4@exam.ple";\
2908 read es; echo $es;vput vexpr es substr "$es" 0 1
2909 if [ "$es" != 2 ]
2910 echoerr "Failed to be juicy4-3, aborting send"; echo "~x"
2911 endif
2912 echo "~:set t_ocs"
2914 call _work 3; echo $?
2915 echo "~r - '__EOT'"
2916 vput ! i echo just knock if you can hear me;\
2917 i=0;\
2918 while [ $i -lt 24 ]; do printf "%s " $i; i=`expr $i + 1`; done;\
2919 echo relax
2920 echon shell-cmd says $?/$^ERRNAME: $i
2921 echo "~x will not become interpreted, we are reading until __EOT"
2922 echo "__EOT"
2924 call _work 4; echo $?
2925 vput cwd cwd;echo cwd:$?
2926 readctl create $cwd/.treadctl ;echo readctl:$?/$^ERRNAME
2927 xcall _read
2929 call _work 5; echo $?
2931 define t_oce {
2932 set t_oce autobcc=oce@exam.ple
2934 define t_ocl {
2935 set t_ocl autocc=ocl@exam.ple
2937 wysh set on-compose-splice=t_ocs \
2938 on-compose-splice-shell="read ver;printf \"t_ocs-shell\\n\
2939 ~t shell@exam.ple\\n~:set t_ocs_shell\\n\"" \
2940 on-compose-enter=t_oce on-compose-leave=t_ocl
2941 ' > ./.tnotes 2>&1
2942 ex0_test behave:compose_hooks-3
2943 ${cat} ./.tnotes >> "${MBOX}"
2945 check behave:compose_hooks-3 - "${MBOX}" '678882154 1071'
2947 t_epilog
2950 t_behave_mime_types_load_control() {
2951 t_prolog
2952 TRAP_EXIT_ADDONS="./.t*"
2954 ${cat} <<-_EOT > ./.tmts1
2955 @ application/mathml+xml mathml
2956 _EOT
2957 ${cat} <<-_EOT > ./.tmts2
2958 @ x-conference/x-cooltalk ice
2959 @ aga-aga aga
2960 @ application/aga-aga aga
2961 _EOT
2963 ${cat} <<-_EOT > ./.tmts1.mathml
2964 <head>nonsense ML</head>
2965 _EOT
2966 ${cat} <<-_EOT > ./.tmts2.ice
2967 Icy, icy road.
2968 _EOT
2969 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.doom
2970 printf 'of which the c\x01rack is coming soon' > ./.tmtsx.aga
2972 printf '
2973 m %s
2974 Schub-di-du
2975 ~@ ./.tmts1.mathml
2976 ~@ ./.tmts2.ice
2977 ~@ ./.tmtsx.doom
2978 ~@ ./.tmtsx.aga
2980 File %s
2981 from*
2982 type
2984 ' "${MBOX}" "${MBOX}" |
2985 ${MAILX} ${ARGS} \
2986 -Smimetypes-load-control=f=./.tmts1,f=./.tmts2 \
2987 > ./.tout 2>&1
2988 ex0_test behave:mime_types_load_control
2990 ${cat} "${MBOX}" >> ./.tout
2991 check behave:mime_types_load_control-1 - ./.tout '529577037 2474'
2993 echo type | ${MAILX} ${ARGS} -R \
2994 -Smimetypes-load-control=f=./.tmts1,f=./.tmts3 \
2995 -f "${MBOX}" >> ./.tout 2>&1
2996 check behave:mime_types_load_control-2 0 ./.tout '2025926659 3558'
2998 t_epilog
3001 t_behave_smime() {
3002 have_feat smime || {
3003 echo 'behave:s/mime: unsupported, skipped'
3004 return
3007 t_prolog
3008 TRAP_EXIT_ADDONS="./.t.conf ./.tkey.pem ./.tcert.pem ./.tpair.pem"
3009 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.VERIFY ./.DECRYPT ./.ENCRYPT"
3010 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.tsendmail.sh"
3012 printf 'behave:s/mime: .. generating test key and certificate ..\n'
3013 ${cat} <<-_EOT > ./.t.conf
3014 [ req ]
3015 default_bits = 1024
3016 default_keyfile = keyfile.pem
3017 distinguished_name = req_distinguished_name
3018 attributes = req_attributes
3019 prompt = no
3020 output_password =
3022 [ req_distinguished_name ]
3023 C = GB
3024 ST = Over the
3025 L = rainbow
3026 O = S-nail
3027 OU = S-nail.smime
3028 CN = S-nail.test
3029 emailAddress = test@localhost
3031 [ req_attributes ]
3032 challengePassword =
3033 _EOT
3034 openssl req -x509 -nodes -days 3650 -config ./.t.conf \
3035 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >/dev/null 2>&1
3036 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
3038 # Sign/verify
3039 printf 'behave:s/mime:sign/verify: '
3040 echo bla | ${MAILX} ${ARGS} \
3041 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3042 -Ssmime-sign -Sfrom=test@localhost \
3043 -s 'S/MIME test' ./.VERIFY
3044 if [ $? -eq 0 ]; then
3045 printf 'ok\n'
3046 else
3047 printf 'failed\n'
3048 ESTAT=1
3049 t_epilog
3050 return
3053 ${awk} '
3054 BEGIN{ skip=0 }
3055 /^Content-Description: /{ skip = 2; print; next }
3056 /^$/{ if(skip) --skip }
3057 { if(!skip) print }
3059 < ./.VERIFY > "${MBOX}"
3060 check behave:s/mime:sign/verify:checksum - "${MBOX}" '2900817158 648'
3062 printf 'behave:s/mime:sign/verify:verify '
3063 printf 'verify\nx\n' |
3064 ${MAILX} ${ARGS} \
3065 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3066 -Ssmime-sign -Sfrom=test@localhost \
3067 -Serrexit -R \
3068 -f ./.VERIFY >/dev/null 2>&1
3069 if [ $? -eq 0 ]; then
3070 printf 'ok\n'
3071 else
3072 printf 'failed\n'
3073 ESTAT=1
3074 t_epilog
3075 return
3078 printf 'behave:s/mime:sign/verify:disproof-1 '
3079 if openssl smime -verify -CAfile ./.tcert.pem \
3080 -in ./.VERIFY >/dev/null 2>&1; then
3081 printf 'ok\n'
3082 else
3083 printf 'failed\n'
3084 ESTAT=1
3085 t_epilog
3086 return
3089 # (signing +) encryption / decryption
3090 ${cat} <<-_EOT > ./.tsendmail.sh
3091 #!${MYSHELL} -
3092 (echo 'From Euphrasia Thu Apr 27 17:56:23 2017' && ${cat}) > ./.ENCRYPT
3093 _EOT
3094 chmod 0755 ./.tsendmail.sh
3096 printf 'behave:s/mime:encrypt+sign: '
3097 echo bla |
3098 ${MAILX} ${ARGS} \
3099 -Ssmime-force-encryption \
3100 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3101 -Smta=./.tsendmail.sh \
3102 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3103 -Ssmime-sign -Sfrom=test@localhost \
3104 -s 'S/MIME test' recei@ver.com
3105 if [ $? -eq 0 ]; then
3106 printf 'ok\n'
3107 else
3108 ESTAT=1
3109 printf 'error: encrypt+sign failed\n'
3112 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
3113 check behave:s/mime:encrypt+sign:checksum - "${MBOX}" '1937410597 327'
3115 printf 'behave:s/mime:decrypt+verify: '
3116 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
3117 ${MAILX} ${ARGS} \
3118 -Ssmime-force-encryption \
3119 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3120 -Smta=./.tsendmail.sh \
3121 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3122 -Ssmime-sign -Sfrom=test@localhost \
3123 -Serrexit -R \
3124 -f ./.ENCRYPT >/dev/null 2>&1
3125 if [ $? -eq 0 ]; then
3126 printf 'ok\n'
3127 else
3128 ESTAT=1
3129 printf 'failed\n'
3132 ${awk} '
3133 BEGIN{ skip=0 }
3134 /^Content-Description: /{ skip = 2; print; next }
3135 /^$/{ if(skip) --skip }
3136 { if(!skip) print }
3138 < ./.DECRYPT > "${MBOX}"
3139 check behave:s/mime:decrypt+verify:checksum - "${MBOX}" '1720739247 931'
3141 printf 'behave:s/mime:decrypt+verify:disproof-1: '
3142 if (openssl smime -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT |
3143 openssl smime -verify -CAfile ./.tcert.pem) >/dev/null 2>&1; then
3144 printf 'ok\n'
3145 else
3146 printf 'failed\n'
3147 ESTAT=1
3150 printf "behave:s/mime:encrypt: "
3151 echo bla | ${MAILX} ${ARGS} \
3152 -Ssmime-force-encryption \
3153 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3154 -Smta=./.tsendmail.sh \
3155 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3156 -Sfrom=test@localhost \
3157 -s 'S/MIME test' recei@ver.com
3158 if [ $? -eq 0 ]; then
3159 printf 'ok\n'
3160 else
3161 ESTAT=1
3162 printf 'failed\n'
3165 # Same as behave:s/mime:encrypt+sign:checksum above
3166 ${sed} -e '/^$/,$d' < ./.ENCRYPT > "${MBOX}"
3167 check behave:s/mime:encrypt:checksum - "${MBOX}" '1937410597 327'
3169 ${rm} -f ./.DECRYPT
3170 printf 'decrypt ./.DECRYPT\nx\n' | ${MAILX} ${ARGS} \
3171 -Ssmime-force-encryption \
3172 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
3173 -Smta=./.tsendmail.sh \
3174 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
3175 -Sfrom=test@localhost \
3176 -Serrexit -R \
3177 -f ./.ENCRYPT >/dev/null 2>&1
3178 check behave:s/mime:decrypt 0 "./.DECRYPT" '2624716890 422'
3180 printf 'behave:s/mime:decrypt:disproof-1: '
3181 if openssl smime -decrypt -inkey ./.tkey.pem \
3182 -in ./.ENCRYPT >/dev/null 2>&1; then
3183 printf 'ok\n'
3184 else
3185 printf 'failed\n'
3186 ESTAT=1
3189 t_epilog
3192 t_behave_maildir() {
3193 t_prolog
3194 TRAP_EXIT_ADDONS="./.t*"
3198 while [ ${i} -lt 112 ]; do
3199 printf 'm file://%s\n~s Subject %s\nHello %s!\n~.\n' \
3200 "${MBOX}" "${i}" "${i}"
3201 i=`add ${i} 1`
3202 done
3203 ) | ${MAILX} ${ARGS}
3204 check behave:maildir-1 0 "${MBOX}" '1140119864 13780'
3206 printf 'File "%s"
3207 copy * "%s"
3208 File "%s"
3209 from*
3210 ' "${MBOX}" .tmdir1 .tmdir1 |
3211 ${MAILX} ${ARGS} -Snewfolders=maildir > .tlst
3212 check behave:maildir-2 0 .tlst '1797938753 9103'
3214 printf 'File "%s"
3215 copy * "maildir://%s"
3216 File "maildir://%s"
3217 from*
3218 ' "${MBOX}" .tmdir2 .tmdir2 |
3219 ${MAILX} ${ARGS} > .tlst
3220 check behave:maildir-3 0 .tlst '1155631089 9113'
3222 printf 'File "maildir://%s"
3223 copy * "file://%s"
3224 File "file://%s"
3225 from*
3226 ' .tmdir2 .tmbox1 .tmbox1 |
3227 ${MAILX} ${ARGS} > .tlst
3228 check behave:maildir-4 0 .tmbox1 '2646131190 13220'
3229 check behave:maildir-5 - .tlst '3701297796 9110'
3231 # only the odd (even)
3233 printf 'File "maildir://%s"
3234 copy ' .tmdir2
3236 while [ ${i} -lt 112 ]; do
3237 j=`modulo ${i} 2`
3238 [ ${j} -eq 1 ] && printf '%s ' "${i}"
3239 i=`add ${i} 1`
3240 done
3241 printf ' file://%s
3242 File "file://%s"
3243 from*
3244 ' .tmbox2 .tmbox2
3245 ) | ${MAILX} ${ARGS} > .tlst
3246 check behave:maildir-6 0 .tmbox2 '142890131 6610'
3247 check behave:maildir-7 - .tlst '960096773 4573'
3248 # ...
3250 printf 'file "maildir://%s"
3251 move ' .tmdir2
3253 while [ ${i} -lt 112 ]; do
3254 j=`modulo ${i} 2`
3255 [ ${j} -eq 0 ] && [ ${i} -ne 0 ] && printf '%s ' "${i}"
3256 i=`add ${i} 1`
3257 done
3258 printf ' file://%s
3259 File "file://%s"
3260 from*
3261 File "maildir://%s"
3262 from*
3263 ' .tmbox2 .tmbox2 .tmdir2
3264 ) | ${MAILX} ${ARGS} > .tlst
3265 check behave:maildir-8 0 .tmbox2 '3806905791 13100'
3266 ${sed} 2d < .tlst > .tlstx
3267 check behave:maildir-9 - .tlstx '4216815295 13645'
3269 t_epilog
3272 # t_content()
3273 # Some basic tests regarding correct sending of mails, via STDIN / -t / -q,
3274 # including basic MIME Content-Transfer-Encoding correctness (quoted-printable)
3275 # Note we unfortunately need to place some statements without proper
3276 # indentation because of continuation problems
3277 t_content() {
3278 t_prolog
3280 # MIME encoding (QP) stress message body
3281 printf \
3282 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
3283 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
3284 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
3285 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
3286 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
3287 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
3288 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
3289 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
3290 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
3291 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
3292 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
3293 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
3294 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
3295 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
3296 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
3297 "auf den zeilen vorher.\r\n"\
3298 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
3299 ".\r\n"\
3300 "Die letzte Zeile war nur ein Punkt.\r\n"\
3301 "..\r\n"\
3302 "Das waren deren zwei.\r\n"\
3303 " \r\n"\
3304 "Die letzte Zeile war ein Leerschritt.\n"\
3305 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
3306 "Prösterchen.\r\n"\
3307 ".\n"\
3308 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
3309 "..\n"\
3310 "Das waren deren zwei. ditto.\n"\
3311 "Prösterchen.\n"\
3312 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
3313 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
3314 "auf den zeilen vorher.\n"\
3315 "ditto.\n"\
3316 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
3317 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
3318 "\n"\
3319 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
3320 "\n"\
3321 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
3322 "3\n"\
3323 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
3324 "34\n"\
3325 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
3326 "345\n"\
3327 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
3328 "3456\n"\
3329 "QP am Zeilenende über soft-nl hinweg\n"\
3330 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
3331 "ö123\n"\
3332 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
3333 "1ö23\n"\
3334 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
3335 "12ö3\n"\
3336 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
3337 "123ö\n"\
3338 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
3339 " \n"\
3340 "Die letzte Zeile war ein Leerschritt.\n"\
3341 ' '\
3342 > "${BODY}"
3344 # MIME encoding (QP) stress message subject
3345 SUB="Äbrä Kä?dä=brö Fü?di=bus? \
3346 adadaddsssssssddddddddddddddddddddd\
3347 ddddddddddddddddddddddddddddddddddd\
3348 ddddddddddddddddddddddddddddddddddd\
3349 dddddddddddddddddddd Hallelulja? Od\
3350 er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
3351 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
3352 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f\
3353 fffffffffffffffffffffffffffffffffff\
3354 fffffffffffffffffffff ggggggggggggg\
3355 ggggggggggggggggggggggggggggggggggg\
3356 ggggggggggggggggggggggggggggggggggg\
3357 ggggggggggggggggggggggggggggggggggg\
3358 gggggggggggggggg"
3360 # Three tests for MIME encoding and (a bit) content classification.
3361 # At the same time testing -q FILE, < FILE and -t FILE
3363 ${rm} -f "${MBOX}"
3364 < "${BODY}" ${MAILX} ${ARGS} ${ADDARG_UNI} \
3365 -a "${BODY}" -s "${SUB}" "${MBOX}"
3366 check content:001 0 "${MBOX}" '1145066634 6654'
3368 ${rm} -f "${MBOX}"
3369 < /dev/null ${MAILX} ${ARGS} ${ADDARG_UNI} \
3370 -a "${BODY}" -s "${SUB}" -q "${BODY}" "${MBOX}"
3371 check content:002 0 "${MBOX}" '1145066634 6654'
3373 ${rm} -f "${MBOX}"
3374 ( echo "To: ${MBOX}" && echo "Subject: ${SUB}" && echo &&
3375 ${cat} "${BODY}"
3376 ) | ${MAILX} ${ARGS} ${ADDARG_UNI} -Snodot -a "${BODY}" -t
3377 check content:003 0 "${MBOX}" '1145066634 6654'
3379 # Test for [260e19d] (Juergen Daubert)
3380 ${rm} -f "${MBOX}"
3381 echo body | ${MAILX} ${ARGS} "${MBOX}"
3382 check content:004 0 "${MBOX}" '2917662811 98'
3384 # Sending of multiple mails in a single invocation
3385 ${rm} -f "${MBOX}"
3386 ( printf "m ${MBOX}\n~s subject1\nE-Mail Körper 1\n~.\n" &&
3387 printf "m ${MBOX}\n~s subject2\nEmail body 2\n~.\n" &&
3388 echo x
3389 ) | ${MAILX} ${ARGS} ${ADDARG_UNI}
3390 check content:005 0 "${MBOX}" '2098659767 358'
3392 ## $BODY CHANGED
3394 # "Test for" [d6f316a] (Gavin Troy)
3395 ${rm} -f "${MBOX}"
3396 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
3397 ${MAILX} ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="@* ${cat}" > "${BODY}"
3398 check content:006 0 "${MBOX}" '2099098650 122'
3399 check content:006-1 - "${BODY}" '794542938 174'
3401 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
3402 ${rm} -f "${MBOX}"
3403 ${awk} 'BEGIN{
3404 for(i = 0; i < 10000; ++i)
3405 printf "\xC3\xBC"
3406 #printf "\xF0\x90\x87\x90"
3407 }' | ${MAILX} ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
3408 check content:007 0 "${MBOX}" '534262374 61816'
3410 ## Test some more corner cases for header bodies (as good as we can today) ##
3413 ${rm} -f "${MBOX}"
3414 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
3415 -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̲' \
3416 "${MBOX}"
3417 check content:008 0 "${MBOX}" '3370931614 375'
3419 # Single word (overlong line split -- bad standard! Requires injection of
3420 # artificial data!! But can be prevented by using RFC 2047 encoding)
3421 ${rm} -f "${MBOX}"
3422 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
3423 echo | ${MAILX} ${ARGS} -s "${i}" "${MBOX}"
3424 check content:009 0 "${MBOX}" '489922370 1718'
3426 # Combination of encoded words, space and tabs of varying sort
3427 ${rm} -f "${MBOX}"
3428 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
3429 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
3430 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
3431 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
3432 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
3433 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
3434 "${MBOX}"
3435 check content:010 0 "${MBOX}" '1676887734 591'
3437 # Overlong multibyte sequence that must be forcefully split
3438 # todo This works even before v15.0, but only by accident
3439 ${rm} -f "${MBOX}"
3440 echo | ${MAILX} ${ARGS} ${ADDARG_UNI} \
3441 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
3442 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
3443 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
3444 "${MBOX}"
3445 check content:011 0 "${MBOX}" '3029301775 659'
3447 # Trailing WS
3448 ${rm} -f "${MBOX}"
3449 echo | ${MAILX} ${ARGS} \
3450 -s "1-1 B2 B3 B4 B5 B6 B\
3451 1-2 B2 B3 B4 B5 B6 B\
3452 1-3 B2 B3 B4 B5 B6 B\
3453 1-4 B2 B3 B4 B5 B6 B\
3454 1-5 B2 B3 B4 B5 B6 B\
3455 1-6 B2 B3 B4 B5 B6 " \
3456 "${MBOX}"
3457 check content:012 0 "${MBOX}" '4126167195 297'
3459 # Leading and trailing WS
3460 ${rm} -f "${MBOX}"
3461 echo | ${MAILX} ${ARGS} \
3462 -s " 2-1 B2 B3 B4 B5 B6 B\
3463 1-2 B2 B3 B4 B5 B6 B\
3464 1-3 B2 B3 B4 B5 B6 B\
3465 1-4 B2 B3 B4 B5 B6 " \
3466 "${MBOX}"
3467 check content:013 0 "${MBOX}" '3600624479 236'
3469 # Quick'n dirty RFC 2231 test; i had more when implementing it, but until we
3470 # have a (better) test framework materialize a quick shot
3471 ${rm} -f "${MBOX}"
3472 TRAP_EXIT_ADDONS=./.ttt
3474 mkdir ./.ttt || exit 1
3475 cd ./.ttt || exit 2
3476 : > "ma'ger.txt"
3477 : > "mä'ger.txt"
3478 : > 'diet\ is \curd.txt'
3479 : > 'diet "is" curd.txt'
3480 : > höde-tröge.txt
3481 : > 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
3482 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
3483 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
3484 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
3486 echo bla | ${MAILX} ${ARGS} ${ADDARG_UNI} \
3487 -a "./.ttt/ma'ger.txt" -a "./.ttt/mä'ger.txt" \
3488 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
3489 -a ./.ttt/höde-tröge.txt \
3490 -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 \
3491 -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 \
3492 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
3493 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
3494 "${MBOX}"
3495 check content:014-1 0 "${MBOX}" '684985954 3092'
3497 # `resend' test, reusing $MBOX
3498 ${rm} -f "${BODY}"
3499 printf "Resend ${BODY}\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
3500 check content:014-2 0 "${BODY}" '684985954 3092'
3502 ${rm} -f "${BODY}"
3503 printf "resend ${BODY}\nx\n" | ${MAILX} ${ARGS} -Rf "${MBOX}"
3504 check content:014-3 0 "${BODY}" '3130352658 3148'
3506 t_epilog
3509 t_all() {
3510 # if have_feat devel; then
3511 # ARGS="${ARGS} -Smemdebug"
3512 # export ARGS
3513 # fi
3514 t_behave
3515 t_content
3518 if [ -z "${CHECK_ONLY}" ]; then
3519 cc_all_configs
3520 else
3521 t_all
3524 [ ${ESTAT} -eq 0 ] && echo Ok || echo >&2 'Errors occurred'
3526 exit ${ESTAT}
3527 # s-sh-mode