diff --git a/src/Makefile b/src/Makefile index f6e5f3e3f..9b8083c06 100644 --- a/src/Makefile +++ b/src/Makefile @@ -362,10 +362,6 @@ lcov: @geninfo -o redis.info . @genhtml --legend -o lcov-html redis.info -test-sds: sds.c sds.h - $(REDIS_CC) sds.c zmalloc.c -DSDS_TEST_MAIN $(FINAL_LIBS) -o /tmp/sds_test - /tmp/sds_test - .PHONY: lcov bench: $(REDIS_BENCHMARK_NAME) diff --git a/src/sds.c b/src/sds.c index ce9cd7032..e30b33b6c 100644 --- a/src/sds.c +++ b/src/sds.c @@ -1121,13 +1121,16 @@ void *sds_malloc(size_t size) { return s_malloc(size); } void *sds_realloc(void *ptr, size_t size) { return s_realloc(ptr,size); } void sds_free(void *ptr) { s_free(ptr); } -#if defined(SDS_TEST_MAIN) +#ifdef REDIS_TEST #include #include "testhelp.h" #include "limits.h" #define UNUSED(x) (void)(x) -int sdsTest(void) { +int sdsTest(int argc, char **argv) { + UNUSED(argc); + UNUSED(argv); + { sds x = sdsnew("foo"), y; @@ -1254,7 +1257,8 @@ int sdsTest(void) { { unsigned int oldfree; char *p; - int step = 10, j, i; + int i; + size_t step = 10, j; sdsfree(x); sdsfree(y); @@ -1264,7 +1268,7 @@ int sdsTest(void) { /* Run the test a few times in order to hit the first two * SDS header types. */ for (i = 0; i < 10; i++) { - int oldlen = sdslen(x); + size_t oldlen = sdslen(x); x = sdsMakeRoomFor(x,step); int type = x[-1]&SDS_TYPE_MASK; @@ -1272,6 +1276,7 @@ int sdsTest(void) { if (type != SDS_TYPE_5) { test_cond("sdsMakeRoomFor() free", sdsavail(x) >= step); oldfree = sdsavail(x); + UNUSED(oldfree); } p = x+oldlen; for (j = 0; j < step; j++) { @@ -1290,9 +1295,3 @@ int sdsTest(void) { return 0; } #endif - -#ifdef SDS_TEST_MAIN -int main(void) { - return sdsTest(); -} -#endif diff --git a/src/server.c b/src/server.c index 24238c595..956cad587 100644 --- a/src/server.c +++ b/src/server.c @@ -5247,6 +5247,8 @@ int main(int argc, char **argv) { return crc64Test(argc, argv); } else if (!strcasecmp(argv[2], "zmalloc")) { return zmalloc_test(argc, argv); + } else if (!strcasecmp(argv[2], "sds")) { + return sdsTest(argc, argv); } return -1; /* test not found */