Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # These are not ash tests, we use ash as a way to test lineedit! |
| 4 | # |
| 5 | # Copyright 2010 by Denys Vlasenko |
| 6 | # Licensed under GPL v2, see file LICENSE for details. |
| 7 | |
| 8 | . ./testing.sh |
Tomas Heinrich | a659b81 | 2010-04-29 13:43:39 +0200 | [diff] [blame] | 9 | test -f "$bindir/.config" && . "$bindir/.config" |
| 10 | |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 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 |
| 14 | |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 15 | # testing "test name" "options" "expected result" "file input" "stdin" |
| 16 | |
Tomas Heinrich | a659b81 | 2010-04-29 13:43:39 +0200 | [diff] [blame] | 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" \ |
| 20 | "\ |
| 21 | 00000000 ff 2d 0a |.-.| |
| 22 | 00000003 |
| 23 | " \ |
| 24 | "" \ |
| 25 | "echo \xff- | hexdump -C >ash.output; exit; exit; exit; exit\n" |
| 26 | |
| 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" \ |
| 29 | "\ |
| 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 |..............-.| |
| 32 | 00000020 |
| 33 | " \ |
| 34 | "" \ |
| 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" |
| 36 | else |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 37 | testing "One byte which is not valid unicode char followed by valid input" \ |
Denys Vlasenko | 58f108e | 2010-03-11 21:17:55 +0100 | [diff] [blame] | 38 | "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \ |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 39 | "\ |
| 40 | 00000000 3f 2d 0a |?-.| |
| 41 | 00000003 |
| 42 | " \ |
| 43 | "" \ |
Denys Vlasenko | 58f108e | 2010-03-11 21:17:55 +0100 | [diff] [blame] | 44 | "echo \xff- | hexdump -C >ash.output; exit; exit; exit; exit\n" |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 45 | |
| 46 | testing "30 bytes which are not valid unicode chars followed by valid input" \ |
Denys Vlasenko | 58f108e | 2010-03-11 21:17:55 +0100 | [diff] [blame] | 47 | "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \ |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 48 | "\ |
| 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 |??????????????-.| |
| 51 | 00000020 |
| 52 | " \ |
| 53 | "" \ |
Denys Vlasenko | 58f108e | 2010-03-11 21:17:55 +0100 | [diff] [blame] | 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" |
Tomas Heinrich | a659b81 | 2010-04-29 13:43:39 +0200 | [diff] [blame] | 55 | fi |
| 56 | |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 57 | |
| 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" \ |
Denys Vlasenko | 58f108e | 2010-03-11 21:17:55 +0100 | [diff] [blame] | 61 | "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \ |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 62 | "\ |
| 63 | 00000000 3d 2d 0a |=-.| |
| 64 | 00000003 |
| 65 | " \ |
| 66 | "" \ |
Denys Vlasenko | 58f108e | 2010-03-11 21:17:55 +0100 | [diff] [blame] | 67 | "echo =+\xff\xff\x1b\x5b\x44- | hexdump -C >ash.output; exit; exit; exit; exit\n" |
| 68 | |
| 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" \ |
Denys Vlasenko | e82cf33 | 2010-05-12 15:59:32 +0200 | [diff] [blame] | 73 | "{ $ECHO -ne 'echo \xff\n'; sleep 1; $ECHO -ne 'echo A | hexdump -C >ash.output; exit; exit; exit; exit\n'; } \ |
Denys Vlasenko | 58f108e | 2010-03-11 21:17:55 +0100 | [diff] [blame] | 74 | | script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \ |
| 75 | "\ |
| 76 | 00000000 41 0a |A.| |
| 77 | 00000002 |
| 78 | " \ |
| 79 | "" "" |
| 80 | |
| 81 | rm ash.output |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 82 | |
| 83 | exit $FAILCOUNT |