diff options
author | Karel Zak | 2011-01-01 22:45:29 +0100 |
---|---|---|
committer | Karel Zak | 2011-01-03 12:28:48 +0100 |
commit | 013bff51a67fe5907532639d35f9d9f1df2c7570 (patch) | |
tree | f270146bbbcf19679c993ce1d0be62f03d4cd4e8 /lib/strutils.c | |
parent | findmnt: add MAJ:MIN (diff) | |
download | kernel-qcow2-util-linux-013bff51a67fe5907532639d35f9d9f1df2c7570.tar.gz kernel-qcow2-util-linux-013bff51a67fe5907532639d35f9d9f1df2c7570.tar.xz kernel-qcow2-util-linux-013bff51a67fe5907532639d35f9d9f1df2c7570.zip |
tests: fix strtosize() test
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib/strutils.c')
-rw-r--r-- | lib/strutils.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/strutils.c b/lib/strutils.c index e8e868653..9a59e67b6 100644 --- a/lib/strutils.c +++ b/lib/strutils.c @@ -273,3 +273,27 @@ char *size_to_human_string(uint64_t bytes) return strdup(buf); } + + +#ifdef TEST_PROGRAM + +#include <stdio.h> +#include <stdlib.h> +#include <err.h> + +int main(int argc, char *argv[]) +{ + uintmax_t size = 0; + + if (argc < 2) { + fprintf(stderr, "usage: %s <number>[suffix]\n", argv[0]); + exit(EXIT_FAILURE); + } + + if (strtosize(argv[1], &size)) + errx(EXIT_FAILURE, "invalid size '%s' value", argv[1]); + + printf("%25s : %20ju\n", argv[1], size); + return EXIT_FAILURE; +} +#endif /* TEST_PROGRAM */ |