Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / nettle / testsuite / sexp-conv-test
blob5b59cb71868a12bd978d813c7bca94e6fb45e9cc
1 #! /bin/sh
3 if [ -z "$srcdir" ] ; then
4 srcdir=`pwd`
5 fi
7 print_raw () {
8 printf "%s" "$1" > "$2"
11 print_nl () {
12 printf "%s\n" "$1" > "$2"
15 test_advanced () {
16 print_raw "$1" test.in
17 if $EMULATOR ../tools/sexp-conv -s advanced <test.in | tr -d '\r' >test1.out ; then
18 true
19 else
20 exit 1
22 print_nl "$2" test2.out
24 if cmp test1.out test2.out ; then
25 true
26 else
27 exit 1;
31 test_advanced_hex () {
32 print_raw "$1" test.in
33 if $EMULATOR ../tools/sexp-conv -s hex <test.in | tr -d '\r' >test1.out ; then
34 true
35 else
36 exit 1
38 print_nl "$2" test2.out
40 if cmp test1.out test2.out ; then
41 true
42 else
43 exit 1;
47 test_transport () {
48 print_raw "$1" test.in
49 if $EMULATOR ../tools/sexp-conv -s transport <test.in | tr -d '\r' >test1.out ; then
50 true
51 else
52 exit 1
54 print_nl "$2" test2.out
56 if cmp test1.out test2.out ; then
57 true
58 else
59 exit 1;
63 test_canonical () {
64 print_raw "$1" test.in
65 if $EMULATOR ../tools/sexp-conv -s canonical <test.in >test1.out ; then
66 true
67 else
68 exit 1
70 print_raw "$2" test2.out
72 if cmp test1.out test2.out ; then
73 true
74 else
75 exit 1;
79 test_advanced '0:' '""'
80 test_advanced '3:foo' 'foo'
81 test_advanced '12:fooooooooooo' 'fooooooooooo'
82 test_advanced '10:fooooooooo' 'fooooooooo'
83 test_advanced '4:3des' '"3des"'
84 test_advanced '"foo"' 'foo'
85 test_advanced '4:foo
86 ' '"foo\n"'
87 # Having the string end with a \ breaks with sysv echo. \x seems harmless.
88 test_advanced '3:"\x' '"\"\\x"'
89 test_advanced '()' '()'
90 test_advanced '(foo bar baz)' '(foo bar
91 baz)'
92 test_advanced '; comment
93 ()' '; comment
94 ()'
95 test_advanced '(foo ; gazonk
96 bar)' '(foo ; gazonk
97 bar)'
99 test_advanced '(foo[bar]foo)' '(foo [bar]foo)'
101 test_advanced '(#aabb#)' '(|qrs=|)'
102 test_advanced '(|qrs=|)' '(|qrs=|)'
103 test_advanced_hex '(|qrs=|)' '(#aabb#)'
104 test_advanced_hex '(#aabb#)' '(#aabb#)'
105 test_advanced_hex '{MToR}' '#11#'
106 test_advanced_hex '|EQ==|' '#11#'
108 test_transport '0:' '{MDo=}'
109 test_transport '()' '{KCk=}'
110 test_transport '1:A' '{MTpB}'
111 test_transport 'foo' '{Mzpmb28=}'
112 test_transport '(foo bar baz)' '{KDM6Zm9vMzpiYXIzOmJheik=}'
114 test_canonical '""' '0:'
115 test_canonical '{MDo=}' '0:'
116 test_canonical '{KCk=}' '()'
117 test_canonical '{MTpB}' '1:A'
118 test_canonical 'foo' '3:foo'
119 test_canonical 'fooooooooooo' '12:fooooooooooo'
120 test_canonical 'fooooooooo' '10:fooooooooo'
121 test_canonical '(foo bar baz)' '(3:foo3:bar3:baz)'
122 test_canonical '{KDM6Zm9vMzpiYXIzOmJheik=}' '(3:foo3:bar3:baz)'
124 exit 0