Fix for bug in behavior.
authorBrian Aker <brian@tangent.org>
Mon, 8 Oct 2007 20:44:31 +0000 (13:44 -0700)
committerBrian Aker <brian@tangent.org>
Mon, 8 Oct 2007 20:44:31 +0000 (13:44 -0700)
Added tests for most of the command line apps (not much of a test... but it
is a start)

12 files changed:
lib/memcached_behavior.c
tests/Makefile.am
tests/r/memcat.res [new file with mode: 0644]
tests/r/memcp.res [new file with mode: 0644]
tests/r/memrm.res [new file with mode: 0644]
tests/r/memslap.res [new file with mode: 0644]
tests/r/memstat.res [new file with mode: 0644]
tests/t/memcat.test [new file with mode: 0644]
tests/t/memcp.test [new file with mode: 0644]
tests/t/memrm.test [new file with mode: 0644]
tests/t/memslap.test [new file with mode: 0644]
tests/t/memstat.test [new file with mode: 0644]

index 7383b4e22d400c85a8f444e4c6c2923e19370bc0..2fce7d5f100b437fce8fed138170bdd2785ba252 100644 (file)
@@ -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;
index e0a25e740fe77b97459ea1c18ef1dc5a449c5695..25b1962e3ab5a18206a89190d0cbaf83e9dbfb06 100644 (file)
@@ -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 (file)
index 0000000..7897d15
--- /dev/null
@@ -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 (file)
index 0000000..991196e
--- /dev/null
@@ -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 (file)
index 0000000..853cf36
--- /dev/null
@@ -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 (file)
index 0000000..5d93dce
--- /dev/null
@@ -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 (file)
index 0000000..5d93dce
--- /dev/null
@@ -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 (file)
index 0000000..3ff082d
--- /dev/null
@@ -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 (file)
index 0000000..cf7728e
--- /dev/null
@@ -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 (file)
index 0000000..90da05c
--- /dev/null
@@ -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 (file)
index 0000000..999eac0
--- /dev/null
@@ -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 (file)
index 0000000..7625409
--- /dev/null
@@ -0,0 +1,3 @@
+MEMSTAT="../src/memslap"
+
+$MEMSTAT --help