3 # These are not ash tests, we use ash as a way to test lineedit!
5 # Copyright 2010 by Denys Vlasenko
6 # Licensed under GPLv2, see file LICENSE in this source tree.
9 test -f "$bindir/.config" && .
"$bindir/.config"
11 test x
"CONFIG_SCRIPT" = x
"y" ||
exit 0
12 test x
"CONFIG_HEXDUMP" = x
"y" ||
exit 0
13 test x
"CONFIG_FEATURE_DEVPTS" = x
"y" ||
exit 0
15 # testing "test name" "options" "expected result" "file input" "stdin"
17 if test x
"$CONFIG_UNICODE_PRESERVE_BROKEN" = x
"y"; then
18 testing
"One byte which is not valid unicode char followed by valid input" \
19 "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \
21 00000000 ff 2d 0a |.-.|
25 "echo \xff- | hexdump -C >ash.output; exit; exit; exit; exit\n"
27 testing
"30 bytes which are not valid unicode chars followed by valid input" \
28 "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \
30 00000000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
31 00000010 ff ff ff ff ff ff ff ff ff ff ff ff ff ff 2d 0a |..............-.|
35 "echo \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff- | hexdump -C >ash.output; exit; exit; exit; exit\n"
37 testing
"One byte which is not valid unicode char followed by valid input" \
38 "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \
40 00000000 3f 2d 0a |?-.|
44 "echo \xff- | hexdump -C >ash.output; exit; exit; exit; exit\n"
46 testing
"30 bytes which are not valid unicode chars followed by valid input" \
47 "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \
49 00000000 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f |????????????????|
50 00000010 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 2d 0a |??????????????-.|
54 "echo \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff- | hexdump -C >ash.output; exit; exit; exit; exit\n"
58 # Not sure this behavior is perfect: we lose all invalid input which precedes
59 # arrow keys and such. In this example, \xff\xff are lost
60 testing
"2 bytes which are not valid unicode chars followed by left arrow key" \
61 "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \
63 00000000 3d 2d 0a |=-.|
67 "echo =+\xff\xff\x1b\x5b\x44- | hexdump -C >ash.output; exit; exit; exit; exit\n"
69 # ash should see "echo \xff\n",pause -> execute it as "echo ?" (which is
70 # not checked by the test), then read and execute the rest: "echo A | ..."
71 # The bug was that ash was eating the beginning of "echo A" despite the pause.
72 testing
"Invalid unicode chars followed by a pause do not eat next chars" \
73 "{ $ECHO -ne 'echo \xff\n'; sleep 1; $ECHO -ne 'echo A | hexdump -C >ash.output; exit; exit; exit; exit\n'; } \
74 | script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \