3 # These are not ash tests, we use ash as a way to test lineedit!
5 # Copyright 2010 by Denys Vlasenko
6 # Licensed under GPL v2, see file LICENSE for details.
10 test -f "$bindir/.config" && . "$bindir/.config"
12 # testing "test name" "options" "expected result" "file input" "stdin"
14 if test x"$CONFIG_UNICODE_PRESERVE_BROKEN" = x"y"; then
15 testing "One byte which is not valid unicode char followed by valid input" \
16 "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \
18 00000000 ff 2d 0a |.-.|
22 "echo \xff- | hexdump -C >ash.output; exit; exit; exit; exit\n"
24 testing "30 bytes which are not valid unicode chars followed by valid input" \
25 "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \
27 00000000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
28 00000010 ff ff ff ff ff ff ff ff ff ff ff ff ff ff 2d 0a |..............-.|
32 "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"
34 testing "One byte which is not valid unicode char followed by valid input" \
35 "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \
37 00000000 3f 2d 0a |?-.|
41 "echo \xff- | hexdump -C >ash.output; exit; exit; exit; exit\n"
43 testing "30 bytes which are not valid unicode chars followed by valid input" \
44 "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \
46 00000000 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f |????????????????|
47 00000010 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 2d 0a |??????????????-.|
51 "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"
55 # Not sure this behavior is perfect: we lose all invalid input which precedes
56 # arrow keys and such. In this example, \xff\xff are lost
57 testing "2 bytes which are not valid unicode chars followed by left arrow key" \
58 "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \
60 00000000 3d 2d 0a |=-.|
64 "echo =+\xff\xff\x1b\x5b\x44- | hexdump -C >ash.output; exit; exit; exit; exit\n"
66 # ash should see "echo \xff\n",pause -> execute it as "echo ?" (which is
67 # not checked by the test), then read and execute the rest: "echo A | ..."
68 # The bug was that ash was eating the beginning of "echo A" despite the pause.
69 testing "Invalid unicode chars followed by a pause do not eat next chars" \
70 "{ echo -ne 'echo \xff\n'; sleep 1; echo -ne 'echo A | hexdump -C >ash.output; exit; exit; exit; exit\n'; } \
71 | script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \