Magellan Linux

Contents of /tags/mkinitrd-6_3_1/busybox/testsuite/ash.tests

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1143 - (show annotations) (download)
Thu Aug 19 12:44:27 2010 UTC (13 years, 9 months ago) by niro
File size: 3148 byte(s)
tagged 'mkinitrd-6_3_1'
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 test -f "$bindir/.config" && . "$bindir/.config"
10
11 test x"CONFIG_SCRIPT" = x"y" || exit 0
12 test x"CONFIG_HEXDUMP" = x"y" || exit 0
13 test x"CONFIG_FEATURE_DEVPTS" = x"y" || exit 0
14
15 # testing "test name" "options" "expected result" "file input" "stdin"
16
17 if test x"$CONFIG_UNICODE_PRESERVE_BROKEN" = x"y"; then
18 testing "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 "\
21 00000000 ff 2d 0a |.-.|
22 00000003
23 " \
24 "" \
25 "echo \xff- | hexdump -C >ash.output; exit; exit; exit; exit\n"
26
27 testing "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 "\
30 00000000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
31 00000010 ff ff ff ff ff ff ff ff ff ff ff ff ff ff 2d 0a |..............-.|
32 00000020
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"
36 else
37 testing "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 "\
40 00000000 3f 2d 0a |?-.|
41 00000003
42 " \
43 "" \
44 "echo \xff- | hexdump -C >ash.output; exit; exit; exit; exit\n"
45
46 testing "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 "\
49 00000000 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f |????????????????|
50 00000010 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 2d 0a |??????????????-.|
51 00000020
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"
55 fi
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
60 testing "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 "\
63 00000000 3d 2d 0a |=-.|
64 00000003
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.
72 testing "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 "\
76 00000000 41 0a |A.|
77 00000002
78 " \
79 "" ""
80
81 rm ash.output
82
83 exit $FAILCOUNT