blobmsg_json: prefer snprintf usage
[project/libubox.git] / tests / cram / test_blobmsg.t
1 check that blobmsg is producing expected results:
2
3 $ [ -n "$TEST_BIN_DIR" ] && export PATH="$TEST_BIN_DIR:$PATH"
4
5 $ valgrind --quiet --leak-check=full test-blobmsg
6 [*] blobmsg dump:
7 Message: Hello, world!
8 List: {
9 0 (i8)
10 100 (i8)
11 -128 (i8)
12 127 (i8)
13 -32768 (i16)
14 32767 (i16)
15 -2147483648 (i32)
16 2147483647 (i32)
17 -9223372036854775808 (i64)
18 9223372036854775807 (i64)
19 0.000000 (dbl)
20 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl)
21 }
22 Testdata: {
23 \tdbl-min : 0.000000 (dbl) (esc)
24 \tdbl-max : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl) (esc)
25 \tfoo : 0 (i8) (esc)
26 \tpoo : 100 (i8) (esc)
27 \tmoo-min : -128 (i8) (esc)
28 \tmoo-max : 127 (i8) (esc)
29 \tbar-min : -32768 (i16) (esc)
30 \tbar-max : 32767 (i16) (esc)
31 \tbaz-min : -2147483648 (i32) (esc)
32 \tbaz-max : 2147483647 (i32) (esc)
33 \ttaz-min : -9223372036854775808 (i64) (esc)
34 \ttaz-max : 9223372036854775807 (i64) (esc)
35 \tworld : 2 (str) (esc)
36 }
37
38 [*] blobmsg to json: {"message":"Hello, world!","testdata":{"dbl-min":0.000000,"dbl-max":179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000,"foo":false,"poo":true,"moo-min":true,"moo-max":true,"bar-min":-32768,"bar-max":32767,"baz-min":-2147483648,"baz-max":2147483647,"taz-min":-9223372036854775808,"taz-max":9223372036854775807,"world":"2"},"list":[false,true,true,true,-32768,32767,-2147483648,2147483647,-9223372036854775808,9223372036854775807,0.000000,179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000]}
39
40 [*] blobmsg from json:
41 Message: Hello, world!
42 List: {
43 0 (i8)
44 1 (i8)
45 1 (i8)
46 1 (i8)
47 -32768 (i32)
48 32767 (i32)
49 -2147483648 (i32)
50 2147483647 (i32)
51 -9223372036854775808 (i64)
52 9223372036854775807 (i64)
53 0.000000 (dbl)
54 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl)
55 }
56 Testdata: {
57 \tdbl-min : 0.000000 (dbl) (esc)
58 \tdbl-max : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl) (esc)
59 \tfoo : 0 (i8) (esc)
60 \tpoo : 1 (i8) (esc)
61 \tmoo-min : 1 (i8) (esc)
62 \tmoo-max : 1 (i8) (esc)
63 \tbar-min : -32768 (i32) (esc)
64 \tbar-max : 32767 (i32) (esc)
65 \tbaz-min : -2147483648 (i32) (esc)
66 \tbaz-max : 2147483647 (i32) (esc)
67 \ttaz-min : -9223372036854775808 (i64) (esc)
68 \ttaz-max : 9223372036854775807 (i64) (esc)
69 \tworld : 2 (str) (esc)
70 }
71
72 $ test-blobmsg-san
73 [*] blobmsg dump:
74 Message: Hello, world!
75 List: {
76 0 (i8)
77 100 (i8)
78 -128 (i8)
79 127 (i8)
80 -32768 (i16)
81 32767 (i16)
82 -2147483648 (i32)
83 2147483647 (i32)
84 -9223372036854775808 (i64)
85 9223372036854775807 (i64)
86 0.000000 (dbl)
87 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl)
88 }
89 Testdata: {
90 \tdbl-min : 0.000000 (dbl) (esc)
91 \tdbl-max : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl) (esc)
92 \tfoo : 0 (i8) (esc)
93 \tpoo : 100 (i8) (esc)
94 \tmoo-min : -128 (i8) (esc)
95 \tmoo-max : 127 (i8) (esc)
96 \tbar-min : -32768 (i16) (esc)
97 \tbar-max : 32767 (i16) (esc)
98 \tbaz-min : -2147483648 (i32) (esc)
99 \tbaz-max : 2147483647 (i32) (esc)
100 \ttaz-min : -9223372036854775808 (i64) (esc)
101 \ttaz-max : 9223372036854775807 (i64) (esc)
102 \tworld : 2 (str) (esc)
103 }
104
105 [*] blobmsg to json: {"message":"Hello, world!","testdata":{"dbl-min":0.000000,"dbl-max":179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000,"foo":false,"poo":true,"moo-min":true,"moo-max":true,"bar-min":-32768,"bar-max":32767,"baz-min":-2147483648,"baz-max":2147483647,"taz-min":-9223372036854775808,"taz-max":9223372036854775807,"world":"2"},"list":[false,true,true,true,-32768,32767,-2147483648,2147483647,-9223372036854775808,9223372036854775807,0.000000,179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000]}
106
107 [*] blobmsg from json:
108 Message: Hello, world!
109 List: {
110 0 (i8)
111 1 (i8)
112 1 (i8)
113 1 (i8)
114 -32768 (i32)
115 32767 (i32)
116 -2147483648 (i32)
117 2147483647 (i32)
118 -9223372036854775808 (i64)
119 9223372036854775807 (i64)
120 0.000000 (dbl)
121 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl)
122 }
123 Testdata: {
124 \tdbl-min : 0.000000 (dbl) (esc)
125 \tdbl-max : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl) (esc)
126 \tfoo : 0 (i8) (esc)
127 \tpoo : 1 (i8) (esc)
128 \tmoo-min : 1 (i8) (esc)
129 \tmoo-max : 1 (i8) (esc)
130 \tbar-min : -32768 (i32) (esc)
131 \tbar-max : 32767 (i32) (esc)
132 \tbaz-min : -2147483648 (i32) (esc)
133 \tbaz-max : 2147483647 (i32) (esc)
134 \ttaz-min : -9223372036854775808 (i64) (esc)
135 \ttaz-max : 9223372036854775807 (i64) (esc)
136 \tworld : 2 (str) (esc)
137 }
138
139 $ test-blobmsg-san
140 [*] blobmsg dump:
141 Message: Hello, world!
142 List: {
143 0 (i8)
144 100 (i8)
145 -128 (i8)
146 127 (i8)
147 -32768 (i16)
148 32767 (i16)
149 -2147483648 (i32)
150 2147483647 (i32)
151 -9223372036854775808 (i64)
152 9223372036854775807 (i64)
153 0.000000 (dbl)
154 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl)
155 }
156 Testdata: {
157 \tdbl-min : 0.000000 (dbl) (esc)
158 \tdbl-max : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl) (esc)
159 \tfoo : 0 (i8) (esc)
160 \tpoo : 100 (i8) (esc)
161 \tmoo-min : -128 (i8) (esc)
162 \tmoo-max : 127 (i8) (esc)
163 \tbar-min : -32768 (i16) (esc)
164 \tbar-max : 32767 (i16) (esc)
165 \tbaz-min : -2147483648 (i32) (esc)
166 \tbaz-max : 2147483647 (i32) (esc)
167 \ttaz-min : -9223372036854775808 (i64) (esc)
168 \ttaz-max : 9223372036854775807 (i64) (esc)
169 \tworld : 2 (str) (esc)
170 }
171
172 [*] blobmsg to json: {"message":"Hello, world!","testdata":{"dbl-min":0.000000,"dbl-max":179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000,"foo":false,"poo":true,"moo-min":true,"moo-max":true,"bar-min":-32768,"bar-max":32767,"baz-min":-2147483648,"baz-max":2147483647,"taz-min":-9223372036854775808,"taz-max":9223372036854775807,"world":"2"},"list":[false,true,true,true,-32768,32767,-2147483648,2147483647,-9223372036854775808,9223372036854775807,0.000000,179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000]}
173
174 [*] blobmsg from json:
175 Message: Hello, world!
176 List: {
177 0 (i8)
178 1 (i8)
179 1 (i8)
180 1 (i8)
181 -32768 (i32)
182 32767 (i32)
183 -2147483648 (i32)
184 2147483647 (i32)
185 -9223372036854775808 (i64)
186 9223372036854775807 (i64)
187 0.000000 (dbl)
188 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl)
189 }
190 Testdata: {
191 \tdbl-min : 0.000000 (dbl) (esc)
192 \tdbl-max : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl) (esc)
193 \tfoo : 0 (i8) (esc)
194 \tpoo : 1 (i8) (esc)
195 \tmoo-min : 1 (i8) (esc)
196 \tmoo-max : 1 (i8) (esc)
197 \tbar-min : -32768 (i32) (esc)
198 \tbar-max : 32767 (i32) (esc)
199 \tbaz-min : -2147483648 (i32) (esc)
200 \tbaz-max : 2147483647 (i32) (esc)
201 \ttaz-min : -9223372036854775808 (i64) (esc)
202 \ttaz-max : 9223372036854775807 (i64) (esc)
203 \tworld : 2 (str) (esc)
204 }
205
206 $ test-blobmsg-san
207 [*] blobmsg dump:
208 Message: Hello, world!
209 List: {
210 0 (i8)
211 100 (i8)
212 -128 (i8)
213 127 (i8)
214 -32768 (i16)
215 32767 (i16)
216 -2147483648 (i32)
217 2147483647 (i32)
218 -9223372036854775808 (i64)
219 9223372036854775807 (i64)
220 0.000000 (dbl)
221 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl)
222 }
223 Testdata: {
224 \tdbl-min : 0.000000 (dbl) (esc)
225 \tdbl-max : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl) (esc)
226 \tfoo : 0 (i8) (esc)
227 \tpoo : 100 (i8) (esc)
228 \tmoo-min : -128 (i8) (esc)
229 \tmoo-max : 127 (i8) (esc)
230 \tbar-min : -32768 (i16) (esc)
231 \tbar-max : 32767 (i16) (esc)
232 \tbaz-min : -2147483648 (i32) (esc)
233 \tbaz-max : 2147483647 (i32) (esc)
234 \ttaz-min : -9223372036854775808 (i64) (esc)
235 \ttaz-max : 9223372036854775807 (i64) (esc)
236 \tworld : 2 (str) (esc)
237 }
238
239 [*] blobmsg to json: {"message":"Hello, world!","testdata":{"dbl-min":0.000000,"dbl-max":179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000,"foo":false,"poo":true,"moo-min":true,"moo-max":true,"bar-min":-32768,"bar-max":32767,"baz-min":-2147483648,"baz-max":2147483647,"taz-min":-9223372036854775808,"taz-max":9223372036854775807,"world":"2"},"list":[false,true,true,true,-32768,32767,-2147483648,2147483647,-9223372036854775808,9223372036854775807,0.000000,179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000]}
240
241 [*] blobmsg from json:
242 Message: Hello, world!
243 List: {
244 0 (i8)
245 1 (i8)
246 1 (i8)
247 1 (i8)
248 -32768 (i32)
249 32767 (i32)
250 -2147483648 (i32)
251 2147483647 (i32)
252 -9223372036854775808 (i64)
253 9223372036854775807 (i64)
254 0.000000 (dbl)
255 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl)
256 }
257 Testdata: {
258 \tdbl-min : 0.000000 (dbl) (esc)
259 \tdbl-max : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl) (esc)
260 \tfoo : 0 (i8) (esc)
261 \tpoo : 1 (i8) (esc)
262 \tmoo-min : 1 (i8) (esc)
263 \tmoo-max : 1 (i8) (esc)
264 \tbar-min : -32768 (i32) (esc)
265 \tbar-max : 32767 (i32) (esc)
266 \tbaz-min : -2147483648 (i32) (esc)
267 \tbaz-max : 2147483647 (i32) (esc)
268 \ttaz-min : -9223372036854775808 (i64) (esc)
269 \ttaz-max : 9223372036854775807 (i64) (esc)
270 \tworld : 2 (str) (esc)
271 }