diff options
author | Alex Gorrod <alexander.gorrod@mongodb.com> | 2016-04-29 20:34:36 +1000 |
---|---|---|
committer | Keith Bostic <keith.bostic@mongodb.com> | 2016-04-29 06:34:36 -0400 |
commit | 66cc8d47963297f066f13900cd264de1cfa08f3a (patch) | |
tree | dd63c55087df80f02a186510cb79d8b09ad7b9ec | |
parent | 770d7f0f6e64b6b93b21dddc69308dc86e289f97 (diff) | |
download | mongo-66cc8d47963297f066f13900cd264de1cfa08f3a.tar.gz |
WT-2595 Fix compiler warning in packing test. (#2704)
While here switch from using asserts to test util functions.
-rw-r--r-- | test/packing/Makefile.am | 3 | ||||
-rw-r--r-- | test/packing/intpack-test.c | 8 | ||||
-rw-r--r-- | test/packing/intpack-test2.c | 8 | ||||
-rw-r--r-- | test/packing/intpack-test3.c | 13 | ||||
-rw-r--r-- | test/packing/packing-test.c | 11 |
5 files changed, 26 insertions, 17 deletions
diff --git a/test/packing/Makefile.am b/test/packing/Makefile.am index a9e7e16e5c2..0e7c8cc8b2e 100644 --- a/test/packing/Makefile.am +++ b/test/packing/Makefile.am @@ -1,4 +1,5 @@ -AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir)/src/include +AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir)/src/include \ + -I$(top_srcdir)/test/utility noinst_PROGRAMS = intpack-test intpack-test2 intpack-test3 packing-test LDADD = $(top_builddir)/libwiredtiger.la diff --git a/test/packing/intpack-test.c b/test/packing/intpack-test.c index 08cc3807725..62d2b21a368 100644 --- a/test/packing/intpack-test.c +++ b/test/packing/intpack-test.c @@ -27,8 +27,9 @@ */ #include "wt_internal.h" /* For __wt_XXX */ +#include "test_util.i" -#include <assert.h> +void (*custom_die)(void) = NULL; int main(void) @@ -47,9 +48,10 @@ main(void) #if 1 p = buf; - assert(__wt_vpack_uint(&p, sizeof(buf), r) == 0); + testutil_check(__wt_vpack_uint(&p, sizeof(buf), r)); cp = buf; - assert(__wt_vunpack_uint(&cp, sizeof(buf), &r2) == 0); + testutil_check( + __wt_vunpack_uint(&cp, sizeof(buf), &r2)); #else /* * Note: use memmove for comparison because GCC does diff --git a/test/packing/intpack-test2.c b/test/packing/intpack-test2.c index 7555d2724e7..4183bea0821 100644 --- a/test/packing/intpack-test2.c +++ b/test/packing/intpack-test2.c @@ -27,8 +27,9 @@ */ #include "wt_internal.h" /* For __wt_XXX */ +#include "test_util.i" -#include <assert.h> +void (*custom_die)(void) = NULL; int main(void) @@ -38,14 +39,15 @@ main(void) for (i = 1; i < 1LL << 60; i <<= 1) { end = buf; - assert(__wt_vpack_uint(&end, sizeof(buf), (uint64_t)i) == 0); + testutil_check( + __wt_vpack_uint(&end, sizeof(buf), (uint64_t)i)); printf("%" PRId64 " ", i); for (p = buf; p < end; p++) printf("%02x", *p); printf("\n"); end = buf; - assert(__wt_vpack_int(&end, sizeof(buf), -i) == 0); + testutil_check(__wt_vpack_int(&end, sizeof(buf), -i)); printf("%" PRId64 " ", -i); for (p = buf; p < end; p++) printf("%02x", *p); diff --git a/test/packing/intpack-test3.c b/test/packing/intpack-test3.c index 2ebc01f9e2e..1c62fcca132 100644 --- a/test/packing/intpack-test3.c +++ b/test/packing/intpack-test3.c @@ -27,8 +27,9 @@ */ #include "wt_internal.h" /* For __wt_XXX */ +#include "test_util.i" -#include <assert.h> +void (*custom_die)(void) = NULL; void test_value(int64_t); void test_spread(int64_t, int64_t, int64_t); @@ -43,11 +44,12 @@ test_value(int64_t val) size_t used_len; sinput = val; + soutput = 0; /* Make GCC happy. */ p = buf; - assert(__wt_vpack_int(&p, sizeof(buf), sinput) == 0); + testutil_check(__wt_vpack_int(&p, sizeof(buf), sinput)); used_len = (size_t)(p - buf); cp = buf; - assert(__wt_vunpack_int(&cp, used_len, &soutput) == 0); + testutil_check(__wt_vunpack_int(&cp, used_len, &soutput)); /* Ensure we got the correct value back */ if (sinput != soutput) { fprintf(stderr, "mismatch %" PRIu64 ", %" PRIu64 "\n", @@ -69,10 +71,9 @@ test_value(int64_t val) uinput = (uint64_t)val; p = buf; - assert(__wt_vpack_uint(&p, sizeof(buf), uinput) == 0); + testutil_check(__wt_vpack_uint(&p, sizeof(buf), uinput)); cp = buf; - assert(__wt_vunpack_uint( - &cp, sizeof(buf), &uoutput) == 0); + testutil_check(__wt_vunpack_uint(&cp, sizeof(buf), &uoutput)); /* Ensure we got the correct value back */ if (sinput != soutput) { fprintf(stderr, "mismatch %" PRIu64 ", %" PRIu64 "\n", diff --git a/test/packing/packing-test.c b/test/packing/packing-test.c index 9b7105d7d4a..4703648aac4 100644 --- a/test/packing/packing-test.c +++ b/test/packing/packing-test.c @@ -27,8 +27,9 @@ */ #include "wt_internal.h" /* For __wt_XXX */ +#include "test_util.i" -#include <assert.h> +void (*custom_die)(void) = NULL; static void check(const char *fmt, ...) @@ -40,13 +41,15 @@ check(const char *fmt, ...) len = 0; /* -Werror=maybe-uninitialized */ va_start(ap, fmt); - assert(__wt_struct_sizev(NULL, &len, fmt, ap) == 0); + testutil_check(__wt_struct_sizev(NULL, &len, fmt, ap)); va_end(ap); - assert(len > 0 && len < sizeof(buf)); + if (len < 1 || len >= sizeof(buf)) + testutil_die(EINVAL, + "Unexpected length from __wt_struct_sizev"); va_start(ap, fmt); - assert(__wt_struct_packv(NULL, buf, sizeof(buf), fmt, ap) == 0); + testutil_check(__wt_struct_packv(NULL, buf, sizeof(buf), fmt, ap)); va_end(ap); printf("%s ", fmt); |