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 "qemu/option.h"
13 #include "qapi/error.h"
14 #include "qapi/qmp/qdict.h"
15 #include "qapi/qmp/qstring.h"
16 #include "qemu/config-file.h"
19 static QemuOptsList opts_list_01
= {
20 .name
= "opts_list_01",
21 .head
= QTAILQ_HEAD_INITIALIZER(opts_list_01
.head
),
25 .type
= QEMU_OPT_STRING
,
28 .type
= QEMU_OPT_STRING
,
31 .type
= QEMU_OPT_STRING
,
34 .type
= QEMU_OPT_NUMBER
,
37 .type
= QEMU_OPT_NUMBER
,
43 static QemuOptsList opts_list_02
= {
44 .name
= "opts_list_02",
45 .head
= QTAILQ_HEAD_INITIALIZER(opts_list_02
.head
),
49 .type
= QEMU_OPT_STRING
,
52 .type
= QEMU_OPT_STRING
,
55 .type
= QEMU_OPT_BOOL
,
58 .type
= QEMU_OPT_BOOL
,
61 .type
= QEMU_OPT_SIZE
,
64 .type
= QEMU_OPT_SIZE
,
67 .type
= QEMU_OPT_SIZE
,
73 static QemuOptsList opts_list_03
= {
74 .name
= "opts_list_03",
75 .implied_opt_name
= "implied",
76 .head
= QTAILQ_HEAD_INITIALIZER(opts_list_03
.head
),
78 /* no elements => accept any params */
83 static void register_opts(void)
85 qemu_add_opts(&opts_list_01
);
86 qemu_add_opts(&opts_list_02
);
87 qemu_add_opts(&opts_list_03
);
90 static void test_find_unknown_opts(void)
95 /* should not return anything, we don't have an "unknown" option */
96 list
= qemu_find_opts_err("unknown", &err
);
97 g_assert(list
== NULL
);
98 error_free_or_abort(&err
);
101 static void test_qemu_find_opts(void)
105 /* we have an "opts_list_01" option, should return it */
106 list
= qemu_find_opts("opts_list_01");
107 g_assert(list
!= NULL
);
108 g_assert_cmpstr(list
->name
, ==, "opts_list_01");
111 static void test_qemu_opts_create(void)
116 list
= qemu_find_opts("opts_list_01");
117 g_assert(list
!= NULL
);
118 g_assert(QTAILQ_EMPTY(&list
->head
));
119 g_assert_cmpstr(list
->name
, ==, "opts_list_01");
121 /* should not find anything at this point */
122 opts
= qemu_opts_find(list
, NULL
);
123 g_assert(opts
== NULL
);
125 /* create the opts */
126 opts
= qemu_opts_create(list
, NULL
, 0, &error_abort
);
127 g_assert(opts
!= NULL
);
128 g_assert(!QTAILQ_EMPTY(&list
->head
));
130 /* now we've create the opts, must find it */
131 opts
= qemu_opts_find(list
, NULL
);
132 g_assert(opts
!= NULL
);
136 /* should not find anything at this point */
137 opts
= qemu_opts_find(list
, NULL
);
138 g_assert(opts
== NULL
);
141 static void test_qemu_opt_get(void)
145 const char *opt
= NULL
;
147 list
= qemu_find_opts("opts_list_01");
148 g_assert(list
!= NULL
);
149 g_assert(QTAILQ_EMPTY(&list
->head
));
150 g_assert_cmpstr(list
->name
, ==, "opts_list_01");
152 /* should not find anything at this point */
153 opts
= qemu_opts_find(list
, NULL
);
154 g_assert(opts
== NULL
);
156 /* create the opts */
157 opts
= qemu_opts_create(list
, NULL
, 0, &error_abort
);
158 g_assert(opts
!= NULL
);
159 g_assert(!QTAILQ_EMPTY(&list
->head
));
161 /* haven't set anything to str2 yet */
162 opt
= qemu_opt_get(opts
, "str2");
163 g_assert(opt
== NULL
);
165 qemu_opt_set(opts
, "str2", "value", &error_abort
);
167 /* now we have set str2, should know about it */
168 opt
= qemu_opt_get(opts
, "str2");
169 g_assert_cmpstr(opt
, ==, "value");
171 qemu_opt_set(opts
, "str2", "value2", &error_abort
);
173 /* having reset the value, the returned should be the reset one */
174 opt
= qemu_opt_get(opts
, "str2");
175 g_assert_cmpstr(opt
, ==, "value2");
179 /* should not find anything at this point */
180 opts
= qemu_opts_find(list
, NULL
);
181 g_assert(opts
== NULL
);
184 static void test_qemu_opt_get_bool(void)
191 list
= qemu_find_opts("opts_list_02");
192 g_assert(list
!= NULL
);
193 g_assert(QTAILQ_EMPTY(&list
->head
));
194 g_assert_cmpstr(list
->name
, ==, "opts_list_02");
196 /* should not find anything at this point */
197 opts
= qemu_opts_find(list
, NULL
);
198 g_assert(opts
== NULL
);
200 /* create the opts */
201 opts
= qemu_opts_create(list
, NULL
, 0, &error_abort
);
202 g_assert(opts
!= NULL
);
203 g_assert(!QTAILQ_EMPTY(&list
->head
));
205 /* haven't set anything to bool1 yet, so defval should be returned */
206 opt
= qemu_opt_get_bool(opts
, "bool1", false);
207 g_assert(opt
== false);
209 qemu_opt_set_bool(opts
, "bool1", true, &err
);
212 /* now we have set bool1, should know about it */
213 opt
= qemu_opt_get_bool(opts
, "bool1", false);
214 g_assert(opt
== true);
216 /* having reset the value, opt should be the reset one not defval */
217 qemu_opt_set_bool(opts
, "bool1", false, &err
);
220 opt
= qemu_opt_get_bool(opts
, "bool1", true);
221 g_assert(opt
== false);
225 /* should not find anything at this point */
226 opts
= qemu_opts_find(list
, NULL
);
227 g_assert(opts
== NULL
);
230 static void test_qemu_opt_get_number(void)
237 list
= qemu_find_opts("opts_list_01");
238 g_assert(list
!= NULL
);
239 g_assert(QTAILQ_EMPTY(&list
->head
));
240 g_assert_cmpstr(list
->name
, ==, "opts_list_01");
242 /* should not find anything at this point */
243 opts
= qemu_opts_find(list
, NULL
);
244 g_assert(opts
== NULL
);
246 /* create the opts */
247 opts
= qemu_opts_create(list
, NULL
, 0, &error_abort
);
248 g_assert(opts
!= NULL
);
249 g_assert(!QTAILQ_EMPTY(&list
->head
));
251 /* haven't set anything to number1 yet, so defval should be returned */
252 opt
= qemu_opt_get_number(opts
, "number1", 5);
255 qemu_opt_set_number(opts
, "number1", 10, &err
);
258 /* now we have set number1, should know about it */
259 opt
= qemu_opt_get_number(opts
, "number1", 5);
262 /* having reset it, the returned should be the reset one not defval */
263 qemu_opt_set_number(opts
, "number1", 15, &err
);
266 opt
= qemu_opt_get_number(opts
, "number1", 5);
271 /* should not find anything at this point */
272 opts
= qemu_opts_find(list
, NULL
);
273 g_assert(opts
== NULL
);
276 static void test_qemu_opt_get_size(void)
283 list
= qemu_find_opts("opts_list_02");
284 g_assert(list
!= NULL
);
285 g_assert(QTAILQ_EMPTY(&list
->head
));
286 g_assert_cmpstr(list
->name
, ==, "opts_list_02");
288 /* should not find anything at this point */
289 opts
= qemu_opts_find(list
, NULL
);
290 g_assert(opts
== NULL
);
292 /* create the opts */
293 opts
= qemu_opts_create(list
, NULL
, 0, &error_abort
);
294 g_assert(opts
!= NULL
);
295 g_assert(!QTAILQ_EMPTY(&list
->head
));
297 /* haven't set anything to size1 yet, so defval should be returned */
298 opt
= qemu_opt_get_size(opts
, "size1", 5);
302 g_assert(dict
!= NULL
);
304 qdict_put_str(dict
, "size1", "10");
306 qemu_opts_absorb_qdict(opts
, dict
, &error_abort
);
307 g_assert(error_abort
== NULL
);
309 /* now we have set size1, should know about it */
310 opt
= qemu_opt_get_size(opts
, "size1", 5);
314 qdict_put_str(dict
, "size1", "15");
316 qemu_opts_absorb_qdict(opts
, dict
, &error_abort
);
317 g_assert(error_abort
== NULL
);
319 /* test the reset value */
320 opt
= qemu_opt_get_size(opts
, "size1", 5);
323 qdict_del(dict
, "size1");
328 /* should not find anything at this point */
329 opts
= qemu_opts_find(list
, NULL
);
330 g_assert(opts
== NULL
);
333 static void test_qemu_opt_unset(void)
339 /* dynamically initialized (parsed) opts */
340 opts
= qemu_opts_parse(&opts_list_03
, "key=value", false, NULL
);
341 g_assert(opts
!= NULL
);
343 /* check default/parsed value */
344 value
= qemu_opt_get(opts
, "key");
345 g_assert_cmpstr(value
, ==, "value");
347 /* reset it to value2 */
348 qemu_opt_set(opts
, "key", "value2", &error_abort
);
350 value
= qemu_opt_get(opts
, "key");
351 g_assert_cmpstr(value
, ==, "value2");
353 /* unset, valid only for "accept any" */
354 ret
= qemu_opt_unset(opts
, "key");
357 /* after reset the value should be the parsed/default one */
358 value
= qemu_opt_get(opts
, "key");
359 g_assert_cmpstr(value
, ==, "value");
364 static void test_qemu_opts_reset(void)
371 list
= qemu_find_opts("opts_list_01");
372 g_assert(list
!= NULL
);
373 g_assert(QTAILQ_EMPTY(&list
->head
));
374 g_assert_cmpstr(list
->name
, ==, "opts_list_01");
376 /* should not find anything at this point */
377 opts
= qemu_opts_find(list
, NULL
);
378 g_assert(opts
== NULL
);
380 /* create the opts */
381 opts
= qemu_opts_create(list
, NULL
, 0, &error_abort
);
382 g_assert(opts
!= NULL
);
383 g_assert(!QTAILQ_EMPTY(&list
->head
));
385 /* haven't set anything to number1 yet, so defval should be returned */
386 opt
= qemu_opt_get_number(opts
, "number1", 5);
389 qemu_opt_set_number(opts
, "number1", 10, &err
);
392 /* now we have set number1, should know about it */
393 opt
= qemu_opt_get_number(opts
, "number1", 5);
396 qemu_opts_reset(list
);
398 /* should not find anything at this point */
399 opts
= qemu_opts_find(list
, NULL
);
400 g_assert(opts
== NULL
);
403 static void test_qemu_opts_set(void)
410 list
= qemu_find_opts("opts_list_01");
411 g_assert(list
!= NULL
);
412 g_assert(QTAILQ_EMPTY(&list
->head
));
413 g_assert_cmpstr(list
->name
, ==, "opts_list_01");
415 /* should not find anything at this point */
416 opts
= qemu_opts_find(list
, NULL
);
417 g_assert(opts
== NULL
);
419 /* implicitly create opts and set str3 value */
420 qemu_opts_set(list
, NULL
, "str3", "value", &err
);
422 g_assert(!QTAILQ_EMPTY(&list
->head
));
424 /* get the just created opts */
425 opts
= qemu_opts_find(list
, NULL
);
426 g_assert(opts
!= NULL
);
428 /* check the str3 value */
429 opt
= qemu_opt_get(opts
, "str3");
430 g_assert_cmpstr(opt
, ==, "value");
434 /* should not find anything at this point */
435 opts
= qemu_opts_find(list
, NULL
);
436 g_assert(opts
== NULL
);
439 static int opts_count_iter(void *opaque
, const char *name
, const char *value
,
442 (*(size_t *)opaque
)++;
446 static size_t opts_count(QemuOpts
*opts
)
450 qemu_opt_foreach(opts
, opts_count_iter
, &n
, NULL
);
454 static void test_opts_parse(void)
462 opts
= qemu_opts_parse(&opts_list_03
, "", false, &error_abort
);
463 g_assert_cmpuint(opts_count(opts
), ==, 0);
466 opts
= qemu_opts_parse(&opts_list_03
, "=val", false, &error_abort
);
467 g_assert_cmpuint(opts_count(opts
), ==, 1);
468 g_assert_cmpstr(qemu_opt_get(opts
, ""), ==, "val");
471 memset(long_key
, 'a', 127);
474 params
= g_strdup_printf("%s=v", long_key
);
475 opts
= qemu_opts_parse(&opts_list_03
, params
+ 1, NULL
, &error_abort
);
476 g_assert_cmpuint(opts_count(opts
), ==, 1);
477 g_assert_cmpstr(qemu_opt_get(opts
, long_key
+ 1), ==, "v");
479 /* Overlong key gets truncated */
480 opts
= qemu_opts_parse(&opts_list_03
, params
, NULL
, &error_abort
);
481 g_assert(opts_count(opts
) == 1);
483 g_assert_cmpstr(qemu_opt_get(opts
, long_key
), ==, "v");
486 /* Multiple keys, last one wins */
487 opts
= qemu_opts_parse(&opts_list_03
, "a=1,b=2,,x,a=3",
488 false, &error_abort
);
489 g_assert_cmpuint(opts_count(opts
), ==, 3);
490 g_assert_cmpstr(qemu_opt_get(opts
, "a"), ==, "3");
491 g_assert_cmpstr(qemu_opt_get(opts
, "b"), ==, "2,x");
493 /* Except when it doesn't */
494 opts
= qemu_opts_parse(&opts_list_03
, "id=foo,id=bar",
495 false, &error_abort
);
496 g_assert_cmpuint(opts_count(opts
), ==, 0);
497 g_assert_cmpstr(qemu_opts_id(opts
), ==, "foo");
499 /* TODO Cover low-level access to repeated keys */
501 /* Trailing comma is ignored */
502 opts
= qemu_opts_parse(&opts_list_03
, "x=y,", false, &error_abort
);
503 g_assert_cmpuint(opts_count(opts
), ==, 1);
504 g_assert_cmpstr(qemu_opt_get(opts
, "x"), ==, "y");
506 /* Except when it isn't */
507 opts
= qemu_opts_parse(&opts_list_03
, ",", false, &error_abort
);
508 g_assert_cmpuint(opts_count(opts
), ==, 1);
509 g_assert_cmpstr(qemu_opt_get(opts
, ""), ==, "on");
512 opts
= qemu_opts_parse(&opts_list_03
, "x=y,id=foo", false, &err
);
513 error_free_or_abort(&err
);
515 /* TODO Cover .merge_lists = true */
517 /* Buggy ID recognition */
518 opts
= qemu_opts_parse(&opts_list_03
, "x=,,id=bar", false, &error_abort
);
519 g_assert_cmpuint(opts_count(opts
), ==, 1);
520 g_assert_cmpstr(qemu_opts_id(opts
), ==, "bar"); /* BUG */
521 g_assert_cmpstr(qemu_opt_get(opts
, "x"), ==, ",id=bar");
524 opts
= qemu_opts_parse(&opts_list_01
, "id=666", false, &err
);
525 error_free_or_abort(&err
);
529 opts
= qemu_opts_parse(&opts_list_03
, "an,noaus,noaus=",
530 false, &error_abort
);
531 g_assert_cmpuint(opts_count(opts
), ==, 3);
532 g_assert_cmpstr(qemu_opt_get(opts
, "an"), ==, "on");
533 g_assert_cmpstr(qemu_opt_get(opts
, "aus"), ==, "off");
534 g_assert_cmpstr(qemu_opt_get(opts
, "noaus"), ==, "");
536 /* Implied value, negated empty key */
537 opts
= qemu_opts_parse(&opts_list_03
, "no", false, &error_abort
);
538 g_assert_cmpuint(opts_count(opts
), ==, 1);
539 g_assert_cmpstr(qemu_opt_get(opts
, ""), ==, "off");
542 opts
= qemu_opts_parse(&opts_list_03
, "an,noaus,noaus=", true,
544 g_assert_cmpuint(opts_count(opts
), ==, 3);
545 g_assert_cmpstr(qemu_opt_get(opts
, "implied"), ==, "an");
546 g_assert_cmpstr(qemu_opt_get(opts
, "aus"), ==, "off");
547 g_assert_cmpstr(qemu_opt_get(opts
, "noaus"), ==, "");
549 /* Implied key with empty value */
550 opts
= qemu_opts_parse(&opts_list_03
, ",", true, &error_abort
);
551 g_assert_cmpuint(opts_count(opts
), ==, 1);
552 g_assert_cmpstr(qemu_opt_get(opts
, "implied"), ==, "");
554 /* Implied key with comma value */
555 opts
= qemu_opts_parse(&opts_list_03
, ",,,a=1", true, &error_abort
);
556 g_assert_cmpuint(opts_count(opts
), ==, 2);
557 g_assert_cmpstr(qemu_opt_get(opts
, "implied"), ==, ",");
558 g_assert_cmpstr(qemu_opt_get(opts
, "a"), ==, "1");
560 /* Empty key is not an implied key */
561 opts
= qemu_opts_parse(&opts_list_03
, "=val", true, &error_abort
);
562 g_assert_cmpuint(opts_count(opts
), ==, 1);
563 g_assert_cmpstr(qemu_opt_get(opts
, ""), ==, "val");
566 opts
= qemu_opts_parse(&opts_list_01
, "nonexistent=", false, &err
);
567 error_free_or_abort(&err
);
570 qemu_opts_reset(&opts_list_01
);
571 qemu_opts_reset(&opts_list_03
);
574 static void test_opts_parse_bool(void)
579 opts
= qemu_opts_parse(&opts_list_02
, "bool1=on,bool2=off",
580 false, &error_abort
);
581 g_assert_cmpuint(opts_count(opts
), ==, 2);
582 g_assert(qemu_opt_get_bool(opts
, "bool1", false));
583 g_assert(!qemu_opt_get_bool(opts
, "bool2", true));
585 opts
= qemu_opts_parse(&opts_list_02
, "bool1=offer", false, &err
);
586 error_free_or_abort(&err
);
589 qemu_opts_reset(&opts_list_02
);
592 static void test_opts_parse_number(void)
597 /* Lower limit zero */
598 opts
= qemu_opts_parse(&opts_list_01
, "number1=0", false, &error_abort
);
599 g_assert_cmpuint(opts_count(opts
), ==, 1);
600 g_assert_cmpuint(qemu_opt_get_number(opts
, "number1", 1), ==, 0);
602 /* Upper limit 2^64-1 */
603 opts
= qemu_opts_parse(&opts_list_01
,
604 "number1=18446744073709551615,number2=-1",
605 false, &error_abort
);
606 g_assert_cmpuint(opts_count(opts
), ==, 2);
607 g_assert_cmphex(qemu_opt_get_number(opts
, "number1", 1), ==, UINT64_MAX
);
608 g_assert_cmphex(qemu_opt_get_number(opts
, "number2", 0), ==, UINT64_MAX
);
610 /* Above upper limit */
611 opts
= qemu_opts_parse(&opts_list_01
, "number1=18446744073709551616",
613 error_free_or_abort(&err
);
616 /* Below lower limit */
617 opts
= qemu_opts_parse(&opts_list_01
, "number1=-18446744073709551616",
619 error_free_or_abort(&err
);
623 opts
= qemu_opts_parse(&opts_list_01
, "number1=0x2a,number2=052",
624 false, &error_abort
);
625 g_assert_cmpuint(opts_count(opts
), ==, 2);
626 g_assert_cmpuint(qemu_opt_get_number(opts
, "number1", 1), ==, 42);
627 g_assert_cmpuint(qemu_opt_get_number(opts
, "number2", 0), ==, 42);
630 opts
= qemu_opts_parse(&opts_list_01
, "number1=", false, &err
);
631 error_free_or_abort(&err
);
633 opts
= qemu_opts_parse(&opts_list_01
, "number1=eins", false, &err
);
634 error_free_or_abort(&err
);
637 /* Leading whitespace */
638 opts
= qemu_opts_parse(&opts_list_01
, "number1= \t42",
639 false, &error_abort
);
640 g_assert_cmpuint(opts_count(opts
), ==, 1);
641 g_assert_cmpuint(qemu_opt_get_number(opts
, "number1", 1), ==, 42);
644 opts
= qemu_opts_parse(&opts_list_01
, "number1=3.14", false, &err
);
645 error_free_or_abort(&err
);
647 opts
= qemu_opts_parse(&opts_list_01
, "number1=08", false, &err
);
648 error_free_or_abort(&err
);
650 opts
= qemu_opts_parse(&opts_list_01
, "number1=0 ", false, &err
);
651 error_free_or_abort(&err
);
654 qemu_opts_reset(&opts_list_01
);
657 static void test_opts_parse_size(void)
662 /* Lower limit zero */
663 opts
= qemu_opts_parse(&opts_list_02
, "size1=0", false, &error_abort
);
664 g_assert_cmpuint(opts_count(opts
), ==, 1);
665 g_assert_cmpuint(qemu_opt_get_size(opts
, "size1", 1), ==, 0);
667 /* Note: precision is 53 bits since we're parsing with strtod() */
669 /* Around limit of precision: 2^53-1, 2^53, 2^54 */
670 opts
= qemu_opts_parse(&opts_list_02
,
671 "size1=9007199254740991,"
672 "size2=9007199254740992,"
673 "size3=9007199254740993",
674 false, &error_abort
);
675 g_assert_cmpuint(opts_count(opts
), ==, 3);
676 g_assert_cmphex(qemu_opt_get_size(opts
, "size1", 1),
677 ==, 0x1fffffffffffff);
678 g_assert_cmphex(qemu_opt_get_size(opts
, "size2", 1),
679 ==, 0x20000000000000);
680 g_assert_cmphex(qemu_opt_get_size(opts
, "size3", 1),
681 ==, 0x20000000000000);
683 /* Close to signed upper limit 0x7ffffffffffffc00 (53 msbs set) */
684 opts
= qemu_opts_parse(&opts_list_02
,
685 "size1=9223372036854774784," /* 7ffffffffffffc00 */
686 "size2=9223372036854775295", /* 7ffffffffffffdff */
687 false, &error_abort
);
688 g_assert_cmpuint(opts_count(opts
), ==, 2);
689 g_assert_cmphex(qemu_opt_get_size(opts
, "size1", 1),
690 ==, 0x7ffffffffffffc00);
691 g_assert_cmphex(qemu_opt_get_size(opts
, "size2", 1),
692 ==, 0x7ffffffffffffc00);
694 /* Close to actual upper limit 0xfffffffffffff800 (53 msbs set) */
695 opts
= qemu_opts_parse(&opts_list_02
,
696 "size1=18446744073709549568," /* fffffffffffff800 */
697 "size2=18446744073709550591", /* fffffffffffffbff */
698 false, &error_abort
);
699 g_assert_cmpuint(opts_count(opts
), ==, 2);
700 g_assert_cmphex(qemu_opt_get_size(opts
, "size1", 1),
701 ==, 0xfffffffffffff800);
702 g_assert_cmphex(qemu_opt_get_size(opts
, "size2", 1),
703 ==, 0xfffffffffffff800);
706 opts
= qemu_opts_parse(&opts_list_02
, "size1=-1", false, &err
);
707 error_free_or_abort(&err
);
709 opts
= qemu_opts_parse(&opts_list_02
,
710 "size1=18446744073709550592", /* fffffffffffffc00 */
712 error_free_or_abort(&err
);
716 opts
= qemu_opts_parse(&opts_list_02
, "size1=8b,size2=1.5k,size3=2M",
717 false, &error_abort
);
718 g_assert_cmpuint(opts_count(opts
), ==, 3);
719 g_assert_cmphex(qemu_opt_get_size(opts
, "size1", 0), ==, 8);
720 g_assert_cmphex(qemu_opt_get_size(opts
, "size2", 0), ==, 1536);
721 g_assert_cmphex(qemu_opt_get_size(opts
, "size3", 0), ==, 2 * M_BYTE
);
722 opts
= qemu_opts_parse(&opts_list_02
, "size1=0.1G,size2=16777215T",
723 false, &error_abort
);
724 g_assert_cmpuint(opts_count(opts
), ==, 2);
725 g_assert_cmphex(qemu_opt_get_size(opts
, "size1", 0), ==, G_BYTE
/ 10);
726 g_assert_cmphex(qemu_opt_get_size(opts
, "size2", 0),
727 ==, 16777215 * T_BYTE
);
729 /* Beyond limit with suffix */
730 opts
= qemu_opts_parse(&opts_list_02
, "size1=16777216T",
732 error_free_or_abort(&err
);
736 opts
= qemu_opts_parse(&opts_list_02
, "size1=16E", false, &err
);
737 error_free_or_abort(&err
);
739 opts
= qemu_opts_parse(&opts_list_02
, "size1=16Gi", false, &err
);
740 error_free_or_abort(&err
);
743 qemu_opts_reset(&opts_list_02
);
746 int main(int argc
, char *argv
[])
749 g_test_init(&argc
, &argv
, NULL
);
750 g_test_add_func("/qemu-opts/find_unknown_opts", test_find_unknown_opts
);
751 g_test_add_func("/qemu-opts/find_opts", test_qemu_find_opts
);
752 g_test_add_func("/qemu-opts/opts_create", test_qemu_opts_create
);
753 g_test_add_func("/qemu-opts/opt_get", test_qemu_opt_get
);
754 g_test_add_func("/qemu-opts/opt_get_bool", test_qemu_opt_get_bool
);
755 g_test_add_func("/qemu-opts/opt_get_number", test_qemu_opt_get_number
);
756 g_test_add_func("/qemu-opts/opt_get_size", test_qemu_opt_get_size
);
757 g_test_add_func("/qemu-opts/opt_unset", test_qemu_opt_unset
);
758 g_test_add_func("/qemu-opts/opts_reset", test_qemu_opts_reset
);
759 g_test_add_func("/qemu-opts/opts_set", test_qemu_opts_set
);
760 g_test_add_func("/qemu-opts/opts_parse/general", test_opts_parse
);
761 g_test_add_func("/qemu-opts/opts_parse/bool", test_opts_parse_bool
);
762 g_test_add_func("/qemu-opts/opts_parse/number", test_opts_parse_number
);
763 g_test_add_func("/qemu-opts/opts_parse/size", test_opts_parse_size
);