cpus.c: Use pthread_sigmask() rather than sigprocmask()
[qemu.git] / tests / test-cutils.c
blobfb8f5b5321a7e847e382ab95df4770a18b3ab259
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"
29 #include <glib.h>
31 #include "qemu/cutils.h"
33 static void test_parse_uint_null(void)
35 unsigned long long i = 999;
36 char f = 'X';
37 char *endptr = &f;
38 int r;
40 r = parse_uint(NULL, &i, &endptr, 0);
42 g_assert_cmpint(r, ==, -EINVAL);
43 g_assert_cmpint(i, ==, 0);
44 g_assert(endptr == NULL);
47 static void test_parse_uint_empty(void)
49 unsigned long long i = 999;
50 char f = 'X';
51 char *endptr = &f;
52 const char *str = "";
53 int r;
55 r = parse_uint(str, &i, &endptr, 0);
57 g_assert_cmpint(r, ==, -EINVAL);
58 g_assert_cmpint(i, ==, 0);
59 g_assert(endptr == str);
62 static void test_parse_uint_whitespace(void)
64 unsigned long long i = 999;
65 char f = 'X';
66 char *endptr = &f;
67 const char *str = " \t ";
68 int r;
70 r = parse_uint(str, &i, &endptr, 0);
72 g_assert_cmpint(r, ==, -EINVAL);
73 g_assert_cmpint(i, ==, 0);
74 g_assert(endptr == str);
78 static void test_parse_uint_invalid(void)
80 unsigned long long i = 999;
81 char f = 'X';
82 char *endptr = &f;
83 const char *str = " \t xxx";
84 int r;
86 r = parse_uint(str, &i, &endptr, 0);
88 g_assert_cmpint(r, ==, -EINVAL);
89 g_assert_cmpint(i, ==, 0);
90 g_assert(endptr == str);
94 static void test_parse_uint_trailing(void)
96 unsigned long long i = 999;
97 char f = 'X';
98 char *endptr = &f;
99 const char *str = "123xxx";
100 int r;
102 r = parse_uint(str, &i, &endptr, 0);
104 g_assert_cmpint(r, ==, 0);
105 g_assert_cmpint(i, ==, 123);
106 g_assert(endptr == str + 3);
109 static void test_parse_uint_correct(void)
111 unsigned long long i = 999;
112 char f = 'X';
113 char *endptr = &f;
114 const char *str = "123";
115 int r;
117 r = parse_uint(str, &i, &endptr, 0);
119 g_assert_cmpint(r, ==, 0);
120 g_assert_cmpint(i, ==, 123);
121 g_assert(endptr == str + strlen(str));
124 static void test_parse_uint_octal(void)
126 unsigned long long i = 999;
127 char f = 'X';
128 char *endptr = &f;
129 const char *str = "0123";
130 int r;
132 r = parse_uint(str, &i, &endptr, 0);
134 g_assert_cmpint(r, ==, 0);
135 g_assert_cmpint(i, ==, 0123);
136 g_assert(endptr == str + strlen(str));
139 static void test_parse_uint_decimal(void)
141 unsigned long long i = 999;
142 char f = 'X';
143 char *endptr = &f;
144 const char *str = "0123";
145 int r;
147 r = parse_uint(str, &i, &endptr, 10);
149 g_assert_cmpint(r, ==, 0);
150 g_assert_cmpint(i, ==, 123);
151 g_assert(endptr == str + strlen(str));
155 static void test_parse_uint_llong_max(void)
157 unsigned long long i = 999;
158 char f = 'X';
159 char *endptr = &f;
160 char *str = g_strdup_printf("%llu", (unsigned long long)LLONG_MAX + 1);
161 int r;
163 r = parse_uint(str, &i, &endptr, 0);
165 g_assert_cmpint(r, ==, 0);
166 g_assert_cmpint(i, ==, (unsigned long long)LLONG_MAX + 1);
167 g_assert(endptr == str + strlen(str));
169 g_free(str);
172 static void test_parse_uint_overflow(void)
174 unsigned long long i = 999;
175 char f = 'X';
176 char *endptr = &f;
177 const char *str = "99999999999999999999999999999999999999";
178 int r;
180 r = parse_uint(str, &i, &endptr, 0);
182 g_assert_cmpint(r, ==, -ERANGE);
183 g_assert_cmpint(i, ==, ULLONG_MAX);
184 g_assert(endptr == str + strlen(str));
187 static void test_parse_uint_negative(void)
189 unsigned long long i = 999;
190 char f = 'X';
191 char *endptr = &f;
192 const char *str = " \t -321";
193 int r;
195 r = parse_uint(str, &i, &endptr, 0);
197 g_assert_cmpint(r, ==, -ERANGE);
198 g_assert_cmpint(i, ==, 0);
199 g_assert(endptr == str + strlen(str));
203 static void test_parse_uint_full_trailing(void)
205 unsigned long long i = 999;
206 const char *str = "123xxx";
207 int r;
209 r = parse_uint_full(str, &i, 0);
211 g_assert_cmpint(r, ==, -EINVAL);
212 g_assert_cmpint(i, ==, 0);
215 static void test_parse_uint_full_correct(void)
217 unsigned long long i = 999;
218 const char *str = "123";
219 int r;
221 r = parse_uint_full(str, &i, 0);
223 g_assert_cmpint(r, ==, 0);
224 g_assert_cmpint(i, ==, 123);
227 static void test_qemu_strtol_correct(void)
229 const char *str = "12345 foo";
230 char f = 'X';
231 const char *endptr = &f;
232 long res = 999;
233 int err;
235 err = qemu_strtol(str, &endptr, 0, &res);
237 g_assert_cmpint(err, ==, 0);
238 g_assert_cmpint(res, ==, 12345);
239 g_assert(endptr == str + 5);
242 static void test_qemu_strtol_null(void)
244 char f = 'X';
245 const char *endptr = &f;
246 long res = 999;
247 int err;
249 err = qemu_strtol(NULL, &endptr, 0, &res);
251 g_assert_cmpint(err, ==, -EINVAL);
252 g_assert(endptr == NULL);
255 static void test_qemu_strtol_empty(void)
257 const char *str = "";
258 char f = 'X';
259 const char *endptr = &f;
260 long res = 999;
261 int err;
263 err = qemu_strtol(str, &endptr, 0, &res);
265 g_assert_cmpint(err, ==, -EINVAL);
268 static void test_qemu_strtol_whitespace(void)
270 const char *str = " \t ";
271 char f = 'X';
272 const char *endptr = &f;
273 long res = 999;
274 int err;
276 err = qemu_strtol(str, &endptr, 0, &res);
278 g_assert_cmpint(err, ==, -EINVAL);
281 static void test_qemu_strtol_invalid(void)
283 const char *str = " xxxx \t abc";
284 char f = 'X';
285 const char *endptr = &f;
286 long res = 999;
287 int err;
289 err = qemu_strtol(str, &endptr, 0, &res);
291 g_assert_cmpint(err, ==, -EINVAL);
294 static void test_qemu_strtol_trailing(void)
296 const char *str = "123xxx";
297 char f = 'X';
298 const char *endptr = &f;
299 long res = 999;
300 int err;
302 err = qemu_strtol(str, &endptr, 0, &res);
304 g_assert_cmpint(err, ==, 0);
305 g_assert_cmpint(res, ==, 123);
306 g_assert(endptr == str + 3);
309 static void test_qemu_strtol_octal(void)
311 const char *str = "0123";
312 char f = 'X';
313 const char *endptr = &f;
314 long res = 999;
315 int err;
317 err = qemu_strtol(str, &endptr, 8, &res);
319 g_assert_cmpint(err, ==, 0);
320 g_assert_cmpint(res, ==, 0123);
321 g_assert(endptr == str + strlen(str));
323 res = 999;
324 endptr = &f;
325 err = qemu_strtol(str, &endptr, 0, &res);
327 g_assert_cmpint(err, ==, 0);
328 g_assert_cmpint(res, ==, 0123);
329 g_assert(endptr == str + strlen(str));
332 static void test_qemu_strtol_decimal(void)
334 const char *str = "0123";
335 char f = 'X';
336 const char *endptr = &f;
337 long res = 999;
338 int err;
340 err = qemu_strtol(str, &endptr, 10, &res);
342 g_assert_cmpint(err, ==, 0);
343 g_assert_cmpint(res, ==, 123);
344 g_assert(endptr == str + strlen(str));
346 str = "123";
347 res = 999;
348 endptr = &f;
349 err = qemu_strtol(str, &endptr, 0, &res);
351 g_assert_cmpint(err, ==, 0);
352 g_assert_cmpint(res, ==, 123);
353 g_assert(endptr == str + strlen(str));
356 static void test_qemu_strtol_hex(void)
358 const char *str = "0123";
359 char f = 'X';
360 const char *endptr = &f;
361 long res = 999;
362 int err;
364 err = qemu_strtol(str, &endptr, 16, &res);
366 g_assert_cmpint(err, ==, 0);
367 g_assert_cmpint(res, ==, 0x123);
368 g_assert(endptr == str + strlen(str));
370 str = "0x123";
371 res = 999;
372 endptr = &f;
373 err = qemu_strtol(str, &endptr, 0, &res);
375 g_assert_cmpint(err, ==, 0);
376 g_assert_cmpint(res, ==, 0x123);
377 g_assert(endptr == str + strlen(str));
380 static void test_qemu_strtol_max(void)
382 const char *str = g_strdup_printf("%ld", LONG_MAX);
383 char f = 'X';
384 const char *endptr = &f;
385 long res = 999;
386 int err;
388 err = qemu_strtol(str, &endptr, 0, &res);
390 g_assert_cmpint(err, ==, 0);
391 g_assert_cmpint(res, ==, LONG_MAX);
392 g_assert(endptr == str + strlen(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 const 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);
511 static void test_qemu_strtoul_correct(void)
513 const char *str = "12345 foo";
514 char f = 'X';
515 const char *endptr = &f;
516 unsigned long res = 999;
517 int err;
519 err = qemu_strtoul(str, &endptr, 0, &res);
521 g_assert_cmpint(err, ==, 0);
522 g_assert_cmpint(res, ==, 12345);
523 g_assert(endptr == str + 5);
526 static void test_qemu_strtoul_null(void)
528 char f = 'X';
529 const char *endptr = &f;
530 unsigned long res = 999;
531 int err;
533 err = qemu_strtoul(NULL, &endptr, 0, &res);
535 g_assert_cmpint(err, ==, -EINVAL);
536 g_assert(endptr == NULL);
539 static void test_qemu_strtoul_empty(void)
541 const char *str = "";
542 char f = 'X';
543 const char *endptr = &f;
544 unsigned long res = 999;
545 int err;
547 err = qemu_strtoul(str, &endptr, 0, &res);
549 g_assert_cmpint(err, ==, -EINVAL);
552 static void test_qemu_strtoul_whitespace(void)
554 const char *str = " \t ";
555 char f = 'X';
556 const char *endptr = &f;
557 unsigned long res = 999;
558 int err;
560 err = qemu_strtoul(str, &endptr, 0, &res);
562 g_assert_cmpint(err, ==, -EINVAL);
565 static void test_qemu_strtoul_invalid(void)
567 const char *str = " xxxx \t abc";
568 char f = 'X';
569 const char *endptr = &f;
570 unsigned long res = 999;
571 int err;
573 err = qemu_strtoul(str, &endptr, 0, &res);
575 g_assert_cmpint(err, ==, -EINVAL);
578 static void test_qemu_strtoul_trailing(void)
580 const char *str = "123xxx";
581 char f = 'X';
582 const char *endptr = &f;
583 unsigned long res = 999;
584 int err;
586 err = qemu_strtoul(str, &endptr, 0, &res);
588 g_assert_cmpint(err, ==, 0);
589 g_assert_cmpint(res, ==, 123);
590 g_assert(endptr == str + 3);
593 static void test_qemu_strtoul_octal(void)
595 const char *str = "0123";
596 char f = 'X';
597 const char *endptr = &f;
598 unsigned long res = 999;
599 int err;
601 err = qemu_strtoul(str, &endptr, 8, &res);
603 g_assert_cmpint(err, ==, 0);
604 g_assert_cmpint(res, ==, 0123);
605 g_assert(endptr == str + strlen(str));
607 res = 999;
608 endptr = &f;
609 err = qemu_strtoul(str, &endptr, 0, &res);
611 g_assert_cmpint(err, ==, 0);
612 g_assert_cmpint(res, ==, 0123);
613 g_assert(endptr == str + strlen(str));
616 static void test_qemu_strtoul_decimal(void)
618 const char *str = "0123";
619 char f = 'X';
620 const char *endptr = &f;
621 unsigned long res = 999;
622 int err;
624 err = qemu_strtoul(str, &endptr, 10, &res);
626 g_assert_cmpint(err, ==, 0);
627 g_assert_cmpint(res, ==, 123);
628 g_assert(endptr == str + strlen(str));
630 str = "123";
631 res = 999;
632 endptr = &f;
633 err = qemu_strtoul(str, &endptr, 0, &res);
635 g_assert_cmpint(err, ==, 0);
636 g_assert_cmpint(res, ==, 123);
637 g_assert(endptr == str + strlen(str));
640 static void test_qemu_strtoul_hex(void)
642 const char *str = "0123";
643 char f = 'X';
644 const char *endptr = &f;
645 unsigned long res = 999;
646 int err;
648 err = qemu_strtoul(str, &endptr, 16, &res);
650 g_assert_cmpint(err, ==, 0);
651 g_assert_cmpint(res, ==, 0x123);
652 g_assert(endptr == str + strlen(str));
654 str = "0x123";
655 res = 999;
656 endptr = &f;
657 err = qemu_strtoul(str, &endptr, 0, &res);
659 g_assert_cmpint(err, ==, 0);
660 g_assert_cmpint(res, ==, 0x123);
661 g_assert(endptr == str + strlen(str));
664 static void test_qemu_strtoul_max(void)
666 const char *str = g_strdup_printf("%lu", ULONG_MAX);
667 char f = 'X';
668 const char *endptr = &f;
669 unsigned long res = 999;
670 int err;
672 err = qemu_strtoul(str, &endptr, 0, &res);
674 g_assert_cmpint(err, ==, 0);
675 g_assert_cmpint(res, ==, ULONG_MAX);
676 g_assert(endptr == str + strlen(str));
679 static void test_qemu_strtoul_overflow(void)
681 const char *str = "99999999999999999999999999999999999999999999";
682 char f = 'X';
683 const char *endptr = &f;
684 unsigned long res = 999;
685 int err;
687 err = qemu_strtoul(str, &endptr, 0, &res);
689 g_assert_cmpint(err, ==, -ERANGE);
690 g_assert_cmpint(res, ==, ULONG_MAX);
691 g_assert(endptr == str + strlen(str));
694 static void test_qemu_strtoul_underflow(void)
696 const char *str = "-99999999999999999999999999999999999999999999";
697 char f = 'X';
698 const char *endptr = &f;
699 unsigned long res = 999;
700 int err;
702 err = qemu_strtoul(str, &endptr, 0, &res);
704 g_assert_cmpint(err, ==, -ERANGE);
705 g_assert_cmpint(res, ==, -1ul);
706 g_assert(endptr == str + strlen(str));
709 static void test_qemu_strtoul_negative(void)
711 const char *str = " \t -321";
712 char f = 'X';
713 const char *endptr = &f;
714 unsigned long res = 999;
715 int err;
717 err = qemu_strtoul(str, &endptr, 0, &res);
719 g_assert_cmpint(err, ==, 0);
720 g_assert_cmpint(res, ==, -321ul);
721 g_assert(endptr == str + strlen(str));
724 static void test_qemu_strtoul_full_correct(void)
726 const char *str = "123";
727 unsigned long res = 999;
728 int err;
730 err = qemu_strtoul(str, NULL, 0, &res);
732 g_assert_cmpint(err, ==, 0);
733 g_assert_cmpint(res, ==, 123);
736 static void test_qemu_strtoul_full_null(void)
738 unsigned long res = 999;
739 int err;
741 err = qemu_strtoul(NULL, NULL, 0, &res);
743 g_assert_cmpint(err, ==, -EINVAL);
746 static void test_qemu_strtoul_full_empty(void)
748 const char *str = "";
749 unsigned long res = 999;
750 int err;
752 err = qemu_strtoul(str, NULL, 0, &res);
754 g_assert_cmpint(err, ==, -EINVAL);
756 static void test_qemu_strtoul_full_negative(void)
758 const char *str = " \t -321";
759 unsigned long res = 999;
760 int err;
762 err = qemu_strtoul(str, NULL, 0, &res);
763 g_assert_cmpint(err, ==, 0);
764 g_assert_cmpint(res, ==, -321ul);
767 static void test_qemu_strtoul_full_trailing(void)
769 const char *str = "123xxx";
770 unsigned long res;
771 int err;
773 err = qemu_strtoul(str, NULL, 0, &res);
775 g_assert_cmpint(err, ==, -EINVAL);
778 static void test_qemu_strtoul_full_max(void)
780 const char *str = g_strdup_printf("%lu", ULONG_MAX);
781 unsigned long res = 999;
782 int err;
784 err = qemu_strtoul(str, NULL, 0, &res);
786 g_assert_cmpint(err, ==, 0);
787 g_assert_cmpint(res, ==, ULONG_MAX);
790 static void test_qemu_strtoll_correct(void)
792 const char *str = "12345 foo";
793 char f = 'X';
794 const char *endptr = &f;
795 int64_t res = 999;
796 int err;
798 err = qemu_strtoll(str, &endptr, 0, &res);
800 g_assert_cmpint(err, ==, 0);
801 g_assert_cmpint(res, ==, 12345);
802 g_assert(endptr == str + 5);
805 static void test_qemu_strtoll_null(void)
807 char f = 'X';
808 const char *endptr = &f;
809 int64_t res = 999;
810 int err;
812 err = qemu_strtoll(NULL, &endptr, 0, &res);
814 g_assert_cmpint(err, ==, -EINVAL);
815 g_assert(endptr == NULL);
818 static void test_qemu_strtoll_empty(void)
820 const char *str = "";
821 char f = 'X';
822 const char *endptr = &f;
823 int64_t res = 999;
824 int err;
826 err = qemu_strtoll(str, &endptr, 0, &res);
828 g_assert_cmpint(err, ==, -EINVAL);
831 static void test_qemu_strtoll_whitespace(void)
833 const char *str = " \t ";
834 char f = 'X';
835 const char *endptr = &f;
836 int64_t res = 999;
837 int err;
839 err = qemu_strtoll(str, &endptr, 0, &res);
841 g_assert_cmpint(err, ==, -EINVAL);
844 static void test_qemu_strtoll_invalid(void)
846 const char *str = " xxxx \t abc";
847 char f = 'X';
848 const char *endptr = &f;
849 int64_t res = 999;
850 int err;
852 err = qemu_strtoll(str, &endptr, 0, &res);
854 g_assert_cmpint(err, ==, -EINVAL);
857 static void test_qemu_strtoll_trailing(void)
859 const char *str = "123xxx";
860 char f = 'X';
861 const char *endptr = &f;
862 int64_t res = 999;
863 int err;
865 err = qemu_strtoll(str, &endptr, 0, &res);
867 g_assert_cmpint(err, ==, 0);
868 g_assert_cmpint(res, ==, 123);
869 g_assert(endptr == str + 3);
872 static void test_qemu_strtoll_octal(void)
874 const char *str = "0123";
875 char f = 'X';
876 const char *endptr = &f;
877 int64_t res = 999;
878 int err;
880 err = qemu_strtoll(str, &endptr, 8, &res);
882 g_assert_cmpint(err, ==, 0);
883 g_assert_cmpint(res, ==, 0123);
884 g_assert(endptr == str + strlen(str));
886 endptr = &f;
887 res = 999;
888 err = qemu_strtoll(str, &endptr, 0, &res);
890 g_assert_cmpint(err, ==, 0);
891 g_assert_cmpint(res, ==, 0123);
892 g_assert(endptr == str + strlen(str));
895 static void test_qemu_strtoll_decimal(void)
897 const char *str = "0123";
898 char f = 'X';
899 const char *endptr = &f;
900 int64_t res = 999;
901 int err;
903 err = qemu_strtoll(str, &endptr, 10, &res);
905 g_assert_cmpint(err, ==, 0);
906 g_assert_cmpint(res, ==, 123);
907 g_assert(endptr == str + strlen(str));
909 str = "123";
910 endptr = &f;
911 res = 999;
912 err = qemu_strtoll(str, &endptr, 0, &res);
914 g_assert_cmpint(err, ==, 0);
915 g_assert_cmpint(res, ==, 123);
916 g_assert(endptr == str + strlen(str));
919 static void test_qemu_strtoll_hex(void)
921 const char *str = "0123";
922 char f = 'X';
923 const char *endptr = &f;
924 int64_t res = 999;
925 int err;
927 err = qemu_strtoll(str, &endptr, 16, &res);
929 g_assert_cmpint(err, ==, 0);
930 g_assert_cmpint(res, ==, 0x123);
931 g_assert(endptr == str + strlen(str));
933 str = "0x123";
934 endptr = &f;
935 res = 999;
936 err = qemu_strtoll(str, &endptr, 0, &res);
938 g_assert_cmpint(err, ==, 0);
939 g_assert_cmpint(res, ==, 0x123);
940 g_assert(endptr == str + strlen(str));
943 static void test_qemu_strtoll_max(void)
945 const char *str = g_strdup_printf("%lld", LLONG_MAX);
946 char f = 'X';
947 const char *endptr = &f;
948 int64_t res = 999;
949 int err;
951 err = qemu_strtoll(str, &endptr, 0, &res);
953 g_assert_cmpint(err, ==, 0);
954 g_assert_cmpint(res, ==, LLONG_MAX);
955 g_assert(endptr == str + strlen(str));
958 static void test_qemu_strtoll_overflow(void)
960 const char *str = "99999999999999999999999999999999999999999999";
961 char f = 'X';
962 const char *endptr = &f;
963 int64_t res = 999;
964 int err;
966 err = qemu_strtoll(str, &endptr, 0, &res);
968 g_assert_cmpint(err, ==, -ERANGE);
969 g_assert_cmpint(res, ==, LLONG_MAX);
970 g_assert(endptr == str + strlen(str));
973 static void test_qemu_strtoll_underflow(void)
975 const char *str = "-99999999999999999999999999999999999999999999";
976 char f = 'X';
977 const char *endptr = &f;
978 int64_t res = 999;
979 int err;
981 err = qemu_strtoll(str, &endptr, 0, &res);
983 g_assert_cmpint(err, ==, -ERANGE);
984 g_assert_cmpint(res, ==, LLONG_MIN);
985 g_assert(endptr == str + strlen(str));
988 static void test_qemu_strtoll_negative(void)
990 const char *str = " \t -321";
991 char f = 'X';
992 const char *endptr = &f;
993 int64_t res = 999;
994 int err;
996 err = qemu_strtoll(str, &endptr, 0, &res);
998 g_assert_cmpint(err, ==, 0);
999 g_assert_cmpint(res, ==, -321);
1000 g_assert(endptr == str + strlen(str));
1003 static void test_qemu_strtoll_full_correct(void)
1005 const char *str = "123";
1006 int64_t res = 999;
1007 int err;
1009 err = qemu_strtoll(str, NULL, 0, &res);
1011 g_assert_cmpint(err, ==, 0);
1012 g_assert_cmpint(res, ==, 123);
1015 static void test_qemu_strtoll_full_null(void)
1017 int64_t res = 999;
1018 int err;
1020 err = qemu_strtoll(NULL, NULL, 0, &res);
1022 g_assert_cmpint(err, ==, -EINVAL);
1025 static void test_qemu_strtoll_full_empty(void)
1027 const char *str = "";
1028 int64_t res = 999;
1029 int err;
1031 err = qemu_strtoll(str, NULL, 0, &res);
1033 g_assert_cmpint(err, ==, -EINVAL);
1036 static void test_qemu_strtoll_full_negative(void)
1038 const char *str = " \t -321";
1039 int64_t res = 999;
1040 int err;
1042 err = qemu_strtoll(str, NULL, 0, &res);
1044 g_assert_cmpint(err, ==, 0);
1045 g_assert_cmpint(res, ==, -321);
1048 static void test_qemu_strtoll_full_trailing(void)
1050 const char *str = "123xxx";
1051 int64_t res = 999;
1052 int err;
1054 err = qemu_strtoll(str, NULL, 0, &res);
1056 g_assert_cmpint(err, ==, -EINVAL);
1059 static void test_qemu_strtoll_full_max(void)
1062 const char *str = g_strdup_printf("%lld", LLONG_MAX);
1063 int64_t res;
1064 int err;
1066 err = qemu_strtoll(str, NULL, 0, &res);
1068 g_assert_cmpint(err, ==, 0);
1069 g_assert_cmpint(res, ==, LLONG_MAX);
1072 static void test_qemu_strtoull_correct(void)
1074 const char *str = "12345 foo";
1075 char f = 'X';
1076 const char *endptr = &f;
1077 uint64_t res = 999;
1078 int err;
1080 err = qemu_strtoull(str, &endptr, 0, &res);
1082 g_assert_cmpint(err, ==, 0);
1083 g_assert_cmpint(res, ==, 12345);
1084 g_assert(endptr == str + 5);
1087 static void test_qemu_strtoull_null(void)
1089 char f = 'X';
1090 const char *endptr = &f;
1091 uint64_t res = 999;
1092 int err;
1094 err = qemu_strtoull(NULL, &endptr, 0, &res);
1096 g_assert_cmpint(err, ==, -EINVAL);
1097 g_assert(endptr == NULL);
1100 static void test_qemu_strtoull_empty(void)
1102 const char *str = "";
1103 char f = 'X';
1104 const char *endptr = &f;
1105 uint64_t res = 999;
1106 int err;
1108 err = qemu_strtoull(str, &endptr, 0, &res);
1110 g_assert_cmpint(err, ==, -EINVAL);
1113 static void test_qemu_strtoull_whitespace(void)
1115 const char *str = " \t ";
1116 char f = 'X';
1117 const char *endptr = &f;
1118 uint64_t res = 999;
1119 int err;
1121 err = qemu_strtoull(str, &endptr, 0, &res);
1123 g_assert_cmpint(err, ==, -EINVAL);
1126 static void test_qemu_strtoull_invalid(void)
1128 const char *str = " xxxx \t abc";
1129 char f = 'X';
1130 const char *endptr = &f;
1131 uint64_t res = 999;
1132 int err;
1134 err = qemu_strtoull(str, &endptr, 0, &res);
1136 g_assert_cmpint(err, ==, -EINVAL);
1139 static void test_qemu_strtoull_trailing(void)
1141 const char *str = "123xxx";
1142 char f = 'X';
1143 const char *endptr = &f;
1144 uint64_t res = 999;
1145 int err;
1147 err = qemu_strtoull(str, &endptr, 0, &res);
1149 g_assert_cmpint(err, ==, 0);
1150 g_assert_cmpint(res, ==, 123);
1151 g_assert(endptr == str + 3);
1154 static void test_qemu_strtoull_octal(void)
1156 const char *str = "0123";
1157 char f = 'X';
1158 const char *endptr = &f;
1159 uint64_t res = 999;
1160 int err;
1162 err = qemu_strtoull(str, &endptr, 8, &res);
1164 g_assert_cmpint(err, ==, 0);
1165 g_assert_cmpint(res, ==, 0123);
1166 g_assert(endptr == str + strlen(str));
1168 endptr = &f;
1169 res = 999;
1170 err = qemu_strtoull(str, &endptr, 0, &res);
1172 g_assert_cmpint(err, ==, 0);
1173 g_assert_cmpint(res, ==, 0123);
1174 g_assert(endptr == str + strlen(str));
1177 static void test_qemu_strtoull_decimal(void)
1179 const char *str = "0123";
1180 char f = 'X';
1181 const char *endptr = &f;
1182 uint64_t res = 999;
1183 int err;
1185 err = qemu_strtoull(str, &endptr, 10, &res);
1187 g_assert_cmpint(err, ==, 0);
1188 g_assert_cmpint(res, ==, 123);
1189 g_assert(endptr == str + strlen(str));
1191 str = "123";
1192 endptr = &f;
1193 res = 999;
1194 err = qemu_strtoull(str, &endptr, 0, &res);
1196 g_assert_cmpint(err, ==, 0);
1197 g_assert_cmpint(res, ==, 123);
1198 g_assert(endptr == str + strlen(str));
1201 static void test_qemu_strtoull_hex(void)
1203 const char *str = "0123";
1204 char f = 'X';
1205 const char *endptr = &f;
1206 uint64_t res = 999;
1207 int err;
1209 err = qemu_strtoull(str, &endptr, 16, &res);
1211 g_assert_cmpint(err, ==, 0);
1212 g_assert_cmpint(res, ==, 0x123);
1213 g_assert(endptr == str + strlen(str));
1215 str = "0x123";
1216 endptr = &f;
1217 res = 999;
1218 err = qemu_strtoull(str, &endptr, 0, &res);
1220 g_assert_cmpint(err, ==, 0);
1221 g_assert_cmpint(res, ==, 0x123);
1222 g_assert(endptr == str + strlen(str));
1225 static void test_qemu_strtoull_max(void)
1227 const char *str = g_strdup_printf("%llu", ULLONG_MAX);
1228 char f = 'X';
1229 const char *endptr = &f;
1230 uint64_t res = 999;
1231 int err;
1233 err = qemu_strtoull(str, &endptr, 0, &res);
1235 g_assert_cmpint(err, ==, 0);
1236 g_assert_cmpint(res, ==, ULLONG_MAX);
1237 g_assert(endptr == str + strlen(str));
1240 static void test_qemu_strtoull_overflow(void)
1242 const char *str = "99999999999999999999999999999999999999999999";
1243 char f = 'X';
1244 const char *endptr = &f;
1245 uint64_t res = 999;
1246 int err;
1248 err = qemu_strtoull(str, &endptr, 0, &res);
1250 g_assert_cmpint(err, ==, -ERANGE);
1251 g_assert_cmpint(res, ==, ULLONG_MAX);
1252 g_assert(endptr == str + strlen(str));
1255 static void test_qemu_strtoull_underflow(void)
1257 const char *str = "-99999999999999999999999999999999999999999999";
1258 char f = 'X';
1259 const char *endptr = &f;
1260 uint64_t res = 999;
1261 int err;
1263 err = qemu_strtoull(str, &endptr, 0, &res);
1265 g_assert_cmpint(err, ==, -ERANGE);
1266 g_assert_cmpint(res, ==, -1);
1267 g_assert(endptr == str + strlen(str));
1270 static void test_qemu_strtoull_negative(void)
1272 const char *str = " \t -321";
1273 char f = 'X';
1274 const char *endptr = &f;
1275 uint64_t res = 999;
1276 int err;
1278 err = qemu_strtoull(str, &endptr, 0, &res);
1280 g_assert_cmpint(err, ==, 0);
1281 g_assert_cmpint(res, ==, -321);
1282 g_assert(endptr == str + strlen(str));
1285 static void test_qemu_strtoull_full_correct(void)
1287 const char *str = "18446744073709551614";
1288 uint64_t res = 999;
1289 int err;
1291 err = qemu_strtoull(str, NULL, 0, &res);
1293 g_assert_cmpint(err, ==, 0);
1294 g_assert_cmpint(res, ==, 18446744073709551614LLU);
1297 static void test_qemu_strtoull_full_null(void)
1299 uint64_t res = 999;
1300 int err;
1302 err = qemu_strtoull(NULL, NULL, 0, &res);
1304 g_assert_cmpint(err, ==, -EINVAL);
1307 static void test_qemu_strtoull_full_empty(void)
1309 const char *str = "";
1310 uint64_t res = 999;
1311 int err;
1313 err = qemu_strtoull(str, NULL, 0, &res);
1315 g_assert_cmpint(err, ==, -EINVAL);
1318 static void test_qemu_strtoull_full_negative(void)
1320 const char *str = " \t -321";
1321 uint64_t res = 999;
1322 int err;
1324 err = qemu_strtoull(str, NULL, 0, &res);
1326 g_assert_cmpint(err, ==, 0);
1327 g_assert_cmpint(res, ==, 18446744073709551295LLU);
1330 static void test_qemu_strtoull_full_trailing(void)
1332 const char *str = "18446744073709551614xxxxxx";
1333 uint64_t res = 999;
1334 int err;
1336 err = qemu_strtoull(str, NULL, 0, &res);
1338 g_assert_cmpint(err, ==, -EINVAL);
1341 static void test_qemu_strtoull_full_max(void)
1343 const char *str = g_strdup_printf("%lld", ULLONG_MAX);
1344 uint64_t res = 999;
1345 int err;
1347 err = qemu_strtoull(str, NULL, 0, &res);
1349 g_assert_cmpint(err, ==, 0);
1350 g_assert_cmpint(res, ==, ULLONG_MAX);
1353 static void test_qemu_strtosz_simple(void)
1355 const char *str = "12345M";
1356 char *endptr = NULL;
1357 int64_t res;
1359 res = qemu_strtosz(str, &endptr);
1360 g_assert_cmpint(res, ==, 12345 * M_BYTE);
1361 g_assert(endptr == str + 6);
1363 res = qemu_strtosz(str, NULL);
1364 g_assert_cmpint(res, ==, 12345 * M_BYTE);
1367 static void test_qemu_strtosz_units(void)
1369 const char *none = "1";
1370 const char *b = "1B";
1371 const char *k = "1K";
1372 const char *m = "1M";
1373 const char *g = "1G";
1374 const char *t = "1T";
1375 const char *p = "1P";
1376 const char *e = "1E";
1377 int64_t res;
1379 /* default is M */
1380 res = qemu_strtosz(none, NULL);
1381 g_assert_cmpint(res, ==, M_BYTE);
1383 res = qemu_strtosz(b, NULL);
1384 g_assert_cmpint(res, ==, 1);
1386 res = qemu_strtosz(k, NULL);
1387 g_assert_cmpint(res, ==, K_BYTE);
1389 res = qemu_strtosz(m, NULL);
1390 g_assert_cmpint(res, ==, M_BYTE);
1392 res = qemu_strtosz(g, NULL);
1393 g_assert_cmpint(res, ==, G_BYTE);
1395 res = qemu_strtosz(t, NULL);
1396 g_assert_cmpint(res, ==, T_BYTE);
1398 res = qemu_strtosz(p, NULL);
1399 g_assert_cmpint(res, ==, P_BYTE);
1401 res = qemu_strtosz(e, NULL);
1402 g_assert_cmpint(res, ==, E_BYTE);
1405 static void test_qemu_strtosz_float(void)
1407 const char *str = "12.345M";
1408 int64_t res;
1410 res = qemu_strtosz(str, NULL);
1411 g_assert_cmpint(res, ==, 12.345 * M_BYTE);
1414 static void test_qemu_strtosz_erange(void)
1416 const char *str = "10E";
1417 int64_t res;
1419 res = qemu_strtosz(str, NULL);
1420 g_assert_cmpint(res, ==, -ERANGE);
1423 static void test_qemu_strtosz_suffix_unit(void)
1425 const char *str = "12345";
1426 int64_t res;
1428 res = qemu_strtosz_suffix_unit(str, NULL,
1429 QEMU_STRTOSZ_DEFSUFFIX_KB, 1000);
1430 g_assert_cmpint(res, ==, 12345000);
1433 int main(int argc, char **argv)
1435 g_test_init(&argc, &argv, NULL);
1437 g_test_add_func("/cutils/parse_uint/null", test_parse_uint_null);
1438 g_test_add_func("/cutils/parse_uint/empty", test_parse_uint_empty);
1439 g_test_add_func("/cutils/parse_uint/whitespace",
1440 test_parse_uint_whitespace);
1441 g_test_add_func("/cutils/parse_uint/invalid", test_parse_uint_invalid);
1442 g_test_add_func("/cutils/parse_uint/trailing", test_parse_uint_trailing);
1443 g_test_add_func("/cutils/parse_uint/correct", test_parse_uint_correct);
1444 g_test_add_func("/cutils/parse_uint/octal", test_parse_uint_octal);
1445 g_test_add_func("/cutils/parse_uint/decimal", test_parse_uint_decimal);
1446 g_test_add_func("/cutils/parse_uint/llong_max", test_parse_uint_llong_max);
1447 g_test_add_func("/cutils/parse_uint/overflow", test_parse_uint_overflow);
1448 g_test_add_func("/cutils/parse_uint/negative", test_parse_uint_negative);
1449 g_test_add_func("/cutils/parse_uint_full/trailing",
1450 test_parse_uint_full_trailing);
1451 g_test_add_func("/cutils/parse_uint_full/correct",
1452 test_parse_uint_full_correct);
1454 /* qemu_strtol() tests */
1455 g_test_add_func("/cutils/qemu_strtol/correct", test_qemu_strtol_correct);
1456 g_test_add_func("/cutils/qemu_strtol/null", test_qemu_strtol_null);
1457 g_test_add_func("/cutils/qemu_strtol/empty", test_qemu_strtol_empty);
1458 g_test_add_func("/cutils/qemu_strtol/whitespace",
1459 test_qemu_strtol_whitespace);
1460 g_test_add_func("/cutils/qemu_strtol/invalid", test_qemu_strtol_invalid);
1461 g_test_add_func("/cutils/qemu_strtol/trailing", test_qemu_strtol_trailing);
1462 g_test_add_func("/cutils/qemu_strtol/octal", test_qemu_strtol_octal);
1463 g_test_add_func("/cutils/qemu_strtol/decimal", test_qemu_strtol_decimal);
1464 g_test_add_func("/cutils/qemu_strtol/hex", test_qemu_strtol_hex);
1465 g_test_add_func("/cutils/qemu_strtol/max", test_qemu_strtol_max);
1466 g_test_add_func("/cutils/qemu_strtol/overflow", test_qemu_strtol_overflow);
1467 g_test_add_func("/cutils/qemu_strtol/underflow",
1468 test_qemu_strtol_underflow);
1469 g_test_add_func("/cutils/qemu_strtol/negative", test_qemu_strtol_negative);
1470 g_test_add_func("/cutils/qemu_strtol_full/correct",
1471 test_qemu_strtol_full_correct);
1472 g_test_add_func("/cutils/qemu_strtol_full/null",
1473 test_qemu_strtol_full_null);
1474 g_test_add_func("/cutils/qemu_strtol_full/empty",
1475 test_qemu_strtol_full_empty);
1476 g_test_add_func("/cutils/qemu_strtol_full/negative",
1477 test_qemu_strtol_full_negative);
1478 g_test_add_func("/cutils/qemu_strtol_full/trailing",
1479 test_qemu_strtol_full_trailing);
1480 g_test_add_func("/cutils/qemu_strtol_full/max",
1481 test_qemu_strtol_full_max);
1483 /* qemu_strtoul() tests */
1484 g_test_add_func("/cutils/qemu_strtoul/correct", test_qemu_strtoul_correct);
1485 g_test_add_func("/cutils/qemu_strtoul/null", test_qemu_strtoul_null);
1486 g_test_add_func("/cutils/qemu_strtoul/empty", test_qemu_strtoul_empty);
1487 g_test_add_func("/cutils/qemu_strtoul/whitespace",
1488 test_qemu_strtoul_whitespace);
1489 g_test_add_func("/cutils/qemu_strtoul/invalid", test_qemu_strtoul_invalid);
1490 g_test_add_func("/cutils/qemu_strtoul/trailing",
1491 test_qemu_strtoul_trailing);
1492 g_test_add_func("/cutils/qemu_strtoul/octal", test_qemu_strtoul_octal);
1493 g_test_add_func("/cutils/qemu_strtoul/decimal", test_qemu_strtoul_decimal);
1494 g_test_add_func("/cutils/qemu_strtoul/hex", test_qemu_strtoul_hex);
1495 g_test_add_func("/cutils/qemu_strtoul/max", test_qemu_strtoul_max);
1496 g_test_add_func("/cutils/qemu_strtoul/overflow",
1497 test_qemu_strtoul_overflow);
1498 g_test_add_func("/cutils/qemu_strtoul/underflow",
1499 test_qemu_strtoul_underflow);
1500 g_test_add_func("/cutils/qemu_strtoul/negative",
1501 test_qemu_strtoul_negative);
1502 g_test_add_func("/cutils/qemu_strtoul_full/correct",
1503 test_qemu_strtoul_full_correct);
1504 g_test_add_func("/cutils/qemu_strtoul_full/null",
1505 test_qemu_strtoul_full_null);
1506 g_test_add_func("/cutils/qemu_strtoul_full/empty",
1507 test_qemu_strtoul_full_empty);
1508 g_test_add_func("/cutils/qemu_strtoul_full/negative",
1509 test_qemu_strtoul_full_negative);
1510 g_test_add_func("/cutils/qemu_strtoul_full/trailing",
1511 test_qemu_strtoul_full_trailing);
1512 g_test_add_func("/cutils/qemu_strtoul_full/max",
1513 test_qemu_strtoul_full_max);
1515 /* qemu_strtoll() tests */
1516 g_test_add_func("/cutils/qemu_strtoll/correct", test_qemu_strtoll_correct);
1517 g_test_add_func("/cutils/qemu_strtoll/null", test_qemu_strtoll_null);
1518 g_test_add_func("/cutils/qemu_strtoll/empty", test_qemu_strtoll_empty);
1519 g_test_add_func("/cutils/qemu_strtoll/whitespace",
1520 test_qemu_strtoll_whitespace);
1521 g_test_add_func("/cutils/qemu_strtoll/invalid", test_qemu_strtoll_invalid);
1522 g_test_add_func("/cutils/qemu_strtoll/trailing",
1523 test_qemu_strtoll_trailing);
1524 g_test_add_func("/cutils/qemu_strtoll/octal", test_qemu_strtoll_octal);
1525 g_test_add_func("/cutils/qemu_strtoll/decimal", test_qemu_strtoll_decimal);
1526 g_test_add_func("/cutils/qemu_strtoll/hex", test_qemu_strtoll_hex);
1527 g_test_add_func("/cutils/qemu_strtoll/max", test_qemu_strtoll_max);
1528 g_test_add_func("/cutils/qemu_strtoll/overflow",
1529 test_qemu_strtoll_overflow);
1530 g_test_add_func("/cutils/qemu_strtoll/underflow",
1531 test_qemu_strtoll_underflow);
1532 g_test_add_func("/cutils/qemu_strtoll/negative",
1533 test_qemu_strtoll_negative);
1534 g_test_add_func("/cutils/qemu_strtoll_full/correct",
1535 test_qemu_strtoll_full_correct);
1536 g_test_add_func("/cutils/qemu_strtoll_full/null",
1537 test_qemu_strtoll_full_null);
1538 g_test_add_func("/cutils/qemu_strtoll_full/empty",
1539 test_qemu_strtoll_full_empty);
1540 g_test_add_func("/cutils/qemu_strtoll_full/negative",
1541 test_qemu_strtoll_full_negative);
1542 g_test_add_func("/cutils/qemu_strtoll_full/trailing",
1543 test_qemu_strtoll_full_trailing);
1544 g_test_add_func("/cutils/qemu_strtoll_full/max",
1545 test_qemu_strtoll_full_max);
1547 /* qemu_strtoull() tests */
1548 g_test_add_func("/cutils/qemu_strtoull/correct",
1549 test_qemu_strtoull_correct);
1550 g_test_add_func("/cutils/qemu_strtoull/null",
1551 test_qemu_strtoull_null);
1552 g_test_add_func("/cutils/qemu_strtoull/empty", test_qemu_strtoull_empty);
1553 g_test_add_func("/cutils/qemu_strtoull/whitespace",
1554 test_qemu_strtoull_whitespace);
1555 g_test_add_func("/cutils/qemu_strtoull/invalid",
1556 test_qemu_strtoull_invalid);
1557 g_test_add_func("/cutils/qemu_strtoull/trailing",
1558 test_qemu_strtoull_trailing);
1559 g_test_add_func("/cutils/qemu_strtoull/octal", test_qemu_strtoull_octal);
1560 g_test_add_func("/cutils/qemu_strtoull/decimal",
1561 test_qemu_strtoull_decimal);
1562 g_test_add_func("/cutils/qemu_strtoull/hex", test_qemu_strtoull_hex);
1563 g_test_add_func("/cutils/qemu_strtoull/max", test_qemu_strtoull_max);
1564 g_test_add_func("/cutils/qemu_strtoull/overflow",
1565 test_qemu_strtoull_overflow);
1566 g_test_add_func("/cutils/qemu_strtoull/underflow",
1567 test_qemu_strtoull_underflow);
1568 g_test_add_func("/cutils/qemu_strtoull/negative",
1569 test_qemu_strtoull_negative);
1570 g_test_add_func("/cutils/qemu_strtoull_full/correct",
1571 test_qemu_strtoull_full_correct);
1572 g_test_add_func("/cutils/qemu_strtoull_full/null",
1573 test_qemu_strtoull_full_null);
1574 g_test_add_func("/cutils/qemu_strtoull_full/empty",
1575 test_qemu_strtoull_full_empty);
1576 g_test_add_func("/cutils/qemu_strtoull_full/negative",
1577 test_qemu_strtoull_full_negative);
1578 g_test_add_func("/cutils/qemu_strtoull_full/trailing",
1579 test_qemu_strtoull_full_trailing);
1580 g_test_add_func("/cutils/qemu_strtoull_full/max",
1581 test_qemu_strtoull_full_max);
1583 g_test_add_func("/cutils/strtosz/simple",
1584 test_qemu_strtosz_simple);
1585 g_test_add_func("/cutils/strtosz/units",
1586 test_qemu_strtosz_units);
1587 g_test_add_func("/cutils/strtosz/float",
1588 test_qemu_strtosz_float);
1589 g_test_add_func("/cutils/strtosz/erange",
1590 test_qemu_strtosz_erange);
1591 g_test_add_func("/cutils/strtosz/suffix-unit",
1592 test_qemu_strtosz_suffix_unit);
1594 return g_test_run();