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 | |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 12 | # testing "test name" "options" "expected result" "file input" "stdin" |
| 13 | |
Tomas Heinrich | a659b81 | 2010-04-29 13:43:39 +0200 | [diff] [blame] | 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" \ |
| 17 | "\ |
| 18 | 00000000 ff 2d 0a |.-.| |
| 19 | 00000003 |
| 20 | " \ |
| 21 | "" \ |
| 22 | "echo \xff- | hexdump -C >ash.output; exit; exit; exit; exit\n" |
| 23 | |
| 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" \ |
| 26 | "\ |
| 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 |..............-.| |
| 29 | 00000020 |
| 30 | " \ |
| 31 | "" \ |
| 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" |
| 33 | else |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 34 | 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] | 35 | "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \ |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 36 | "\ |
| 37 | 00000000 3f 2d 0a |?-.| |
| 38 | 00000003 |
| 39 | " \ |
| 40 | "" \ |
Denys Vlasenko | 58f108e | 2010-03-11 21:17:55 +0100 | [diff] [blame] | 41 | "echo \xff- | hexdump -C >ash.output; exit; exit; exit; exit\n" |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 42 | |
| 43 | 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] | 44 | "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \ |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 45 | "\ |
| 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 |??????????????-.| |
| 48 | 00000020 |
| 49 | " \ |
| 50 | "" \ |
Denys Vlasenko | 58f108e | 2010-03-11 21:17:55 +0100 | [diff] [blame] | 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" |
Tomas Heinrich | a659b81 | 2010-04-29 13:43:39 +0200 | [diff] [blame] | 52 | fi |
| 53 | |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 54 | |
| 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" \ |
Denys Vlasenko | 58f108e | 2010-03-11 21:17:55 +0100 | [diff] [blame] | 58 | "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \ |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 59 | "\ |
| 60 | 00000000 3d 2d 0a |=-.| |
| 61 | 00000003 |
| 62 | " \ |
| 63 | "" \ |
Denys Vlasenko | 58f108e | 2010-03-11 21:17:55 +0100 | [diff] [blame] | 64 | "echo =+\xff\xff\x1b\x5b\x44- | hexdump -C >ash.output; exit; exit; exit; exit\n" |
| 65 | |
| 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" \ |
| 72 | "\ |
| 73 | 00000000 41 0a |A.| |
| 74 | 00000002 |
| 75 | " \ |
| 76 | "" "" |
| 77 | |
| 78 | rm ash.output |
Tomas Heinrich | d2b0405 | 2010-03-09 14:09:24 +0100 | [diff] [blame] | 79 | |
| 80 | exit $FAILCOUNT |