mjson icon indicating copy to clipboard operation
mjson copied to clipboard

unit_test failed.

Open tercelcn opened this issue 3 years ago • 5 comments

I run the unit_test.c in arm clang. test_printf fail because "%M" point to jsonrpc_print_methods.

tercelcn avatar Jun 01 '22 07:06 tercelcn

Care to share the output?

cpq avatar Jun 05 '22 16:06 cpq

#define MJSON_ENABLE_RPC 0 run the main in unit_test.c, and run code { char *s = NULL; const char *fmt = "{\"a\":%d, \"b\":%u, \"c\":%ld, \"d\":%lu, \"e\":%M}"; ASSERT(mjson_printf(&mjson_print_dynamic_buf, &s, fmt, -1, 3456789012, (long) -1, (unsigned long) 3456789012, f1, 1234) == 60); ASSERT(s != NULL); str = "{\"a\":-1, \"b\":3456789012, \"c\":-1, \"d\":3456789012, " "\"e\":[1234]}"; ASSERT(memcmp(s, str, 60) == 0); free(s); } when code run to } else if (fc == 'M') { mjson_vprint_fn_t vfn = va_arg(*ap, mjson_vprint_fn_t); n += vfn(fn, fnd, ap); } vfn should point to f1, but vfn point to 0xCE0A6A14 which isn't a funciton.

tercelcn avatar Jun 06 '22 02:06 tercelcn

I have added an armlinux target which builds and tests on aarch64 linux - and tests pass:

make -C test armlinux

What hardware are you using? Is that a raspi or cortex-m device?

cpq avatar Jun 06 '22 23:06 cpq

My hardware is stm32f103 and mdk IDE, compiler is armclang 6.

tercelcn avatar Jun 07 '22 02:06 tercelcn

Thank you @tercelcn . Is there any chance to try it with GCC, just to narrow down the issue to armclang?

cpq avatar Jun 07 '22 03:06 cpq