hw/registerfields.h: Pull FIELD etc macros out of hw/register.h
[qemu/kevin.git] / tests / test-cutils.c
blob20b0f59ba2c0e007c8f9e23b90d1f8445b9465bc
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 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));
392 g_free(str);
395 static void test_qemu_strtol_overflow(void)
397 const char *str = "99999999999999999999999999999999999999999999";
398 char f = 'X';
399 const char *endptr = &f;
400 long res = 999;
401 int err;
403 err = qemu_strtol(str, &endptr, 0, &res);
405 g_assert_cmpint(err, ==, -ERANGE);
406 g_assert_cmpint(res, ==, LONG_MAX);
407 g_assert(endptr == str + strlen(str));
410 static void test_qemu_strtol_underflow(void)
412 const char *str = "-99999999999999999999999999999999999999999999";
413 char f = 'X';
414 const char *endptr = &f;
415 long res = 999;
416 int err;
418 err = qemu_strtol(str, &endptr, 0, &res);
420 g_assert_cmpint(err, ==, -ERANGE);
421 g_assert_cmpint(res, ==, LONG_MIN);
422 g_assert(endptr == str + strlen(str));
425 static void test_qemu_strtol_negative(void)
427 const char *str = " \t -321";
428 char f = 'X';
429 const char *endptr = &f;
430 long res = 999;
431 int err;
433 err = qemu_strtol(str, &endptr, 0, &res);
435 g_assert_cmpint(err, ==, 0);
436 g_assert_cmpint(res, ==, -321);
437 g_assert(endptr == str + strlen(str));
440 static void test_qemu_strtol_full_correct(void)
442 const char *str = "123";
443 long res = 999;
444 int err;
446 err = qemu_strtol(str, NULL, 0, &res);
448 g_assert_cmpint(err, ==, 0);
449 g_assert_cmpint(res, ==, 123);
452 static void test_qemu_strtol_full_null(void)
454 char f = 'X';
455 const char *endptr = &f;
456 long res = 999;
457 int err;
459 err = qemu_strtol(NULL, &endptr, 0, &res);
461 g_assert_cmpint(err, ==, -EINVAL);
462 g_assert(endptr == NULL);
465 static void test_qemu_strtol_full_empty(void)
467 const char *str = "";
468 long res = 999L;
469 int err;
471 err = qemu_strtol(str, NULL, 0, &res);
473 g_assert_cmpint(err, ==, -EINVAL);
476 static void test_qemu_strtol_full_negative(void)
478 const char *str = " \t -321";
479 long res = 999;
480 int err;
482 err = qemu_strtol(str, NULL, 0, &res);
484 g_assert_cmpint(err, ==, 0);
485 g_assert_cmpint(res, ==, -321);
488 static void test_qemu_strtol_full_trailing(void)
490 const char *str = "123xxx";
491 long res;
492 int err;
494 err = qemu_strtol(str, NULL, 0, &res);
496 g_assert_cmpint(err, ==, -EINVAL);
499 static void test_qemu_strtol_full_max(void)
501 char *str = g_strdup_printf("%ld", LONG_MAX);
502 long res;
503 int err;
505 err = qemu_strtol(str, NULL, 0, &res);
507 g_assert_cmpint(err, ==, 0);
508 g_assert_cmpint(res, ==, LONG_MAX);
509 g_free(str);
512 static void test_qemu_strtoul_correct(void)
514 const char *str = "12345 foo";
515 char f = 'X';
516 const char *endptr = &f;
517 unsigned long res = 999;
518 int err;
520 err = qemu_strtoul(str, &endptr, 0, &res);
522 g_assert_cmpint(err, ==, 0);
523 g_assert_cmpint(res, ==, 12345);
524 g_assert(endptr == str + 5);
527 static void test_qemu_strtoul_null(void)
529 char f = 'X';
530 const char *endptr = &f;
531 unsigned long res = 999;
532 int err;
534 err = qemu_strtoul(NULL, &endptr, 0, &res);
536 g_assert_cmpint(err, ==, -EINVAL);
537 g_assert(endptr == NULL);
540 static void test_qemu_strtoul_empty(void)
542 const char *str = "";
543 char f = 'X';
544 const char *endptr = &f;
545 unsigned long res = 999;
546 int err;
548 err = qemu_strtoul(str, &endptr, 0, &res);
550 g_assert_cmpint(err, ==, -EINVAL);
553 static void test_qemu_strtoul_whitespace(void)
555 const char *str = " \t ";
556 char f = 'X';
557 const char *endptr = &f;
558 unsigned long res = 999;
559 int err;
561 err = qemu_strtoul(str, &endptr, 0, &res);
563 g_assert_cmpint(err, ==, -EINVAL);
566 static void test_qemu_strtoul_invalid(void)
568 const char *str = " xxxx \t abc";
569 char f = 'X';
570 const char *endptr = &f;
571 unsigned long res = 999;
572 int err;
574 err = qemu_strtoul(str, &endptr, 0, &res);
576 g_assert_cmpint(err, ==, -EINVAL);
579 static void test_qemu_strtoul_trailing(void)
581 const char *str = "123xxx";
582 char f = 'X';
583 const char *endptr = &f;
584 unsigned long res = 999;
585 int err;
587 err = qemu_strtoul(str, &endptr, 0, &res);
589 g_assert_cmpint(err, ==, 0);
590 g_assert_cmpint(res, ==, 123);
591 g_assert(endptr == str + 3);
594 static void test_qemu_strtoul_octal(void)
596 const char *str = "0123";
597 char f = 'X';
598 const char *endptr = &f;
599 unsigned long res = 999;
600 int err;
602 err = qemu_strtoul(str, &endptr, 8, &res);
604 g_assert_cmpint(err, ==, 0);
605 g_assert_cmpint(res, ==, 0123);
606 g_assert(endptr == str + strlen(str));
608 res = 999;
609 endptr = &f;
610 err = qemu_strtoul(str, &endptr, 0, &res);
612 g_assert_cmpint(err, ==, 0);
613 g_assert_cmpint(res, ==, 0123);
614 g_assert(endptr == str + strlen(str));
617 static void test_qemu_strtoul_decimal(void)
619 const char *str = "0123";
620 char f = 'X';
621 const char *endptr = &f;
622 unsigned long res = 999;
623 int err;
625 err = qemu_strtoul(str, &endptr, 10, &res);
627 g_assert_cmpint(err, ==, 0);
628 g_assert_cmpint(res, ==, 123);
629 g_assert(endptr == str + strlen(str));
631 str = "123";
632 res = 999;
633 endptr = &f;
634 err = qemu_strtoul(str, &endptr, 0, &res);
636 g_assert_cmpint(err, ==, 0);
637 g_assert_cmpint(res, ==, 123);
638 g_assert(endptr == str + strlen(str));
641 static void test_qemu_strtoul_hex(void)
643 const char *str = "0123";
644 char f = 'X';
645 const char *endptr = &f;
646 unsigned long res = 999;
647 int err;
649 err = qemu_strtoul(str, &endptr, 16, &res);
651 g_assert_cmpint(err, ==, 0);
652 g_assert_cmpint(res, ==, 0x123);
653 g_assert(endptr == str + strlen(str));
655 str = "0x123";
656 res = 999;
657 endptr = &f;
658 err = qemu_strtoul(str, &endptr, 0, &res);
660 g_assert_cmpint(err, ==, 0);
661 g_assert_cmpint(res, ==, 0x123);
662 g_assert(endptr == str + strlen(str));
665 static void test_qemu_strtoul_max(void)
667 char *str = g_strdup_printf("%lu", ULONG_MAX);
668 char f = 'X';
669 const char *endptr = &f;
670 unsigned long res = 999;
671 int err;
673 err = qemu_strtoul(str, &endptr, 0, &res);
675 g_assert_cmpint(err, ==, 0);
676 g_assert_cmpint(res, ==, ULONG_MAX);
677 g_assert(endptr == str + strlen(str));
678 g_free(str);
681 static void test_qemu_strtoul_overflow(void)
683 const char *str = "99999999999999999999999999999999999999999999";
684 char f = 'X';
685 const char *endptr = &f;
686 unsigned long res = 999;
687 int err;
689 err = qemu_strtoul(str, &endptr, 0, &res);
691 g_assert_cmpint(err, ==, -ERANGE);
692 g_assert_cmpint(res, ==, ULONG_MAX);
693 g_assert(endptr == str + strlen(str));
696 static void test_qemu_strtoul_underflow(void)
698 const char *str = "-99999999999999999999999999999999999999999999";
699 char f = 'X';
700 const char *endptr = &f;
701 unsigned long res = 999;
702 int err;
704 err = qemu_strtoul(str, &endptr, 0, &res);
706 g_assert_cmpint(err, ==, -ERANGE);
707 g_assert_cmpint(res, ==, -1ul);
708 g_assert(endptr == str + strlen(str));
711 static void test_qemu_strtoul_negative(void)
713 const char *str = " \t -321";
714 char f = 'X';
715 const char *endptr = &f;
716 unsigned long res = 999;
717 int err;
719 err = qemu_strtoul(str, &endptr, 0, &res);
721 g_assert_cmpint(err, ==, 0);
722 g_assert_cmpint(res, ==, -321ul);
723 g_assert(endptr == str + strlen(str));
726 static void test_qemu_strtoul_full_correct(void)
728 const char *str = "123";
729 unsigned long res = 999;
730 int err;
732 err = qemu_strtoul(str, NULL, 0, &res);
734 g_assert_cmpint(err, ==, 0);
735 g_assert_cmpint(res, ==, 123);
738 static void test_qemu_strtoul_full_null(void)
740 unsigned long res = 999;
741 int err;
743 err = qemu_strtoul(NULL, NULL, 0, &res);
745 g_assert_cmpint(err, ==, -EINVAL);
748 static void test_qemu_strtoul_full_empty(void)
750 const char *str = "";
751 unsigned long res = 999;
752 int err;
754 err = qemu_strtoul(str, NULL, 0, &res);
756 g_assert_cmpint(err, ==, -EINVAL);
758 static void test_qemu_strtoul_full_negative(void)
760 const char *str = " \t -321";
761 unsigned long res = 999;
762 int err;
764 err = qemu_strtoul(str, NULL, 0, &res);
765 g_assert_cmpint(err, ==, 0);
766 g_assert_cmpint(res, ==, -321ul);
769 static void test_qemu_strtoul_full_trailing(void)
771 const char *str = "123xxx";
772 unsigned long res;
773 int err;
775 err = qemu_strtoul(str, NULL, 0, &res);
777 g_assert_cmpint(err, ==, -EINVAL);
780 static void test_qemu_strtoul_full_max(void)
782 char *str = g_strdup_printf("%lu", ULONG_MAX);
783 unsigned long res = 999;
784 int err;
786 err = qemu_strtoul(str, NULL, 0, &res);
788 g_assert_cmpint(err, ==, 0);
789 g_assert_cmpint(res, ==, ULONG_MAX);
790 g_free(str);
793 static void test_qemu_strtoll_correct(void)
795 const char *str = "12345 foo";
796 char f = 'X';
797 const char *endptr = &f;
798 int64_t res = 999;
799 int err;
801 err = qemu_strtoll(str, &endptr, 0, &res);
803 g_assert_cmpint(err, ==, 0);
804 g_assert_cmpint(res, ==, 12345);
805 g_assert(endptr == str + 5);
808 static void test_qemu_strtoll_null(void)
810 char f = 'X';
811 const char *endptr = &f;
812 int64_t res = 999;
813 int err;
815 err = qemu_strtoll(NULL, &endptr, 0, &res);
817 g_assert_cmpint(err, ==, -EINVAL);
818 g_assert(endptr == NULL);
821 static void test_qemu_strtoll_empty(void)
823 const char *str = "";
824 char f = 'X';
825 const char *endptr = &f;
826 int64_t res = 999;
827 int err;
829 err = qemu_strtoll(str, &endptr, 0, &res);
831 g_assert_cmpint(err, ==, -EINVAL);
834 static void test_qemu_strtoll_whitespace(void)
836 const char *str = " \t ";
837 char f = 'X';
838 const char *endptr = &f;
839 int64_t res = 999;
840 int err;
842 err = qemu_strtoll(str, &endptr, 0, &res);
844 g_assert_cmpint(err, ==, -EINVAL);
847 static void test_qemu_strtoll_invalid(void)
849 const char *str = " xxxx \t abc";
850 char f = 'X';
851 const char *endptr = &f;
852 int64_t res = 999;
853 int err;
855 err = qemu_strtoll(str, &endptr, 0, &res);
857 g_assert_cmpint(err, ==, -EINVAL);
860 static void test_qemu_strtoll_trailing(void)
862 const char *str = "123xxx";
863 char f = 'X';
864 const char *endptr = &f;
865 int64_t res = 999;
866 int err;
868 err = qemu_strtoll(str, &endptr, 0, &res);
870 g_assert_cmpint(err, ==, 0);
871 g_assert_cmpint(res, ==, 123);
872 g_assert(endptr == str + 3);
875 static void test_qemu_strtoll_octal(void)
877 const char *str = "0123";
878 char f = 'X';
879 const char *endptr = &f;
880 int64_t res = 999;
881 int err;
883 err = qemu_strtoll(str, &endptr, 8, &res);
885 g_assert_cmpint(err, ==, 0);
886 g_assert_cmpint(res, ==, 0123);
887 g_assert(endptr == str + strlen(str));
889 endptr = &f;
890 res = 999;
891 err = qemu_strtoll(str, &endptr, 0, &res);
893 g_assert_cmpint(err, ==, 0);
894 g_assert_cmpint(res, ==, 0123);
895 g_assert(endptr == str + strlen(str));
898 static void test_qemu_strtoll_decimal(void)
900 const char *str = "0123";
901 char f = 'X';
902 const char *endptr = &f;
903 int64_t res = 999;
904 int err;
906 err = qemu_strtoll(str, &endptr, 10, &res);
908 g_assert_cmpint(err, ==, 0);
909 g_assert_cmpint(res, ==, 123);
910 g_assert(endptr == str + strlen(str));
912 str = "123";
913 endptr = &f;
914 res = 999;
915 err = qemu_strtoll(str, &endptr, 0, &res);
917 g_assert_cmpint(err, ==, 0);
918 g_assert_cmpint(res, ==, 123);
919 g_assert(endptr == str + strlen(str));
922 static void test_qemu_strtoll_hex(void)
924 const char *str = "0123";
925 char f = 'X';
926 const char *endptr = &f;
927 int64_t res = 999;
928 int err;
930 err = qemu_strtoll(str, &endptr, 16, &res);
932 g_assert_cmpint(err, ==, 0);
933 g_assert_cmpint(res, ==, 0x123);
934 g_assert(endptr == str + strlen(str));
936 str = "0x123";
937 endptr = &f;
938 res = 999;
939 err = qemu_strtoll(str, &endptr, 0, &res);
941 g_assert_cmpint(err, ==, 0);
942 g_assert_cmpint(res, ==, 0x123);
943 g_assert(endptr == str + strlen(str));
946 static void test_qemu_strtoll_max(void)
948 char *str = g_strdup_printf("%lld", LLONG_MAX);
949 char f = 'X';
950 const char *endptr = &f;
951 int64_t res = 999;
952 int err;
954 err = qemu_strtoll(str, &endptr, 0, &res);
956 g_assert_cmpint(err, ==, 0);
957 g_assert_cmpint(res, ==, LLONG_MAX);
958 g_assert(endptr == str + strlen(str));
959 g_free(str);
962 static void test_qemu_strtoll_overflow(void)
964 const char *str = "99999999999999999999999999999999999999999999";
965 char f = 'X';
966 const char *endptr = &f;
967 int64_t res = 999;
968 int err;
970 err = qemu_strtoll(str, &endptr, 0, &res);
972 g_assert_cmpint(err, ==, -ERANGE);
973 g_assert_cmpint(res, ==, LLONG_MAX);
974 g_assert(endptr == str + strlen(str));
977 static void test_qemu_strtoll_underflow(void)
979 const char *str = "-99999999999999999999999999999999999999999999";
980 char f = 'X';
981 const char *endptr = &f;
982 int64_t res = 999;
983 int err;
985 err = qemu_strtoll(str, &endptr, 0, &res);
987 g_assert_cmpint(err, ==, -ERANGE);
988 g_assert_cmpint(res, ==, LLONG_MIN);
989 g_assert(endptr == str + strlen(str));
992 static void test_qemu_strtoll_negative(void)
994 const char *str = " \t -321";
995 char f = 'X';
996 const char *endptr = &f;
997 int64_t res = 999;
998 int err;
1000 err = qemu_strtoll(str, &endptr, 0, &res);
1002 g_assert_cmpint(err, ==, 0);
1003 g_assert_cmpint(res, ==, -321);
1004 g_assert(endptr == str + strlen(str));
1007 static void test_qemu_strtoll_full_correct(void)
1009 const char *str = "123";
1010 int64_t res = 999;
1011 int err;
1013 err = qemu_strtoll(str, NULL, 0, &res);
1015 g_assert_cmpint(err, ==, 0);
1016 g_assert_cmpint(res, ==, 123);
1019 static void test_qemu_strtoll_full_null(void)
1021 int64_t res = 999;
1022 int err;
1024 err = qemu_strtoll(NULL, NULL, 0, &res);
1026 g_assert_cmpint(err, ==, -EINVAL);
1029 static void test_qemu_strtoll_full_empty(void)
1031 const char *str = "";
1032 int64_t res = 999;
1033 int err;
1035 err = qemu_strtoll(str, NULL, 0, &res);
1037 g_assert_cmpint(err, ==, -EINVAL);
1040 static void test_qemu_strtoll_full_negative(void)
1042 const char *str = " \t -321";
1043 int64_t res = 999;
1044 int err;
1046 err = qemu_strtoll(str, NULL, 0, &res);
1048 g_assert_cmpint(err, ==, 0);
1049 g_assert_cmpint(res, ==, -321);
1052 static void test_qemu_strtoll_full_trailing(void)
1054 const char *str = "123xxx";
1055 int64_t res = 999;
1056 int err;
1058 err = qemu_strtoll(str, NULL, 0, &res);
1060 g_assert_cmpint(err, ==, -EINVAL);
1063 static void test_qemu_strtoll_full_max(void)
1066 char *str = g_strdup_printf("%lld", LLONG_MAX);
1067 int64_t res;
1068 int err;
1070 err = qemu_strtoll(str, NULL, 0, &res);
1072 g_assert_cmpint(err, ==, 0);
1073 g_assert_cmpint(res, ==, LLONG_MAX);
1074 g_free(str);
1077 static void test_qemu_strtoull_correct(void)
1079 const char *str = "12345 foo";
1080 char f = 'X';
1081 const char *endptr = &f;
1082 uint64_t res = 999;
1083 int err;
1085 err = qemu_strtoull(str, &endptr, 0, &res);
1087 g_assert_cmpint(err, ==, 0);
1088 g_assert_cmpint(res, ==, 12345);
1089 g_assert(endptr == str + 5);
1092 static void test_qemu_strtoull_null(void)
1094 char f = 'X';
1095 const char *endptr = &f;
1096 uint64_t res = 999;
1097 int err;
1099 err = qemu_strtoull(NULL, &endptr, 0, &res);
1101 g_assert_cmpint(err, ==, -EINVAL);
1102 g_assert(endptr == NULL);
1105 static void test_qemu_strtoull_empty(void)
1107 const char *str = "";
1108 char f = 'X';
1109 const char *endptr = &f;
1110 uint64_t res = 999;
1111 int err;
1113 err = qemu_strtoull(str, &endptr, 0, &res);
1115 g_assert_cmpint(err, ==, -EINVAL);
1118 static void test_qemu_strtoull_whitespace(void)
1120 const char *str = " \t ";
1121 char f = 'X';
1122 const char *endptr = &f;
1123 uint64_t res = 999;
1124 int err;
1126 err = qemu_strtoull(str, &endptr, 0, &res);
1128 g_assert_cmpint(err, ==, -EINVAL);
1131 static void test_qemu_strtoull_invalid(void)
1133 const char *str = " xxxx \t abc";
1134 char f = 'X';
1135 const char *endptr = &f;
1136 uint64_t res = 999;
1137 int err;
1139 err = qemu_strtoull(str, &endptr, 0, &res);
1141 g_assert_cmpint(err, ==, -EINVAL);
1144 static void test_qemu_strtoull_trailing(void)
1146 const char *str = "123xxx";
1147 char f = 'X';
1148 const char *endptr = &f;
1149 uint64_t res = 999;
1150 int err;
1152 err = qemu_strtoull(str, &endptr, 0, &res);
1154 g_assert_cmpint(err, ==, 0);
1155 g_assert_cmpint(res, ==, 123);
1156 g_assert(endptr == str + 3);
1159 static void test_qemu_strtoull_octal(void)
1161 const char *str = "0123";
1162 char f = 'X';
1163 const char *endptr = &f;
1164 uint64_t res = 999;
1165 int err;
1167 err = qemu_strtoull(str, &endptr, 8, &res);
1169 g_assert_cmpint(err, ==, 0);
1170 g_assert_cmpint(res, ==, 0123);
1171 g_assert(endptr == str + strlen(str));
1173 endptr = &f;
1174 res = 999;
1175 err = qemu_strtoull(str, &endptr, 0, &res);
1177 g_assert_cmpint(err, ==, 0);
1178 g_assert_cmpint(res, ==, 0123);
1179 g_assert(endptr == str + strlen(str));
1182 static void test_qemu_strtoull_decimal(void)
1184 const char *str = "0123";
1185 char f = 'X';
1186 const char *endptr = &f;
1187 uint64_t res = 999;
1188 int err;
1190 err = qemu_strtoull(str, &endptr, 10, &res);
1192 g_assert_cmpint(err, ==, 0);
1193 g_assert_cmpint(res, ==, 123);
1194 g_assert(endptr == str + strlen(str));
1196 str = "123";
1197 endptr = &f;
1198 res = 999;
1199 err = qemu_strtoull(str, &endptr, 0, &res);
1201 g_assert_cmpint(err, ==, 0);
1202 g_assert_cmpint(res, ==, 123);
1203 g_assert(endptr == str + strlen(str));
1206 static void test_qemu_strtoull_hex(void)
1208 const char *str = "0123";
1209 char f = 'X';
1210 const char *endptr = &f;
1211 uint64_t res = 999;
1212 int err;
1214 err = qemu_strtoull(str, &endptr, 16, &res);
1216 g_assert_cmpint(err, ==, 0);
1217 g_assert_cmpint(res, ==, 0x123);
1218 g_assert(endptr == str + strlen(str));
1220 str = "0x123";
1221 endptr = &f;
1222 res = 999;
1223 err = qemu_strtoull(str, &endptr, 0, &res);
1225 g_assert_cmpint(err, ==, 0);
1226 g_assert_cmpint(res, ==, 0x123);
1227 g_assert(endptr == str + strlen(str));
1230 static void test_qemu_strtoull_max(void)
1232 char *str = g_strdup_printf("%llu", ULLONG_MAX);
1233 char f = 'X';
1234 const char *endptr = &f;
1235 uint64_t res = 999;
1236 int err;
1238 err = qemu_strtoull(str, &endptr, 0, &res);
1240 g_assert_cmpint(err, ==, 0);
1241 g_assert_cmpint(res, ==, ULLONG_MAX);
1242 g_assert(endptr == str + strlen(str));
1243 g_free(str);
1246 static void test_qemu_strtoull_overflow(void)
1248 const char *str = "99999999999999999999999999999999999999999999";
1249 char f = 'X';
1250 const char *endptr = &f;
1251 uint64_t res = 999;
1252 int err;
1254 err = qemu_strtoull(str, &endptr, 0, &res);
1256 g_assert_cmpint(err, ==, -ERANGE);
1257 g_assert_cmpint(res, ==, ULLONG_MAX);
1258 g_assert(endptr == str + strlen(str));
1261 static void test_qemu_strtoull_underflow(void)
1263 const char *str = "-99999999999999999999999999999999999999999999";
1264 char f = 'X';
1265 const char *endptr = &f;
1266 uint64_t res = 999;
1267 int err;
1269 err = qemu_strtoull(str, &endptr, 0, &res);
1271 g_assert_cmpint(err, ==, -ERANGE);
1272 g_assert_cmpint(res, ==, -1);
1273 g_assert(endptr == str + strlen(str));
1276 static void test_qemu_strtoull_negative(void)
1278 const char *str = " \t -321";
1279 char f = 'X';
1280 const char *endptr = &f;
1281 uint64_t res = 999;
1282 int err;
1284 err = qemu_strtoull(str, &endptr, 0, &res);
1286 g_assert_cmpint(err, ==, 0);
1287 g_assert_cmpint(res, ==, -321);
1288 g_assert(endptr == str + strlen(str));
1291 static void test_qemu_strtoull_full_correct(void)
1293 const char *str = "18446744073709551614";
1294 uint64_t res = 999;
1295 int err;
1297 err = qemu_strtoull(str, NULL, 0, &res);
1299 g_assert_cmpint(err, ==, 0);
1300 g_assert_cmpint(res, ==, 18446744073709551614LLU);
1303 static void test_qemu_strtoull_full_null(void)
1305 uint64_t res = 999;
1306 int err;
1308 err = qemu_strtoull(NULL, NULL, 0, &res);
1310 g_assert_cmpint(err, ==, -EINVAL);
1313 static void test_qemu_strtoull_full_empty(void)
1315 const char *str = "";
1316 uint64_t res = 999;
1317 int err;
1319 err = qemu_strtoull(str, NULL, 0, &res);
1321 g_assert_cmpint(err, ==, -EINVAL);
1324 static void test_qemu_strtoull_full_negative(void)
1326 const char *str = " \t -321";
1327 uint64_t res = 999;
1328 int err;
1330 err = qemu_strtoull(str, NULL, 0, &res);
1332 g_assert_cmpint(err, ==, 0);
1333 g_assert_cmpint(res, ==, 18446744073709551295LLU);
1336 static void test_qemu_strtoull_full_trailing(void)
1338 const char *str = "18446744073709551614xxxxxx";
1339 uint64_t res = 999;
1340 int err;
1342 err = qemu_strtoull(str, NULL, 0, &res);
1344 g_assert_cmpint(err, ==, -EINVAL);
1347 static void test_qemu_strtoull_full_max(void)
1349 char *str = g_strdup_printf("%lld", ULLONG_MAX);
1350 uint64_t res = 999;
1351 int err;
1353 err = qemu_strtoull(str, NULL, 0, &res);
1355 g_assert_cmpint(err, ==, 0);
1356 g_assert_cmpint(res, ==, ULLONG_MAX);
1357 g_free(str);
1360 static void test_qemu_strtosz_simple(void)
1362 const char *str = "12345M";
1363 char *endptr = NULL;
1364 int64_t res;
1366 res = qemu_strtosz(str, &endptr);
1367 g_assert_cmpint(res, ==, 12345 * M_BYTE);
1368 g_assert(endptr == str + 6);
1370 res = qemu_strtosz(str, NULL);
1371 g_assert_cmpint(res, ==, 12345 * M_BYTE);
1374 static void test_qemu_strtosz_units(void)
1376 const char *none = "1";
1377 const char *b = "1B";
1378 const char *k = "1K";
1379 const char *m = "1M";
1380 const char *g = "1G";
1381 const char *t = "1T";
1382 const char *p = "1P";
1383 const char *e = "1E";
1384 int64_t res;
1386 /* default is M */
1387 res = qemu_strtosz(none, NULL);
1388 g_assert_cmpint(res, ==, M_BYTE);
1390 res = qemu_strtosz(b, NULL);
1391 g_assert_cmpint(res, ==, 1);
1393 res = qemu_strtosz(k, NULL);
1394 g_assert_cmpint(res, ==, K_BYTE);
1396 res = qemu_strtosz(m, NULL);
1397 g_assert_cmpint(res, ==, M_BYTE);
1399 res = qemu_strtosz(g, NULL);
1400 g_assert_cmpint(res, ==, G_BYTE);
1402 res = qemu_strtosz(t, NULL);
1403 g_assert_cmpint(res, ==, T_BYTE);
1405 res = qemu_strtosz(p, NULL);
1406 g_assert_cmpint(res, ==, P_BYTE);
1408 res = qemu_strtosz(e, NULL);
1409 g_assert_cmpint(res, ==, E_BYTE);
1412 static void test_qemu_strtosz_float(void)
1414 const char *str = "12.345M";
1415 int64_t res;
1417 res = qemu_strtosz(str, NULL);
1418 g_assert_cmpint(res, ==, 12.345 * M_BYTE);
1421 static void test_qemu_strtosz_erange(void)
1423 const char *str = "10E";
1424 int64_t res;
1426 res = qemu_strtosz(str, NULL);
1427 g_assert_cmpint(res, ==, -ERANGE);
1430 static void test_qemu_strtosz_suffix_unit(void)
1432 const char *str = "12345";
1433 int64_t res;
1435 res = qemu_strtosz_suffix_unit(str, NULL,
1436 QEMU_STRTOSZ_DEFSUFFIX_KB, 1000);
1437 g_assert_cmpint(res, ==, 12345000);
1440 int main(int argc, char **argv)
1442 g_test_init(&argc, &argv, NULL);
1444 g_test_add_func("/cutils/parse_uint/null", test_parse_uint_null);
1445 g_test_add_func("/cutils/parse_uint/empty", test_parse_uint_empty);
1446 g_test_add_func("/cutils/parse_uint/whitespace",
1447 test_parse_uint_whitespace);
1448 g_test_add_func("/cutils/parse_uint/invalid", test_parse_uint_invalid);
1449 g_test_add_func("/cutils/parse_uint/trailing", test_parse_uint_trailing);
1450 g_test_add_func("/cutils/parse_uint/correct", test_parse_uint_correct);
1451 g_test_add_func("/cutils/parse_uint/octal", test_parse_uint_octal);
1452 g_test_add_func("/cutils/parse_uint/decimal", test_parse_uint_decimal);
1453 g_test_add_func("/cutils/parse_uint/llong_max", test_parse_uint_llong_max);
1454 g_test_add_func("/cutils/parse_uint/overflow", test_parse_uint_overflow);
1455 g_test_add_func("/cutils/parse_uint/negative", test_parse_uint_negative);
1456 g_test_add_func("/cutils/parse_uint_full/trailing",
1457 test_parse_uint_full_trailing);
1458 g_test_add_func("/cutils/parse_uint_full/correct",
1459 test_parse_uint_full_correct);
1461 /* qemu_strtol() tests */
1462 g_test_add_func("/cutils/qemu_strtol/correct", test_qemu_strtol_correct);
1463 g_test_add_func("/cutils/qemu_strtol/null", test_qemu_strtol_null);
1464 g_test_add_func("/cutils/qemu_strtol/empty", test_qemu_strtol_empty);
1465 g_test_add_func("/cutils/qemu_strtol/whitespace",
1466 test_qemu_strtol_whitespace);
1467 g_test_add_func("/cutils/qemu_strtol/invalid", test_qemu_strtol_invalid);
1468 g_test_add_func("/cutils/qemu_strtol/trailing", test_qemu_strtol_trailing);
1469 g_test_add_func("/cutils/qemu_strtol/octal", test_qemu_strtol_octal);
1470 g_test_add_func("/cutils/qemu_strtol/decimal", test_qemu_strtol_decimal);
1471 g_test_add_func("/cutils/qemu_strtol/hex", test_qemu_strtol_hex);
1472 g_test_add_func("/cutils/qemu_strtol/max", test_qemu_strtol_max);
1473 g_test_add_func("/cutils/qemu_strtol/overflow", test_qemu_strtol_overflow);
1474 g_test_add_func("/cutils/qemu_strtol/underflow",
1475 test_qemu_strtol_underflow);
1476 g_test_add_func("/cutils/qemu_strtol/negative", test_qemu_strtol_negative);
1477 g_test_add_func("/cutils/qemu_strtol_full/correct",
1478 test_qemu_strtol_full_correct);
1479 g_test_add_func("/cutils/qemu_strtol_full/null",
1480 test_qemu_strtol_full_null);
1481 g_test_add_func("/cutils/qemu_strtol_full/empty",
1482 test_qemu_strtol_full_empty);
1483 g_test_add_func("/cutils/qemu_strtol_full/negative",
1484 test_qemu_strtol_full_negative);
1485 g_test_add_func("/cutils/qemu_strtol_full/trailing",
1486 test_qemu_strtol_full_trailing);
1487 g_test_add_func("/cutils/qemu_strtol_full/max",
1488 test_qemu_strtol_full_max);
1490 /* qemu_strtoul() tests */
1491 g_test_add_func("/cutils/qemu_strtoul/correct", test_qemu_strtoul_correct);
1492 g_test_add_func("/cutils/qemu_strtoul/null", test_qemu_strtoul_null);
1493 g_test_add_func("/cutils/qemu_strtoul/empty", test_qemu_strtoul_empty);
1494 g_test_add_func("/cutils/qemu_strtoul/whitespace",
1495 test_qemu_strtoul_whitespace);
1496 g_test_add_func("/cutils/qemu_strtoul/invalid", test_qemu_strtoul_invalid);
1497 g_test_add_func("/cutils/qemu_strtoul/trailing",
1498 test_qemu_strtoul_trailing);
1499 g_test_add_func("/cutils/qemu_strtoul/octal", test_qemu_strtoul_octal);
1500 g_test_add_func("/cutils/qemu_strtoul/decimal", test_qemu_strtoul_decimal);
1501 g_test_add_func("/cutils/qemu_strtoul/hex", test_qemu_strtoul_hex);
1502 g_test_add_func("/cutils/qemu_strtoul/max", test_qemu_strtoul_max);
1503 g_test_add_func("/cutils/qemu_strtoul/overflow",
1504 test_qemu_strtoul_overflow);
1505 g_test_add_func("/cutils/qemu_strtoul/underflow",
1506 test_qemu_strtoul_underflow);
1507 g_test_add_func("/cutils/qemu_strtoul/negative",
1508 test_qemu_strtoul_negative);
1509 g_test_add_func("/cutils/qemu_strtoul_full/correct",
1510 test_qemu_strtoul_full_correct);
1511 g_test_add_func("/cutils/qemu_strtoul_full/null",
1512 test_qemu_strtoul_full_null);
1513 g_test_add_func("/cutils/qemu_strtoul_full/empty",
1514 test_qemu_strtoul_full_empty);
1515 g_test_add_func("/cutils/qemu_strtoul_full/negative",
1516 test_qemu_strtoul_full_negative);
1517 g_test_add_func("/cutils/qemu_strtoul_full/trailing",
1518 test_qemu_strtoul_full_trailing);
1519 g_test_add_func("/cutils/qemu_strtoul_full/max",
1520 test_qemu_strtoul_full_max);
1522 /* qemu_strtoll() tests */
1523 g_test_add_func("/cutils/qemu_strtoll/correct", test_qemu_strtoll_correct);
1524 g_test_add_func("/cutils/qemu_strtoll/null", test_qemu_strtoll_null);
1525 g_test_add_func("/cutils/qemu_strtoll/empty", test_qemu_strtoll_empty);
1526 g_test_add_func("/cutils/qemu_strtoll/whitespace",
1527 test_qemu_strtoll_whitespace);
1528 g_test_add_func("/cutils/qemu_strtoll/invalid", test_qemu_strtoll_invalid);
1529 g_test_add_func("/cutils/qemu_strtoll/trailing",
1530 test_qemu_strtoll_trailing);
1531 g_test_add_func("/cutils/qemu_strtoll/octal", test_qemu_strtoll_octal);
1532 g_test_add_func("/cutils/qemu_strtoll/decimal", test_qemu_strtoll_decimal);
1533 g_test_add_func("/cutils/qemu_strtoll/hex", test_qemu_strtoll_hex);
1534 g_test_add_func("/cutils/qemu_strtoll/max", test_qemu_strtoll_max);
1535 g_test_add_func("/cutils/qemu_strtoll/overflow",
1536 test_qemu_strtoll_overflow);
1537 g_test_add_func("/cutils/qemu_strtoll/underflow",
1538 test_qemu_strtoll_underflow);
1539 g_test_add_func("/cutils/qemu_strtoll/negative",
1540 test_qemu_strtoll_negative);
1541 g_test_add_func("/cutils/qemu_strtoll_full/correct",
1542 test_qemu_strtoll_full_correct);
1543 g_test_add_func("/cutils/qemu_strtoll_full/null",
1544 test_qemu_strtoll_full_null);
1545 g_test_add_func("/cutils/qemu_strtoll_full/empty",
1546 test_qemu_strtoll_full_empty);
1547 g_test_add_func("/cutils/qemu_strtoll_full/negative",
1548 test_qemu_strtoll_full_negative);
1549 g_test_add_func("/cutils/qemu_strtoll_full/trailing",
1550 test_qemu_strtoll_full_trailing);
1551 g_test_add_func("/cutils/qemu_strtoll_full/max",
1552 test_qemu_strtoll_full_max);
1554 /* qemu_strtoull() tests */
1555 g_test_add_func("/cutils/qemu_strtoull/correct",
1556 test_qemu_strtoull_correct);
1557 g_test_add_func("/cutils/qemu_strtoull/null",
1558 test_qemu_strtoull_null);
1559 g_test_add_func("/cutils/qemu_strtoull/empty", test_qemu_strtoull_empty);
1560 g_test_add_func("/cutils/qemu_strtoull/whitespace",
1561 test_qemu_strtoull_whitespace);
1562 g_test_add_func("/cutils/qemu_strtoull/invalid",
1563 test_qemu_strtoull_invalid);
1564 g_test_add_func("/cutils/qemu_strtoull/trailing",
1565 test_qemu_strtoull_trailing);
1566 g_test_add_func("/cutils/qemu_strtoull/octal", test_qemu_strtoull_octal);
1567 g_test_add_func("/cutils/qemu_strtoull/decimal",
1568 test_qemu_strtoull_decimal);
1569 g_test_add_func("/cutils/qemu_strtoull/hex", test_qemu_strtoull_hex);
1570 g_test_add_func("/cutils/qemu_strtoull/max", test_qemu_strtoull_max);
1571 g_test_add_func("/cutils/qemu_strtoull/overflow",
1572 test_qemu_strtoull_overflow);
1573 g_test_add_func("/cutils/qemu_strtoull/underflow",
1574 test_qemu_strtoull_underflow);
1575 g_test_add_func("/cutils/qemu_strtoull/negative",
1576 test_qemu_strtoull_negative);
1577 g_test_add_func("/cutils/qemu_strtoull_full/correct",
1578 test_qemu_strtoull_full_correct);
1579 g_test_add_func("/cutils/qemu_strtoull_full/null",
1580 test_qemu_strtoull_full_null);
1581 g_test_add_func("/cutils/qemu_strtoull_full/empty",
1582 test_qemu_strtoull_full_empty);
1583 g_test_add_func("/cutils/qemu_strtoull_full/negative",
1584 test_qemu_strtoull_full_negative);
1585 g_test_add_func("/cutils/qemu_strtoull_full/trailing",
1586 test_qemu_strtoull_full_trailing);
1587 g_test_add_func("/cutils/qemu_strtoull_full/max",
1588 test_qemu_strtoull_full_max);
1590 g_test_add_func("/cutils/strtosz/simple",
1591 test_qemu_strtosz_simple);
1592 g_test_add_func("/cutils/strtosz/units",
1593 test_qemu_strtosz_units);
1594 g_test_add_func("/cutils/strtosz/float",
1595 test_qemu_strtosz_float);
1596 g_test_add_func("/cutils/strtosz/erange",
1597 test_qemu_strtosz_erange);
1598 g_test_add_func("/cutils/strtosz/suffix-unit",
1599 test_qemu_strtosz_suffix_unit);
1601 return g_test_run();