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 |
| 9 | |
Tomas Heinrich | a659b81 | 2010-04-29 13:43:39 +0200 | [diff] [blame] | 10 | test -f "$bindir/.config" && . "$bindir/.config" |
| 11 | |
Denys Vlasenko | ff0e875 | 2010-05-10 04:16:43 +0200 | [diff] [blame] | 12 | test x"CONFIG_SCRIPT" = x"y" || exit 0 |
| 13 | test x"CONFIG_HEXDUMP" = x"y" || exit 0 |
| 14 | test x"CONFIG_FEATURE_DEVPTS" = x"y" || exit 0 |
| 15 | |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 16 | # testing "test name" "options" "expected result" "file input" "stdin" |
| 17 | |
Tomas Heinrich | a659b81 | 2010-04-29 13:43:39 +0200 | [diff] [blame] | 18 | if test x"$CONFIG_UNICODE_PRESERVE_BROKEN" = x"y"; then |
| 19 | testing "One byte which is not valid unicode char followed by valid input" \ |
| 20 | "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \ |
| 21 | "\ |
| 22 | 00000000 ff 2d 0a |.-.| |
| 23 | 00000003 |
| 24 | " \ |
| 25 | "" \ |
| 26 | "echo \xff- | hexdump -C >ash.output; exit; exit; exit; exit\n" |
| 27 | |
| 28 | testing "30 bytes which are not valid unicode chars followed by valid input" \ |
| 29 | "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \ |
| 30 | "\ |
| 31 | 00000000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| |
| 32 | 00000010 ff ff ff ff ff ff ff ff ff ff ff ff ff ff 2d 0a |..............-.| |
| 33 | 00000020 |
| 34 | " \ |
| 35 | "" \ |
| 36 | "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 | else |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 38 | 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] | 39 | "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \ |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 40 | "\ |
| 41 | 00000000 3f 2d 0a |?-.| |
| 42 | 00000003 |
| 43 | " \ |
| 44 | "" \ |
Denys Vlasenko | 58f108e | 2010-03-11 21:17:55 +0100 | [diff] [blame] | 45 | "echo \xff- | hexdump -C >ash.output; exit; exit; exit; exit\n" |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 46 | |
| 47 | 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] | 48 | "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \ |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 49 | "\ |
| 50 | 00000000 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f |????????????????| |
| 51 | 00000010 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 2d 0a |??????????????-.| |
| 52 | 00000020 |
| 53 | " \ |
| 54 | "" \ |
Denys Vlasenko | 58f108e | 2010-03-11 21:17:55 +0100 | [diff] [blame] | 55 | "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] | 56 | fi |
| 57 | |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 58 | |
| 59 | # Not sure this behavior is perfect: we lose all invalid input which precedes |
| 60 | # arrow keys and such. In this example, \xff\xff are lost |
| 61 | 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] | 62 | "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \ |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 63 | "\ |
| 64 | 00000000 3d 2d 0a |=-.| |
| 65 | 00000003 |
| 66 | " \ |
| 67 | "" \ |
Denys Vlasenko | 58f108e | 2010-03-11 21:17:55 +0100 | [diff] [blame] | 68 | "echo =+\xff\xff\x1b\x5b\x44- | hexdump -C >ash.output; exit; exit; exit; exit\n" |
| 69 | |
| 70 | # ash should see "echo \xff\n",pause -> execute it as "echo ?" (which is |
| 71 | # not checked by the test), then read and execute the rest: "echo A | ..." |
| 72 | # The bug was that ash was eating the beginning of "echo A" despite the pause. |
| 73 | testing "Invalid unicode chars followed by a pause do not eat next chars" \ |
| 74 | "{ echo -ne 'echo \xff\n'; sleep 1; echo -ne 'echo A | hexdump -C >ash.output; exit; exit; exit; exit\n'; } \ |
| 75 | | script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \ |
| 76 | "\ |
| 77 | 00000000 41 0a |A.| |
| 78 | 00000002 |
| 79 | " \ |
| 80 | "" "" |
| 81 | |
| 82 | rm ash.output |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 83 | |
| 84 | exit $FAILCOUNT |