4 * Copyright (C) 2014 Leandro Dorileo <l@dorileo.org>
6 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
7 * See the COPYING.LIB file in the top-level directory.
10 #include "qemu/osdep.h"
11 #include "qemu/cutils.h"
12 #include "qapi/error.h"
13 #include "qapi/qmp/qstring.h"
14 #include "qemu/config-file.h"
17 static QemuOptsList opts_list_01
= {
18 .name
= "opts_list_01",
19 .head
= QTAILQ_HEAD_INITIALIZER(opts_list_01
.head
),
23 .type
= QEMU_OPT_STRING
,
26 .type
= QEMU_OPT_STRING
,
29 .type
= QEMU_OPT_STRING
,
32 .type
= QEMU_OPT_NUMBER
,
35 .type
= QEMU_OPT_NUMBER
,
41 static QemuOptsList opts_list_02
= {
42 .name
= "opts_list_02",
43 .head
= QTAILQ_HEAD_INITIALIZER(opts_list_02
.head
),
47 .type
= QEMU_OPT_STRING
,
50 .type
= QEMU_OPT_STRING
,
53 .type
= QEMU_OPT_BOOL
,
56 .type
= QEMU_OPT_BOOL
,
59 .type
= QEMU_OPT_SIZE
,
62 .type
= QEMU_OPT_SIZE
,
65 .type
= QEMU_OPT_SIZE
,
71 static QemuOptsList opts_list_03
= {
72 .name
= "opts_list_03",
73 .implied_opt_name
= "implied",
74 .head
= QTAILQ_HEAD_INITIALIZER(opts_list_03
.head
),
76 /* no elements => accept any params */
81 static void register_opts(void)
83 qemu_add_opts(&opts_list_01
);
84 qemu_add_opts(&opts_list_02
);
85 qemu_add_opts(&opts_list_03
);
88 static void test_find_unknown_opts(void)
93 /* should not return anything, we don't have an "unknown" option */
94 list
= qemu_find_opts_err("unknown", &err
);
95 g_assert(list
== NULL
);
96 error_free_or_abort(&err
);
99 static void test_qemu_find_opts(void)
103 /* we have an "opts_list_01" option, should return it */
104 list
= qemu_find_opts("opts_list_01");
105 g_assert(list
!= NULL
);
106 g_assert_cmpstr(list
->name
, ==, "opts_list_01");
109 static void test_qemu_opts_create(void)
114 list
= qemu_find_opts("opts_list_01");
115 g_assert(list
!= NULL
);
116 g_assert(QTAILQ_EMPTY(&list
->head
));
117 g_assert_cmpstr(list
->name
, ==, "opts_list_01");
119 /* should not find anything at this point */
120 opts
= qemu_opts_find(list
, NULL
);
121 g_assert(opts
== NULL
);
123 /* create the opts */
124 opts
= qemu_opts_create(list
, NULL
, 0, &error_abort
);
125 g_assert(opts
!= NULL
);
126 g_assert(!QTAILQ_EMPTY(&list
->head
));
128 /* now we've create the opts, must find it */
129 opts
= qemu_opts_find(list
, NULL
);
130 g_assert(opts
!= NULL
);
134 /* should not find anything at this point */
135 opts
= qemu_opts_find(list
, NULL
);
136 g_assert(opts
== NULL
);
139 static void test_qemu_opt_get(void)
143 const char *opt
= NULL
;
145 list
= qemu_find_opts("opts_list_01");
146 g_assert(list
!= NULL
);
147 g_assert(QTAILQ_EMPTY(&list
->head
));
148 g_assert_cmpstr(list
->name
, ==, "opts_list_01");
150 /* should not find anything at this point */
151 opts
= qemu_opts_find(list
, NULL
);
152 g_assert(opts
== NULL
);
154 /* create the opts */
155 opts
= qemu_opts_create(list
, NULL
, 0, &error_abort
);
156 g_assert(opts
!= NULL
);
157 g_assert(!QTAILQ_EMPTY(&list
->head
));
159 /* haven't set anything to str2 yet */
160 opt
= qemu_opt_get(opts
, "str2");
161 g_assert(opt
== NULL
);
163 qemu_opt_set(opts
, "str2", "value", &error_abort
);
165 /* now we have set str2, should know about it */
166 opt
= qemu_opt_get(opts
, "str2");
167 g_assert_cmpstr(opt
, ==, "value");
169 qemu_opt_set(opts
, "str2", "value2", &error_abort
);
171 /* having reset the value, the returned should be the reset one */
172 opt
= qemu_opt_get(opts
, "str2");
173 g_assert_cmpstr(opt
, ==, "value2");
177 /* should not find anything at this point */
178 opts
= qemu_opts_find(list
, NULL
);
179 g_assert(opts
== NULL
);
182 static void test_qemu_opt_get_bool(void)
189 list
= qemu_find_opts("opts_list_02");
190 g_assert(list
!= NULL
);
191 g_assert(QTAILQ_EMPTY(&list
->head
));
192 g_assert_cmpstr(list
->name
, ==, "opts_list_02");
194 /* should not find anything at this point */
195 opts
= qemu_opts_find(list
, NULL
);
196 g_assert(opts
== NULL
);
198 /* create the opts */
199 opts
= qemu_opts_create(list
, NULL
, 0, &error_abort
);
200 g_assert(opts
!= NULL
);
201 g_assert(!QTAILQ_EMPTY(&list
->head
));
203 /* haven't set anything to bool1 yet, so defval should be returned */
204 opt
= qemu_opt_get_bool(opts
, "bool1", false);
205 g_assert(opt
== false);
207 qemu_opt_set_bool(opts
, "bool1", true, &err
);
210 /* now we have set bool1, should know about it */
211 opt
= qemu_opt_get_bool(opts
, "bool1", false);
212 g_assert(opt
== true);
214 /* having reset the value, opt should be the reset one not defval */
215 qemu_opt_set_bool(opts
, "bool1", false, &err
);
218 opt
= qemu_opt_get_bool(opts
, "bool1", true);
219 g_assert(opt
== false);
223 /* should not find anything at this point */
224 opts
= qemu_opts_find(list
, NULL
);
225 g_assert(opts
== NULL
);
228 static void test_qemu_opt_get_number(void)
235 list
= qemu_find_opts("opts_list_01");
236 g_assert(list
!= NULL
);
237 g_assert(QTAILQ_EMPTY(&list
->head
));
238 g_assert_cmpstr(list
->name
, ==, "opts_list_01");
240 /* should not find anything at this point */
241 opts
= qemu_opts_find(list
, NULL
);
242 g_assert(opts
== NULL
);
244 /* create the opts */
245 opts
= qemu_opts_create(list
, NULL
, 0, &error_abort
);
246 g_assert(opts
!= NULL
);
247 g_assert(!QTAILQ_EMPTY(&list
->head
));
249 /* haven't set anything to number1 yet, so defval should be returned */
250 opt
= qemu_opt_get_number(opts
, "number1", 5);
253 qemu_opt_set_number(opts
, "number1", 10, &err
);
256 /* now we have set number1, should know about it */
257 opt
= qemu_opt_get_number(opts
, "number1", 5);
260 /* having reset it, the returned should be the reset one not defval */
261 qemu_opt_set_number(opts
, "number1", 15, &err
);
264 opt
= qemu_opt_get_number(opts
, "number1", 5);
269 /* should not find anything at this point */
270 opts
= qemu_opts_find(list
, NULL
);
271 g_assert(opts
== NULL
);
274 static void test_qemu_opt_get_size(void)
281 list
= qemu_find_opts("opts_list_02");
282 g_assert(list
!= NULL
);
283 g_assert(QTAILQ_EMPTY(&list
->head
));
284 g_assert_cmpstr(list
->name
, ==, "opts_list_02");
286 /* should not find anything at this point */
287 opts
= qemu_opts_find(list
, NULL
);
288 g_assert(opts
== NULL
);
290 /* create the opts */
291 opts
= qemu_opts_create(list
, NULL
, 0, &error_abort
);
292 g_assert(opts
!= NULL
);
293 g_assert(!QTAILQ_EMPTY(&list
->head
));
295 /* haven't set anything to size1 yet, so defval should be returned */
296 opt
= qemu_opt_get_size(opts
, "size1", 5);
300 g_assert(dict
!= NULL
);
302 qdict_put(dict
, "size1", qstring_from_str("10"));
304 qemu_opts_absorb_qdict(opts
, dict
, &error_abort
);
305 g_assert(error_abort
== NULL
);
307 /* now we have set size1, should know about it */
308 opt
= qemu_opt_get_size(opts
, "size1", 5);
312 qdict_put(dict
, "size1", qstring_from_str("15"));
314 qemu_opts_absorb_qdict(opts
, dict
, &error_abort
);
315 g_assert(error_abort
== NULL
);
317 /* test the reset value */
318 opt
= qemu_opt_get_size(opts
, "size1", 5);
321 qdict_del(dict
, "size1");
326 /* should not find anything at this point */
327 opts
= qemu_opts_find(list
, NULL
);
328 g_assert(opts
== NULL
);
331 static void test_qemu_opt_unset(void)
337 /* dynamically initialized (parsed) opts */
338 opts
= qemu_opts_parse(&opts_list_03
, "key=value", false, NULL
);
339 g_assert(opts
!= NULL
);
341 /* check default/parsed value */
342 value
= qemu_opt_get(opts
, "key");
343 g_assert_cmpstr(value
, ==, "value");
345 /* reset it to value2 */
346 qemu_opt_set(opts
, "key", "value2", &error_abort
);
348 value
= qemu_opt_get(opts
, "key");
349 g_assert_cmpstr(value
, ==, "value2");
351 /* unset, valid only for "accept any" */
352 ret
= qemu_opt_unset(opts
, "key");
355 /* after reset the value should be the parsed/default one */
356 value
= qemu_opt_get(opts
, "key");
357 g_assert_cmpstr(value
, ==, "value");
362 static void test_qemu_opts_reset(void)
369 list
= qemu_find_opts("opts_list_01");
370 g_assert(list
!= NULL
);
371 g_assert(QTAILQ_EMPTY(&list
->head
));
372 g_assert_cmpstr(list
->name
, ==, "opts_list_01");
374 /* should not find anything at this point */
375 opts
= qemu_opts_find(list
, NULL
);
376 g_assert(opts
== NULL
);
378 /* create the opts */
379 opts
= qemu_opts_create(list
, NULL
, 0, &error_abort
);
380 g_assert(opts
!= NULL
);
381 g_assert(!QTAILQ_EMPTY(&list
->head
));
383 /* haven't set anything to number1 yet, so defval should be returned */
384 opt
= qemu_opt_get_number(opts
, "number1", 5);
387 qemu_opt_set_number(opts
, "number1", 10, &err
);
390 /* now we have set number1, should know about it */
391 opt
= qemu_opt_get_number(opts
, "number1", 5);
394 qemu_opts_reset(list
);
396 /* should not find anything at this point */
397 opts
= qemu_opts_find(list
, NULL
);
398 g_assert(opts
== NULL
);
401 static void test_qemu_opts_set(void)
408 list
= qemu_find_opts("opts_list_01");
409 g_assert(list
!= NULL
);
410 g_assert(QTAILQ_EMPTY(&list
->head
));
411 g_assert_cmpstr(list
->name
, ==, "opts_list_01");
413 /* should not find anything at this point */
414 opts
= qemu_opts_find(list
, NULL
);
415 g_assert(opts
== NULL
);
417 /* implicitly create opts and set str3 value */
418 qemu_opts_set(list
, NULL
, "str3", "value", &err
);
420 g_assert(!QTAILQ_EMPTY(&list
->head
));
422 /* get the just created opts */
423 opts
= qemu_opts_find(list
, NULL
);
424 g_assert(opts
!= NULL
);
426 /* check the str3 value */
427 opt
= qemu_opt_get(opts
, "str3");
428 g_assert_cmpstr(opt
, ==, "value");
432 /* should not find anything at this point */
433 opts
= qemu_opts_find(list
, NULL
);
434 g_assert(opts
== NULL
);
437 static int opts_count_iter(void *opaque
, const char *name
, const char *value
,
440 (*(size_t *)opaque
)++;
444 static size_t opts_count(QemuOpts
*opts
)
448 qemu_opt_foreach(opts
, opts_count_iter
, &n
, NULL
);
452 static void test_opts_parse(void)
460 opts
= qemu_opts_parse(&opts_list_03
, "", false, &error_abort
);
461 g_assert_cmpuint(opts_count(opts
), ==, 0);
464 opts
= qemu_opts_parse(&opts_list_03
, "=val", false, &error_abort
);
465 g_assert_cmpuint(opts_count(opts
), ==, 1);
466 g_assert_cmpstr(qemu_opt_get(opts
, ""), ==, "val");
469 memset(long_key
, 'a', 127);
472 params
= g_strdup_printf("%s=v", long_key
);
473 opts
= qemu_opts_parse(&opts_list_03
, params
+ 1, NULL
, &error_abort
);
474 g_assert_cmpuint(opts_count(opts
), ==, 1);
475 g_assert_cmpstr(qemu_opt_get(opts
, long_key
+ 1), ==, "v");
477 /* Overlong key gets truncated */
478 opts
= qemu_opts_parse(&opts_list_03
, params
, NULL
, &error_abort
);
479 g_assert(opts_count(opts
) == 1);
481 g_assert_cmpstr(qemu_opt_get(opts
, long_key
), ==, "v");
484 /* Multiple keys, last one wins */
485 opts
= qemu_opts_parse(&opts_list_03
, "a=1,b=2,,x,a=3",
486 false, &error_abort
);
487 g_assert_cmpuint(opts_count(opts
), ==, 3);
488 g_assert_cmpstr(qemu_opt_get(opts
, "a"), ==, "3");
489 g_assert_cmpstr(qemu_opt_get(opts
, "b"), ==, "2,x");
491 /* Except when it doesn't */
492 opts
= qemu_opts_parse(&opts_list_03
, "id=foo,id=bar",
493 false, &error_abort
);
494 g_assert_cmpuint(opts_count(opts
), ==, 0);
495 g_assert_cmpstr(qemu_opts_id(opts
), ==, "foo");
497 /* TODO Cover low-level access to repeated keys */
499 /* Trailing comma is ignored */
500 opts
= qemu_opts_parse(&opts_list_03
, "x=y,", false, &error_abort
);
501 g_assert_cmpuint(opts_count(opts
), ==, 1);
502 g_assert_cmpstr(qemu_opt_get(opts
, "x"), ==, "y");
504 /* Except when it isn't */
505 opts
= qemu_opts_parse(&opts_list_03
, ",", false, &error_abort
);
506 g_assert_cmpuint(opts_count(opts
), ==, 1);
507 g_assert_cmpstr(qemu_opt_get(opts
, ""), ==, "on");
510 opts
= qemu_opts_parse(&opts_list_03
, "x=y,id=foo", false, &err
);
511 error_free_or_abort(&err
);
513 /* TODO Cover .merge_lists = true */
515 /* Buggy ID recognition */
516 opts
= qemu_opts_parse(&opts_list_03
, "x=,,id=bar", false, &error_abort
);
517 g_assert_cmpuint(opts_count(opts
), ==, 1);
518 g_assert_cmpstr(qemu_opts_id(opts
), ==, "bar"); /* BUG */
519 g_assert_cmpstr(qemu_opt_get(opts
, "x"), ==, ",id=bar");
522 opts
= qemu_opts_parse(&opts_list_01
, "id=666", false, &err
);
523 error_free_or_abort(&err
);
527 opts
= qemu_opts_parse(&opts_list_03
, "an,noaus,noaus=",
528 false, &error_abort
);
529 g_assert_cmpuint(opts_count(opts
), ==, 3);
530 g_assert_cmpstr(qemu_opt_get(opts
, "an"), ==, "on");
531 g_assert_cmpstr(qemu_opt_get(opts
, "aus"), ==, "off");
532 g_assert_cmpstr(qemu_opt_get(opts
, "noaus"), ==, "");
534 /* Implied value, negated empty key */
535 opts
= qemu_opts_parse(&opts_list_03
, "no", false, &error_abort
);
536 g_assert_cmpuint(opts_count(opts
), ==, 1);
537 g_assert_cmpstr(qemu_opt_get(opts
, ""), ==, "off");
540 opts
= qemu_opts_parse(&opts_list_03
, "an,noaus,noaus=", true,
542 g_assert_cmpuint(opts_count(opts
), ==, 3);
543 g_assert_cmpstr(qemu_opt_get(opts
, "implied"), ==, "an");
544 g_assert_cmpstr(qemu_opt_get(opts
, "aus"), ==, "off");
545 g_assert_cmpstr(qemu_opt_get(opts
, "noaus"), ==, "");
547 /* Implied key with empty value */
548 opts
= qemu_opts_parse(&opts_list_03
, ",", true, &error_abort
);
549 g_assert_cmpuint(opts_count(opts
), ==, 1);
550 g_assert_cmpstr(qemu_opt_get(opts
, "implied"), ==, "");
552 /* Implied key with comma value */
553 opts
= qemu_opts_parse(&opts_list_03
, ",,,a=1", true, &error_abort
);
554 g_assert_cmpuint(opts_count(opts
), ==, 2);
555 g_assert_cmpstr(qemu_opt_get(opts
, "implied"), ==, ",");
556 g_assert_cmpstr(qemu_opt_get(opts
, "a"), ==, "1");
558 /* Empty key is not an implied key */
559 opts
= qemu_opts_parse(&opts_list_03
, "=val", true, &error_abort
);
560 g_assert_cmpuint(opts_count(opts
), ==, 1);
561 g_assert_cmpstr(qemu_opt_get(opts
, ""), ==, "val");
564 opts
= qemu_opts_parse(&opts_list_01
, "nonexistent=", false, &err
);
565 error_free_or_abort(&err
);
568 qemu_opts_reset(&opts_list_01
);
569 qemu_opts_reset(&opts_list_03
);
572 static void test_opts_parse_bool(void)
577 opts
= qemu_opts_parse(&opts_list_02
, "bool1=on,bool2=off",
578 false, &error_abort
);
579 g_assert_cmpuint(opts_count(opts
), ==, 2);
580 g_assert(qemu_opt_get_bool(opts
, "bool1", false));
581 g_assert(!qemu_opt_get_bool(opts
, "bool2", true));
583 opts
= qemu_opts_parse(&opts_list_02
, "bool1=offer", false, &err
);
584 error_free_or_abort(&err
);
587 qemu_opts_reset(&opts_list_02
);
590 static void test_opts_parse_number(void)
595 /* Lower limit zero */
596 opts
= qemu_opts_parse(&opts_list_01
, "number1=0", false, &error_abort
);
597 g_assert_cmpuint(opts_count(opts
), ==, 1);
598 g_assert_cmpuint(qemu_opt_get_number(opts
, "number1", 1), ==, 0);
600 /* Upper limit 2^64-1 */
601 opts
= qemu_opts_parse(&opts_list_01
,
602 "number1=18446744073709551615,number2=-1",
603 false, &error_abort
);
604 g_assert_cmpuint(opts_count(opts
), ==, 2);
605 g_assert_cmphex(qemu_opt_get_number(opts
, "number1", 1), ==, UINT64_MAX
);
606 g_assert_cmphex(qemu_opt_get_number(opts
, "number2", 0), ==, UINT64_MAX
);
608 /* Above upper limit */
609 opts
= qemu_opts_parse(&opts_list_01
, "number1=18446744073709551616",
611 error_free_or_abort(&err
);
614 /* Below lower limit */
615 opts
= qemu_opts_parse(&opts_list_01
, "number1=-18446744073709551616",
617 error_free_or_abort(&err
);
621 opts
= qemu_opts_parse(&opts_list_01
, "number1=0x2a,number2=052",
622 false, &error_abort
);
623 g_assert_cmpuint(opts_count(opts
), ==, 2);
624 g_assert_cmpuint(qemu_opt_get_number(opts
, "number1", 1), ==, 42);
625 g_assert_cmpuint(qemu_opt_get_number(opts
, "number2", 0), ==, 42);
628 opts
= qemu_opts_parse(&opts_list_01
, "number1=", false, &err
);
629 error_free_or_abort(&err
);
631 opts
= qemu_opts_parse(&opts_list_01
, "number1=eins", false, &err
);
632 error_free_or_abort(&err
);
635 /* Leading whitespace */
636 opts
= qemu_opts_parse(&opts_list_01
, "number1= \t42",
637 false, &error_abort
);
638 g_assert_cmpuint(opts_count(opts
), ==, 1);
639 g_assert_cmpuint(qemu_opt_get_number(opts
, "number1", 1), ==, 42);
642 opts
= qemu_opts_parse(&opts_list_01
, "number1=3.14", false, &err
);
643 error_free_or_abort(&err
);
645 opts
= qemu_opts_parse(&opts_list_01
, "number1=08", false, &err
);
646 error_free_or_abort(&err
);
648 opts
= qemu_opts_parse(&opts_list_01
, "number1=0 ", false, &err
);
649 error_free_or_abort(&err
);
652 qemu_opts_reset(&opts_list_01
);
655 static void test_opts_parse_size(void)
660 /* Lower limit zero */
661 opts
= qemu_opts_parse(&opts_list_02
, "size1=0", false, &error_abort
);
662 g_assert_cmpuint(opts_count(opts
), ==, 1);
663 g_assert_cmpuint(qemu_opt_get_size(opts
, "size1", 1), ==, 0);
665 /* Note: precision is 53 bits since we're parsing with strtod() */
667 /* Around limit of precision: 2^53-1, 2^53, 2^54 */
668 opts
= qemu_opts_parse(&opts_list_02
,
669 "size1=9007199254740991,"
670 "size2=9007199254740992,"
671 "size3=9007199254740993",
672 false, &error_abort
);
673 g_assert_cmpuint(opts_count(opts
), ==, 3);
674 g_assert_cmphex(qemu_opt_get_size(opts
, "size1", 1),
675 ==, 0x1fffffffffffff);
676 g_assert_cmphex(qemu_opt_get_size(opts
, "size2", 1),
677 ==, 0x20000000000000);
678 g_assert_cmphex(qemu_opt_get_size(opts
, "size3", 1),
679 ==, 0x20000000000000);
681 /* Close to signed upper limit 0x7ffffffffffffc00 (53 msbs set) */
682 opts
= qemu_opts_parse(&opts_list_02
,
683 "size1=9223372036854774784," /* 7ffffffffffffc00 */
684 "size2=9223372036854775295", /* 7ffffffffffffdff */
685 false, &error_abort
);
686 g_assert_cmpuint(opts_count(opts
), ==, 2);
687 g_assert_cmphex(qemu_opt_get_size(opts
, "size1", 1),
688 ==, 0x7ffffffffffffc00);
689 g_assert_cmphex(qemu_opt_get_size(opts
, "size2", 1),
690 ==, 0x7ffffffffffffc00);
692 /* Close to actual upper limit 0xfffffffffffff800 (53 msbs set) */
693 opts
= qemu_opts_parse(&opts_list_02
,
694 "size1=18446744073709549568," /* fffffffffffff800 */
695 "size2=18446744073709550591", /* fffffffffffffbff */
696 false, &error_abort
);
697 g_assert_cmpuint(opts_count(opts
), ==, 2);
698 g_assert_cmphex(qemu_opt_get_size(opts
, "size1", 1),
699 ==, 0xfffffffffffff800);
700 g_assert_cmphex(qemu_opt_get_size(opts
, "size2", 1),
701 ==, 0xfffffffffffff800);
704 opts
= qemu_opts_parse(&opts_list_02
, "size1=-1", false, &err
);
705 error_free_or_abort(&err
);
707 opts
= qemu_opts_parse(&opts_list_02
,
708 "size1=18446744073709550592", /* fffffffffffffc00 */
710 error_free_or_abort(&err
);
714 opts
= qemu_opts_parse(&opts_list_02
, "size1=8b,size2=1.5k,size3=2M",
715 false, &error_abort
);
716 g_assert_cmpuint(opts_count(opts
), ==, 3);
717 g_assert_cmphex(qemu_opt_get_size(opts
, "size1", 0), ==, 8);
718 g_assert_cmphex(qemu_opt_get_size(opts
, "size2", 0), ==, 1536);
719 g_assert_cmphex(qemu_opt_get_size(opts
, "size3", 0), ==, 2 * M_BYTE
);
720 opts
= qemu_opts_parse(&opts_list_02
, "size1=0.1G,size2=16777215T",
721 false, &error_abort
);
722 g_assert_cmpuint(opts_count(opts
), ==, 2);
723 g_assert_cmphex(qemu_opt_get_size(opts
, "size1", 0), ==, G_BYTE
/ 10);
724 g_assert_cmphex(qemu_opt_get_size(opts
, "size2", 0),
725 ==, 16777215 * T_BYTE
);
727 /* Beyond limit with suffix */
728 opts
= qemu_opts_parse(&opts_list_02
, "size1=16777216T",
730 error_free_or_abort(&err
);
734 opts
= qemu_opts_parse(&opts_list_02
, "size1=16E", false, &err
);
735 error_free_or_abort(&err
);
737 opts
= qemu_opts_parse(&opts_list_02
, "size1=16Gi", false, &err
);
738 error_free_or_abort(&err
);
741 qemu_opts_reset(&opts_list_02
);
744 int main(int argc
, char *argv
[])
747 g_test_init(&argc
, &argv
, NULL
);
748 g_test_add_func("/qemu-opts/find_unknown_opts", test_find_unknown_opts
);
749 g_test_add_func("/qemu-opts/find_opts", test_qemu_find_opts
);
750 g_test_add_func("/qemu-opts/opts_create", test_qemu_opts_create
);
751 g_test_add_func("/qemu-opts/opt_get", test_qemu_opt_get
);
752 g_test_add_func("/qemu-opts/opt_get_bool", test_qemu_opt_get_bool
);
753 g_test_add_func("/qemu-opts/opt_get_number", test_qemu_opt_get_number
);
754 g_test_add_func("/qemu-opts/opt_get_size", test_qemu_opt_get_size
);
755 g_test_add_func("/qemu-opts/opt_unset", test_qemu_opt_unset
);
756 g_test_add_func("/qemu-opts/opts_reset", test_qemu_opts_reset
);
757 g_test_add_func("/qemu-opts/opts_set", test_qemu_opts_set
);
758 g_test_add_func("/qemu-opts/opts_parse/general", test_opts_parse
);
759 g_test_add_func("/qemu-opts/opts_parse/bool", test_opts_parse_bool
);
760 g_test_add_func("/qemu-opts/opts_parse/number", test_opts_parse_number
);
761 g_test_add_func("/qemu-opts/opts_parse/size", test_opts_parse_size
);