aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/check-qjson.c6
-rw-r--r--tests/check-qnull.c27
-rw-r--r--tests/qapi-schema/qapi-schema-test.json3
-rw-r--r--tests/qapi-schema/qapi-schema-test.out1
-rwxr-xr-xtests/qemu-iotests/0852
-rw-r--r--tests/qemu-iotests/1392
-rw-r--r--tests/test-qobject-input-visitor.c24
-rw-r--r--tests/test-qobject-output-visitor.c13
8 files changed, 50 insertions, 28 deletions
diff --git a/tests/check-qjson.c b/tests/check-qjson.c
index 53f2275..a3a97b0 100644
--- a/tests/check-qjson.c
+++ b/tests/check-qjson.c
@@ -1012,7 +1012,7 @@ static void keyword_literal(void)
{
QObject *obj;
QBool *qbool;
- QObject *null;
+ QNull *null;
QString *str;
obj = qobject_from_json("true", &error_abort);
@@ -1053,10 +1053,10 @@ static void keyword_literal(void)
g_assert(qobject_type(obj) == QTYPE_QNULL);
null = qnull();
- g_assert(null == obj);
+ g_assert(QOBJECT(null) == obj);
qobject_decref(obj);
- qobject_decref(null);
+ QDECREF(null);
}
typedef struct LiteralQDictEntry LiteralQDictEntry;
diff --git a/tests/check-qnull.c b/tests/check-qnull.c
index 8dd1c96..5c6eb0a 100644
--- a/tests/check-qnull.c
+++ b/tests/check-qnull.c
@@ -24,20 +24,21 @@ static void qnull_ref_test(void)
{
QObject *obj;
- g_assert(qnull_.refcnt == 1);
- obj = qnull();
+ g_assert(qnull_.base.refcnt == 1);
+ obj = QOBJECT(qnull());
g_assert(obj);
- g_assert(obj == &qnull_);
- g_assert(qnull_.refcnt == 2);
+ g_assert(obj == QOBJECT(&qnull_));
+ g_assert(qnull_.base.refcnt == 2);
g_assert(qobject_type(obj) == QTYPE_QNULL);
qobject_decref(obj);
- g_assert(qnull_.refcnt == 1);
+ g_assert(qnull_.base.refcnt == 1);
}
static void qnull_visit_test(void)
{
QObject *obj;
Visitor *v;
+ QNull *null;
/*
* Most tests of interactions between QObject and visitors are in
@@ -45,21 +46,25 @@ static void qnull_visit_test(void)
* depend on layering violations to check qnull_ refcnt.
*/
- g_assert(qnull_.refcnt == 1);
- obj = qnull();
+ g_assert(qnull_.base.refcnt == 1);
+ obj = QOBJECT(qnull());
v = qobject_input_visitor_new(obj);
qobject_decref(obj);
- visit_type_null(v, NULL, &error_abort);
+ visit_type_null(v, NULL, &null, &error_abort);
+ g_assert(obj == QOBJECT(&qnull_));
+ QDECREF(null);
visit_free(v);
+ null = NULL;
v = qobject_output_visitor_new(&obj);
- visit_type_null(v, NULL, &error_abort);
+ visit_type_null(v, NULL, &null, &error_abort);
visit_complete(v, &obj);
- g_assert(obj == &qnull_);
+ g_assert(obj == QOBJECT(&qnull_));
+ QDECREF(null);
qobject_decref(obj);
visit_free(v);
- g_assert(qnull_.refcnt == 1);
+ g_assert(qnull_.base.refcnt == 1);
}
int main(int argc, char **argv)
diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json
index 91ffb26..c72dbd8 100644
--- a/tests/qapi-schema/qapi-schema-test.json
+++ b/tests/qapi-schema/qapi-schema-test.json
@@ -93,7 +93,8 @@
{ 'struct': 'WrapAlternate',
'data': { 'alt': 'UserDefAlternate' } }
{ 'alternate': 'UserDefAlternate',
- 'data': { 'udfu': 'UserDefFlatUnion', 'e': 'EnumOne', 'i': 'int' } }
+ 'data': { 'udfu': 'UserDefFlatUnion', 'e': 'EnumOne', 'i': 'int',
+ 'n': 'null' } }
{ 'struct': 'UserDefC',
'data': { 'string1': 'str', 'string2': 'str' } }
diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out
index b88b8aa..3b1e908 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -64,6 +64,7 @@ alternate UserDefAlternate
case udfu: UserDefFlatUnion
case e: EnumOne
case i: int
+ case n: null
object UserDefB
member intb: int optional=False
member a-b: bool optional=True
diff --git a/tests/qemu-iotests/085 b/tests/qemu-iotests/085
index 71efe50..5c7668c 100755
--- a/tests/qemu-iotests/085
+++ b/tests/qemu-iotests/085
@@ -106,7 +106,7 @@ function add_snapshot_image()
snapshot_file="${TEST_DIR}/${1}-${snapshot_virt0}"
_make_test_img -u -b "${base_image}" "$size"
mv "${TEST_IMG}" "${snapshot_file}"
- do_blockdev_add "$1" "'backing': '', " "${snapshot_file}"
+ do_blockdev_add "$1" "'backing': null, " "${snapshot_file}"
}
# ${1}: unique identifier for the snapshot filename
diff --git a/tests/qemu-iotests/139 b/tests/qemu-iotests/139
index 9ff51d9..50cf40f 100644
--- a/tests/qemu-iotests/139
+++ b/tests/qemu-iotests/139
@@ -69,7 +69,7 @@ class TestBlockdevDel(iotests.QMPTestCase):
'-b', base_img, new_img, '1M')
opts = {'driver': iotests.imgfmt,
'node-name': node,
- 'backing': '',
+ 'backing': None,
'file': {'driver': 'file',
'filename': new_img}}
result = self.vm.qmp('blockdev-add', conv_keys = False, **opts)
diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-visitor.c
index 34bab8a..bcf0261 100644
--- a/tests/test-qobject-input-visitor.c
+++ b/tests/test-qobject-input-visitor.c
@@ -510,6 +510,7 @@ static void test_visitor_in_null(TestInputVisitorData *data,
{
Visitor *v;
Error *err = NULL;
+ QNull *null;
char *tmp;
/*
@@ -524,12 +525,15 @@ static void test_visitor_in_null(TestInputVisitorData *data,
v = visitor_input_test_init_full(data, false,
"{ 'a': null, 'b': '' }");
visit_start_struct(v, NULL, NULL, 0, &error_abort);
- visit_type_null(v, "a", &error_abort);
- visit_type_null(v, "b", &err);
+ visit_type_null(v, "a", &null, &error_abort);
+ g_assert(qobject_type(QOBJECT(null)) == QTYPE_QNULL);
+ QDECREF(null);
+ visit_type_null(v, "b", &null, &err);
error_free_or_abort(&err);
+ g_assert(!null);
visit_type_str(v, "c", &tmp, &err);
- g_assert(!tmp);
error_free_or_abort(&err);
+ g_assert(!tmp);
visit_check_struct(v, &error_abort);
visit_end_struct(v, NULL);
}
@@ -563,7 +567,6 @@ static void test_visitor_in_alternate(TestInputVisitorData *data,
const void *unused)
{
Visitor *v;
- Error *err = NULL;
UserDefAlternate *tmp;
WrapAlternate *wrap;
@@ -579,6 +582,11 @@ static void test_visitor_in_alternate(TestInputVisitorData *data,
g_assert_cmpint(tmp->u.e, ==, ENUM_ONE_VALUE1);
qapi_free_UserDefAlternate(tmp);
+ v = visitor_input_test_init(data, "null");
+ visit_type_UserDefAlternate(v, NULL, &tmp, &error_abort);
+ g_assert_cmpint(tmp->type, ==, QTYPE_QNULL);
+ qapi_free_UserDefAlternate(tmp);
+
v = visitor_input_test_init(data, "{'integer':1, 'string':'str', "
"'enum1':'value1', 'boolean':true}");
visit_type_UserDefAlternate(v, NULL, &tmp, &error_abort);
@@ -590,11 +598,6 @@ static void test_visitor_in_alternate(TestInputVisitorData *data,
g_assert_cmpint(tmp->u.udfu.u.value1.has_a_b, ==, false);
qapi_free_UserDefAlternate(tmp);
- v = visitor_input_test_init(data, "false");
- visit_type_UserDefAlternate(v, NULL, &tmp, &err);
- error_free_or_abort(&err);
- qapi_free_UserDefAlternate(tmp);
-
v = visitor_input_test_init(data, "{ 'alt': 42 }");
visit_type_WrapAlternate(v, NULL, &wrap, &error_abort);
g_assert_cmpint(wrap->alt->type, ==, QTYPE_QNUM);
@@ -1087,6 +1090,7 @@ static void test_visitor_in_fail_struct_missing(TestInputVisitorData *data,
Error *err = NULL;
Visitor *v;
QObject *any;
+ QNull *null;
GenericAlternate *alt;
bool present;
int en;
@@ -1120,7 +1124,7 @@ static void test_visitor_in_fail_struct_missing(TestInputVisitorData *data,
error_free_or_abort(&err);
visit_type_any(v, "any", &any, &err);
error_free_or_abort(&err);
- visit_type_null(v, "null", &err);
+ visit_type_null(v, "null", &null, &err);
error_free_or_abort(&err);
visit_start_list(v, "sub", NULL, 0, &error_abort);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-output-visitor.c
index 749c540..7eb1620 100644
--- a/tests/test-qobject-output-visitor.c
+++ b/tests/test-qobject-output-visitor.c
@@ -424,6 +424,16 @@ static void test_visitor_out_alternate(TestOutputVisitorData *data,
visitor_reset(data);
tmp = g_new0(UserDefAlternate, 1);
+ tmp->type = QTYPE_QNULL;
+ tmp->u.n = qnull();
+
+ visit_type_UserDefAlternate(data->ov, NULL, &tmp, &error_abort);
+ g_assert_cmpint(qobject_type(visitor_get(data)), ==, QTYPE_QNULL);
+
+ qapi_free_UserDefAlternate(tmp);
+
+ visitor_reset(data);
+ tmp = g_new0(UserDefAlternate, 1);
tmp->type = QTYPE_QDICT;
tmp->u.udfu.integer = 1;
tmp->u.udfu.string = g_strdup("str");
@@ -445,11 +455,12 @@ static void test_visitor_out_alternate(TestOutputVisitorData *data,
static void test_visitor_out_null(TestOutputVisitorData *data,
const void *unused)
{
+ QNull *null = NULL;
QDict *qdict;
QObject *nil;
visit_start_struct(data->ov, NULL, NULL, 0, &error_abort);
- visit_type_null(data->ov, "a", &error_abort);
+ visit_type_null(data->ov, "a", &null, &error_abort);
visit_check_struct(data->ov, &error_abort);
visit_end_struct(data->ov, NULL);
qdict = qobject_to_qdict(visitor_get(data));