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/zipmap.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/zipmap.c')
-rw-r--r-- | src/zipmap.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/zipmap.c b/src/zipmap.c index 384b76bba..22bfa1a46 100644 --- a/src/zipmap.c +++ b/src/zipmap.c @@ -370,8 +370,8 @@ size_t zipmapBlobLen(unsigned char *zm) { return totlen; } -#ifdef ZIPMAP_TEST_MAIN -void zipmapRepr(unsigned char *p) { +#ifdef REDIS_TEST +static void zipmapRepr(unsigned char *p) { unsigned int l; printf("{status %u}",*p++); @@ -404,9 +404,13 @@ void zipmapRepr(unsigned char *p) { printf("\n"); } -int main(void) { +#define UNUSED(x) (void)(x) +int zipmapTest(int argc, char *argv[]) { unsigned char *zm; + UNUSED(argc); + UNUSED(argv); + zm = zipmapNew(); zm = zipmapSet(zm,(unsigned char*) "name",4, (unsigned char*) "foo",3,NULL); |