2012-02-09 18:21:03 +08:00
|
|
|
/*
|
|
|
|
* String Output Visitor unit-tests.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Red Hat Inc.
|
|
|
|
*
|
|
|
|
* Authors:
|
2016-09-30 22:45:27 +08:00
|
|
|
* Paolo Bonzini <pbonzini@redhat.com> (based on test-qobject-output-visitor)
|
2012-02-09 18:21:03 +08:00
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*/
|
|
|
|
|
2016-02-09 02:08:51 +08:00
|
|
|
#include "qemu/osdep.h"
|
2012-02-09 18:21:03 +08:00
|
|
|
|
2012-12-06 18:22:34 +08:00
|
|
|
#include "qemu-common.h"
|
include/qemu/osdep.h: Don't include qapi/error.h
Commit 57cb38b included qapi/error.h into qemu/osdep.h to get the
Error typedef. Since then, we've moved to include qemu/osdep.h
everywhere. Its file comment explains: "To avoid getting into
possible circular include dependencies, this file should not include
any other QEMU headers, with the exceptions of config-host.h,
compiler.h, os-posix.h and os-win32.h, all of which are doing a
similar job to this file and are under similar constraints."
qapi/error.h doesn't do a similar job, and it doesn't adhere to
similar constraints: it includes qapi-types.h. That's in excess of
100KiB of crap most .c files don't actually need.
Add the typedef to qemu/typedefs.h, and include that instead of
qapi/error.h. Include qapi/error.h in .c files that need it and don't
get it now. Include qapi-types.h in qom/object.h for uint16List.
Update scripts/clean-includes accordingly. Update it further to match
reality: replace config.h by config-target.h, add sysemu/os-posix.h,
sysemu/os-win32.h. Update the list of includes in the qemu/osdep.h
comment quoted above similarly.
This reduces the number of objects depending on qapi/error.h from "all
of them" to less than a third. Unfortunately, the number depending on
qapi-types.h shrinks only a little. More work is needed for that one.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
[Fix compilation without the spice devel packages. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-03-14 16:01:28 +08:00
|
|
|
#include "qapi/error.h"
|
2012-02-09 18:21:03 +08:00
|
|
|
#include "qapi/string-output-visitor.h"
|
|
|
|
#include "test-qapi-visit.h"
|
|
|
|
|
|
|
|
typedef struct TestOutputVisitorData {
|
|
|
|
Visitor *ov;
|
2016-06-10 00:48:42 +08:00
|
|
|
char *str;
|
2014-06-20 13:55:43 +08:00
|
|
|
bool human;
|
2012-02-09 18:21:03 +08:00
|
|
|
} TestOutputVisitorData;
|
|
|
|
|
2016-06-10 00:48:41 +08:00
|
|
|
static void visitor_output_setup_internal(TestOutputVisitorData *data,
|
|
|
|
bool human)
|
|
|
|
{
|
|
|
|
data->human = human;
|
qapi: Add new visit_complete() function
Making each output visitor provide its own output collection
function was the only remaining reason for exposing visitor
sub-types to the rest of the code base. Add a polymorphic
visit_complete() function which is a no-op for input visitors,
and which populates an opaque pointer for output visitors. For
maximum type-safety, also add a parameter to the output visitor
constructors with a type-correct version of the output pointer,
and assert that the two uses match.
This approach was considered superior to either passing the
output parameter only during construction (action at a distance
during visit_free() feels awkward) or only during visit_complete()
(defeating type safety makes it easier to use incorrectly).
Most callers were function-local, and therefore a mechanical
conversion; the testsuite was a bit trickier, but the previous
cleanup patch minimized the churn here.
The visit_complete() function may be called at most once; doing
so lets us use transfer semantics rather than duplication or
ref-count semantics to get the just-built output back to the
caller, even though it means our behavior is not idempotent.
Generated code is simplified as follows for events:
|@@ -26,7 +26,7 @@ void qapi_event_send_acpi_device_ost(ACP
| QDict *qmp;
| Error *err = NULL;
| QMPEventFuncEmit emit;
|- QmpOutputVisitor *qov;
|+ QObject *obj;
| Visitor *v;
| q_obj_ACPI_DEVICE_OST_arg param = {
| info
|@@ -39,8 +39,7 @@ void qapi_event_send_acpi_device_ost(ACP
|
| qmp = qmp_event_build_dict("ACPI_DEVICE_OST");
|
|- qov = qmp_output_visitor_new();
|- v = qmp_output_get_visitor(qov);
|+ v = qmp_output_visitor_new(&obj);
|
| visit_start_struct(v, "ACPI_DEVICE_OST", NULL, 0, &err);
| if (err) {
|@@ -55,7 +54,8 @@ void qapi_event_send_acpi_device_ost(ACP
| goto out;
| }
|
|- qdict_put_obj(qmp, "data", qmp_output_get_qobject(qov));
|+ visit_complete(v, &obj);
|+ qdict_put_obj(qmp, "data", obj);
| emit(QAPI_EVENT_ACPI_DEVICE_OST, qmp, &err);
and for commands:
| {
| Error *err = NULL;
|- QmpOutputVisitor *qov = qmp_output_visitor_new();
| Visitor *v;
|
|- v = qmp_output_get_visitor(qov);
|+ v = qmp_output_visitor_new(ret_out);
| visit_type_AddfdInfo(v, "unused", &ret_in, &err);
|- if (err) {
|- goto out;
|+ if (!err) {
|+ visit_complete(v, ret_out);
| }
|- *ret_out = qmp_output_get_qobject(qov);
|-
|-out:
| error_propagate(errp, err);
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1465490926-28625-13-git-send-email-eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-06-10 00:48:43 +08:00
|
|
|
data->ov = string_output_visitor_new(human, &data->str);
|
2016-06-10 00:48:41 +08:00
|
|
|
g_assert(data->ov);
|
|
|
|
}
|
|
|
|
|
2012-02-09 18:21:03 +08:00
|
|
|
static void visitor_output_setup(TestOutputVisitorData *data,
|
|
|
|
const void *unused)
|
|
|
|
{
|
2016-06-10 00:48:41 +08:00
|
|
|
return visitor_output_setup_internal(data, false);
|
2014-06-20 13:55:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void visitor_output_setup_human(TestOutputVisitorData *data,
|
|
|
|
const void *unused)
|
|
|
|
{
|
2016-06-10 00:48:41 +08:00
|
|
|
return visitor_output_setup_internal(data, true);
|
2012-02-09 18:21:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void visitor_output_teardown(TestOutputVisitorData *data,
|
|
|
|
const void *unused)
|
|
|
|
{
|
2016-06-10 00:48:39 +08:00
|
|
|
visit_free(data->ov);
|
2012-02-09 18:21:03 +08:00
|
|
|
data->ov = NULL;
|
2016-06-10 00:48:42 +08:00
|
|
|
g_free(data->str);
|
|
|
|
data->str = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *visitor_get(TestOutputVisitorData *data)
|
|
|
|
{
|
qapi: Add new visit_complete() function
Making each output visitor provide its own output collection
function was the only remaining reason for exposing visitor
sub-types to the rest of the code base. Add a polymorphic
visit_complete() function which is a no-op for input visitors,
and which populates an opaque pointer for output visitors. For
maximum type-safety, also add a parameter to the output visitor
constructors with a type-correct version of the output pointer,
and assert that the two uses match.
This approach was considered superior to either passing the
output parameter only during construction (action at a distance
during visit_free() feels awkward) or only during visit_complete()
(defeating type safety makes it easier to use incorrectly).
Most callers were function-local, and therefore a mechanical
conversion; the testsuite was a bit trickier, but the previous
cleanup patch minimized the churn here.
The visit_complete() function may be called at most once; doing
so lets us use transfer semantics rather than duplication or
ref-count semantics to get the just-built output back to the
caller, even though it means our behavior is not idempotent.
Generated code is simplified as follows for events:
|@@ -26,7 +26,7 @@ void qapi_event_send_acpi_device_ost(ACP
| QDict *qmp;
| Error *err = NULL;
| QMPEventFuncEmit emit;
|- QmpOutputVisitor *qov;
|+ QObject *obj;
| Visitor *v;
| q_obj_ACPI_DEVICE_OST_arg param = {
| info
|@@ -39,8 +39,7 @@ void qapi_event_send_acpi_device_ost(ACP
|
| qmp = qmp_event_build_dict("ACPI_DEVICE_OST");
|
|- qov = qmp_output_visitor_new();
|- v = qmp_output_get_visitor(qov);
|+ v = qmp_output_visitor_new(&obj);
|
| visit_start_struct(v, "ACPI_DEVICE_OST", NULL, 0, &err);
| if (err) {
|@@ -55,7 +54,8 @@ void qapi_event_send_acpi_device_ost(ACP
| goto out;
| }
|
|- qdict_put_obj(qmp, "data", qmp_output_get_qobject(qov));
|+ visit_complete(v, &obj);
|+ qdict_put_obj(qmp, "data", obj);
| emit(QAPI_EVENT_ACPI_DEVICE_OST, qmp, &err);
and for commands:
| {
| Error *err = NULL;
|- QmpOutputVisitor *qov = qmp_output_visitor_new();
| Visitor *v;
|
|- v = qmp_output_get_visitor(qov);
|+ v = qmp_output_visitor_new(ret_out);
| visit_type_AddfdInfo(v, "unused", &ret_in, &err);
|- if (err) {
|- goto out;
|+ if (!err) {
|+ visit_complete(v, ret_out);
| }
|- *ret_out = qmp_output_get_qobject(qov);
|-
|-out:
| error_propagate(errp, err);
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1465490926-28625-13-git-send-email-eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-06-10 00:48:43 +08:00
|
|
|
visit_complete(data->ov, &data->str);
|
2016-06-10 00:48:42 +08:00
|
|
|
g_assert(data->str);
|
|
|
|
return data->str;
|
2012-02-09 18:21:03 +08:00
|
|
|
}
|
|
|
|
|
2016-06-10 00:48:41 +08:00
|
|
|
static void visitor_reset(TestOutputVisitorData *data)
|
|
|
|
{
|
|
|
|
bool human = data->human;
|
|
|
|
|
|
|
|
visitor_output_teardown(data, NULL);
|
|
|
|
visitor_output_setup_internal(data, human);
|
|
|
|
}
|
|
|
|
|
2012-02-09 18:21:03 +08:00
|
|
|
static void test_visitor_out_int(TestOutputVisitorData *data,
|
|
|
|
const void *unused)
|
|
|
|
{
|
2014-06-10 19:15:28 +08:00
|
|
|
int64_t value = 42;
|
2014-05-02 19:26:29 +08:00
|
|
|
Error *err = NULL;
|
2012-02-09 18:21:03 +08:00
|
|
|
char *str;
|
|
|
|
|
qapi: Swap visit_* arguments for consistent 'name' placement
JSON uses "name":value, but many of our visitor interfaces were
called with visit_type_FOO(v, &value, name, errp). This can be
a bit confusing to have to mentally swap the parameter order to
match JSON order. It's particularly bad for visit_start_struct(),
where the 'name' parameter is smack in the middle of the
otherwise-related group of 'obj, kind, size' parameters! It's
time to do a global swap of the parameter ordering, so that the
'name' parameter is always immediately after the Visitor argument.
Additional reason in favor of the swap: the existing include/qjson.h
prefers listing 'name' first in json_prop_*(), and I have plans to
unify that file with the qapi visitors; listing 'name' first in
qapi will minimize churn to the (admittedly few) qjson.h clients.
Later patches will then fix docs, object.h, visitor-impl.h, and
those clients to match.
Done by first patching scripts/qapi*.py by hand to make generated
files do what I want, then by running the following Coccinelle
script to affect the rest of the code base:
$ spatch --sp-file script `git grep -l '\bvisit_' -- '**/*.[ch]'`
I then had to apply some touchups (Coccinelle insisted on TAB
indentation in visitor.h, and botched the signature of
visit_type_enum() by rewriting 'const char *const strings[]' to
the syntactically invalid 'const char*const[] strings'). The
movement of parameters is sufficient to provoke compiler errors
if any callers were missed.
// Part 1: Swap declaration order
@@
type TV, TErr, TObj, T1, T2;
identifier OBJ, ARG1, ARG2;
@@
void visit_start_struct
-(TV v, TObj OBJ, T1 ARG1, const char *name, T2 ARG2, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
{ ... }
@@
type bool, TV, T1;
identifier ARG1;
@@
bool visit_optional
-(TV v, T1 ARG1, const char *name)
+(TV v, const char *name, T1 ARG1)
{ ... }
@@
type TV, TErr, TObj, T1;
identifier OBJ, ARG1;
@@
void visit_get_next_type
-(TV v, TObj OBJ, T1 ARG1, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, TErr errp)
{ ... }
@@
type TV, TErr, TObj, T1, T2;
identifier OBJ, ARG1, ARG2;
@@
void visit_type_enum
-(TV v, TObj OBJ, T1 ARG1, T2 ARG2, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
{ ... }
@@
type TV, TErr, TObj;
identifier OBJ;
identifier VISIT_TYPE =~ "^visit_type_";
@@
void VISIT_TYPE
-(TV v, TObj OBJ, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, TErr errp)
{ ... }
// Part 2: swap caller order
@@
expression V, NAME, OBJ, ARG1, ARG2, ERR;
identifier VISIT_TYPE =~ "^visit_type_";
@@
(
-visit_start_struct(V, OBJ, ARG1, NAME, ARG2, ERR)
+visit_start_struct(V, NAME, OBJ, ARG1, ARG2, ERR)
|
-visit_optional(V, ARG1, NAME)
+visit_optional(V, NAME, ARG1)
|
-visit_get_next_type(V, OBJ, ARG1, NAME, ERR)
+visit_get_next_type(V, NAME, OBJ, ARG1, ERR)
|
-visit_type_enum(V, OBJ, ARG1, ARG2, NAME, ERR)
+visit_type_enum(V, NAME, OBJ, ARG1, ARG2, ERR)
|
-VISIT_TYPE(V, OBJ, NAME, ERR)
+VISIT_TYPE(V, NAME, OBJ, ERR)
)
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <1454075341-13658-19-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-01-29 21:48:54 +08:00
|
|
|
visit_type_int(data->ov, NULL, &value, &err);
|
2014-05-02 19:26:29 +08:00
|
|
|
g_assert(!err);
|
2012-02-09 18:21:03 +08:00
|
|
|
|
2016-06-10 00:48:42 +08:00
|
|
|
str = visitor_get(data);
|
2014-06-20 13:55:43 +08:00
|
|
|
if (data->human) {
|
|
|
|
g_assert_cmpstr(str, ==, "42 (0x2a)");
|
|
|
|
} else {
|
|
|
|
g_assert_cmpstr(str, ==, "42");
|
|
|
|
}
|
2012-02-09 18:21:03 +08:00
|
|
|
}
|
|
|
|
|
2014-06-10 19:15:28 +08:00
|
|
|
static void test_visitor_out_intList(TestOutputVisitorData *data,
|
|
|
|
const void *unused)
|
|
|
|
{
|
|
|
|
int64_t value[] = {0, 1, 9, 10, 16, 15, 14,
|
|
|
|
3, 4, 5, 6, 11, 12, 13, 21, 22, INT64_MAX - 1, INT64_MAX};
|
|
|
|
intList *list = NULL, **tmp = &list;
|
|
|
|
int i;
|
2015-12-18 23:35:27 +08:00
|
|
|
Error *err = NULL;
|
2014-06-10 19:15:28 +08:00
|
|
|
char *str;
|
|
|
|
|
2017-07-18 14:10:05 +08:00
|
|
|
for (i = 0; i < ARRAY_SIZE(value); i++) {
|
2014-06-10 19:15:28 +08:00
|
|
|
*tmp = g_malloc0(sizeof(**tmp));
|
|
|
|
(*tmp)->value = value[i];
|
|
|
|
tmp = &(*tmp)->next;
|
|
|
|
}
|
|
|
|
|
qapi: Swap visit_* arguments for consistent 'name' placement
JSON uses "name":value, but many of our visitor interfaces were
called with visit_type_FOO(v, &value, name, errp). This can be
a bit confusing to have to mentally swap the parameter order to
match JSON order. It's particularly bad for visit_start_struct(),
where the 'name' parameter is smack in the middle of the
otherwise-related group of 'obj, kind, size' parameters! It's
time to do a global swap of the parameter ordering, so that the
'name' parameter is always immediately after the Visitor argument.
Additional reason in favor of the swap: the existing include/qjson.h
prefers listing 'name' first in json_prop_*(), and I have plans to
unify that file with the qapi visitors; listing 'name' first in
qapi will minimize churn to the (admittedly few) qjson.h clients.
Later patches will then fix docs, object.h, visitor-impl.h, and
those clients to match.
Done by first patching scripts/qapi*.py by hand to make generated
files do what I want, then by running the following Coccinelle
script to affect the rest of the code base:
$ spatch --sp-file script `git grep -l '\bvisit_' -- '**/*.[ch]'`
I then had to apply some touchups (Coccinelle insisted on TAB
indentation in visitor.h, and botched the signature of
visit_type_enum() by rewriting 'const char *const strings[]' to
the syntactically invalid 'const char*const[] strings'). The
movement of parameters is sufficient to provoke compiler errors
if any callers were missed.
// Part 1: Swap declaration order
@@
type TV, TErr, TObj, T1, T2;
identifier OBJ, ARG1, ARG2;
@@
void visit_start_struct
-(TV v, TObj OBJ, T1 ARG1, const char *name, T2 ARG2, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
{ ... }
@@
type bool, TV, T1;
identifier ARG1;
@@
bool visit_optional
-(TV v, T1 ARG1, const char *name)
+(TV v, const char *name, T1 ARG1)
{ ... }
@@
type TV, TErr, TObj, T1;
identifier OBJ, ARG1;
@@
void visit_get_next_type
-(TV v, TObj OBJ, T1 ARG1, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, TErr errp)
{ ... }
@@
type TV, TErr, TObj, T1, T2;
identifier OBJ, ARG1, ARG2;
@@
void visit_type_enum
-(TV v, TObj OBJ, T1 ARG1, T2 ARG2, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
{ ... }
@@
type TV, TErr, TObj;
identifier OBJ;
identifier VISIT_TYPE =~ "^visit_type_";
@@
void VISIT_TYPE
-(TV v, TObj OBJ, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, TErr errp)
{ ... }
// Part 2: swap caller order
@@
expression V, NAME, OBJ, ARG1, ARG2, ERR;
identifier VISIT_TYPE =~ "^visit_type_";
@@
(
-visit_start_struct(V, OBJ, ARG1, NAME, ARG2, ERR)
+visit_start_struct(V, NAME, OBJ, ARG1, ARG2, ERR)
|
-visit_optional(V, ARG1, NAME)
+visit_optional(V, NAME, ARG1)
|
-visit_get_next_type(V, OBJ, ARG1, NAME, ERR)
+visit_get_next_type(V, NAME, OBJ, ARG1, ERR)
|
-visit_type_enum(V, OBJ, ARG1, ARG2, NAME, ERR)
+visit_type_enum(V, NAME, OBJ, ARG1, ARG2, ERR)
|
-VISIT_TYPE(V, OBJ, NAME, ERR)
+VISIT_TYPE(V, NAME, OBJ, ERR)
)
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <1454075341-13658-19-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-01-29 21:48:54 +08:00
|
|
|
visit_type_intList(data->ov, NULL, &list, &err);
|
2015-12-18 23:35:27 +08:00
|
|
|
g_assert(err == NULL);
|
2014-06-10 19:15:28 +08:00
|
|
|
|
2016-06-10 00:48:42 +08:00
|
|
|
str = visitor_get(data);
|
2014-06-20 13:55:43 +08:00
|
|
|
if (data->human) {
|
|
|
|
g_assert_cmpstr(str, ==,
|
|
|
|
"0-1,3-6,9-16,21-22,9223372036854775806-9223372036854775807 "
|
|
|
|
"(0x0-0x1,0x3-0x6,0x9-0x10,0x15-0x16,"
|
|
|
|
"0x7ffffffffffffffe-0x7fffffffffffffff)");
|
|
|
|
} else {
|
|
|
|
g_assert_cmpstr(str, ==,
|
|
|
|
"0-1,3-6,9-16,21-22,9223372036854775806-9223372036854775807");
|
|
|
|
}
|
2016-06-10 00:48:41 +08:00
|
|
|
qapi_free_intList(list);
|
2014-06-10 19:15:28 +08:00
|
|
|
}
|
|
|
|
|
2012-02-09 18:21:03 +08:00
|
|
|
static void test_visitor_out_bool(TestOutputVisitorData *data,
|
|
|
|
const void *unused)
|
|
|
|
{
|
2014-05-02 19:26:29 +08:00
|
|
|
Error *err = NULL;
|
2012-02-09 18:21:03 +08:00
|
|
|
bool value = true;
|
|
|
|
char *str;
|
|
|
|
|
qapi: Swap visit_* arguments for consistent 'name' placement
JSON uses "name":value, but many of our visitor interfaces were
called with visit_type_FOO(v, &value, name, errp). This can be
a bit confusing to have to mentally swap the parameter order to
match JSON order. It's particularly bad for visit_start_struct(),
where the 'name' parameter is smack in the middle of the
otherwise-related group of 'obj, kind, size' parameters! It's
time to do a global swap of the parameter ordering, so that the
'name' parameter is always immediately after the Visitor argument.
Additional reason in favor of the swap: the existing include/qjson.h
prefers listing 'name' first in json_prop_*(), and I have plans to
unify that file with the qapi visitors; listing 'name' first in
qapi will minimize churn to the (admittedly few) qjson.h clients.
Later patches will then fix docs, object.h, visitor-impl.h, and
those clients to match.
Done by first patching scripts/qapi*.py by hand to make generated
files do what I want, then by running the following Coccinelle
script to affect the rest of the code base:
$ spatch --sp-file script `git grep -l '\bvisit_' -- '**/*.[ch]'`
I then had to apply some touchups (Coccinelle insisted on TAB
indentation in visitor.h, and botched the signature of
visit_type_enum() by rewriting 'const char *const strings[]' to
the syntactically invalid 'const char*const[] strings'). The
movement of parameters is sufficient to provoke compiler errors
if any callers were missed.
// Part 1: Swap declaration order
@@
type TV, TErr, TObj, T1, T2;
identifier OBJ, ARG1, ARG2;
@@
void visit_start_struct
-(TV v, TObj OBJ, T1 ARG1, const char *name, T2 ARG2, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
{ ... }
@@
type bool, TV, T1;
identifier ARG1;
@@
bool visit_optional
-(TV v, T1 ARG1, const char *name)
+(TV v, const char *name, T1 ARG1)
{ ... }
@@
type TV, TErr, TObj, T1;
identifier OBJ, ARG1;
@@
void visit_get_next_type
-(TV v, TObj OBJ, T1 ARG1, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, TErr errp)
{ ... }
@@
type TV, TErr, TObj, T1, T2;
identifier OBJ, ARG1, ARG2;
@@
void visit_type_enum
-(TV v, TObj OBJ, T1 ARG1, T2 ARG2, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
{ ... }
@@
type TV, TErr, TObj;
identifier OBJ;
identifier VISIT_TYPE =~ "^visit_type_";
@@
void VISIT_TYPE
-(TV v, TObj OBJ, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, TErr errp)
{ ... }
// Part 2: swap caller order
@@
expression V, NAME, OBJ, ARG1, ARG2, ERR;
identifier VISIT_TYPE =~ "^visit_type_";
@@
(
-visit_start_struct(V, OBJ, ARG1, NAME, ARG2, ERR)
+visit_start_struct(V, NAME, OBJ, ARG1, ARG2, ERR)
|
-visit_optional(V, ARG1, NAME)
+visit_optional(V, NAME, ARG1)
|
-visit_get_next_type(V, OBJ, ARG1, NAME, ERR)
+visit_get_next_type(V, NAME, OBJ, ARG1, ERR)
|
-visit_type_enum(V, OBJ, ARG1, ARG2, NAME, ERR)
+visit_type_enum(V, NAME, OBJ, ARG1, ARG2, ERR)
|
-VISIT_TYPE(V, OBJ, NAME, ERR)
+VISIT_TYPE(V, NAME, OBJ, ERR)
)
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <1454075341-13658-19-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-01-29 21:48:54 +08:00
|
|
|
visit_type_bool(data->ov, NULL, &value, &err);
|
2014-05-02 19:26:29 +08:00
|
|
|
g_assert(!err);
|
2012-02-09 18:21:03 +08:00
|
|
|
|
2016-06-10 00:48:42 +08:00
|
|
|
str = visitor_get(data);
|
2012-02-09 18:21:03 +08:00
|
|
|
g_assert_cmpstr(str, ==, "true");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_visitor_out_number(TestOutputVisitorData *data,
|
|
|
|
const void *unused)
|
|
|
|
{
|
|
|
|
double value = 3.14;
|
2014-05-02 19:26:29 +08:00
|
|
|
Error *err = NULL;
|
2012-02-09 18:21:03 +08:00
|
|
|
char *str;
|
|
|
|
|
qapi: Swap visit_* arguments for consistent 'name' placement
JSON uses "name":value, but many of our visitor interfaces were
called with visit_type_FOO(v, &value, name, errp). This can be
a bit confusing to have to mentally swap the parameter order to
match JSON order. It's particularly bad for visit_start_struct(),
where the 'name' parameter is smack in the middle of the
otherwise-related group of 'obj, kind, size' parameters! It's
time to do a global swap of the parameter ordering, so that the
'name' parameter is always immediately after the Visitor argument.
Additional reason in favor of the swap: the existing include/qjson.h
prefers listing 'name' first in json_prop_*(), and I have plans to
unify that file with the qapi visitors; listing 'name' first in
qapi will minimize churn to the (admittedly few) qjson.h clients.
Later patches will then fix docs, object.h, visitor-impl.h, and
those clients to match.
Done by first patching scripts/qapi*.py by hand to make generated
files do what I want, then by running the following Coccinelle
script to affect the rest of the code base:
$ spatch --sp-file script `git grep -l '\bvisit_' -- '**/*.[ch]'`
I then had to apply some touchups (Coccinelle insisted on TAB
indentation in visitor.h, and botched the signature of
visit_type_enum() by rewriting 'const char *const strings[]' to
the syntactically invalid 'const char*const[] strings'). The
movement of parameters is sufficient to provoke compiler errors
if any callers were missed.
// Part 1: Swap declaration order
@@
type TV, TErr, TObj, T1, T2;
identifier OBJ, ARG1, ARG2;
@@
void visit_start_struct
-(TV v, TObj OBJ, T1 ARG1, const char *name, T2 ARG2, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
{ ... }
@@
type bool, TV, T1;
identifier ARG1;
@@
bool visit_optional
-(TV v, T1 ARG1, const char *name)
+(TV v, const char *name, T1 ARG1)
{ ... }
@@
type TV, TErr, TObj, T1;
identifier OBJ, ARG1;
@@
void visit_get_next_type
-(TV v, TObj OBJ, T1 ARG1, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, TErr errp)
{ ... }
@@
type TV, TErr, TObj, T1, T2;
identifier OBJ, ARG1, ARG2;
@@
void visit_type_enum
-(TV v, TObj OBJ, T1 ARG1, T2 ARG2, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
{ ... }
@@
type TV, TErr, TObj;
identifier OBJ;
identifier VISIT_TYPE =~ "^visit_type_";
@@
void VISIT_TYPE
-(TV v, TObj OBJ, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, TErr errp)
{ ... }
// Part 2: swap caller order
@@
expression V, NAME, OBJ, ARG1, ARG2, ERR;
identifier VISIT_TYPE =~ "^visit_type_";
@@
(
-visit_start_struct(V, OBJ, ARG1, NAME, ARG2, ERR)
+visit_start_struct(V, NAME, OBJ, ARG1, ARG2, ERR)
|
-visit_optional(V, ARG1, NAME)
+visit_optional(V, NAME, ARG1)
|
-visit_get_next_type(V, OBJ, ARG1, NAME, ERR)
+visit_get_next_type(V, NAME, OBJ, ARG1, ERR)
|
-visit_type_enum(V, OBJ, ARG1, ARG2, NAME, ERR)
+visit_type_enum(V, NAME, OBJ, ARG1, ARG2, ERR)
|
-VISIT_TYPE(V, OBJ, NAME, ERR)
+VISIT_TYPE(V, NAME, OBJ, ERR)
)
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <1454075341-13658-19-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-01-29 21:48:54 +08:00
|
|
|
visit_type_number(data->ov, NULL, &value, &err);
|
2014-05-02 19:26:29 +08:00
|
|
|
g_assert(!err);
|
2012-02-09 18:21:03 +08:00
|
|
|
|
2016-06-10 00:48:42 +08:00
|
|
|
str = visitor_get(data);
|
2012-04-30 22:33:30 +08:00
|
|
|
g_assert_cmpstr(str, ==, "3.140000");
|
2012-02-09 18:21:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_visitor_out_string(TestOutputVisitorData *data,
|
|
|
|
const void *unused)
|
|
|
|
{
|
|
|
|
char *string = (char *) "Q E M U";
|
2014-06-20 13:55:43 +08:00
|
|
|
const char *string_human = "\"Q E M U\"";
|
2014-05-02 19:26:29 +08:00
|
|
|
Error *err = NULL;
|
2012-02-09 18:21:03 +08:00
|
|
|
char *str;
|
|
|
|
|
qapi: Swap visit_* arguments for consistent 'name' placement
JSON uses "name":value, but many of our visitor interfaces were
called with visit_type_FOO(v, &value, name, errp). This can be
a bit confusing to have to mentally swap the parameter order to
match JSON order. It's particularly bad for visit_start_struct(),
where the 'name' parameter is smack in the middle of the
otherwise-related group of 'obj, kind, size' parameters! It's
time to do a global swap of the parameter ordering, so that the
'name' parameter is always immediately after the Visitor argument.
Additional reason in favor of the swap: the existing include/qjson.h
prefers listing 'name' first in json_prop_*(), and I have plans to
unify that file with the qapi visitors; listing 'name' first in
qapi will minimize churn to the (admittedly few) qjson.h clients.
Later patches will then fix docs, object.h, visitor-impl.h, and
those clients to match.
Done by first patching scripts/qapi*.py by hand to make generated
files do what I want, then by running the following Coccinelle
script to affect the rest of the code base:
$ spatch --sp-file script `git grep -l '\bvisit_' -- '**/*.[ch]'`
I then had to apply some touchups (Coccinelle insisted on TAB
indentation in visitor.h, and botched the signature of
visit_type_enum() by rewriting 'const char *const strings[]' to
the syntactically invalid 'const char*const[] strings'). The
movement of parameters is sufficient to provoke compiler errors
if any callers were missed.
// Part 1: Swap declaration order
@@
type TV, TErr, TObj, T1, T2;
identifier OBJ, ARG1, ARG2;
@@
void visit_start_struct
-(TV v, TObj OBJ, T1 ARG1, const char *name, T2 ARG2, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
{ ... }
@@
type bool, TV, T1;
identifier ARG1;
@@
bool visit_optional
-(TV v, T1 ARG1, const char *name)
+(TV v, const char *name, T1 ARG1)
{ ... }
@@
type TV, TErr, TObj, T1;
identifier OBJ, ARG1;
@@
void visit_get_next_type
-(TV v, TObj OBJ, T1 ARG1, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, TErr errp)
{ ... }
@@
type TV, TErr, TObj, T1, T2;
identifier OBJ, ARG1, ARG2;
@@
void visit_type_enum
-(TV v, TObj OBJ, T1 ARG1, T2 ARG2, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
{ ... }
@@
type TV, TErr, TObj;
identifier OBJ;
identifier VISIT_TYPE =~ "^visit_type_";
@@
void VISIT_TYPE
-(TV v, TObj OBJ, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, TErr errp)
{ ... }
// Part 2: swap caller order
@@
expression V, NAME, OBJ, ARG1, ARG2, ERR;
identifier VISIT_TYPE =~ "^visit_type_";
@@
(
-visit_start_struct(V, OBJ, ARG1, NAME, ARG2, ERR)
+visit_start_struct(V, NAME, OBJ, ARG1, ARG2, ERR)
|
-visit_optional(V, ARG1, NAME)
+visit_optional(V, NAME, ARG1)
|
-visit_get_next_type(V, OBJ, ARG1, NAME, ERR)
+visit_get_next_type(V, NAME, OBJ, ARG1, ERR)
|
-visit_type_enum(V, OBJ, ARG1, ARG2, NAME, ERR)
+visit_type_enum(V, NAME, OBJ, ARG1, ARG2, ERR)
|
-VISIT_TYPE(V, OBJ, NAME, ERR)
+VISIT_TYPE(V, NAME, OBJ, ERR)
)
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <1454075341-13658-19-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-01-29 21:48:54 +08:00
|
|
|
visit_type_str(data->ov, NULL, &string, &err);
|
2014-05-02 19:26:29 +08:00
|
|
|
g_assert(!err);
|
2012-02-09 18:21:03 +08:00
|
|
|
|
2016-06-10 00:48:42 +08:00
|
|
|
str = visitor_get(data);
|
2014-06-20 13:55:43 +08:00
|
|
|
if (data->human) {
|
|
|
|
g_assert_cmpstr(str, ==, string_human);
|
|
|
|
} else {
|
|
|
|
g_assert_cmpstr(str, ==, string);
|
|
|
|
}
|
2012-02-09 18:21:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_visitor_out_no_string(TestOutputVisitorData *data,
|
|
|
|
const void *unused)
|
|
|
|
{
|
|
|
|
char *string = NULL;
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
/* A null string should return "" */
|
2016-06-10 00:48:41 +08:00
|
|
|
visit_type_str(data->ov, NULL, &string, &error_abort);
|
2012-02-09 18:21:03 +08:00
|
|
|
|
2016-06-10 00:48:42 +08:00
|
|
|
str = visitor_get(data);
|
2014-06-20 13:55:43 +08:00
|
|
|
if (data->human) {
|
|
|
|
g_assert_cmpstr(str, ==, "<null>");
|
|
|
|
} else {
|
|
|
|
g_assert_cmpstr(str, ==, "");
|
|
|
|
}
|
2012-02-09 18:21:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_visitor_out_enum(TestOutputVisitorData *data,
|
|
|
|
const void *unused)
|
|
|
|
{
|
|
|
|
char *str;
|
|
|
|
EnumOne i;
|
|
|
|
|
qapi: Don't let implicit enum MAX member collide
Now that we guarantee the user doesn't have any enum values
beginning with a single underscore, we can use that for our
own purposes. Renaming ENUM_MAX to ENUM__MAX makes it obvious
that the sentinel is generated.
This patch was mostly generated by applying a temporary patch:
|diff --git a/scripts/qapi.py b/scripts/qapi.py
|index e6d014b..b862ec9 100644
|--- a/scripts/qapi.py
|+++ b/scripts/qapi.py
|@@ -1570,6 +1570,7 @@ const char *const %(c_name)s_lookup[] = {
| max_index = c_enum_const(name, 'MAX', prefix)
| ret += mcgen('''
| [%(max_index)s] = NULL,
|+// %(max_index)s
| };
| ''',
| max_index=max_index)
then running:
$ cat qapi-{types,event}.c tests/test-qapi-types.c |
sed -n 's,^// \(.*\)MAX,s|\1MAX|\1_MAX|g,p' > list
$ git grep -l _MAX | xargs sed -i -f list
The only things not generated are the changes in scripts/qapi.py.
Rejecting enum members named 'MAX' is now useless, and will be dropped
in the next patch.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1447836791-369-23-git-send-email-eblake@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
[Rebased to current master, commit message tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2015-11-18 16:52:57 +08:00
|
|
|
for (i = 0; i < ENUM_ONE__MAX; i++) {
|
2016-06-10 00:48:41 +08:00
|
|
|
visit_type_EnumOne(data->ov, "unused", &i, &error_abort);
|
2014-06-20 13:55:43 +08:00
|
|
|
|
2016-06-10 00:48:42 +08:00
|
|
|
str = visitor_get(data);
|
2014-06-20 13:55:43 +08:00
|
|
|
if (data->human) {
|
2017-08-24 16:46:08 +08:00
|
|
|
char *str_human = g_strdup_printf("\"%s\"", EnumOne_str(i));
|
2016-06-10 00:48:41 +08:00
|
|
|
|
2014-06-20 13:55:43 +08:00
|
|
|
g_assert_cmpstr(str, ==, str_human);
|
2016-06-10 00:48:41 +08:00
|
|
|
g_free(str_human);
|
2014-06-20 13:55:43 +08:00
|
|
|
} else {
|
2017-08-24 16:46:08 +08:00
|
|
|
g_assert_cmpstr(str, ==, EnumOne_str(i));
|
2014-06-20 13:55:43 +08:00
|
|
|
}
|
2016-06-10 00:48:41 +08:00
|
|
|
visitor_reset(data);
|
2012-02-09 18:21:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_visitor_out_enum_errors(TestOutputVisitorData *data,
|
|
|
|
const void *unused)
|
|
|
|
{
|
qapi: Don't let implicit enum MAX member collide
Now that we guarantee the user doesn't have any enum values
beginning with a single underscore, we can use that for our
own purposes. Renaming ENUM_MAX to ENUM__MAX makes it obvious
that the sentinel is generated.
This patch was mostly generated by applying a temporary patch:
|diff --git a/scripts/qapi.py b/scripts/qapi.py
|index e6d014b..b862ec9 100644
|--- a/scripts/qapi.py
|+++ b/scripts/qapi.py
|@@ -1570,6 +1570,7 @@ const char *const %(c_name)s_lookup[] = {
| max_index = c_enum_const(name, 'MAX', prefix)
| ret += mcgen('''
| [%(max_index)s] = NULL,
|+// %(max_index)s
| };
| ''',
| max_index=max_index)
then running:
$ cat qapi-{types,event}.c tests/test-qapi-types.c |
sed -n 's,^// \(.*\)MAX,s|\1MAX|\1_MAX|g,p' > list
$ git grep -l _MAX | xargs sed -i -f list
The only things not generated are the changes in scripts/qapi.py.
Rejecting enum members named 'MAX' is now useless, and will be dropped
in the next patch.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1447836791-369-23-git-send-email-eblake@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
[Rebased to current master, commit message tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2015-11-18 16:52:57 +08:00
|
|
|
EnumOne i, bad_values[] = { ENUM_ONE__MAX, -1 };
|
2012-02-09 18:21:03 +08:00
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) {
|
2019-12-04 17:36:11 +08:00
|
|
|
Error *err = NULL;
|
|
|
|
|
qapi: Swap visit_* arguments for consistent 'name' placement
JSON uses "name":value, but many of our visitor interfaces were
called with visit_type_FOO(v, &value, name, errp). This can be
a bit confusing to have to mentally swap the parameter order to
match JSON order. It's particularly bad for visit_start_struct(),
where the 'name' parameter is smack in the middle of the
otherwise-related group of 'obj, kind, size' parameters! It's
time to do a global swap of the parameter ordering, so that the
'name' parameter is always immediately after the Visitor argument.
Additional reason in favor of the swap: the existing include/qjson.h
prefers listing 'name' first in json_prop_*(), and I have plans to
unify that file with the qapi visitors; listing 'name' first in
qapi will minimize churn to the (admittedly few) qjson.h clients.
Later patches will then fix docs, object.h, visitor-impl.h, and
those clients to match.
Done by first patching scripts/qapi*.py by hand to make generated
files do what I want, then by running the following Coccinelle
script to affect the rest of the code base:
$ spatch --sp-file script `git grep -l '\bvisit_' -- '**/*.[ch]'`
I then had to apply some touchups (Coccinelle insisted on TAB
indentation in visitor.h, and botched the signature of
visit_type_enum() by rewriting 'const char *const strings[]' to
the syntactically invalid 'const char*const[] strings'). The
movement of parameters is sufficient to provoke compiler errors
if any callers were missed.
// Part 1: Swap declaration order
@@
type TV, TErr, TObj, T1, T2;
identifier OBJ, ARG1, ARG2;
@@
void visit_start_struct
-(TV v, TObj OBJ, T1 ARG1, const char *name, T2 ARG2, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
{ ... }
@@
type bool, TV, T1;
identifier ARG1;
@@
bool visit_optional
-(TV v, T1 ARG1, const char *name)
+(TV v, const char *name, T1 ARG1)
{ ... }
@@
type TV, TErr, TObj, T1;
identifier OBJ, ARG1;
@@
void visit_get_next_type
-(TV v, TObj OBJ, T1 ARG1, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, TErr errp)
{ ... }
@@
type TV, TErr, TObj, T1, T2;
identifier OBJ, ARG1, ARG2;
@@
void visit_type_enum
-(TV v, TObj OBJ, T1 ARG1, T2 ARG2, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
{ ... }
@@
type TV, TErr, TObj;
identifier OBJ;
identifier VISIT_TYPE =~ "^visit_type_";
@@
void VISIT_TYPE
-(TV v, TObj OBJ, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, TErr errp)
{ ... }
// Part 2: swap caller order
@@
expression V, NAME, OBJ, ARG1, ARG2, ERR;
identifier VISIT_TYPE =~ "^visit_type_";
@@
(
-visit_start_struct(V, OBJ, ARG1, NAME, ARG2, ERR)
+visit_start_struct(V, NAME, OBJ, ARG1, ARG2, ERR)
|
-visit_optional(V, ARG1, NAME)
+visit_optional(V, NAME, ARG1)
|
-visit_get_next_type(V, OBJ, ARG1, NAME, ERR)
+visit_get_next_type(V, NAME, OBJ, ARG1, ERR)
|
-visit_type_enum(V, OBJ, ARG1, ARG2, NAME, ERR)
+visit_type_enum(V, NAME, OBJ, ARG1, ARG2, ERR)
|
-VISIT_TYPE(V, OBJ, NAME, ERR)
+VISIT_TYPE(V, NAME, OBJ, ERR)
)
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <1454075341-13658-19-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-01-29 21:48:54 +08:00
|
|
|
visit_type_EnumOne(data->ov, "unused", &bad_values[i], &err);
|
2016-06-10 00:48:41 +08:00
|
|
|
error_free_or_abort(&err);
|
2012-02-09 18:21:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-20 13:55:43 +08:00
|
|
|
static void
|
|
|
|
output_visitor_test_add(const char *testpath,
|
|
|
|
TestOutputVisitorData *data,
|
|
|
|
void (*test_func)(TestOutputVisitorData *data,
|
|
|
|
const void *user_data),
|
|
|
|
bool human)
|
2012-02-09 18:21:03 +08:00
|
|
|
{
|
2014-06-20 13:55:43 +08:00
|
|
|
g_test_add(testpath, TestOutputVisitorData, data,
|
|
|
|
human ? visitor_output_setup_human : visitor_output_setup,
|
2012-02-09 18:21:03 +08:00
|
|
|
test_func, visitor_output_teardown);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
TestOutputVisitorData out_visitor_data;
|
|
|
|
|
|
|
|
g_test_init(&argc, &argv, NULL);
|
|
|
|
|
|
|
|
output_visitor_test_add("/string-visitor/output/int",
|
2014-06-20 13:55:43 +08:00
|
|
|
&out_visitor_data, test_visitor_out_int, false);
|
2015-10-05 19:04:20 +08:00
|
|
|
output_visitor_test_add("/string-visitor/output/int-human",
|
2014-06-20 13:55:43 +08:00
|
|
|
&out_visitor_data, test_visitor_out_int, true);
|
|
|
|
output_visitor_test_add("/string-visitor/output/bool",
|
|
|
|
&out_visitor_data, test_visitor_out_bool, false);
|
2015-10-05 19:04:20 +08:00
|
|
|
output_visitor_test_add("/string-visitor/output/bool-human",
|
2014-06-20 13:55:43 +08:00
|
|
|
&out_visitor_data, test_visitor_out_bool, true);
|
|
|
|
output_visitor_test_add("/string-visitor/output/number",
|
|
|
|
&out_visitor_data, test_visitor_out_number, false);
|
2015-10-05 19:04:20 +08:00
|
|
|
output_visitor_test_add("/string-visitor/output/number-human",
|
2014-06-20 13:55:43 +08:00
|
|
|
&out_visitor_data, test_visitor_out_number, true);
|
2012-02-09 18:21:03 +08:00
|
|
|
output_visitor_test_add("/string-visitor/output/string",
|
2014-06-20 13:55:43 +08:00
|
|
|
&out_visitor_data, test_visitor_out_string, false);
|
2015-10-05 19:04:20 +08:00
|
|
|
output_visitor_test_add("/string-visitor/output/string-human",
|
2014-06-20 13:55:43 +08:00
|
|
|
&out_visitor_data, test_visitor_out_string, true);
|
|
|
|
output_visitor_test_add("/string-visitor/output/no-string",
|
|
|
|
&out_visitor_data, test_visitor_out_no_string,
|
|
|
|
false);
|
2015-10-05 19:04:20 +08:00
|
|
|
output_visitor_test_add("/string-visitor/output/no-string-human",
|
2014-06-20 13:55:43 +08:00
|
|
|
&out_visitor_data, test_visitor_out_no_string,
|
|
|
|
true);
|
|
|
|
output_visitor_test_add("/string-visitor/output/enum",
|
|
|
|
&out_visitor_data, test_visitor_out_enum, false);
|
2015-10-05 19:04:20 +08:00
|
|
|
output_visitor_test_add("/string-visitor/output/enum-human",
|
2014-06-20 13:55:43 +08:00
|
|
|
&out_visitor_data, test_visitor_out_enum, true);
|
2012-02-09 18:21:03 +08:00
|
|
|
output_visitor_test_add("/string-visitor/output/enum-errors",
|
2014-06-20 13:55:43 +08:00
|
|
|
&out_visitor_data, test_visitor_out_enum_errors,
|
|
|
|
false);
|
2015-10-05 19:04:20 +08:00
|
|
|
output_visitor_test_add("/string-visitor/output/enum-errors-human",
|
2014-06-20 13:55:43 +08:00
|
|
|
&out_visitor_data, test_visitor_out_enum_errors,
|
|
|
|
true);
|
|
|
|
output_visitor_test_add("/string-visitor/output/intList",
|
|
|
|
&out_visitor_data, test_visitor_out_intList, false);
|
2015-10-05 19:04:20 +08:00
|
|
|
output_visitor_test_add("/string-visitor/output/intList-human",
|
2014-06-20 13:55:43 +08:00
|
|
|
&out_visitor_data, test_visitor_out_intList, true);
|
2012-02-09 18:21:03 +08:00
|
|
|
|
|
|
|
g_test_run();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|