Date: Tue, 27 Aug 2013 11:41:06 GMT From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r256618 - in soc2013/dpl/head/lib/libzcap: . test zlibworker Message-ID: <201308271141.r7RBf6a4057185@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dpl Date: Tue Aug 27 11:41:06 2013 New Revision: 256618 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256618 Log: Still have a bug related to nvlist send'ing/recv'ing. The tests work perfectly with libz, tough. I have to test more functions now. Modified: soc2013/dpl/head/lib/libzcap/commands.c soc2013/dpl/head/lib/libzcap/test/zcaplibtest.c soc2013/dpl/head/lib/libzcap/zlibworker/commands.c Modified: soc2013/dpl/head/lib/libzcap/commands.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/commands.c Tue Aug 27 06:50:46 2013 (r256617) +++ soc2013/dpl/head/lib/libzcap/commands.c Tue Aug 27 11:41:06 2013 (r256618) @@ -1049,9 +1049,7 @@ nvlist_add_number(args, "len", len); nvlist_add_nvlist(nvl, "args", args); - fprintf(stderr, "libzcap: Before sendCommand(): nvl:%p\n", nvl); result = sendCommand(nvl); - fprintf(stderr, "libzcap: After sendCommand(): result:%p\n", result); ret = nvlist_take_number(result, "result"); destroy(); Modified: soc2013/dpl/head/lib/libzcap/test/zcaplibtest.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/test/zcaplibtest.c Tue Aug 27 06:50:46 2013 (r256617) +++ soc2013/dpl/head/lib/libzcap/test/zcaplibtest.c Tue Aug 27 11:41:06 2013 (r256618) @@ -18,6 +18,7 @@ void testchecksums(void); +#define SIZEOFDATA 10*1024 int i; char *data; z_streamp strmdef; @@ -25,14 +26,13 @@ int main() { - if ( (data = malloc(10*1024)) == NULL) + if ( (data = malloc(SIZEOFDATA)) == NULL) err(1, "zcaplibtest: malloc()"); - for (i=0; i < (10*1024); i+=sizeof(long)) - data[i] = rand(); + for (i=0; i < SIZEOFDATA; i+=sizeof(long)) + data[i] = i; printf("This is a zcaplib program tester.\n"); - printf("I will now test all the zcaplib functions.\n\n"); if ( (strmdef = calloc(1, sizeof (z_stream))) == NULL) err(1, "zcaplibtest: malloc()"); @@ -59,11 +59,12 @@ void testdeflateInit(z_streamp strm) { - printf("deflateInit()\t...\t"); - deflateInit(strm, Z_DEFAULT_COMPRESSION); - if (strm->state != NULL) + printf("deflateInit(): "); + int ret = deflateInit(strm, Z_DEFAULT_COMPRESSION); + if (strm->state != NULL || ret == 0) printf("OK\n"); else printf("Error"); + printf("deflateInit %d\n", ret); return; } @@ -76,27 +77,25 @@ void testdeflateEnd(z_streamp strm) { - printf("deflateEnd()\t...\t"); - // XXX - strm->state = (void *)1; + printf("deflateEnd(): "); int ret = deflateEnd(strm); - if (strm->state == Z_NULL ) + if (strm->state == Z_NULL || ret == 0) printf("OK\n"); else printf("Error\n"); - printf("deflateEnd: %d", ret); + printf("deflateEnd %d\n", ret); return; } void testinflateInit(z_streamp strm) { - printf("inflateInit()\t...\t"); + printf("inflateInit(): "); int ret = inflateInit(strm); - if (strm->state != NULL) + if (strm->state != NULL || ret == 0) printf("OK\n"); else printf("Error"); - printf("inflateInit: %d", ret); + printf("inflateInit %d\n", ret); return; } @@ -110,20 +109,26 @@ void testinflateEnd(z_streamp strm) { + printf("inflateEnd(): "); + int ret = inflateEnd(strm); + if (strm->state == Z_NULL || ret == 0) + printf("OK\n"); + else + printf("Error\n"); + printf("deflateEnd %d\n", ret); return; } void testzlibCompileFlags(void) { + printf("zlibCompileFlags(): "); uLong ret = zlibCompileFlags(); - - printf("zlibCompileFlags()\t...\t"); if ( ret > 0) printf("OK\n"); else err(1, "Error\n"); - printf("zlibCompileFlags: %lu\n", ret); + printf("zlibCompileFlags %lu\n", ret); return; } @@ -131,65 +136,64 @@ void testCompressBound(void) { + printf("compressBound(): "); uLong ret = compressBound(10L); - printf("compressBound()\t...\t"); - - if (ret) printf("OK\n"); - else printf("Error\n"); - printf("Compressbound: %lu\n", ret); + if (ret) printf("%lu\n", ret); + else printf("-1\n"); return; } void testchecksums(void) { - uLong first, second, combined; - first = second = combined = 0; + /* + * first, second: checksum of the first,second half of the data buffer. + * allone, alltwo: checksum of the whole buffer in one,two call(s). + */ + uLong first, second, combined, allone, alltwo; + first = second = combined = allone = alltwo = 0L; /* adler32 */ - first = adler32(0L, Z_NULL, 0); - printf("adler32: %ld\n", first ); - first = adler32(first, (void *)data, 5*1024); - printf("adler32: %ld\n", first ); - second = adler32(first, (void *)(data+5*1024), 5*1024); - printf("adler32: %ld\n", second ); - - combined = adler32_combine(first, second, 5*1024); - printf("adler32_combine(): %ld\n", combined ); - - printf("adler32\t...\t"); - if (second == combined) - printf("OK\n"); + uLong adler = adler32(0L, Z_NULL, 0); + first = adler32(adler, (void *)data, SIZEOFDATA/2); + second = adler32(adler, (void *)(data+SIZEOFDATA/2), SIZEOFDATA/2); + alltwo = adler32(first, (void *)(data+SIZEOFDATA/2), SIZEOFDATA/2); + allone = adler32(adler, (void *)(data), SIZEOFDATA); + + combined = adler32_combine(first, second, SIZEOFDATA/2); + + printf("adler32(): "); + if (alltwo == allone) + printf("%lu\n", alltwo); else - printf("Error\n"); + printf("-1\n"); - printf("adler32_combine()\t...\t"); - if (second == combined) - printf("OK\n"); + printf("adler32_combine(): "); + if (allone == combined) + printf("%lu\n", combined); else - printf("Error\n"); + printf("-1\n"); /* crc32 */ - first = second = combined = 0; - first = crc32(0L, Z_NULL, 0); - printf("crc32: %ld\n", first ); - first = crc32(first, (void *)data, 5*1024); - printf("crc32: %ld\n", first ); - second = crc32(first, (void *)(data+5*1024), 5*1024); - printf("crc32: %ld\n", second ); - - combined = crc32_combine(first, second, 5*1024); - printf("crc32_combine(): %ld\n", combined ); + first = second = combined = allone = alltwo = 0L; - printf("crc32\t...\t"); - if (second == combined) - printf("OK\n"); + uLong crc = crc32(0L, Z_NULL, 0); + first = crc32(crc, (void *)data, SIZEOFDATA/2); + second = crc32(crc, (void *)(data+SIZEOFDATA/2), SIZEOFDATA/2); + alltwo = crc32(first, (void *)(data+SIZEOFDATA/2), SIZEOFDATA/2); + allone = crc32(crc, (void *)(data), SIZEOFDATA); + + combined = crc32_combine(first, second, SIZEOFDATA/2); + + printf("crc32(): "); + if (alltwo == allone) + printf("%lu\n", alltwo); else - printf("Error\n"); + printf("-1\n"); - printf("crc32_combine()\t...\t"); - if (second == combined) - printf("OK\n"); + printf("crc32_combine(): "); + if (allone == combined) + printf("%lu\n", combined); else - printf("Error\n"); + printf("-1\n"); } \ No newline at end of file Modified: soc2013/dpl/head/lib/libzcap/zlibworker/commands.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/zlibworker/commands.c Tue Aug 27 06:50:46 2013 (r256617) +++ soc2013/dpl/head/lib/libzcap/zlibworker/commands.c Tue Aug 27 11:41:06 2013 (r256618) @@ -474,12 +474,11 @@ zcapcmd_adler32_combine(nvlist_t *args, nvlist_t *result) { uLong ret = -1; - - ret = adler32_combine( - nvlist_take_number(args, "adler1"), - nvlist_take_number(args, "adler2"), - nvlist_take_number(args, "len2") - ); + uLong adler1 = nvlist_take_number(args, "adler1"); + uLong adler2 = nvlist_take_number(args, "adler2"); + z_off_t len2 = nvlist_take_number(args, "len2"); + ret = adler32_combine(adler1, adler2, len2); + fprintf("zlibworker: adler32_combine: %d\n", ret); nvlist_add_number(result, "result", ret ); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308271141.r7RBf6a4057185>