Commit Graph

21 Commits

Author SHA1 Message Date
Erik Skultety
5165ff0971 src: More cleanup of some system headers already contained in internal.h
All of the ones being removed are pulled in by internal.h. The only
exception is sanlock which expects the application to include <stdint.h>
before sanlock's headers, because sanlock prototypes use fixed width
int, but they don't include stdint.h themselves, so we have to leave
that one in place.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
2018-09-20 10:16:39 +02:00
Erik Skultety
9403b63102 internal: Move <stdio.h> include to internal.h
It doesn't really make sense for us to have stdlib.h and string.h but
not stdio.h in the internal.h header.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
2018-09-20 10:16:38 +02:00
Ján Tomko
7d6c58ed12 Test parsing of large numbers in JSON
We expect to get numbers as big as ULLONG_MAX from QEMU,
add a test for them.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-09-04 10:19:23 +02:00
Ján Tomko
c61e729382 virjsontest: use the test name in AddRemove test
Instead of printing the whole JSON in error messages,
print just the test name.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-09-04 10:19:23 +02:00
Ján Tomko
b565e40705 virjsontest: use name instead of doc for deflatten test
This test gets its JSON docs from files.

Now that we have a 'name' field in testInfo, use it instead
of abusing the 'doc' field.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-09-04 10:19:23 +02:00
Ján Tomko
020382b298 virjsontest: store name in testInfo
Give the testing function access to the test name instead of only
passing it to virTestRun.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-09-04 10:19:23 +02:00
Ján Tomko
6f99de3148 Revert "m4: Introduce STABLE_ORDERING_JANSSON"
This reverts commit 4dd6054000.

Jansson cannot parse QEMU's quirky JSON.
Revert back to yajl.

https://bugzilla.redhat.com/show_bug.cgi?id=1614569

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-08-13 15:50:00 +02:00
Ján Tomko
4dd6054000 m4: Introduce STABLE_ORDERING_JANSSON
Add a second check for Jansson >= 2.8, which includes
fixes to preserve ordering of object keys.

Use this constant to guard tests that depend on stable ordering.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-07-18 17:54:18 +02:00
Ján Tomko
3487973ee0 virjsontest: Use a more stable floating point number for testing
We store all JSON numbers as strings. To allow using json libraries
that store them in numeric types, use a more predictable and normalized
value.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-04-04 15:08:32 +02:00
Peter Krempa
d4dd836edc tests: json: Validate that attribute values are properly stolen
Make sure that the 'a' and 'A' modifiers for virJSONValueObjectAddVArgs
behave correctly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 13:34:33 +02:00
Andrea Bolognani
3e7db8d3e8 Remove backslash alignment attempts
Right-aligning backslashes when defining macros or using complex
commands in Makefiles looks cute, but as soon as any changes is
required to the code you end up with either distractingly broken
alignment or unnecessarily big diffs where most of the changes
are just pushing all backslashes a few characters to one side.

Generated using

  $ git grep -El '[[:blank:]][[:blank:]]\\$' | \
    grep -E '*\.([chx]|am|mk)$$' | \
    while read f; do \
      sed -Ei 's/[[:blank:]]*[[:blank:]]\\$/ \\/g' "$f"; \
    done

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2017-11-03 13:24:12 +01:00
Peter Krempa
99eac2668c tests: virjson: Test nesting of JSON string into a JSON (string) property
Test that we are able to create a JSON object and nest it into a string
property of a JSON object and then correctly extract and parse it back.
2017-07-19 17:59:09 +02:00
Peter Krempa
6e51642bd2 tests: virjson: Test parsing and formatting of strings with escaped chars
Make sure that JSON strings can contain characters which need to be
escaped (double quotes, backslashes, tabs, etc.).
2017-07-19 17:59:09 +02:00
Peter Krempa
0c02071b56 tests: virjson: Test formatting along with parsing of JSON objects
Format the parsed string back and compare it to the original (or
modified) string for back and forth comparison.
2017-07-19 15:24:10 +02:00
Peter Krempa
85f7620212 tests: virjson: Remove spaces from 'very-hard' parsing example
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.
2017-07-19 15:24:10 +02:00
Peter Krempa
0a2866b42a tests: virjson: Modify logic in testJSONFromString
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.
2017-07-19 15:24:10 +02:00
Peter Krempa
a1ac4c880b tests: virjson: Reuse VIR_TEST_VERBOSE in testJSONCopy
Use VIR_TEST_VERBOSE instead of calling virTestGetVerbose and
conditionally fprintf. Additionally remove redundant setting of 'ret' to
-1.
2017-07-11 14:40:05 +02:00
Peter Krempa
ffdf532328 tests: Validate that JSON deflattening fixed nested json pseudo-protocol strings
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.
2017-07-11 14:24:17 +02:00
Peter Krempa
d40f4b3e67 util: json: Properly implement JSON deflattening
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.
2017-07-11 14:13:35 +02:00
Peter Krempa
7f1209ad1e tests: json: Add test for the deflattening function
Add a few test cases to verify that the old behaviour does not break and
that new one behaves sanely.
2017-07-11 14:12:55 +02:00
Peter Krempa
9f0b7e99c5 tests: Rename jsontest to virjsontest 2017-07-11 14:02:28 +02:00