5
5
# -q for 'quiet' mode.
6
6
7
7
T=yes
8
- F =0
8
+ FAILS =0
9
9
Q=N
10
+ TOTAL=0
10
11
if [ x$1 = " x-q" ] ; then Q=Y ; fi
11
12
13
+ function Base64_Conv_Func {
14
+ local out_var=$1 ;
15
+ shift
16
+ local ret_str
17
+ ret_str=` ../run/base64conv 2> /dev/null $* `
18
+ (( TOTAL++ ))
19
+ eval $out_var =\$ ret_str;
20
+ }
21
+
12
22
# simple test cycling through the types. $MEM and $V9 should be same in the end
13
23
MEM=123456789aBCDefGHJ
14
- V1= ` ../run/base64conv 2> /dev/null -i raw -q -e -o hex $MEM `
15
- V2= ` ../run/base64conv 2> /dev/null -i hex -q -e -o mime $V1 `
16
- V3= ` ../run/base64conv 2> /dev/null -i mime -q -e -o crypt $V2 `
17
- V4= ` ../run/base64conv 2> /dev/null -i crypt -q -e -o cryptBS $V3 `
18
- V5= ` ../run/base64conv 2> /dev/null -i cryptBS -q -e -o mime $V4 `
19
- V6= ` ../run/base64conv 2> /dev/null -i mime -q -e -o cryptBS $V5 `
20
- V7= ` ../run/base64conv 2> /dev/null -i cryptBS -q -e -o crypt $V6 `
21
- V8= ` ../run/base64conv 2> /dev/null -i crypt -q -e -o hex $V7 `
22
- V9= ` ../run/base64conv 2> /dev/null -i hex -q -e -o raw $V8 `
24
+ Base64_Conv_Func V1 -i raw -q -e -o hex $MEM
25
+ Base64_Conv_Func V2 -i hex -q -e -o mime $V1
26
+ Base64_Conv_Func V3 -i mime -q -e -o crypt $V2
27
+ Base64_Conv_Func V4 -i crypt -q -e -o cryptBS $V3
28
+ Base64_Conv_Func V5 -i cryptBS -q -e -o mime $V4
29
+ Base64_Conv_Func V6 -i mime -q -e -o cryptBS $V5
30
+ Base64_Conv_Func V7 -i cryptBS -q -e -o crypt $V6
31
+ Base64_Conv_Func V8 -i crypt -q -e -o hex $V7
32
+ Base64_Conv_Func V9 -i hex -q -e -o raw $V8
23
33
if [ x$MEM != x$V9 ];
24
34
then
25
- F=1
26
- echo " Simple test failed. '$MEM ' not same as '$9 '"
35
+ (( FAILS ++ ))
36
+ echo " Simple test failed. '$MEM ' not same as '$V9 '"
27
37
echo " MEM='$MEM '"
28
38
echo " V1 ='$V1 '"
29
39
echo " V2 ='$V2 '"
@@ -47,66 +57,74 @@ function known {
47
57
kC=$4
48
58
kM=$3
49
59
kB=$2
50
- B= ` ../run/base64conv 2> /dev/null -i raw -q -e -o cryptBS $1 `
51
- C= ` ../run/base64conv 2> /dev/null -i raw -q -e -o crypt $1 `
52
- M= ` ../run/base64conv 2> /dev/null -i raw -q -e -o mime $1 `
60
+ Base64_Conv_Func B -i raw -q -e -o cryptBS $1
61
+ Base64_Conv_Func C -i raw -q -e -o crypt $1
62
+ Base64_Conv_Func M -i raw -q -e -o mime $1
53
63
T=yes
54
64
if [ x$B != x$kB ];
55
65
then
56
66
echo " Known test failed (cryptBS). '$1 ' should be '$kB ' not '$B '"
57
67
T=no
68
+ (( FAILS++ ))
58
69
fi
59
70
if [ x$M != x$kM ];
60
71
then
61
72
echo " Known test failed (mime). '$1 ' should be '$kM ' not '$M '"
62
73
T=no
74
+ (( FAILS++ ))
63
75
fi
64
76
if [ x$C != x$kC ];
65
77
then
66
78
echo " Known test failed (crypt). '$1 ' should be '$kC ' not '$C '"
67
79
T=no
80
+ (( FAILS++ ))
68
81
fi
69
- C2= ` ../run/base64conv 2> /dev/null -i cryptBS -q -e -o crypt $B `
70
- M2= ` ../run/base64conv 2> /dev/null -i cryptBS -q -e -o mime $B `
82
+ Base64_Conv_Func C2 -i cryptBS -q -e -o crypt $B
83
+ Base64_Conv_Func M2 -i cryptBS -q -e -o mime $B
71
84
if [ x$M2 != x$kM ];
72
85
then
73
86
echo " Known test failed (cryptBS->mime). '$1 ' should be '$kM ' not '$M2 '"
74
87
T=no
88
+ (( FAILS++ ))
75
89
fi
76
90
if [ x$C2 != x$kC ];
77
91
then
78
92
echo " Known test failed (cryptBS->crypt). '$1 ' should be '$kC ' not '$C2 '"
79
93
T=no
94
+ (( FAILS++ ))
80
95
fi
81
- B2= ` ../run/base64conv 2> /dev/null -i crypt -q -e -o cryptBS $C `
82
- M2= ` ../run/base64conv 2> /dev/null -i crypt -q -e -o mime $C `
96
+ Base64_Conv_Func B2 -i crypt -q -e -o cryptBS $C
97
+ Base64_Conv_Func M2 -i crypt -q -e -o mime $C
83
98
if [ x$M2 != x$kM ];
84
99
then
85
100
echo " Known test failed (crypt->mime). '$1 ' should be '$kM ' not '$M2 '"
86
101
T=no
102
+ (( FAILS++ ))
87
103
fi
88
104
if [ x$B2 != x$kB ];
89
105
then
90
106
echo " Known test failed (crypt->cryptBS). '$1 ' should be '$kB ' not '$B2 '"
91
107
T=no
92
- fi
93
- B2=` ../run/base64conv 2> /dev/null -i mime -q -e -o cryptBS $M `
94
- C2=` ../run/base64conv 2> /dev/null -i mime -q -e -o crypt $M `
108
+ (( FAILS++ ))
109
+ fi
110
+ Base64_Conv_Func B2 -i mime -q -e -o cryptBS $M
111
+ Base64_Conv_Func C2 -i mime -q -e -o crypt $M
95
112
if [ x$C2 != x$kC ];
96
113
then
97
114
echo " Known test failed (mime->crypt). '$1 ' should be '$kC ' not '$C2 '"
98
115
T=no
116
+ (( FAILS++ ))
99
117
fi
100
118
if [ x$B2 != x$kB ];
101
119
then
102
120
echo " Known test failed (mime->cryptBS). '$1 ' should be '$kB ' not '$B2 '"
103
121
T=no
104
- fi
122
+ (( FAILS++ ))
123
+ fi
105
124
if [ x$T = " xyes" ];
106
125
then
107
126
if [ $Q = " N" ] ; then echo " Success known test param = $1 " ; fi
108
127
else
109
- F=1
110
128
echo " Failure known test param = $1 "
111
129
fi
112
130
}
@@ -131,33 +149,33 @@ if [ $Q = "N" ] ; then echo "performing NULL checks" ; fi
131
149
T=yes
132
150
B2=000000000000
133
151
C2=........
134
- B= ` ../run/base64conv 2> /dev/null -q -i hex -o crypt $B2 `
135
- C= ` ../run/base64conv 2> /dev/null -q -o hex -i crypt $C2 `
152
+ Base64_Conv_Func B -q -i hex -o crypt $B2
153
+ Base64_Conv_Func C -q -o hex -i crypt $C2
136
154
if [ x$B != " x$C2 " -o x$C != " x$B2 " ];
137
155
then
138
156
echo " failed! crypt" ;
139
157
T=no
158
+ (( FAILS++ ))
140
159
fi
141
- B= ` ../run/base64conv 2> /dev/null -q -i hex -o cryptBS $B2 `
142
- C= ` ../run/base64conv 2> /dev/null -q -o hex -i cryptBS $C2 `
160
+ Base64_Conv_Func B -q -i hex -o cryptBS $B2
161
+ Base64_Conv_Func C -q -o hex -i cryptBS $C2
143
162
if [ x$B != " x$C2 " -o x$C != " x$B2 " ];
144
163
then
145
164
echo " failed! cryptBS" ;
146
165
T=no
166
+ (( FAILS++ ))
147
167
fi
148
168
C2=AAAAAAAA
149
- B= ` ../run/base64conv 2> /dev/null -q -i hex -o mime $B2 `
150
- C= ` ../run/base64conv 2> /dev/null -q -o hex -i mime $C2 `
169
+ Base64_Conv_Func B -q -i hex -o mime $B2
170
+ Base64_Conv_Func C -q -o hex -i mime $C2
151
171
if [ x$B != " x$C2 " -o x$C != " x$B2 " ];
152
172
then
153
173
echo " failed! mime" ;
154
174
T=no
175
+ (( FAILS++ ))
155
176
fi
156
- if [ x$T = " xyes" ];
157
- then
177
+ if [ x$T = " xyes" ]; then
158
178
if [ $Q = " N" ] ; then echo " ALL null tests were valid" ; fi
159
- else
160
- F=1
161
179
fi
162
180
163
181
# ########################################
@@ -171,44 +189,44 @@ function comp {
171
189
then
172
190
echo " $3 : '$1 ' is not equal to '$2 '"
173
191
T=no
192
+ (( FAILS++ ))
174
193
fi
175
194
}
176
195
177
196
function tst {
178
197
T=yes
179
- B= ` ../run/base64conv 2> /dev/null -i raw -q -e -o cryptBS $1 `
180
- C= ` ../run/base64conv 2> /dev/null -i raw -q -e -o crypt $1 `
181
- M= ` ../run/base64conv 2> /dev/null -i raw -q -e -o mime $1 `
198
+ Base64_Conv_Func B -i raw -q -e -o cryptBS $1
199
+ Base64_Conv_Func C -i raw -q -e -o crypt $1
200
+ Base64_Conv_Func M -i raw -q -e -o mime $1
182
201
183
- R= ` ../run/base64conv 2> /dev/null -i crypt -q -e -o cryptBS $C `
184
- R= ` ../run/base64conv 2> /dev/null -i cryptBS -q -e -o raw $R `
202
+ Base64_Conv_Func R -i crypt -q -e -o cryptBS $C
203
+ Base64_Conv_Func R -i cryptBS -q -e -o raw $R
185
204
comp x$1 x$R " crypt_cryptBS (1)"
186
205
187
- R= ` ../run/base64conv 2> /dev/null -i mime -q -e -o cryptBS $M `
188
- R= ` ../run/base64conv 2> /dev/null -i cryptBS -q -e -o raw $R `
206
+ Base64_Conv_Func R -i mime -q -e -o cryptBS $M
207
+ Base64_Conv_Func R -i cryptBS -q -e -o raw $R
189
208
comp x$1 x$R " mime_cryptBS (2)"
190
209
191
- R= ` ../run/base64conv 2> /dev/null -i cryptBS -q -e -o crypt $B `
192
- R= ` ../run/base64conv 2> /dev/null -i crypt -q -e -o raw $R `
210
+ Base64_Conv_Func R -i cryptBS -q -e -o crypt $B
211
+ Base64_Conv_Func R -i crypt -q -e -o raw $R
193
212
comp x$1 x$R " cryptBS_crypt (3)"
194
213
195
- R= ` ../run/base64conv 2> /dev/null -i mime -q -e -o crypt $M `
196
- R= ` ../run/base64conv 2> /dev/null -i crypt -q -e -o raw $R `
214
+ Base64_Conv_Func R -i mime -q -e -o crypt $M
215
+ Base64_Conv_Func R -i crypt -q -e -o raw $R
197
216
comp x$1 x$R " mime_crypt (4)"
198
217
199
- R= ` ../run/base64conv 2> /dev/null -i cryptBS -q -e -o mime $B `
200
- R= ` ../run/base64conv 2> /dev/null -i mime -q -e -o raw $R `
218
+ Base64_Conv_Func R -i cryptBS -q -e -o mime $B
219
+ Base64_Conv_Func R -i mime -q -e -o raw $R
201
220
comp a$1 a$R " cryptBS_mime (5)"
202
221
203
- R= ` ../run/base64conv 2> /dev/null -i crypt -q -e -o mime $C `
204
- R= ` ../run/base64conv 2> /dev/null -i mime -q -e -o raw $R `
222
+ Base64_Conv_Func R -i crypt -q -e -o mime $C
223
+ Base64_Conv_Func R -i mime -q -e -o raw $R
205
224
comp b$1 b$R " crypt_mime (6)"
206
225
207
226
if [ x$T = " xyes" ];
208
227
then
209
228
if [ $Q = " N" ] ; then echo " Success multi-convert test param = $1 " ; fi
210
229
else
211
- F=1
212
230
echo " Failure multi-convert test param = $1 "
213
231
fi
214
232
}
@@ -397,5 +415,9 @@ tst $P
397
415
398
416
# if there were no failures, then list so. This is so there
399
417
# is SOME output in -q mode, if all tests passed.
400
- if [ x$F = " x0" ] ; then echo " All tests succeeded" ; fi
418
+ if [ x$FAILS = " x0" ] ; then
419
+ echo " All tests succeeded. $TOTAL calls to ../run/base64conv"
420
+ else
421
+ echo " There were $FAILS failures, from $TOTAL calls to ../run/base64conv"
422
+ fi
401
423
0 commit comments