Merge lp:~tangent-org/libmemcached/1.0-build/ Build: jenkins-Libmemcached-170
[awesomized/libmemcached] / tests / mem_udp.cc
index 846d2bfdea9bbdba3facd0a8dc4be2a0e7b315f4..d59244715f7e127af7812487c9d8bfe5a6b8f245 100644 (file)
@@ -1,27 +1,59 @@
-/* libMemcached Functions Test
- * Copyright (C) 2006-2009 Brian Aker
- * All rights reserved.
+/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ * 
+ *  Libmemcached library
+ *
+ *  Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *  Copyright (C) 2006-2009 Brian Aker All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are
+ *  met:
+ *
+ *      * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ *
+ *      * Redistributions in binary form must reproduce the above
+ *  copyright notice, this list of conditions and the following disclaimer
+ *  in the documentation and/or other materials provided with the
+ *  distribution.
+ *
+ *      * The names of its contributors may not be used to endorse or
+ *  promote products derived from this software without specific prior
+ *  written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * Use and distribution licensed under the BSD license.  See
- * the COPYING file in the parent directory for full text.
  */
 
+
 /*
   Sample test application.
 */
 
-#include <config.h>
+#include <mem_config.h>
 #include <libtest/test.hpp>
 
 using namespace libtest;
 
-#include <libmemcached/common.h>
+#include <libmemcached-1.0/memcached.h>
+#include <libmemcached/server_instance.h>
+#include <libmemcached/io.h>
+#include <libmemcached/udp.hpp>
+#include <libmemcachedutil-1.0/util.h>
 
-#include <assert.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
 #include <sys/time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -31,7 +63,7 @@ using namespace libtest;
 
 #include <libtest/server.h>
 
-#define SERVERS_TO_CREATE 5
+#include "libmemcached/instance.hpp"
 
 #ifndef __INTEL_COMPILER
 #pragma GCC diagnostic ignored "-Wstrict-aliasing"
@@ -42,54 +74,45 @@ using namespace libtest;
 */
 static test_return_t pre_binary(memcached_st *memc)
 {
-  memcached_return_t rc= MEMCACHED_FAILURE;
-  memcached_st *memc_clone;
-  memcached_server_instance_st instance;
-
-  memc_clone= memcached_clone(NULL, memc);
+  memcached_st *memc_clone= memcached_clone(NULL, memc);
   test_true(memc_clone);
+
   // The memcached_version needs to be done on a clone, because the server
   // will not toggle protocol on an connection.
   memcached_version(memc_clone);
 
-  instance= memcached_server_instance_by_position(memc_clone, 0);
-
-  if (instance->major_version >= 1 && instance->minor_version > 2)
-  {
-    rc = memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1);
-    test_true(rc == MEMCACHED_SUCCESS);
-    test_true(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == 1);
-  }
+  test_compare(MEMCACHED_SUCCESS, memcached_version(memc));
+  test_compare(true, libmemcached_util_version_check(memc, 1, 2, 1));
+  test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, true));
+  test_compare(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
 
   memcached_free(memc_clone);
 
-  return rc == MEMCACHED_SUCCESS ? TEST_SUCCESS : TEST_SKIPPED;
+  return TEST_SUCCESS;
 }
 
+typedef std::vector<uint16_t> Expected;
+
 static void increment_request_id(uint16_t *id)
 {
   (*id)++;
   if ((*id & UDP_REQUEST_ID_THREAD_MASK) != 0)
+  {
     *id= 0;
+  }
 }
 
-static uint16_t *get_udp_request_ids(memcached_st *memc)
+static void get_udp_request_ids(memcached_st *memc, Expected &ids)
 {
-  uint16_t *ids= (uint16_t*)malloc(sizeof(uint16_t) * memcached_server_count(memc));
-  assert(ids);
-
   for (uint32_t x= 0; x < memcached_server_count(memc); x++)
   {
-    memcached_server_instance_st instance=
-      memcached_server_instance_by_position(memc, x);
+    memcached_server_instance_st instance= memcached_server_instance_by_position(memc, x);
 
-    ids[x]= get_udp_datagram_request_id((struct udp_datagram_header_st *) ((memcached_server_instance_st )instance)->write_buffer);
+    ids.push_back(get_udp_datagram_request_id((struct udp_datagram_header_st *) ((memcached_server_instance_st )instance)->write_buffer));
   }
-
-  return ids;
 }
 
-static test_return_t post_udp_op_check(memcached_st *memc, uint16_t *expected_req_ids)
+static test_return_t post_udp_op_check(memcached_st *memc, Expected& expected_req_ids)
 {
   (void)memc;
   (void)expected_req_ids;
@@ -115,49 +138,31 @@ static test_return_t post_udp_op_check(memcached_st *memc, uint16_t *expected_re
 **/
 static test_return_t init_udp(memcached_st *memc)
 {
-  memcached_version(memc);
-#if 0
-  memcached_server_instance_st instance=
-    memcached_server_instance_by_position(memc, 0);
+  test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP, true));
 
-  /* For the time being, only support udp test for >= 1.2.6 && < 1.3 */
-  if (instance->major_version != 1 || instance->minor_version != 2
-          || instance->micro_version < 6)
-    return TEST_SKIPPED;
+  return TEST_SUCCESS;
+}
 
-  uint32_t num_hosts= memcached_server_count(memc);
-  memcached_server_st servers[num_hosts];
-  memcpy(servers, memcached_server_list(memc), sizeof(memcached_server_st) * num_hosts);
-  for (uint32_t x= 0; x < num_hosts; x++)
+static test_return_t init_udp_valgrind(memcached_st *memc)
+{
+  if (getenv("TESTS_ENVIRONMENT"))
   {
-   memcached_server_instance_st set_instance=
-     memcached_server_instance_by_position(memc, x);
-
-    memcached_server_free(((memcached_server_write_instance_st)set_instance));
+    return TEST_SKIPPED; 
   }
 
-  memc->number_of_hosts= 0;
-  memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP, 1);
-  for (uint32_t x= 0; x < num_hosts; x++)
-  {
-    memcached_server_instance_st set_instance=
-      memcached_server_instance_by_position(memc, x);
-
-    test_true(memcached_server_add_udp(memc, servers[x].hostname, servers[x].port) == MEMCACHED_SUCCESS);
-    test_true(set_instance->write_buffer_offset == UDP_DATAGRAM_HEADER_LENGTH);
-  }
-#endif
+  test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP, true));
 
-  return TEST_SKIPPED;
+  return TEST_SUCCESS;
 }
 
 static test_return_t binary_init_udp(memcached_st *memc)
 {
-  test_return_t test_rc;
-  test_rc= pre_binary(memc);
+  if (getenv("TESTS_ENVIRONMENT"))
+  {
+    return TEST_SKIPPED; 
+  }
 
-  if (test_rc != TEST_SUCCESS)
-    return test_rc;
+  test_skip(TEST_SUCCESS, pre_binary(memc));
 
   return init_udp(memc);
 }
@@ -196,117 +201,168 @@ static test_return_t add_udp_server_tcp_client_test(memcached_st *memc)
   return TEST_SUCCESS;
 }
 
-static test_return_t set_udp_behavior_test(memcached_st *memc)
+static test_return_t version_TEST(memcached_st *memc)
+{
+  test_compare(MEMCACHED_NOT_SUPPORTED, memcached_version(memc));
+  return TEST_SUCCESS;
+}
+
+static test_return_t verbosity_TEST(memcached_st *memc)
+{
+  test_compare(MEMCACHED_SUCCESS, memcached_verbosity(memc, 0));
+  return TEST_SUCCESS;
+}
+
+static test_return_t memcached_get_TEST(memcached_st *memc)
+{
+  memcached_return_t rc;
+  test_null(memcached_get(memc,
+                          test_literal_param(__func__),
+                          0, 0, &rc));
+  test_compare(MEMCACHED_NOT_SUPPORTED, rc);
+
+  return TEST_SUCCESS;
+}
+
+static test_return_t memcached_mget_execute_by_key_TEST(memcached_st *memc)
+{
+  char **keys= NULL;
+  size_t *key_length= NULL;
+  test_compare(MEMCACHED_NOT_SUPPORTED,
+               memcached_mget_execute_by_key(memc,
+                                             test_literal_param(__func__), // Group key
+                                             keys, key_length, // Actual key
+                                             0, // Number of keys
+                                             0, // callbacks
+                                             0, // context
+                                             0)); // Number of callbacks
+
+  return TEST_SUCCESS;
+}
+
+static test_return_t memcached_stat_TEST(memcached_st *memc)
 {
+  memcached_return_t rc;
+  test_null(memcached_stat(memc, 0, &rc));
+  test_compare(MEMCACHED_NOT_SUPPORTED, rc);
+
+  return TEST_SUCCESS;
+}
 
+static test_return_t set_udp_behavior_test(memcached_st *memc)
+{
   memcached_quit(memc);
-  memc->number_of_hosts= 0;
-  memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, memc->distribution);
-  test_true(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP, 1) == MEMCACHED_SUCCESS);
-  test_true(memc->flags.use_udp);
-  test_true(memc->flags.no_reply);
 
-  test_true(memcached_server_count(memc) == 0);
+  test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, memc->distribution));
+  test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP, true));
+  test_compare(true, memc->flags.use_udp);
+  test_compare(false, memc->flags.reply);
 
-  memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP,0);
-  test_true(! (memc->flags.use_udp));
-  memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY,0);
-  test_true(! (memc->flags.no_reply));
+  test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP, false));
+  test_compare(false, memc->flags.use_udp);
+  test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, false));
+  test_compare(true, memc->flags.reply);
 
   return TEST_SUCCESS;
 }
 
 static test_return_t udp_set_test(memcached_st *memc)
 {
-  unsigned int num_iters= 1025; //request id rolls over at 1024
+  // Assume we are running under valgrind, and bail 
+  if (getenv("TESTS_ENVIRONMENT"))
+  {
+    return TEST_SUCCESS; 
+  }
+
+  const unsigned int num_iters= 1025; //request id rolls over at 1024
+
+  test_true(memc);
 
   for (size_t x= 0; x < num_iters;x++)
   {
-    memcached_return_t rc;
-    const char *key= "foo";
-    const char *value= "when we sanitize";
-    uint16_t *expected_ids= get_udp_request_ids(memc);
-    unsigned int server_key= memcached_generate_hash(memc, key, strlen(key));
-    memcached_server_instance_st instance=
-      memcached_server_instance_by_position(memc, server_key);
+    Expected expected_ids;
+    get_udp_request_ids(memc, expected_ids);
+    unsigned int server_key= memcached_generate_hash(memc, test_literal_param("foo"));
+    test_true(server_key < memcached_server_count(memc));
+    memcached_server_instance_st instance= memcached_server_instance_by_position(memc, server_key);
     size_t init_offset= instance->write_buffer_offset;
 
-    rc= memcached_set(memc, key, strlen(key),
-                      value, strlen(value),
-                      (time_t)0, (uint32_t)0);
-    test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
-    /** NB, the check below assumes that if new write_ptr is less than
-     *  the original write_ptr that we have flushed. For large payloads, this
-     *  maybe an invalid assumption, but for the small payload we have it is OK
-     */
-    if (rc == MEMCACHED_SUCCESS ||
-            instance->write_buffer_offset < init_offset)
-      increment_request_id(&expected_ids[server_key]);
-
-    if (rc == MEMCACHED_SUCCESS)
-    {
-      test_true(instance->write_buffer_offset == UDP_DATAGRAM_HEADER_LENGTH);
-    }
-    else
+    test_compare_hint(MEMCACHED_SUCCESS, 
+                      memcached_set(memc,
+                                    test_literal_param("foo"),
+                                    test_literal_param("when we sanitize"),
+                                    time_t(0), uint32_t(0)),
+                      memcached_last_error_message(memc));
+
+    /*
+      NB, the check below assumes that if new write_ptr is less than
+      the original write_ptr that we have flushed. For large payloads, this
+      maybe an invalid assumption, but for the small payload we have it is OK
+    */
+    if (instance->write_buffer_offset < init_offset)
     {
-      test_true(instance->write_buffer_offset != UDP_DATAGRAM_HEADER_LENGTH);
-      test_true(instance->write_buffer_offset <= MAX_UDP_DATAGRAM_LENGTH);
+      increment_request_id(&expected_ids[server_key]);
     }
-    test_true(post_udp_op_check(memc, expected_ids) == TEST_SUCCESS);
+
+    test_compare(TEST_SUCCESS, post_udp_op_check(memc, expected_ids));
   }
+
   return TEST_SUCCESS;
 }
 
 static test_return_t udp_buffered_set_test(memcached_st *memc)
 {
-  memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1);
-  return udp_set_test(memc);
+  test_true(memc);
+  test_compare(MEMCACHED_INVALID_ARGUMENTS,
+               memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, true));
+  return TEST_SUCCESS;
 }
 
 static test_return_t udp_set_too_big_test(memcached_st *memc)
 {
-  memcached_return_t rc;
-  const char *key= "bar";
-  char value[MAX_UDP_DATAGRAM_LENGTH];
-  uint16_t *expected_ids= get_udp_request_ids(memc);
-  rc= memcached_set(memc, key, strlen(key),
-                    value, MAX_UDP_DATAGRAM_LENGTH,
-                    (time_t)0, (uint32_t)0);
-  test_true(rc == MEMCACHED_WRITE_FAILURE);
-
-  return post_udp_op_check(memc,expected_ids);
+  test_true(memc);
+  Expected expected_ids;
+  get_udp_request_ids(memc, expected_ids);
+
+  std::vector<char> value;
+  value.resize(1024 * 1024 * 10);
+
+  test_compare_hint(MEMCACHED_WRITE_FAILURE,
+                    memcached_set(memc,
+                                  test_literal_param(__func__), 
+                                  &value[0], value.size(),
+                                  time_t(0), uint32_t(0)),
+                    memcached_last_error_message(memc));
+  memcached_quit(memc);
+
+  return post_udp_op_check(memc, expected_ids);
 }
 
 static test_return_t udp_delete_test(memcached_st *memc)
 {
-  unsigned int num_iters= 1025; //request id rolls over at 1024
+  test_true(memc);
 
-  for (size_t x= 0; x < num_iters;x++)
+  //request id rolls over at 1024
+  for (size_t x= 0; x < 1025; x++)
   {
-    memcached_return_t rc;
-    const char *key= "foo";
-    uint16_t *expected_ids=get_udp_request_ids(memc);
-    unsigned int server_key= memcached_generate_hash(memc, key, strlen(key));
-    memcached_server_instance_st instance=
-      memcached_server_instance_by_position(memc, server_key);
+    Expected expected_ids;
+    get_udp_request_ids(memc, expected_ids);
+
+    unsigned int server_key= memcached_generate_hash(memc, test_literal_param("foo"));
+    memcached_server_instance_st instance= memcached_server_instance_by_position(memc, server_key);
     size_t init_offset= instance->write_buffer_offset;
 
-    rc= memcached_delete(memc, key, strlen(key), 0);
-    test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
+    test_compare(MEMCACHED_SUCCESS,
+                 memcached_delete(memc, test_literal_param("foo"), 0));
 
-    if (rc == MEMCACHED_SUCCESS || instance->write_buffer_offset < init_offset)
-      increment_request_id(&expected_ids[server_key]);
-    if (rc == MEMCACHED_SUCCESS)
-    {
-      test_true(instance->write_buffer_offset == UDP_DATAGRAM_HEADER_LENGTH);
-    }
-    else
+    if (instance->write_buffer_offset < init_offset)
     {
-      test_true(instance->write_buffer_offset != UDP_DATAGRAM_HEADER_LENGTH);
-      test_true(instance->write_buffer_offset <= MAX_UDP_DATAGRAM_LENGTH);
+      increment_request_id(&expected_ids[server_key]);
     }
-    test_true(post_udp_op_check(memc,expected_ids) == TEST_SUCCESS);
+
+    test_compare(TEST_SUCCESS, post_udp_op_check(memc, expected_ids));
   }
+
   return TEST_SUCCESS;
 }
 
@@ -318,116 +374,123 @@ static test_return_t udp_buffered_delete_test(memcached_st *memc)
 
 static test_return_t udp_verbosity_test(memcached_st *memc)
 {
-  memcached_return_t rc;
-  uint16_t *expected_ids= get_udp_request_ids(memc);
+  Expected expected_ids;
+  get_udp_request_ids(memc, expected_ids);
 
   for (size_t x= 0; x < memcached_server_count(memc); x++)
   {
     increment_request_id(&expected_ids[x]);
   }
 
-  rc= memcached_verbosity(memc,3);
-  test_true(rc == MEMCACHED_SUCCESS);
-  return post_udp_op_check(memc,expected_ids);
+  test_compare(MEMCACHED_SUCCESS, memcached_verbosity(memc, 3));
+
+  return post_udp_op_check(memc, expected_ids);
 }
 
 static test_return_t udp_quit_test(memcached_st *memc)
 {
-  uint16_t *expected_ids= get_udp_request_ids(memc);
+  Expected expected_ids;
   memcached_quit(memc);
+
   return post_udp_op_check(memc, expected_ids);
 }
 
 static test_return_t udp_flush_test(memcached_st *memc)
 {
-  memcached_return_t rc;
-  uint16_t *expected_ids= get_udp_request_ids(memc);
+  Expected expected_ids;
+  get_udp_request_ids(memc, expected_ids);
 
   for (size_t x= 0; x < memcached_server_count(memc); x++)
   {
     increment_request_id(&expected_ids[x]);
   }
+  memcached_error_print(memc);
+  test_compare_hint(MEMCACHED_SUCCESS, memcached_flush(memc, 0), memcached_last_error_message(memc));
 
-  rc= memcached_flush(memc,0);
-  test_true(rc == MEMCACHED_SUCCESS);
-  return post_udp_op_check(memc,expected_ids);
+  return post_udp_op_check(memc, expected_ids);
 }
 
 static test_return_t udp_incr_test(memcached_st *memc)
 {
-  memcached_return_t rc;
-  const char *key= "incr";
-  const char *value= "1";
-  rc= memcached_set(memc, key, strlen(key),
-                    value, strlen(value),
-                    (time_t)0, (uint32_t)0);
-
-  test_true(rc == MEMCACHED_SUCCESS);
-  uint16_t *expected_ids= get_udp_request_ids(memc);
-  unsigned int server_key= memcached_generate_hash(memc, key, strlen(key));
+  test_compare(MEMCACHED_SUCCESS,
+               memcached_set(memc, test_literal_param("incr"), 
+                             test_literal_param("1"),
+                             (time_t)0, (uint32_t)0));
+
+  Expected expected_ids;
+  get_udp_request_ids(memc, expected_ids);
+
+  unsigned int server_key= memcached_generate_hash(memc, test_literal_param("incr"));
   increment_request_id(&expected_ids[server_key]);
+
   uint64_t newvalue;
-  rc= memcached_increment(memc, key, strlen(key), 1, &newvalue);
-  test_true(rc == MEMCACHED_SUCCESS);
+  test_compare(MEMCACHED_SUCCESS, memcached_increment(memc, test_literal_param("incr"), 1, &newvalue));
+
   return post_udp_op_check(memc, expected_ids);
 }
 
 static test_return_t udp_decr_test(memcached_st *memc)
 {
-  memcached_return_t rc;
-  const char *key= "decr";
-  const char *value= "1";
-  rc= memcached_set(memc, key, strlen(key),
-                    value, strlen(value),
-                    (time_t)0, (uint32_t)0);
-
-  test_true(rc == MEMCACHED_SUCCESS);
-  uint16_t *expected_ids= get_udp_request_ids(memc);
-  unsigned int server_key= memcached_generate_hash(memc, key, strlen(key));
+  test_compare(MEMCACHED_SUCCESS,
+               memcached_set(memc, 
+                             test_literal_param(__func__),
+                             test_literal_param("1"),
+                             time_t(0), uint32_t(0)));
+
+  Expected expected_ids;
+  get_udp_request_ids(memc, expected_ids);
+
+  unsigned int server_key= memcached_generate_hash(memc,
+                                                   test_literal_param(__func__));
   increment_request_id(&expected_ids[server_key]);
+
   uint64_t newvalue;
-  rc= memcached_decrement(memc, key, strlen(key), 1, &newvalue);
-  test_true(rc == MEMCACHED_SUCCESS);
+  test_compare(MEMCACHED_SUCCESS, memcached_decrement(memc,
+                                                      test_literal_param(__func__),
+                                                      1, &newvalue));
+
   return post_udp_op_check(memc, expected_ids);
 }
 
 
 static test_return_t udp_stat_test(memcached_st *memc)
 {
-  memcached_stat_st * rv= NULL;
   memcached_return_t rc;
   char args[]= "";
-  uint16_t *expected_ids = get_udp_request_ids(memc);
-  rv = memcached_stat(memc, args, &rc);
-  free(rv);
-  test_true(rc == MEMCACHED_NOT_SUPPORTED);
+  Expected expected_ids;
+  get_udp_request_ids(memc, expected_ids);
+  memcached_stat_st *rv= memcached_stat(memc, args, &rc);
+  memcached_stat_free(memc, rv);
+  test_compare(MEMCACHED_NOT_SUPPORTED, rc);
+
   return post_udp_op_check(memc, expected_ids);
 }
 
 static test_return_t udp_version_test(memcached_st *memc)
 {
-  memcached_return_t rc;
-  uint16_t *expected_ids = get_udp_request_ids(memc);
-  rc = memcached_version(memc);
-  test_true(rc == MEMCACHED_NOT_SUPPORTED);
+  Expected expected_ids;
+  get_udp_request_ids(memc, expected_ids);
+
+  test_compare(MEMCACHED_NOT_SUPPORTED,
+               memcached_version(memc));
+
   return post_udp_op_check(memc, expected_ids);
 }
 
 static test_return_t udp_get_test(memcached_st *memc)
 {
   memcached_return_t rc;
-  const char *key= "foo";
   size_t vlen;
-  uint16_t *expected_ids = get_udp_request_ids(memc);
-  char *val= memcached_get(memc, key, strlen(key), &vlen, (uint32_t)0, &rc);
-  test_true(rc == MEMCACHED_NOT_SUPPORTED);
-  test_true(val == NULL);
+  Expected expected_ids;
+  get_udp_request_ids(memc, expected_ids);
+  test_null(memcached_get(memc, test_literal_param("foo"), &vlen, (uint32_t)0, &rc));
+  test_compare(MEMCACHED_NOT_SUPPORTED, rc);
+
   return post_udp_op_check(memc, expected_ids);
 }
 
 static test_return_t udp_mixed_io_test(memcached_st *memc)
 {
-  test_st current_op;
   test_st mixed_io_ops [] ={
     {"udp_set_test", 0,
       (test_callback_fn*)udp_set_test},
@@ -439,8 +502,10 @@ static test_return_t udp_mixed_io_test(memcached_st *memc)
       (test_callback_fn*)udp_verbosity_test},
     {"udp_quit_test", 0,
       (test_callback_fn*)udp_quit_test},
+#if 0
     {"udp_flush_test", 0,
       (test_callback_fn*)udp_flush_test},
+#endif
     {"udp_incr_test", 0,
       (test_callback_fn*)udp_incr_test},
     {"udp_decr_test", 0,
@@ -451,12 +516,21 @@ static test_return_t udp_mixed_io_test(memcached_st *memc)
 
   for (size_t x= 0; x < 500; x++)
   {
-    current_op= mixed_io_ops[random() % 9];
-    test_true(current_op.test_fn(memc) == TEST_SUCCESS);
+    test_st current_op= mixed_io_ops[(random() % 8)];
+    test_compare(TEST_SUCCESS, current_op.test_fn(memc));
   }
   return TEST_SUCCESS;
 }
 
+test_st compatibility_TESTS[] ={
+  {"version", 0, (test_callback_fn*)version_TEST },
+  {"version", 0, (test_callback_fn*)verbosity_TEST },
+  {"memcached_get()", 0, (test_callback_fn*)memcached_get_TEST },
+  {"memcached_mget_execute_by_key()", 0, (test_callback_fn*)memcached_mget_execute_by_key_TEST },
+  {"memcached_stat()", 0, (test_callback_fn*)memcached_stat_TEST },
+  {0, 0, 0}
+};
+
 test_st udp_setup_server_tests[] ={
   {"set_udp_behavior_test", 0, (test_callback_fn*)set_udp_behavior_test},
   {"add_tcp_server_udp_client_test", 0, (test_callback_fn*)add_tcp_server_udp_client_test},
@@ -484,30 +558,20 @@ test_st upd_io_tests[] ={
 
 collection_st collection[] ={
   {"udp_setup", (test_callback_fn*)init_udp, 0, udp_setup_server_tests},
-  {"udp_io", (test_callback_fn*)init_udp, 0, upd_io_tests},
+  {"compatibility", (test_callback_fn*)init_udp, 0, compatibility_TESTS},
+  {"udp_io", (test_callback_fn*)init_udp_valgrind, 0, upd_io_tests},
   {"udp_binary_io", (test_callback_fn*)binary_init_udp, 0, upd_io_tests},
   {0, 0, 0, 0}
 };
 
-#define SERVERS_TO_CREATE 5
+#include "tests/libmemcached_world.h"
 
-#include "libmemcached_world.h"
-
-void get_world(Framework *world)
+void get_world(libtest::Framework* world)
 {
-  world->collections= collection;
-
-  world->_create= (test_callback_create_fn*)world_create;
-  world->_destroy= (test_callback_destroy_fn*)world_destroy;
-
-  world->item._startup= (test_callback_fn*)world_test_startup;
-  world->item._flush= (test_callback_fn*)world_flush;
-  world->item.set_pre((test_callback_fn*)world_pre_run);
-  world->item.set_post((test_callback_fn*)world_post_run);
-  world->_on_error= (test_callback_error_fn*)world_on_error;
+  world->collections(collection);
 
-  world->collection_startup= (test_callback_fn*)world_container_startup;
-  world->collection_shutdown= (test_callback_fn*)world_container_shutdown;
+  world->create((test_callback_create_fn*)world_create);
+  world->destroy((test_callback_destroy_fn*)world_destroy);
 
-  world->set_runner(&defualt_libmemcached_runner);
+  world->set_runner(new LibmemcachedRunner);
 }