aboutsummaryrefslogtreecommitdiff
path: root/tests/test-qemu-opts.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2017-02-21 21:14:08 +0100
committerMarkus Armbruster <armbru@redhat.com>2017-02-23 20:35:36 +0100
commit75cdcd1553e74b5edc58aed23e3b2da8dabb1876 (patch)
tree65345fb1cb4518f0d9ca6abef0db9486e334b985 /tests/test-qemu-opts.c
parentf46bfdbfc8f95cf65d7818ef68a801e063c40332 (diff)
downloadqemu-75cdcd1553e74b5edc58aed23e3b2da8dabb1876.zip
qemu-75cdcd1553e74b5edc58aed23e3b2da8dabb1876.tar.gz
qemu-75cdcd1553e74b5edc58aed23e3b2da8dabb1876.tar.bz2
option: Fix checking of sizes for overflow and trailing crap
parse_option_size()'s checking for overflow and trailing crap is wrong. Has always been that way. qemu_strtosz() gets it right, so use that. This adds support for size suffixes 'P', 'E', and ignores case for all suffixes, not just 'k'. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <1487708048-2131-25-git-send-email-armbru@redhat.com>
Diffstat (limited to 'tests/test-qemu-opts.c')
-rw-r--r--tests/test-qemu-opts.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/tests/test-qemu-opts.c b/tests/test-qemu-opts.c
index 8b92f7b..c46ef31 100644
--- a/tests/test-qemu-opts.c
+++ b/tests/test-qemu-opts.c
@@ -702,10 +702,9 @@ static void test_opts_parse_size(void)
g_assert(!opts);
opts = qemu_opts_parse(&opts_list_02,
"size1=18446744073709550592", /* fffffffffffffc00 */
- false, &error_abort);
- /* BUG: should reject */
- g_assert_cmpuint(opts_count(opts), ==, 1);
- g_assert_cmpuint(qemu_opt_get_size(opts, "size1", 1), ==, 0);
+ false, &err);
+ error_free_or_abort(&err);
+ g_assert(!opts);
/* Suffixes */
opts = qemu_opts_parse(&opts_list_02, "size1=8b,size2=1.5k,size3=2M",
@@ -723,19 +722,17 @@ static void test_opts_parse_size(void)
/* Beyond limit with suffix */
opts = qemu_opts_parse(&opts_list_02, "size1=16777216T",
- false, &error_abort);
- /* BUG: should reject */
- g_assert_cmpuint(opts_count(opts), ==, 1);
- g_assert_cmpuint(qemu_opt_get_size(opts, "size1", 1), ==, 0);
+ false, &err);
+ error_free_or_abort(&err);
+ g_assert(!opts);
/* Trailing crap */
opts = qemu_opts_parse(&opts_list_02, "size1=16E", false, &err);
error_free_or_abort(&err);
g_assert(!opts);
- opts = qemu_opts_parse(&opts_list_02, "size1=16Gi", false, &error_abort);
- /* BUG: should reject */
- g_assert_cmpuint(opts_count(opts), ==, 1);
- g_assert_cmpuint(qemu_opt_get_size(opts, "size1", 1), ==, 16 * G_BYTE);
+ opts = qemu_opts_parse(&opts_list_02, "size1=16Gi", false, &err);
+ error_free_or_abort(&err);
+ g_assert(!opts);
qemu_opts_reset(&opts_list_02);
}