blob: 2a99245a99fedb0849ba70e644c2fdec289d1745 [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
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02006# Licensed under GPLv2, see file LICENSE in this source tree.
Tomas Heinrichd2b04052010-03-09 14:09:24 +01007
8. ./testing.sh
Tomas Heinricha659b812010-04-29 13:43:39 +02009test -f "$bindir/.config" && . "$bindir/.config"
10
Denys Vlasenkoff0e8752010-05-10 04:16:43 +020011test x"CONFIG_SCRIPT" = x"y" || exit 0
12test x"CONFIG_HEXDUMP" = x"y" || exit 0
13test x"CONFIG_FEATURE_DEVPTS" = x"y" || exit 0
14
Tomas Heinrichd2b04052010-03-09 14:09:24 +010015# testing "test name" "options" "expected result" "file input" "stdin"
16
Tomas Heinricha659b812010-04-29 13:43:39 +020017if test x"$CONFIG_UNICODE_PRESERVE_BROKEN" = x"y"; then
18testing "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 "\
2100000000 ff 2d 0a |.-.|
2200000003
23" \
24 "" \
25 "echo \xff- | hexdump -C >ash.output; exit; exit; exit; exit\n"
26
27testing "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 "\
3000000000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
3100000010 ff ff ff ff ff ff ff ff ff ff ff ff ff ff 2d 0a |..............-.|
3200000020
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"
36else
Tomas Heinrichd2b04052010-03-09 14:09:24 +010037testing "One byte which is not valid unicode char followed by valid input" \
Denys Vlasenko58f108e2010-03-11 21:17:55 +010038 "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \
Tomas Heinrichd2b04052010-03-09 14:09:24 +010039 "\
4000000000 3f 2d 0a |?-.|
4100000003
42" \
43 "" \
Denys Vlasenko58f108e2010-03-11 21:17:55 +010044 "echo \xff- | hexdump -C >ash.output; exit; exit; exit; exit\n"
Tomas Heinrichd2b04052010-03-09 14:09:24 +010045
46testing "30 bytes which are not valid unicode chars followed by valid input" \
Denys Vlasenko58f108e2010-03-11 21:17:55 +010047 "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \
Tomas Heinrichd2b04052010-03-09 14:09:24 +010048 "\
4900000000 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f |????????????????|
5000000010 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 2d 0a |??????????????-.|
5100000020
52" \
53 "" \
Denys Vlasenko58f108e2010-03-11 21:17:55 +010054 "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 +020055fi
56
Tomas Heinrichd2b04052010-03-09 14:09:24 +010057
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
60testing "2 bytes which are not valid unicode chars followed by left arrow key" \
Denys Vlasenko58f108e2010-03-11 21:17:55 +010061 "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \
Tomas Heinrichd2b04052010-03-09 14:09:24 +010062 "\
6300000000 3d 2d 0a |=-.|
6400000003
65" \
66 "" \
Denys Vlasenko58f108e2010-03-11 21:17:55 +010067 "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.
72testing "Invalid unicode chars followed by a pause do not eat next chars" \
Denys Vlasenkoe82cf332010-05-12 15:59:32 +020073 "{ $ECHO -ne 'echo \xff\n'; sleep 1; $ECHO -ne 'echo A | hexdump -C >ash.output; exit; exit; exit; exit\n'; } \
Denys Vlasenko58f108e2010-03-11 21:17:55 +010074 | script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \
75 "\
7600000000 41 0a |A.|
7700000002
78" \
79 "" ""
80
81rm ash.output
Tomas Heinrichd2b04052010-03-09 14:09:24 +010082
83exit $FAILCOUNT