Merge remote-tracking branch 'remotes/amit-migration/tags/migration-for-2.7-7' into...
[qemu.git] / tests / test-cutils.c
blob64e3e95ce2e3517aff813364ff25302ef7b5a47f
1 /*
2 * cutils.c unit-tests
4 * Copyright (C) 2013 Red Hat Inc.
6 * Authors:
7 * Eduardo Habkost <ehabkost@redhat.com>
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 * THE SOFTWARE.
28 #include "qemu/osdep.h"
30 #include "qemu/cutils.h"
32 static void test_parse_uint_null(void)
34 unsigned long long i = 999;
35 char f = 'X';
36 char *endptr = &f;
37 int r;
39 r = parse_uint(NULL, &i, &endptr, 0);
41 g_assert_cmpint(r, ==, -EINVAL);
42 g_assert_cmpint(i, ==, 0);
43 g_assert(endptr == NULL);
46 static void test_parse_uint_empty(void)
48 unsigned long long i = 999;
49 char f = 'X';
50 char *endptr = &f;
51 const char *str = "";
52 int r;
54 r = parse_uint(str, &i, &endptr, 0);
56 g_assert_cmpint(r, ==, -EINVAL);
57 g_assert_cmpint(i, ==, 0);
58 g_assert(endptr == str);
61 static void test_parse_uint_whitespace(void)
63 unsigned long long i = 999;
64 char f = 'X';
65 char *endptr = &f;
66 const char *str = " \t ";
67 int r;
69 r = parse_uint(str, &i, &endptr, 0);
71 g_assert_cmpint(r, ==, -EINVAL);
72 g_assert_cmpint(i, ==, 0);
73 g_assert(endptr == str);
77 static void test_parse_uint_invalid(void)
79 unsigned long long i = 999;
80 char f = 'X';
81 char *endptr = &f;
82 const char *str = " \t xxx";
83 int r;
85 r = parse_uint(str, &i, &endptr, 0);
87 g_assert_cmpint(r, ==, -EINVAL);
88 g_assert_cmpint(i, ==, 0);
89 g_assert(endptr == str);
93 static void test_parse_uint_trailing(void)
95 unsigned long long i = 999;
96 char f = 'X';
97 char *endptr = &f;
98 const char *str = "123xxx";
99 int r;
101 r = parse_uint(str, &i, &endptr, 0);
103 g_assert_cmpint(r, ==, 0);
104 g_assert_cmpint(i, ==, 123);
105 g_assert(endptr == str + 3);
108 static void test_parse_uint_correct(void)
110 unsigned long long i = 999;
111 char f = 'X';
112 char *endptr = &f;
113 const char *str = "123";
114 int r;
116 r = parse_uint(str, &i, &endptr, 0);
118 g_assert_cmpint(r, ==, 0);
119 g_assert_cmpint(i, ==, 123);
120 g_assert(endptr == str + strlen(str));
123 static void test_parse_uint_octal(void)
125 unsigned long long i = 999;
126 char f = 'X';
127 char *endptr = &f;
128 const char *str = "0123";
129 int r;
131 r = parse_uint(str, &i, &endptr, 0);
133 g_assert_cmpint(r, ==, 0);
134 g_assert_cmpint(i, ==, 0123);
135 g_assert(endptr == str + strlen(str));
138 static void test_parse_uint_decimal(void)
140 unsigned long long i = 999;
141 char f = 'X';
142 char *endptr = &f;
143 const char *str = "0123";
144 int r;
146 r = parse_uint(str, &i, &endptr, 10);
148 g_assert_cmpint(r, ==, 0);
149 g_assert_cmpint(i, ==, 123);
150 g_assert(endptr == str + strlen(str));
154 static void test_parse_uint_llong_max(void)
156 unsigned long long i = 999;
157 char f = 'X';
158 char *endptr = &f;
159 char *str = g_strdup_printf("%llu", (unsigned long long)LLONG_MAX + 1);
160 int r;
162 r = parse_uint(str, &i, &endptr, 0);
164 g_assert_cmpint(r, ==, 0);
165 g_assert_cmpint(i, ==, (unsigned long long)LLONG_MAX + 1);
166 g_assert(endptr == str + strlen(str));
168 g_free(str);
171 static void test_parse_uint_overflow(void)
173 unsigned long long i = 999;
174 char f = 'X';
175 char *endptr = &f;
176 const char *str = "99999999999999999999999999999999999999";
177 int r;
179 r = parse_uint(str, &i, &endptr, 0);
181 g_assert_cmpint(r, ==, -ERANGE);
182 g_assert_cmpint(i, ==, ULLONG_MAX);
183 g_assert(endptr == str + strlen(str));
186 static void test_parse_uint_negative(void)
188 unsigned long long i = 999;
189 char f = 'X';
190 char *endptr = &f;
191 const char *str = " \t -321";
192 int r;
194 r = parse_uint(str, &i, &endptr, 0);
196 g_assert_cmpint(r, ==, -ERANGE);
197 g_assert_cmpint(i, ==, 0);
198 g_assert(endptr == str + strlen(str));
202 static void test_parse_uint_full_trailing(void)
204 unsigned long long i = 999;
205 const char *str = "123xxx";
206 int r;
208 r = parse_uint_full(str, &i, 0);
210 g_assert_cmpint(r, ==, -EINVAL);
211 g_assert_cmpint(i, ==, 0);
214 static void test_parse_uint_full_correct(void)
216 unsigned long long i = 999;
217 const char *str = "123";
218 int r;
220 r = parse_uint_full(str, &i, 0);
222 g_assert_cmpint(r, ==, 0);
223 g_assert_cmpint(i, ==, 123);
226 static void test_qemu_strtol_correct(void)
228 const char *str = "12345 foo";
229 char f = 'X';
230 const char *endptr = &f;
231 long res = 999;
232 int err;
234 err = qemu_strtol(str, &endptr, 0, &res);
236 g_assert_cmpint(err, ==, 0);
237 g_assert_cmpint(res, ==, 12345);
238 g_assert(endptr == str + 5);
241 static void test_qemu_strtol_null(void)
243 char f = 'X';
244 const char *endptr = &f;
245 long res = 999;
246 int err;
248 err = qemu_strtol(NULL, &endptr, 0, &res);
250 g_assert_cmpint(err, ==, -EINVAL);
251 g_assert(endptr == NULL);
254 static void test_qemu_strtol_empty(void)
256 const char *str = "";
257 char f = 'X';
258 const char *endptr = &f;
259 long res = 999;
260 int err;
262 err = qemu_strtol(str, &endptr, 0, &res);
264 g_assert_cmpint(err, ==, -EINVAL);
267 static void test_qemu_strtol_whitespace(void)
269 const char *str = " \t ";
270 char f = 'X';
271 const char *endptr = &f;
272 long res = 999;
273 int err;
275 err = qemu_strtol(str, &endptr, 0, &res);
277 g_assert_cmpint(err, ==, -EINVAL);
280 static void test_qemu_strtol_invalid(void)
282 const char *str = " xxxx \t abc";
283 char f = 'X';
284 const char *endptr = &f;
285 long res = 999;
286 int err;
288 err = qemu_strtol(str, &endptr, 0, &res);
290 g_assert_cmpint(err, ==, -EINVAL);
293 static void test_qemu_strtol_trailing(void)
295 const char *str = "123xxx";
296 char f = 'X';
297 const char *endptr = &f;
298 long res = 999;
299 int err;
301 err = qemu_strtol(str, &endptr, 0, &res);
303 g_assert_cmpint(err, ==, 0);
304 g_assert_cmpint(res, ==, 123);
305 g_assert(endptr == str + 3);
308 static void test_qemu_strtol_octal(void)
310 const char *str = "0123";
311 char f = 'X';
312 const char *endptr = &f;
313 long res = 999;
314 int err;
316 err = qemu_strtol(str, &endptr, 8, &res);
318 g_assert_cmpint(err, ==, 0);
319 g_assert_cmpint(res, ==, 0123);
320 g_assert(endptr == str + strlen(str));
322 res = 999;
323 endptr = &f;
324 err = qemu_strtol(str, &endptr, 0, &res);
326 g_assert_cmpint(err, ==, 0);
327 g_assert_cmpint(res, ==, 0123);
328 g_assert(endptr == str + strlen(str));
331 static void test_qemu_strtol_decimal(void)
333 const char *str = "0123";
334 char f = 'X';
335 const char *endptr = &f;
336 long res = 999;
337 int err;
339 err = qemu_strtol(str, &endptr, 10, &res);
341 g_assert_cmpint(err, ==, 0);
342 g_assert_cmpint(res, ==, 123);
343 g_assert(endptr == str + strlen(str));
345 str = "123";
346 res = 999;
347 endptr = &f;
348 err = qemu_strtol(str, &endptr, 0, &res);
350 g_assert_cmpint(err, ==, 0);
351 g_assert_cmpint(res, ==, 123);
352 g_assert(endptr == str + strlen(str));
355 static void test_qemu_strtol_hex(void)
357 const char *str = "0123";
358 char f = 'X';
359 const char *endptr = &f;
360 long res = 999;
361 int err;
363 err = qemu_strtol(str, &endptr, 16, &res);
365 g_assert_cmpint(err, ==, 0);
366 g_assert_cmpint(res, ==, 0x123);
367 g_assert(endptr == str + strlen(str));
369 str = "0x123";
370 res = 999;
371 endptr = &f;
372 err = qemu_strtol(str, &endptr, 0, &res);
374 g_assert_cmpint(err, ==, 0);
375 g_assert_cmpint(res, ==, 0x123);
376 g_assert(endptr == str + strlen(str));
379 static void test_qemu_strtol_max(void)
381 const char *str = g_strdup_printf("%ld", LONG_MAX);
382 char f = 'X';
383 const char *endptr = &f;
384 long res = 999;
385 int err;
387 err = qemu_strtol(str, &endptr, 0, &res);
389 g_assert_cmpint(err, ==, 0);
390 g_assert_cmpint(res, ==, LONG_MAX);
391 g_assert(endptr == str + strlen(str));
394 static void test_qemu_strtol_overflow(void)
396 const char *str = "99999999999999999999999999999999999999999999";
397 char f = 'X';
398 const char *endptr = &f;
399 long res = 999;
400 int err;
402 err = qemu_strtol(str, &endptr, 0, &res);
404 g_assert_cmpint(err, ==, -ERANGE);
405 g_assert_cmpint(res, ==, LONG_MAX);
406 g_assert(endptr == str + strlen(str));
409 static void test_qemu_strtol_underflow(void)
411 const char *str = "-99999999999999999999999999999999999999999999";
412 char f = 'X';
413 const char *endptr = &f;
414 long res = 999;
415 int err;
417 err = qemu_strtol(str, &endptr, 0, &res);
419 g_assert_cmpint(err, ==, -ERANGE);
420 g_assert_cmpint(res, ==, LONG_MIN);
421 g_assert(endptr == str + strlen(str));
424 static void test_qemu_strtol_negative(void)
426 const char *str = " \t -321";
427 char f = 'X';
428 const char *endptr = &f;
429 long res = 999;
430 int err;
432 err = qemu_strtol(str, &endptr, 0, &res);
434 g_assert_cmpint(err, ==, 0);
435 g_assert_cmpint(res, ==, -321);
436 g_assert(endptr == str + strlen(str));
439 static void test_qemu_strtol_full_correct(void)
441 const char *str = "123";
442 long res = 999;
443 int err;
445 err = qemu_strtol(str, NULL, 0, &res);
447 g_assert_cmpint(err, ==, 0);
448 g_assert_cmpint(res, ==, 123);
451 static void test_qemu_strtol_full_null(void)
453 char f = 'X';
454 const char *endptr = &f;
455 long res = 999;
456 int err;
458 err = qemu_strtol(NULL, &endptr, 0, &res);
460 g_assert_cmpint(err, ==, -EINVAL);
461 g_assert(endptr == NULL);
464 static void test_qemu_strtol_full_empty(void)
466 const char *str = "";
467 long res = 999L;
468 int err;
470 err = qemu_strtol(str, NULL, 0, &res);
472 g_assert_cmpint(err, ==, -EINVAL);
475 static void test_qemu_strtol_full_negative(void)
477 const char *str = " \t -321";
478 long res = 999;
479 int err;
481 err = qemu_strtol(str, NULL, 0, &res);
483 g_assert_cmpint(err, ==, 0);
484 g_assert_cmpint(res, ==, -321);
487 static void test_qemu_strtol_full_trailing(void)
489 const char *str = "123xxx";
490 long res;
491 int err;
493 err = qemu_strtol(str, NULL, 0, &res);
495 g_assert_cmpint(err, ==, -EINVAL);
498 static void test_qemu_strtol_full_max(void)
500 const char *str = g_strdup_printf("%ld", LONG_MAX);
501 long res;
502 int err;
504 err = qemu_strtol(str, NULL, 0, &res);
506 g_assert_cmpint(err, ==, 0);
507 g_assert_cmpint(res, ==, LONG_MAX);
510 static void test_qemu_strtoul_correct(void)
512 const char *str = "12345 foo";
513 char f = 'X';
514 const char *endptr = &f;
515 unsigned long res = 999;
516 int err;
518 err = qemu_strtoul(str, &endptr, 0, &res);
520 g_assert_cmpint(err, ==, 0);
521 g_assert_cmpint(res, ==, 12345);
522 g_assert(endptr == str + 5);
525 static void test_qemu_strtoul_null(void)
527 char f = 'X';
528 const char *endptr = &f;
529 unsigned long res = 999;
530 int err;
532 err = qemu_strtoul(NULL, &endptr, 0, &res);
534 g_assert_cmpint(err, ==, -EINVAL);
535 g_assert(endptr == NULL);
538 static void test_qemu_strtoul_empty(void)
540 const char *str = "";
541 char f = 'X';
542 const char *endptr = &f;
543 unsigned long res = 999;
544 int err;
546 err = qemu_strtoul(str, &endptr, 0, &res);
548 g_assert_cmpint(err, ==, -EINVAL);
551 static void test_qemu_strtoul_whitespace(void)
553 const char *str = " \t ";
554 char f = 'X';
555 const char *endptr = &f;
556 unsigned long res = 999;
557 int err;
559 err = qemu_strtoul(str, &endptr, 0, &res);
561 g_assert_cmpint(err, ==, -EINVAL);
564 static void test_qemu_strtoul_invalid(void)
566 const char *str = " xxxx \t abc";
567 char f = 'X';
568 const char *endptr = &f;
569 unsigned long res = 999;
570 int err;
572 err = qemu_strtoul(str, &endptr, 0, &res);
574 g_assert_cmpint(err, ==, -EINVAL);
577 static void test_qemu_strtoul_trailing(void)
579 const char *str = "123xxx";
580 char f = 'X';
581 const char *endptr = &f;
582 unsigned long res = 999;
583 int err;
585 err = qemu_strtoul(str, &endptr, 0, &res);
587 g_assert_cmpint(err, ==, 0);
588 g_assert_cmpint(res, ==, 123);
589 g_assert(endptr == str + 3);
592 static void test_qemu_strtoul_octal(void)
594 const char *str = "0123";
595 char f = 'X';
596 const char *endptr = &f;
597 unsigned long res = 999;
598 int err;
600 err = qemu_strtoul(str, &endptr, 8, &res);
602 g_assert_cmpint(err, ==, 0);
603 g_assert_cmpint(res, ==, 0123);
604 g_assert(endptr == str + strlen(str));
606 res = 999;
607 endptr = &f;
608 err = qemu_strtoul(str, &endptr, 0, &res);
610 g_assert_cmpint(err, ==, 0);
611 g_assert_cmpint(res, ==, 0123);
612 g_assert(endptr == str + strlen(str));
615 static void test_qemu_strtoul_decimal(void)
617 const char *str = "0123";
618 char f = 'X';
619 const char *endptr = &f;
620 unsigned long res = 999;
621 int err;
623 err = qemu_strtoul(str, &endptr, 10, &res);
625 g_assert_cmpint(err, ==, 0);
626 g_assert_cmpint(res, ==, 123);
627 g_assert(endptr == str + strlen(str));
629 str = "123";
630 res = 999;
631 endptr = &f;
632 err = qemu_strtoul(str, &endptr, 0, &res);
634 g_assert_cmpint(err, ==, 0);
635 g_assert_cmpint(res, ==, 123);
636 g_assert(endptr == str + strlen(str));
639 static void test_qemu_strtoul_hex(void)
641 const char *str = "0123";
642 char f = 'X';
643 const char *endptr = &f;
644 unsigned long res = 999;
645 int err;
647 err = qemu_strtoul(str, &endptr, 16, &res);
649 g_assert_cmpint(err, ==, 0);
650 g_assert_cmpint(res, ==, 0x123);
651 g_assert(endptr == str + strlen(str));
653 str = "0x123";
654 res = 999;
655 endptr = &f;
656 err = qemu_strtoul(str, &endptr, 0, &res);
658 g_assert_cmpint(err, ==, 0);
659 g_assert_cmpint(res, ==, 0x123);
660 g_assert(endptr == str + strlen(str));
663 static void test_qemu_strtoul_max(void)
665 const char *str = g_strdup_printf("%lu", ULONG_MAX);
666 char f = 'X';
667 const char *endptr = &f;
668 unsigned long res = 999;
669 int err;
671 err = qemu_strtoul(str, &endptr, 0, &res);
673 g_assert_cmpint(err, ==, 0);
674 g_assert_cmpint(res, ==, ULONG_MAX);
675 g_assert(endptr == str + strlen(str));
678 static void test_qemu_strtoul_overflow(void)
680 const char *str = "99999999999999999999999999999999999999999999";
681 char f = 'X';
682 const char *endptr = &f;
683 unsigned long res = 999;
684 int err;
686 err = qemu_strtoul(str, &endptr, 0, &res);
688 g_assert_cmpint(err, ==, -ERANGE);
689 g_assert_cmpint(res, ==, ULONG_MAX);
690 g_assert(endptr == str + strlen(str));
693 static void test_qemu_strtoul_underflow(void)
695 const char *str = "-99999999999999999999999999999999999999999999";
696 char f = 'X';
697 const char *endptr = &f;
698 unsigned long res = 999;
699 int err;
701 err = qemu_strtoul(str, &endptr, 0, &res);
703 g_assert_cmpint(err, ==, -ERANGE);
704 g_assert_cmpint(res, ==, -1ul);
705 g_assert(endptr == str + strlen(str));
708 static void test_qemu_strtoul_negative(void)
710 const char *str = " \t -321";
711 char f = 'X';
712 const char *endptr = &f;
713 unsigned long res = 999;
714 int err;
716 err = qemu_strtoul(str, &endptr, 0, &res);
718 g_assert_cmpint(err, ==, 0);
719 g_assert_cmpint(res, ==, -321ul);
720 g_assert(endptr == str + strlen(str));
723 static void test_qemu_strtoul_full_correct(void)
725 const char *str = "123";
726 unsigned long res = 999;
727 int err;
729 err = qemu_strtoul(str, NULL, 0, &res);
731 g_assert_cmpint(err, ==, 0);
732 g_assert_cmpint(res, ==, 123);
735 static void test_qemu_strtoul_full_null(void)
737 unsigned long res = 999;
738 int err;
740 err = qemu_strtoul(NULL, NULL, 0, &res);
742 g_assert_cmpint(err, ==, -EINVAL);
745 static void test_qemu_strtoul_full_empty(void)
747 const char *str = "";
748 unsigned long res = 999;
749 int err;
751 err = qemu_strtoul(str, NULL, 0, &res);
753 g_assert_cmpint(err, ==, -EINVAL);
755 static void test_qemu_strtoul_full_negative(void)
757 const char *str = " \t -321";
758 unsigned long res = 999;
759 int err;
761 err = qemu_strtoul(str, NULL, 0, &res);
762 g_assert_cmpint(err, ==, 0);
763 g_assert_cmpint(res, ==, -321ul);
766 static void test_qemu_strtoul_full_trailing(void)
768 const char *str = "123xxx";
769 unsigned long res;
770 int err;
772 err = qemu_strtoul(str, NULL, 0, &res);
774 g_assert_cmpint(err, ==, -EINVAL);
777 static void test_qemu_strtoul_full_max(void)
779 const char *str = g_strdup_printf("%lu", ULONG_MAX);
780 unsigned long res = 999;
781 int err;
783 err = qemu_strtoul(str, NULL, 0, &res);
785 g_assert_cmpint(err, ==, 0);
786 g_assert_cmpint(res, ==, ULONG_MAX);
789 static void test_qemu_strtoll_correct(void)
791 const char *str = "12345 foo";
792 char f = 'X';
793 const char *endptr = &f;
794 int64_t res = 999;
795 int err;
797 err = qemu_strtoll(str, &endptr, 0, &res);
799 g_assert_cmpint(err, ==, 0);
800 g_assert_cmpint(res, ==, 12345);
801 g_assert(endptr == str + 5);
804 static void test_qemu_strtoll_null(void)
806 char f = 'X';
807 const char *endptr = &f;
808 int64_t res = 999;
809 int err;
811 err = qemu_strtoll(NULL, &endptr, 0, &res);
813 g_assert_cmpint(err, ==, -EINVAL);
814 g_assert(endptr == NULL);
817 static void test_qemu_strtoll_empty(void)
819 const char *str = "";
820 char f = 'X';
821 const char *endptr = &f;
822 int64_t res = 999;
823 int err;
825 err = qemu_strtoll(str, &endptr, 0, &res);
827 g_assert_cmpint(err, ==, -EINVAL);
830 static void test_qemu_strtoll_whitespace(void)
832 const char *str = " \t ";
833 char f = 'X';
834 const char *endptr = &f;
835 int64_t res = 999;
836 int err;
838 err = qemu_strtoll(str, &endptr, 0, &res);
840 g_assert_cmpint(err, ==, -EINVAL);
843 static void test_qemu_strtoll_invalid(void)
845 const char *str = " xxxx \t abc";
846 char f = 'X';
847 const char *endptr = &f;
848 int64_t res = 999;
849 int err;
851 err = qemu_strtoll(str, &endptr, 0, &res);
853 g_assert_cmpint(err, ==, -EINVAL);
856 static void test_qemu_strtoll_trailing(void)
858 const char *str = "123xxx";
859 char f = 'X';
860 const char *endptr = &f;
861 int64_t res = 999;
862 int err;
864 err = qemu_strtoll(str, &endptr, 0, &res);
866 g_assert_cmpint(err, ==, 0);
867 g_assert_cmpint(res, ==, 123);
868 g_assert(endptr == str + 3);
871 static void test_qemu_strtoll_octal(void)
873 const char *str = "0123";
874 char f = 'X';
875 const char *endptr = &f;
876 int64_t res = 999;
877 int err;
879 err = qemu_strtoll(str, &endptr, 8, &res);
881 g_assert_cmpint(err, ==, 0);
882 g_assert_cmpint(res, ==, 0123);
883 g_assert(endptr == str + strlen(str));
885 endptr = &f;
886 res = 999;
887 err = qemu_strtoll(str, &endptr, 0, &res);
889 g_assert_cmpint(err, ==, 0);
890 g_assert_cmpint(res, ==, 0123);
891 g_assert(endptr == str + strlen(str));
894 static void test_qemu_strtoll_decimal(void)
896 const char *str = "0123";
897 char f = 'X';
898 const char *endptr = &f;
899 int64_t res = 999;
900 int err;
902 err = qemu_strtoll(str, &endptr, 10, &res);
904 g_assert_cmpint(err, ==, 0);
905 g_assert_cmpint(res, ==, 123);
906 g_assert(endptr == str + strlen(str));
908 str = "123";
909 endptr = &f;
910 res = 999;
911 err = qemu_strtoll(str, &endptr, 0, &res);
913 g_assert_cmpint(err, ==, 0);
914 g_assert_cmpint(res, ==, 123);
915 g_assert(endptr == str + strlen(str));
918 static void test_qemu_strtoll_hex(void)
920 const char *str = "0123";
921 char f = 'X';
922 const char *endptr = &f;
923 int64_t res = 999;
924 int err;
926 err = qemu_strtoll(str, &endptr, 16, &res);
928 g_assert_cmpint(err, ==, 0);
929 g_assert_cmpint(res, ==, 0x123);
930 g_assert(endptr == str + strlen(str));
932 str = "0x123";
933 endptr = &f;
934 res = 999;
935 err = qemu_strtoll(str, &endptr, 0, &res);
937 g_assert_cmpint(err, ==, 0);
938 g_assert_cmpint(res, ==, 0x123);
939 g_assert(endptr == str + strlen(str));
942 static void test_qemu_strtoll_max(void)
944 const char *str = g_strdup_printf("%lld", LLONG_MAX);
945 char f = 'X';
946 const char *endptr = &f;
947 int64_t res = 999;
948 int err;
950 err = qemu_strtoll(str, &endptr, 0, &res);
952 g_assert_cmpint(err, ==, 0);
953 g_assert_cmpint(res, ==, LLONG_MAX);
954 g_assert(endptr == str + strlen(str));
957 static void test_qemu_strtoll_overflow(void)
959 const char *str = "99999999999999999999999999999999999999999999";
960 char f = 'X';
961 const char *endptr = &f;
962 int64_t res = 999;
963 int err;
965 err = qemu_strtoll(str, &endptr, 0, &res);
967 g_assert_cmpint(err, ==, -ERANGE);
968 g_assert_cmpint(res, ==, LLONG_MAX);
969 g_assert(endptr == str + strlen(str));
972 static void test_qemu_strtoll_underflow(void)
974 const char *str = "-99999999999999999999999999999999999999999999";
975 char f = 'X';
976 const char *endptr = &f;
977 int64_t res = 999;
978 int err;
980 err = qemu_strtoll(str, &endptr, 0, &res);
982 g_assert_cmpint(err, ==, -ERANGE);
983 g_assert_cmpint(res, ==, LLONG_MIN);
984 g_assert(endptr == str + strlen(str));
987 static void test_qemu_strtoll_negative(void)
989 const char *str = " \t -321";
990 char f = 'X';
991 const char *endptr = &f;
992 int64_t res = 999;
993 int err;
995 err = qemu_strtoll(str, &endptr, 0, &res);
997 g_assert_cmpint(err, ==, 0);
998 g_assert_cmpint(res, ==, -321);
999 g_assert(endptr == str + strlen(str));
1002 static void test_qemu_strtoll_full_correct(void)
1004 const char *str = "123";
1005 int64_t res = 999;
1006 int err;
1008 err = qemu_strtoll(str, NULL, 0, &res);
1010 g_assert_cmpint(err, ==, 0);
1011 g_assert_cmpint(res, ==, 123);
1014 static void test_qemu_strtoll_full_null(void)
1016 int64_t res = 999;
1017 int err;
1019 err = qemu_strtoll(NULL, NULL, 0, &res);
1021 g_assert_cmpint(err, ==, -EINVAL);
1024 static void test_qemu_strtoll_full_empty(void)
1026 const char *str = "";
1027 int64_t res = 999;
1028 int err;
1030 err = qemu_strtoll(str, NULL, 0, &res);
1032 g_assert_cmpint(err, ==, -EINVAL);
1035 static void test_qemu_strtoll_full_negative(void)
1037 const char *str = " \t -321";
1038 int64_t res = 999;
1039 int err;
1041 err = qemu_strtoll(str, NULL, 0, &res);
1043 g_assert_cmpint(err, ==, 0);
1044 g_assert_cmpint(res, ==, -321);
1047 static void test_qemu_strtoll_full_trailing(void)
1049 const char *str = "123xxx";
1050 int64_t res = 999;
1051 int err;
1053 err = qemu_strtoll(str, NULL, 0, &res);
1055 g_assert_cmpint(err, ==, -EINVAL);
1058 static void test_qemu_strtoll_full_max(void)
1061 const char *str = g_strdup_printf("%lld", LLONG_MAX);
1062 int64_t res;
1063 int err;
1065 err = qemu_strtoll(str, NULL, 0, &res);
1067 g_assert_cmpint(err, ==, 0);
1068 g_assert_cmpint(res, ==, LLONG_MAX);
1071 static void test_qemu_strtoull_correct(void)
1073 const char *str = "12345 foo";
1074 char f = 'X';
1075 const char *endptr = &f;
1076 uint64_t res = 999;
1077 int err;
1079 err = qemu_strtoull(str, &endptr, 0, &res);
1081 g_assert_cmpint(err, ==, 0);
1082 g_assert_cmpint(res, ==, 12345);
1083 g_assert(endptr == str + 5);
1086 static void test_qemu_strtoull_null(void)
1088 char f = 'X';
1089 const char *endptr = &f;
1090 uint64_t res = 999;
1091 int err;
1093 err = qemu_strtoull(NULL, &endptr, 0, &res);
1095 g_assert_cmpint(err, ==, -EINVAL);
1096 g_assert(endptr == NULL);
1099 static void test_qemu_strtoull_empty(void)
1101 const char *str = "";
1102 char f = 'X';
1103 const char *endptr = &f;
1104 uint64_t res = 999;
1105 int err;
1107 err = qemu_strtoull(str, &endptr, 0, &res);
1109 g_assert_cmpint(err, ==, -EINVAL);
1112 static void test_qemu_strtoull_whitespace(void)
1114 const char *str = " \t ";
1115 char f = 'X';
1116 const char *endptr = &f;
1117 uint64_t res = 999;
1118 int err;
1120 err = qemu_strtoull(str, &endptr, 0, &res);
1122 g_assert_cmpint(err, ==, -EINVAL);
1125 static void test_qemu_strtoull_invalid(void)
1127 const char *str = " xxxx \t abc";
1128 char f = 'X';
1129 const char *endptr = &f;
1130 uint64_t res = 999;
1131 int err;
1133 err = qemu_strtoull(str, &endptr, 0, &res);
1135 g_assert_cmpint(err, ==, -EINVAL);
1138 static void test_qemu_strtoull_trailing(void)
1140 const char *str = "123xxx";
1141 char f = 'X';
1142 const char *endptr = &f;
1143 uint64_t res = 999;
1144 int err;
1146 err = qemu_strtoull(str, &endptr, 0, &res);
1148 g_assert_cmpint(err, ==, 0);
1149 g_assert_cmpint(res, ==, 123);
1150 g_assert(endptr == str + 3);
1153 static void test_qemu_strtoull_octal(void)
1155 const char *str = "0123";
1156 char f = 'X';
1157 const char *endptr = &f;
1158 uint64_t res = 999;
1159 int err;
1161 err = qemu_strtoull(str, &endptr, 8, &res);
1163 g_assert_cmpint(err, ==, 0);
1164 g_assert_cmpint(res, ==, 0123);
1165 g_assert(endptr == str + strlen(str));
1167 endptr = &f;
1168 res = 999;
1169 err = qemu_strtoull(str, &endptr, 0, &res);
1171 g_assert_cmpint(err, ==, 0);
1172 g_assert_cmpint(res, ==, 0123);
1173 g_assert(endptr == str + strlen(str));
1176 static void test_qemu_strtoull_decimal(void)
1178 const char *str = "0123";
1179 char f = 'X';
1180 const char *endptr = &f;
1181 uint64_t res = 999;
1182 int err;
1184 err = qemu_strtoull(str, &endptr, 10, &res);
1186 g_assert_cmpint(err, ==, 0);
1187 g_assert_cmpint(res, ==, 123);
1188 g_assert(endptr == str + strlen(str));
1190 str = "123";
1191 endptr = &f;
1192 res = 999;
1193 err = qemu_strtoull(str, &endptr, 0, &res);
1195 g_assert_cmpint(err, ==, 0);
1196 g_assert_cmpint(res, ==, 123);
1197 g_assert(endptr == str + strlen(str));
1200 static void test_qemu_strtoull_hex(void)
1202 const char *str = "0123";
1203 char f = 'X';
1204 const char *endptr = &f;
1205 uint64_t res = 999;
1206 int err;
1208 err = qemu_strtoull(str, &endptr, 16, &res);
1210 g_assert_cmpint(err, ==, 0);
1211 g_assert_cmpint(res, ==, 0x123);
1212 g_assert(endptr == str + strlen(str));
1214 str = "0x123";
1215 endptr = &f;
1216 res = 999;
1217 err = qemu_strtoull(str, &endptr, 0, &res);
1219 g_assert_cmpint(err, ==, 0);
1220 g_assert_cmpint(res, ==, 0x123);
1221 g_assert(endptr == str + strlen(str));
1224 static void test_qemu_strtoull_max(void)
1226 const char *str = g_strdup_printf("%llu", ULLONG_MAX);
1227 char f = 'X';
1228 const char *endptr = &f;
1229 uint64_t res = 999;
1230 int err;
1232 err = qemu_strtoull(str, &endptr, 0, &res);
1234 g_assert_cmpint(err, ==, 0);
1235 g_assert_cmpint(res, ==, ULLONG_MAX);
1236 g_assert(endptr == str + strlen(str));
1239 static void test_qemu_strtoull_overflow(void)
1241 const char *str = "99999999999999999999999999999999999999999999";
1242 char f = 'X';
1243 const char *endptr = &f;
1244 uint64_t res = 999;
1245 int err;
1247 err = qemu_strtoull(str, &endptr, 0, &res);
1249 g_assert_cmpint(err, ==, -ERANGE);
1250 g_assert_cmpint(res, ==, ULLONG_MAX);
1251 g_assert(endptr == str + strlen(str));
1254 static void test_qemu_strtoull_underflow(void)
1256 const char *str = "-99999999999999999999999999999999999999999999";
1257 char f = 'X';
1258 const char *endptr = &f;
1259 uint64_t res = 999;
1260 int err;
1262 err = qemu_strtoull(str, &endptr, 0, &res);
1264 g_assert_cmpint(err, ==, -ERANGE);
1265 g_assert_cmpint(res, ==, -1);
1266 g_assert(endptr == str + strlen(str));
1269 static void test_qemu_strtoull_negative(void)
1271 const char *str = " \t -321";
1272 char f = 'X';
1273 const char *endptr = &f;
1274 uint64_t res = 999;
1275 int err;
1277 err = qemu_strtoull(str, &endptr, 0, &res);
1279 g_assert_cmpint(err, ==, 0);
1280 g_assert_cmpint(res, ==, -321);
1281 g_assert(endptr == str + strlen(str));
1284 static void test_qemu_strtoull_full_correct(void)
1286 const char *str = "18446744073709551614";
1287 uint64_t res = 999;
1288 int err;
1290 err = qemu_strtoull(str, NULL, 0, &res);
1292 g_assert_cmpint(err, ==, 0);
1293 g_assert_cmpint(res, ==, 18446744073709551614LLU);
1296 static void test_qemu_strtoull_full_null(void)
1298 uint64_t res = 999;
1299 int err;
1301 err = qemu_strtoull(NULL, NULL, 0, &res);
1303 g_assert_cmpint(err, ==, -EINVAL);
1306 static void test_qemu_strtoull_full_empty(void)
1308 const char *str = "";
1309 uint64_t res = 999;
1310 int err;
1312 err = qemu_strtoull(str, NULL, 0, &res);
1314 g_assert_cmpint(err, ==, -EINVAL);
1317 static void test_qemu_strtoull_full_negative(void)
1319 const char *str = " \t -321";
1320 uint64_t res = 999;
1321 int err;
1323 err = qemu_strtoull(str, NULL, 0, &res);
1325 g_assert_cmpint(err, ==, 0);
1326 g_assert_cmpint(res, ==, 18446744073709551295LLU);
1329 static void test_qemu_strtoull_full_trailing(void)
1331 const char *str = "18446744073709551614xxxxxx";
1332 uint64_t res = 999;
1333 int err;
1335 err = qemu_strtoull(str, NULL, 0, &res);
1337 g_assert_cmpint(err, ==, -EINVAL);
1340 static void test_qemu_strtoull_full_max(void)
1342 const char *str = g_strdup_printf("%lld", ULLONG_MAX);
1343 uint64_t res = 999;
1344 int err;
1346 err = qemu_strtoull(str, NULL, 0, &res);
1348 g_assert_cmpint(err, ==, 0);
1349 g_assert_cmpint(res, ==, ULLONG_MAX);
1352 static void test_qemu_strtosz_simple(void)
1354 const char *str = "12345M";
1355 char *endptr = NULL;
1356 int64_t res;
1358 res = qemu_strtosz(str, &endptr);
1359 g_assert_cmpint(res, ==, 12345 * M_BYTE);
1360 g_assert(endptr == str + 6);
1362 res = qemu_strtosz(str, NULL);
1363 g_assert_cmpint(res, ==, 12345 * M_BYTE);
1366 static void test_qemu_strtosz_units(void)
1368 const char *none = "1";
1369 const char *b = "1B";
1370 const char *k = "1K";
1371 const char *m = "1M";
1372 const char *g = "1G";
1373 const char *t = "1T";
1374 const char *p = "1P";
1375 const char *e = "1E";
1376 int64_t res;
1378 /* default is M */
1379 res = qemu_strtosz(none, NULL);
1380 g_assert_cmpint(res, ==, M_BYTE);
1382 res = qemu_strtosz(b, NULL);
1383 g_assert_cmpint(res, ==, 1);
1385 res = qemu_strtosz(k, NULL);
1386 g_assert_cmpint(res, ==, K_BYTE);
1388 res = qemu_strtosz(m, NULL);
1389 g_assert_cmpint(res, ==, M_BYTE);
1391 res = qemu_strtosz(g, NULL);
1392 g_assert_cmpint(res, ==, G_BYTE);
1394 res = qemu_strtosz(t, NULL);
1395 g_assert_cmpint(res, ==, T_BYTE);
1397 res = qemu_strtosz(p, NULL);
1398 g_assert_cmpint(res, ==, P_BYTE);
1400 res = qemu_strtosz(e, NULL);
1401 g_assert_cmpint(res, ==, E_BYTE);
1404 static void test_qemu_strtosz_float(void)
1406 const char *str = "12.345M";
1407 int64_t res;
1409 res = qemu_strtosz(str, NULL);
1410 g_assert_cmpint(res, ==, 12.345 * M_BYTE);
1413 static void test_qemu_strtosz_erange(void)
1415 const char *str = "10E";
1416 int64_t res;
1418 res = qemu_strtosz(str, NULL);
1419 g_assert_cmpint(res, ==, -ERANGE);
1422 static void test_qemu_strtosz_suffix_unit(void)
1424 const char *str = "12345";
1425 int64_t res;
1427 res = qemu_strtosz_suffix_unit(str, NULL,
1428 QEMU_STRTOSZ_DEFSUFFIX_KB, 1000);
1429 g_assert_cmpint(res, ==, 12345000);
1432 int main(int argc, char **argv)
1434 g_test_init(&argc, &argv, NULL);
1436 g_test_add_func("/cutils/parse_uint/null", test_parse_uint_null);
1437 g_test_add_func("/cutils/parse_uint/empty", test_parse_uint_empty);
1438 g_test_add_func("/cutils/parse_uint/whitespace",
1439 test_parse_uint_whitespace);
1440 g_test_add_func("/cutils/parse_uint/invalid", test_parse_uint_invalid);
1441 g_test_add_func("/cutils/parse_uint/trailing", test_parse_uint_trailing);
1442 g_test_add_func("/cutils/parse_uint/correct", test_parse_uint_correct);
1443 g_test_add_func("/cutils/parse_uint/octal", test_parse_uint_octal);
1444 g_test_add_func("/cutils/parse_uint/decimal", test_parse_uint_decimal);
1445 g_test_add_func("/cutils/parse_uint/llong_max", test_parse_uint_llong_max);
1446 g_test_add_func("/cutils/parse_uint/overflow", test_parse_uint_overflow);
1447 g_test_add_func("/cutils/parse_uint/negative", test_parse_uint_negative);
1448 g_test_add_func("/cutils/parse_uint_full/trailing",
1449 test_parse_uint_full_trailing);
1450 g_test_add_func("/cutils/parse_uint_full/correct",
1451 test_parse_uint_full_correct);
1453 /* qemu_strtol() tests */
1454 g_test_add_func("/cutils/qemu_strtol/correct", test_qemu_strtol_correct);
1455 g_test_add_func("/cutils/qemu_strtol/null", test_qemu_strtol_null);
1456 g_test_add_func("/cutils/qemu_strtol/empty", test_qemu_strtol_empty);
1457 g_test_add_func("/cutils/qemu_strtol/whitespace",
1458 test_qemu_strtol_whitespace);
1459 g_test_add_func("/cutils/qemu_strtol/invalid", test_qemu_strtol_invalid);
1460 g_test_add_func("/cutils/qemu_strtol/trailing", test_qemu_strtol_trailing);
1461 g_test_add_func("/cutils/qemu_strtol/octal", test_qemu_strtol_octal);
1462 g_test_add_func("/cutils/qemu_strtol/decimal", test_qemu_strtol_decimal);
1463 g_test_add_func("/cutils/qemu_strtol/hex", test_qemu_strtol_hex);
1464 g_test_add_func("/cutils/qemu_strtol/max", test_qemu_strtol_max);
1465 g_test_add_func("/cutils/qemu_strtol/overflow", test_qemu_strtol_overflow);
1466 g_test_add_func("/cutils/qemu_strtol/underflow",
1467 test_qemu_strtol_underflow);
1468 g_test_add_func("/cutils/qemu_strtol/negative", test_qemu_strtol_negative);
1469 g_test_add_func("/cutils/qemu_strtol_full/correct",
1470 test_qemu_strtol_full_correct);
1471 g_test_add_func("/cutils/qemu_strtol_full/null",
1472 test_qemu_strtol_full_null);
1473 g_test_add_func("/cutils/qemu_strtol_full/empty",
1474 test_qemu_strtol_full_empty);
1475 g_test_add_func("/cutils/qemu_strtol_full/negative",
1476 test_qemu_strtol_full_negative);
1477 g_test_add_func("/cutils/qemu_strtol_full/trailing",
1478 test_qemu_strtol_full_trailing);
1479 g_test_add_func("/cutils/qemu_strtol_full/max",
1480 test_qemu_strtol_full_max);
1482 /* qemu_strtoul() tests */
1483 g_test_add_func("/cutils/qemu_strtoul/correct", test_qemu_strtoul_correct);
1484 g_test_add_func("/cutils/qemu_strtoul/null", test_qemu_strtoul_null);
1485 g_test_add_func("/cutils/qemu_strtoul/empty", test_qemu_strtoul_empty);
1486 g_test_add_func("/cutils/qemu_strtoul/whitespace",
1487 test_qemu_strtoul_whitespace);
1488 g_test_add_func("/cutils/qemu_strtoul/invalid", test_qemu_strtoul_invalid);
1489 g_test_add_func("/cutils/qemu_strtoul/trailing",
1490 test_qemu_strtoul_trailing);
1491 g_test_add_func("/cutils/qemu_strtoul/octal", test_qemu_strtoul_octal);
1492 g_test_add_func("/cutils/qemu_strtoul/decimal", test_qemu_strtoul_decimal);
1493 g_test_add_func("/cutils/qemu_strtoul/hex", test_qemu_strtoul_hex);
1494 g_test_add_func("/cutils/qemu_strtoul/max", test_qemu_strtoul_max);
1495 g_test_add_func("/cutils/qemu_strtoul/overflow",
1496 test_qemu_strtoul_overflow);
1497 g_test_add_func("/cutils/qemu_strtoul/underflow",
1498 test_qemu_strtoul_underflow);
1499 g_test_add_func("/cutils/qemu_strtoul/negative",
1500 test_qemu_strtoul_negative);
1501 g_test_add_func("/cutils/qemu_strtoul_full/correct",
1502 test_qemu_strtoul_full_correct);
1503 g_test_add_func("/cutils/qemu_strtoul_full/null",
1504 test_qemu_strtoul_full_null);
1505 g_test_add_func("/cutils/qemu_strtoul_full/empty",
1506 test_qemu_strtoul_full_empty);
1507 g_test_add_func("/cutils/qemu_strtoul_full/negative",
1508 test_qemu_strtoul_full_negative);
1509 g_test_add_func("/cutils/qemu_strtoul_full/trailing",
1510 test_qemu_strtoul_full_trailing);
1511 g_test_add_func("/cutils/qemu_strtoul_full/max",
1512 test_qemu_strtoul_full_max);
1514 /* qemu_strtoll() tests */
1515 g_test_add_func("/cutils/qemu_strtoll/correct", test_qemu_strtoll_correct);
1516 g_test_add_func("/cutils/qemu_strtoll/null", test_qemu_strtoll_null);
1517 g_test_add_func("/cutils/qemu_strtoll/empty", test_qemu_strtoll_empty);
1518 g_test_add_func("/cutils/qemu_strtoll/whitespace",
1519 test_qemu_strtoll_whitespace);
1520 g_test_add_func("/cutils/qemu_strtoll/invalid", test_qemu_strtoll_invalid);
1521 g_test_add_func("/cutils/qemu_strtoll/trailing",
1522 test_qemu_strtoll_trailing);
1523 g_test_add_func("/cutils/qemu_strtoll/octal", test_qemu_strtoll_octal);
1524 g_test_add_func("/cutils/qemu_strtoll/decimal", test_qemu_strtoll_decimal);
1525 g_test_add_func("/cutils/qemu_strtoll/hex", test_qemu_strtoll_hex);
1526 g_test_add_func("/cutils/qemu_strtoll/max", test_qemu_strtoll_max);
1527 g_test_add_func("/cutils/qemu_strtoll/overflow",
1528 test_qemu_strtoll_overflow);
1529 g_test_add_func("/cutils/qemu_strtoll/underflow",
1530 test_qemu_strtoll_underflow);
1531 g_test_add_func("/cutils/qemu_strtoll/negative",
1532 test_qemu_strtoll_negative);
1533 g_test_add_func("/cutils/qemu_strtoll_full/correct",
1534 test_qemu_strtoll_full_correct);
1535 g_test_add_func("/cutils/qemu_strtoll_full/null",
1536 test_qemu_strtoll_full_null);
1537 g_test_add_func("/cutils/qemu_strtoll_full/empty",
1538 test_qemu_strtoll_full_empty);
1539 g_test_add_func("/cutils/qemu_strtoll_full/negative",
1540 test_qemu_strtoll_full_negative);
1541 g_test_add_func("/cutils/qemu_strtoll_full/trailing",
1542 test_qemu_strtoll_full_trailing);
1543 g_test_add_func("/cutils/qemu_strtoll_full/max",
1544 test_qemu_strtoll_full_max);
1546 /* qemu_strtoull() tests */
1547 g_test_add_func("/cutils/qemu_strtoull/correct",
1548 test_qemu_strtoull_correct);
1549 g_test_add_func("/cutils/qemu_strtoull/null",
1550 test_qemu_strtoull_null);
1551 g_test_add_func("/cutils/qemu_strtoull/empty", test_qemu_strtoull_empty);
1552 g_test_add_func("/cutils/qemu_strtoull/whitespace",
1553 test_qemu_strtoull_whitespace);
1554 g_test_add_func("/cutils/qemu_strtoull/invalid",
1555 test_qemu_strtoull_invalid);
1556 g_test_add_func("/cutils/qemu_strtoull/trailing",
1557 test_qemu_strtoull_trailing);
1558 g_test_add_func("/cutils/qemu_strtoull/octal", test_qemu_strtoull_octal);
1559 g_test_add_func("/cutils/qemu_strtoull/decimal",
1560 test_qemu_strtoull_decimal);
1561 g_test_add_func("/cutils/qemu_strtoull/hex", test_qemu_strtoull_hex);
1562 g_test_add_func("/cutils/qemu_strtoull/max", test_qemu_strtoull_max);
1563 g_test_add_func("/cutils/qemu_strtoull/overflow",
1564 test_qemu_strtoull_overflow);
1565 g_test_add_func("/cutils/qemu_strtoull/underflow",
1566 test_qemu_strtoull_underflow);
1567 g_test_add_func("/cutils/qemu_strtoull/negative",
1568 test_qemu_strtoull_negative);
1569 g_test_add_func("/cutils/qemu_strtoull_full/correct",
1570 test_qemu_strtoull_full_correct);
1571 g_test_add_func("/cutils/qemu_strtoull_full/null",
1572 test_qemu_strtoull_full_null);
1573 g_test_add_func("/cutils/qemu_strtoull_full/empty",
1574 test_qemu_strtoull_full_empty);
1575 g_test_add_func("/cutils/qemu_strtoull_full/negative",
1576 test_qemu_strtoull_full_negative);
1577 g_test_add_func("/cutils/qemu_strtoull_full/trailing",
1578 test_qemu_strtoull_full_trailing);
1579 g_test_add_func("/cutils/qemu_strtoull_full/max",
1580 test_qemu_strtoull_full_max);
1582 g_test_add_func("/cutils/strtosz/simple",
1583 test_qemu_strtosz_simple);
1584 g_test_add_func("/cutils/strtosz/units",
1585 test_qemu_strtosz_units);
1586 g_test_add_func("/cutils/strtosz/float",
1587 test_qemu_strtosz_float);
1588 g_test_add_func("/cutils/strtosz/erange",
1589 test_qemu_strtosz_erange);
1590 g_test_add_func("/cutils/strtosz/suffix-unit",
1591 test_qemu_strtosz_suffix_unit);
1593 return g_test_run();