Lines Matching refs:opts
132 QemuOpts *opts; in test_qemu_opts_create() local
140 opts = qemu_opts_find(list, NULL); in test_qemu_opts_create()
141 g_assert(opts == NULL); in test_qemu_opts_create()
144 opts = qemu_opts_create(list, NULL, 0, &error_abort); in test_qemu_opts_create()
145 g_assert(opts != NULL); in test_qemu_opts_create()
149 opts = qemu_opts_find(list, NULL); in test_qemu_opts_create()
150 g_assert(opts != NULL); in test_qemu_opts_create()
152 qemu_opts_del(opts); in test_qemu_opts_create()
155 opts = qemu_opts_find(list, NULL); in test_qemu_opts_create()
156 g_assert(opts == NULL); in test_qemu_opts_create()
162 QemuOpts *opts; in test_qemu_opt_get() local
171 opts = qemu_opts_find(list, NULL); in test_qemu_opt_get()
172 g_assert(opts == NULL); in test_qemu_opt_get()
175 opts = qemu_opts_create(list, NULL, 0, &error_abort); in test_qemu_opt_get()
176 g_assert(opts != NULL); in test_qemu_opt_get()
180 opt = qemu_opt_get(opts, "str2"); in test_qemu_opt_get()
183 qemu_opt_set(opts, "str2", "value", &error_abort); in test_qemu_opt_get()
186 opt = qemu_opt_get(opts, "str2"); in test_qemu_opt_get()
189 qemu_opt_set(opts, "str2", "value2", &error_abort); in test_qemu_opt_get()
192 opt = qemu_opt_get(opts, "str2"); in test_qemu_opt_get()
195 qemu_opts_del(opts); in test_qemu_opt_get()
198 opts = qemu_opts_find(list, NULL); in test_qemu_opt_get()
199 g_assert(opts == NULL); in test_qemu_opt_get()
205 QemuOpts *opts; in test_qemu_opt_get_bool() local
214 opts = qemu_opts_find(list, NULL); in test_qemu_opt_get_bool()
215 g_assert(opts == NULL); in test_qemu_opt_get_bool()
218 opts = qemu_opts_create(list, NULL, 0, &error_abort); in test_qemu_opt_get_bool()
219 g_assert(opts != NULL); in test_qemu_opt_get_bool()
223 opt = qemu_opt_get_bool(opts, "bool1", false); in test_qemu_opt_get_bool()
226 qemu_opt_set_bool(opts, "bool1", true, &error_abort); in test_qemu_opt_get_bool()
229 opt = qemu_opt_get_bool(opts, "bool1", false); in test_qemu_opt_get_bool()
233 qemu_opt_set_bool(opts, "bool1", false, &error_abort); in test_qemu_opt_get_bool()
235 opt = qemu_opt_get_bool(opts, "bool1", true); in test_qemu_opt_get_bool()
238 qemu_opts_del(opts); in test_qemu_opt_get_bool()
241 opts = qemu_opts_find(list, NULL); in test_qemu_opt_get_bool()
242 g_assert(opts == NULL); in test_qemu_opt_get_bool()
248 QemuOpts *opts; in test_qemu_opt_get_number() local
257 opts = qemu_opts_find(list, NULL); in test_qemu_opt_get_number()
258 g_assert(opts == NULL); in test_qemu_opt_get_number()
261 opts = qemu_opts_create(list, NULL, 0, &error_abort); in test_qemu_opt_get_number()
262 g_assert(opts != NULL); in test_qemu_opt_get_number()
266 opt = qemu_opt_get_number(opts, "number1", 5); in test_qemu_opt_get_number()
269 qemu_opt_set_number(opts, "number1", 10, &error_abort); in test_qemu_opt_get_number()
272 opt = qemu_opt_get_number(opts, "number1", 5); in test_qemu_opt_get_number()
276 qemu_opt_set_number(opts, "number1", 15, &error_abort); in test_qemu_opt_get_number()
278 opt = qemu_opt_get_number(opts, "number1", 5); in test_qemu_opt_get_number()
281 qemu_opts_del(opts); in test_qemu_opt_get_number()
284 opts = qemu_opts_find(list, NULL); in test_qemu_opt_get_number()
285 g_assert(opts == NULL); in test_qemu_opt_get_number()
291 QemuOpts *opts; in test_qemu_opt_get_size() local
301 opts = qemu_opts_find(list, NULL); in test_qemu_opt_get_size()
302 g_assert(opts == NULL); in test_qemu_opt_get_size()
305 opts = qemu_opts_create(list, NULL, 0, &error_abort); in test_qemu_opt_get_size()
306 g_assert(opts != NULL); in test_qemu_opt_get_size()
310 opt = qemu_opt_get_size(opts, "size1", 5); in test_qemu_opt_get_size()
318 qemu_opts_absorb_qdict(opts, dict, &error_abort); in test_qemu_opt_get_size()
322 opt = qemu_opt_get_size(opts, "size1", 5); in test_qemu_opt_get_size()
328 qemu_opts_absorb_qdict(opts, dict, &error_abort); in test_qemu_opt_get_size()
332 opt = qemu_opt_get_size(opts, "size1", 5); in test_qemu_opt_get_size()
338 qemu_opts_del(opts); in test_qemu_opt_get_size()
341 opts = qemu_opts_find(list, NULL); in test_qemu_opt_get_size()
342 g_assert(opts == NULL); in test_qemu_opt_get_size()
347 QemuOpts *opts; in test_qemu_opt_unset() local
352 opts = qemu_opts_parse(&opts_list_03, "key=value", false, NULL); in test_qemu_opt_unset()
353 g_assert(opts != NULL); in test_qemu_opt_unset()
356 value = qemu_opt_get(opts, "key"); in test_qemu_opt_unset()
360 qemu_opt_set(opts, "key", "value2", &error_abort); in test_qemu_opt_unset()
362 value = qemu_opt_get(opts, "key"); in test_qemu_opt_unset()
366 ret = qemu_opt_unset(opts, "key"); in test_qemu_opt_unset()
370 value = qemu_opt_get(opts, "key"); in test_qemu_opt_unset()
373 qemu_opts_del(opts); in test_qemu_opt_unset()
379 QemuOpts *opts; in test_qemu_opts_reset() local
388 opts = qemu_opts_find(list, NULL); in test_qemu_opts_reset()
389 g_assert(opts == NULL); in test_qemu_opts_reset()
392 opts = qemu_opts_create(list, NULL, 0, &error_abort); in test_qemu_opts_reset()
393 g_assert(opts != NULL); in test_qemu_opts_reset()
397 opt = qemu_opt_get_number(opts, "number1", 5); in test_qemu_opts_reset()
400 qemu_opt_set_number(opts, "number1", 10, &error_abort); in test_qemu_opts_reset()
403 opt = qemu_opt_get_number(opts, "number1", 5); in test_qemu_opts_reset()
409 opts = qemu_opts_find(list, NULL); in test_qemu_opts_reset()
410 g_assert(opts == NULL); in test_qemu_opts_reset()
420 static size_t opts_count(QemuOpts *opts) in opts_count() argument
424 qemu_opt_foreach(opts, opts_count_iter, &n, NULL); in opts_count()
431 QemuOpts *opts; in test_opts_parse() local
434 opts = qemu_opts_parse(&opts_list_03, "", false, &error_abort); in test_opts_parse()
435 g_assert_cmpuint(opts_count(opts), ==, 0); in test_opts_parse()
438 opts = qemu_opts_parse(&opts_list_03, "=val", false, &error_abort); in test_opts_parse()
439 g_assert_cmpuint(opts_count(opts), ==, 1); in test_opts_parse()
440 g_assert_cmpstr(qemu_opt_get(opts, ""), ==, "val"); in test_opts_parse()
443 opts = qemu_opts_parse(&opts_list_03, "a=1,b=2,,x,a=3", in test_opts_parse()
445 g_assert_cmpuint(opts_count(opts), ==, 3); in test_opts_parse()
446 g_assert_cmpstr(qemu_opt_get(opts, "a"), ==, "3"); in test_opts_parse()
447 g_assert_cmpstr(qemu_opt_get(opts, "b"), ==, "2,x"); in test_opts_parse()
450 opts = qemu_opts_parse(&opts_list_03, "id=foo,id=bar", in test_opts_parse()
452 g_assert_cmpuint(opts_count(opts), ==, 0); in test_opts_parse()
453 g_assert_cmpstr(qemu_opts_id(opts), ==, "foo"); in test_opts_parse()
458 opts = qemu_opts_parse(&opts_list_03, "x=y,", false, &error_abort); in test_opts_parse()
459 g_assert_cmpuint(opts_count(opts), ==, 1); in test_opts_parse()
460 g_assert_cmpstr(qemu_opt_get(opts, "x"), ==, "y"); in test_opts_parse()
463 opts = qemu_opts_parse(&opts_list_03, ",", false, &error_abort); in test_opts_parse()
464 g_assert_cmpuint(opts_count(opts), ==, 1); in test_opts_parse()
465 g_assert_cmpstr(qemu_opt_get(opts, ""), ==, "on"); in test_opts_parse()
468 opts = qemu_opts_parse(&opts_list_03, "x=y,id=foo", false, &err); in test_opts_parse()
470 g_assert(!opts); in test_opts_parse()
474 opts = qemu_opts_parse(&opts_list_03, "x=,,id=bar", false, &error_abort); in test_opts_parse()
475 g_assert_cmpuint(opts_count(opts), ==, 1); in test_opts_parse()
476 g_assert(!qemu_opts_id(opts)); in test_opts_parse()
477 g_assert_cmpstr(qemu_opt_get(opts, "x"), ==, ",id=bar"); in test_opts_parse()
480 opts = qemu_opts_parse(&opts_list_01, "id=666", false, &err); in test_opts_parse()
482 g_assert(!opts); in test_opts_parse()
485 opts = qemu_opts_parse(&opts_list_03, "an,noaus,noaus=", in test_opts_parse()
487 g_assert_cmpuint(opts_count(opts), ==, 3); in test_opts_parse()
488 g_assert_cmpstr(qemu_opt_get(opts, "an"), ==, "on"); in test_opts_parse()
489 g_assert_cmpstr(qemu_opt_get(opts, "aus"), ==, "off"); in test_opts_parse()
490 g_assert_cmpstr(qemu_opt_get(opts, "noaus"), ==, ""); in test_opts_parse()
493 opts = qemu_opts_parse(&opts_list_03, "no", false, &error_abort); in test_opts_parse()
494 g_assert_cmpuint(opts_count(opts), ==, 1); in test_opts_parse()
495 g_assert_cmpstr(qemu_opt_get(opts, ""), ==, "off"); in test_opts_parse()
498 opts = qemu_opts_parse(&opts_list_03, "an,noaus,noaus=", true, in test_opts_parse()
500 g_assert_cmpuint(opts_count(opts), ==, 3); in test_opts_parse()
501 g_assert_cmpstr(qemu_opt_get(opts, "implied"), ==, "an"); in test_opts_parse()
502 g_assert_cmpstr(qemu_opt_get(opts, "aus"), ==, "off"); in test_opts_parse()
503 g_assert_cmpstr(qemu_opt_get(opts, "noaus"), ==, ""); in test_opts_parse()
506 opts = qemu_opts_parse(&opts_list_03, ",", true, &error_abort); in test_opts_parse()
507 g_assert_cmpuint(opts_count(opts), ==, 1); in test_opts_parse()
508 g_assert_cmpstr(qemu_opt_get(opts, "implied"), ==, ""); in test_opts_parse()
511 opts = qemu_opts_parse(&opts_list_03, ",,,a=1", true, &error_abort); in test_opts_parse()
512 g_assert_cmpuint(opts_count(opts), ==, 2); in test_opts_parse()
513 g_assert_cmpstr(qemu_opt_get(opts, "implied"), ==, ","); in test_opts_parse()
514 g_assert_cmpstr(qemu_opt_get(opts, "a"), ==, "1"); in test_opts_parse()
517 opts = qemu_opts_parse(&opts_list_03, "=val", true, &error_abort); in test_opts_parse()
518 g_assert_cmpuint(opts_count(opts), ==, 1); in test_opts_parse()
519 g_assert_cmpstr(qemu_opt_get(opts, ""), ==, "val"); in test_opts_parse()
522 opts = qemu_opts_parse(&opts_list_01, "nonexistent=", false, &err); in test_opts_parse()
524 g_assert(!opts); in test_opts_parse()
533 QemuOpts *opts; in test_opts_parse_bool() local
535 opts = qemu_opts_parse(&opts_list_02, "bool1=on,bool2=off", in test_opts_parse_bool()
537 g_assert_cmpuint(opts_count(opts), ==, 2); in test_opts_parse_bool()
538 g_assert(qemu_opt_get_bool(opts, "bool1", false)); in test_opts_parse_bool()
539 g_assert(!qemu_opt_get_bool(opts, "bool2", true)); in test_opts_parse_bool()
541 opts = qemu_opts_parse(&opts_list_02, "bool1=offer", false, &err); in test_opts_parse_bool()
543 g_assert(!opts); in test_opts_parse_bool()
551 QemuOpts *opts; in test_opts_parse_number() local
554 opts = qemu_opts_parse(&opts_list_01, "number1=0", false, &error_abort); in test_opts_parse_number()
555 g_assert_cmpuint(opts_count(opts), ==, 1); in test_opts_parse_number()
556 g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), ==, 0); in test_opts_parse_number()
559 opts = qemu_opts_parse(&opts_list_01, in test_opts_parse_number()
562 g_assert_cmpuint(opts_count(opts), ==, 2); in test_opts_parse_number()
563 g_assert_cmphex(qemu_opt_get_number(opts, "number1", 1), ==, UINT64_MAX); in test_opts_parse_number()
564 g_assert_cmphex(qemu_opt_get_number(opts, "number2", 0), ==, UINT64_MAX); in test_opts_parse_number()
567 opts = qemu_opts_parse(&opts_list_01, "number1=18446744073709551616", in test_opts_parse_number()
570 g_assert(!opts); in test_opts_parse_number()
573 opts = qemu_opts_parse(&opts_list_01, "number1=-18446744073709551616", in test_opts_parse_number()
576 g_assert(!opts); in test_opts_parse_number()
579 opts = qemu_opts_parse(&opts_list_01, "number1=0x2a,number2=052", in test_opts_parse_number()
581 g_assert_cmpuint(opts_count(opts), ==, 2); in test_opts_parse_number()
582 g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), ==, 42); in test_opts_parse_number()
583 g_assert_cmpuint(qemu_opt_get_number(opts, "number2", 0), ==, 42); in test_opts_parse_number()
586 opts = qemu_opts_parse(&opts_list_01, "number1=", false, &err); in test_opts_parse_number()
588 g_assert(!opts); in test_opts_parse_number()
589 opts = qemu_opts_parse(&opts_list_01, "number1=eins", false, &err); in test_opts_parse_number()
591 g_assert(!opts); in test_opts_parse_number()
594 opts = qemu_opts_parse(&opts_list_01, "number1= \t42", in test_opts_parse_number()
596 g_assert_cmpuint(opts_count(opts), ==, 1); in test_opts_parse_number()
597 g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), ==, 42); in test_opts_parse_number()
600 opts = qemu_opts_parse(&opts_list_01, "number1=3.14", false, &err); in test_opts_parse_number()
602 g_assert(!opts); in test_opts_parse_number()
603 opts = qemu_opts_parse(&opts_list_01, "number1=08", false, &err); in test_opts_parse_number()
605 g_assert(!opts); in test_opts_parse_number()
606 opts = qemu_opts_parse(&opts_list_01, "number1=0 ", false, &err); in test_opts_parse_number()
608 g_assert(!opts); in test_opts_parse_number()
616 QemuOpts *opts; in test_opts_parse_size() local
619 opts = qemu_opts_parse(&opts_list_02, "size1=0", false, &error_abort); in test_opts_parse_size()
620 g_assert_cmpuint(opts_count(opts), ==, 1); in test_opts_parse_size()
621 g_assert_cmpuint(qemu_opt_get_size(opts, "size1", 1), ==, 0); in test_opts_parse_size()
626 opts = qemu_opts_parse(&opts_list_02, in test_opts_parse_size()
631 g_assert_cmpuint(opts_count(opts), ==, 3); in test_opts_parse_size()
632 g_assert_cmphex(qemu_opt_get_size(opts, "size1", 1), in test_opts_parse_size()
634 g_assert_cmphex(qemu_opt_get_size(opts, "size2", 1), in test_opts_parse_size()
636 g_assert_cmphex(qemu_opt_get_size(opts, "size3", 1), in test_opts_parse_size()
640 opts = qemu_opts_parse(&opts_list_02, in test_opts_parse_size()
645 g_assert_cmpuint(opts_count(opts), ==, 3); in test_opts_parse_size()
646 g_assert_cmphex(qemu_opt_get_size(opts, "size1", 1), in test_opts_parse_size()
648 g_assert_cmphex(qemu_opt_get_size(opts, "size2", 1), in test_opts_parse_size()
650 g_assert_cmphex(qemu_opt_get_size(opts, "size3", 1), in test_opts_parse_size()
654 opts = qemu_opts_parse(&opts_list_02, in test_opts_parse_size()
658 g_assert_cmpuint(opts_count(opts), ==, 2); in test_opts_parse_size()
659 g_assert_cmphex(qemu_opt_get_size(opts, "size1", 1), in test_opts_parse_size()
661 g_assert_cmphex(qemu_opt_get_size(opts, "size2", 1), in test_opts_parse_size()
665 opts = qemu_opts_parse(&opts_list_02, in test_opts_parse_size()
668 g_assert_cmpuint(opts_count(opts), ==, 1); in test_opts_parse_size()
669 g_assert_cmphex(qemu_opt_get_size(opts, "size1", 1), in test_opts_parse_size()
673 opts = qemu_opts_parse(&opts_list_02, "size1=-1", false, &err); in test_opts_parse_size()
675 g_assert(!opts); in test_opts_parse_size()
676 opts = qemu_opts_parse(&opts_list_02, in test_opts_parse_size()
680 g_assert(!opts); in test_opts_parse_size()
683 opts = qemu_opts_parse(&opts_list_02, "size1=8b,size2=1.5k,size3=2M", in test_opts_parse_size()
685 g_assert_cmpuint(opts_count(opts), ==, 3); in test_opts_parse_size()
686 g_assert_cmphex(qemu_opt_get_size(opts, "size1", 0), ==, 8); in test_opts_parse_size()
687 g_assert_cmphex(qemu_opt_get_size(opts, "size2", 0), ==, 1536); in test_opts_parse_size()
688 g_assert_cmphex(qemu_opt_get_size(opts, "size3", 0), ==, 2 * MiB); in test_opts_parse_size()
689 opts = qemu_opts_parse(&opts_list_02, "size1=0.1G,size2=16777215T", in test_opts_parse_size()
691 g_assert_cmpuint(opts_count(opts), ==, 2); in test_opts_parse_size()
692 g_assert_cmphex(qemu_opt_get_size(opts, "size1", 0), ==, GiB / 10); in test_opts_parse_size()
693 g_assert_cmphex(qemu_opt_get_size(opts, "size2", 0), ==, 16777215ULL * TiB); in test_opts_parse_size()
696 opts = qemu_opts_parse(&opts_list_02, "size1=16777216T", in test_opts_parse_size()
699 g_assert(!opts); in test_opts_parse_size()
702 opts = qemu_opts_parse(&opts_list_02, "size1=16E", false, &err); in test_opts_parse_size()
704 g_assert(!opts); in test_opts_parse_size()
705 opts = qemu_opts_parse(&opts_list_02, "size1=16Gi", false, &err); in test_opts_parse_size()
707 g_assert(!opts); in test_opts_parse_size()
735 QemuOpts *opts; in test_has_help_option() local
740 opts = qemu_opts_parse(&opts_list_03, test[i].params, false, in test_has_help_option()
742 g_assert_cmpint(qemu_opt_has_help_opt(opts), in test_has_help_option()
744 qemu_opts_del(opts); in test_has_help_option()
745 opts = qemu_opts_parse(&opts_list_03, test[i].params, true, in test_has_help_option()
747 g_assert_cmpint(qemu_opt_has_help_opt(opts), in test_has_help_option()
749 qemu_opts_del(opts); in test_has_help_option()
877 QemuOpts *opts; in test_opts_to_qdict_basic() local
880 opts = qemu_opts_parse(&opts_list_01, "str1=foo,str2=,str3=bar,number1=42", in test_opts_to_qdict_basic()
882 g_assert(opts != NULL); in test_opts_to_qdict_basic()
884 dict = qemu_opts_to_qdict(opts, NULL); in test_opts_to_qdict_basic()
894 qemu_opts_del(opts); in test_opts_to_qdict_basic()
900 QemuOpts *opts; in test_opts_to_qdict_filtered() local
906 opts = qemu_opts_parse(merged, in test_opts_to_qdict_filtered()
909 g_assert(opts != NULL); in test_opts_to_qdict_filtered()
912 dict = qemu_opts_to_qdict_filtered(opts, NULL, &opts_list_01, false); in test_opts_to_qdict_filtered()
922 dict = qemu_opts_to_qdict_filtered(opts, NULL, &opts_list_02, false); in test_opts_to_qdict_filtered()
933 dict = qemu_opts_to_qdict_filtered(opts, NULL, &opts_list_01, true); in test_opts_to_qdict_filtered()
943 dict = qemu_opts_to_qdict_filtered(opts, NULL, &opts_list_02, true); in test_opts_to_qdict_filtered()
953 g_assert_true(QTAILQ_EMPTY(&opts->head)); in test_opts_to_qdict_filtered()
955 qemu_opts_del(opts); in test_opts_to_qdict_filtered()
961 QemuOpts *opts; in test_opts_to_qdict_duplicates() local
965 opts = qemu_opts_parse(&opts_list_03, "foo=a,foo=b", false, &error_abort); in test_opts_to_qdict_duplicates()
966 g_assert(opts != NULL); in test_opts_to_qdict_duplicates()
969 opt = QTAILQ_FIRST(&opts->head); in test_opts_to_qdict_duplicates()
981 dict = qemu_opts_to_qdict(opts, NULL); in test_opts_to_qdict_duplicates()
987 dict = qemu_opts_to_qdict_filtered(opts, NULL, NULL, true); in test_opts_to_qdict_duplicates()
992 g_assert_true(QTAILQ_EMPTY(&opts->head)); in test_opts_to_qdict_duplicates()
994 qemu_opts_del(opts); in test_opts_to_qdict_duplicates()