memcached/.gitignore
memcached/memcached
memcached/memcached.spec
+tests/parser
memcached_st *memcached(const char *string, size_t length)
{
- memcached_st *self= memcached_create(NULL);
- if (self == NULL)
+ if (length == 0 and string)
+ {
+ return NULL;
+ }
+
+ if (length and string == NULL)
{
return NULL;
}
if (length == 0)
{
- return self;
+ if (bool(getenv("LIBMEMCACHED")))
+ {
+ string= getenv("LIBMEMCACHED");
+ length= string ? strlen(string) : 0;
+ }
+ }
+
+ memcached_st *memc= memcached_create(NULL);
+ if (memc == NULL)
+ {
+ return NULL;
+ }
+
+ if (length == 0 or string == NULL)
+ {
+ return memc;
}
- memcached_return_t rc= memcached_parse_configuration(self, string, length);
- if (memcached_success(rc) and memcached_parse_filename(self))
+ memcached_return_t rc= memcached_parse_configuration(memc, string, length);
+ if (memcached_success(rc) and memcached_parse_filename(memc))
{
- rc= memcached_parse_configure_file(*self, memcached_parse_filename(self), memcached_parse_filename_length(self));
+ rc= memcached_parse_configure_file(*memc, memcached_parse_filename(memc), memcached_parse_filename_length(memc));
}
if (memcached_failed(rc))
{
- memcached_free(self);
+ memcached_free(memc);
return NULL;
}
- return self;
+ return memc;
}
memcached_return_t memcached_reset(memcached_st *ptr)
#ifdef TARGET_OS_OSX
return;
#endif
- if (getenv("LIBMEMCACHED_NO_COREDUMP") == NULL)
+ if (getenv("YATL_COREDUMP"))
{
pid_t pid= fork();
{
delete *iter;
}
+ _collection.clear();
}
bool Framework::match(const char* arg)
include tests/libmemcached-1.0/include.am
+include tests/parser.am
+
tests_failure_SOURCES=
tests_failure_SOURCES+= tests/failure.cc
tests_failure_SOURCES+= clients/execute.cc
#include "tests/exist.h"
#include "tests/ketama.h"
#include "tests/namespace.h"
-#include "tests/parser.h"
#include "tests/libmemcached-1.0/dump.h"
#include "tests/libmemcached-1.0/generate.h"
#include "tests/libmemcached-1.0/haldenbrand.h"
+#include "tests/libmemcached-1.0/parser.h"
#include "tests/libmemcached-1.0/stat.h"
#include "tests/touch.h"
#include "tests/callbacks.h"
#include "tests/exist.h"
#include "tests/ketama.h"
#include "tests/namespace.h"
-#include "tests/parser.h"
+#include "tests/libmemcached-1.0/parser.h"
#include "tests/libmemcached-1.0/dump.h"
#include "tests/libmemcached-1.0/generate.h"
#include "tests/libmemcached-1.0/haldenbrand.h"
noinst_HEADERS+= tests/libmemcached-1.0/all_tests.h
noinst_HEADERS+= tests/libmemcached-1.0/callback_counter.h
noinst_HEADERS+= tests/libmemcached-1.0/dump.h
+noinst_HEADERS+= tests/libmemcached-1.0/encoding_key.h
noinst_HEADERS+= tests/libmemcached-1.0/fetch_all_results.h
noinst_HEADERS+= tests/libmemcached-1.0/generate.h
-noinst_HEADERS+= tests/libmemcached-1.0/encoding_key.h
noinst_HEADERS+= tests/libmemcached-1.0/haldenbrand.h
noinst_HEADERS+= tests/libmemcached-1.0/mem_functions.h
noinst_HEADERS+= tests/libmemcached-1.0/memcached_get.h
+noinst_HEADERS+= tests/libmemcached-1.0/parser.h
noinst_HEADERS+= tests/libmemcached-1.0/setup_and_teardowns.h
noinst_HEADERS+= tests/libmemcached-1.0/stat.h
noinst_HEADERS+= tests/namespace.h
-noinst_HEADERS+= tests/parser.h
noinst_HEADERS+= tests/pool.h
noinst_HEADERS+= tests/print.h
noinst_HEADERS+= tests/replication.h
#include <libmemcached/memcached.h>
#include <libmemcached/util.h>
-#include <tests/parser.h>
+#include <tests/libmemcached-1.0/parser.h>
#include <tests/print.h>
enum scanner_type_t
return MEMCACHED_SUCCESS;
}
-
test_return_t test_hostname_port_weight(memcached_st *)
{
const char *server_string= "--server=localhost:8888/?2 --server=localhost:8889/?3 --server=localhost:8890/?4 --server=localhost:8891/?5 --server=localhost:8892/?3";
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached
+ *
+ * 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
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+test_return_t memcached_NULL_string_TEST(memcached_st*);
+test_return_t memcached_zero_string_length_TEST(memcached_st*);
+
+LIBTEST_LOCAL
+test_return_t server_test(memcached_st *memc);
+
+LIBTEST_LOCAL
+test_return_t servers_bad_test(memcached_st *memc);
+
+LIBTEST_LOCAL
+test_return_t behavior_parser_test(memcached_st*);
+
+LIBTEST_LOCAL
+test_return_t parser_number_options_test(memcached_st*);
+
+LIBTEST_LOCAL
+test_return_t parser_distribution_test(memcached_st*);
+
+LIBTEST_LOCAL
+test_return_t parser_hash_test(memcached_st*);
+
+LIBTEST_LOCAL
+test_return_t parser_boolean_options_test(memcached_st*);
+
+LIBTEST_LOCAL
+test_return_t parser_key_prefix_test(memcached_st*);
+
+LIBTEST_LOCAL
+ test_return_t libmemcached_check_configuration_test(memcached_st*);
+
+LIBTEST_LOCAL
+ test_return_t memcached_create_with_options_test(memcached_st*);
+
+LIBTEST_LOCAL
+ test_return_t memcached_create_with_options_with_filename(memcached_st*);
+
+LIBTEST_LOCAL
+ test_return_t libmemcached_check_configuration_with_filename_test(memcached_st*);
+
+LIBTEST_LOCAL
+ test_return_t random_statement_build_test(memcached_st*);
+
+LIBTEST_LOCAL
+test_return_t test_include_keyword(memcached_st*);
+
+LIBTEST_LOCAL
+test_return_t test_end_keyword(memcached_st*);
+
+LIBTEST_LOCAL
+test_return_t test_reset_keyword(memcached_st*);
+
+LIBTEST_LOCAL
+test_return_t test_error_keyword(memcached_st*);
+
+LIBTEST_LOCAL
+test_return_t server_with_weight_test(memcached_st *);
+
+LIBTEST_LOCAL
+test_return_t test_hostname_port_weight(memcached_st *);
+
+LIBTEST_LOCAL
+test_return_t regression_bug_71231153_connect(memcached_st *);
+
+LIBTEST_LOCAL
+test_return_t regression_bug_71231153_poll(memcached_st *);
+
+LIBTEST_LOCAL
+test_return_t test_parse_socket(memcached_st *);
+
+LIBTEST_LOCAL
+test_return_t test_namespace_keyword(memcached_st*);
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+# vim:ft=automake
+# Copyright (C) 2012 Data Differential
+# All rights reserved.
+#
+# Use and distribution licensed under the BSD license. See
+# the COPYING file in the parent directory for full text.
+#
+# included from Top Level Makefile.am
+# All paths should be given relative to the root
+
+noinst_HEADERS+= tests/libmemcached-1.0/parser.h
+
+tests_parser_SOURCES=
+tests_parser_CXXFLAGS=
+tests_parser_DEPENDENCIES=
+tests_parser_LDADD=
+
+tests_parser_SOURCES+= tests/parser.cc
+
+tests_parser_CXXFLAGS+= $(AM_CXXFLAGS) $(NO_EFF_CXX)
+tests_parser_DEPENDENCIES+= $(TESTS_LDADDS)
+tests_parser_LDADD+= $(tests_parser_DEPENDENCIES)
+check_PROGRAMS+= tests/parser
+noinst_PROGRAMS+= tests/parser
+
+test-parser: tests/parser
+ @tests/parser
+
+valgrind-parser: tests/parser
+ $(VALGRIND_COMMAND) tests/parser
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached library
+ *
+ * Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ *
+ * 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>
+
+/*
+ C++ interface test
+*/
+#include <libmemcached-1.0/memcached.hpp>
+#include <libtest/test.hpp>
+
+using namespace libtest;
+
+static test_return_t memcached_NULL_string_TEST(void*)
+{
+ test_null(memcached(NULL, 75));
+ return TEST_SUCCESS;
+}
+
+static test_return_t memcached_zero_string_length_TEST(void*)
+{
+ test_null(memcached("value", 0));
+ return TEST_SUCCESS;
+}
+
+static test_return_t putenv_localhost_quoted_TEST(void*)
+{
+ char set_env[1024];
+
+ snprintf(set_env, sizeof(set_env), "LIBMEMCACHED=\"--server=localhost\"");
+ test_zero(putenv(set_env));
+ test_null(memcached(NULL, 0));
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t putenv_NULL_TEST(void*)
+{
+ char set_env[1024];
+
+ snprintf(set_env, sizeof(set_env), "LIBMEMCACHED");
+ test_zero(putenv(set_env));
+ memcached_st *memc= memcached(NULL, 0);
+ test_true(memc);
+
+ memcached_free(memc);
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t putenv_NULL_TEST2(void*)
+{
+ char set_env[1024];
+
+ snprintf(set_env, sizeof(set_env), "LIBMEMCACHED=");
+ test_zero(putenv(set_env));
+ memcached_st *memc= memcached(NULL, 0);
+ test_true(memc);
+
+ memcached_free(memc);
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t putenv_localhost_TEST(void*)
+{
+ char set_env[1024];
+
+ snprintf(set_env, sizeof(set_env), "LIBMEMCACHED=--server=localhost");
+ test_zero(putenv(set_env));
+ memcached_st *memc= memcached(NULL, 0);
+ test_true(memc);
+
+ memcached_free(memc);
+
+ return TEST_SUCCESS;
+}
+
+test_st memcached_TESTS[] ={
+ {"memcached(NULL, 75)", false, (test_callback_fn*)memcached_NULL_string_TEST },
+ {"memcached(\"value\", 0)", false, (test_callback_fn*)memcached_zero_string_length_TEST },
+ {"putenv(LIBMEMCACHED=--server=localhost)", false, (test_callback_fn*)putenv_localhost_TEST },
+ {"putenv(LIBMEMCACHED)", false, (test_callback_fn*)putenv_NULL_TEST },
+ {"putenv(LIBMEMCACHED=)", false, (test_callback_fn*)putenv_NULL_TEST2 },
+ {"putenv(LIBMEMCACHED=--server=\"localhost\")", false, (test_callback_fn*)putenv_localhost_quoted_TEST },
+ {0, 0, 0}
+};
+
+collection_st collection[] ={
+ {"memcached()", 0, 0, memcached_TESTS},
+ {0, 0, 0, 0}
+};
+
+void get_world(Framework *world)
+{
+ world->collections= collection;
+}
+
+++ /dev/null
-/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- * Libmemcached
- *
- * 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
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-LIBTEST_LOCAL
-test_return_t server_test(memcached_st *memc);
-
-LIBTEST_LOCAL
-test_return_t servers_bad_test(memcached_st *memc);
-
-LIBTEST_LOCAL
-test_return_t behavior_parser_test(memcached_st*);
-
-LIBTEST_LOCAL
-test_return_t parser_number_options_test(memcached_st*);
-
-LIBTEST_LOCAL
-test_return_t parser_distribution_test(memcached_st*);
-
-LIBTEST_LOCAL
-test_return_t parser_hash_test(memcached_st*);
-
-LIBTEST_LOCAL
-test_return_t parser_boolean_options_test(memcached_st*);
-
-LIBTEST_LOCAL
-test_return_t parser_key_prefix_test(memcached_st*);
-
-LIBTEST_LOCAL
- test_return_t libmemcached_check_configuration_test(memcached_st*);
-
-LIBTEST_LOCAL
- test_return_t memcached_create_with_options_test(memcached_st*);
-
-LIBTEST_LOCAL
- test_return_t memcached_create_with_options_with_filename(memcached_st*);
-
-LIBTEST_LOCAL
- test_return_t libmemcached_check_configuration_with_filename_test(memcached_st*);
-
-LIBTEST_LOCAL
- test_return_t random_statement_build_test(memcached_st*);
-
-LIBTEST_LOCAL
-test_return_t test_include_keyword(memcached_st*);
-
-LIBTEST_LOCAL
-test_return_t test_end_keyword(memcached_st*);
-
-LIBTEST_LOCAL
-test_return_t test_reset_keyword(memcached_st*);
-
-LIBTEST_LOCAL
-test_return_t test_error_keyword(memcached_st*);
-
-LIBTEST_LOCAL
-test_return_t server_with_weight_test(memcached_st *);
-
-LIBTEST_LOCAL
-test_return_t test_hostname_port_weight(memcached_st *);
-
-LIBTEST_LOCAL
-test_return_t regression_bug_71231153_connect(memcached_st *);
-
-LIBTEST_LOCAL
-test_return_t regression_bug_71231153_poll(memcached_st *);
-
-LIBTEST_LOCAL
-test_return_t test_parse_socket(memcached_st *);
-
-LIBTEST_LOCAL
-test_return_t test_namespace_keyword(memcached_st*);
-
-#ifdef __cplusplus
-}
-#endif