86 .xct_sizeof =
sizeof (
struct un),
95 .xct_sizeof =
sizeof (
tdef),
104 .xct_sizeof =
sizeof (
struct v),
113 .xct_sizeof =
sizeof (
struct foo),
122 .xct_sizeof =
sizeof (
struct ar),
131 .xct_sizeof =
sizeof (
struct top),
136 static char data[] =
"Hello, world!\n";
266 .xf_opaque = opaq_type,
324 const struct m0_xcode_cursor_frame *
f;
326 for (
i = 0,
f = &
it->xcu_stack[0]; i < it->xcu_depth; ++
i, ++
f) {
327 printf(
".%s[%" PRId64 "]",
328 f->s_obj.xo_type->xct_child[
f->s_fieldno].xf_name,
333 switch (
f->s_obj.xo_type->xct_atype) {
338 printf(
"%c", *(
char *)
f->s_obj.xo_ptr);
341 printf(
"%x", *(uint32_t *)
f->s_obj.xo_ptr);
344 printf(
"%x", (
unsigned)*(uint64_t *)
f->s_obj.xo_ptr);
356 void *
addr,
int fieldno,
int elno,
361 struct m0_xcode_cursor_frame *
f;
387 it.xcu_stack[0].s_obj.xo_ptr = &
T;
435 for (
i = 0;
i <
N; ++
i) {
498 *
obj =
ctx.xcx_it.xcu_stack[0].s_obj;
524 FSIZE =
sizeof(uint64_t) +
sizeof(uint64_t)
592 for (
i = 0;
i <
N; ++
i)
596 for (
i = 0;
i <
N; ++
i)
637 t1->t_v.v_data[0] =
'J';
640 t1->t_v.v_data[0] =
t0->t_v.v_data[0];
656 static const char pattern[] =
"!EXPECTED!";
667 #define OBJ(xt, ptr) (&(struct m0_xcode_obj){ .xo_type = (xt), .xo_ptr = (ptr) }) 669 static void literal(
const char *input,
const char *output)
676 output = output ?: input;
684 M0_UT_ASSERT(strncmp(V->v_data, output + 1, V->v_nr) == 0);
796 #define ARS "<(0, 0x1), (0, 0x1), (0, 0x1), (0, 0x1), (0, 0x1), (0, 0x1)>" 803 literal(
"\"/dev/disk/by-id/wwn-0x5000c50078c12486\"",
NULL);
804 literal(
"[0x15:0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30," 805 "0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30]",
806 "\"000000000000000000000\"");
807 literal(
"[0x16:0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30," 808 "0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30]",
809 "\"0000000000000000000000\"");
822 "((1, 2), 8, [4: 1, 2, 3, 4], 4, {1| 42}, 7," ARS ")");
834 for (
i = 0;
i <
N; ++
i) {
845 "((1, 2), 8, ^!EXPECTED!, 4, {1| 42}, 7," ARS ")");
856 "((1, 2), 8, [4: 1, 2, 3, 4], 4, {1| 42}, 7," ARS ")");
869 char data[] = { 1, 2, 3, 4 };
874 .t_v = { .v_nr = 4, .v_data =
data },
876 .t_un = { .u_tag = 1, .u = { .u_x = 42 }},
877 .t_opaq = { .o_64 = &o64 },
893 for (s0 =
buf, s1 =
"" 896 " [0x4: 0x1, 0x2, 0x3, 0x4]," 900 *s0 != 0 && *s1 != 0; ++s0, ++s1) {
950 #include "test_gccxml_simple_xc.h" 957 M0_UT_ASSERT(m0_xc_testenum_enum.xe_val[1].xev_val == 1);
971 m0_streq(m0_xcode_enum_print(&m0_xc_testenum_enum, v, NULL), #v) 996 #define C(v) (enum_read_check(#v, strlen(#v), v, 0)) 1011 int nr,
bool ok,
const char *
out)
1032 {
BM_ZERO, 10,
true,
"BM_ZERO" },
1033 {
BM_SIX, 10,
true,
"BM_SIX" },
1034 {
BM_FOUR, 10,
true,
"BM_FOUR" },
1035 {
BM_NINE, 10,
true,
"BM_NINE" },
1036 {
BM_FIVE, 10,
true,
"BM_FIVE" },
1040 { 1024, 10,
true,
"400" },
1041 { 1024|
BM_ZERO, 20,
true,
"BM_ZERO|400" },
1075 {
BM_ZERO, -1,
true,
"BM_ZERO" },
1076 {
BM_SIX, -1,
true,
"BM_SIX" },
1077 {
BM_FOUR, -1,
true,
"BM_FOUR" },
1078 {
BM_NINE, -1,
true,
"BM_NINE" },
1079 {
BM_FIVE, -1,
true,
"BM_FIVE" },
1084 { 0, -1,
false,
"BM_FOUR|BM_NINE|400Z" },
1085 { 0, -1,
false,
"BM_FOUR|BM_NINE|Z" },
1086 { 0, -1,
false,
"ZZZZZZZZZZZZZZZZZ" },
1088 { 0, -1,
false,
"BM_FOUR|BM_NINE||" },
1090 { 0, -1,
false,
"|BM_FOUR|BM_NINE||" },
1091 { 0, -1,
false,
"|||" },
1092 { 0, -1,
false,
"||" },
1093 { 0, -1,
false,
"|" },
1094 { 0, -1,
false,
"|0" },
1095 { 0, -1,
false,
"|0|0|" },
1096 { 0, -1,
false,
"|0|" },
1097 { 0, -1,
true,
"0|0" },
1098 { 1, -1,
true,
"1|" },
1117 uint64_t
seed = (uint64_t)
buf;
1120 for (
i = 0;
i < 2000; ++
i) {
1126 out, strlen(
out), &val1);
1133 buf, strlen(
buf), &val1);
1149 .xo_type = enumfield_xc,
1155 m0_xc_xcode_ut_test_gccxml_simple_init();
M0_INTERNAL struct m0_xcode_cursor_frame * m0_xcode_cursor_top(struct m0_xcode_cursor *it)
#define M0_BUFVEC_INIT_BUF(addr_ptr, count_ptr)
static void foo_xor(char *buf)
M0_INTERNAL int m0_xcode_print(const struct m0_xcode_obj *obj, char *str, int nr)
static struct static_xt xut_v
static void xcode_find_test(void)
const struct m0_xcode_type * xo_type
int const char const void size_t int flags
M0_INTERNAL void m0_xcode_type_iterate(struct m0_xcode_type *xt, void(*t)(struct m0_xcode_type *, void *), void(*f)(struct m0_xcode_type *, struct m0_xcode_field *, void *), void *datum)
static struct buffer * cur(struct m0_addb2_mach *mach, m0_bcount_t space)
M0_INTERNAL int m0_xcode_read(struct m0_xcode_obj *obj, const char *str)
static m0_bcount_t foo_count
static int xcode_init(void)
static const struct m0_xcode_type_ops foo_ops
static void xcode_length_test(void)
static struct static_xt xut_top
static void xcode_enum_gccxml(void)
static struct m0_be_emap_cursor it
static void xcode_opaque_test(void)
struct m0_xcode_field xct_child[0]
static void xcode_encode_test(void)
int(* xto_length)(struct m0_xcode_ctx *ctx, const void *obj)
M0_INTERNAL void m0_xcode_free_obj(struct m0_xcode_obj *obj)
static void xcode_decode_test(void)
M0_INTERNAL int m0_xcode_decode(struct m0_xcode_ctx *ctx)
static void decode(struct m0_xcode_obj *obj)
const struct m0_xcode_type_ops * xct_ops
static struct m0_xcode_type ** xt[]
static void xcode_enum_read(void)
const struct m0_xcode_type * p_src
static char foo_buf[FSIZE]
static void xcode_nonstandard_test(void)
M0_INTERNAL int m0_xcode_length(struct m0_xcode_ctx *ctx)
static void xcode_read_test(void)
int(* xto_read)(const struct m0_xcode_cursor *it, struct m0_xcode_obj *obj, const char *str)
struct m0_xcode_type p_dst
static void xcode_cursor_test(void)
static void flagset(struct m0_xcode_type *xt, uint32_t flags)
M0_INTERNAL m0_bcount_t m0_bufvec_cursor_copy(struct m0_bufvec_cursor *dcur, struct m0_bufvec_cursor *scur, m0_bcount_t num_bytes)
const struct m0_xcode_type M0_XT_OPAQUE
int m0_package_cred_get(const struct m0_xcode_obj *par, const struct m0_xcode_type **out)
static void xcode_enum_field(void)
static int field(struct ff2c_context *ctx, struct ff2c_term *term)
static void fieldset(struct m0_xcode_type *xt, struct m0_xcode_field *field, void *unused)
M0_INTERNAL int m0_xcode_cmp(const struct m0_xcode_obj *o0, const struct m0_xcode_obj *o1)
static void xcode_enum_loop(void)
static struct m0_thread t[8]
const struct m0_xcode_type M0_XT_VOID
static struct m0_bufvec bvec
static struct static_xt xut_un
M0_INTERNAL void m0_bufvec_cursor_init(struct m0_bufvec_cursor *cur, const struct m0_bufvec *bvec)
static int cmp(const struct m0_ut_suite **s0, const struct m0_ut_suite **s1)
void * m0_alloc(size_t size)
static int foo_length(struct m0_xcode_ctx *ctx, const void *obj)
struct tdata::_foo __attribute__((packed))
M0_INTERNAL int m0_xcode_next(struct m0_xcode_cursor *it)
static struct static_xt xut_tdef
static void xcode_flags(void)
static void t_count(struct m0_xcode_type *xt, void *data)
int m0_xcode_bitmask_print(const struct m0_xcode_enum *en, uint64_t val, char *buf, int nr)
int m0_xcode_bitmask_read(const struct m0_xcode_enum *en, const char *buf, int nr, uint64_t *val)
static void xcode_print_test(void)
M0_INTERNAL void * m0_xcode_alloc(struct m0_xcode_cursor *it, size_t nob)
static int custom_read(const struct m0_xcode_cursor *it, struct m0_xcode_obj *obj, const char *str)
const char * m0_xcode_enum_print(const struct m0_xcode_enum *en, uint64_t val, char *buf)
static void xcode_iterate(void)
const char * m0_xcode_aggr_name[M0_XA_NR]
static char pattern[CHAR_NUM]
static int foo_decode(struct m0_xcode_ctx *ctx, void *obj)
static void bitmask_read_check(uint64_t mask, int nr, bool ok, const char *buf)
const struct m0_xcode_type M0_XT_U32
static struct static_xt xut_foo
enum m0_xcode_aggr xct_aggr
M0_INTERNAL uint64_t m0_rnd64(uint64_t *seed)
static int foo_encode(struct m0_xcode_ctx *ctx, const void *obj)
struct m0_ut_suite xcode_ut
#define M0_ALLOC_PTR(ptr)
static void bitmask_print_check(uint64_t mask, int nr, bool ok, const char *out)
static void xcode_enum_print(void)
static const struct m0_xcode_type_ops read_ops
static struct m0_bufvec foo_bvec
M0_INTERNAL int m0_xcode_find(struct m0_xcode_obj *obj, const struct m0_xcode_type *xt, void **place)
M0_INTERNAL int m0_xcode_encode(struct m0_xcode_ctx *ctx)
const struct m0_xcode_type M0_XT_U8
static void literal(const char *input, const char *output)
#define IS_IN_ARRAY(idx, array)
int m0_xcode_enum_read(const struct m0_xcode_enum *en, const char *buf, int nr, uint64_t *val)
#define _T(name, str, field, ops)
static struct elevator el
static struct static_xt xut_ar
static void enum_read_check(const char *name, int nr, uint64_t v, int rc)
static void xcode_bitmask_print(void)
M0_INTERNAL void m0_xcode_ctx_init(struct m0_xcode_ctx *ctx, const struct m0_xcode_obj *obj)
static void fieldclear(struct m0_xcode_type *xt, struct m0_xcode_field *field, void *unused)
M0_INTERNAL bool m0_xcode_type_flags(struct m0_xcode_type *xt, uint32_t on, uint32_t off, uint64_t aggr_umask)
static void chk(struct m0_xcode_cursor *it, int depth, const struct m0_xcode_type *xt, void *addr, int fieldno, int elno, enum m0_xcode_cursor_flag flag)
static void f_count(struct m0_xcode_type *xt, struct m0_xcode_field *field, void *data)
static void xcode_cmp_test(void)
const struct m0_xcode_type M0_XT_U64
static void xcode_bitmask_read(void)
struct m0_xcode_field field[CHILDREN_MAX]
#define offsetof(typ, memb)
#define M0_IMPOSSIBLE(fmt,...)