AC_SUBST(MEMCACHED_LIBRARY_VERSION)
-HASHKIT_LIBRARY_VERSION=0:0:0
+HASHKIT_LIBRARY_VERSION=1:0:0
AC_SUBST(HASHKIT_LIBRARY_VERSION)
AH_TOP([
LIBS=
PANDORA_REQUIRE_PTHREAD
LIBS="$my_saved_libs"
-PANDORA_CXX_DEMANGLE
dnl Specialty checks
DETECT_BYTEORDER
self->function= hashkit_jenkins;
break;
case HASHKIT_HASH_CUSTOM:
+ return HASHKIT_INVALID_ARGUMENT;
case HASHKIT_HASH_MAX:
default:
- return HASHKIT_FAILURE;
+ return HASHKIT_INVALID_HASH;
}
self->context= NULL;
(void)ptr;
switch (rc)
{
- case HASHKIT_SUCCESS:
- return "SUCCESS";
- case HASHKIT_FAILURE:
- return "FAILURE";
- case HASHKIT_MEMORY_ALLOCATION_FAILURE:
- return "MEMORY ALLOCATION FAILURE";
+ case HASHKIT_SUCCESS: return "SUCCESS";
+ case HASHKIT_FAILURE: return "FAILURE";
+ case HASHKIT_MEMORY_ALLOCATION_FAILURE: return "MEMORY ALLOCATION FAILURE";
+ case HASHKIT_INVALID_ARGUMENT: return "INVALID ARGUMENT";
+ case HASHKIT_INVALID_HASH: return "INVALID hashkit_hash_algorithm_t";
case HASHKIT_MAXIMUM_RETURN:
- return "Gibberish returned!";
default:
- return "Gibberish returned!";
+ return "INVALID hashkit_return_t";
}
}
HASHKIT_SUCCESS,
HASHKIT_FAILURE,
HASHKIT_MEMORY_ALLOCATION_FAILURE,
+ HASHKIT_INVALID_HASH,
+ HASHKIT_INVALID_ARGUMENT,
HASHKIT_MAXIMUM_RETURN /* Always add new error code before */
} hashkit_return_t;
break;
case MEMCACHED_BEHAVIOR_VERIFY_KEY:
if (ptr->flags.binary_protocol)
- return MEMCACHED_FAILURE;
+ return memcached_set_error_string(ptr, MEMCACHED_FAILURE,
+ memcached_string_with_size("MEMCACHED_BEHAVIOR_VERIFY_KEY if the binary protocol has been enabled."));
ptr->flags.verify_key= set_flag(data);
break;
case MEMCACHED_BEHAVIOR_SORT_HOSTS:
memcached_quit(ptr);
break;
case MEMCACHED_BEHAVIOR_USER_DATA:
- return MEMCACHED_FAILURE;
+ return memcached_set_error_string(ptr, MEMCACHED_FAILURE,
+ memcached_string_with_size("MEMCACHED_BEHAVIOR_USER_DATA deprecated."));
case MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY:
ptr->flags.hash_with_prefix_key= set_flag(data);
break;
break;
case MEM_NOT:
default:
- return MEMCACHED_NOT_SUPPORTED;
+ return memcached_set_error_string(ptr, MEMCACHED_NOT_SUPPORTED,
+ memcached_string_with_size("MEMCACHED_BEHAVIOR_CORK is not supported on this platform."));
}
}
break;
case MEMCACHED_BEHAVIOR_LOAD_FROM_FILE:
- return MEMCACHED_FAILURE;
+ return memcached_set_error_string(ptr, MEMCACHED_INVALID_ARGUMENTS,
+ memcached_string_with_size("MEMCACHED_BEHAVIOR_LOAD_FROM_FILE can not be set with memcached_behavior_set()"));
case MEMCACHED_BEHAVIOR_MAX:
default:
/* Shouldn't get here */
WATCHPOINT_ASSERT(0);
- return MEMCACHED_FAILURE;
+ return memcached_set_error_string(ptr, MEMCACHED_INVALID_ARGUMENTS,
+ memcached_string_with_size("Invalid behavior passed to memcached_behavior_set()"));
}
return MEMCACHED_SUCCESS;
return (uint64_t) sock_size;
}
case MEMCACHED_BEHAVIOR_USER_DATA:
- return MEMCACHED_FAILURE;
+ return memcached_set_error_string(ptr, MEMCACHED_FAILURE,
+ memcached_string_with_size("MEMCACHED_BEHAVIOR_USER_DATA deprecated."));
case MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY:
return ptr->flags.hash_with_prefix_key;
case MEMCACHED_BEHAVIOR_NOREPLY:
{
ptr->distribution= type;
run_distribution(ptr);
- }
- else
- {
- return MEMCACHED_FAILURE;
+ return MEMCACHED_SUCCESS;
}
- return MEMCACHED_SUCCESS;
+ return memcached_set_error_string(ptr, MEMCACHED_INVALID_ARGUMENTS,
+ memcached_string_with_size("Invalid memcached_server_distribution_t"));
}
memcached_return_t memcached_behavior_set_key_hash(memcached_st *ptr, memcached_hash_t type)
{
- hashkit_return_t rc;
- rc= hashkit_set_function(&ptr->hashkit, (hashkit_hash_algorithm_t)type);
+ if (hashkit_set_function(&ptr->hashkit, (hashkit_hash_algorithm_t)type) == HASHKIT_SUCCESS)
+ return MEMCACHED_SUCCESS;
- return rc == HASHKIT_SUCCESS ? MEMCACHED_SUCCESS : MEMCACHED_FAILURE;
+ return memcached_set_error_string(ptr, MEMCACHED_INVALID_ARGUMENTS,
+ memcached_string_with_size("Invalid memcached_hash_t()"));
}
memcached_hash_t memcached_behavior_get_key_hash(memcached_st *ptr)
memcached_return_t memcached_behavior_set_distribution_hash(memcached_st *ptr, memcached_hash_t type)
{
- hashkit_return_t rc;
- rc= hashkit_set_function(&ptr->distribution_hashkit, (hashkit_hash_algorithm_t)type);
+ if (hashkit_set_function(&ptr->distribution_hashkit, (hashkit_hash_algorithm_t)type) == HASHKIT_SUCCESS)
+ return MEMCACHED_SUCCESS;
- return rc == HASHKIT_SUCCESS ? MEMCACHED_SUCCESS : MEMCACHED_FAILURE;
+ return memcached_set_error_string(ptr, MEMCACHED_INVALID_ARGUMENTS,
+ memcached_string_with_size("Invalid memcached_hash_t()"));
}
memcached_hash_t memcached_behavior_get_distribution_hash(memcached_st *ptr)
{
return (memcached_hash_t)hashkit_get_function(&ptr->distribution_hashkit);
}
+
+const char *libmemcached_string_behavior(const memcached_behavior_t flag)
+{
+ switch (flag)
+ {
+ case MEMCACHED_BEHAVIOR_NO_BLOCK: return "MEMCACHED_BEHAVIOR_NO_BLOCK";
+ case MEMCACHED_BEHAVIOR_TCP_NODELAY: return "MEMCACHED_BEHAVIOR_TCP_NODELAY";
+ case MEMCACHED_BEHAVIOR_HASH: return "MEMCACHED_BEHAVIOR_HASH";
+ case MEMCACHED_BEHAVIOR_KETAMA: return "MEMCACHED_BEHAVIOR_KETAMA";
+ case MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE: return "MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE";
+ case MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE: return "MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE";
+ case MEMCACHED_BEHAVIOR_CACHE_LOOKUPS: return "MEMCACHED_BEHAVIOR_CACHE_LOOKUPS";
+ case MEMCACHED_BEHAVIOR_SUPPORT_CAS: return "MEMCACHED_BEHAVIOR_SUPPORT_CAS";
+ case MEMCACHED_BEHAVIOR_POLL_TIMEOUT: return "MEMCACHED_BEHAVIOR_POLL_TIMEOUT";
+ case MEMCACHED_BEHAVIOR_DISTRIBUTION: return "MEMCACHED_BEHAVIOR_DISTRIBUTION";
+ case MEMCACHED_BEHAVIOR_BUFFER_REQUESTS: return "MEMCACHED_BEHAVIOR_BUFFER_REQUESTS";
+ case MEMCACHED_BEHAVIOR_USER_DATA: return "MEMCACHED_BEHAVIOR_USER_DATA";
+ case MEMCACHED_BEHAVIOR_SORT_HOSTS: return "MEMCACHED_BEHAVIOR_SORT_HOSTS";
+ case MEMCACHED_BEHAVIOR_VERIFY_KEY: return "MEMCACHED_BEHAVIOR_VERIFY_KEY";
+ case MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT: return "MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT";
+ case MEMCACHED_BEHAVIOR_RETRY_TIMEOUT: return "MEMCACHED_BEHAVIOR_RETRY_TIMEOUT";
+ case MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED: return "MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED";
+ case MEMCACHED_BEHAVIOR_KETAMA_HASH: return "MEMCACHED_BEHAVIOR_KETAMA_HASH";
+ case MEMCACHED_BEHAVIOR_BINARY_PROTOCOL: return "MEMCACHED_BEHAVIOR_BINARY_PROTOCOL";
+ case MEMCACHED_BEHAVIOR_SND_TIMEOUT: return "MEMCACHED_BEHAVIOR_SND_TIMEOUT";
+ case MEMCACHED_BEHAVIOR_RCV_TIMEOUT: return "MEMCACHED_BEHAVIOR_RCV_TIMEOUT";
+ case MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT: return "MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT";
+ case MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK: return "MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK";
+ case MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK: return "MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK";
+ case MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH: return "MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH";
+ case MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY: return "MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY";
+ case MEMCACHED_BEHAVIOR_NOREPLY: return "MEMCACHED_BEHAVIOR_NOREPLY";
+ case MEMCACHED_BEHAVIOR_USE_UDP: return "MEMCACHED_BEHAVIOR_USE_UDP";
+ case MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS: return "MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS";
+ case MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS: return "MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS";
+ case MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ: return "MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ";
+ case MEMCACHED_BEHAVIOR_CORK: return "MEMCACHED_BEHAVIOR_CORK";
+ case MEMCACHED_BEHAVIOR_TCP_KEEPALIVE: return "MEMCACHED_BEHAVIOR_TCP_KEEPALIVE";
+ case MEMCACHED_BEHAVIOR_TCP_KEEPIDLE: return "MEMCACHED_BEHAVIOR_TCP_KEEPIDLE";
+ case MEMCACHED_BEHAVIOR_LOAD_FROM_FILE: return "MEMCACHED_BEHAVIOR_LOAD_FROM_FILE";
+ default:
+ case MEMCACHED_BEHAVIOR_MAX: return "INVALID BEHAVIOR";
+ }
+}
LIBMEMCACHED_LOCAL
bool _is_auto_eject_host(const memcached_st *ptr);
+LIBMEMCACHED_LOCAL
+ const char *libmemcached_string_behavior(const memcached_behavior_t flag);
#ifdef __cplusplus
}
{
error->size= str->size;
memcpy(error->c_str, str->c_str, str->size);
+ error->c_str[str->size]= 0;
+ }
+ else
+ {
+ error->size= 0;
}
- error->c_str[(str ? str->size :0)]= 0;
error->next= memc->error_messages;
memc->error_messages= error;
return error;
}
+memcached_return_t memcached_set_error_string(memcached_st *memc, memcached_return_t rc, const char *str, size_t length)
+{
+ memcached_string_t tmp;
+ tmp.c_str= str;
+ tmp.size= length;
+ return memcached_set_error(memc, rc, &tmp);
+}
+
memcached_return_t memcached_set_error(memcached_st *memc, memcached_return_t rc, memcached_string_t *str)
{
if (rc == MEMCACHED_SUCCESS)
return error->rc;
}
+static void _error_print(const memcached_error_st *error)
+{
+ if (! error)
+ return;
+
+ if (! error->size)
+ {
+ fprintf(stderr, "%s\n", memcached_strerror(NULL, error->rc) );
+ }
+ else
+ {
+ fprintf(stderr, "%s %s\n", memcached_strerror(NULL, error->rc), error->c_str);
+ }
+
+ _error_print(error->next);
+}
+
+void memcached_error_print(const memcached_st *self)
+{
+ if (! self)
+ return;
+
+ _error_print(self->error_messages);
+}
+
static void _error_free(memcached_error_st *error)
{
if (! error)
if (! memc->error_messages)
return memcached_strerror(memc, MEMCACHED_SUCCESS);
- if (! memc->error_messages->c_str)
+ if (! memc->error_messages->size)
{
return memcached_strerror(memc, memc->error_messages->rc);
}
LIBMEMCACHED_LOCAL
memcached_return_t memcached_set_error(memcached_st *memc, memcached_return_t rc, memcached_string_t *str);
+LIBMEMCACHED_LOCAL
+ memcached_return_t memcached_set_error_string(memcached_st *memc, memcached_return_t rc, const char *str, size_t length);
+
LIBMEMCACHED_LOCAL
memcached_return_t memcached_set_errno(memcached_st *memc, int local_errno, memcached_string_t *str);
LIBMEMCACHED_API
const char *memcached_last_error_message(memcached_st *memc);
+LIBMEMCACHED_API
+ void memcached_error_print(const memcached_st *self);
+
LIBMEMCACHED_API
memcached_return_t memcached_last_error(memcached_st *memc);
return MEMCACHED_SUCCESS;
}
+
+const char * libmemcached_string_hash(memcached_hash_t type)
+{
+ switch (type)
+ {
+ case MEMCACHED_HASH_DEFAULT: return "MEMCACHED_HASH_DEFAULT";
+ case MEMCACHED_HASH_MD5: return "MEMCACHED_HASH_MD5";
+ case MEMCACHED_HASH_CRC: return "MEMCACHED_HASH_CRC";
+ case MEMCACHED_HASH_FNV1_64: return "MEMCACHED_HASH_FNV1_64";
+ case MEMCACHED_HASH_FNV1A_64: return "MEMCACHED_HASH_FNV1A_64";
+ case MEMCACHED_HASH_FNV1_32: return "MEMCACHED_HASH_FNV1_32";
+ case MEMCACHED_HASH_FNV1A_32: return "MEMCACHED_HASH_FNV1A_32";
+ case MEMCACHED_HASH_HSIEH: return "MEMCACHED_HASH_HSIEH";
+ case MEMCACHED_HASH_MURMUR: return "MEMCACHED_HASH_MURMUR";
+ case MEMCACHED_HASH_JENKINS: return "MEMCACHED_HASH_JENKINS";
+ case MEMCACHED_HASH_CUSTOM: return "MEMCACHED_HASH_CUSTOM";
+ default:
+ case MEMCACHED_HASH_MAX: return "INVALID memcached_hash_t";
+ }
+}
LIBMEMCACHED_API
void memcached_autoeject(memcached_st *ptr);
+LIBMEMCACHED_API
+ const char * libmemcached_string_hash(memcached_hash_t type);
+
#ifdef __cplusplus
}
#endif
%{
+#include <config.h>
+
#include <stdint.h>
#include <iostream>
+#include <sstream>
+#include <string>
#include <libmemcached/options/type.h>
#include <libmemcached/options/string.h>
expression:
SERVER '=' server
{
- (void) memcached_server_add_parsed(parser->memc, $3.c_str, $3.length, $3.port, 0);
+ if (memcached_server_add_parsed(parser->memc, $3.c_str, $3.length, $3.port, 0) != MEMCACHED_SUCCESS)
+ YYERROR;
}
| SERVERS '=' server_list
{
behaviors:
PREFIX_KEY '=' string
{
- memcached_callback_set(parser->memc, MEMCACHED_CALLBACK_PREFIX_KEY, std::string($3.c_str, $3.length).c_str());
+ memcached_return_t rc;
+ if ((rc= memcached_callback_set(parser->memc, MEMCACHED_CALLBACK_PREFIX_KEY, std::string($3.c_str, $3.length).c_str())) != MEMCACHED_SUCCESS)
+ {
+ std::string error_message("--PREFIX-KEY");
+ error_message.append($3.c_str, $3.length);
+ memcached_string_t tmp= memcached_string_make(error_message.c_str(), error_message.size());
+ memcached_set_error(parser->memc, rc, &tmp);
+ YYERROR;
+ }
}
| DISTRIBUTION '=' distribution
{
- memcached_behavior_set(parser->memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, $3);
+ memcached_return_t rc;
+ if ((rc= memcached_behavior_set(parser->memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, $3)) != MEMCACHED_SUCCESS)
+ {
+ memcached_string_t tmp= memcached_string_make(memcached_string_with_size("--DISTRIBUTION"));
+ memcached_set_error(parser->memc, rc, &tmp);
+ YYERROR;
+ }
}
| HASH '=' hash
{
- memcached_behavior_set(parser->memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, $3);
+ memcached_return_t rc;
+ if ((rc= memcached_behavior_set(parser->memc, MEMCACHED_BEHAVIOR_HASH, $3)) != MEMCACHED_SUCCESS)
+ {
+ std::string buffer;
+ buffer+= "--HASH=";
+ buffer+= libmemcached_string_hash($3);
+ memcached_string_t tmp= memcached_string_make(buffer.c_str(), buffer.size());
+ memcached_set_error(parser->memc, rc, &tmp);
+ YYERROR;
+ }
}
| KETAMA_HASH '=' hash
{
- memcached_behavior_set(parser->memc, MEMCACHED_BEHAVIOR_KETAMA_HASH, $3);
+ memcached_return_t rc;
+ if ((rc= memcached_behavior_set(parser->memc, MEMCACHED_BEHAVIOR_KETAMA_HASH, $3)) != MEMCACHED_SUCCESS)
+ {
+ memcached_string_t tmp= memcached_string_make(memcached_string_with_size("--KETAMA-HASH"));
+ memcached_set_error(parser->memc, rc, &tmp);
+ YYERROR;
+ }
}
| behavior_number '=' NUMBER
{
- memcached_behavior_set(parser->memc, $1, $3);
+ memcached_return_t rc;
+ if ((rc= memcached_behavior_set(parser->memc, $1, $3)) != MEMCACHED_SUCCESS)
+ {
+ memcached_string_t tmp= memcached_string_make(libmemcached_string_behavior($1), strlen(libmemcached_string_behavior($1)));
+ memcached_set_error(parser->memc, rc, &tmp);
+ YYERROR;
+ }
}
| behavior_boolean
{
- memcached_behavior_set(parser->memc, $1, true);
+ memcached_return_t rc;
+ if ((rc= memcached_behavior_set(parser->memc, $1, true)) != MEMCACHED_SUCCESS)
+ {
+ memcached_string_t tmp= memcached_string_make(libmemcached_string_behavior($1), strlen(libmemcached_string_behavior($1)));
+ memcached_set_error(parser->memc, rc, &tmp);
+ YYERROR;
+ }
}
| USER_DATA
{
server_list:
server
{
- (void) memcached_server_add_parsed(parser->memc, $1.c_str, $1.length, $1.port, 0);
+ memcached_return_t rc;
+ if ((rc= memcached_server_add_parsed(parser->memc, $1.c_str, $1.length, $1.port, 0)) != MEMCACHED_SUCCESS)
+ {
+ std::stringstream ss;
+ ss << "--SERVER=" << $1;
+ memcached_string_t tmp= memcached_string_make(ss.str().c_str(), ss.str().length());
+ memcached_set_error(parser->memc, rc, &tmp);
+ YYERROR;
+ }
}
| server_list ',' server
{
- (void) memcached_server_add_parsed(parser->memc, $3.c_str, $3.length, $3.port, 0);
+ memcached_return_t rc;
+ if ((rc= memcached_server_add_parsed(parser->memc, $3.c_str, $3.length, $3.port, 0)) != MEMCACHED_SUCCESS)
+ {
+ std::stringstream ss;
+ ss << "--SERVERS=" << $3;
+ memcached_string_t tmp= memcached_string_make(ss.str().c_str(), ss.str().length());
+ memcached_set_error(parser->memc, rc, &tmp);
+ YYERROR;
+ }
}
;
{
self->end= self->string + length;
}
+
+memcached_string_t memcached_string_make(const char *str, size_t length)
+{
+ memcached_string_t tmp;
+ tmp.c_str= str;
+ tmp.size= length;
+
+ return tmp;
+}
LIBMEMCACHED_LOCAL
void memcached_string_set_length(memcached_string_st *self, size_t length);
+LIBMEMCACHED_LOCAL
+memcached_string_t memcached_string_make(const char *str, size_t length);
+
#ifdef __cplusplus
}
#endif
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * uTest Framework
+ *
+ * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ * 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.
+ *
+ */
+
+#include <config.h>
+
+#include <libtest/failed.h>
+
+#include <iostream>
+#include <string>
+#include <vector>
+
+struct failed_test_names_st
+{
+ failed_test_names_st(const char *collection_arg, const char *test_arg) :
+ collection(collection_arg),
+ test(test_arg)
+ {
+ }
+
+ std::string collection;
+ std::string test;
+};
+
+typedef std::vector<failed_test_names_st> Failures;
+
+static Failures failures;
+
+void push_failed_test(const char *collection, const char *test)
+{
+ failures.push_back(failed_test_names_st(collection, test));
+}
+
+void print_failed_test(void)
+{
+ for (Failures::iterator iter= failures.begin(); iter != failures.end(); iter++)
+ {
+ std::cerr << "\t" << (*iter).collection << " " << (*iter).test << std::endl;
+ }
+ std::cerr << std::endl;
+}
+
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * uTest Framework
+ *
+ * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ * 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.
+ *
+ */
+
+#pragma once
+#include <libtest/visibility.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+LIBTEST_INTERNAL_API
+ void push_failed_test(const char *collection, const char *test);
+
+LIBTEST_INTERNAL_API
+ void print_failed_test(void);
+
+#ifdef __cplusplus
+}
+#endif
# All paths should be given relative to the root
noinst_HEADERS+= \
+ libtest/failed.h \
libtest/server.h \
libtest/test.h \
libtest/visibility.h
libtest_libserver_la_SOURCES= libtest/server.c
noinst_LTLIBRARIES+= libtest/libtest.la
-libtest_libtest_la_SOURCES= libtest/test.c
+libtest_libtest_la_SOURCES=\
+ libtest/test.c
+libtest_libtest_la_CFLAGS= ${AM_CFLAGS} ${NO_CONVERSION}
+libtest_libtest_la_CPPFLAGS= ${AM_CPPFLAGS}
#include <libmemcached/memcached.h>
#include <libtest/test.h>
+#include <libtest/failed.h>
static void world_stats_print(world_stats_st *stats)
{
stats.success++;
break;
case TEST_FAILURE:
+#if 0
+ push_failed_test(next->name, run->name);
+#endif
stats.failed++;
failed= true;
break;
if (stats.collection_failed || stats.collection_skipped)
{
fprintf(stderr, "Some test failures and/or skipped test occurred.\n\n");
+#if 0
+ print_failed_test();
+#endif
}
else
{
continue;
#endif
- if (rc == HASHKIT_FAILURE && algo == HASHKIT_HASH_CUSTOM)
+ if (rc == HASHKIT_INVALID_ARGUMENT && algo == HASHKIT_HASH_CUSTOM)
continue;
- test_true(rc == HASHKIT_SUCCESS);
+ test_true_got(rc == HASHKIT_SUCCESS, hashkit_strerror(NULL, rc));
switch (algo)
{
if (rc == HASHKIT_FAILURE && algo == HASHKIT_HASH_HSIEH)
continue;
- if (rc == HASHKIT_FAILURE && algo == HASHKIT_HASH_CUSTOM)
+ if (rc == HASHKIT_INVALID_ARGUMENT && algo == HASHKIT_HASH_CUSTOM)
continue;
test_true(rc == HASHKIT_SUCCESS);
static test_return_t hsieh_avaibility_test (memcached_st *memc)
{
- memcached_return_t expected_rc= MEMCACHED_FAILURE;
+ memcached_return_t expected_rc= MEMCACHED_INVALID_ARGUMENTS;
#ifdef HAVE_HSIEH_HASH
expected_rc= MEMCACHED_SUCCESS;
#endif
static test_return_t murmur_avaibility_test (memcached_st *memc)
{
- memcached_return_t expected_rc= MEMCACHED_FAILURE;
+ memcached_return_t expected_rc= MEMCACHED_INVALID_ARGUMENTS;
#ifdef HAVE_MURMUR_HASH
expected_rc= MEMCACHED_SUCCESS;
#endif
#include <config.h>
+#include <iostream>
+
#include <libmemcached/memcached.h>
#include "tests/parser.h"
{ ARRAY, make_scanner_string("--BINARY_PROTOCOL"), scanner_string_null, NULL },
{ ARRAY, make_scanner_string("--BUFFER_REQUESTS"), scanner_string_null, NULL },
{ ARRAY, make_scanner_string("--CACHE_LOOKUPS"), scanner_string_null, __check_CACHE_LOOKUPS },
+#if 0 // Not all platforms support
{ ARRAY, make_scanner_string("--CORK"), scanner_string_null, NULL },
+#endif
{ ARRAY, make_scanner_string("--HASH_WITH_PREFIX_KEY"), scanner_string_null, NULL },
{ ARRAY, make_scanner_string("--KETAMA"), scanner_string_null, NULL },
{ ARRAY, make_scanner_string("--KETAMA_WEIGHTED"), scanner_string_null, NULL },
};
scanner_variable_t hash_strings[]= {
- { ARRAY, make_scanner_string("--HASH=MD5"), scanner_string_null, NULL },
{ ARRAY, make_scanner_string("--HASH=CRC"), scanner_string_null, NULL },
- { ARRAY, make_scanner_string("--HASH=FNV1_64"), scanner_string_null, NULL },
+ { ARRAY, make_scanner_string("--HASH=FNV1A_32"), scanner_string_null, NULL },
{ ARRAY, make_scanner_string("--HASH=FNV1A_64"), scanner_string_null, NULL },
{ ARRAY, make_scanner_string("--HASH=FNV1_32"), scanner_string_null, NULL },
- { ARRAY, make_scanner_string("--HASH=FNV1A_32"), scanner_string_null, NULL },
- { ARRAY, make_scanner_string("--HASH=MURMUR"), scanner_string_null, NULL },
+ { ARRAY, make_scanner_string("--HASH=FNV1_64"), scanner_string_null, NULL },
{ ARRAY, make_scanner_string("--HASH=JENKINS"), scanner_string_null, NULL },
+ { ARRAY, make_scanner_string("--HASH=MD5"), scanner_string_null, NULL },
+ { ARRAY, make_scanner_string("--HASH=MURMUR"), scanner_string_null, NULL },
{ NIL, scanner_string_null, scanner_string_null, NULL}
};
rc= memcached_parse_configuration(memc, ptr->option.c_str, ptr->option.size);
if (test_true)
{
- test_true_got(rc == MEMCACHED_SUCCESS, memcached_last_error_message(memc));
+ if (rc != MEMCACHED_SUCCESS)
+ memcached_error_print(memc);
+
+ test_true(rc == MEMCACHED_SUCCESS);
if (ptr->check_func)
{