diff options
author | 2017-11-21 19:25:46 +0000 | |
---|---|---|
committer | 2017-11-21 19:25:46 +0000 | |
commit | aaf5d128b83cf6e713121ac90e14682a57a7c5ba (patch) | |
tree | 9046b6ad2197d99e6c39b5f1d9ce2c460b98f4e3 /regress/bin | |
parent | Do not exit 0 if the program was terminated due to receipt of a signal other (diff) | |
download | wireguard-openbsd-aaf5d128b83cf6e713121ac90e14682a57a7c5ba.tar.xz wireguard-openbsd-aaf5d128b83cf6e713121ac90e14682a57a7c5ba.zip |
Add tests for emacs editing mode in ksh. While here, improve the output on test
failure.
Diffstat (limited to 'regress/bin')
-rw-r--r-- | regress/bin/ksh/edit/emacs.sh | 236 | ||||
-rw-r--r-- | regress/bin/ksh/edit/subr.sh | 21 |
2 files changed, 245 insertions, 12 deletions
diff --git a/regress/bin/ksh/edit/emacs.sh b/regress/bin/ksh/edit/emacs.sh index bf387943728..d9db5474c68 100644 --- a/regress/bin/ksh/edit/emacs.sh +++ b/regress/bin/ksh/edit/emacs.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# $OpenBSD: emacs.sh,v 1.9 2017/08/22 20:14:57 anton Exp $ +# $OpenBSD: emacs.sh,v 1.10 2017/11/21 19:25:46 anton Exp $ # # Copyright (c) 2017 Anton Lindqvist <anton@openbsd.org> # Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> @@ -93,3 +93,237 @@ testseq "z\0002\0364\0277\0277\0277" \ # insertion of unmatched meta sequence testseq "z\0002\0033[3z" " # z\b\0007" + +# ^C, ^G: abort +testseq "echo 1\0003" " # echo 1\r\n # " +testseq "echo 1\0007" " # echo 1\r\n # " + +# ^B, Left: backward-char +testseq "\0002" " # \0007" +testseq "a\0002" " # a\0010" +testseq "\0303\0266\0002" " # \0303\0266\0010" +testseq "a\0033[D" " # a\0010" +testseq "a\0033OD" " # a\0010" + +# ^[b, Ctrl-Left: backward-word +testseq "\0033b" " # \0007" +testseq "a1_$\0033b" " # a1_$\0010\0010\0010\0010" +testseq "a1 \0303\0266\0033b\0033b" " # a1 \0303\0266\0010\0010\0010\0010" +testseq "a1_$\0033[1;5D" " # a1_$\0010\0010\0010\0010" + +# ^[<: beginning-of-history +testseq "\0033<" " # \0007" +testseq ": 1\n: 2\n\0033<" " # : 1\r\r\n # : 2\r\r\n # \r # : 1 \0010" + +# ^A, Home, Ctrl-Down: beginning-of-line +testseq "\0001" " # " +testseq "aa\0001" " # aa\0010\0010" +testseq "\0303\0266\0001" " # \0303\0266\0010" +testseq "aa\0033[H" " # aa\0010\0010" +testseq "aa\0033OH" " # aa\0010\0010" +testseq "aa\0033[1~" " # aa\0010\0010" +testseq "aa\0033[1;5B" " # aa\0010\0010" + +# [n] ^[C, ^[c: capitalize-word +testseq "\0033C\0033c" " # \0007\0007" +testseq "ab cd\0001\0033C" " # ab cd\0010\0010\0010\0010\0010Ab" +testseq "ab\0001\00332\0033C" " # ab\0010\0010Ab" +testseq "ab cd\0001\00332\0033C" " # ab cd\0010\0010\0010\0010\0010Ab Cd" +testseq "1a\0001\0033C" " # 1a\0010\00101a" +testseq "\0026\0002\0001\0033C" " # ^B\0010\0010^B" +testseq "\0303\0266b\0001\0033C" " # \0303\0266b\0010\0010\0303\0266b" + +# ^[#: comment +testseq "\0033#" " # \r # \0010\r\r\n # " +testseq "a\0033#" " # a\r # #a \0010\0010\0010\r\r\n # " + +# XXX ^[^[: complete +# XXX ^X^[: complete-command +# XXX ^[^X: complete-file +# XXX ^I, ^[=: complete-list + +# [n] ERASE, ^?, ^H: delete-char-backward +testseq "\0177\0010" " # \0007\0007" +testseq "ab\00332\0177" " # ab\0010\0010 \0010\0010" +testseq "a\00332\0177" " # a\0010 \0010" +testseq "\0303\0266\0177" " # \0303\0266\0010 \0010" + +# [n] Delete: delete-char-forward +testseq "\0033[3~" " # \0007" +testseq "a\0033[3~" " # a\0007" +testseq "a\0001\0033[3~" " # a\0010 \0010" +testseq "ab\0001\00332\0033[3~" " # ab\0010\0010 \0010\0010" +testseq "a\0001\00332\0033[3~" " # a\0010 \0010" +testseq "\0303\0266\0001\0033[3~" " # \0303\0266\0010 \0010" + +# [n] ^[ERASE, ^[^?, ^[^H, ^[h: delete-word-backward +testseq "\0033\0177\033\0010\0033h" " # \0007\0007\0007" +testseq "ab\0033\0177" " # ab\0010\0010 \0010\0010" +testseq "ab cd\00332\0033\0177" \ + " # ab cd\0010\0010\0010\0010\0010 \0010\0010\0010\0010\0010" +testseq "ab\00332\0033\0177" " # ab\0010\0010 \0010\0010" +testseq "ab \0303\0266\0033\0177" " # ab \0303\0266\0010 \0010" + +# [n] ^[d: delete-word-forward +testseq "\0033d" " # \0007" +testseq "ab\0001\0033d" " # ab\0010\0010 \0010\0010" +testseq "ab cd\0001\00332\0033d" \ + " # ab cd\0010\0010\0010\0010\0010 \0010\0010\0010\0010\0010" +testseq "ab\0001\00332\0033d" " # ab\0010\0010 \0010\0010" + +# [n] ^N, ^XB, Down: down-history +# [n] ^P, ^XA, Up: up-history +testseq "\0016\0030B\0020\0030A" " # \0007\0007\0007\0007" +testseq ": 1\n\0020\0016" " # : 1\r\r\n # \r # : 1 \0010\0007" +testseq ": 1\n: 2\n\0020\0020\0016" \ + " # : 1\r\r\n # : 2\r\r\n # \r # : 2 \0010\r # : 1 \0010\r # : 2 \0010" +testseq ": 1\n: 2\n\0033[A\0033[A\0033[B" \ + " # : 1\r\r\n # : 2\r\r\n # \r # : 2 \0010\r # : 1 \0010\r # : 2 \0010" +testseq ": 1\n: 2\n\0033OA\0033OA\0033OB" \ + " # : 1\r\r\n # : 2\r\r\n # \r # : 2 \0010\r # : 1 \0010\r # : 2 \0010" + +# [n] ^[L, ^[l: downcase-word +testseq "\0033L\0033l" " # \0007\0007" +testseq "AB\0001\0033L" " # AB\0010\0010ab" +testseq "AB CD\0001\00332\0033L" " # AB CD\0010\0010\0010\0010\0010ab cd" +testseq "AB\0001\00332\0033L" " # AB\0010\0010ab" +testseq "1A\0001\0033L" " # 1A\0010\00101a" +testseq "\0026\0002A\0001\0033L" " # ^BA\0010\0010\0010^Ba" +testseq "\0303\0266A\0001\0033L" " # \0303\0266A\0010\0010\0303\0266a" + +# ^[>: end-of-history +testseq "\0033>" " # \0007" +testseq ": 1\n\0033>" " # : 1\r\r\n # \r # : 1 \0010" + +# ^E, End, Ctrl-Up: end-of-line +testseq "\0005" " # " +testseq "abc\0001\0005" " # abc\0010\0010\0010abc" +testseq "\0303\0266\0001\0005" " # \0303\0266\0010\0303\0266" +testseq "abc\0001\0033[F" " # abc\0010\0010\0010abc" +testseq "abc\0001\0033OF" " # abc\0010\0010\0010abc" +testseq "abc\0001\0033[4~" " # abc\0010\0010\0010abc" +testseq "abc\0001\0033[1;5A" " # abc\0010\0010\0010abc" + +# ^_: eot +testseq "\0037" " # ^D\r\r" + +# [n] ^D: eot-or-delete +testseq "\0004" " # ^D\r\r" + +# ^X^X: exchange-point-and-mark +# ^[space: set-mark-command +testseq "\0030\0030" " # \0007" +testseq "abc\0033 \0001\0030\0030" " # abc\0010\0010\0010abc" +testseq "\0303\0266\0033 \0001\0030\0030" " # \0303\0266\0010\0303\0266" + +# XXX ^[*: expand-file + +# [n] ^F, ^XC, Right: forward-char +testseq "\0006\0030C" " # \0007\0007" +testseq "abc\0001\0006" " # abc\0010\0010\0010a" +testseq "abc\0001\00332\0006" " # abc\0010\0010\0010ab" +testseq "a\0001\00332\0006" " # a\0010a" +testseq "\0303\0266\0001\0006" " # \0303\0266\0010\0303\0266" +testseq "abc\0001\0033[C" " # abc\0010\0010\0010a" +testseq "abc\0001\0033OC" " # abc\0010\0010\0010a" + +# [n] ^[f, Ctrl-Right: forward-word +testseq "\0033f" " # \0007" +testseq "ab\0001\0033f" " # ab\0010\0010ab" +testseq "ab cd\0001\00332\0033f" " # ab cd\0010\0010\0010\0010\0010ab cd" +testseq "ab\0001\00332\0033f" " # ab\0010\0010ab" +testseq "\0303\0266\0001\0033f" " # \0303\0266\0010\0303\0266" +testseq "ab\0001\0033[1;5C" " # ab\0010\0010ab" + +# [n] ^[g: goto-history +testseq "\0033g" " # \0007" +testseq ": 1\n\0033g" " # : 1\r\r\n # \r # : 1 \0010" +testseq ": 1\n: 2\n\00332\0033g" " # : 1\r\r\n # : 2\r\r\n # \r # : 2 \0010" +testseq ": 1\n\00332\0033g" " # : 1\r\r\n # \0007" + +# KILL: kill-line +testseq "\0025" " # \r # \0010" +testseq "ab\0025" " # ab\r # \0010\0010\0010" + +# [n] ^K: kill-to-eol +testseq "\0013" " # " +testseq "abc\0002\0002\0013" " # abc\0010\0010 \0010\0010" + +# XXX ^[?: list +# XXX ^X?: list-command +# XXX ^X^Y: list-file + +# ^J, ^M: newline +testseq "\0012\0015" " # \r\r\n # \r\r\n # " +testseq ": 1\0012" " # : 1\r\r\n # " +testseq ": 1\0001\0012" " # : 1\0010\0010\0010\r\r\n # " + +# ^O: newline-and-next +testseq "\0017" " # \r\r\n # \0007" +testseq ": 1\n: 2\n\0020\0020\0017" \ + " # : 1\r\r\n # : 2\r\r\n # \r # : 2 \0010\r # : 1 \0010\r\r\n # \r # : 2 \0010" + +# QUIT: no-op +testseq "\0034" " # " + +# [n] ^[., ^[_: prev-hist-word +testseq "\0033.\0033_" " # \0007\0007" +testseq ": 1\n\0033." " # : 1\r\r\n # 1" +testseq ": 1\n\00331\0033." " # : 1\r\r\n # :" +testseq ": 1\n\00333\0033." " # : 1\r\r\n # " + +# ^V, ^^: quote +testseq "\0026\0001" " # ^A" +testseq "\0036\0001" " # ^A" + +# ^L: redraw +testseq "\0014" " # \r\n # " +testseq "echo\0014" " # echo\r\n # echo" + +# [n] ^[^]: search-character-backward +testseq "\0033\0035a" " # \0007" +testseq "echo\0033\0035e" " # echo\0010\0010\0010\0010" +testseq "echo\0033\0035a" " # echo\0007" +testseq "eecho\00332\0033\0035e" " # eecho\0010\0010\0010\0010\0010" +testseq "echo\00332\0033\0035e" " # echo\0007" + +# [n] ^]: search-character-forward +testseq "\0035a" " # \0007" +testseq "echo\0001\0035o" " # echo\0010\0010\0010\0010ech" +testseq "echo\0001\0035a" " # echo\0010\0010\0010\0010\0007" +testseq "echoo\0001\00332\0035o" " # echoo\0010\0010\0010\0010\0010echo" +# XXX differs from search-character-backward, should ring bell +testseq "echo\0001\00332\0035o" " # echo\0010\0010\0010\0010ech" + +# ^R: search-history +testseq "\0022" " # \r\nI-search: " +testseq "echo\n\0022e" \ + " # echo\r\r\n\r\n # \r\nI-search: \r\n\r # echo \0010\0010\0010\0010" +testseq "echo\n\0022a" " # echo\r\r\n\r\n # \r\nI-search: \0007\r\nI-search: a" + +# ^T: transpose-chars +testseq "\0024" " # \0007" +testseq "a\0024" " # a\0007" +testseq "ab\0024" " # ab\0010\0010ba" +testseq "ab\0001\0024" " # ab\0010\0010\0007" +# XXX UTF-8 testseq "\0303\0266a\0024" " # \0303\0266a\0010\0010a\303\0266" + +# [n] ^[U, ^[u: upcase-word +testseq "\0033U\0033u" " # \0007\0007" +testseq "ab\0001\0033U" " # ab\0010\0010AB" +testseq "ab cd\0001\00332\0033U" " # ab cd\0010\0010\0010\0010\0010AB CD" +testseq "ab\0001\00332\0033U" " # ab\0010\0010AB" +testseq "1a\0001\0033U" " # 1a\0010\00101A" +testseq "\0026\0002a\0001\0033U" " # ^Ba\0010\0010\0010^BA" +testseq "\0303\0266a\0001\0033U" " # \0303\0266a\0010\0010\0303\0266A" + +# ^Y: yank +testseq "\0031" " # \r\nnothing to yank\r\n # " +testseq "abc\0027\0031" " # abc\0010\0010\0010 \0010\0010\0010abc" +testseq "ab/cd\0027\0001\0031" \ + " # ab/cd\0010\0010 \0010\0010\0010\0010\0010cdab/\0010\0010\0010" + +# ^[y: yank-pop +testseq "\0033y" " # \r\nyank something first\r\n # " +testseq "ab/cd\0027\0027\0031\0033y" \ + " # ab/cd\0010\0010 \0010\0010\0010\0010\0010 \0010\0010\0010ab/\0010\0010\0010 \0010\0010\0010cd" diff --git a/regress/bin/ksh/edit/subr.sh b/regress/bin/ksh/edit/subr.sh index 14fcb9dd087..b24253d6d69 100644 --- a/regress/bin/ksh/edit/subr.sh +++ b/regress/bin/ksh/edit/subr.sh @@ -1,4 +1,4 @@ -# $OpenBSD: subr.sh,v 1.7 2017/08/22 20:14:57 anton Exp $ +# $OpenBSD: subr.sh,v 1.8 2017/11/21 19:25:46 anton Exp $ # # Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> # Copyright (c) 2017 Anton Lindqvist <anton@openbsd.org> @@ -18,18 +18,17 @@ testseq() { stdin=$1 exp=$(echo "$2") - act=$(echo -n "$stdin" | ./edit -p "$PS1" ${KSH:-/bin/ksh} -r) + act=$(echo -n "$stdin" | ./edit -p "$PS1" ${KSH:-/bin/ksh} -r 2>&1) [ $? = 0 ] && [ "$exp" = "$act" ] && return 0 - echo input: - echo ">>>$stdin<<<" - echo -n "$stdin" | hexdump -Cv - echo expected: - echo ">>>$exp<<<" - echo -n "$exp" | hexdump -Cv - echo actual: - echo ">>>$act<<<" - echo -n "$act" | hexdump -Cv + dump input "$stdin" + dump expected "$exp" + dump actual "$act" exit 1 } + +dump() { + printf '%s:\n>>>%s<<<\n' "$1" "$(echo -n "$2" | vis -ol)" + echo -n "$2" | hexdump -Cv +} |