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 GPLv2, see file LICENSE in this source tree. 7 8. ./testing.sh 9test -f "$bindir/.config" && . "$bindir/.config" 10 11test 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 15# testing "test name" "options" "expected result" "file input" "stdin" 16 17if 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 37testing "One byte which is not valid unicode char followed by valid input" \ 38 "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \ 39 "\ 4000000000 3f 2d 0a |?-.| 4100000003 42" \ 43 "" \ 44 "echo \xff- | hexdump -C >ash.output; exit; exit; exit; exit\n" 45 46testing "30 bytes which are not valid unicode chars followed by valid input" \ 47 "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \ 48 "\ 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 "" \ 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" 55fi 56 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 60testing "2 bytes which are not valid unicode chars followed by left arrow key" \ 61 "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \ 62 "\ 6300000000 3d 2d 0a |=-.| 6400000003 65" \ 66 "" \ 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. 72testing "Invalid unicode chars followed by a pause do not eat next chars" \ 73 "{ $ECHO -ne 'echo \xff\n'; sleep 1; $ECHO -ne 'echo A | hexdump -C >ash.output; exit; exit; exit; exit\n'; } \ 74 | script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \ 75 "\ 7600000000 41 0a |A.| 7700000002 78" \ 79 "" "" 80 81rm ash.output 82 83exit $FAILCOUNT 84