blob: ce585beb1446b2b92643bace677b25ced6891174 [file] [log] [blame]
Tomas Heinrichd2b04052010-03-09 14:09:24 +01001#!/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 Heinricha659b812010-04-29 13:43:39 +020010test -f "$bindir/.config" && . "$bindir/.config"
11
Tomas Heinrichd2b04052010-03-09 14:09:24 +010012# testing "test name" "options" "expected result" "file input" "stdin"
13
Tomas Heinricha659b812010-04-29 13:43:39 +020014if test x"$CONFIG_UNICODE_PRESERVE_BROKEN" = x"y"; then
15testing "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 "\
1800000000 ff 2d 0a |.-.|
1900000003
20" \
21 "" \
22 "echo \xff- | hexdump -C >ash.output; exit; exit; exit; exit\n"
23
24testing "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 "\
2700000000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
2800000010 ff ff ff ff ff ff ff ff ff ff ff ff ff ff 2d 0a |..............-.|
2900000020
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"
33else
Tomas Heinrichd2b04052010-03-09 14:09:24 +010034testing "One byte which is not valid unicode char followed by valid input" \
Denys Vlasenko58f108e2010-03-11 21:17:55 +010035 "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \
Tomas Heinrichd2b04052010-03-09 14:09:24 +010036 "\
3700000000 3f 2d 0a |?-.|
3800000003
39" \
40 "" \
Denys Vlasenko58f108e2010-03-11 21:17:55 +010041 "echo \xff- | hexdump -C >ash.output; exit; exit; exit; exit\n"
Tomas Heinrichd2b04052010-03-09 14:09:24 +010042
43testing "30 bytes which are not valid unicode chars followed by valid input" \
Denys Vlasenko58f108e2010-03-11 21:17:55 +010044 "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \
Tomas Heinrichd2b04052010-03-09 14:09:24 +010045 "\
4600000000 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f |????????????????|
4700000010 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 2d 0a |??????????????-.|
4800000020
49" \
50 "" \
Denys Vlasenko58f108e2010-03-11 21:17:55 +010051 "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 Heinricha659b812010-04-29 13:43:39 +020052fi
53
Tomas Heinrichd2b04052010-03-09 14:09:24 +010054
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
57testing "2 bytes which are not valid unicode chars followed by left arrow key" \
Denys Vlasenko58f108e2010-03-11 21:17:55 +010058 "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \
Tomas Heinrichd2b04052010-03-09 14:09:24 +010059 "\
6000000000 3d 2d 0a |=-.|
6100000003
62" \
63 "" \
Denys Vlasenko58f108e2010-03-11 21:17:55 +010064 "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.
69testing "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 "\
7300000000 41 0a |A.|
7400000002
75" \
76 "" ""
77
78rm ash.output
Tomas Heinrichd2b04052010-03-09 14:09:24 +010079
80exit $FAILCOUNT