static void test_noop(void) { int ret; lwres_lwpacket_t pkt, pkt2; lwres_nooprequest_t nooprequest, *nooprequest2; lwres_noopresponse_t noopresponse, *noopresponse2; lwres_buffer_t b; pkt.pktflags = 0; pkt.serial = 0x11223344; pkt.recvlength = 0x55667788; pkt.result = 0; nooprequest.datalength = strlen(TESTSTRING); /* XXXDCL maybe "nooprequest.data" should be const. */ DE_CONST(TESTSTRING, nooprequest.data); ret = lwres_nooprequest_render(ctx, &nooprequest, &pkt, &b); CHECK(ret, "lwres_nooprequest_render"); hexdump("rendered noop request", b.base, b.used); /* * Now, parse it into a new structure. */ lwres_buffer_first(&b); ret = lwres_lwpacket_parseheader(&b, &pkt2); CHECK(ret, "lwres_lwpacket_parseheader"); hexdump("parsed pkt2", &pkt2, sizeof(pkt2)); nooprequest2 = NULL; ret = lwres_nooprequest_parse(ctx, &b, &pkt2, &nooprequest2); CHECK(ret, "lwres_nooprequest_parse"); assert(nooprequest.datalength == nooprequest2->datalength); assert(memcmp(nooprequest.data, nooprequest2->data, nooprequest.datalength) == 0); lwres_nooprequest_free(ctx, &nooprequest2); lwres_context_freemem(ctx, b.base, b.length); b.base = NULL; b.length = 0; pkt.pktflags = 0; pkt.serial = 0x11223344; pkt.recvlength = 0x55667788; pkt.result = 0xdeadbeef; noopresponse.datalength = strlen(TESTSTRING); /* XXXDCL maybe "noopresponse.data" should be const. */ DE_CONST(TESTSTRING, noopresponse.data); ret = lwres_noopresponse_render(ctx, &noopresponse, &pkt, &b); CHECK(ret, "lwres_noopresponse_render"); hexdump("rendered noop response", b.base, b.used); /* * Now, parse it into a new structure. */ lwres_buffer_first(&b); ret = lwres_lwpacket_parseheader(&b, &pkt2); CHECK(ret, "lwres_lwpacket_parseheader"); hexdump("parsed pkt2", &pkt2, sizeof(pkt2)); noopresponse2 = NULL; ret = lwres_noopresponse_parse(ctx, &b, &pkt2, &noopresponse2); CHECK(ret, "lwres_noopresponse_parse"); assert(noopresponse.datalength == noopresponse2->datalength); assert(memcmp(noopresponse.data, noopresponse2->data, noopresponse.datalength) == 0); lwres_noopresponse_free(ctx, &noopresponse2); lwres_context_freemem(ctx, b.base, b.length); b.base = NULL; b.length = 0; }
static void test_noop(void) { lwres_result_t ret; lwres_lwpacket_t pkt, pkt2; lwres_nooprequest_t nooprequest, *nooprequest2; lwres_noopresponse_t noopresponse, *noopresponse2; lwres_buffer_t b; pkt.pktflags = 0; pkt.serial = 0x11223344; pkt.recvlength = 0x55667788; pkt.result = 0; nooprequest.datalength = strlen((char *)TESTSTRING); nooprequest.data = TESTSTRING; ret = lwres_nooprequest_render(ctx, &nooprequest, &pkt, &b); CHECK(ret, "lwres_nooprequest_render"); /* * Now, parse it into a new structure. */ lwres_buffer_first(&b); ret = lwres_lwpacket_parseheader(&b, &pkt2); CHECK(ret, "lwres_lwpacket_parseheader"); nooprequest2 = NULL; ret = lwres_nooprequest_parse(ctx, &b, &pkt2, &nooprequest2); CHECK(ret, "lwres_nooprequest_parse"); assert(nooprequest.datalength == nooprequest2->datalength); assert(memcmp(nooprequest.data, nooprequest2->data, nooprequest.datalength) == 0); lwres_nooprequest_free(ctx, &nooprequest2); lwres_context_freemem(ctx, b.base, b.length); b.base = NULL; b.length = 0; pkt.pktflags = 0; pkt.serial = 0x11223344; pkt.recvlength = 0x55667788; pkt.result = 0xdeadbeef; noopresponse.datalength = strlen((char *)TESTSTRING); noopresponse.data = TESTSTRING; ret = lwres_noopresponse_render(ctx, &noopresponse, &pkt, &b); CHECK(ret, "lwres_noopresponse_render"); /* * Now, parse it into a new structure. */ lwres_buffer_first(&b); ret = lwres_lwpacket_parseheader(&b, &pkt2); CHECK(ret, "lwres_lwpacket_parseheader"); noopresponse2 = NULL; ret = lwres_noopresponse_parse(ctx, &b, &pkt2, &noopresponse2); CHECK(ret, "lwres_noopresponse_parse"); assert(noopresponse.datalength == noopresponse2->datalength); assert(memcmp(noopresponse.data, noopresponse2->data, noopresponse.datalength) == 0); lwres_noopresponse_free(ctx, &noopresponse2); lwres_context_freemem(ctx, b.base, b.length); b.base = NULL; b.length = 0; }