[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 16/23] check-qjson: add test for large JSON objects
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 16/23] check-qjson: add test for large JSON objects |
Date: |
Tue, 21 Aug 2012 12:05:50 -0500 |
Signed-off-by: Michael Roth <address@hidden>
Signed-off-by: Anthony Liguori <address@hidden>
(cherry picked from commit 7109edfeb69c1d3c2164175837784dfcd210fed0)
Signed-off-by: Michael Roth <address@hidden>
---
tests/check-qjson.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/tests/check-qjson.c b/tests/check-qjson.c
index 526e25e..3b896f5 100644
--- a/tests/check-qjson.c
+++ b/tests/check-qjson.c
@@ -466,6 +466,58 @@ static void simple_dict(void)
}
}
+/*
+ * this generates json of the form:
+ * a(0,m) = [0, 1, ..., m-1]
+ * a(n,m) = {
+ * 'key0': a(0,m),
+ * 'key1': a(1,m),
+ * ...
+ * 'key(n-1)': a(n-1,m)
+ * }
+ */
+static void gen_test_json(GString *gstr, int nest_level_max,
+ int elem_count)
+{
+ int i;
+
+ g_assert(gstr);
+ if (nest_level_max == 0) {
+ g_string_append(gstr, "[");
+ for (i = 0; i < elem_count; i++) {
+ g_string_append_printf(gstr, "%d", i);
+ if (i < elem_count - 1) {
+ g_string_append_printf(gstr, ", ");
+ }
+ }
+ g_string_append(gstr, "]");
+ return;
+ }
+
+ g_string_append(gstr, "{");
+ for (i = 0; i < nest_level_max; i++) {
+ g_string_append_printf(gstr, "'key%d': ", i);
+ gen_test_json(gstr, i, elem_count);
+ if (i < nest_level_max - 1) {
+ g_string_append(gstr, ",");
+ }
+ }
+ g_string_append(gstr, "}");
+}
+
+static void large_dict(void)
+{
+ GString *gstr = g_string_new("");
+ QObject *obj;
+
+ gen_test_json(gstr, 10, 100);
+ obj = qobject_from_json(gstr->str);
+ g_assert(obj != NULL);
+
+ qobject_decref(obj);
+ g_string_free(gstr, true);
+}
+
static void simple_list(void)
{
int i;
@@ -706,6 +758,7 @@ int main(int argc, char **argv)
g_test_add_func("/literals/keyword", keyword_literal);
g_test_add_func("/dicts/simple_dict", simple_dict);
+ g_test_add_func("/dicts/large_dict", large_dict);
g_test_add_func("/lists/simple_list", simple_list);
g_test_add_func("/whitespace/simple_whitespace", simple_whitespace);
--
1.7.9.5
- [Qemu-devel] [PATCH 01/23] qtest: fix infinite loop when QEMU aborts abruptly, (continued)
- [Qemu-devel] [PATCH 01/23] qtest: fix infinite loop when QEMU aborts abruptly, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 07/23] virtio-blk: fix use-after-free while handling scsi commands, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 08/23] ehci: fix reset, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 06/23] qdev: fix use-after-free in the error path of qdev_init_nofail, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 13/23] usb-ehci: Fix an assert whenever isoc transfers are used, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 11/23] usb: restore USBDevice->attached on vmload, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 10/23] uhci: fix uhci_async_cancel_all, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 14/23] qlist: add qlist_size(), Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 09/23] ehci: don't flush cache on doorbell rings., Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 12/23] usb-redir: Correctly handle the usb_redir_babble usbredir status, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 16/23] check-qjson: add test for large JSON objects,
Michael Roth <=
- [Qemu-devel] [PATCH 17/23] slirp: Enforce host-side user of smb share, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 15/23] json-parser: don't replicate tokens at each level of recursion, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 19/23] slirp: Improve error reporting of inaccessible smb directories, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 23/23] update VERSION for 1.1.2, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 22/23] apic: Defer interrupt updates to VCPU thread, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 20/23] apic: Resolve potential endless loop around apic_update_irq, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 18/23] slirp: Ensure smbd and shared directory exist when enable smb, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 21/23] apic: Reevaluate pending interrupts on LVT_LINT0 changes, Michael Roth, 2012/08/21