Tweak previous, it added a bad memory access
[s-mailx.git] / cc-test.sh
blob7101e2fc3f18be74e5a2e89afc28ad1aed224800
1 #!/bin/mksh -
2 #@ Usage: ./cc-test.sh [--check-only [s-nail-binary]]
3 # Public Domain
5 ARGS='-:/ -# -Sdotlock-ignore-error -Sencoding=quoted-printable -Sstealthmua'
6 ARGS="${ARGS}"' -Snosave -Sexpandaddr=restrict'
7 ARGS="${ARGS}"' -Slog-prefix=classico:'
8 CONF=./make.rc
9 BODY=./.cc-body.txt
10 MBOX=./.cc-test.mbox
11 MAIL=/dev/null
12 #UTF8_LOCALE= autodetected unless set
14 if ( command -v command ) >/dev/null 2>&1; then :; else
15 command() {
16 shift
17 which "${@}"
21 MAKE="${MAKE:-`command -v make`}"
22 awk=${awk:-`command -v awk`}
23 cat=${cat:-`command -v cat`}
24 cksum=${cksum:-`command -v cksum`}
25 rm=${rm:-`command -v rm`}
26 sed=${sed:-`command -v sed`}
27 grep=${grep:-`command -v grep`}
29 ## -- >8 -- 8< -- ##
31 export SNAIL ARGS CONF BODY MBOX MAIL MAKE awk cat cksum rm sed grep
33 LC_ALL=C LANG=C ADDARG_UNI=-Sttycharset=UTF-8
34 TZ=UTC
35 # Wed Oct 2 01:50:07 UTC 1996
36 SOURCE_DATE_EPOCH=844221007
38 export LC_ALL LANG ADDARG_UNI TZ SOURCE_DATE_EPOCH
39 unset POSIXLY_CORRECT
41 # Problem: force $SHELL to be a real shell. It seems some testing environments
42 # use nologin(?), but we need a real shell for command execution
43 if { echo ${SHELL} | ${grep} nologin; } >/dev/null 2>&1; then
44 echo >&2 '$SHELL seems to be nologin, overwriting to /bin/sh!'
45 SHELL=/bin/sh
46 export SHELL
49 if [ -z "${UTF8_LOCALE}" ]; then
50 UTF8_LOCALE=
51 if command -v locale >/dev/null 2>&1; then
52 UTF8_LOCALE=`locale -a | { m=
53 while read n; do
54 if { echo ${n} | ${grep} -i 'utf-\{0,1\}8'; } >/dev/null 2>&1; then
55 m=${n}
56 if { echo ${n} | ${grep} -e POSIX -e en_EN -e en_US; }; then
57 exit 0
60 m=${n}
61 done
62 echo ${m}
67 ESTAT=0
69 usage() {
70 echo >&2 "Usage: ./cc-test.sh [--check-only [s-nail-binary]]"
71 exit 1
74 CHECK_ONLY=
75 [ ${#} -gt 0 ] && {
76 [ "${1}" = --check-only ] || usage
77 [ ${#} -gt 2 ] && usage
78 [ ${#} -eq 2 ] && SNAIL="${2}"
79 [ -x "${SNAIL}" ] || usage
80 CHECK_ONLY=1
83 TRAP_EXIT_ADDONS=
84 trap "${rm} -rf \"${BODY}\" \"${MBOX}\" \${TRAP_EXIT_ADDONS}" EXIT
85 trap "exit 1" HUP INT TERM
87 # cc_all_configs()
88 # Test all configs TODO doesn't cover all *combinations*, stupid!
89 cc_all_configs() {
90 < ${CONF} ${awk} '
91 BEGIN {
92 NOTME["OPT_AUTOCC"] = 1
93 NOTME["OPT_DEBUG"] = 1
94 NOTME["OPT_DEVEL"] = 1
95 NOTME["OPT_NOEXTMD5"] = 1
96 NOTME["OPT_NOMEMDBG"] = 1
97 NOTME["OPT_NYD2"] = 1
98 i = 0
100 /^[[:space:]]*OPT_/ {
101 sub(/^[[:space:]]*/, "")
102 # This bails for UnixWare 7.1.4 awk(1), but preceeding = with \
103 # does not seem to be a compliant escape for =
104 #sub(/=.*$/, "")
105 $1 = substr($1, 1, index($1, "=") - 1)
106 if (NOTME[$1])
107 next
108 data[i++] = $1
110 END {
111 # Doing this completely sequentially and not doing make distclean in
112 # between runs should effectively result in lesser compilations.
113 # It is completely dumb nonetheless... TODO
114 for (j = 1; j < i; ++j) {
115 for (k = 1; k < j; ++k)
116 printf data[k] "=1 "
117 for (k = j; k < i; ++k)
118 printf data[k] "=0 "
119 printf "OPT_AUTOCC=1\n"
121 for (j = 1; j < i; ++j) {
122 for (k = 1; k < j; ++k)
123 printf data[k] "=0 "
124 for (k = j; k < i; ++k)
125 printf data[k] "=1 "
126 printf "OPT_AUTOCC=1\n"
128 # With debug
129 for (j = 1; j < i; ++j) {
130 for (k = 1; k < j; ++k)
131 printf data[k] "=1 "
132 for (k = j; k < i; ++k)
133 printf data[k] "=0 "
134 printf "OPT_AUTOCC=1\n"
135 printf "OPT_DEBUG=1\n"
137 for (j = 1; j < i; ++j) {
138 for (k = 1; k < j; ++k)
139 printf data[k] "=0 "
140 for (k = j; k < i; ++k)
141 printf data[k] "=1 "
142 printf "OPT_AUTOCC=1\n"
143 printf "OPT_DEBUG=1\n"
146 printf "CONFIG=NULL OPT_AUTOCC=0\n"
147 printf "CONFIG=NULL OPT_AUTOCC=1\n"
148 printf "CONFIG=NULLI OPT_AUTOCC=0\n"
149 printf "CONFIG=NULLI OPT_AUTOCC=1\n"
150 printf "CONFIG=MINIMAL OPT_AUTOCC=0\n"
151 printf "CONFIG=MINIMAL OPT_AUTOCC=1\n"
152 printf "CONFIG=MEDIUM OPT_AUTOCC=0\n"
153 printf "CONFIG=MEDIUM OPT_AUTOCC=1\n"
154 printf "CONFIG=NETSEND OPT_AUTOCC=0\n"
155 printf "CONFIG=NETSEND OPT_AUTOCC=1\n"
156 printf "CONFIG=MAXIMAL OPT_AUTOCC=0\n"
157 printf "CONFIG=MAXIMAL OPT_AUTOCC=1\n"
158 printf "CONFIG=DEVEL OPT_AUTOCC=0\n"
159 printf "CONFIG=DEVEL OPT_AUTOCC=1\n"
160 printf "CONFIG=ODEVEL OPT_AUTOCC=0\n"
161 printf "CONFIG=ODEVEL OPT_AUTOCC=1\n"
163 ' | while read c; do
164 printf "\n\n##########\n$c\n"
165 printf "\n\n##########\n$c\n" >&2
166 sh -c "${MAKE} ${c}"
167 t_all
168 done
169 ${MAKE} distclean
172 # cksum_test()
173 # Read mailbox $2, strip non-constant headers and MIME boundaries, query the
174 # cksum(1) of the resulting data and compare against the checksum $3
175 cksum_test() {
176 tid=${1} f=${2} s=${3}
177 printf "${tid}: "
178 csum="`${sed} -e '/^From /d' \
179 -e '/^ boundary=/d' -e '/^--=-=/d' < \"${f}\" \
180 -e '/^\[-- Message/d' | ${cksum}`";
181 if [ "${csum}" = "${s}" ]; then
182 printf 'ok\n'
183 else
184 ESTAT=1
185 printf 'error: checksum mismatch (got %s)\n' "${csum}"
189 err() {
190 ESTAT=1
191 printf '%s: error: %s\n' ${1} "${2}"
194 ex0_test() {
195 [ $? -ne 0 ] && err $1 'unexpected non-0 exit status'
198 exn0_test() {
199 [ $? -eq 0 ] && err $1 'unexpected 0 exit status'
202 have_feat() {
203 ( "${SNAIL}" ${ARGS} -X'echo $features' -Xx | ${grep} +${1} ) >/dev/null 2>&1
206 # t_behave()
207 # Basic (easily testable) behaviour tests
208 t_behave() {
209 t_behave_X_opt_input_command_stack
210 t_behave_X_errexit
211 t_behave_wysh
212 t_behave_input_inject_semicolon_seq
213 t_behave_commandalias
214 t_behave_ifelse
215 t_behave_localopts
216 t_behave_macro_param_shift
217 t_behave_addrcodec
218 t_behave_vexpr
219 t_behave_call_ret
220 t_behave_xcall
222 # FIXME t_behave_alias
224 # FIXME t_behave_mlist
226 have_feat smime && t_behave_smime
228 t_behave_e_H_L_opts
229 t_behave_compose_hooks
232 t_behave_X_opt_input_command_stack() {
233 ${cat} <<- '__EOT' > "${BODY}"
234 echo 1
235 define mac0 {
236 echo mac0-1 via1 $0
238 call mac0
239 echo 2
240 source '\
241 echo "define mac1 {";\
242 echo " echo mac1-1 via1 \$0";\
243 echo " call mac0";\
244 echo " echo mac1-2";\
245 echo " call mac2";\
246 echo " echo mac1-3";\
247 echo "}";\
248 echo "echo 1-1";\
249 echo "define mac2 {";\
250 echo " echo mac2-1 via1 \$0";\
251 echo " call mac0";\
252 echo " echo mac2-2";\
253 echo "}";\
254 echo "echo 1-2";\
255 echo "call mac1";\
256 echo "echo 1-3";\
257 echo "source \"\
258 echo echo 1-1-1 via1 \$0;\
259 echo call mac0;\
260 echo echo 1-1-2;\
261 | \"";\
262 echo "echo 1-4";\
264 echo 3
265 call mac2
266 echo 4
267 undefine *
268 __EOT
270 # The -X option supports multiline arguments, and those can internally use
271 # reverse solidus newline escaping. And all -X options are joined...
272 APO=\'
273 < "${BODY}" "${SNAIL}" ${ARGS} \
274 -X 'e\' \
275 -X ' c\' \
276 -X ' h\' \
277 -X ' o \' \
278 -X 1 \
280 define mac0 {
281 echo mac0-1 via2 $0
283 call mac0
284 echo 2
287 source '${APO}'\
288 echo "define mac1 {";\
289 echo " echo mac1-1 via2 \$0";\
290 echo " call mac0";\
291 echo " echo mac1-2";\
292 echo " call mac2";\
293 echo " echo mac1-3";\
294 echo "}";\
295 echo "echo 1-1";\
296 echo "define mac2 {";\
297 echo " echo mac2-1 via2 \$0";\
298 echo " call mac0";\
299 echo " echo mac2-2";\
300 echo "}";\
301 echo "echo 1-2";\
302 echo "call mac1";\
303 echo "echo 1-3";\
304 echo "source \"\
305 echo echo 1-1-1 via2 \$0;\
306 echo call mac0;\
307 echo echo 1-1-2;\
308 | \"";\
309 echo "echo 1-4";\
310 | '${APO}'
311 echo 3
314 call mac2
315 echo 4
316 undefine *
317 ' > "${MBOX}" 2>/dev/null
319 #mac0-1 via2
321 #1-1
322 #1-2
323 #mac1-1 via2
324 #mac0-1 via2 mac1
325 #mac1-2
326 #mac2-1 via2 mac1
327 #mac0-1 via2 mac2
328 #mac2-2
329 #mac1-3
330 #1-3
331 #1-1-1 via2
332 #mac0-1 via2
333 #1-1-2
334 #1-4
336 #mac2-1 via2
337 #mac0-1 via2 mac2
338 #mac2-2
341 #mac0-1 via1
343 #1-1
344 #1-2
345 #mac1-1 via1
346 #mac0-1 via1 mac1
347 #mac1-2
348 #mac2-1 via1 mac1
349 #mac0-1 via1 mac2
350 #mac2-2
351 #mac1-3
352 #1-3
353 #1-1-1 via1
354 #mac0-1 via1
355 #1-1-2
356 #1-4
358 #mac2-1 via1
359 #mac0-1 via1 mac2
360 #mac2-2
362 ex0_test behave:x_opt_input_command_stack
363 cksum_test behave:x_opt_input_command_stack "${MBOX}" '1391275936 378'
366 t_behave_X_errexit() {
367 ${cat} <<- '__EOT' > "${BODY}"
368 echo one
369 echos nono
370 echo two
371 __EOT
373 </dev/null "${SNAIL}" ${ARGS} -Snomemdebug \
374 -X'echo one' -X' echos nono ' -X'echo two' \
375 > "${MBOX}" 2>&1
376 #one
377 #classico:Unknown command: `echos'
378 #two
379 ex0_test behave:x_errexit-1
380 cksum_test behave:x_errexit-1 "${MBOX}" '2893507350 42'
382 </dev/null "${SNAIL}" ${ARGS} -X'source '"${BODY}" -Snomemdebug \
383 > "${MBOX}" 2>&1
384 ex0_test behave:x_errexit-2
385 cksum_test behave:x_errexit-2 "${MBOX}" '2893507350 42'
387 </dev/null MAILRC="${BODY}" "${SNAIL}" ${ARGS} -:u -Snomemdebug \
388 > "${MBOX}" 2>&1
389 ex0_test behave:x_errexit-3
390 cksum_test behave:x_errexit-3 "${MBOX}" '2893507350 42'
394 </dev/null "${SNAIL}" ${ARGS} -Serrexit -Snomemdebug \
395 -X'echo one' -X' echos nono ' -X'echo two' \
396 > "${MBOX}" 2>&1
397 #one
398 #classico:Unknown command: `echos'
399 exn0_test behave:x_errexit-4
400 cksum_test behave:x_errexit-4 "${MBOX}" '3287572983 38'
402 </dev/null "${SNAIL}" ${ARGS} -X'source '"${BODY}" -Serrexit -Snomemdebug \
403 > "${MBOX}" 2>&1
404 exn0_test behave:x_errexit-5
405 cksum_test behave:x_errexit-5 "${MBOX}" '3287572983 38'
407 </dev/null MAILRC="${BODY}" "${SNAIL}" ${ARGS} -:u -Serrexit -Snomemdebug \
408 > "${MBOX}" 2>&1
409 #one
410 #classico:Unknown command: `echos'
411 #classico:Alert: Stopped loading initialization resource ./.cc-body.txt due to errors (enable *debug* for trace)
412 exn0_test behave:x_errexit-6
413 cksum_test behave:x_errexit-6 "${MBOX}" '2718843754 150'
415 </dev/null MAILRC="${BODY}" "${SNAIL}" ${ARGS} -:u -Sposix -Snomemdebug \
416 > "${MBOX}" 2>&1
417 exn0_test behave:x_errexit-7
418 cksum_test behave:x_errexit-7 "${MBOX}" '2718843754 150'
420 ## Repeat 4-7 with ignerr set
422 ${sed} -e 's/^echos /ignerr echos /' < "${BODY}" > "${MBOX}"
424 </dev/null "${SNAIL}" ${ARGS} -Serrexit -Snomemdebug \
425 -X'echo one' -X'ignerr echos nono ' -X'echo two' \
426 > "${BODY}" 2>&1
427 ex0_test behave:x_errexit-8
428 cksum_test behave:x_errexit-8 "${BODY}" '2893507350 42'
430 </dev/null "${SNAIL}" ${ARGS} -X'source '"${MBOX}" -Serrexit -Snomemdebug \
431 > "${BODY}" 2>&1
432 ex0_test behave:x_errexit-9
433 cksum_test behave:x_errexit-9 "${BODY}" '2893507350 42'
435 </dev/null MAILRC="${MBOX}" "${SNAIL}" ${ARGS} -:u -Serrexit -Snomemdebug \
436 > "${BODY}" 2>&1
437 ex0_test behave:x_errexit-10
438 cksum_test behave:x_errexit-10 "${BODY}" '2893507350 42'
440 </dev/null MAILRC="${MBOX}" "${SNAIL}" ${ARGS} -:u -Sposix -Snomemdebug \
441 > "${BODY}" 2>&1
442 ex0_test behave:x_errexit-11
443 cksum_test behave:x_errexit-11 "${BODY}" '2893507350 42'
446 t_behave_wysh() {
447 ${cat} <<- '__EOT' > "${BODY}"
449 echo abcd
450 echo a'b'c'd'
451 echo a"b"c"d"
452 echo a$'b'c$'d'
453 echo 'abcd'
454 echo "abcd"
455 echo $'abcd'
456 echo a\ b\ c\ d
457 echo a 'b c' d
458 echo a "b c" d
459 echo a $'b c' d
461 echo 'a$`"\'
462 echo "a\$\`'\"\\"
463 echo $'a\$`\'\"\\'
464 echo $'a\$`\'"\\'
465 # DIET=CURD TIED=
466 echo 'a${DIET}b${TIED}c\${DIET}d\${TIED}e' # COMMENT
467 echo "a${DIET}b${TIED}c\${DIET}d\${TIED}e"
468 echo $'a${DIET}b${TIED}c\${DIET}d\${TIED}e'
470 echo a$'\101\0101\x41\u0041\u41\U00000041\U41'c
471 echo a$'\u0041\u41\u0C1\U00000041\U41'c
472 echo a$'\377'c
473 echo a$'\0377'c
474 echo a$'\400'c
475 echo a$'\0400'c
476 echo a$'\U1100001'c
478 echo a$'b\0c'd
479 echo a$'b\00c'de
480 echo a$'b\000c'df
481 echo a$'b\0000c'dg
482 echo a$'b\x0c'dh
483 echo a$'b\x00c'di
484 echo a$'b\u0'dj
485 echo a$'b\u00'dk
486 echo a$'b\u000'dl
487 echo a$'b\u0000'dm
488 echo a$'b\U0'dn
489 echo a$'b\U00'do
490 echo a$'b\U000'dp
491 echo a$'b\U0000'dq
492 echo a$'b\U00000'dr
493 echo a$'b\U000000'ds
494 echo a$'b\U0000000'dt
495 echo a$'b\U00000000'du
497 echo a$'\cI'b
498 echo a$'\011'b
499 echo a$'\x9'b
500 echo a$'\u9'b
501 echo a$'\U9'b
502 echo a$'\c@'b c d
503 __EOT
505 if [ -z "${UTF8_LOCALE}" ]; then
506 echo 'Skip behave:wysh_unicode, no UTF8_LOCALE'
507 else
508 < "${BODY}" DIET=CURD TIED= \
509 LC_ALL=${UTF8_LOCALE} "${SNAIL}" ${ARGS} 2>/dev/null > "${MBOX}"
510 #abcd
511 #abcd
512 #abcd
513 #abcd
514 #abcd
515 #abcd
516 #abcd
517 #a b c d
518 #a b c d
519 #a b c d
520 #a b c d
521 #a$`"\
522 #a$`'"\
523 #a$`'"\
524 #a$`'"\
525 #a${DIET}b${TIED}c\${DIET}d\${TIED}e
526 #aCURDbc${DIET}d${TIED}e
527 #a${DIET}b${TIED}cCURDde
528 #aAAAAAAAc
529 #aAAÁAAc
530 #aÿc
531 #aÿc
532 #abd
533 #abde
534 #abdf
535 #abdg
536 #ab\fdh
537 #abdi
538 #abdj
539 #abdk
540 #abdl
541 #abdm
542 #abdn
543 #abdo
544 #abdp
545 #abdq
546 #abdr
547 #abds
548 #abdt
549 #abdu
550 #a b
551 #a b
552 #a b
553 #a b
554 #a b
556 ex0_test behave:wysh_unicode
557 cksum_test behave:wysh_unicode "${MBOX}" '475805847 317'
560 < "${BODY}" DIET=CURD TIED= "${SNAIL}" ${ARGS} > "${MBOX}" 2>/dev/null
561 #abcd
562 #abcd
563 #abcd
564 #abcd
565 #abcd
566 #abcd
567 #abcd
568 #a b c d
569 #a b c d
570 #a b c d
571 #a b c d
572 #a$`"\
573 #a$`'"\
574 #a$`'"\
575 #a$`'"\
576 #a${DIET}b${TIED}c\${DIET}d\${TIED}e
577 #aCURDbc${DIET}d${TIED}e
578 #a${DIET}b${TIED}cCURDde
579 #aAAAAAAAc
580 #aAA\u0C1AAc
581 #aÿc
582 #aÿc
583 #abd
584 #abde
585 #abdf
586 #abdg
587 #ab\fdh
588 #abdi
589 #abdj
590 #abdk
591 #abdl
592 #abdm
593 #abdn
594 #abdo
595 #abdp
596 #abdq
597 #abdr
598 #abds
599 #abdt
600 #abdu
601 #a b
602 #a b
603 #a b
604 #a b
605 #a b
607 ex0_test behave:wysh_c
608 cksum_test behave:wysh_c "${MBOX}" '1473887148 321'
611 t_behave_input_inject_semicolon_seq() {
612 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
613 define mydeepmac {
614 echon '(mydeepmac)';
616 define mymac {
617 echon this_is_mymac;call mydeepmac;echon ';';
619 echon one';';~mymac;echon two";";call mymac;echo three$';';
620 define mymac {
621 echon this_is_mymac;call mydeepmac;echon ,TOO'!;';
623 echon one';';~mymac;echon two";";call mymac;echo three$';';
624 __EOT
625 #one;this_is_mymac(mydeepmac);two;this_is_mymac(mydeepmac);three;
626 #one;this_is_mymac(mydeepmac),TOO!;two;this_is_mymac(mydeepmac),TOO!;three;
627 ex0_test behave:input_inject_semicolon_seq
628 cksum_test behave:input_inject_semicolon_seq "${MBOX}" '512117110 140'
631 t_behave_commandalias() {
632 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
633 commandalias echo echo hoho
634 echo stop.
635 commandalias X Xx
636 commandalias Xx XxX
637 commandalias XxX XxXx
638 commandalias XxXx XxXxX
639 commandalias XxXxX XxXxXx
640 commandalias XxXxXx echo huhu
641 commandalias XxXxXxX echo huhu
643 commandalias XxXxXx XxXxXxX
645 uncommandalias echo
646 commandalias XxXxXx echo huhu
648 __EOT
649 #hoho stop.
650 #hoho huhu
651 #huhu
652 #huhu
653 ex0_test behave:commandalias
654 cksum_test behave:commandalias "${MBOX}" '3694143612 31'
657 t_behave_ifelse() {
658 # Nestable conditions test
659 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
660 if 0
661 echo 1.err
662 else
663 echo 1.ok
664 endif
665 if 1
666 echo 2.ok
667 else
668 echo 2.err
669 endif
670 if $dietcurd
671 echo 3.err
672 else
673 echo 3.ok
674 endif
675 set dietcurd=yoho
676 if $dietcurd
677 echo 4.ok
678 else
679 echo 4.err
680 endif
681 if $dietcurd == 'yoho'
682 echo 5.ok
683 else
684 echo 5.err
685 endif
686 if $dietcurd != 'yoho'
687 echo 6.err
688 else
689 echo 6.ok
690 endif
691 # Nesting
692 if faLse
693 echo 7.err1
694 if tRue
695 echo 7.err2
696 if yEs
697 echo 7.err3
698 else
699 echo 7.err4
700 endif
701 echo 7.err5
702 endif
703 echo 7.err6
704 else
705 echo 7.ok7
706 if YeS
707 echo 7.ok8
708 if No
709 echo 7.err9
710 else
711 echo 7.ok9
712 endif
713 echo 7.ok10
714 else
715 echo 7.err11
716 if yeS
717 echo 7.err12
718 else
719 echo 7.err13
720 endif
721 endif
722 echo 7.ok14
723 endif
724 if r
725 echo 8.ok1
726 if R
727 echo 8.ok2
728 else
729 echo 8.err2
730 endif
731 echo 8.ok3
732 else
733 echo 8.err1
734 endif
735 if s
736 echo 9.err1
737 else
738 echo 9.ok1
739 if S
740 echo 9.err2
741 else
742 echo 9.ok2
743 endif
744 echo 9.ok3
745 endif
746 # `elif'
747 if $dietcurd == 'yohu'
748 echo 10.err1
749 elif $dietcurd == 'yoha'
750 echo 10.err2
751 elif $dietcurd == 'yohe'
752 echo 10.err3
753 elif $dietcurd == 'yoho'
754 echo 10.ok1
755 if $dietcurd == 'yohu'
756 echo 10.err4
757 elif $dietcurd == 'yoha'
758 echo 10.err5
759 elif $dietcurd == 'yohe'
760 echo 10.err6
761 elif $dietcurd == 'yoho'
762 echo 10.ok2
763 if $dietcurd == 'yohu'
764 echo 10.err7
765 elif $dietcurd == 'yoha'
766 echo 10.err8
767 elif $dietcurd == 'yohe'
768 echo 10.err9
769 elif $dietcurd == 'yoho'
770 echo 10.ok3
771 else
772 echo 10.err10
773 endif
774 else
775 echo 10.err11
776 endif
777 else
778 echo 10.err12
779 endif
780 # integer conversion, <..>..
781 set dietcurd=10
782 if $dietcurd -lt 11
783 echo 11.ok1
784 if $dietcurd -gt 9
785 echo 11.ok2
786 else
787 echo 11.err2
788 endif
789 if $dietcurd -eq 10
790 echo 11.ok3
791 else
792 echo 11.err3
793 endif
794 if $dietcurd -ge 10
795 echo 11.ok4
796 else
797 echo 11.err4
798 endif
799 if $dietcurd -le 10
800 echo 11.ok5
801 else
802 echo 11.err5
803 endif
804 if $dietcurd -ge 11
805 echo 11.err6
806 else
807 echo 11.ok6
808 endif
809 if $dietcurd -le 9
810 echo 11.err7
811 else
812 echo 11.ok7
813 endif
814 else
815 echo 11.err1
816 endif
817 set dietcurd=Abc
818 if $dietcurd < aBd
819 echo 12.ok1
820 if $dietcurd > abB
821 echo 12.ok2
822 else
823 echo 12.err2
824 endif
825 if $dietcurd == aBC
826 echo 12.ok3
827 else
828 echo 12.err3
829 endif
830 if $dietcurd >= AbC
831 echo 12.ok4
832 else
833 echo 12.err4
834 endif
835 if $dietcurd <= ABc
836 echo 12.ok5
837 else
838 echo 12.err5
839 endif
840 if $dietcurd >= abd
841 echo 12.err6
842 else
843 echo 12.ok6
844 endif
845 if $dietcurd <= abb
846 echo 12.err7
847 else
848 echo 12.ok7
849 endif
850 else
851 echo 12.err1
852 endif
853 if $dietcurd =@ aB
854 echo 13.ok
855 else
856 echo 13.err
857 endif
858 if $dietcurd =@ bC
859 echo 14.ok
860 else
861 echo 14.err
862 endif
863 if $dietcurd !@ aB
864 echo 15.err
865 else
866 echo 15.ok
867 endif
868 if $dietcurd !@ bC
869 echo 15.err
870 else
871 echo 15.ok
872 endif
873 if $dietcurd =@ Cd
874 echo 16.err
875 else
876 echo 16.ok
877 endif
878 if $dietcurd !@ Cd
879 echo 17.ok
880 else
881 echo 17.err
882 endif
883 set diet=abc curd=abc
884 if $diet == $curd
885 echo 18.ok
886 else
887 echo 18.err
888 endif
889 set diet=abc curd=abcd
890 if $diet != $curd
891 echo 19.ok
892 else
893 echo 19.err
894 endif
895 # 1. Shitty grouping capabilities as of today
896 unset diet curd ndefined
897 if [ [ false ] || [ false ] || [ true ] ] && [ [ false ] || [ true ] ] && \
898 [ yes ]
899 echo 20.ok
900 else
901 echo 20.err
902 endif
903 if [ [ [ [ 0 ] || [ 1 ] ] && [ [ 1 ] || [ 0 ] ] ] && [ 1 ] ] && [ yes ]
904 echo 21.ok
905 else
906 echo 21.err
907 endif
908 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] ]
909 echo 22.ok
910 else
911 echo 22.err
912 endif
913 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] ]
914 echo 23.ok
915 else
916 echo 23.err
917 endif
918 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] && [ no ]
919 echo 24.err
920 else
921 echo 24.ok
922 endif
923 if [ [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] || [ [ 1 ] ] || [ 1 ] ] \
924 && [ no ] || [ yes ]
925 echo 25.ok
926 else
927 echo 25.err
928 endif
929 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
930 echo 26.ok
931 else
932 echo 26.err
933 endif
934 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 0 ] ]
935 echo 27.err
936 else
937 echo 27.ok
938 endif
939 if [ [ [ [ [ [ [ 1 ] ] && [ 1 ] ] && [ 0 ] ] && [ 1 ] ] ] && [ 1 ] ]
940 echo 28.err
941 else
942 echo 28.ok
943 endif
944 if [ [ [ [ [ [ [ 0 ] ] && [ 1 ] ] && [ 1 ] ] && [ 1 ] ] ] && [ 1 ] ]
945 echo 29.err
946 else
947 echo 29.ok
948 endif
949 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 0 ]
950 echo 30.err
951 else
952 echo 30.ok
953 endif
954 if [ 1 ] || [ 0 ] || [ 0 ] || [ 0 ] && [ 1 ]
955 echo 31.ok
956 else
957 echo 31.err
958 endif
959 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ]
960 echo 32.err
961 else
962 echo 32.ok
963 endif
964 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 1 ]
965 echo 33.ok
966 else
967 echo 33.err
968 endif
969 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 0 ]
970 echo 34.err
971 else
972 echo 34.ok
973 endif
974 if [ 0 ] || [ 0 ] || [ 0 ] || [ 1 ] && [ 0 ] || [ 1 ] && [ 1 ]
975 echo 35.ok
976 else
977 echo 35.err
978 endif
979 set diet=yo curd=ho
980 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
981 echo 36.err
982 else
983 echo 36.ok
984 endif
985 set ndefined
986 if [ [ $diet == 'yo' ] && [ $curd == 'ho' ] ] && [ $ndefined ]
987 echo 37.ok
988 else
989 echo 37.err
990 endif
991 # 2. Shitty grouping capabilities as of today
992 unset diet curd ndefined
993 if [ false || false || true ] && [ false || true ] && yes
994 echo 40.ok
995 else
996 echo 40.err
997 endif
998 if [ [ [ 0 || 1 ] && [ 1 || 0 ] ] && 1 ] && [ yes ]
999 echo 41.ok
1000 else
1001 echo 41.err
1002 endif
1003 if [ 1 || 0 || 0 || 0 ]
1004 echo 42.ok
1005 else
1006 echo 42.err
1007 endif
1008 if [ 1 || 0 || 0 || 0 || [ 1 ] ]
1009 echo 43.ok
1010 else
1011 echo 43.err
1012 endif
1013 if [ 1 || 0 || 0 || 0 || [ 1 ] || 1 ] && no
1014 echo 44.err
1015 else
1016 echo 44.ok
1017 endif
1018 if [ 1 || 0 || 0 || 0 || 1 || [ 1 ] ] && no || [ yes ]
1019 echo 45.ok
1020 else
1021 echo 45.err
1022 endif
1023 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && 1 ] ] && [ 1 ] ]
1024 echo 46.ok
1025 else
1026 echo 46.err
1027 endif
1028 if [ [ [ [ [ [ 1 ] && 1 ] && 1 ] && [ 1 ] ] ] && 0 ]
1029 echo 47.err
1030 else
1031 echo 47.ok
1032 endif
1033 if [ [ [ [ [ [ [ 1 ] ] && 1 ] && 0 ] && [ 1 ] ] ] && 1 ]
1034 echo 48.err
1035 else
1036 echo 48.ok
1037 endif
1038 if [ [ [ [ [ [ 0 ] && 1 ] && 1 ] && 1 ] ] && 1 ]
1039 echo 49.err
1040 else
1041 echo 49.ok
1042 endif
1043 if 1 || 0 || 0 || 0 && 0
1044 echo 50.err
1045 else
1046 echo 50.ok
1047 endif
1048 if 1 || 0 || 0 || 0 && 1
1049 echo 51.ok
1050 else
1051 echo 51.err
1052 endif
1053 if 0 || 0 || 0 || 1 && 0
1054 echo 52.err
1055 else
1056 echo 52.ok
1057 endif
1058 if 0 || 0 || 0 || 1 && 1
1059 echo 53.ok
1060 else
1061 echo 53.err
1062 endif
1063 if 0 || 0 || 0 || 1 && 0 || 1 && 0
1064 echo 54.err
1065 else
1066 echo 54.ok
1067 endif
1068 if 0 || 0 || 0 || 1 && 0 || 1 && 1
1069 echo 55.ok
1070 else
1071 echo 55.err
1072 endif
1073 set diet=yo curd=ho
1074 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1075 echo 56.err
1076 else
1077 echo 56.ok
1078 endif
1079 if $diet == 'yo' && $curd == 'ho' && $ndefined
1080 echo 57.err
1081 else
1082 echo 57.ok
1083 endif
1084 set ndefined
1085 if [ $diet == 'yo' && $curd == 'ho' ] && $ndefined
1086 echo 57.ok
1087 else
1088 echo 57.err
1089 endif
1090 if $diet == 'yo' && $curd == 'ho' && $ndefined
1091 echo 58.ok
1092 else
1093 echo 58.err
1094 endif
1095 if [ [ [ [ [ [ $diet == 'yo' && $curd == 'ho' && $ndefined ] ] ] ] ] ]
1096 echo 59.ok
1097 else
1098 echo 59.err
1099 endif
1100 # Some more en-braced variables
1101 set diet=yo curd=ho
1102 if ${diet} == ${curd}
1103 echo 70.err
1104 else
1105 echo 70.ok
1106 endif
1107 if ${diet} != ${curd}
1108 echo 71.ok
1109 else
1110 echo 71.err
1111 endif
1112 if $diet == ${curd}
1113 echo 72.err
1114 else
1115 echo 72.ok
1116 endif
1117 if ${diet} == $curd
1118 echo 73.err
1119 else
1120 echo 73.ok
1121 endif
1122 # Unary !
1123 if ! 0 && ! ! 1 && ! ! ! ! 2 && 3
1124 echo 80.ok
1125 else
1126 echo 80.err
1127 endif
1128 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ ! 2 ] ] ] && 3
1129 echo 81.ok
1130 else
1131 echo 81.err
1132 endif
1133 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1134 echo 82.ok
1135 else
1136 echo 82.err
1137 endif
1138 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1139 echo 83.err
1140 else
1141 echo 83.ok
1142 endif
1143 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ [ ! [ ! [ ! [ 2 ] ] ] ] ] && ! 3
1144 echo 84.err
1145 else
1146 echo 84.ok
1147 endif
1148 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1149 echo 85.err
1150 else
1151 echo 85.ok
1152 endif
1153 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] && 3
1154 echo 86.err
1155 else
1156 echo 86.ok
1157 endif
1158 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ 2 ] ] ] ] ] || 3
1159 echo 87.ok
1160 else
1161 echo 87.err
1162 endif
1163 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! ! [ 2 ] ] ] ] ]
1164 echo 88.ok
1165 else
1166 echo 88.err
1167 endif
1168 # Unary !, odd
1169 if ! 0 && ! ! 1 && ! ! ! 0 && 3
1170 echo 90.ok
1171 else
1172 echo 90.err
1173 endif
1174 if ! 0 && ! [ ! 1 ] && ! [ ! [ ! [ 0 ] ] ] && 3
1175 echo 91.ok
1176 else
1177 echo 91.err
1178 endif
1179 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ [ 0 ] ] ] ] ] && 3
1180 echo 92.ok
1181 else
1182 echo 92.err
1183 endif
1184 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! ! [ ! [ ! 0 ] ] ] ] && ! 3
1185 echo 93.err
1186 else
1187 echo 93.ok
1188 endif
1189 if [ ! 0 ] && [ ! [ ! 1 ] ] && ! [ ! [ ! [ ! [ ! 0 ] ] ] ] && 3
1190 echo 94.ok
1191 else
1192 echo 94.err
1193 endif
1194 if [ ! 0 ] && ! [ ! [ ! 1 ] ] && [ ! ! [ ! [ ! [ ! [ 0 ] ] ] ] ] && 3
1195 echo 95.err
1196 else
1197 echo 95.ok
1198 endif
1199 if ! [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! ! 0 ] ] ] ] && 3
1200 echo 96.err
1201 else
1202 echo 96.ok
1203 endif
1204 if [ ! 0 ] && [ ! [ ! 1 ] ] && [ ! [ ! [ ! [ ! [ ! 0 ] ] ] ] ] || 3
1205 echo 97.ok
1206 else
1207 echo 97.err
1208 endif
1209 if [ ! 0 ] && [ ! ! [ ! ! 1 ] ] && [ ! ! [ ! ! [ ! ! [ ! [ 0 ] ] ] ] ]
1210 echo 98.ok
1211 else
1212 echo 98.err
1213 endif
1214 __EOT
1215 ex0_test behave:if-normal
1216 cksum_test behave:if-normal "${MBOX}" '557629289 631'
1218 if have_feat regex; then
1219 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
1220 set dietcurd=yoho
1221 if $dietcurd =~ '^yo.*'
1222 echo 1.ok
1223 else
1224 echo 1.err
1225 endif
1226 if $dietcurd =~ '^yoho.+'
1227 echo 2.err
1228 else
1229 echo 2.ok
1230 endif
1231 if $dietcurd !~ '.*ho$'
1232 echo 3.err
1233 else
1234 echo 3.ok
1235 endif
1236 if $dietcurd !~ '.+yoho$'
1237 echo 4.ok
1238 else
1239 echo 4.err
1240 endif
1241 if [ $dietcurd !~ '.+yoho$' ]
1242 echo 5.ok
1243 else
1244 echo 5.err
1245 endif
1246 if ! [ $dietcurd =~ '.+yoho$' ]
1247 echo 6.ok
1248 else
1249 echo 6.err
1250 endif
1251 if ! ! [ $dietcurd !~ '.+yoho$' ]
1252 echo 7.ok
1253 else
1254 echo 7.err
1255 endif
1256 if ! [ ! [ $dietcurd !~ '.+yoho$' ] ]
1257 echo 8.ok
1258 else
1259 echo 8.err
1260 endif
1261 if [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1262 echo 9.ok
1263 else
1264 echo 9.err
1265 endif
1266 if ! [ ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1267 echo 10.err
1268 else
1269 echo 10.ok
1270 endif
1271 if ! ! ! $dietcurd !~ '.+yoho$'
1272 echo 11.err
1273 else
1274 echo 11.ok
1275 endif
1276 if ! ! ! $dietcurd =~ '.+yoho$'
1277 echo 12.ok
1278 else
1279 echo 12.err
1280 endif
1281 if ! [ ! ! [ ! [ $dietcurd !~ '.+yoho$' ] ] ]
1282 echo 13.ok
1283 else
1284 echo 13.err
1285 endif
1286 set diet=abc curd='^abc$'
1287 if $diet =~ $curd
1288 echo 14.ok
1289 else
1290 echo 14.err
1291 endif
1292 set diet=abc curd='^abcd$'
1293 if $diet !~ $curd
1294 echo 15.ok
1295 else
1296 echo 15.err
1297 endif
1298 __EOT
1299 ex0_test behave:if-regex
1300 cksum_test behave:if-regex "${MBOX}" '439960016 81'
1304 t_behave_localopts() {
1305 # Nestable conditions test
1306 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
1307 define t2 {
1308 echo in: t2
1309 set t2=t2
1310 echo $t2
1312 define t1 {
1313 echo in: t1
1314 set gv1=gv1
1315 localopts on
1316 set lv1=lv1 lv2=lv2
1317 set lv3=lv3
1318 call t2
1319 localopts off
1320 set gv2=gv2
1321 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1323 define t0 {
1324 echo in: t0
1325 call t1
1326 echo $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2
1327 echo "$gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t2"
1329 account trouble {
1330 echo in: trouble
1331 call t0
1333 call t0
1334 unset gv1 gv2
1335 account trouble
1336 echo active trouble: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1337 account null
1338 echo active null: $gv1 $lv1 ${lv2} ${lv3} ${gv2}, $t3
1339 __EOT
1340 #in: t0
1341 #in: t1
1342 #in: t2
1344 #gv1 lv1 lv2 lv3 gv2, t2
1345 #gv1 gv2,
1346 #gv1 gv2,
1347 #in: trouble
1348 #in: t0
1349 #in: t1
1350 #in: t2
1352 #gv1 lv1 lv2 lv3 gv2, t2
1353 #gv1 gv2,
1354 #gv1 gv2,
1355 #active trouble: gv1 gv2,
1356 #active null: ,
1357 ex0_test behave:localopts
1358 cksum_test behave:localopts "${MBOX}" '1936527193 192'
1361 t_behave_macro_param_shift() {
1362 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}" 2>/dev/null
1363 define t2 {
1364 echo in: t2
1365 echo t2.0 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1366 localopts on
1367 wysh set ignerr=$1
1368 shift
1369 localopts off
1370 echo t2.1 has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1371 if [ $# > 1 ] || [ $ignerr == '' ]
1372 shift 2
1373 else
1374 ignerr shift 2
1375 endif
1376 echo t2.2:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1377 shift 0
1378 echo t2.3:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1379 if [ $# > 0 ]
1380 shift
1381 endif
1382 echo t2.4:$? has $#/${#} parameters: "$1,${2},$3" (${*}) [$@]
1384 define t1 {
1385 set errexit
1386 echo in: t1
1387 call t2 1 you get four args
1388 echo t1.1: $?';' ignerr ($ignerr) should not exist
1389 call t2 1 you get 'three args'
1390 echo t1.2: $?';' ignerr ($ignerr) should not exist
1391 call t2 1 you 'get two args'
1392 echo t1.3: $?';' ignerr ($ignerr) should not exist
1393 call t2 1 'you get one arg'
1394 echo t1.4: $?';' ignerr ($ignerr) should not exist
1395 ignerr call t2 '' 'you get one arg'
1396 echo t1.5: $?';' ignerr ($ignerr) should not exist
1398 call t1
1399 __EOT
1400 #in: t1
1401 #in: t2
1402 #t2.0 has 5/5 parameters: 1,you,get (1 you get four args) [1 you get four args]
1403 #t2.1 has 4/4 parameters: you,get,four (you get four args) [you get four args]
1404 #t2.2:0 has 2/2 parameters: four,args, (four args) [four args]
1405 #t2.3:0 has 2/2 parameters: four,args, (four args) [four args]
1406 #t2.4:0 has 1/1 parameters: args,, (args) [args]
1407 #t1.1: 0; ignerr () should not exist
1408 #in: t2
1409 #t2.0 has 4/4 parameters: 1,you,get (1 you get three args) [1 you get three args]
1410 #t2.1 has 3/3 parameters: you,get,three args (you get three args) [you get three args]
1411 #t2.2:0 has 1/1 parameters: three args,, (three args) [three args]
1412 #t2.3:0 has 1/1 parameters: three args,, (three args) [three args]
1413 #t2.4:0 has 0/0 parameters: ,, () []
1414 #t1.2: 0; ignerr () should not exist
1415 #in: t2
1416 #t2.0 has 3/3 parameters: 1,you,get two args (1 you get two args) [1 you get two args]
1417 #t2.1 has 2/2 parameters: you,get two args, (you get two args) [you get two args]
1418 #t2.2:0 has 0/0 parameters: ,, () []
1419 #t2.3:0 has 0/0 parameters: ,, () []
1420 #t2.4:0 has 0/0 parameters: ,, () []
1421 #t1.3: 0; ignerr () should not exist
1422 #in: t2
1423 #t2.0 has 2/2 parameters: 1,you get one arg, (1 you get one arg) [1 you get one arg]
1424 #t2.1 has 1/1 parameters: you get one arg,, (you get one arg) [you get one arg]
1425 #t2.2:0 has 1/1 parameters: you get one arg,, (you get one arg) [you get one arg]
1426 #t2.3:0 has 1/1 parameters: you get one arg,, (you get one arg) [you get one arg]
1427 #t2.4:0 has 0/0 parameters: ,, () []
1428 #t1.4: 0; ignerr () should not exist
1429 #in: t2
1430 #t2.0 has 2/2 parameters: ,you get one arg, ( you get one arg) [ you get one arg]
1431 #t2.1 has 1/1 parameters: you get one arg,, (you get one arg) [you get one arg]
1432 #t1.5: 1; ignerr () should not exist
1433 ex0_test behave:macro_param_shift
1434 cksum_test behave:macro_param_shift "${MBOX}" '1402489146 1682'
1437 t_behave_addrcodec() {
1438 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}"
1439 vput addrcodec res e 1 <doog@def>
1440 echo $?/$^ERRNAME $res
1441 eval vput addrcodec res d $res
1442 echo $?/$^ERRNAME $res
1443 vput addrcodec res e 2 . <doog@def>
1444 echo $?/$^ERRNAME $res
1445 eval vput addrcodec res d $res
1446 echo $?/$^ERRNAME $res
1447 vput addrcodec res e 3 Sauer Dr. <doog@def>
1448 echo $?/$^ERRNAME $res
1449 eval vput addrcodec res d $res
1450 echo $?/$^ERRNAME $res
1451 vput addrcodec res e 3.50 Sauer (Ma) Dr. <doog@def>
1452 echo $?/$^ERRNAME $res
1453 eval vput addrcodec res d $res
1454 echo $?/$^ERRNAME $res
1455 vput addrcodec res e 3.51 Sauer (Ma) "Dr." <doog@def>
1456 echo $?/$^ERRNAME $res
1457 eval vput addrcodec res d $res
1458 echo $?/$^ERRNAME $res
1460 vput addrcodec res +e 4 Sauer (Ma) Dr. <doog@def>
1461 echo $?/$^ERRNAME $res
1462 eval vput addrcodec res d $res
1463 echo $?/$^ERRNAME $res
1464 vput addrcodec res +e 5 Sauer (Ma) Braten Dr. <doog@def>
1465 echo $?/$^ERRNAME $res
1466 eval vput addrcodec res d $res
1467 echo $?/$^ERRNAME $res
1468 vput addrcodec res +e 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
1469 echo $?/$^ERRNAME $res
1470 eval vput addrcodec res d $res
1471 echo $?/$^ERRNAME $res
1472 vput addrcodec res +e 7 Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu)
1473 echo $?/$^ERRNAME $res
1474 eval vput addrcodec res d $res
1475 echo $?/$^ERRNAME $res
1476 vput addrcodec res +e 8 \
1477 Dr. Sauer (Ma) Braten Dr. (Heu) <doog@def> (bu) Boom. Boom
1478 echo $?/$^ERRNAME $res
1479 eval vput addrcodec res d $res
1480 echo $?/$^ERRNAME $res
1481 vput addrcodec res +e 9 Dr.Sauer(Ma)Braten Dr. (Heu) <doog@def>
1482 echo $?/$^ERRNAME $res
1483 eval vput addrcodec res d $res
1484 echo $?/$^ERRNAME $res
1485 vput addrcodec res +e 10 (Ma)Braten Dr. (Heu) <doog@def>
1486 echo $?/$^ERRNAME $res
1487 eval vput addrcodec res d $res
1488 echo $?/$^ERRNAME $res
1489 vput addrcodec res +e 11 (Ma)Braten Dr"." (Heu) <doog@def>
1490 echo $?/$^ERRNAME $res
1491 eval vput addrcodec res d $res
1492 echo $?/$^ERRNAME $res
1493 vput addrcodec res +e 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
1494 echo $?/$^ERRNAME $res
1495 eval vput addrcodec res d $res
1496 echo $?/$^ERRNAME $res
1497 vput addrcodec res +e 13(Ma)Braten Dr. (Heu) <doog@def>
1498 echo $?/$^ERRNAME $res
1499 eval vput addrcodec res d $res
1500 echo $?/$^ERRNAME $res
1501 vput addrcodec res +e 14 Hey, Du <doog@def> Wie() findet Dr. das? ()
1502 echo $?/$^ERRNAME $res
1503 eval vput addrcodec res d $res
1504 echo $?/$^ERRNAME $res
1505 vput addrcodec res +e 15 \
1506 Hey, Du <doog@def> Wie() findet "" Dr. "" das? ()
1507 echo $?/$^ERRNAME $res
1508 eval vput addrcodec res d $res
1509 echo $?/$^ERRNAME $res
1510 vput addrcodec res +e 16 \
1511 "Hey," "Du" <doog@def> "Wie()" findet "" Dr. "" das? ()
1512 echo $?/$^ERRNAME $res
1513 eval vput addrcodec res d $res
1514 echo $?/$^ERRNAME $res
1515 vput addrcodec res +e 17 \
1516 "Hey" Du <doog@def> "Wie() findet " " Dr. """ das? ()
1517 echo $?/$^ERRNAME $res
1518 eval vput addrcodec res d $res
1519 echo $?/$^ERRNAME $res
1520 vput addrcodec res +e 18 \
1521 <doog@def> "Hey" Du "Wie() findet " " Dr. """ das? ()
1522 echo $?/$^ERRNAME $res
1523 eval vput addrcodec res d $res
1524 echo $?/$^ERRNAME $res
1525 vput addrcodec res +e 19 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1526 echo $?/$^ERRNAME $res
1527 eval vput addrcodec res d $res
1528 echo $?/$^ERRNAME $res
1530 vput addrcodec res ++e 20 Hey\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1531 echo $?/$^ERRNAME $res
1532 vput addrcodec res ++e 21 Hey\,\"" <doog@def> "Wie()" findet \" Dr. \" das?
1533 echo $?/$^ERRNAME $res
1534 eval vput addrcodec res d $res
1535 echo $?/$^ERRNAME $res
1537 vput addrcodec res +++e 22 Hey\\,\" <doog@def> "Wie()" findet \" Dr. \" das?
1538 echo $?/$^ERRNAME $res
1539 eval vput addrcodec res d $res
1540 echo $?/$^ERRNAME $res
1542 vput addrcodec res s \
1543 "23 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
1544 echo $?/$^ERRNAME $res
1545 __EOT
1546 #0/NONE 1 <doog@def>
1547 #0/NONE 1 <doog@def>
1548 #0/NONE "2 ." <doog@def>
1549 #0/NONE 2 . <doog@def>
1550 #0/NONE "3 Sauer Dr." <doog@def>
1551 #0/NONE 3 Sauer Dr. <doog@def>
1552 #0/NONE "3.50 Sauer (Ma) Dr." <doog@def>
1553 #0/NONE 3.50 Sauer (Ma) Dr. <doog@def>
1554 #0/NONE "3.51 Sauer (Ma) \"Dr.\"" <doog@def>
1555 #0/NONE 3.51 Sauer (Ma) "Dr." <doog@def>
1556 #0/NONE 4 Sauer (Ma) "Dr." <doog@def>
1557 #0/NONE 4 Sauer (Ma) Dr. <doog@def>
1558 #0/NONE 5 Sauer (Ma) "Braten Dr." <doog@def>
1559 #0/NONE 5 Sauer (Ma) Braten Dr. <doog@def>
1560 #0/NONE 6 Sauer (Ma) "Braten Dr." (Heu) <doog@def>
1561 #0/NONE 6 Sauer (Ma) Braten Dr. (Heu) <doog@def>
1562 #0/NONE 7 Sauer (Ma) "Braten Dr." (Heu bu) <doog@def>
1563 #0/NONE 7 Sauer (Ma) Braten Dr. (Heu bu) <doog@def>
1564 #0/NONE "8 Dr. Sauer" (Ma) "Braten Dr." (Heu bu) "Boom. Boom" <doog@def>
1565 #0/NONE 8 Dr. Sauer (Ma) Braten Dr. (Heu bu) Boom. Boom <doog@def>
1566 #0/NONE "9 Dr.Sauer" (Ma) "Braten Dr." (Heu) <doog@def>
1567 #0/NONE 9 Dr.Sauer (Ma) Braten Dr. (Heu) <doog@def>
1568 #0/NONE 10 (Ma) "Braten Dr." (Heu) <doog@def>
1569 #0/NONE 10 (Ma) Braten Dr. (Heu) <doog@def>
1570 #0/NONE 11 (Ma) "Braten Dr\".\"" (Heu) <doog@def>
1571 #0/NONE 11 (Ma) Braten Dr"." (Heu) <doog@def>
1572 #0/NONE "12 Dr. Sauer" (Ma) "Braten Dr." (u) <doog@def>
1573 #0/NONE 12 Dr. Sauer (Ma) Braten Dr. (u) <doog@def>
1574 #0/NONE 13 (Ma) "Braten Dr." (Heu) <doog@def>
1575 #0/NONE 13 (Ma) Braten Dr. (Heu) <doog@def>
1576 #0/NONE "14 Hey, Du Wie" () "findet Dr. das?" () <doog@def>
1577 #0/NONE 14 Hey, Du Wie () findet Dr. das? () <doog@def>
1578 #0/NONE "15 Hey, Du Wie" () "findet \"\" Dr. \"\" das?" () <doog@def>
1579 #0/NONE 15 Hey, Du Wie () findet "" Dr. "" das? () <doog@def>
1580 #0/NONE "16 \"Hey,\" \"Du\" \"Wie" () "\" findet \"\" Dr. \"\" das?" () <doog@def>
1581 #0/NONE 16 "Hey," "Du" "Wie () " findet "" Dr. "" das? () <doog@def>
1582 #0/NONE "17 \"Hey\" Du \"Wie" () "findet \" \" Dr. \"\"\" das?" () <doog@def>
1583 #0/NONE 17 "Hey" Du "Wie () findet " " Dr. """ das? () <doog@def>
1584 #0/NONE "18 \"Hey\" Du \"Wie" () "findet \" \" Dr. \"\"\" das?" () <doog@def>
1585 #0/NONE 18 "Hey" Du "Wie () findet " " Dr. """ das? () <doog@def>
1586 #0/NONE "19 Hey\\,\\\" \"Wie" () "\" findet \\\" Dr. \\\" das?" <doog@def>
1587 #0/NONE 19 Hey\,\" "Wie () " findet \" Dr. \" das? <doog@def>
1588 #1/INVAL 20 Hey\\,\\" <doog@def> "Wie()" findet \\" Dr. \\" das?
1589 #0/NONE "21 Hey\\,\\ Wie() findet \\ Dr. \\ das?" <doog@def>
1590 #0/NONE 21 Hey\,\ Wie() findet \ Dr. \ das? <doog@def>
1591 #0/NONE "22 Hey\\,\" Wie() findet \" Dr. \" das?" <doog@def>
1592 #0/NONE 22 Hey\," Wie() findet " Dr. " das? <doog@def>
1593 #0/NONE doog@def
1594 ex0_test behave:addrcodec
1595 cksum_test behave:addrcodec "${MBOX}" '429099645 2414'
1598 t_behave_vexpr() {
1599 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}" 2>/dev/null
1600 vput vexpr res = 9223372036854775807
1601 echo $?/$^ERRNAME $res
1602 vput vexpr res = 9223372036854775808
1603 echo $?/$^ERRNAME $res
1604 vput vexpr res =@ 9223372036854775808
1605 echo $?/$^ERRNAME $res
1606 vput vexpr res = -9223372036854775808
1607 echo $?/$^ERRNAME $res
1608 vput vexpr res = -9223372036854775809
1609 echo $?/$^ERRNAME $res
1610 vput vexpr res =@ -9223372036854775809
1611 echo $?/$^ERRNAME $res
1612 echo ' #1'
1613 vput vexpr res ~ 0
1614 echo $?/$^ERRNAME $res
1615 vput vexpr res ~ 1
1616 echo $?/$^ERRNAME $res
1617 vput vexpr res ~ -1
1618 echo $?/$^ERRNAME $res
1619 echo ' #2'
1620 vput vexpr res + 0 0
1621 echo $?/$^ERRNAME $res
1622 vput vexpr res + 0 1
1623 echo $?/$^ERRNAME $res
1624 vput vexpr res + 1 1
1625 echo $?/$^ERRNAME $res
1626 echo ' #3'
1627 vput vexpr res + 9223372036854775807 0
1628 echo $?/$^ERRNAME $res
1629 vput vexpr res + 9223372036854775807 1
1630 echo $?/$^ERRNAME $res
1631 vput vexpr res +@ 9223372036854775807 1
1632 echo $?/$^ERRNAME $res
1633 vput vexpr res + 0 9223372036854775807
1634 echo $?/$^ERRNAME $res
1635 vput vexpr res + 1 9223372036854775807
1636 echo $?/$^ERRNAME $res
1637 vput vexpr res +@ 1 9223372036854775807
1638 echo $?/$^ERRNAME $res
1639 echo ' #4'
1640 vput vexpr res + -9223372036854775808 0
1641 echo $?/$^ERRNAME $res
1642 vput vexpr res + -9223372036854775808 -1
1643 echo $?/$^ERRNAME $res
1644 vput vexpr res +@ -9223372036854775808 -1
1645 echo $?/$^ERRNAME $res
1646 vput vexpr res + 0 -9223372036854775808
1647 echo $?/$^ERRNAME $res
1648 vput vexpr res + -1 -9223372036854775808
1649 echo $?/$^ERRNAME $res
1650 vput vexpr res +@ -1 -9223372036854775808
1651 echo $?/$^ERRNAME $res
1652 echo ' #5'
1653 vput vexpr res - 0 0
1654 echo $?/$^ERRNAME $res
1655 vput vexpr res - 0 1
1656 echo $?/$^ERRNAME $res
1657 vput vexpr res - 1 1
1658 echo $?/$^ERRNAME $res
1659 echo ' #6'
1660 vput vexpr res - 9223372036854775807 0
1661 echo $?/$^ERRNAME $res
1662 vput vexpr res - 9223372036854775807 -1
1663 echo $?/$^ERRNAME $res
1664 vput vexpr res -@ 9223372036854775807 -1
1665 echo $?/$^ERRNAME $res
1666 vput vexpr res - 0 9223372036854775807
1667 echo $?/$^ERRNAME $res
1668 vput vexpr res - -1 9223372036854775807
1669 echo $?/$^ERRNAME $res
1670 vput vexpr res - -2 9223372036854775807
1671 echo $?/$^ERRNAME $res
1672 vput vexpr res -@ -2 9223372036854775807
1673 echo $?/$^ERRNAME $res
1674 echo ' #7'
1675 vput vexpr res - -9223372036854775808 +0
1676 echo $?/$^ERRNAME $res
1677 vput vexpr res - -9223372036854775808 +1
1678 echo $?/$^ERRNAME $res
1679 vput vexpr res -@ -9223372036854775808 +1
1680 echo $?/$^ERRNAME $res
1681 vput vexpr res - 0 -9223372036854775808
1682 echo $?/$^ERRNAME $res
1683 vput vexpr res - +1 -9223372036854775808
1684 echo $?/$^ERRNAME $res
1685 vput vexpr res -@ +1 -9223372036854775808
1686 echo $?/$^ERRNAME $res
1687 echo ' #8'
1688 vput vexpr res + -13 -2
1689 echo $?/$^ERRNAME $res
1690 vput vexpr res - 0 0
1691 echo $?/$^ERRNAME $res
1692 vput vexpr res - 0 1
1693 echo $?/$^ERRNAME $res
1694 vput vexpr res - 1 1
1695 echo $?/$^ERRNAME $res
1696 vput vexpr res - -13 -2
1697 echo $?/$^ERRNAME $res
1698 echo ' #9'
1699 vput vexpr res * 0 0
1700 echo $?/$^ERRNAME $res
1701 vput vexpr res * 0 1
1702 echo $?/$^ERRNAME $res
1703 vput vexpr res * 1 1
1704 echo $?/$^ERRNAME $res
1705 vput vexpr res * -13 -2
1706 echo $?/$^ERRNAME $res
1707 echo ' #10'
1708 vput vexpr res / 0 0
1709 echo $?/$^ERRNAME $res
1710 vput vexpr res / 0 1
1711 echo $?/$^ERRNAME $res
1712 vput vexpr res / 1 1
1713 echo $?/$^ERRNAME $res
1714 vput vexpr res / -13 -2
1715 echo $?/$^ERRNAME $res
1716 echo ' #11'
1717 vput vexpr res % 0 0
1718 echo $?/$^ERRNAME $res
1719 vput vexpr res % 0 1
1720 echo $?/$^ERRNAME $res
1721 vput vexpr res % 1 1
1722 echo $?/$^ERRNAME $res
1723 vput vexpr res % -13 -2
1724 echo $?/$^ERRNAME $res
1725 __EOT
1726 #0/NONE 9223372036854775807
1727 #1/RANGE -1
1728 #0/OVERFLOW 9223372036854775807
1729 #0/NONE -9223372036854775808
1730 #1/RANGE -1
1731 #0/OVERFLOW -9223372036854775808
1732 # #1
1733 #0/NONE -1
1734 #0/NONE -2
1735 #0/NONE 0
1736 # #2
1737 #0/NONE 0
1738 #0/NONE 1
1739 #0/NONE 2
1740 # #3
1741 #0/NONE 9223372036854775807
1742 #1/OVERFLOW -1
1743 #0/OVERFLOW 9223372036854775807
1744 #0/NONE 9223372036854775807
1745 #1/OVERFLOW -1
1746 #0/OVERFLOW 9223372036854775807
1747 # #4
1748 #0/NONE -9223372036854775808
1749 #1/OVERFLOW -1
1750 #0/OVERFLOW -9223372036854775808
1751 #0/NONE -9223372036854775808
1752 #1/OVERFLOW -1
1753 #0/OVERFLOW -9223372036854775808
1754 # #5
1755 #0/NONE 0
1756 #0/NONE -1
1757 #0/NONE 0
1758 # #6
1759 #0/NONE 9223372036854775807
1760 #1/OVERFLOW -1
1761 #0/OVERFLOW 9223372036854775807
1762 #0/NONE -9223372036854775807
1763 #0/NONE -9223372036854775808
1764 #1/OVERFLOW -1
1765 #0/OVERFLOW -9223372036854775808
1766 # #7
1767 #0/NONE -9223372036854775808
1768 #1/OVERFLOW -1
1769 #0/OVERFLOW -9223372036854775808
1770 #0/NONE -9223372036854775808
1771 #1/OVERFLOW -1
1772 #0/OVERFLOW -9223372036854775808
1773 # #8
1774 #0/NONE -15
1775 #0/NONE 0
1776 #0/NONE -1
1777 #0/NONE 0
1778 #0/NONE -11
1779 # #9
1780 #0/NONE 0
1781 #0/NONE 0
1782 #0/NONE 1
1783 #0/NONE 26
1784 # #10
1785 #1/RANGE -1
1786 #0/NONE 0
1787 #0/NONE 1
1788 #0/NONE 6
1789 # #11
1790 #1/RANGE -1
1791 #0/NONE 0
1792 #0/NONE 0
1793 #0/NONE -1
1794 ex0_test behave:vexpr-numeric
1795 cksum_test behave:vexpr-numeric "${MBOX}" '1723609217 1048'
1797 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}" #2>/dev/null
1798 vput vexpr res find 'bananarama' 'nana'
1799 echo $?/$^ERRNAME :$res:
1800 vput vexpr res find 'bananarama' 'bana'
1801 echo $?/$^ERRNAME :$res:
1802 vput vexpr res find 'bananarama' 'Bana'
1803 echo $?/$^ERRNAME :$res:
1804 vput vexpr res find 'bananarama' 'rama'
1805 echo $?/$^ERRNAME :$res:
1806 echo ' #1'
1807 vput vexpr res ifind 'bananarama' 'nana'
1808 echo $?/$^ERRNAME :$res:
1809 vput vexpr res ifind 'bananarama' 'bana'
1810 echo $?/$^ERRNAME :$res:
1811 vput vexpr res ifind 'bananarama' 'Bana'
1812 echo $?/$^ERRNAME :$res:
1813 vput vexpr res ifind 'bananarama' 'rama'
1814 echo $?/$^ERRNAME :$res:
1815 echo ' #2'
1816 vput vexpr res substring 'bananarama' 1
1817 echo $?/$^ERRNAME :$res:
1818 vput vexpr res substring 'bananarama' 3
1819 echo $?/$^ERRNAME :$res:
1820 vput vexpr res substring 'bananarama' 5
1821 echo $?/$^ERRNAME :$res:
1822 vput vexpr res substring 'bananarama' 7
1823 echo $?/$^ERRNAME :$res:
1824 vput vexpr res substring 'bananarama' 9
1825 echo $?/$^ERRNAME :$res:
1826 vput vexpr res substring 'bananarama' 10
1827 echo $?/$^ERRNAME :$res:
1828 vput vexpr res substring 'bananarama' 1 3
1829 echo $?/$^ERRNAME :$res:
1830 vput vexpr res substring 'bananarama' 3 3
1831 echo $?/$^ERRNAME :$res:
1832 vput vexpr res substring 'bananarama' 5 3
1833 echo $?/$^ERRNAME :$res:
1834 vput vexpr res substring 'bananarama' 7 3
1835 echo $?/$^ERRNAME :$res:
1836 vput vexpr res substring 'bananarama' 9 3
1837 echo $?/$^ERRNAME :$res:
1838 vput vexpr res substring 'bananarama' 10 3
1839 echo $?/$^ERRNAME :$res:
1840 echo ' #3'
1841 __EOT
1842 #0/NONE :2:
1843 #0/NONE :0:
1844 #1/NODATA ::
1845 #0/NONE :6:
1846 # #1
1847 #0/NONE :2:
1848 #0/NONE :0:
1849 #0/NONE :0:
1850 #0/NONE :6:
1851 # #2
1852 #0/NONE :ananarama:
1853 #0/NONE :anarama:
1854 #0/NONE :arama:
1855 #0/NONE :ama:
1856 #0/NONE :a:
1857 #0/NONE ::
1858 #0/NONE :ana:
1859 #0/NONE :ana:
1860 #0/NONE :ara:
1861 #0/NONE :ama:
1862 #0/OVERFLOW :a:
1863 #0/OVERFLOW ::
1864 # #3
1865 ex0_test behave:vexpr-string
1866 cksum_test behave:vexpr-string "${MBOX}" '265398700 267'
1868 if have_feat regex; then
1869 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} > "${MBOX}" #2>/dev/null
1870 vput vexpr res regex 'bananarama' 'nana'
1871 echo $?/$^ERRNAME :$res:
1872 vput vexpr res regex 'bananarama' 'bana'
1873 echo $?/$^ERRNAME :$res:
1874 vput vexpr res regex 'bananarama' 'Bana'
1875 echo $?/$^ERRNAME :$res:
1876 vput vexpr res regex 'bananarama' 'rama'
1877 echo $?/$^ERRNAME :$res:
1878 echo ' #1'
1879 vput vexpr res iregex 'bananarama' 'nana'
1880 echo $?/$^ERRNAME :$res:
1881 vput vexpr res iregex 'bananarama' 'bana'
1882 echo $?/$^ERRNAME :$res:
1883 vput vexpr res iregex 'bananarama' 'Bana'
1884 echo $?/$^ERRNAME :$res:
1885 vput vexpr res iregex 'bananarama' 'rama'
1886 echo $?/$^ERRNAME :$res:
1887 echo ' #2'
1888 vput vexpr res regex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1889 echo $?/$^ERRNAME :$res:
1890 vput vexpr res regex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1891 echo $?/$^ERRNAME :$res:
1892 vput vexpr res regex 'bananarama' 'Bana(.+)' '\$1\$0'
1893 echo $?/$^ERRNAME :$res:
1894 vput vexpr res regex 'bananarama' '(.+)rama' '\$1\$0'
1895 echo $?/$^ERRNAME :$res:
1896 echo ' #3'
1897 vput vexpr res iregex 'bananarama' '(.*)nana(.*)' '\${1}a\${0}u{\$2}'
1898 echo $?/$^ERRNAME :$res:
1899 vput vexpr res iregex 'bananarama' '(.*)bana(.*)' '\${1}a\${0}u\$2'
1900 echo $?/$^ERRNAME :$res:
1901 vput vexpr res iregex 'bananarama' 'Bana(.+)' '\$1\$0'
1902 echo $?/$^ERRNAME :$res:
1903 vput vexpr res iregex 'bananarama' '(.+)rama' '\$1\$0'
1904 echo $?/$^ERRNAME :$res:
1905 echo ' #4'
1906 __EOT
1907 #0/NONE :2:
1908 #0/NONE :0:
1909 #1/NODATA ::
1910 #0/NONE :6:
1911 # #1
1912 #0/NONE :2:
1913 #0/NONE :0:
1914 #0/NONE :0:
1915 #0/NONE :6:
1916 # #2
1917 #0/NONE :baabananaramau{rama}:
1918 #0/NONE :abananaramaunarama:
1919 #1/NODATA ::
1920 #0/NONE :bananabananarama:
1921 # #3
1922 #0/NONE :baabananaramau{rama}:
1923 #0/NONE :abananaramaunarama:
1924 #0/NONE :naramabananarama:
1925 #0/NONE :bananabananarama:
1926 # #4
1927 ex0_test behave:vexpr-regex
1928 cksum_test behave:vexpr-regex "${MBOX}" '3270360157 311'
1932 t_behave_call_ret() {
1933 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
1934 define w1 {
1935 echon ">$1 "
1936 vput vexpr i + $1 1
1937 if [ $i -le 42 ]
1938 vput vexpr j '&' $i 7
1939 if [ $j -eq 7 ]
1940 echo .
1942 call w1 $i
1943 wysh set i=$? k=$!
1944 vput vexpr j '&' $i 7
1945 echon "<$1/$i/$k "
1946 if [ $j -eq 7 ]
1947 echo .
1949 else
1950 echo ! The end for $1
1952 return $1
1954 # Transport $?/$! up the call chain
1955 define w2 {
1956 echon ">$1 "
1957 vput vexpr i + $1 1
1958 if [ $1 -lt 42 ]
1959 call w2 $i
1960 wysh set i=$? j=$!
1961 echon "<$1/$i/$j "
1962 return $i $j
1963 else
1964 echo ! The end for $1
1965 return $i $^ERR-BUSY
1967 echoerr au
1969 # Up and down it goes
1970 define w3 {
1971 echon ">$1/$2 "
1972 vput vexpr i + $1 1
1973 if [ $1 -lt 42 ]
1974 call w3 $i $2
1975 wysh set i=$? j=$!
1976 vput vexpr k - $1 $2
1977 if [ $k -eq 21 ]
1978 vput vexpr i + $1 1
1979 vput vexpr j + $2 1
1980 echo "# <$i/$j> .. "
1981 call w3 $i $j
1982 wysh set i=$? j=$!
1984 echon "<$1=$i/$j "
1985 return $i $j
1986 else
1987 vput vexpr j + $^ERR-BUSY $2
1988 echo ! The end for $1=$i/$j
1989 return $i $j
1991 echoerr au
1994 call w1 0; echo ?=$? !=$!; echo -----;
1995 call w2 0; echo ?=$? !=$!; echo -----;
1996 call w3 0 1; echo ?=$? !=$!; echo -----;
1997 __EOT
1998 ex0_test behave:call_ret
1999 cksum_test behave:call_ret "${MBOX}" '2240086482 5844'
2002 t_behave_xcall() {
2003 ${cat} <<- '__EOT' | "${SNAIL}" ${ARGS} -Snomemdebug > "${MBOX}" 2>&1
2004 define work {
2005 echon "$1 "
2006 vput vexpr i + $1 1
2007 if [ $i -le 1111 ]
2008 vput vexpr j '&' $i 7
2009 if [ $j -eq 7 ]
2010 echo .
2012 \xcall work $i $2
2014 echo ! The end for $1/$2
2015 if [ "$2" != "" ]
2016 return $i $^ERR-BUSY
2019 define xwork {
2020 \xcall work 0 $2
2022 call work 0
2023 echo ?=$? !=$!
2024 call xwork
2025 echo ?=$? !=$!
2026 xcall xwork
2027 echo ?=$? !=$!
2029 call work 0 yes
2030 echo ?=$? !=$!
2031 call xwork 0 yes
2032 echo ?=$? !=$!
2033 __EOT
2034 ex0_test behave:xcall
2035 cksum_test behave:xcall-1 "${MBOX}" '1579767783 19097'
2039 ${cat} <<- '__EOT' > "${BODY}"
2040 define __w {
2041 echon "$1 "
2042 vput vexpr i + $1 1
2043 if [ $i -le 111 ]
2044 vput vexpr j '&' $i 7
2045 if [ $j -eq 7 ]
2046 echo .
2048 \xcall __w $i $2
2050 echo ! The end for $1
2051 if [ $2 -eq 0 ]
2052 nonexistingcommand
2053 echo would be err with errexit
2054 return
2056 echo calling exit
2057 exit
2059 define work {
2060 echo eins
2061 call __w 0 0
2062 echo zwei, ?=$? !=$!
2063 localopts yes; set errexit
2064 ignerr call __w 0 0
2065 echo drei, ?=$? !=$!
2066 call __w 0 $1
2067 echo vier, ?=$? !=$!, this is an error
2069 ignerr call work 0
2070 echo outer 1, ?=$? !=$!
2071 xxxign call work 0
2072 echo outer 2, ?=$? !=$!, could be error if xxxign non-empty
2073 call work 1
2074 echo outer 3, ?=$? !=$!
2075 echo this is definitely an error
2076 __EOT
2078 < "${BODY}" "${SNAIL}" ${ARGS} -X'commandalias xxxign ignerr' -Snomemdebug \
2079 > "${MBOX}" 2>&1
2080 ex0_test behave:xcall-2
2081 cksum_test behave:xcall-2 "${MBOX}" '4079235300 4097'
2083 < "${BODY}" "${SNAIL}" ${ARGS} -X'commandalias xxxign " "' -Snomemdebug \
2084 > "${MBOX}" 2>&1
2085 exn0_test behave:xcall-3
2086 cksum_test behave:xcall-3 "${MBOX}" '1132745876 2724'
2089 t_behave_e_H_L_opts() {
2090 TRAP_EXIT_ADDONS="./.tsendmail.sh ./.t.mbox"
2092 touch ./.t.mbox
2093 "${SNAIL}" ${ARGS} -ef ./.t.mbox
2094 echo ${?} > "${MBOX}"
2096 ${cat} <<-_EOT > ./.tsendmail.sh
2097 #!/bin/sh -
2098 (echo 'From Alchemilla Wed Apr 07 17:03:33 2017' && ${cat} && echo
2099 ) >> "./.t.mbox"
2100 _EOT
2101 chmod 0755 ./.tsendmail.sh
2102 printf 'm me@exam.ple\nLine 1.\nHello.\n~.\n' |
2103 "${SNAIL}" ${ARGS} -Smta=./.tsendmail.sh
2104 printf 'm you@exam.ple\nLine 1.\nBye.\n~.\n' |
2105 "${SNAIL}" ${ARGS} -Smta=./.tsendmail.sh
2107 "${SNAIL}" ${ARGS} -ef ./.t.mbox
2108 echo ${?} >> "${MBOX}"
2109 "${SNAIL}" ${ARGS} -efL @t@me ./.t.mbox
2110 echo ${?} >> "${MBOX}"
2111 "${SNAIL}" ${ARGS} -efL @t@you ./.t.mbox
2112 echo ${?} >> "${MBOX}"
2113 "${SNAIL}" ${ARGS} -efL '@>@Line 1' ./.t.mbox
2114 echo ${?} >> "${MBOX}"
2115 "${SNAIL}" ${ARGS} -efL '@>@Hello.' ./.t.mbox
2116 echo ${?} >> "${MBOX}"
2117 "${SNAIL}" ${ARGS} -efL '@>@Bye.' ./.t.mbox
2118 echo ${?} >> "${MBOX}"
2119 "${SNAIL}" ${ARGS} -efL '@>@Good bye.' ./.t.mbox
2120 echo ${?} >> "${MBOX}"
2122 "${SNAIL}" ${ARGS} -fH ./.t.mbox >> "${MBOX}"
2123 echo ${?} >> "${MBOX}"
2124 "${SNAIL}" ${ARGS} -fL @t@me ./.t.mbox >> "${MBOX}"
2125 echo ${?} >> "${MBOX}"
2126 "${SNAIL}" ${ARGS} -fL @t@you ./.t.mbox >> "${MBOX}"
2127 echo ${?} >> "${MBOX}"
2128 "${SNAIL}" ${ARGS} -fL '@>@Line 1' ./.t.mbox >> "${MBOX}"
2129 echo ${?} >> "${MBOX}"
2130 "${SNAIL}" ${ARGS} -fL '@>@Hello.' ./.t.mbox >> "${MBOX}"
2131 echo ${?} >> "${MBOX}"
2132 "${SNAIL}" ${ARGS} -fL '@>@Bye.' ./.t.mbox >> "${MBOX}"
2133 echo ${?} >> "${MBOX}"
2134 "${SNAIL}" ${ARGS} -fL '@>@Good bye.' ./.t.mbox >> "${MBOX}" 2>/dev/null
2135 echo ${?} >> "${MBOX}"
2137 ${rm} -f ${TRAP_EXIT_ADDONS}
2138 TRAP_EXIT_ADDONS=
2148 #>N 1 Alchemilla 1996-10-02 01:50 7/112
2149 # N 2 Alchemilla 1996-10-02 01:50 7/111
2151 #>N 1 Alchemilla 1996-10-02 01:50 7/112
2153 # N 2 Alchemilla 1996-10-02 01:50 7/111
2155 #>N 1 Alchemilla 1996-10-02 01:50 7/112
2156 # N 2 Alchemilla 1996-10-02 01:50 7/111
2158 #>N 1 Alchemilla 1996-10-02 01:50 7/112
2160 # N 2 Alchemilla 1996-10-02 01:50 7/111
2163 cksum_test behave:e_H_L_opts "${MBOX}" '1708955574 678'
2166 t_behave_compose_hooks() {
2167 TRAP_EXIT_ADDONS="./.tsendmail.sh ./.tnotes"
2169 ${cat} <<-_EOT > ./.tsendmail.sh
2170 #!/bin/sh -
2171 ${rm} -f "${MBOX}"
2172 (echo 'From PrimulaVeris Wed Apr 10 22:59:00 2017' && ${cat}) > "${MBOX}"
2173 _EOT
2174 chmod 0755 ./.tsendmail.sh
2176 printf 'm hook-test@exam.ple\nbody\n~.\nvar t_oce t_ocs t_ocs_shell t_ocl' |
2177 "${SNAIL}" ${ARGS} \
2178 -Smta=./.tsendmail.sh \
2180 define t_ocs {
2181 read ver
2182 echo t_ocs
2183 echo "~^header list"; read hl; vput vexpr es substr "$hl" 0 1
2184 if [ "$es" != 2 ]
2185 echoerr "Failed to header list, aborting send"; echo "~x"
2186 endif
2187 echo "~^header insert cc splicy diet <splice@exam.ple> spliced";\
2188 read es; vput vexpr es substr "$es" 0 1
2189 if [ "$es" != 2 ]
2190 echoerr "Failed to be diet, aborting send"; echo "~x"
2191 endif
2192 echo "~^header insert bcc juicy juice <juice@exam.ple> spliced";\
2193 read es; vput vexpr es substr "$es" 0 1
2194 if [ "$es" != 2 ]
2195 echoerr "Failed to be juicy, aborting send"; echo "~x"
2196 endif
2197 echo "~:set t_ocs"
2199 define t_oce {
2200 set t_oce autobcc=oce@exam.ple
2202 define t_ocl {
2203 set t_ocl autocc=ocl@exam.ple
2205 wysh set on-compose-splice=t_ocs \
2206 on-compose-splice-shell="read ver;printf \"t_ocs-shell\\n\
2207 ~t shell@exam.ple\\n~:set t_ocs_shell\\n\"" \
2208 on-compose-enter=t_oce on-compose-leave=t_ocl
2209 ' > ./.tnotes
2210 ex0_test behave:compose_hooks
2211 ${cat} ./.tnotes >> "${MBOX}"
2213 ${rm} -f ${TRAP_EXIT_ADDONS}
2214 TRAP_EXIT_ADDONS=
2216 #From PrimulaVeris Wed Apr 10 22:59:00 2017
2217 #Date: Wed, 02 Oct 1996 01:50:07 +0000
2218 #To: hook-test@exam.ple, shell@exam.ple
2219 #Cc: ocl@exam.ple, splicy diet spliced <splice@exam.ple>
2220 #Bcc: juicy juice spliced <juice@exam.ple>, oce@exam.ple
2222 #body
2223 #t_ocs-shell
2224 #t_ocs
2225 ##variable not set: t_oce
2226 ##variable not set: t_ocs
2227 ##variable not set: t_ocs_shell
2228 ##variable not set: t_ocl
2229 cksum_test behave:compose_hooks "${MBOX}" '3240856112 319'
2232 t_behave_smime() { # FIXME add test/ dir, unroll tests therein
2233 TRAP_EXIT_ADDONS="./.t.conf ./.tkey.pem ./.tcert.pem ./.tpair.pem"
2234 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.VERIFY ./.DECRYPT ./.ENCRYPT"
2235 TRAP_EXIT_ADDONS="${TRAP_EXIT_ADDONS} ./.tsendmail.sh"
2237 printf 'behave:s/mime: .. generating test key and certificate ..\n'
2238 ${cat} <<-_EOT > ./.t.conf
2239 [ req ]
2240 default_bits = 1024
2241 default_keyfile = keyfile.pem
2242 distinguished_name = req_distinguished_name
2243 attributes = req_attributes
2244 prompt = no
2245 output_password =
2247 [ req_distinguished_name ]
2248 C = GB
2249 ST = Over the
2250 L = rainbow
2251 O = S-nail
2252 OU = S-nail.smime
2253 CN = S-nail.test
2254 emailAddress = test@localhost
2256 [ req_attributes ]
2257 challengePassword =
2258 _EOT
2259 openssl req -x509 -nodes -days 3650 -config ./.t.conf \
2260 -newkey rsa:1024 -keyout ./.tkey.pem -out ./.tcert.pem >/dev/null 2>&1
2261 ${cat} ./.tkey.pem ./.tcert.pem > ./.tpair.pem
2263 printf "behave:s/mime:sign/verify: "
2264 echo bla | "${SNAIL}" ${ARGS} \
2265 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
2266 -Ssmime-sign -Sfrom=test@localhost \
2267 -s 'S/MIME test' ./.VERIFY
2268 printf 'verify\nx\n' |
2269 "${SNAIL}" ${ARGS} \
2270 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
2271 -Ssmime-sign -Sfrom=test@localhost \
2272 -Serrexit -R \
2273 -f ./.VERIFY >/dev/null 2>&1
2274 if [ $? -eq 0 ]; then
2275 printf 'ok\n'
2276 else
2277 printf 'error: verification failed\n'
2278 ESTAT=1
2279 ${rm} -f ${TRAP_EXIT_ADDONS}
2280 TRAP_EXIT_ADDONS=
2281 return
2283 printf ' .. disproof via openssl smime(1): '
2284 if openssl smime -verify -CAfile ./.tcert.pem \
2285 -in ./.VERIFY >/dev/null 2>&1; then
2286 printf 'ok\n'
2287 else
2288 printf 'failed\n'
2289 ESTAT=1
2290 ${rm} -f ${TRAP_EXIT_ADDONS}
2291 TRAP_EXIT_ADDONS=
2292 return
2295 # (signing +) encryption / decryption
2296 ${cat} <<-_EOT > ./.tsendmail.sh
2297 #!/bin/sh -
2298 ${rm} -f ./.ENCRYPT
2299 (echo 'From S-Postman Thu May 10 20:40:54 2012' && ${cat}) > ./.ENCRYPT
2300 _EOT
2301 chmod 0755 ./.tsendmail.sh
2303 printf "behave:s/mime:encrypt+sign/decrypt+verify: "
2304 echo bla |
2305 "${SNAIL}" ${ARGS} \
2306 -Ssmime-force-encryption \
2307 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
2308 -Smta=./.tsendmail.sh \
2309 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
2310 -Ssmime-sign -Sfrom=test@localhost \
2311 -s 'S/MIME test' recei@ver.com
2312 # TODO CHECK
2313 printf 'decrypt ./.DECRYPT\nfi ./.DECRYPT\nverify\nx\n' |
2314 "${SNAIL}" ${ARGS} \
2315 -Ssmime-force-encryption \
2316 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
2317 -Smta=./.tsendmail.sh \
2318 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
2319 -Ssmime-sign -Sfrom=test@localhost \
2320 -Serrexit -R \
2321 -f ./.ENCRYPT >/dev/null 2>&1
2322 if [ $? -eq 0 ]; then
2323 printf 'ok\n'
2324 else
2325 ESTAT=1
2326 printf 'error: decryption+verification failed\n'
2328 printf ' ..disproof via openssl smime(1): '
2329 if (openssl smime -decrypt -inkey ./.tkey.pem -in ./.ENCRYPT |
2330 openssl smime -verify -CAfile ./.tcert.pem) >/dev/null 2>&1; then
2331 printf 'ok\n'
2332 else
2333 printf 'failed\n'
2334 ESTAT=1
2336 ${sed} -e '/^Date:/d' -e '/^X-Decoding-Date/d' \
2337 -e \
2338 '/^Content-Disposition: attachment; filename="smime.p7s"/,/^-- /d' \
2339 < ./.DECRYPT > ./.ENCRYPT
2340 cksum_test ".. checksum of decrypted content" "./.ENCRYPT" '3090916509 510'
2342 printf "behave:s/mime:encrypt/decrypt: "
2343 ${rm} -f ./.DECRYPT
2344 echo bla | "${SNAIL}" ${ARGS} \
2345 -Ssmime-force-encryption \
2346 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
2347 -Smta=./.tsendmail.sh \
2348 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
2349 -Sfrom=test@localhost \
2350 -s 'S/MIME test' recei@ver.com
2351 printf 'decrypt ./.DECRYPT\nx\n' | "${SNAIL}" ${ARGS} \
2352 -Ssmime-force-encryption \
2353 -Ssmime-encrypt-recei@ver.com=./.tpair.pem \
2354 -Smta=./.tsendmail.sh \
2355 -Ssmime-ca-file=./.tcert.pem -Ssmime-sign-cert=./.tpair.pem \
2356 -Sfrom=test@localhost \
2357 -Serrexit -R \
2358 -f ./.ENCRYPT >/dev/null 2>&1
2359 if [ $? -eq 0 ]; then
2360 printf 'ok\n'
2361 else
2362 ESTAT=1
2363 printf 'error: decryption failed\n'
2365 printf '.. disproof via openssl smime(1): '
2366 if openssl smime -decrypt -inkey ./.tkey.pem \
2367 -in ./.ENCRYPT >/dev/null 2>&1; then
2368 printf 'ok\n'
2369 else
2370 printf 'failed\n'
2371 ESTAT=1
2373 ${sed} -e '/^Date:/d' -e '/^X-Decoding-Date/d' \
2374 < ./.DECRYPT > ./.ENCRYPT
2375 cksum_test ".. checksum of decrypted content" ./.ENCRYPT '999887248 295'
2377 ${rm} -f ${TRAP_EXIT_ADDONS}
2378 TRAP_EXIT_ADDONS=
2381 # t_content()
2382 # Some basic tests regarding correct sending of mails, via STDIN / -t / -q,
2383 # including basic MIME Content-Transfer-Encoding correctness (quoted-printable)
2384 # Note we unfortunately need to place some statements without proper
2385 # indentation because of continuation problems
2386 t_content() {
2387 # MIME encoding (QP) stress message body
2388 printf \
2389 'Ich bin eine DÖS-Datäi mit sehr langen Zeilen und auch '\
2390 'sonst bin ich ganz schön am Schleudern, da kannste denke '\
2391 "wasde willst, gelle, gelle, gelle, gelle, gelle.\r\n"\
2392 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst \r\n"\
2393 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1\r\n"\
2394 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12\r\n"\
2395 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123\r\n"\
2396 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234\r\n"\
2397 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345\r\n"\
2398 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456\r\n"\
2399 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 1234567\r\n"\
2400 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 12345678\r\n"\
2401 "Ich bin eine DÖS-Datäi mit langen Zeilen und auch sonst 123456789\r\n"\
2402 "Unn ausserdem habe ich trailing SP/HT/SP/HT whitespace \r\n"\
2403 "Unn ausserdem habe ich trailing HT/SP/HT/SP whitespace \r\n"\
2404 "auf den zeilen vorher.\r\n"\
2405 "From am Zeilenbeginn und From der Mitte gibt es auch.\r\n"\
2406 ".\r\n"\
2407 "Die letzte Zeile war nur ein Punkt.\r\n"\
2408 "..\r\n"\
2409 "Das waren deren zwei.\r\n"\
2410 " \r\n"\
2411 "Die letzte Zeile war ein Leerschritt.\n"\
2412 "=VIER = EQUAL SIGNS=ON A LINE=\r\n"\
2413 "Prösterchen.\r\n"\
2414 ".\n"\
2415 "Die letzte Zeile war nur ein Punkt, mit Unix Zeilenende.\n"\
2416 "..\n"\
2417 "Das waren deren zwei. ditto.\n"\
2418 "Prösterchen.\n"\
2419 "Unn ausseerdem habe ich trailing SP/HT/SP/HT whitespace \n"\
2420 "Unn ausseerdem habe ich trailing HT/SP/HT/SP whitespace \n"\
2421 "auf den zeilen vorher.\n"\
2422 "ditto.\n"\
2423 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.\n"\
2424 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.1"\
2425 "\n"\
2426 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
2427 "\n"\
2428 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
2429 "3\n"\
2430 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
2431 "34\n"\
2432 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
2433 "345\n"\
2434 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende.12"\
2435 "3456\n"\
2436 "QP am Zeilenende über soft-nl hinweg\n"\
2437 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
2438 "ö123\n"\
2439 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
2440 "1ö23\n"\
2441 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
2442 "12ö3\n"\
2443 "Ich bin eine ziemlich lange, steile, scharfe Zeile mit Unix Zeilenende."\
2444 "123ö\n"\
2445 "=VIER = EQUAL SIGNS=ON A LINE=\n"\
2446 " \n"\
2447 "Die letzte Zeile war ein Leerschritt.\n"\
2448 ' '\
2449 > "${BODY}"
2451 # MIME encoding (QP) stress message subject
2452 SUB="Äbrä Kä?dä=brö Fü?di=bus? \
2453 adadaddsssssssddddddddddddddddddddd\
2454 ddddddddddddddddddddddddddddddddddd\
2455 ddddddddddddddddddddddddddddddddddd\
2456 dddddddddddddddddddd Hallelulja? Od\
2457 er?? eeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
2458 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\
2459 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee f\
2460 fffffffffffffffffffffffffffffffffff\
2461 fffffffffffffffffffff ggggggggggggg\
2462 ggggggggggggggggggggggggggggggggggg\
2463 ggggggggggggggggggggggggggggggggggg\
2464 ggggggggggggggggggggggggggggggggggg\
2465 gggggggggggggggg"
2467 # Three tests for MIME encodign and (a bit) content classification.
2468 # At the same time testing -q FILE, < FILE and -t FILE
2470 ${rm} -f "${MBOX}"
2471 < "${BODY}" "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2472 -a "${BODY}" -s "${SUB}" "${MBOX}"
2473 ex0_test content:001
2474 cksum_test content:001 "${MBOX}" '2356108758 6413'
2476 ${rm} -f "${MBOX}"
2477 < /dev/null "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2478 -a "${BODY}" -s "${SUB}" -q "${BODY}" "${MBOX}"
2479 ex0_test content:002
2480 cksum_test content:002 "${MBOX}" '2356108758 6413'
2482 ${rm} -f "${MBOX}"
2483 ( echo "To: ${MBOX}" && echo "Subject: ${SUB}" && echo &&
2484 ${cat} "${BODY}"
2485 ) | "${SNAIL}" ${ARGS} ${ADDARG_UNI} -Snodot -a "${BODY}" -t
2486 ex0_test content:003
2487 cksum_test content:003 "${MBOX}" '2356108758 6413'
2489 # Test for [260e19d] (Juergen Daubert)
2490 ${rm} -f "${MBOX}"
2491 echo body | "${SNAIL}" ${ARGS} "${MBOX}"
2492 ex0_test content:004
2493 cksum_test content:004 "${MBOX}" '4004005686 49'
2495 # Sending of multiple mails in a single invocation
2496 ${rm} -f "${MBOX}"
2497 ( printf "m ${MBOX}\n~s subject1\nE-Mail Körper 1\n~.\n" &&
2498 printf "m ${MBOX}\n~s subject2\nEmail body 2\n~.\n" &&
2499 echo x
2500 ) | "${SNAIL}" ${ARGS} ${ADDARG_UNI}
2501 ex0_test content:005
2502 cksum_test content:005 "${MBOX}" '2157252578 260'
2504 ## $BODY CHANGED
2506 # "Test for" [d6f316a] (Gavin Troy)
2507 ${rm} -f "${MBOX}"
2508 printf "m ${MBOX}\n~s subject1\nEmail body\n~.\nfi ${MBOX}\np\nx\n" |
2509 "${SNAIL}" ${ARGS} ${ADDARG_UNI} -Spipe-text/plain="${cat}" > "${BODY}"
2510 ex0_test content:006
2511 ${sed} -e 1d < "${BODY}" > "${MBOX}"
2512 cksum_test content:006 "${MBOX}" '2273863401 83'
2514 # "Test for" [c299c45] (Peter Hofmann) TODO shouldn't end up QP-encoded?
2515 ${rm} -f "${MBOX}"
2516 ${awk} 'BEGIN{
2517 for(i = 0; i < 10000; ++i)
2518 printf "\xC3\xBC"
2519 #printf "\xF0\x90\x87\x90"
2520 }' | "${SNAIL}" ${ARGS} ${ADDARG_UNI} -s TestSubject "${MBOX}"
2521 ex0_test content:007
2522 cksum_test content:007 "${MBOX}" '1754234717 61767'
2524 ## Test some more corner cases for header bodies (as good as we can today) ##
2527 ${rm} -f "${MBOX}"
2528 echo | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2529 -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̲' \
2530 "${MBOX}"
2531 ex0_test content:008
2532 cksum_test content:008 "${MBOX}" '1563381297 326'
2534 # Single word (overlong line split -- bad standard! Requires injection of
2535 # artificial data!! Bad can be prevented by using RFC 2047 encoding)
2536 ${rm} -f "${MBOX}"
2537 i=`${awk} 'BEGIN{for(i=0; i<92; ++i) printf "0123456789_"}'`
2538 echo | "${SNAIL}" ${ARGS} -s "${i}" "${MBOX}"
2539 ex0_test content:009
2540 cksum_test content:009 "${MBOX}" '1996714851 1669'
2542 # Combination of encoded words, space and tabs of varying sort
2543 ${rm} -f "${MBOX}"
2544 echo | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2545 -s "1Abrä Kaspas1 2Abra Katä b_kaspas2 \
2546 3Abrä Kaspas3 4Abrä Kaspas4 5Abrä Kaspas5 \
2547 6Abra Kaspas6 7Abrä Kaspas7 8Abra Kaspas8 \
2548 9Abra Kaspastäb4-3 10Abra Kaspas1 _ 11Abra Katäb1 \
2549 12Abra Kadabrä1 After Tab after Täb this is NUTS" \
2550 "${MBOX}"
2551 ex0_test content:010
2552 cksum_test content:010 "${MBOX}" '2956039469 542'
2554 # Overlong multibyte sequence that must be forcefully split
2555 # todo This works even before v15.0, but only by accident
2556 ${rm} -f "${MBOX}"
2557 echo | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2558 -s "✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
2559 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄\
2560 ✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄✄" \
2561 "${MBOX}"
2562 ex0_test content:011
2563 cksum_test content:011 "${MBOX}" '454973928 610'
2565 # Trailing WS
2566 ${rm} -f "${MBOX}"
2567 echo | "${SNAIL}" ${ARGS} \
2568 -s "1-1 B2 B3 B4 B5 B6 B\
2569 1-2 B2 B3 B4 B5 B6 B\
2570 1-3 B2 B3 B4 B5 B6 B\
2571 1-4 B2 B3 B4 B5 B6 B\
2572 1-5 B2 B3 B4 B5 B6 B\
2573 1-6 B2 B3 B4 B5 B6 " \
2574 "${MBOX}"
2575 ex0_test content:012
2576 cksum_test content:012 "${MBOX}" '1014122962 248'
2578 # Leading and trailing WS
2579 ${rm} -f "${MBOX}"
2580 echo | "${SNAIL}" ${ARGS} \
2581 -s " 2-1 B2 B3 B4 B5 B6 B\
2582 1-2 B2 B3 B4 B5 B6 B\
2583 1-3 B2 B3 B4 B5 B6 B\
2584 1-4 B2 B3 B4 B5 B6 " \
2585 "${MBOX}"
2586 ex0_test content:013
2587 cksum_test content:013 "${MBOX}" '3212167908 187'
2589 # Quick'n dirty RFC 2231 test; i had more when implementing it, but until we
2590 # have a (better) test framework materialize a quick shot
2591 ${rm} -f "${MBOX}"
2592 TRAP_EXIT_ADDONS=./.ttt
2594 mkdir ./.ttt || exit 1
2595 cd ./.ttt || exit 2
2596 : > "ma'ger.txt"
2597 : > "mä'ger.txt"
2598 : > 'diet\ is \curd.txt'
2599 : > 'diet "is" curd.txt'
2600 : > höde-tröge.txt
2601 : > 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
2602 : > höde__tröge__müde__dätte__hätte__vuelle__guelle__aese__aesse__sauerliche__kräuter__österliche__grüße__mäh.txt
2603 : > hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt
2604 : > ✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt
2606 echo bla | "${SNAIL}" ${ARGS} ${ADDARG_UNI} \
2607 -a "./.ttt/ma'ger.txt" -a "./.ttt/mä'ger.txt" \
2608 -a './.ttt/diet\ is \curd.txt' -a './.ttt/diet "is" curd.txt' \
2609 -a ./.ttt/höde-tröge.txt \
2610 -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 \
2611 -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 \
2612 -a ./.ttt/hööööööööööööööööö_nöööööööööööööööööööööö_düüüüüüüüüüüüüüüüüüü_bäääääääääääääääääääääääh.txt \
2613 -a ./.ttt/✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆✆.txt \
2614 "${MBOX}"
2615 ex0_test content:014-1
2616 ${rm} -rf ./.ttt
2617 cksum_test content:014-1 "${MBOX}" '589846634 2491'
2618 # `resend' test
2619 printf "Resend ${BODY}\nx\n" | "${SNAIL}" ${ARGS} -f "${MBOX}"
2620 ex0_test content:014-2
2621 cksum_test content:014-2 "${MBOX}" '589846634 2491'
2624 t_all() {
2625 if have_feat devel; then
2626 ARGS="${ARGS} -Smemdebug"
2627 export ARGS
2629 t_behave
2630 t_content
2633 if [ -z "${CHECK_ONLY}" ]; then
2634 cc_all_configs
2635 else
2636 t_all
2639 [ ${ESTAT} -eq 0 ] && echo Ok || echo >&2 'Errors occurred'
2641 exit ${ESTAT}
2642 # s-sh-mode