[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH RFC V2 09/10] libxl/gentest.py: test JSON parser
On Thu, 2014-04-17 at 12:13 +0100, Wei Liu wrote: > @@ -240,20 +241,36 @@ int main(int argc, char **argv) > exit(1); > } > """) > - f.write(" printf(\"Testing TYPE_to_json()\\n\");\n") > + f.write(" printf(\"Testing TYPE_to/from_json()\\n\");\n") > f.write(" printf(\"----------------------\\n\");\n") > f.write(" printf(\"\\n\");\n") > for ty in [t for t in types if t.json_gen_fn is not None]: > arg = ty.typename + "_val" > f.write(" %s_rand_init(%s);\n" % (ty.typename, \ > ty.pass_arg(arg, isref=False, passby=idl.PASS_BY_REFERENCE))) > + if not isinstance(ty, idl.Enumeration): > + f.write(" %s_init(%s_new);\n" % (ty.typename, \ > + ty.pass_arg(arg, isref=False, passby=idl.PASS_BY_REFERENCE))) > f.write(" s = %s_to_json(ctx, %s);\n" % \ > (ty.typename, ty.pass_arg(arg, isref=False))) > f.write(" printf(\"%%s: %%s\\n\", \"%s\", s);\n" % ty.typename) > f.write(" if (s == NULL) abort();\n") > + f.write(" rc = %s_from_json(ctx, &%s_val_new, s);\n" % \ > + (ty.typename, ty.typename)) > + f.write(" if (rc) abort();\n") > + f.write(" new_s = %s_to_json(ctx, %s_new);\n" % \ > + (ty.typename, ty.pass_arg(arg, isref=False))) > + f.write(" if (new_s == NULL) abort();\n") > + f.write(" if (strcmp(s, new_s)) {\n") > + f.write(" printf(\"Huh? Regenerated string different from > original string.\\n\");\n") > + f.write(" printf(\"Regenerated string: %s\\n\", new_s);\n") This could use some hint as to which struct went wrong. Perhaps including the original string too for comparison? _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |