diff options
author | Matt Stancliff <matt@genges.com> | 2014-11-12 21:58:57 -0500 |
---|---|---|
committer | Matt Stancliff <matt@genges.com> | 2014-12-23 09:31:03 -0500 |
commit | 8febcffdc597566f1e307c0534014b2bdf687c02 (patch) | |
tree | 74cf78291298cce2dfc1abf5fe1c25aacd86aa4f /src/ziplist.c | |
parent | 8380655e85f0afd1f0afc99b464717cb97002b7a (diff) | |
download | redis-8febcffdc597566f1e307c0534014b2bdf687c02.tar.gz |
Allow all code tests to run using Redis args
Previously, many files had individual main() functions for testing,
but each required being compiled with their own testing flags.
That gets difficult when you have 8 different flags you need
to set just to run all tests (plus, some test files required
other files to be compiled aaginst them, and it seems some didn't
build at all without including the rest of Redis).
Now all individual test main() funcions are renamed to a test
function for the file itself and one global REDIS_TEST define enables
testing across the entire codebase.
Tests can now be run with:
- `./redis-server test <test>`
e.g. ./redis-server test ziplist
If REDIS_TEST is not defined, then no tests get included and no
tests are included in the final redis-server binary.
Diffstat (limited to 'src/ziplist.c')
-rw-r--r-- | src/ziplist.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/ziplist.c b/src/ziplist.c index 41d9cb20c..3ff44c5b8 100644 --- a/src/ziplist.c +++ b/src/ziplist.c @@ -952,14 +952,14 @@ void ziplistRepr(unsigned char *zl) { printf("{end}\n\n"); } -#ifdef ZIPLIST_TEST_MAIN +#ifdef REDIS_TEST #include <sys/time.h> #include "adlist.h" #include "sds.h" #define debug(f, ...) { if (DEBUG) printf(f, __VA_ARGS__); } -unsigned char *createList() { +static unsigned char *createList() { unsigned char *zl = ziplistNew(); zl = ziplistPush(zl, (unsigned char*)"foo", 3, ZIPLIST_TAIL); zl = ziplistPush(zl, (unsigned char*)"quux", 4, ZIPLIST_TAIL); @@ -968,7 +968,7 @@ unsigned char *createList() { return zl; } -unsigned char *createIntList() { +static unsigned char *createIntList() { unsigned char *zl = ziplistNew(); char buf[32]; @@ -987,13 +987,13 @@ unsigned char *createIntList() { return zl; } -long long usec(void) { +static long long usec(void) { struct timeval tv; gettimeofday(&tv,NULL); return (((long long)tv.tv_sec)*1000000)+tv.tv_usec; } -void stress(int pos, int num, int maxsize, int dnum) { +static void stress(int pos, int num, int maxsize, int dnum) { int i,j,k; unsigned char *zl; char posstr[2][5] = { "HEAD", "TAIL" }; @@ -1016,7 +1016,7 @@ void stress(int pos, int num, int maxsize, int dnum) { } } -void pop(unsigned char *zl, int where) { +static void pop(unsigned char *zl, int where) { unsigned char *p, *vstr; unsigned int vlen; long long vlong; @@ -1043,7 +1043,7 @@ void pop(unsigned char *zl, int where) { } } -int randstring(char *target, unsigned int min, unsigned int max) { +static int randstring(char *target, unsigned int min, unsigned int max) { int p = 0; int len = min+rand()%(max-min+1); int minval, maxval; @@ -1069,7 +1069,7 @@ int randstring(char *target, unsigned int min, unsigned int max) { return len; } -void verify(unsigned char *zl, zlentry *e) { +static void verify(unsigned char *zl, zlentry *e) { int i; int len = ziplistLen(zl); zlentry _e; @@ -1085,7 +1085,7 @@ void verify(unsigned char *zl, zlentry *e) { } } -int main(int argc, char **argv) { +int ziplistTest(int argc, char **argv) { unsigned char *zl, *p; unsigned char *entry; unsigned int elen; @@ -1534,5 +1534,4 @@ int main(int argc, char **argv) { return 0; } - #endif |