sbus_codegen_tests.c revision e51143e3e67c70b86dd9a67cb7e802dd96f989e1
ff7056842f14fd3b30a2d327dfab165b9d15dd30Timo Sirainen sbus_codegen tests.
ff7056842f14fd3b30a2d327dfab165b9d15dd30Timo Sirainen Stef Walter <stefw@redhat.com>
ff7056842f14fd3b30a2d327dfab165b9d15dd30Timo Sirainen Copyright (C) Red Hat, Inc 2014
ff7056842f14fd3b30a2d327dfab165b9d15dd30Timo Sirainen This program is free software; you can redistribute it and/or modify
ff7056842f14fd3b30a2d327dfab165b9d15dd30Timo Sirainen it under the terms of the GNU General Public License as published by
ac4e6609cbdca594db1b1c02afb1e372ab22e060Timo Sirainen the Free Software Foundation; either version 3 of the License, or
ac4e6609cbdca594db1b1c02afb1e372ab22e060Timo Sirainen (at your option) any later version.
ac4e6609cbdca594db1b1c02afb1e372ab22e060Timo Sirainen This program is distributed in the hope that it will be useful,
ac4e6609cbdca594db1b1c02afb1e372ab22e060Timo Sirainen but WITHOUT ANY WARRANTY; without even the implied warranty of
ac4e6609cbdca594db1b1c02afb1e372ab22e060Timo Sirainen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ff7056842f14fd3b30a2d327dfab165b9d15dd30Timo Sirainen GNU General Public License for more details.
ff7056842f14fd3b30a2d327dfab165b9d15dd30Timo Sirainen You should have received a copy of the GNU General Public License
ff7056842f14fd3b30a2d327dfab165b9d15dd30Timo Sirainen along with this program. If not, see <http://www.gnu.org/licenses/>.
ff7056842f14fd3b30a2d327dfab165b9d15dd30Timo Sirainen#include "tests/sbus_codegen_tests_generated.h"
910fa4e4204a73d3d24c03f3059dd24e727ca057Timo Sirainen/* The following 2 macros were taken from check's project source files (0.9.10)
4321f6c969e7b8f6b243ff5bb6b8d297921676f6Timo Sirainen ck_assert_msg(_ck_x OP _ck_y, "Assertion '"#X#OP#Y"' failed: "#X"==%ju, "#Y"==%ju", _ck_x, _ck_y); \
ff7056842f14fd3b30a2d327dfab165b9d15dd30Timo Sirainen#endif /* _ck_assert_uint */
ff7056842f14fd3b30a2d327dfab165b9d15dd30Timo Sirainen#define ck_assert_uint_eq(X, Y) _ck_assert_uint(X, ==, Y)
ff7056842f14fd3b30a2d327dfab165b9d15dd30Timo Sirainen#endif /* ck_assert_uint_eq */
ff7056842f14fd3b30a2d327dfab165b9d15dd30Timo Sirainenstatic const struct sbus_arg_meta *
const char *name)
return arg;
return NULL;
const char *where)
{ &com_planetexpress_Ship_meta, 0 },
NULL,
/* constants for com.planetexpress.Pilot */
return tc;
arg_byte++;
arg_int16++;
arg_uint16++;
arg_int32++;
arg_uint32++;
arg_int64++;
arg_uint64++;
arg_double++;
for (i = 0; i < len_byte_array; i++)
arg_byte_array[i]++;
for (i = 0; i < len_int16_array; i++)
arg_int16_array[i]++;
for (i = 0; i < len_uint16_array; i++)
arg_uint16_array[i]++;
for (i = 0; i < len_int32_array; i++)
arg_int32_array[i]++;
for (i = 0; i < len_uint32_array; i++)
arg_uint32_array[i]++;
for (i = 0; i < len_int64_array; i++)
arg_int64_array[i]++;
for (i = 0; i < len_uint64_array; i++)
arg_uint64_array[i]++;
for (i = 0; i < len_double_array; i++)
arg_double_array[i]++;
for (i = 0; i < len_double_array; i++) {
arg_object_path_array = talloc_memdup(req, arg_object_path_array, sizeof(char *) * len_object_path_array);
for (i = 0; i < len_object_path_array; i++) {
static const bool pilot_bool = true;
void *instance_data,
bool *val)
void *instance_data,
const char **name)
void *instance_data,
void *instance_data,
void *instance_data,
void *instance_data,
void *instance_data,
void *instance_data,
void *instance_data,
void *instance_data,
double *double_val)
void *instance_data,
const char **string_val)
void *instance_data,
const char **path_val)
void *instance_data,
const char **string_val)
void *instance_data,
const char **path_val)
void *instance_data,
void *instance_data,
void *instance_data,
void *instance_data,
void *instance_data,
void *instance_data,
void *instance_data,
void *instance_data,
void *data,
const char ***arr_out,
int *arr_len)
void *data,
const char ***arr_out,
int *arr_len)
void *data,
char **values;
int hret;
{ &test_pilot_meta, 0 },
{ &test_special_meta, 0},
int ret;
return EOK;
int ret;
return EOK;
&error,
const char *object_path,
const char *iface,
const char *prop,
int type,
void *val)
&error,
const char *string_val;
const char *path_val;
double double_val;
const char **strings;
*nels = n;
const char *object_path,
const char *iface,
const char *prop,
int type,
void **values,
int *nels)
&error,
const char **string_arr_val;
int string_arr_len;
const char **path_arr_val;
int path_arr_len;
int byte_arr_len;
int int16_arr_len;
int uint16_arr_len;
int int32_arr_len;
int uint32_arr_len;
int int64_arr_len;
int uint64_arr_len;
double *double_arr_val;
int double_arr_len;
const char *value;
const char **exp_values;
&error,
struct prop_test {
const char *name;
bool handled;
int length;
int type;
union prop_value {
bool bool_val;
const char *string_val;
const char *path_val;
double double_val;
const char **string_arr_val;
const char **path_arr_val;
double *double_arr_val;
} value;
const char *string_val;
const char *path_val;
double double_val;
int type;
switch (p->type) {
case DBUS_TYPE_BOOLEAN:
case DBUS_TYPE_STRING:
case DBUS_TYPE_BYTE:
case DBUS_TYPE_INT16:
case DBUS_TYPE_UINT16:
case DBUS_TYPE_INT32:
case DBUS_TYPE_UINT32:
case DBUS_TYPE_INT64:
case DBUS_TYPE_UINT64:
case DBUS_TYPE_DOUBLE:
case DBUS_TYPE_OBJECT_PATH:
p->handled = true;
double *double_arr_val;
int len;
int type;
len = n;
switch (p->type) {
case DBUS_TYPE_STRING:
case DBUS_TYPE_BYTE:
case DBUS_TYPE_INT16:
case DBUS_TYPE_UINT16:
case DBUS_TYPE_INT32:
case DBUS_TYPE_UINT32:
case DBUS_TYPE_INT64:
case DBUS_TYPE_UINT64:
case DBUS_TYPE_DOUBLE:
case DBUS_TYPE_OBJECT_PATH:
p->handled = true;
char *attr_name;
int num_prop;
{ "byte_array", false, N_ELEMENTS(pilot_byte_array), DBUS_TYPE_BYTE, { .byte_arr_val = pilot_byte_array } },
{ "int16_array", false, N_ELEMENTS(pilot_int16_array), DBUS_TYPE_INT16, { .int16_arr_val = pilot_int16_array } },
{ "uint16_array", false, N_ELEMENTS(pilot_uint16_array), DBUS_TYPE_UINT16, { .uint16_arr_val = pilot_uint16_array } },
{ "int32_array", false, N_ELEMENTS(pilot_int32_array), DBUS_TYPE_INT32, { .int32_arr_val = pilot_int32_array } },
{ "uint32_array", false, N_ELEMENTS(pilot_uint32_array), DBUS_TYPE_UINT32, { .uint32_arr_val = pilot_uint32_array } },
{ "int64_array", false, N_ELEMENTS(pilot_int64_array), DBUS_TYPE_INT64, { .int64_arr_val = pilot_int64_array } },
{ "uint64_array", false, N_ELEMENTS(pilot_uint64_array), DBUS_TYPE_UINT64, { .uint64_arr_val = pilot_uint64_array } },
{ "double_array", false, N_ELEMENTS(pilot_double_array), DBUS_TYPE_DOUBLE, { .double_arr_val = pilot_double_array } },
{ "string_array", false, N_ELEMENTS(pilot_string_array), DBUS_TYPE_STRING, { .string_arr_val = pilot_string_array } },
{ "object_path_array", false, N_ELEMENTS(pilot_path_array), DBUS_TYPE_OBJECT_PATH, { .path_arr_val = pilot_path_array } },
&error,
num_prop = 0;
num_prop++;
return tc;
int opt;
int failure_count;
switch (opt) {