From: Brian Aker Date: Mon, 8 Oct 2007 20:44:31 +0000 (-0700) Subject: Fix for bug in behavior. X-Git-Tag: 0.5~2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=e3397365efeab6e20419c29993b71989ba9d11df;p=m6w6%2Flibmemcached Fix for bug in behavior. Added tests for most of the command line apps (not much of a test... but it is a start) --- diff --git a/lib/memcached_behavior.c b/lib/memcached_behavior.c index 7383b4e2..2fce7d5f 100644 --- a/lib/memcached_behavior.c +++ b/lib/memcached_behavior.c @@ -9,31 +9,35 @@ We quit all connections so we can reset the sockets. */ +void set_behavior_flag(memcached_st *ptr, memcached_flags temp_flag, void *data) +{ + unsigned int *truefalse= (unsigned int *)data; + + memcached_quit(ptr); + if (truefalse) + ptr->flags|= temp_flag; + else + ptr->flags+= temp_flag; +} + memcached_return memcached_behavior_set(memcached_st *ptr, memcached_behavior flag, void *data) { - memcached_flags temp_flag; - switch (flag) { case MEMCACHED_BEHAVIOR_NO_BLOCK: - temp_flag= MEM_NO_BLOCK; + set_behavior_flag(ptr, MEM_NO_BLOCK, data); + break; case MEMCACHED_BEHAVIOR_TCP_NODELAY: - temp_flag= MEM_TCP_NODELAY; + set_behavior_flag(ptr, MEM_TCP_NODELAY, data); + break; case MEMCACHED_BEHAVIOR_MD5_HASHING: - temp_flag= MEM_USE_MD5; + set_behavior_flag(ptr, MEM_USE_MD5, data); + break; case MEMCACHED_BEHAVIOR_KETAMA: - temp_flag= MEM_USE_KETAMA; - { - unsigned int *truefalse= (unsigned int *)data; - memcached_quit(ptr); - if (truefalse) - ptr->flags|= temp_flag; - else - ptr->flags+= temp_flag; - break; - } + set_behavior_flag(ptr, MEM_USE_KETAMA, data); + break; } return MEMCACHED_SUCCESS; diff --git a/tests/Makefile.am b/tests/Makefile.am index e0a25e74..25b1962e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,7 +1,17 @@ INCLUDES = -I$(top_builddir)/include LDADDS = ../lib/libmemcached.la -EXTRA_DIST = output.res output2.res +EXTRA_DIST = output.res output2.res\ + r/memcat.res\ + r/memcp.res\ + r/memrm.res\ + r/memslap.res\ + r/memstat.res\ + t/memcat.test\ + t/memcp.test\ + t/memrm.test\ + t/memslap.test\ + t/memstat.test LIBS = @@ -12,6 +22,11 @@ testapp_LDADD = $(LDADDS) record: ./testapp > output.res + sh t/memcat.test > r/memcat.res + sh t/memcp.test > r/memcp.res + sh t/memrm.test > r/memrm.res + sh t/memslap.test > r/memslap.res + sh t/memstat.test > r/memstat.res record-extended: ./testapp extended > output2.res @@ -19,6 +34,16 @@ record-extended: test: testapp ./testapp > output.cmp diff output.res output.cmp + sh t/memcat.test > r/memcat.cmp + diff r/memcat.res r/memcat.cmp + sh t/memcp.test > r/memcp.cmp + diff r/memcp.res r/memcp.cmp + sh t/memrm.test > r/memrm.cmp + diff r/memrm.res r/memrm.cmp + sh t/memslap.test > r/memslap.cmp + diff r/memslap.res r/memslap.cmp + sh t/memstat.test > r/memstat.cmp + diff r/memstat.res r/memstat.cmp test-extended: testapp ./testapp extended > output.cmp diff --git a/tests/r/memcat.res b/tests/r/memcat.res new file mode 100644 index 00000000..7897d154 --- /dev/null +++ b/tests/r/memcat.res @@ -0,0 +1,19 @@ +memcat v1.0 + + Cat a set of key values to stdout. + +Current options. A '=' means the option takes a value. + + --version + Display the version of the application and then exit. + --help + Diplay this message and then exit. + --verbose + Give more details on the progression of the application. + --debug + Provide output only useful for debugging. + --servers= + List which servers you wish to connect to. + --flag + Provide flag information for storage operation. + diff --git a/tests/r/memcp.res b/tests/r/memcp.res new file mode 100644 index 00000000..991196e9 --- /dev/null +++ b/tests/r/memcp.res @@ -0,0 +1,27 @@ +memcp v1.0 + + Copy a set of files to a memcached cluster. + +Current options. A '=' means the option takes a value. + + --version + Display the version of the application and then exit. + --help + Diplay this message and then exit. + --verbose + Give more details on the progression of the application. + --debug + Provide output only useful for debugging. + --servers= + List which servers you wish to connect to. + --flag= + Provide flag information for storage operation. + --expire= + Set the expire option for the object. + --set + Use set command with memcached when storing. + --add + Use add command with memcached when storing. + --replace + Use replace command with memcached when storing. + diff --git a/tests/r/memrm.res b/tests/r/memrm.res new file mode 100644 index 00000000..853cf36d --- /dev/null +++ b/tests/r/memrm.res @@ -0,0 +1,19 @@ +memrm v1.0 + + Erase a key or set of keys from a memcached cluster. + +Current options. A '=' means the option takes a value. + + --version + Display the version of the application and then exit. + --help + Diplay this message and then exit. + --verbose + Give more details on the progression of the application. + --debug + Provide output only useful for debugging. + --servers= + List which servers you wish to connect to. + --expire= + Set the expire option for the object. + diff --git a/tests/r/memslap.res b/tests/r/memslap.res new file mode 100644 index 00000000..5d93dcea --- /dev/null +++ b/tests/r/memslap.res @@ -0,0 +1,33 @@ +memslap v1.0 + + Generates a load against a memcached custer of servers. + +Current options. A '=' means the option takes a value. + + --concurrency= + Number of users to simulate with load. + --debug + Provide output only useful for debugging. + --execute-number= + Number of times to execute the given test. + --flag + Provide flag information for storage operation. + --flush + Flush servers before running tests. + --help + Diplay this message and then exit. + --initial-load= + Number of key pairs to load before executing tests. + --non-blocking + Set TCP up to use non-blocking IO. + --servers= + List which servers you wish to connect to. + --tcp-nodelay + Set TCP socket up to use nodelay. + --test= + Test to run. + --verbose + Give more details on the progression of the application. + --version + Display the version of the application and then exit. + diff --git a/tests/r/memstat.res b/tests/r/memstat.res new file mode 100644 index 00000000..5d93dcea --- /dev/null +++ b/tests/r/memstat.res @@ -0,0 +1,33 @@ +memslap v1.0 + + Generates a load against a memcached custer of servers. + +Current options. A '=' means the option takes a value. + + --concurrency= + Number of users to simulate with load. + --debug + Provide output only useful for debugging. + --execute-number= + Number of times to execute the given test. + --flag + Provide flag information for storage operation. + --flush + Flush servers before running tests. + --help + Diplay this message and then exit. + --initial-load= + Number of key pairs to load before executing tests. + --non-blocking + Set TCP up to use non-blocking IO. + --servers= + List which servers you wish to connect to. + --tcp-nodelay + Set TCP socket up to use nodelay. + --test= + Test to run. + --verbose + Give more details on the progression of the application. + --version + Display the version of the application and then exit. + diff --git a/tests/t/memcat.test b/tests/t/memcat.test new file mode 100644 index 00000000..3ff082d6 --- /dev/null +++ b/tests/t/memcat.test @@ -0,0 +1,4 @@ +#!/bin/sh +MEMCAT="../src/memcat" + +$MEMCAT --help diff --git a/tests/t/memcp.test b/tests/t/memcp.test new file mode 100644 index 00000000..cf7728ed --- /dev/null +++ b/tests/t/memcp.test @@ -0,0 +1,3 @@ +MEMCP="../src/memcp" + +$MEMCP --help diff --git a/tests/t/memrm.test b/tests/t/memrm.test new file mode 100644 index 00000000..90da05cb --- /dev/null +++ b/tests/t/memrm.test @@ -0,0 +1,3 @@ +MEMRM="../src/memrm" + +$MEMRM --help diff --git a/tests/t/memslap.test b/tests/t/memslap.test new file mode 100644 index 00000000..999eac0a --- /dev/null +++ b/tests/t/memslap.test @@ -0,0 +1,3 @@ +MEMSLAP="../src/memslap" + +$MEMSLAP --help diff --git a/tests/t/memstat.test b/tests/t/memstat.test new file mode 100644 index 00000000..7625409d --- /dev/null +++ b/tests/t/memstat.test @@ -0,0 +1,3 @@ +MEMSTAT="../src/memslap" + +$MEMSTAT --help