- 19 7月, 2017 2 次提交
-
-
由 Peter Krempa 提交于
The example is rather long and upcomming patch will check whether the string can be formatted back. As the formatted string lacks spaces and adding the 'expect' string with spaces would be rather long, just drop spaces from this test case. There are other test cases which do contain spaces.
-
由 Peter Krempa 提交于
To allow better testing in case where the string was parsed, modify the logic so that the regular code path is not included in a conditional block.
-
- 11 7月, 2017 5 次提交
-
-
由 Peter Krempa 提交于
Use VIR_TEST_VERBOSE instead of calling virTestGetVerbose and conditionally fprintf. Additionally remove redundant setting of 'ret' to -1.
-
由 Peter Krempa 提交于
Sheepdog and possibly others use nested objects for network server and thus could be specified in a way that libvirt would not parse. Validates that https://bugzilla.redhat.com/show_bug.cgi?id=1464821 is fixed properly.
-
由 Peter Krempa 提交于
As it turns out sometimes users pass in an arbitrarily nested structure e.g. for the qemu backing chains JSON pseudo protocol. This new implementation deflattens now a single object fully even with nested keys. Additionally it's not necessary now to stick with the "file." prefix for the properties.
-
由 Peter Krempa 提交于
Add a few test cases to verify that the old behaviour does not break and that new one behaves sanely.
-
由 Peter Krempa 提交于
-
- 04 4月, 2017 1 次提交
-
-
由 Andrea Bolognani 提交于
We use the "vir" prefix pretty consistently in our APIs, both external and internal, which made these macros stood out.
-
- 08 6月, 2016 2 次提交
-
-
由 Tomáš Ryšavý 提交于
This function doesn't follow our convention of naming functions.
-
由 Tomáš Ryšavý 提交于
This function doesn't follow our convention of naming functions.
-
- 25 6月, 2015 5 次提交
-
-
由 Eric Blake 提交于
We already enable the parser option to detect invalid UTF-8, but didn't test it. Also, JSON states that behavior of an object with a duplicated key is undefined; we chose to reject it, but were not testing it. With the enhanced tests in place, we can simplify yajl2 initialization by relying on parser defaults being sane. * src/util/virjson.c (virJSONValueFromString): Simplify. * tests/jsontest.c (mymain): Test more bad usage. Signed-off-by: NEric Blake <eblake@redhat.com>
-
由 Eric Blake 提交于
Since older yajl ignores trailing garbage, a client can cause problems by intentionally ending the wrapper array early. Since we already track nesting, it's not too much harder to reject invalid nesting pops. * src/util/virjson. (_virJSONParser): Add field. (virJSONValueFromString): Set witness. (virJSONParserHandleEndArray): Use it to catch abuse. * tests/jsontest.c (mymain): Test it. Signed-off-by: NEric Blake <eblake@redhat.com>
-
由 Eric Blake 提交于
Yajl 2 has a nice feature that it can be configured whether to allow multiple JSON objects parsed from a single stream, defaulting to off. And yajl 1.0.12 at least provided a way to tell if all input bytes were parsed, or if trailing bytes remained after a valid JSON object was parsed. But we target RHEL 6 yajl 1.0.7, which has neither of these. So fake it by always parsing '[...]' instead, so that trailing garbage either trips up the array parse, or is easily detected when unwrapping the result. * src/util/virjson.c (virJSONValueFromString): With older json, wrap text to avoid trailing garbage. * tests/jsontest.c (mymain): Add tests for this. Signed-off-by: NEric Blake <eblake@redhat.com>
-
由 Eric Blake 提交于
We have been allowing javascript style comments in JSON ever since commit 9428f2ce (v0.7.5), but qemu doesn't send them, and they are not strict JSON. Reject them for now; if we can later prove that it is worthwhile, we can reinstate it at that point (or even make it conditional, by adding a bool parameter to the libvirt entry point). * src/util/virjson.c (virJSONValueFromString): Don't enable comment parsing. * tests/jsontest.c (mymain): Test it. Signed-off-by: NEric Blake <eblake@redhat.com>
-
由 Eric Blake 提交于
Commit ceb496e5 fails on RHEL 6, with yajl 1.0.7, because that version of yajl returns yajl_status_insufficient_data when the parser is waiting for the rest of a token (this enum value was dropped in yajl 2, so we have to wrap it). It also exposes a problem where older yajl silently ignores trailing garbage after a successful parse, so this patch works around that by changing the testsuite. Another more invasive patch can add tighter semantics to json parsing, but this is sufficient for a minimal clean backport. While touching this, fix up our error message cleanup. Yajl documents that error messages produced by yajl_get_error() MUST be cleaned with yajl_free_error(); this is certainly true if we were to pass non-NULL allocator callbacks during yajl_alloc(), but probably harmless in our usage of passing NULL. But better safe than sorry. * src/util/virjson.c (virJSONValueFromString): Allow different error code. Use canonical cleanup of error message. (VIR_YAJL_STATUS_OK): New helper macro. * tests/jsontest.c (mymain): Wrap text to avoid difference in trailing garbage handling Signed-off-by: NEric Blake <eblake@redhat.com>
-
- 23 6月, 2015 2 次提交
-
-
由 Eric Blake 提交于
While working in qemu_monitor_json, I repeatedly found myself getting a value then checking if it was an object. Add some wrappers to make this task easier. * src/util/virjson.c (virJSONValueObjectGetByType) (virJSONValueObjectGetObject, virJSONValueObjectGetArray): New functions. (virJSONValueObjectGetString, virJSONValueObjectGetNumberInt) (virJSONValueObjectGetNumberUint) (virJSONValueObjectGetNumberLong) (virJSONValueObjectGetNumberUlong) (virJSONValueObjectGetNumberDouble) (virJSONValueObjectGetBoolean): Simplify. (virJSONValueIsNull): Change return type. * src/util/virjson.h: Reflect changes. * src/libvirt_private.syms (virjson.h): Export them. * tests/jsontest.c (testJSONLookup): New test. Signed-off-by: NEric Blake <eblake@redhat.com>
-
由 Eric Blake 提交于
I was adding a JSON test, and was shocked to find out our parser treated the input string of "1" as invalid JSON. It turns out that YAJL specifically documents that it buffers input, and that if the last input read could be a prefix to a longer token, then you have to explicitly tell the parser that the buffer has ended before that token will be processed. It doesn't help that yajl 2 renamed the function from what it was in yajl 1. * src/util/virjson.c (virJSONValueFromString): Complete parse, in case buffer ends in possible token prefix. * tests/jsontest.c (mymain): Expose the problem. Signed-off-by: NEric Blake <eblake@redhat.com>
-
- 11 6月, 2015 1 次提交
-
-
由 Martin Kletzander 提交于
Faster version of virJSONValueFromString(virJSONValueToString()). Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
-
- 14 5月, 2015 1 次提交
-
-
由 Martin Kletzander 提交于
Again, a clean-up for which we don't have proper syntax-check. Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
-
- 24 4月, 2015 1 次提交
-
-
由 Cole Robinson 提交于
To remove a bunch of TestGetDebug()/TestGetVerbose() checks
-
- 25 3月, 2014 1 次提交
-
-
由 Ján Tomko 提交于
-
- 20 11月, 2013 2 次提交
- 08 10月, 2013 1 次提交
-
-
由 Daniel P. Berrange 提交于
The test case average timing code has not been used by any test case ever. Delete it to remove complexity. Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
-
- 02 8月, 2013 1 次提交
-
-
由 John Ferlan 提交于
Coverity reported the existing missing check of the return value and subsequent use from a call to virJSONValueFromString() in testJSONAddRemove().
-
- 14 5月, 2013 1 次提交
-
-
由 Eric Blake 提交于
In an upcoming patch, I need the way to safely transfer a nested virJSON object out of its parent container for independent use, even after the parent is freed. * src/util/virjson.h (virJSONValueObjectRemoveKey): New function. (_virJSONObject, _virJSONArray): Use correct type. * src/util/virjson.c (virJSONValueObjectRemoveKey): Implement it. * src/libvirt_private.syms (virjson.h): Export it. * tests/jsontest.c (mymain): Test it. Signed-off-by: NEric Blake <eblake@redhat.com>
-
- 21 12月, 2012 1 次提交
-
-
由 Daniel P. Berrange 提交于
-
- 01 7月, 2011 1 次提交
-
-
由 Daniel P. Berrange 提交于
While investigating some memory leaks it was unclear whether the JSON code correctly free'd all memory during parsing. Add a test case which can be run under valgrind to clearly demonstrate that the parser is leak free. * tests/Makefile.am: Add 'jsontest' * tests/jsontest.c: A few simple JSON parsing tests
-