From 9fd31c03436acf24c593dc3a77c905eb137ef570 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Tue, 21 Jun 2011 00:38:30 -0700 Subject: [PATCH] Merge in code such that we are much closer to running the same test framework in all projects. --- libmemcached/behavior.cc | 1 + libmemcached/connect.cc | 16 +- libmemcached/include.am | 1 + libmemcached/io.cc | 21 +- libmemcached/memcached.cc | 6 +- libmemcached/memcached.hpp | 12 +- libmemcached/options.cc | 50 +- libmemcached/options.h | 22 - libmemcached/options.hpp | 56 ++ libmemcached/options/parser.cc | 150 ++--- libmemcached/options/parser.yy | 4 +- libmemcached/options/scanner.cc | 51 +- libmemcached/options/scanner.h | 22 +- libtest/include.am | 2 +- libtest/test.c | 399 ------------ libtest/test.cc | 369 +++++++++++ libtest/test.h | 263 ++++---- tests/{atomsmasher.c => atomsmasher.cc} | 46 +- tests/hash_plus.cc | 16 +- ...shkit_functions.c => hashkit_functions.cc} | 121 ++-- tests/include.am | 8 +- tests/libmemcached_world.h | 29 +- tests/mem_functions.cc | 574 +++++++++--------- tests/{mem_udp.c => mem_udp.cc} | 80 +-- tests/parser.cc | 24 +- tests/plus.cpp | 28 +- tests/{start.c => start.cc} | 0 27 files changed, 1202 insertions(+), 1169 deletions(-) create mode 100644 libmemcached/options.hpp delete mode 100644 libtest/test.c create mode 100644 libtest/test.cc rename tests/{atomsmasher.c => atomsmasher.cc} (82%) rename tests/{hashkit_functions.c => hashkit_functions.cc} (72%) rename tests/{mem_udp.c => mem_udp.cc} (85%) rename tests/{start.c => start.cc} (100%) diff --git a/libmemcached/behavior.cc b/libmemcached/behavior.cc index 6546efba..60aa6b17 100644 --- a/libmemcached/behavior.cc +++ b/libmemcached/behavior.cc @@ -36,6 +36,7 @@ */ #include +#include #include #include diff --git a/libmemcached/connect.cc b/libmemcached/connect.cc index 77cfb3bd..5e6c77f5 100644 --- a/libmemcached/connect.cc +++ b/libmemcached/connect.cc @@ -49,18 +49,14 @@ static memcached_return_t connect_poll(memcached_server_st *ptr) size_t loop_max= 5; - while (--loop_max) // Should only loop on cases of ERESTART or EINTR + if (ptr->root->poll_timeout == 0) { - int error; - if (ptr->root->poll_timeout) - { - error= poll(fds, 1, ptr->root->connect_timeout); - } - else - { - error= 0; - } + return memcached_set_error(*ptr, MEMCACHED_TIMEOUT, MEMCACHED_AT); + } + while (--loop_max) // Should only loop on cases of ERESTART or EINTR + { + int error= poll(fds, 1, ptr->root->connect_timeout); switch (error) { case 1: diff --git a/libmemcached/include.am b/libmemcached/include.am index bd07da6d..e799093f 100644 --- a/libmemcached/include.am +++ b/libmemcached/include.am @@ -22,6 +22,7 @@ noinst_HEADERS+= \ libmemcached/is.h \ libmemcached/libmemcached_probes.h \ libmemcached/memory.h \ + libmemcached/options.hpp \ libmemcached/protocol/ascii_handler.h \ libmemcached/protocol/binary_handler.h \ libmemcached/protocol/common.h \ diff --git a/libmemcached/io.cc b/libmemcached/io.cc index 6594aa75..a787b0c2 100644 --- a/libmemcached/io.cc +++ b/libmemcached/io.cc @@ -57,8 +57,6 @@ static memcached_return_t io_wait(memcached_server_write_instance_st ptr, fds.fd= ptr->fd; fds.events= POLLIN; - int error; - if (read_or_write == MEM_WRITE) /* write */ { fds.events= POLLOUT; @@ -86,18 +84,16 @@ static memcached_return_t io_wait(memcached_server_write_instance_st ptr, } } + if (ptr->root->poll_timeout == 0) // Mimic 0 causes timeout behavior (not all platforms do this) + { + return memcached_set_error(*ptr, MEMCACHED_TIMEOUT, MEMCACHED_AT); + } + size_t loop_max= 5; while (--loop_max) // While loop is for ERESTART or EINTR { - if (ptr->root->poll_timeout) // Mimic 0 causes timeout behavior (not all platforms do this) - { - error= poll(&fds, 1, ptr->root->poll_timeout); - } - else - { - error= 0; - } + int error= poll(&fds, 1, ptr->root->poll_timeout); switch (error) { case 1: // Success! @@ -145,8 +141,6 @@ static memcached_return_t io_wait(memcached_server_write_instance_st ptr, } } - /* Imposssible for anything other then -1 */ - WATCHPOINT_ASSERT(error == -1); ptr->cached_errno= get_socket_errno(); memcached_quit_server(ptr, true); @@ -619,7 +613,8 @@ memcached_server_write_instance_st memcached_io_get_readable_server(memcached_st return NULL; } - switch (poll(fds, host_index, memc->poll_timeout)) + int error= poll(fds, host_index, memc->poll_timeout); + switch (error) { case -1: memcached_set_errno(*memc, get_socket_errno(), MEMCACHED_AT); diff --git a/libmemcached/memcached.cc b/libmemcached/memcached.cc index ee95eaa1..f93f74b4 100644 --- a/libmemcached/memcached.cc +++ b/libmemcached/memcached.cc @@ -36,6 +36,8 @@ */ #include + +#include #include #if 0 @@ -238,7 +240,7 @@ memcached_st *memcached(const char *string, size_t length) if (memcached_success(rc) and memcached_parse_filename(self)) { - rc= memcached_parse_configure_file(self, memcached_parse_filename(self), memcached_parse_filename_length(self)); + rc= memcached_parse_configure_file(*self, memcached_parse_filename(self), memcached_parse_filename_length(self)); } if (memcached_failed(rc)) @@ -266,7 +268,7 @@ memcached_return_t memcached_reset(memcached_st *ptr) if (ptr->configure.filename) { - return memcached_parse_configure_file(ptr, memcached_param_array(ptr->configure.filename)); + return memcached_parse_configure_file(*ptr, memcached_param_array(ptr->configure.filename)); } return MEMCACHED_SUCCESS; diff --git a/libmemcached/memcached.hpp b/libmemcached/memcached.hpp index 0b27291b..58fff4df 100644 --- a/libmemcached/memcached.hpp +++ b/libmemcached/memcached.hpp @@ -117,7 +117,17 @@ public: */ bool configure(const std::string &configuration) { - return memcached_success(memcached_parse_configuration(memc, configuration.c_str(), configuration.size())); + memcached_st *new_memc= memcached(configuration.c_str(), configuration.size()); + + if (new_memc) + { + memcached_free(memc); + memc= new_memc; + + return true; + } + + return false; } /** diff --git a/libmemcached/options.cc b/libmemcached/options.cc index 16f378e8..c1e591d8 100644 --- a/libmemcached/options.cc +++ b/libmemcached/options.cc @@ -36,7 +36,9 @@ */ #include -#include +#include + +#include #include @@ -51,13 +53,13 @@ size_t memcached_parse_filename_length(memcached_st *memc) return memcached_array_size(memc->configure.filename); } -static memcached_return_t _parse_file_options(memcached_st *self, memcached_array_st *real_name) +static memcached_return_t _parse_file_options(memcached_st& self, memcached_array_st *real_name) { FILE *fp= fopen(memcached_array_string(real_name), "r"); if (not fp) { memcached_string_t error_message= memcached_array_to_string(real_name); - memcached_return_t rc= memcached_set_errno(*self, errno, MEMCACHED_AT, error_message); + memcached_return_t rc= memcached_set_errno(self, errno, MEMCACHED_AT, error_message); return rc; } @@ -70,7 +72,7 @@ static memcached_return_t _parse_file_options(memcached_st *self, memcached_arra if (length == 1 and buffer[0] == '\n') continue; - if (memcached_failed(rc= memcached_parse_configuration(self, buffer, length))) + if (memcached_failed(rc= memcached_parse_configuration(&self, buffer, length))) break; } fclose(fp); @@ -101,7 +103,7 @@ memcached_return_t libmemcached_check_configuration(const char *option_string, s assert(memcached_parse_filename(memc_ptr)); assert(memcached_parse_filename_length(memc_ptr)); memcached_string_t filename= memcached_array_to_string(memc_ptr->configure.filename); - rc= _parse_file_options(memc_ptr, memc_ptr->configure.filename); + rc= _parse_file_options(*memc_ptr, memc_ptr->configure.filename); if (memcached_failed(rc) and error_buffer && error_buffer_size) { @@ -138,47 +140,39 @@ void memcached_set_configuration_file(memcached_st *self, const char *filename, self->configure.filename= memcached_strcpy(self, filename, filename_length); } -memcached_return_t memcached_parse_configure_file(memcached_st *self, const char *filename, size_t length) +memcached_return_t memcached_parse_configure_file(memcached_st& self, const char *filename, size_t length) { - WATCHPOINT_ASSERT(self); - if (not self) - { - return MEMCACHED_INVALID_ARGUMENTS; - } - - WATCHPOINT_ASSERT(self); if (not filename) { - return memcached_set_error(*self, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT); + return memcached_set_error(self, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT); } WATCHPOINT_ASSERT(self); if (not length) { - return memcached_set_error(*self, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT); + return memcached_set_error(self, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT); } - memcached_array_st *tmp_array= memcached_strcpy(self, filename, length); + memcached_array_st *tmp_array= memcached_strcpy(&self, filename, length); - memcached_return_t rc= memcached_parse_configure_file(self, tmp_array); + if (not tmp_array) + { + return memcached_set_error(self, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT); + } + + memcached_return_t rc= memcached_parse_configure_file(self, *tmp_array); memcached_array_free(tmp_array); return rc; } -memcached_return_t memcached_parse_configure_file(memcached_st *self, memcached_array_st *filename) +memcached_return_t memcached_parse_configure_file(memcached_st& self, memcached_array_st& filename) { - WATCHPOINT_ASSERT(self); - if (not self) - { - return MEMCACHED_INVALID_ARGUMENTS; - } - - WATCHPOINT_ASSERT(memcached_array_size(filename)); - if (not memcached_array_size(filename)) + WATCHPOINT_ASSERT(memcached_array_size(&filename)); + if (not memcached_array_size(&filename)) { - return memcached_set_error(*self, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT); + return memcached_set_error(self, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT); } - return _parse_file_options(self, filename); + return _parse_file_options(self, &filename); } diff --git a/libmemcached/options.h b/libmemcached/options.h index 893da2ac..f5a6e06d 100644 --- a/libmemcached/options.h +++ b/libmemcached/options.h @@ -44,28 +44,6 @@ extern "C" { LIBMEMCACHED_API memcached_return_t libmemcached_check_configuration(const char *option_string, size_t length, char *error_buffer, size_t error_buffer_size); -LIBMEMCACHED_LOCAL - void memcached_set_configuration_file(memcached_st *self, const char *filename, size_t filename_length); - -LIBMEMCACHED_LOCAL - memcached_return_t memcached_parse_configuration(memcached_st *ptr, const char *option_string, size_t length); - -LIBMEMCACHED_LOCAL - const char *memcached_parse_filename(memcached_st *memc); - -LIBMEMCACHED_LOCAL - size_t memcached_parse_filename_length(memcached_st *memc); - #ifdef __cplusplus } #endif - -#ifdef __cplusplus - -LIBMEMCACHED_LOCAL - memcached_return_t memcached_parse_configure_file(memcached_st *self, const char *filename, size_t length); - -LIBMEMCACHED_LOCAL - memcached_return_t memcached_parse_configure_file(memcached_st *self, memcached_array_st *filename); - -#endif diff --git a/libmemcached/options.hpp b/libmemcached/options.hpp new file mode 100644 index 00000000..bc717322 --- /dev/null +++ b/libmemcached/options.hpp @@ -0,0 +1,56 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * 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 + +LIBMEMCACHED_LOCAL + void memcached_set_configuration_file(memcached_st *self, const char *filename, size_t filename_length); + +LIBMEMCACHED_LOCAL + const char *memcached_parse_filename(memcached_st *memc); + +LIBMEMCACHED_LOCAL + memcached_return_t memcached_parse_configuration(memcached_st *ptr, const char *option_string, size_t length); + +LIBMEMCACHED_LOCAL + size_t memcached_parse_filename_length(memcached_st *memc); + +LIBMEMCACHED_LOCAL + memcached_return_t memcached_parse_configure_file(memcached_st&, const char *filename, size_t length); + +LIBMEMCACHED_LOCAL + memcached_return_t memcached_parse_configure_file(memcached_st&, memcached_array_st& filename); diff --git a/libmemcached/options/parser.cc b/libmemcached/options/parser.cc index d199a5fa..2e478dcc 100644 --- a/libmemcached/options/parser.cc +++ b/libmemcached/options/parser.cc @@ -83,6 +83,8 @@ #include #include +#include + #include #include #include @@ -102,7 +104,7 @@ inline void config_error(Context *context, yyscan_t *scanner, const char *error) /* Line 189 of yacc.c */ -#line 106 "libmemcached/options/parser.cc" +#line 108 "libmemcached/options/parser.cc" /* Enabling traces. */ #ifndef YYDEBUG @@ -213,7 +215,7 @@ inline void config_error(Context *context, yyscan_t *scanner, const char *error) /* Line 264 of yacc.c */ -#line 217 "libmemcached/options/parser.cc" +#line 219 "libmemcached/options/parser.cc" #ifdef short # undef short @@ -522,13 +524,13 @@ static const yytype_int8 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 157, 157, 158, 162, 164, 166, 168, 173, 178, - 182, 186, 197, 205, 213, 217, 221, 225, 229, 236, - 243, 254, 261, 268, 275, 281, 285, 289, 293, 297, - 301, 305, 309, 313, 317, 321, 325, 332, 336, 340, - 344, 348, 352, 356, 360, 364, 368, 372, 376, 383, - 384, 389, 390, 395, 399, 403, 407, 411, 415, 419, - 423, 427, 434, 438, 446, 450, 454 + 0, 159, 159, 160, 164, 166, 168, 170, 175, 180, + 184, 188, 199, 207, 215, 219, 223, 227, 231, 238, + 245, 256, 263, 270, 277, 283, 287, 291, 295, 299, + 303, 307, 311, 315, 319, 323, 327, 334, 338, 342, + 346, 350, 354, 358, 362, 366, 370, 374, 378, 385, + 386, 391, 392, 397, 401, 405, 409, 413, 417, 421, + 425, 429, 436, 440, 448, 452, 456 }; #endif @@ -1520,28 +1522,28 @@ yyreduce: case 4: /* Line 1464 of yacc.c */ -#line 163 "libmemcached/options/parser.yy" +#line 165 "libmemcached/options/parser.yy" { ;} break; case 5: /* Line 1464 of yacc.c */ -#line 165 "libmemcached/options/parser.yy" +#line 167 "libmemcached/options/parser.yy" { ;} break; case 6: /* Line 1464 of yacc.c */ -#line 167 "libmemcached/options/parser.yy" +#line 169 "libmemcached/options/parser.yy" { ;} break; case 7: /* Line 1464 of yacc.c */ -#line 169 "libmemcached/options/parser.yy" +#line 171 "libmemcached/options/parser.yy" { context->set_end(); YYACCEPT; @@ -1551,7 +1553,7 @@ yyreduce: case 8: /* Line 1464 of yacc.c */ -#line 174 "libmemcached/options/parser.yy" +#line 176 "libmemcached/options/parser.yy" { context->rc= MEMCACHED_PARSE_USER_ERROR; parser_abort(context, NULL); @@ -1561,7 +1563,7 @@ yyreduce: case 9: /* Line 1464 of yacc.c */ -#line 179 "libmemcached/options/parser.yy" +#line 181 "libmemcached/options/parser.yy" { memcached_reset(context->memc); ;} @@ -1570,7 +1572,7 @@ yyreduce: case 10: /* Line 1464 of yacc.c */ -#line 183 "libmemcached/options/parser.yy" +#line 185 "libmemcached/options/parser.yy" { yydebug= 1; ;} @@ -1579,9 +1581,9 @@ yyreduce: case 11: /* Line 1464 of yacc.c */ -#line 187 "libmemcached/options/parser.yy" +#line 189 "libmemcached/options/parser.yy" { - if ((context->rc= memcached_parse_configure_file(context->memc, (yyvsp[(3) - (3)].string).c_str, (yyvsp[(3) - (3)].string).size)) != MEMCACHED_SUCCESS) + if ((context->rc= memcached_parse_configure_file(*context->memc, (yyvsp[(3) - (3)].string).c_str, (yyvsp[(3) - (3)].string).size)) != MEMCACHED_SUCCESS) { parser_abort(context, NULL); } @@ -1591,7 +1593,7 @@ yyreduce: case 12: /* Line 1464 of yacc.c */ -#line 198 "libmemcached/options/parser.yy" +#line 200 "libmemcached/options/parser.yy" { if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, (yyvsp[(2) - (4)].server).c_str, (yyvsp[(3) - (4)].number), (yyvsp[(4) - (4)].number)))) { @@ -1604,7 +1606,7 @@ yyreduce: case 13: /* Line 1464 of yacc.c */ -#line 206 "libmemcached/options/parser.yy" +#line 208 "libmemcached/options/parser.yy" { if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, (yyvsp[(2) - (4)].server).c_str, (yyvsp[(3) - (4)].number), (yyvsp[(4) - (4)].number)))) { @@ -1617,7 +1619,7 @@ yyreduce: case 14: /* Line 1464 of yacc.c */ -#line 214 "libmemcached/options/parser.yy" +#line 216 "libmemcached/options/parser.yy" { memcached_set_configuration_file(context->memc, (yyvsp[(2) - (2)].string).c_str, (yyvsp[(2) - (2)].string).size); ;} @@ -1626,7 +1628,7 @@ yyreduce: case 15: /* Line 1464 of yacc.c */ -#line 218 "libmemcached/options/parser.yy" +#line 220 "libmemcached/options/parser.yy" { context->memc->configure.initial_pool_size= (yyvsp[(2) - (2)].number); ;} @@ -1635,7 +1637,7 @@ yyreduce: case 16: /* Line 1464 of yacc.c */ -#line 222 "libmemcached/options/parser.yy" +#line 224 "libmemcached/options/parser.yy" { context->memc->configure.max_pool_size= (yyvsp[(2) - (2)].number); ;} @@ -1644,7 +1646,7 @@ yyreduce: case 18: /* Line 1464 of yacc.c */ -#line 230 "libmemcached/options/parser.yy" +#line 232 "libmemcached/options/parser.yy" { if ((context->rc= memcached_set_prefix_key(context->memc, (yyvsp[(2) - (2)].string).c_str, (yyvsp[(2) - (2)].string).size)) != MEMCACHED_SUCCESS) { @@ -1656,7 +1658,7 @@ yyreduce: case 19: /* Line 1464 of yacc.c */ -#line 237 "libmemcached/options/parser.yy" +#line 239 "libmemcached/options/parser.yy" { if ((context->rc= memcached_behavior_set(context->memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, (yyvsp[(2) - (2)].distribution))) != MEMCACHED_SUCCESS) { @@ -1668,7 +1670,7 @@ yyreduce: case 20: /* Line 1464 of yacc.c */ -#line 244 "libmemcached/options/parser.yy" +#line 246 "libmemcached/options/parser.yy" { if ((context->rc= memcached_behavior_set(context->memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, (yyvsp[(2) - (4)].distribution))) != MEMCACHED_SUCCESS) { @@ -1684,7 +1686,7 @@ yyreduce: case 21: /* Line 1464 of yacc.c */ -#line 255 "libmemcached/options/parser.yy" +#line 257 "libmemcached/options/parser.yy" { if ((context->rc= memcached_behavior_set(context->memc, MEMCACHED_BEHAVIOR_HASH, (yyvsp[(2) - (2)].hash))) != MEMCACHED_SUCCESS) { @@ -1696,7 +1698,7 @@ yyreduce: case 22: /* Line 1464 of yacc.c */ -#line 262 "libmemcached/options/parser.yy" +#line 264 "libmemcached/options/parser.yy" { if ((context->rc= memcached_behavior_set(context->memc, (yyvsp[(1) - (2)].behavior), (yyvsp[(2) - (2)].number))) != MEMCACHED_SUCCESS) { @@ -1708,7 +1710,7 @@ yyreduce: case 23: /* Line 1464 of yacc.c */ -#line 269 "libmemcached/options/parser.yy" +#line 271 "libmemcached/options/parser.yy" { if ((context->rc= memcached_behavior_set(context->memc, (yyvsp[(1) - (1)].behavior), true)) != MEMCACHED_SUCCESS) { @@ -1720,7 +1722,7 @@ yyreduce: case 24: /* Line 1464 of yacc.c */ -#line 276 "libmemcached/options/parser.yy" +#line 278 "libmemcached/options/parser.yy" { ;} break; @@ -1728,7 +1730,7 @@ yyreduce: case 25: /* Line 1464 of yacc.c */ -#line 282 "libmemcached/options/parser.yy" +#line 284 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS; ;} @@ -1737,7 +1739,7 @@ yyreduce: case 26: /* Line 1464 of yacc.c */ -#line 286 "libmemcached/options/parser.yy" +#line 288 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT; ;} @@ -1746,7 +1748,7 @@ yyreduce: case 27: /* Line 1464 of yacc.c */ -#line 290 "libmemcached/options/parser.yy" +#line 292 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK; ;} @@ -1755,7 +1757,7 @@ yyreduce: case 28: /* Line 1464 of yacc.c */ -#line 294 "libmemcached/options/parser.yy" +#line 296 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK; ;} @@ -1764,7 +1766,7 @@ yyreduce: case 29: /* Line 1464 of yacc.c */ -#line 298 "libmemcached/options/parser.yy" +#line 300 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH; ;} @@ -1773,7 +1775,7 @@ yyreduce: case 30: /* Line 1464 of yacc.c */ -#line 302 "libmemcached/options/parser.yy" +#line 304 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS; ;} @@ -1782,7 +1784,7 @@ yyreduce: case 31: /* Line 1464 of yacc.c */ -#line 306 "libmemcached/options/parser.yy" +#line 308 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_POLL_TIMEOUT; ;} @@ -1791,7 +1793,7 @@ yyreduce: case 32: /* Line 1464 of yacc.c */ -#line 310 "libmemcached/options/parser.yy" +#line 312 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_RCV_TIMEOUT; ;} @@ -1800,7 +1802,7 @@ yyreduce: case 33: /* Line 1464 of yacc.c */ -#line 314 "libmemcached/options/parser.yy" +#line 316 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_RETRY_TIMEOUT; ;} @@ -1809,7 +1811,7 @@ yyreduce: case 34: /* Line 1464 of yacc.c */ -#line 318 "libmemcached/options/parser.yy" +#line 320 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_SND_TIMEOUT; ;} @@ -1818,7 +1820,7 @@ yyreduce: case 35: /* Line 1464 of yacc.c */ -#line 322 "libmemcached/options/parser.yy" +#line 324 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE; ;} @@ -1827,7 +1829,7 @@ yyreduce: case 36: /* Line 1464 of yacc.c */ -#line 326 "libmemcached/options/parser.yy" +#line 328 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE; ;} @@ -1836,7 +1838,7 @@ yyreduce: case 37: /* Line 1464 of yacc.c */ -#line 333 "libmemcached/options/parser.yy" +#line 335 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_BINARY_PROTOCOL; ;} @@ -1845,7 +1847,7 @@ yyreduce: case 38: /* Line 1464 of yacc.c */ -#line 337 "libmemcached/options/parser.yy" +#line 339 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_BUFFER_REQUESTS; ;} @@ -1854,7 +1856,7 @@ yyreduce: case 39: /* Line 1464 of yacc.c */ -#line 341 "libmemcached/options/parser.yy" +#line 343 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY; ;} @@ -1863,7 +1865,7 @@ yyreduce: case 40: /* Line 1464 of yacc.c */ -#line 345 "libmemcached/options/parser.yy" +#line 347 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_NOREPLY; ;} @@ -1872,7 +1874,7 @@ yyreduce: case 41: /* Line 1464 of yacc.c */ -#line 349 "libmemcached/options/parser.yy" +#line 351 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ; ;} @@ -1881,7 +1883,7 @@ yyreduce: case 42: /* Line 1464 of yacc.c */ -#line 353 "libmemcached/options/parser.yy" +#line 355 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_SORT_HOSTS; ;} @@ -1890,7 +1892,7 @@ yyreduce: case 43: /* Line 1464 of yacc.c */ -#line 357 "libmemcached/options/parser.yy" +#line 359 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_SUPPORT_CAS; ;} @@ -1899,7 +1901,7 @@ yyreduce: case 44: /* Line 1464 of yacc.c */ -#line 361 "libmemcached/options/parser.yy" +#line 363 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_TCP_NODELAY; ;} @@ -1908,7 +1910,7 @@ yyreduce: case 45: /* Line 1464 of yacc.c */ -#line 365 "libmemcached/options/parser.yy" +#line 367 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_TCP_KEEPALIVE; ;} @@ -1917,7 +1919,7 @@ yyreduce: case 46: /* Line 1464 of yacc.c */ -#line 369 "libmemcached/options/parser.yy" +#line 371 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_TCP_KEEPIDLE; ;} @@ -1926,7 +1928,7 @@ yyreduce: case 47: /* Line 1464 of yacc.c */ -#line 373 "libmemcached/options/parser.yy" +#line 375 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_USE_UDP; ;} @@ -1935,7 +1937,7 @@ yyreduce: case 48: /* Line 1464 of yacc.c */ -#line 377 "libmemcached/options/parser.yy" +#line 379 "libmemcached/options/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_VERIFY_KEY; ;} @@ -1944,35 +1946,35 @@ yyreduce: case 49: /* Line 1464 of yacc.c */ -#line 383 "libmemcached/options/parser.yy" +#line 385 "libmemcached/options/parser.yy" { (yyval.number)= MEMCACHED_DEFAULT_PORT;;} break; case 50: /* Line 1464 of yacc.c */ -#line 385 "libmemcached/options/parser.yy" +#line 387 "libmemcached/options/parser.yy" { ;} break; case 51: /* Line 1464 of yacc.c */ -#line 389 "libmemcached/options/parser.yy" +#line 391 "libmemcached/options/parser.yy" { (yyval.number)= 1; ;} break; case 52: /* Line 1464 of yacc.c */ -#line 391 "libmemcached/options/parser.yy" +#line 393 "libmemcached/options/parser.yy" { ;} break; case 53: /* Line 1464 of yacc.c */ -#line 396 "libmemcached/options/parser.yy" +#line 398 "libmemcached/options/parser.yy" { (yyval.hash)= MEMCACHED_HASH_MD5; ;} @@ -1981,7 +1983,7 @@ yyreduce: case 54: /* Line 1464 of yacc.c */ -#line 400 "libmemcached/options/parser.yy" +#line 402 "libmemcached/options/parser.yy" { (yyval.hash)= MEMCACHED_HASH_CRC; ;} @@ -1990,7 +1992,7 @@ yyreduce: case 55: /* Line 1464 of yacc.c */ -#line 404 "libmemcached/options/parser.yy" +#line 406 "libmemcached/options/parser.yy" { (yyval.hash)= MEMCACHED_HASH_FNV1_64; ;} @@ -1999,7 +2001,7 @@ yyreduce: case 56: /* Line 1464 of yacc.c */ -#line 408 "libmemcached/options/parser.yy" +#line 410 "libmemcached/options/parser.yy" { (yyval.hash)= MEMCACHED_HASH_FNV1A_64; ;} @@ -2008,7 +2010,7 @@ yyreduce: case 57: /* Line 1464 of yacc.c */ -#line 412 "libmemcached/options/parser.yy" +#line 414 "libmemcached/options/parser.yy" { (yyval.hash)= MEMCACHED_HASH_FNV1_32; ;} @@ -2017,7 +2019,7 @@ yyreduce: case 58: /* Line 1464 of yacc.c */ -#line 416 "libmemcached/options/parser.yy" +#line 418 "libmemcached/options/parser.yy" { (yyval.hash)= MEMCACHED_HASH_FNV1A_32; ;} @@ -2026,7 +2028,7 @@ yyreduce: case 59: /* Line 1464 of yacc.c */ -#line 420 "libmemcached/options/parser.yy" +#line 422 "libmemcached/options/parser.yy" { (yyval.hash)= MEMCACHED_HASH_HSIEH; ;} @@ -2035,7 +2037,7 @@ yyreduce: case 60: /* Line 1464 of yacc.c */ -#line 424 "libmemcached/options/parser.yy" +#line 426 "libmemcached/options/parser.yy" { (yyval.hash)= MEMCACHED_HASH_MURMUR; ;} @@ -2044,7 +2046,7 @@ yyreduce: case 61: /* Line 1464 of yacc.c */ -#line 428 "libmemcached/options/parser.yy" +#line 430 "libmemcached/options/parser.yy" { (yyval.hash)= MEMCACHED_HASH_JENKINS; ;} @@ -2053,7 +2055,7 @@ yyreduce: case 62: /* Line 1464 of yacc.c */ -#line 435 "libmemcached/options/parser.yy" +#line 437 "libmemcached/options/parser.yy" { (yyval.string)= (yyvsp[(1) - (1)].string); ;} @@ -2062,7 +2064,7 @@ yyreduce: case 63: /* Line 1464 of yacc.c */ -#line 439 "libmemcached/options/parser.yy" +#line 441 "libmemcached/options/parser.yy" { (yyval.string).c_str= (yyvsp[(1) - (1)].string).c_str +1; // +1 to move use passed the initial quote (yyval.string).size= (yyvsp[(1) - (1)].string).size -2; // -2 removes the begin and end quote @@ -2072,7 +2074,7 @@ yyreduce: case 64: /* Line 1464 of yacc.c */ -#line 447 "libmemcached/options/parser.yy" +#line 449 "libmemcached/options/parser.yy" { (yyval.distribution)= MEMCACHED_DISTRIBUTION_CONSISTENT; ;} @@ -2081,7 +2083,7 @@ yyreduce: case 65: /* Line 1464 of yacc.c */ -#line 451 "libmemcached/options/parser.yy" +#line 453 "libmemcached/options/parser.yy" { (yyval.distribution)= MEMCACHED_DISTRIBUTION_MODULA; ;} @@ -2090,7 +2092,7 @@ yyreduce: case 66: /* Line 1464 of yacc.c */ -#line 455 "libmemcached/options/parser.yy" +#line 457 "libmemcached/options/parser.yy" { (yyval.distribution)= MEMCACHED_DISTRIBUTION_RANDOM; ;} @@ -2099,7 +2101,7 @@ yyreduce: /* Line 1464 of yacc.c */ -#line 2103 "libmemcached/options/parser.cc" +#line 2105 "libmemcached/options/parser.cc" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -2311,7 +2313,7 @@ yyreturn: /* Line 1684 of yacc.c */ -#line 460 "libmemcached/options/parser.yy" +#line 462 "libmemcached/options/parser.yy" void Context::start() diff --git a/libmemcached/options/parser.yy b/libmemcached/options/parser.yy index 6a7bd9b9..722ced5f 100644 --- a/libmemcached/options/parser.yy +++ b/libmemcached/options/parser.yy @@ -40,6 +40,8 @@ #include #include +#include + #include #include #include @@ -185,7 +187,7 @@ statement: } | INCLUDE ' ' string { - if ((context->rc= memcached_parse_configure_file(context->memc, $3.c_str, $3.size)) != MEMCACHED_SUCCESS) + if ((context->rc= memcached_parse_configure_file(*context->memc, $3.c_str, $3.size)) != MEMCACHED_SUCCESS) { parser_abort(context, NULL); } diff --git a/libmemcached/options/scanner.cc b/libmemcached/options/scanner.cc index fd5a0cb9..686db323 100644 --- a/libmemcached/options/scanner.cc +++ b/libmemcached/options/scanner.cc @@ -227,6 +227,11 @@ typedef void* yyscan_t; typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + /* %if-not-reentrant */ /* %endif */ @@ -257,11 +262,6 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state @@ -284,7 +284,7 @@ struct yy_buffer_state /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - int yy_n_chars; + yy_size_t yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -381,7 +381,7 @@ static void config__init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanne YY_BUFFER_STATE config__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); YY_BUFFER_STATE config__scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE config__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); +YY_BUFFER_STATE config__scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner ); /* %endif */ @@ -1172,8 +1172,8 @@ struct yyguts_t size_t yy_buffer_stack_max; /**< capacity of stack. */ YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ char yy_hold_char; - int yy_n_chars; - int yyleng_r; + yy_size_t yy_n_chars; + yy_size_t yyleng_r; char *yy_c_buf_p; int yy_init; int yy_start; @@ -1236,7 +1236,7 @@ FILE *config_get_out (yyscan_t yyscanner ); void config_set_out (FILE * out_str ,yyscan_t yyscanner ); -int config_get_leng (yyscan_t yyscanner ); +yy_size_t config_get_leng (yyscan_t yyscanner ); char *config_get_text (yyscan_t yyscanner ); @@ -1244,10 +1244,6 @@ int config_get_lineno (yyscan_t yyscanner ); void config_set_lineno (int line_number ,yyscan_t yyscanner ); -int config_get_column (yyscan_t yyscanner ); - -void config_set_column (int column_no ,yyscan_t yyscanner ); - /* %if-bison-bridge */ YYSTYPE * config_get_lval (yyscan_t yyscanner ); @@ -1311,7 +1307,7 @@ static int input (yyscan_t yyscanner ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) +#define ECHO fwrite( yytext, yyleng, 1, yyout ) /* %endif */ /* %if-c++-only C++ definition */ /* %endif */ @@ -1326,7 +1322,7 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - unsigned n; \ + yy_size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -1443,7 +1439,7 @@ YY_DECL -#line 1447 "libmemcached/options/scanner.cc" +#line 1443 "libmemcached/options/scanner.cc" yylval = yylval_param; @@ -1919,7 +1915,7 @@ YY_RULE_SETUP #line 196 "libmemcached/options/scanner.l" ECHO; YY_BREAK -#line 1923 "libmemcached/options/scanner.cc" +#line 1919 "libmemcached/options/scanner.cc" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -2119,7 +2115,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else { - int num_to_read = + yy_size_t num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) @@ -2133,7 +2129,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) if ( b->yy_is_our_buffer ) { - int new_size = b->yy_buf_size * 2; + yy_size_t new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -2164,7 +2160,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, (size_t) num_to_read ); + yyg->yy_n_chars, num_to_read ); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } @@ -2311,7 +2307,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else { /* need more input */ - int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; ++yyg->yy_c_buf_p; switch ( yy_get_next_buffer( yyscanner ) ) @@ -2335,7 +2331,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) case EOB_ACT_END_OF_FILE: { if ( config_wrap(yyscanner ) ) - return EOF; + return 0; if ( ! yyg->yy_did_buffer_switch_on_eof ) YY_NEW_FILE; @@ -2657,7 +2653,7 @@ static void config_ensure_buffer_stack (yyscan_t yyscanner) /* %if-c++-only */ /* %endif */ { - int num_to_alloc; + yy_size_t num_to_alloc; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!yyg->yy_buffer_stack) { @@ -2761,12 +2757,11 @@ YY_BUFFER_STATE config__scan_string (yyconst char * yystr , yyscan_t yyscanner) * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE config__scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) +YY_BUFFER_STATE config__scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) { YY_BUFFER_STATE b; char *buf; - yy_size_t n; - int i; + yy_size_t n, i; /* Get memory for full buffer, including space for trailing EOB's. */ n = _yybytes_len + 2; @@ -2886,7 +2881,7 @@ FILE *config_get_out (yyscan_t yyscanner) /** Get the length of the current token. * @param yyscanner The scanner object. */ -int config_get_leng (yyscan_t yyscanner) +yy_size_t config_get_leng (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyleng; diff --git a/libmemcached/options/scanner.h b/libmemcached/options/scanner.h index 3e7b5aee..26031bac 100644 --- a/libmemcached/options/scanner.h +++ b/libmemcached/options/scanner.h @@ -188,6 +188,11 @@ typedef void* yyscan_t; typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + /* %if-not-reentrant */ /* %endif */ @@ -196,11 +201,6 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; /* %endif */ /* %endif */ -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state @@ -223,7 +223,7 @@ struct yy_buffer_state /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - int yy_n_chars; + yy_size_t yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -279,7 +279,7 @@ void config_pop_buffer_state (yyscan_t yyscanner ); YY_BUFFER_STATE config__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); YY_BUFFER_STATE config__scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE config__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); +YY_BUFFER_STATE config__scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner ); /* %endif */ @@ -360,7 +360,7 @@ FILE *config_get_out (yyscan_t yyscanner ); void config_set_out (FILE * out_str ,yyscan_t yyscanner ); -int config_get_leng (yyscan_t yyscanner ); +yy_size_t config_get_leng (yyscan_t yyscanner ); char *config_get_text (yyscan_t yyscanner ); @@ -368,10 +368,6 @@ int config_get_lineno (yyscan_t yyscanner ); void config_set_lineno (int line_number ,yyscan_t yyscanner ); -int config_get_column (yyscan_t yyscanner ); - -void config_set_column (int column_no ,yyscan_t yyscanner ); - /* %if-bison-bridge */ YYSTYPE * config_get_lval (yyscan_t yyscanner ); @@ -474,6 +470,6 @@ extern int config_lex \ #line 196 "libmemcached/options/scanner.l" -#line 478 "libmemcached/options/scanner.h" +#line 474 "libmemcached/options/scanner.h" #undef config_IN_HEADER #endif /* config_HEADER_H */ diff --git a/libtest/include.am b/libtest/include.am index fb859b66..a7a795fd 100644 --- a/libtest/include.am +++ b/libtest/include.am @@ -26,7 +26,7 @@ libtest_libserver_la_SOURCES= libtest/server.c noinst_LTLIBRARIES+= libtest/libtest.la libtest_libtest_la_SOURCES=\ - libtest/test.c + libtest/test.cc libtest_libtest_la_CFLAGS= ${AM_CFLAGS} ${NO_CONVERSION} libtest_libtest_la_CPPFLAGS= ${AM_CPPFLAGS} diff --git a/libtest/test.c b/libtest/test.c deleted file mode 100644 index 0905e13b..00000000 --- a/libtest/test.c +++ /dev/null @@ -1,399 +0,0 @@ -/* uTest - * Copyright (C) 2006-2009 Brian Aker - * All rights reserved. - * - * Use and distribution licensed under the BSD license. See - * the COPYING file in the parent directory for full text. - */ - -/* - Sample test application. -*/ - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -static void world_stats_print(world_stats_st *stats) -{ - fputc('\n', stderr); - fprintf(stderr, "Total Collections\t\t\t\t%u\n", stats->collection_total); - fprintf(stderr, "\tFailed Collections\t\t\t%u\n", stats->collection_failed); - fprintf(stderr, "\tSkipped Collections\t\t\t%u\n", stats->collection_skipped); - fprintf(stderr, "\tSucceeded Collections\t\t%u\n", stats->collection_success); - fputc('\n', stderr); - fprintf(stderr, "Total\t\t\t\t%u\n", stats->total); - fprintf(stderr, "\tFailed\t\t\t%u\n", stats->failed); - fprintf(stderr, "\tSkipped\t\t\t%u\n", stats->skipped); - fprintf(stderr, "\tSucceeded\t\t%u\n", stats->success); -} - -long int timedif(struct timeval a, struct timeval b) -{ - long us, s; - - us = (int)(a.tv_usec - b.tv_usec); - us /= 1000; - s = (int)(a.tv_sec - b.tv_sec); - s *= 1000; - return s + us; -} - -const char *test_strerror(test_return_t code) -{ - switch (code) { - case TEST_SUCCESS: - return "ok"; - case TEST_FAILURE: - return "failed"; - case TEST_FATAL: - return "failed"; - case TEST_SKIPPED: - return "skipped"; - case TEST_MEMORY_ALLOCATION_FAILURE: - return "memory allocation"; - case TEST_MAXIMUM_RETURN: - default: - fprintf(stderr, "Unknown return value\n"); - abort(); - } -} - -void create_core(void) -{ - if (getenv("LIBMEMCACHED_NO_COREDUMP") == NULL) - { - pid_t pid= fork(); - - if (pid == 0) - { - abort(); - } - else - { - while (waitpid(pid, NULL, 0) != pid) - { - ; - } - } - } -} - - -static test_return_t _runner_default(test_callback_fn func, void *p) -{ - if (func) - { - return func(p); - } - else - { - return TEST_SUCCESS; - } -} - -static world_runner_st defualt_runners= { - _runner_default, - _runner_default, - _runner_default -}; - -static test_return_t _default_callback(void *p) -{ - (void)p; - - return TEST_SUCCESS; -} - -static inline void set_default_fn(test_callback_fn *fn) -{ - if (*fn == NULL) - { - *fn= _default_callback; - } -} - -static collection_st *init_world(world_st *world) -{ - if (! world->runner) - { - world->runner= &defualt_runners; - } - - set_default_fn(&world->collection.startup); - set_default_fn(&world->collection.shutdown); - - return world->collections; -} - - -int main(int argc, char *argv[]) -{ - test_return_t return_code; - unsigned int x; - char *collection_to_run= NULL; - char *wildcard= NULL; - world_st world; - collection_st *collection; - void *world_ptr; - - world_stats_st stats; - -#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT - if (sasl_client_init(NULL) != SASL_OK) - { - fprintf(stderr, "Failed to initialize sasl library!\n"); - return EXIT_FAILURE; - } -#endif - - memset(&stats, 0, sizeof(stats)); - memset(&world, 0, sizeof(world)); - get_world(&world); - - collection= init_world(&world); - - if (world.create) - { - test_return_t error; - world_ptr= world.create(&error); - if (error != TEST_SUCCESS) - exit(1); - } - else - { - world_ptr= NULL; - } - - if (argc > 1) - { - collection_to_run= argv[1]; - } - else if (getenv("TEST_COLLECTION")) - { - collection_to_run= getenv("TEST_COLLECTION"); - } - - if (collection_to_run) - printf("Only testing %s\n", collection_to_run); - - if (argc == 3) - { - wildcard= argv[2]; - } - - for (collection_st *next= collection; next->name; next++) - { - test_return_t collection_rc= TEST_SUCCESS; - test_st *run; - bool failed= false; - bool skipped= false; - - run= next->tests; - if (collection_to_run && fnmatch(collection_to_run, next->name, 0)) - continue; - - stats.collection_total++; - - collection_rc= world.collection.startup(world_ptr); - - if (collection_rc != TEST_SUCCESS) - goto skip_pre; - - if (next->pre) - { - collection_rc= world.runner->pre(next->pre, world_ptr); - } - -skip_pre: - switch (collection_rc) - { - case TEST_SUCCESS: - fprintf(stderr, "\n%s\n\n", next->name); - break; - case TEST_FATAL: - fprintf(stderr, "\n%s [ failed ]\n\n", next->name); - stats.collection_failed++; - goto cleanup; - case TEST_FAILURE: - fprintf(stderr, "\n%s [ failed ]\n\n", next->name); - stats.collection_failed++; - goto cleanup; - case TEST_SKIPPED: - fprintf(stderr, "\n%s [ skipping ]\n\n", next->name); - stats.collection_skipped++; - goto cleanup; - case TEST_MEMORY_ALLOCATION_FAILURE: - case TEST_MAXIMUM_RETURN: - default: - assert(0); - break; - } - - - for (x= 0; run->name; run++) - { - struct timeval start_time, end_time; - long int load_time= 0; - - if (wildcard && fnmatch(wildcard, run->name, 0)) - continue; - - fprintf(stderr, "Testing %s", run->name); - - if (world.test.startup) - { - world.test.startup(world_ptr); - } - - if (run->requires_flush && world.test.flush) - { - world.test.flush(world_ptr); - } - - if (world.test.pre_run) - { - world.test.pre_run(world_ptr); - } - - - // Runner code - { -#if 0 - if (next->pre && world.runner->pre) - { - return_code= world.runner->pre(next->pre, world_ptr); - - if (return_code != TEST_SUCCESS) - { - goto error; - } - } -#endif - - gettimeofday(&start_time, NULL); - return_code= world.runner->run(run->test_fn, world_ptr); - gettimeofday(&end_time, NULL); - load_time= timedif(end_time, start_time); - -#if 0 - if (next->post && world.runner->post) - { - (void) world.runner->post(next->post, world_ptr); - } -#endif - } - - if (world.test.post_run) - { - world.test.post_run(world_ptr); - } - - stats.total++; - - fprintf(stderr, "\t\t\t\t\t"); - - switch (return_code) - { - case TEST_SUCCESS: - fprintf(stderr, "%ld.%03ld ", load_time / 1000, load_time % 1000); - stats.success++; - break; - - case TEST_FATAL: - case TEST_FAILURE: -#if 0 - push_failed_test(next->name, run->name); -#endif - stats.failed++; - failed= true; - break; - - case TEST_SKIPPED: - stats.skipped++; - skipped= true; - break; - - case TEST_MEMORY_ALLOCATION_FAILURE: - fprintf(stderr, "Exhausted memory, quitting\n"); - abort(); - - case TEST_MAXIMUM_RETURN: - default: - assert(0); // Coding error. - break; - } - - fprintf(stderr, "[ %s ]\n", test_strerror(return_code)); - - if (world.test.on_error) - { - test_return_t rc; - rc= world.test.on_error(return_code, world_ptr); - - if (rc != TEST_SUCCESS) - break; - } - - // If we get a TEST_FATAL we move onto the next collection - if (return_code == TEST_FATAL) - { - break; - } - } - - if (next->post && world.runner->post) - { - (void) world.runner->post(next->post, world_ptr); - } - - if (! failed && ! skipped) - { - stats.collection_success++; - } -cleanup: - - world.collection.shutdown(world_ptr); - } - - 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 - { - fprintf(stderr, "All tests completed successfully\n\n"); - } - - if (world.destroy) - { - test_return_t error; - error= world.destroy(world_ptr); - - if (error != TEST_SUCCESS) - { - fprintf(stderr, "Failure during shutdown.\n"); - stats.failed++; // We do this to make our exit code return EXIT_FAILURE - } - } - - world_stats_print(&stats); - - return stats.failed == 0 ? 0 : 1; -} diff --git a/libtest/test.cc b/libtest/test.cc new file mode 100644 index 00000000..2c57d206 --- /dev/null +++ b/libtest/test.cc @@ -0,0 +1,369 @@ +/* uTest + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker + * All rights reserved. + * + * Use and distribution licensed under the BSD license. See + * the COPYING file in the parent directory for full text. + */ + + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifndef __INTEL_COMPILER +#pragma GCC diagnostic ignored "-Wold-style-cast" +#endif + +static void world_stats_print(world_stats_st *stats) +{ + std::cout << "\tTotal Collections\t\t\t\t" << stats->collection_total << std::endl; + std::cout << "\tFailed Collections\t\t\t\t" << stats->collection_failed << std::endl; + std::cout << "\tSkipped Collections\t\t\t\t" << stats->collection_skipped << std::endl; + std::cout << "\tSucceeded Collections\t\t\t\t" << stats->collection_success << std::endl; + std::cout << std::endl; + std::cout << "Total\t\t\t\t" << stats->total << std::endl; + std::cout << "\tFailed\t\t\t" << stats->failed << std::endl; + std::cout << "\tSkipped\t\t\t" << stats->skipped << std::endl; + std::cout << "\tSucceeded\t\t" << stats->success << std::endl; +} + +static long int timedif(struct timeval a, struct timeval b) +{ + long us, s; + + us = (long)(a.tv_usec - b.tv_usec); + us /= 1000; + s = (long)(a.tv_sec - b.tv_sec); + s *= 1000; + return s + us; +} + +const char *test_strerror(test_return_t code) +{ + switch (code) { + case TEST_SUCCESS: + return "ok"; + case TEST_FAILURE: + return "failed"; + case TEST_FATAL: + return "failed"; + case TEST_MEMORY_ALLOCATION_FAILURE: + return "memory allocation"; + case TEST_SKIPPED: + return "skipped"; + case TEST_MAXIMUM_RETURN: + default: + std::cerr << "Unknown return value." << std::endl; + abort(); + } +} + +void create_core(void) +{ + if (getenv("LIBMEMCACHED_NO_COREDUMP") == NULL) + { + pid_t pid= fork(); + + if (pid == 0) + { + abort(); + } + else + { + while (waitpid(pid, NULL, 0) != pid) {}; + } + } +} + + +static test_return_t _runner_default(test_callback_fn func, void *p) +{ + if (func) + return func(p); + + return TEST_SUCCESS; +} + +static world_runner_st defualt_runners= { + _runner_default, + _runner_default, + _runner_default +}; + +static test_return_t _default_callback(void *p) +{ + (void)p; + + return TEST_SUCCESS; +} + +static collection_st *init_world(world_st *world) +{ + if (world->runner == NULL) + { + world->runner= &defualt_runners; + } + + if (world->collection_startup == NULL) + world->collection_startup= _default_callback; + + if (world->collection_shutdown == NULL) + world->collection_shutdown= _default_callback; + + return world->collections; +} + + +int main(int argc, char *argv[]) +{ + world_st world; + void *world_ptr; + + world_stats_st stats; + + get_world(&world); + + if (not world.runner) + { + world.runner= &defualt_runners; + } + + collection_st *collection= init_world(&world); + + if (world.create) + { + test_return_t error; + world_ptr= world.create(&error); + if (error != TEST_SUCCESS) + { + return EXIT_FAILURE; + } + } + else + { + world_ptr= NULL; + } + + char *collection_to_run= NULL; + if (argc > 1) + { + collection_to_run= argv[1]; + } + else if (getenv("TEST_COLLECTION")) + { + collection_to_run= getenv("TEST_COLLECTION"); + } + + if (collection_to_run) + { + std::cout << "Only testing " << collection_to_run << std::endl; + } + + char *wildcard= NULL; + if (argc == 3) + { + wildcard= argv[2]; + } + + for (collection_st *next= collection; next->name; next++) + { + test_return_t collection_rc= TEST_SUCCESS; + bool failed= false; + bool skipped= false; + + if (collection_to_run && fnmatch(collection_to_run, next->name, 0)) + continue; + + stats.collection_total++; + + collection_rc= world.collection_startup(world_ptr); + + if (collection_rc == TEST_SUCCESS and next->pre) + { + collection_rc= world.runner->pre(next->pre, world_ptr); + } + + switch (collection_rc) + { + case TEST_SUCCESS: + std::cerr << std::endl << next->name << std::endl << std::endl; + break; + + case TEST_FATAL: + case TEST_FAILURE: + std::cerr << std::endl << next->name << " [ failed ]" << std::endl << std::endl; + stats.collection_failed++; + goto cleanup; + + case TEST_SKIPPED: + std::cerr << std::endl << next->name << " [ skipping ]" << std::endl << std::endl; + stats.collection_skipped++; + goto cleanup; + + case TEST_MEMORY_ALLOCATION_FAILURE: + case TEST_MAXIMUM_RETURN: + default: + assert(0); + break; + } + + for (test_st *run= next->tests; run->name; run++) + { + struct timeval start_time, end_time; + long int load_time= 0; + + if (wildcard && fnmatch(wildcard, run->name, 0)) + { + continue; + } + + std::cerr << "\tTesting " << run->name; + + if (world.run_startup) + { + world.run_startup(world_ptr); + } + + if (run->requires_flush && world.flush) + { + world.flush(world_ptr); + } + + if (world.pre_run) + { + world.pre_run(world_ptr); + } + + + test_return_t return_code; + { // Runner Code +#if 0 + if (next->pre and world.runner->pre) + { + return_code= world.runner->pre(next->pre, world_ptr); + + if (return_code != TEST_SUCCESS) + { + goto error; + } + } +#endif + + gettimeofday(&start_time, NULL); + return_code= world.runner->run(run->test_fn, world_ptr); + gettimeofday(&end_time, NULL); + load_time= timedif(end_time, start_time); + +#if 0 + if (next->post && world.runner->post) + { + (void) world.runner->post(next->post, world_ptr); + } +#endif + } + + if (world.post_run) + { + world.post_run(world_ptr); + } + + stats.total++; + + std::cerr << "\t\t\t\t\t"; + + switch (return_code) + { + case TEST_SUCCESS: + std::cerr << load_time / 1000 << "." << load_time % 1000; + stats.success++; + break; + + case TEST_FATAL: + case TEST_FAILURE: + stats.failed++; + failed= true; + break; + + case TEST_SKIPPED: + stats.skipped++; + skipped= true; + break; + + case TEST_MEMORY_ALLOCATION_FAILURE: + case TEST_MAXIMUM_RETURN: + default: + break; + abort(); + } + + std::cerr << "[ " << test_strerror(return_code) << " ]" << std::endl; + + if (world.on_error) + { + test_return_t rc= world.on_error(return_code, world_ptr); + + if (rc != TEST_SUCCESS) + break; + } + + } + + if (next->post && world.runner->post) + { + (void) world.runner->post(next->post, world_ptr); + } + + if (failed == 0 and skipped == 0) + { + stats.collection_success++; + } +cleanup: + + if (world.collection_shutdown) + { + world.collection_shutdown(world_ptr); + } + } + + if (stats.collection_failed || stats.collection_skipped) + { + std::cerr << std::endl << std::endl << "Some test failures and/or skipped test occurred." << std::endl << std::endl; +#if 0 + print_failed_test(); +#endif + } + else + { + std::cout << std::endl << std::endl << "All tests completed successfully." << std::endl << std::endl; + } + + if (world.destroy) + { + test_return_t error= world.destroy(world_ptr); + + if (error != TEST_SUCCESS) + { + std::cerr << "Failure during shutdown." << std::endl; + stats.failed++; // We do this to make our exit code return EXIT_FAILURE + } + } + + world_stats_print(&stats); + + return stats.failed == 0 ? 0 : 1; +} diff --git a/libtest/test.h b/libtest/test.h index 2245e798..d6d7d787 100644 --- a/libtest/test.h +++ b/libtest/test.h @@ -1,63 +1,26 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Gearmand client and server library. - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2010 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. +/* uTest + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker + * All rights reserved. * + * Use and distribution licensed under the BSD license. See + * the COPYING file in the parent directory for full text. */ -#pragma once - -#include - /* Structures for generic tests. */ #include #include +#include #include +#include -#if !defined(__cplusplus) -# include -#endif - -typedef struct world_st world_st; -typedef struct collection_st collection_st; -typedef struct test_st test_st; +#pragma once enum test_return_t { - TEST_SUCCESS, /* Backwards compatibility */ + TEST_SUCCESS= 0, /* Backwards compatibility */ TEST_FAILURE, TEST_MEMORY_ALLOCATION_FAILURE, TEST_SKIPPED, @@ -69,25 +32,22 @@ enum test_return_t { extern "C" { #endif -typedef enum test_return_t test_return_t; +typedef void* (test_callback_create_fn)(enum test_return_t*); +typedef enum test_return_t (test_callback_fn)(void *); +typedef enum test_return_t (test_callback_runner_fn)(test_callback_fn*, void *); +typedef enum test_return_t (test_callback_error_fn)(const enum test_return_t, void *); #ifdef __cplusplus } #endif - -typedef void *(*test_callback_create_fn)(test_return_t *error); -typedef test_return_t (*test_callback_fn)(void *); -typedef test_return_t (*test_callback_runner_fn)(test_callback_fn, void *); -typedef test_return_t (*test_callback_error_fn)(test_return_t, void *); - /** A structure describing the test case. */ struct test_st { const char *name; bool requires_flush; - test_callback_fn test_fn; + test_callback_fn *test_fn; }; @@ -96,9 +56,9 @@ struct test_st { */ struct collection_st { const char *name; - test_callback_fn pre; - test_callback_fn post; - test_st *tests; + test_callback_fn *pre; + test_callback_fn *post; + struct test_st *tests; }; @@ -106,11 +66,11 @@ struct collection_st { Structure which houses the actual callers for the test cases contained in the collections. */ -typedef struct { - test_callback_runner_fn pre; - test_callback_runner_fn run; - test_callback_runner_fn post; -} world_runner_st; +struct world_runner_st { + test_callback_runner_fn *pre; + test_callback_runner_fn *run; + test_callback_runner_fn *post; +}; /** @@ -123,43 +83,59 @@ struct world_st { collection_st *collections; /* These methods are called outside of any collection call. */ - test_callback_create_fn create; - test_callback_fn destroy; - - struct { - /* This is called a the beginning of any test run. */ - test_callback_fn startup; + test_callback_create_fn *create; + test_callback_fn *destroy; - /* This called on a test if the test requires a flush call (the bool is from test_st) */ - test_callback_fn flush; + /* This is called a the beginning of any collection run. */ + test_callback_fn *collection_startup; - /** - These are run before/after the test. If implemented. Their execution is not controlled - by the test. - */ - test_callback_fn pre_run; - test_callback_fn post_run; + /* This is called a the end of any collection run. */ + test_callback_fn *collection_shutdown; - /** - If an error occurs during the test, this is called. - */ - test_callback_error_fn on_error; - } test; + /* This is called a the beginning of any run. */ + test_callback_fn *run_startup; - struct { - /* This is called a the beginning of any collection run. */ - test_callback_fn startup; + /* This called on a test if the test requires a flush call (the bool is from test_st) */ + test_callback_fn *flush; - /* This is called at the end of any collection run. */ - test_callback_fn shutdown; - } collection; + /** + These are run before/after the test. If implemented. Their execution is not controlled + by the test. + */ + test_callback_fn *pre_run; + test_callback_fn *post_run; + /** + If an error occurs during the test, this is called. + */ + test_callback_error_fn *on_error; /** Runner represents the callers for the tests. If not implemented we will use a set of default implementations. */ world_runner_st *runner; + + world_st() : + collections(NULL), + create(NULL), + destroy(NULL), + collection_startup(NULL), + collection_shutdown(NULL), + run_startup(NULL), + flush(NULL), + pre_run(NULL), + post_run(NULL), + on_error(NULL), + runner(NULL) + { } + + virtual ~world_st() + { } + +private: + world_st(const world_st&); + world_st& operator=(const world_st&); }; @@ -167,25 +143,37 @@ struct world_st { /** @note world_stats_st is a simple structure for tracking test successes. */ -typedef struct { - uint32_t collection_success; - uint32_t collection_skipped; - uint32_t collection_failed; - uint32_t collection_total; +struct world_stats_st { + int32_t collection_success; + int32_t collection_skipped; + int32_t collection_failed; + int32_t collection_total; + uint32_t success; uint32_t skipped; uint32_t failed; uint32_t total; -} world_stats_st; + + world_stats_st() : + collection_success(0), + collection_skipped(0), + collection_failed(0), + collection_total(0), + success(0), + skipped(0), + failed(0), + total(0) + { } +}; + +#define TEST_STRINGIFY(x) #x +#define TEST_TOSTRING(x) TEST_STRINGIFY(x) +#define TEST_AT __FILE__ ":" TEST_TOSTRING(__LINE__) #ifdef __cplusplus extern "C" { #endif -/* Help function for use with gettimeofday() */ -LIBTEST_API -long int timedif(struct timeval a, struct timeval b); - /* How we make all of this work :) */ LIBTEST_API void get_world(world_st *world); @@ -196,20 +184,22 @@ void create_core(void); /** @note Friendly print function for errors. */ -LIBTEST_API +LIBTEST_INTERNAL_API const char *test_strerror(test_return_t code); -#define test_fail(A) \ +#define test_assert_errno(A) \ do \ { \ - if (1) { \ - fprintf(stderr, "\nFailed at %s:%d: %s\n", __FILE__, __LINE__, #A);\ + if ((A)) { \ + fprintf(stderr, "\nAssertion failed at %s:%d: ", __FILE__, __LINE__);\ + perror(#A); \ + fprintf(stderr, "\n"); \ create_core(); \ - return TEST_FAILURE; \ + assert((A)); \ } \ } while (0) -#define test_true(A) \ +#define test_truth(A) \ do \ { \ if (! (A)) { \ @@ -219,22 +209,21 @@ do \ } \ } while (0) -#define test_true_got(A,B) \ +#define test_true(A) \ do \ { \ if (! (A)) { \ - fprintf(stderr, "\nAssertion failed at %s:%d: \"%s\" received \"%s\"\n", __FILE__, __LINE__, #A, (B));\ + fprintf(stderr, "\nAssertion failed at %s:%d: %s\n", __FILE__, __LINE__, #A);\ create_core(); \ return TEST_FAILURE; \ } \ } while (0) -#define test_compare(A,B) \ +#define test_true_got(A,B) \ do \ { \ - if ((A) != (B)) \ - { \ - fprintf(stderr, "\n%s:%d: Expected %s, got %lu\n", __FILE__, __LINE__, #A, (unsigned long)(B)); \ + if (! (A)) { \ + fprintf(stderr, "\nAssertion failed at %s:%d: \"%s\" received \"%s\"\n", __FILE__, __LINE__, #A, (B));\ create_core(); \ return TEST_FAILURE; \ } \ @@ -249,22 +238,22 @@ do \ } \ } while (0) -#define test_compare_got(A,B,C) \ +#define test_fail(A) \ do \ { \ - if ((A) != (B)) \ - { \ - fprintf(stderr, "\n%s:%d: Expected %s, got %s\n", __FILE__, __LINE__, #A, (C)); \ + if (1) { \ + fprintf(stderr, "\nFailed at %s:%d: %s\n", __FILE__, __LINE__, #A);\ create_core(); \ return TEST_FAILURE; \ } \ } while (0) + #define test_false(A) \ do \ { \ if ((A)) { \ - fprintf(stderr, "\nAssertion failed at %s:%d: %s\n", __FILE__, __LINE__, #A);\ + fprintf(stderr, "\nAssertion failed in %s:%d: %s\n", __FILE__, __LINE__, #A);\ create_core(); \ return TEST_FAILURE; \ } \ @@ -280,12 +269,36 @@ do \ } \ } while (0) + +#define test_compare(A,B) \ +do \ +{ \ + if ((A) != (B)) \ + { \ + fprintf(stderr, "\n%s:%d: Expected %s, got %lu\n", __FILE__, __LINE__, #A, (unsigned long)(B)); \ + create_core(); \ + return TEST_FAILURE; \ + } \ +} while (0) + +#define test_compare_got(A,B,C) \ +do \ +{ \ + if ((A) != (B)) \ + { \ + fprintf(stderr, "\n%s:%d: Expected %s, got %s\n", __FILE__, __LINE__, #A, (C)); \ + create_core(); \ + return TEST_FAILURE; \ + } \ +} while (0) + + #define test_strcmp(A,B) \ do \ { \ if (strcmp((A), (B))) \ { \ - fprintf(stderr, "\n%s:%d: `%s` -> `%s`\n", __FILE__, __LINE__, (A), (B)); \ + fprintf(stderr, "\n%s:%d: Expected %s, got %s\n", __FILE__, __LINE__, (A), (B)); \ create_core(); \ return TEST_FAILURE; \ } \ @@ -302,22 +315,14 @@ do \ } \ } while (0) -#define STRINGIFY(x) #x -#define TOSTRING(x) STRINGIFY(x) -#define AT __FILE__ ":" TOSTRING(__LINE__) - -#ifdef __cplusplus -#define STRING_WITH_LEN(X) (X), (static_cast((sizeof(X) - 1))) -#else -#define STRING_WITH_LEN(X) (X), ((size_t)((sizeof(X) - 1))) +#ifdef __cplusplus +} #endif #ifdef __cplusplus -#define STRING_PARAM_WITH_LEN(X) X, static_cast(sizeof(X) - 1) +#define test_literal_param(X) (X), (static_cast((sizeof(X) - 1))) #else -#define STRING_PARAM_WITH_LEN(X) X, (size_t)((sizeof(X) - 1)) +#define test_literal_param(X) (X), ((size_t)((sizeof(X) - 1))) #endif -#ifdef __cplusplus -} -#endif +#define test_string_make_from_cstr(X) (X), ((X) ? strlen(X) : 0) diff --git a/tests/atomsmasher.c b/tests/atomsmasher.cc similarity index 82% rename from tests/atomsmasher.c rename to tests/atomsmasher.cc index 8563e4ec..ffde3877 100644 --- a/tests/atomsmasher.c +++ b/tests/atomsmasher.cc @@ -14,8 +14,8 @@ */ #include "config.h" -#include "libmemcached/memcached.h" -#include "libmemcached/watchpoint.h" +#include +#include #include #include @@ -48,7 +48,7 @@ static test_return_t cleanup_pairs(memcached_st *memc) (void)memc; pairs_free(global_pairs); - return EXIT_SUCCESS; + return TEST_SUCCESS; } static test_return_t generate_pairs(memcached_st *memc) @@ -63,7 +63,7 @@ static test_return_t generate_pairs(memcached_st *memc) global_keys_length[x]= global_pairs[x].key_length; } - return EXIT_SUCCESS; + return TEST_SUCCESS; } static test_return_t drizzle(memcached_st *memc) @@ -160,7 +160,7 @@ static test_return_t add_test(memcached_st *memc) test_true(rc == MEMCACHED_NOTSTORED); } - return EXIT_SUCCESS; + return TEST_SUCCESS; } /* @@ -173,14 +173,14 @@ static test_return_t many_adds(memcached_st *memc) { add_test(memc); } - return EXIT_SUCCESS; + return TEST_SUCCESS; } test_st smash_tests[] ={ - {"generate_pairs", 1, (test_callback_fn)generate_pairs }, - {"drizzle", 1, (test_callback_fn)drizzle }, - {"cleanup", 1, (test_callback_fn)cleanup_pairs }, - {"many_adds", 1, (test_callback_fn)many_adds }, + {"generate_pairs", 1, (test_callback_fn*)generate_pairs }, + {"drizzle", 1, (test_callback_fn*)drizzle }, + {"cleanup", 1, (test_callback_fn*)cleanup_pairs }, + {"many_adds", 1, (test_callback_fn*)many_adds }, {0, 0, 0} }; @@ -258,16 +258,16 @@ static test_return_t post_allocate(memcached_st *memc) test_st micro_tests[] ={ - {"memcached_create", 1, (test_callback_fn)memcached_create_benchmark }, - {"memcached_clone", 1, (test_callback_fn)memcached_clone_benchmark }, + {"memcached_create", 1, (test_callback_fn*)memcached_create_benchmark }, + {"memcached_clone", 1, (test_callback_fn*)memcached_clone_benchmark }, {0, 0, 0} }; collection_st collection[] ={ {"smash", 0, 0, smash_tests}, - {"smash_nonblock", (test_callback_fn)pre_nonblock, 0, smash_tests}, - {"micro-benchmark", (test_callback_fn)pre_allocate, (test_callback_fn)post_allocate, micro_tests}, + {"smash_nonblock", (test_callback_fn*)pre_nonblock, 0, smash_tests}, + {"micro-benchmark", (test_callback_fn*)pre_allocate, (test_callback_fn*)post_allocate, micro_tests}, {0, 0, 0, 0} }; @@ -280,17 +280,17 @@ void get_world(world_st *world) { world->collections= collection; - world->create= (test_callback_create_fn)world_create; - world->destroy= (test_callback_fn)world_destroy; + world->create= (test_callback_create_fn*)world_create; + world->destroy= (test_callback_fn*)world_destroy; - world->test.startup= (test_callback_fn)world_test_startup; - world->test.flush= (test_callback_fn)world_flush; - world->test.pre_run= (test_callback_fn)world_pre_run; - world->test.post_run= (test_callback_fn)world_post_run; - world->test.on_error= (test_callback_error_fn)world_on_error; + world->run_startup= (test_callback_fn*)world_test_startup; + world->flush= (test_callback_fn*)world_flush; + world->pre_run= (test_callback_fn*)world_pre_run; + world->post_run= (test_callback_fn*)world_post_run; + world->on_error= (test_callback_error_fn*)world_on_error; - world->collection.startup= (test_callback_fn)world_container_startup; - world->collection.shutdown= (test_callback_fn)world_container_shutdown; + world->collection_startup= (test_callback_fn*)world_container_startup; + world->collection_shutdown= (test_callback_fn*)world_container_shutdown; world->runner= &defualt_libmemcached_runner; } diff --git a/tests/hash_plus.cc b/tests/hash_plus.cc index 20cf79db..987d7971 100644 --- a/tests/hash_plus.cc +++ b/tests/hash_plus.cc @@ -195,14 +195,14 @@ static test_return_t compare_function_test(void *obj) } test_st basic[] ={ - { "exists", 0, reinterpret_cast(exists_test) }, - { "new", 0, reinterpret_cast(new_test) }, - { "copy", 0, reinterpret_cast(copy_test) }, - { "assign", 0, reinterpret_cast(assign_test) }, - { "digest", 0, reinterpret_cast(digest_test) }, - { "set_function", 0, reinterpret_cast(set_function_test) }, - { "set_distribution_function", 0, reinterpret_cast(set_distribution_function_test) }, - { "compare", 0, reinterpret_cast(compare_function_test) }, + { "exists", 0, reinterpret_cast(exists_test) }, + { "new", 0, reinterpret_cast(new_test) }, + { "copy", 0, reinterpret_cast(copy_test) }, + { "assign", 0, reinterpret_cast(assign_test) }, + { "digest", 0, reinterpret_cast(digest_test) }, + { "set_function", 0, reinterpret_cast(set_function_test) }, + { "set_distribution_function", 0, reinterpret_cast(set_distribution_function_test) }, + { "compare", 0, reinterpret_cast(compare_function_test) }, { 0, 0, 0} }; diff --git a/tests/hashkit_functions.c b/tests/hashkit_functions.cc similarity index 72% rename from tests/hashkit_functions.c rename to tests/hashkit_functions.cc index 23feb9e5..461faaed 100644 --- a/tests/hashkit_functions.c +++ b/tests/hashkit_functions.cc @@ -1,9 +1,38 @@ -/* libHashKit Functions Test - * Copyright (C) 2006-2009 Brian Aker - * All rights reserved. +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * libHashKit Functions Test + * + * 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. */ #include "config.h" @@ -309,9 +338,9 @@ static test_return_t jenkins_run (hashkit_st *hashk) */ test_st allocation[]= { - {"init", 0, (test_callback_fn)init_test}, - {"create and free", 0, (test_callback_fn)allocation_test}, - {"clone", 0, (test_callback_fn)clone_test}, + {"init", 0, (test_callback_fn*)init_test}, + {"create and free", 0, (test_callback_fn*)allocation_test}, + {"clone", 0, (test_callback_fn*)clone_test}, {0, 0, 0} }; @@ -325,14 +354,13 @@ static test_return_t hashkit_digest_test(hashkit_st *hashk) static test_return_t hashkit_set_function_test(hashkit_st *hashk) { - for (hashkit_hash_algorithm_t algo = HASHKIT_HASH_DEFAULT; algo < HASHKIT_HASH_MAX; algo++) + for (int algo= int(HASHKIT_HASH_DEFAULT); algo < int(HASHKIT_HASH_MAX); algo++) { - hashkit_return_t rc; uint32_t x; const char **ptr; uint32_t *list; - rc= hashkit_set_function(hashk, algo); + hashkit_return_t rc= hashkit_set_function(hashk, static_cast(algo)); /* Hsieh is disabled most of the time for patent issues */ #ifndef HAVE_HSIEH_HASH @@ -438,11 +466,9 @@ static test_return_t hashkit_set_custom_function_test(hashkit_st *hashk) static test_return_t hashkit_set_distribution_function_test(hashkit_st *hashk) { - for (hashkit_hash_algorithm_t algo = HASHKIT_HASH_DEFAULT; algo < HASHKIT_HASH_MAX; algo++) + for (int algo= int(HASHKIT_HASH_DEFAULT); algo < int(HASHKIT_HASH_MAX); algo++) { - hashkit_return_t rc; - - rc= hashkit_set_distribution_function(hashk, algo); + hashkit_return_t rc= hashkit_set_distribution_function(hashk, static_cast(algo)); /* Hsieh is disabled most of the time for patent issues */ if (rc == HASHKIT_FAILURE && algo == HASHKIT_HASH_HSIEH) @@ -459,9 +485,7 @@ static test_return_t hashkit_set_distribution_function_test(hashkit_st *hashk) static test_return_t hashkit_set_custom_distribution_function_test(hashkit_st *hashk) { - hashkit_return_t rc; - - rc= hashkit_set_custom_distribution_function(hashk, hash_test_function, NULL); + hashkit_return_t rc= hashkit_set_custom_distribution_function(hashk, hash_test_function, NULL); test_true(rc == HASHKIT_SUCCESS); return TEST_SUCCESS; @@ -470,14 +494,13 @@ static test_return_t hashkit_set_custom_distribution_function_test(hashkit_st *h static test_return_t hashkit_get_function_test(hashkit_st *hashk) { - for (hashkit_hash_algorithm_t algo = HASHKIT_HASH_DEFAULT; algo < HASHKIT_HASH_MAX; algo++) + for (int algo= int(HASHKIT_HASH_DEFAULT); algo < int(HASHKIT_HASH_MAX); algo++) { - hashkit_return_t rc; - if (HASHKIT_HASH_CUSTOM || HASHKIT_HASH_HSIEH) + if (HASHKIT_HASH_CUSTOM or HASHKIT_HASH_HSIEH) continue; - rc= hashkit_set_function(hashk, algo); + hashkit_return_t rc= hashkit_set_function(hashk, static_cast(algo)); test_true(rc == HASHKIT_SUCCESS); test_true(hashkit_get_function(hashk) == algo); @@ -487,9 +510,7 @@ static test_return_t hashkit_get_function_test(hashkit_st *hashk) static test_return_t hashkit_compare_test(hashkit_st *hashk) { - hashkit_st *clone; - - clone= hashkit_clone(NULL, hashk); + hashkit_st *clone= hashkit_clone(NULL, hashk); test_true(hashkit_compare(clone, hashk)); hashkit_free(clone); @@ -498,44 +519,44 @@ static test_return_t hashkit_compare_test(hashkit_st *hashk) } test_st hashkit_st_functions[] ={ - {"hashkit_digest", 0, (test_callback_fn)hashkit_digest_test}, - {"hashkit_set_function", 0, (test_callback_fn)hashkit_set_function_test}, - {"hashkit_set_custom_function", 0, (test_callback_fn)hashkit_set_custom_function_test}, - {"hashkit_get_function", 0, (test_callback_fn)hashkit_get_function_test}, - {"hashkit_set_distribution_function", 0, (test_callback_fn)hashkit_set_distribution_function_test}, - {"hashkit_set_custom_distribution_function", 0, (test_callback_fn)hashkit_set_custom_distribution_function_test}, - {"hashkit_compare", 0, (test_callback_fn)hashkit_compare_test}, + {"hashkit_digest", 0, (test_callback_fn*)hashkit_digest_test}, + {"hashkit_set_function", 0, (test_callback_fn*)hashkit_set_function_test}, + {"hashkit_set_custom_function", 0, (test_callback_fn*)hashkit_set_custom_function_test}, + {"hashkit_get_function", 0, (test_callback_fn*)hashkit_get_function_test}, + {"hashkit_set_distribution_function", 0, (test_callback_fn*)hashkit_set_distribution_function_test}, + {"hashkit_set_custom_distribution_function", 0, (test_callback_fn*)hashkit_set_custom_distribution_function_test}, + {"hashkit_compare", 0, (test_callback_fn*)hashkit_compare_test}, {0, 0, 0} }; static test_return_t libhashkit_digest_test(hashkit_st *hashk) { - uint32_t value; (void)hashk; - value= libhashkit_digest("a", sizeof("a"), HASHKIT_HASH_DEFAULT); + uint32_t value= libhashkit_digest("a", sizeof("a"), HASHKIT_HASH_DEFAULT); + test_true(value); return TEST_SUCCESS; } test_st library_functions[] ={ - {"libhashkit_digest", 0, (test_callback_fn)libhashkit_digest_test}, + {"libhashkit_digest", 0, (test_callback_fn*)libhashkit_digest_test}, {0, 0, 0} }; test_st hash_tests[] ={ - {"one_at_a_time", 0, (test_callback_fn)one_at_a_time_run }, - {"md5", 0, (test_callback_fn)md5_run }, - {"crc", 0, (test_callback_fn)crc_run }, - {"fnv1_64", 0, (test_callback_fn)fnv1_64_run }, - {"fnv1a_64", 0, (test_callback_fn)fnv1a_64_run }, - {"fnv1_32", 0, (test_callback_fn)fnv1_32_run }, - {"fnv1a_32", 0, (test_callback_fn)fnv1a_32_run }, - {"hsieh", 0, (test_callback_fn)hsieh_run }, - {"murmur", 0, (test_callback_fn)murmur_run }, - {"jenkis", 0, (test_callback_fn)jenkins_run }, - {0, 0, (test_callback_fn)0} + {"one_at_a_time", 0, (test_callback_fn*)one_at_a_time_run }, + {"md5", 0, (test_callback_fn*)md5_run }, + {"crc", 0, (test_callback_fn*)crc_run }, + {"fnv1_64", 0, (test_callback_fn*)fnv1_64_run }, + {"fnv1a_64", 0, (test_callback_fn*)fnv1a_64_run }, + {"fnv1_32", 0, (test_callback_fn*)fnv1_32_run }, + {"fnv1a_32", 0, (test_callback_fn*)fnv1a_32_run }, + {"hsieh", 0, (test_callback_fn*)hsieh_run }, + {"murmur", 0, (test_callback_fn*)murmur_run }, + {"jenkis", 0, (test_callback_fn*)jenkins_run }, + {0, 0, (test_callback_fn*)0} }; /* @@ -563,9 +584,7 @@ test_return_t world_destroy(hashkit_st *hashk); void *world_create(test_return_t *error) { - hashkit_st *hashk_ptr; - - hashk_ptr= hashkit_create(&global_hashk); + hashkit_st *hashk_ptr= hashkit_create(&global_hashk); if (hashk_ptr != &global_hashk) { @@ -597,6 +616,6 @@ test_return_t world_destroy(hashkit_st *hashk) void get_world(world_st *world) { world->collections= collection; - world->create= (test_callback_create_fn)world_create; - world->destroy= (test_callback_fn)world_destroy; + world->create= (test_callback_create_fn*)world_create; + world->destroy= (test_callback_fn*)world_destroy; } diff --git a/tests/include.am b/tests/include.am index abcc0f33..7ce21a12 100644 --- a/tests/include.am +++ b/tests/include.am @@ -84,23 +84,23 @@ tests_testplus_DEPENDENCIES= $(TESTS_LDADDS) tests_testplus_LDADD= $(tests_testplus_DEPENDENCIES) $(LIBSASL) check_PROGRAMS+= tests/testplus -tests_atomsmasher_SOURCES= tests/atomsmasher.c +tests_atomsmasher_SOURCES= tests/atomsmasher.cc tests_atomsmasher_SOURCES+= clients/generator.cc clients/execute.cc tests_atomsmasher_DEPENDENCIES= $(TESTS_LDADDS) tests_atomsmasher_LDADD= $(tests_atomsmasher_DEPENDENCIES) $(LIBSASL) tests_testudp_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING) -tests_testudp_SOURCES= tests/mem_udp.c +tests_testudp_SOURCES= tests/mem_udp.cc tests_testudp_DEPENDENCIES= $(TESTS_LDADDS) tests_testudp_LDADD= $(tests_testudp_DEPENDENCIES) $(LIBSASL) -tests_startservers_SOURCES= tests/start.c +tests_startservers_SOURCES= tests/start.cc tests_startservers_DEPENDENCIES= $(TESTS_LDADDS) tests_startservers_LDADD= $(tests_startservers_DEPENDENCIES) $(LIBSASL) -tests_testhashkit_SOURCES = tests/hashkit_functions.c +tests_testhashkit_SOURCES = tests/hashkit_functions.cc tests_testhashkit_DEPENDENCIES = libtest/libtest.la libhashkit/libhashkit.la tests_testhashkit_LDADD = $(tests_testhashkit_DEPENDENCIES) diff --git a/tests/libmemcached_world.h b/tests/libmemcached_world.h index 4793569c..36136c6e 100644 --- a/tests/libmemcached_world.h +++ b/tests/libmemcached_world.h @@ -14,12 +14,19 @@ extern "C" { #endif /* The structure we use for the test system */ -typedef struct +struct libmemcached_test_container_st { server_startup_st construct; memcached_st *parent; memcached_st *memc; -} libmemcached_test_container_st; + + libmemcached_test_container_st() : + parent(NULL), + memc(NULL) + { + memset(&construct, 0, sizeof(server_startup_st)); + } +}; /* Prototypes for functions we will pass to test framework */ libmemcached_test_container_st *world_create(test_return_t *error); @@ -41,12 +48,11 @@ test_return_t world_container_shutdown(libmemcached_test_container_st *container libmemcached_test_container_st *world_create(test_return_t *error) { - memset(&global_container, 0, sizeof(global_container)); global_container.construct.count= SERVERS_TO_CREATE; global_container.construct.udp= 0; server_startup(&global_container.construct); - if (! global_container.construct.servers) + if (not global_container.construct.servers) { *error= TEST_FAILURE; server_shutdown(&global_container.construct); @@ -60,12 +66,11 @@ libmemcached_test_container_st *world_create(test_return_t *error) test_return_t world_container_startup(libmemcached_test_container_st *container) { - memcached_return_t rc; container->parent= memcached_create(NULL); test_true((container->parent != NULL)); - rc= memcached_server_push(container->parent, container->construct.servers); - test_true(rc == MEMCACHED_SUCCESS); + test_compare(MEMCACHED_SUCCESS, + memcached_server_push(container->parent, container->construct.servers)); return TEST_SUCCESS; } @@ -101,8 +106,8 @@ test_return_t world_pre_run(libmemcached_test_container_st *container) memcached_server_instance_st instance= memcached_server_instance_by_position(container->memc, loop); - test_true(instance->fd == -1); - test_true(instance->cursor_active == 0); + test_compare(-1, instance->fd); + test_compare(0, instance->cursor_active); } return TEST_SUCCESS; @@ -184,9 +189,9 @@ static test_return_t _post_runner_default(libmemcached_test_callback_fn func, li #ifdef __cplusplus static world_runner_st defualt_libmemcached_runner= { - reinterpret_cast(_pre_runner_default), - reinterpret_cast(_runner_default), - reinterpret_cast(_post_runner_default) + reinterpret_cast(_pre_runner_default), + reinterpret_cast(_runner_default), + reinterpret_cast(_post_runner_default) }; #else diff --git a/tests/mem_functions.cc b/tests/mem_functions.cc index dec17427..bc29f2c0 100644 --- a/tests/mem_functions.cc +++ b/tests/mem_functions.cc @@ -3909,32 +3909,32 @@ static test_return_t set_prefix(memcached_st *memc) /* Make sure be default none exists */ value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_PREFIX_KEY, &rc); - test_true(rc == MEMCACHED_FAILURE); + test_compare_got(MEMCACHED_FAILURE, rc, memcached_strerror(NULL, rc)); /* Test a clean set */ rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, (void *)key); - test_true_got(rc == MEMCACHED_SUCCESS, memcached_last_error_message(memc)); + test_compare_got(MEMCACHED_SUCCESS, rc , memcached_last_error_message(memc)); value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_PREFIX_KEY, &rc); test_true(value); test_memcmp(value, key, 4); - test_compare(MEMCACHED_SUCCESS, rc); + test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc)); /* Test that we can turn it off */ rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, NULL); - test_compare(MEMCACHED_SUCCESS, rc); + test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc)); value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_PREFIX_KEY, &rc); test_false(value); - test_true(rc == MEMCACHED_FAILURE); + test_compare_got(MEMCACHED_FAILURE, rc, memcached_strerror(NULL, rc)); /* Now setup for main test */ rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, (void *)key); - test_compare(MEMCACHED_SUCCESS, rc); + test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc)); value= (char *)memcached_callback_get(memc, MEMCACHED_CALLBACK_PREFIX_KEY, &rc); test_true(value); - test_compare(MEMCACHED_SUCCESS, rc); + test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc)); test_memcmp(value, key, 4); /* Set to Zero, and then Set to something too large */ @@ -5845,6 +5845,10 @@ static test_return_t regression_bug_655423(memcached_st *memc) test_true(clone); char payload[100]; +#ifdef __APPLE__ + return TEST_SKIPPED; +#endif + test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1)); test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_SUPPORT_CAS, 1)); test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1)); @@ -5854,7 +5858,7 @@ static test_return_t regression_bug_655423(memcached_st *memc) for (uint32_t x= 0; x < regression_bug_655423_COUNT; x++) { - char key[1024]; + char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1]; snprintf(key, sizeof(key), "%u", x); test_compare(MEMCACHED_SUCCESS, memcached_set(clone, key, strlen(key), payload, sizeof(payload), 0, 0)); @@ -5862,7 +5866,7 @@ static test_return_t regression_bug_655423(memcached_st *memc) for (uint32_t x= 0; x < regression_bug_655423_COUNT; x++) { - char key[1024]; + char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1]; snprintf(key, sizeof(key), "%u", x); size_t value_length; @@ -5886,11 +5890,13 @@ static test_return_t regression_bug_655423(memcached_st *memc) size_t *key_length= (size_t *)calloc(regression_bug_655423_COUNT, sizeof(size_t)); for (uint32_t x= 0; x < regression_bug_655423_COUNT; x++) { - char key[1024]; + char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1]; snprintf(key, sizeof(key), "%u", x); keys[x]= strdup(key); + test_true(keys[x]); key_length[x]= strlen(key); + test_true(key_length[x]); } memcached_return_t rc; @@ -6105,155 +6111,155 @@ static test_return_t sasl_auth_test(memcached_st *memc) /* Clean the server before beginning testing */ test_st tests[] ={ - {"util_version", 1, (test_callback_fn)util_version_test }, - {"flush", 0, (test_callback_fn)flush_test }, - {"init", 0, (test_callback_fn)init_test }, - {"allocation", 0, (test_callback_fn)allocation_test }, - {"server_list_null_test", 0, (test_callback_fn)server_list_null_test}, - {"server_unsort", 0, (test_callback_fn)server_unsort_test}, - {"server_sort", 0, (test_callback_fn)server_sort_test}, - {"server_sort2", 0, (test_callback_fn)server_sort2_test}, - {"memcached_server_remove", 0, (test_callback_fn)memcached_server_remove_test}, - {"clone_test", 0, (test_callback_fn)clone_test }, - {"connection_test", 0, (test_callback_fn)connection_test}, - {"callback_test", 0, (test_callback_fn)callback_test}, - {"userdata_test", 0, (test_callback_fn)userdata_test}, - {"error", 0, (test_callback_fn)error_test }, - {"set", 0, (test_callback_fn)set_test }, - {"set2", 0, (test_callback_fn)set_test2 }, - {"set3", 0, (test_callback_fn)set_test3 }, - {"dump", 1, (test_callback_fn)dump_test}, - {"add", 1, (test_callback_fn)add_test }, - {"memcached_fetch_result(MEMCACHED_NOTFOUND)", 1, (test_callback_fn)memcached_fetch_result_NOT_FOUND }, - {"replace", 1, (test_callback_fn)replace_test }, - {"delete", 1, (test_callback_fn)delete_test }, - {"get", 1, (test_callback_fn)get_test }, - {"get2", 0, (test_callback_fn)get_test2 }, - {"get3", 0, (test_callback_fn)get_test3 }, - {"get4", 0, (test_callback_fn)get_test4 }, - {"partial mget", 0, (test_callback_fn)get_test5 }, - {"stats_servername", 0, (test_callback_fn)stats_servername_test }, - {"increment", 0, (test_callback_fn)increment_test }, - {"increment_with_initial", 1, (test_callback_fn)increment_with_initial_test }, - {"decrement", 0, (test_callback_fn)decrement_test }, - {"decrement_with_initial", 1, (test_callback_fn)decrement_with_initial_test }, - {"increment_by_key", 0, (test_callback_fn)increment_by_key_test }, - {"increment_with_initial_by_key", 1, (test_callback_fn)increment_with_initial_by_key_test }, - {"decrement_by_key", 0, (test_callback_fn)decrement_by_key_test }, - {"decrement_with_initial_by_key", 1, (test_callback_fn)decrement_with_initial_by_key_test }, - {"quit", 0, (test_callback_fn)quit_test }, - {"mget", 1, (test_callback_fn)mget_test }, - {"mget_result", 1, (test_callback_fn)mget_result_test }, - {"mget_result_alloc", 1, (test_callback_fn)mget_result_alloc_test }, - {"mget_result_function", 1, (test_callback_fn)mget_result_function }, - {"mget_execute", 1, (test_callback_fn)mget_execute }, - {"mget_end", 0, (test_callback_fn)mget_end }, - {"get_stats", 0, (test_callback_fn)get_stats }, - {"add_host_test", 0, (test_callback_fn)add_host_test }, - {"add_host_test_1", 0, (test_callback_fn)add_host_test1 }, - {"get_stats_keys", 0, (test_callback_fn)get_stats_keys }, - {"version_string_test", 0, (test_callback_fn)version_string_test}, - {"bad_key", 1, (test_callback_fn)bad_key_test }, - {"memcached_server_cursor", 1, (test_callback_fn)memcached_server_cursor_test }, - {"read_through", 1, (test_callback_fn)read_through }, - {"delete_through", 1, (test_callback_fn)delete_through }, - {"noreply", 1, (test_callback_fn)noreply_test}, - {"analyzer", 1, (test_callback_fn)analyzer_test}, - {"connectionpool", 1, (test_callback_fn)connection_pool_test }, - {"memcached_pool_test", 1, (test_callback_fn)memcached_pool_test }, - {"ping", 1, (test_callback_fn)ping_test }, - {"test_get_last_disconnect", 1, (test_callback_fn)test_get_last_disconnect}, - {"verbosity", 1, (test_callback_fn)test_verbosity}, - {"test_server_failure", 1, (test_callback_fn)test_server_failure}, - {"cull_servers", 1, (test_callback_fn)test_cull_servers}, - {"memcached_stat_execute", 1, (test_callback_fn)memcached_stat_execute_test}, + {"util_version", 1, (test_callback_fn*)util_version_test }, + {"flush", 0, (test_callback_fn*)flush_test }, + {"init", 0, (test_callback_fn*)init_test }, + {"allocation", 0, (test_callback_fn*)allocation_test }, + {"server_list_null_test", 0, (test_callback_fn*)server_list_null_test}, + {"server_unsort", 0, (test_callback_fn*)server_unsort_test}, + {"server_sort", 0, (test_callback_fn*)server_sort_test}, + {"server_sort2", 0, (test_callback_fn*)server_sort2_test}, + {"memcached_server_remove", 0, (test_callback_fn*)memcached_server_remove_test}, + {"clone_test", 0, (test_callback_fn*)clone_test }, + {"connection_test", 0, (test_callback_fn*)connection_test}, + {"callback_test", 0, (test_callback_fn*)callback_test}, + {"userdata_test", 0, (test_callback_fn*)userdata_test}, + {"error", 0, (test_callback_fn*)error_test }, + {"set", 0, (test_callback_fn*)set_test }, + {"set2", 0, (test_callback_fn*)set_test2 }, + {"set3", 0, (test_callback_fn*)set_test3 }, + {"dump", 1, (test_callback_fn*)dump_test}, + {"add", 1, (test_callback_fn*)add_test }, + {"memcached_fetch_result(MEMCACHED_NOTFOUND)", 1, (test_callback_fn*)memcached_fetch_result_NOT_FOUND }, + {"replace", 1, (test_callback_fn*)replace_test }, + {"delete", 1, (test_callback_fn*)delete_test }, + {"get", 1, (test_callback_fn*)get_test }, + {"get2", 0, (test_callback_fn*)get_test2 }, + {"get3", 0, (test_callback_fn*)get_test3 }, + {"get4", 0, (test_callback_fn*)get_test4 }, + {"partial mget", 0, (test_callback_fn*)get_test5 }, + {"stats_servername", 0, (test_callback_fn*)stats_servername_test }, + {"increment", 0, (test_callback_fn*)increment_test }, + {"increment_with_initial", 1, (test_callback_fn*)increment_with_initial_test }, + {"decrement", 0, (test_callback_fn*)decrement_test }, + {"decrement_with_initial", 1, (test_callback_fn*)decrement_with_initial_test }, + {"increment_by_key", 0, (test_callback_fn*)increment_by_key_test }, + {"increment_with_initial_by_key", 1, (test_callback_fn*)increment_with_initial_by_key_test }, + {"decrement_by_key", 0, (test_callback_fn*)decrement_by_key_test }, + {"decrement_with_initial_by_key", 1, (test_callback_fn*)decrement_with_initial_by_key_test }, + {"quit", 0, (test_callback_fn*)quit_test }, + {"mget", 1, (test_callback_fn*)mget_test }, + {"mget_result", 1, (test_callback_fn*)mget_result_test }, + {"mget_result_alloc", 1, (test_callback_fn*)mget_result_alloc_test }, + {"mget_result_function", 1, (test_callback_fn*)mget_result_function }, + {"mget_execute", 1, (test_callback_fn*)mget_execute }, + {"mget_end", 0, (test_callback_fn*)mget_end }, + {"get_stats", 0, (test_callback_fn*)get_stats }, + {"add_host_test", 0, (test_callback_fn*)add_host_test }, + {"add_host_test_1", 0, (test_callback_fn*)add_host_test1 }, + {"get_stats_keys", 0, (test_callback_fn*)get_stats_keys }, + {"version_string_test", 0, (test_callback_fn*)version_string_test}, + {"bad_key", 1, (test_callback_fn*)bad_key_test }, + {"memcached_server_cursor", 1, (test_callback_fn*)memcached_server_cursor_test }, + {"read_through", 1, (test_callback_fn*)read_through }, + {"delete_through", 1, (test_callback_fn*)delete_through }, + {"noreply", 1, (test_callback_fn*)noreply_test}, + {"analyzer", 1, (test_callback_fn*)analyzer_test}, + {"connectionpool", 1, (test_callback_fn*)connection_pool_test }, + {"memcached_pool_test", 1, (test_callback_fn*)memcached_pool_test }, + {"ping", 1, (test_callback_fn*)ping_test }, + {"test_get_last_disconnect", 1, (test_callback_fn*)test_get_last_disconnect}, + {"verbosity", 1, (test_callback_fn*)test_verbosity}, + {"test_server_failure", 1, (test_callback_fn*)test_server_failure}, + {"cull_servers", 1, (test_callback_fn*)test_cull_servers}, + {"memcached_stat_execute", 1, (test_callback_fn*)memcached_stat_execute_test}, {0, 0, 0} }; test_st behavior_tests[] ={ - {"libmemcached_string_behavior()", 0, (test_callback_fn)libmemcached_string_behavior_test}, - {"libmemcached_string_distribution()", 0, (test_callback_fn)libmemcached_string_distribution_test}, - {"behavior_test", 0, (test_callback_fn)behavior_test}, - {"MEMCACHED_BEHAVIOR_CORK", 0, (test_callback_fn)MEMCACHED_BEHAVIOR_CORK_test}, - {"MEMCACHED_BEHAVIOR_TCP_KEEPALIVE", 0, (test_callback_fn)MEMCACHED_BEHAVIOR_TCP_KEEPALIVE_test}, - {"MEMCACHED_BEHAVIOR_TCP_KEEPIDLE", 0, (test_callback_fn)MEMCACHED_BEHAVIOR_TCP_KEEPIDLE_test}, + {"libmemcached_string_behavior()", 0, (test_callback_fn*)libmemcached_string_behavior_test}, + {"libmemcached_string_distribution()", 0, (test_callback_fn*)libmemcached_string_distribution_test}, + {"behavior_test", 0, (test_callback_fn*)behavior_test}, + {"MEMCACHED_BEHAVIOR_CORK", 0, (test_callback_fn*)MEMCACHED_BEHAVIOR_CORK_test}, + {"MEMCACHED_BEHAVIOR_TCP_KEEPALIVE", 0, (test_callback_fn*)MEMCACHED_BEHAVIOR_TCP_KEEPALIVE_test}, + {"MEMCACHED_BEHAVIOR_TCP_KEEPIDLE", 0, (test_callback_fn*)MEMCACHED_BEHAVIOR_TCP_KEEPIDLE_test}, {0, 0, 0} }; test_st basic_tests[] ={ - {"init", 1, (test_callback_fn)basic_init_test}, - {"clone", 1, (test_callback_fn)basic_clone_test}, - {"reset", 1, (test_callback_fn)basic_reset_stack_test}, - {"reset heap", 1, (test_callback_fn)basic_reset_heap_test}, - {"reset stack clone", 1, (test_callback_fn)basic_reset_stack_clone_test}, - {"reset heap clone", 1, (test_callback_fn)basic_reset_heap_clone_test}, + {"init", 1, (test_callback_fn*)basic_init_test}, + {"clone", 1, (test_callback_fn*)basic_clone_test}, + {"reset", 1, (test_callback_fn*)basic_reset_stack_test}, + {"reset heap", 1, (test_callback_fn*)basic_reset_heap_test}, + {"reset stack clone", 1, (test_callback_fn*)basic_reset_stack_clone_test}, + {"reset heap clone", 1, (test_callback_fn*)basic_reset_heap_clone_test}, {0, 0, 0} }; test_st regression_binary_vs_block[] ={ - {"block add", 1, (test_callback_fn)block_add_regression}, - {"binary add", 1, (test_callback_fn)binary_add_regression}, + {"block add", 1, (test_callback_fn*)block_add_regression}, + {"binary add", 1, (test_callback_fn*)binary_add_regression}, {0, 0, 0} }; test_st async_tests[] ={ - {"add", 1, (test_callback_fn)add_wrapper }, + {"add", 1, (test_callback_fn*)add_wrapper }, {0, 0, 0} }; test_st string_tests[] ={ - {"string static with null", 0, (test_callback_fn)string_static_null }, - {"string alloc with null", 0, (test_callback_fn)string_alloc_null }, - {"string alloc with 1K", 0, (test_callback_fn)string_alloc_with_size }, - {"string alloc with malloc failure", 0, (test_callback_fn)string_alloc_with_size_toobig }, - {"string append", 0, (test_callback_fn)string_alloc_append }, - {"string append failure (too big)", 0, (test_callback_fn)string_alloc_append_toobig }, - {"string_alloc_append_multiple", 0, (test_callback_fn)string_alloc_append_multiple }, - {0, 0, (test_callback_fn)0} + {"string static with null", 0, (test_callback_fn*)string_static_null }, + {"string alloc with null", 0, (test_callback_fn*)string_alloc_null }, + {"string alloc with 1K", 0, (test_callback_fn*)string_alloc_with_size }, + {"string alloc with malloc failure", 0, (test_callback_fn*)string_alloc_with_size_toobig }, + {"string append", 0, (test_callback_fn*)string_alloc_append }, + {"string append failure (too big)", 0, (test_callback_fn*)string_alloc_append_toobig }, + {"string_alloc_append_multiple", 0, (test_callback_fn*)string_alloc_append_multiple }, + {0, 0, (test_callback_fn*)0} }; test_st memcached_server_get_last_disconnect_tests[] ={ - {"memcached_server_get_last_disconnect()", 0, (test_callback_fn)test_multiple_get_last_disconnect}, - {0, 0, (test_callback_fn)0} + {"memcached_server_get_last_disconnect()", 0, (test_callback_fn*)test_multiple_get_last_disconnect}, + {0, 0, (test_callback_fn*)0} }; test_st result_tests[] ={ - {"result static", 0, (test_callback_fn)result_static}, - {"result alloc", 0, (test_callback_fn)result_alloc}, - {0, 0, (test_callback_fn)0} + {"result static", 0, (test_callback_fn*)result_static}, + {"result alloc", 0, (test_callback_fn*)result_alloc}, + {0, 0, (test_callback_fn*)0} }; test_st version_1_2_3[] ={ - {"append", 0, (test_callback_fn)append_test }, - {"prepend", 0, (test_callback_fn)prepend_test }, - {"cas", 0, (test_callback_fn)cas_test }, - {"cas2", 0, (test_callback_fn)cas2_test }, - {"append_binary", 0, (test_callback_fn)append_binary_test }, - {0, 0, (test_callback_fn)0} + {"append", 0, (test_callback_fn*)append_test }, + {"prepend", 0, (test_callback_fn*)prepend_test }, + {"cas", 0, (test_callback_fn*)cas_test }, + {"cas2", 0, (test_callback_fn*)cas2_test }, + {"append_binary", 0, (test_callback_fn*)append_binary_test }, + {0, 0, (test_callback_fn*)0} }; test_st haldenbrand_tests[] ={ - {"memcached_set", 0, (test_callback_fn)user_supplied_bug1 }, - {"memcached_get()", 0, (test_callback_fn)user_supplied_bug2 }, - {"memcached_mget()", 0, (test_callback_fn)user_supplied_bug3 }, - {0, 0, (test_callback_fn)0} + {"memcached_set", 0, (test_callback_fn*)user_supplied_bug1 }, + {"memcached_get()", 0, (test_callback_fn*)user_supplied_bug2 }, + {"memcached_mget()", 0, (test_callback_fn*)user_supplied_bug3 }, + {0, 0, (test_callback_fn*)0} }; test_st user_tests[] ={ - {"user_supplied_bug4", true, (test_callback_fn)user_supplied_bug4 }, - {"user_supplied_bug5", 1, (test_callback_fn)user_supplied_bug5 }, - {"user_supplied_bug6", 1, (test_callback_fn)user_supplied_bug6 }, - {"user_supplied_bug7", 1, (test_callback_fn)user_supplied_bug7 }, - {"user_supplied_bug8", 1, (test_callback_fn)user_supplied_bug8 }, - {"user_supplied_bug9", 1, (test_callback_fn)user_supplied_bug9 }, - {"user_supplied_bug10", 1, (test_callback_fn)user_supplied_bug10 }, - {"user_supplied_bug11", 1, (test_callback_fn)user_supplied_bug11 }, - {"user_supplied_bug12", 1, (test_callback_fn)user_supplied_bug12 }, - {"user_supplied_bug13", 1, (test_callback_fn)user_supplied_bug13 }, - {"user_supplied_bug14", 1, (test_callback_fn)user_supplied_bug14 }, - {"user_supplied_bug15", 1, (test_callback_fn)user_supplied_bug15 }, - {"user_supplied_bug16", 1, (test_callback_fn)user_supplied_bug16 }, + {"user_supplied_bug4", true, (test_callback_fn*)user_supplied_bug4 }, + {"user_supplied_bug5", 1, (test_callback_fn*)user_supplied_bug5 }, + {"user_supplied_bug6", 1, (test_callback_fn*)user_supplied_bug6 }, + {"user_supplied_bug7", 1, (test_callback_fn*)user_supplied_bug7 }, + {"user_supplied_bug8", 1, (test_callback_fn*)user_supplied_bug8 }, + {"user_supplied_bug9", 1, (test_callback_fn*)user_supplied_bug9 }, + {"user_supplied_bug10", 1, (test_callback_fn*)user_supplied_bug10 }, + {"user_supplied_bug11", 1, (test_callback_fn*)user_supplied_bug11 }, + {"user_supplied_bug12", 1, (test_callback_fn*)user_supplied_bug12 }, + {"user_supplied_bug13", 1, (test_callback_fn*)user_supplied_bug13 }, + {"user_supplied_bug14", 1, (test_callback_fn*)user_supplied_bug14 }, + {"user_supplied_bug15", 1, (test_callback_fn*)user_supplied_bug15 }, + {"user_supplied_bug16", 1, (test_callback_fn*)user_supplied_bug16 }, #if !defined(__sun) && !defined(__OpenBSD__) /* ** It seems to be something weird with the character sets.. @@ -6262,25 +6268,25 @@ test_st user_tests[] ={ ** to run the test in a specific locale (I tried zh_CN.UTF-8 without success, ** so just disable the code for now...). */ - {"user_supplied_bug17", 1, (test_callback_fn)user_supplied_bug17 }, + {"user_supplied_bug17", 1, (test_callback_fn*)user_supplied_bug17 }, #endif - {"user_supplied_bug18", 1, (test_callback_fn)user_supplied_bug18 }, - {"user_supplied_bug19", 1, (test_callback_fn)user_supplied_bug19 }, - {"user_supplied_bug20", 1, (test_callback_fn)user_supplied_bug20 }, - {"user_supplied_bug21", 1, (test_callback_fn)user_supplied_bug21 }, - {"wrong_failure_counter_test", 1, (test_callback_fn)wrong_failure_counter_test}, - {"wrong_failure_counter_two_test", 1, (test_callback_fn)wrong_failure_counter_two_test}, - {0, 0, (test_callback_fn)0} + {"user_supplied_bug18", 1, (test_callback_fn*)user_supplied_bug18 }, + {"user_supplied_bug19", 1, (test_callback_fn*)user_supplied_bug19 }, + {"user_supplied_bug20", 1, (test_callback_fn*)user_supplied_bug20 }, + {"user_supplied_bug21", 1, (test_callback_fn*)user_supplied_bug21 }, + {"wrong_failure_counter_test", 1, (test_callback_fn*)wrong_failure_counter_test}, + {"wrong_failure_counter_two_test", 1, (test_callback_fn*)wrong_failure_counter_two_test}, + {0, 0, (test_callback_fn*)0} }; test_st replication_tests[]= { - {"set", 1, (test_callback_fn)replication_set_test }, - {"get", 0, (test_callback_fn)replication_get_test }, - {"mget", 0, (test_callback_fn)replication_mget_test }, - {"delete", 0, (test_callback_fn)replication_delete_test }, - {"rand_mget", 0, (test_callback_fn)replication_randomize_mget_test }, - {"fail", 0, (test_callback_fn)replication_randomize_mget_fail_test }, - {0, 0, (test_callback_fn)0} + {"set", 1, (test_callback_fn*)replication_set_test }, + {"get", 0, (test_callback_fn*)replication_get_test }, + {"mget", 0, (test_callback_fn*)replication_mget_test }, + {"delete", 0, (test_callback_fn*)replication_delete_test }, + {"rand_mget", 0, (test_callback_fn*)replication_randomize_mget_test }, + {"fail", 0, (test_callback_fn*)replication_randomize_mget_fail_test }, + {0, 0, (test_callback_fn*)0} }; /* @@ -6290,143 +6296,143 @@ test_st replication_tests[]= { * http://bugs.launchpad.net/libmemcached */ test_st regression_tests[]= { - {"lp:434484", 1, (test_callback_fn)regression_bug_434484 }, - {"lp:434843", 1, (test_callback_fn)regression_bug_434843 }, - {"lp:434843-buffered", 1, (test_callback_fn)regression_bug_434843_buffered }, - {"lp:421108", 1, (test_callback_fn)regression_bug_421108 }, - {"lp:442914", 1, (test_callback_fn)regression_bug_442914 }, - {"lp:447342", 1, (test_callback_fn)regression_bug_447342 }, - {"lp:463297", 1, (test_callback_fn)regression_bug_463297 }, - {"lp:490486", 1, (test_callback_fn)regression_bug_490486 }, - {"lp:583031", 1, (test_callback_fn)regression_bug_583031 }, - {"lp:?", 1, (test_callback_fn)regression_bug_ }, - {"lp:728286", 1, (test_callback_fn)regression_bug_728286 }, - {"lp:581030", 1, (test_callback_fn)regression_bug_581030 }, - {"lp:71231153 connect()", 1, (test_callback_fn)regression_bug_71231153_connect }, - {"lp:71231153 poll()", 1, (test_callback_fn)regression_bug_71231153_poll }, - {"lp:655423", 1, (test_callback_fn)regression_bug_655423 }, - {"lp:490520", 1, (test_callback_fn)regression_bug_490520 }, - {0, 0, (test_callback_fn)0} + {"lp:434484", 1, (test_callback_fn*)regression_bug_434484 }, + {"lp:434843", 1, (test_callback_fn*)regression_bug_434843 }, + {"lp:434843-buffered", 1, (test_callback_fn*)regression_bug_434843_buffered }, + {"lp:421108", 1, (test_callback_fn*)regression_bug_421108 }, + {"lp:442914", 1, (test_callback_fn*)regression_bug_442914 }, + {"lp:447342", 1, (test_callback_fn*)regression_bug_447342 }, + {"lp:463297", 1, (test_callback_fn*)regression_bug_463297 }, + {"lp:490486", 1, (test_callback_fn*)regression_bug_490486 }, + {"lp:583031", 1, (test_callback_fn*)regression_bug_583031 }, + {"lp:?", 1, (test_callback_fn*)regression_bug_ }, + {"lp:728286", 1, (test_callback_fn*)regression_bug_728286 }, + {"lp:581030", 1, (test_callback_fn*)regression_bug_581030 }, + {"lp:71231153 connect()", 1, (test_callback_fn*)regression_bug_71231153_connect }, + {"lp:71231153 poll()", 1, (test_callback_fn*)regression_bug_71231153_poll }, + {"lp:655423", 1, (test_callback_fn*)regression_bug_655423 }, + {"lp:490520", 1, (test_callback_fn*)regression_bug_490520 }, + {0, 0, (test_callback_fn*)0} }; test_st sasl_auth_tests[]= { - {"sasl_auth", 1, (test_callback_fn)sasl_auth_test }, - {0, 0, (test_callback_fn)0} + {"sasl_auth", 1, (test_callback_fn*)sasl_auth_test }, + {0, 0, (test_callback_fn*)0} }; test_st ketama_compatibility[]= { - {"libmemcached", 1, (test_callback_fn)ketama_compatibility_libmemcached }, - {"spymemcached", 1, (test_callback_fn)ketama_compatibility_spymemcached }, - {0, 0, (test_callback_fn)0} + {"libmemcached", 1, (test_callback_fn*)ketama_compatibility_libmemcached }, + {"spymemcached", 1, (test_callback_fn*)ketama_compatibility_spymemcached }, + {0, 0, (test_callback_fn*)0} }; test_st generate_tests[] ={ - {"generate_pairs", 1, (test_callback_fn)generate_pairs }, - {"generate_data", 1, (test_callback_fn)generate_data }, - {"get_read", 0, (test_callback_fn)get_read }, - {"delete_generate", 0, (test_callback_fn)delete_generate }, - {"generate_buffer_data", 1, (test_callback_fn)generate_buffer_data }, - {"delete_buffer", 0, (test_callback_fn)delete_buffer_generate}, - {"generate_data", 1, (test_callback_fn)generate_data }, - {"mget_read", 0, (test_callback_fn)mget_read }, - {"mget_read_result", 0, (test_callback_fn)mget_read_result }, - {"memcached_fetch_result() use internal result", 0, (test_callback_fn)mget_read_internal_result }, - {"memcached_fetch_result() partial read", 0, (test_callback_fn)mget_read_partial_result }, - {"mget_read_function", 0, (test_callback_fn)mget_read_function }, - {"cleanup", 1, (test_callback_fn)cleanup_pairs }, - {"generate_large_pairs", 1, (test_callback_fn)generate_large_pairs }, - {"generate_data", 1, (test_callback_fn)generate_data }, - {"generate_buffer_data", 1, (test_callback_fn)generate_buffer_data }, - {"cleanup", 1, (test_callback_fn)cleanup_pairs }, - {0, 0, (test_callback_fn)0} + {"generate_pairs", 1, (test_callback_fn*)generate_pairs }, + {"generate_data", 1, (test_callback_fn*)generate_data }, + {"get_read", 0, (test_callback_fn*)get_read }, + {"delete_generate", 0, (test_callback_fn*)delete_generate }, + {"generate_buffer_data", 1, (test_callback_fn*)generate_buffer_data }, + {"delete_buffer", 0, (test_callback_fn*)delete_buffer_generate}, + {"generate_data", 1, (test_callback_fn*)generate_data }, + {"mget_read", 0, (test_callback_fn*)mget_read }, + {"mget_read_result", 0, (test_callback_fn*)mget_read_result }, + {"memcached_fetch_result() use internal result", 0, (test_callback_fn*)mget_read_internal_result }, + {"memcached_fetch_result() partial read", 0, (test_callback_fn*)mget_read_partial_result }, + {"mget_read_function", 0, (test_callback_fn*)mget_read_function }, + {"cleanup", 1, (test_callback_fn*)cleanup_pairs }, + {"generate_large_pairs", 1, (test_callback_fn*)generate_large_pairs }, + {"generate_data", 1, (test_callback_fn*)generate_data }, + {"generate_buffer_data", 1, (test_callback_fn*)generate_buffer_data }, + {"cleanup", 1, (test_callback_fn*)cleanup_pairs }, + {0, 0, (test_callback_fn*)0} }; test_st consistent_tests[] ={ - {"generate_pairs", 1, (test_callback_fn)generate_pairs }, - {"generate_data", 1, (test_callback_fn)generate_data }, - {"get_read", 0, (test_callback_fn)get_read_count }, - {"cleanup", 1, (test_callback_fn)cleanup_pairs }, - {0, 0, (test_callback_fn)0} + {"generate_pairs", 1, (test_callback_fn*)generate_pairs }, + {"generate_data", 1, (test_callback_fn*)generate_data }, + {"get_read", 0, (test_callback_fn*)get_read_count }, + {"cleanup", 1, (test_callback_fn*)cleanup_pairs }, + {0, 0, (test_callback_fn*)0} }; test_st consistent_weighted_tests[] ={ - {"generate_pairs", 1, (test_callback_fn)generate_pairs }, - {"generate_data", 1, (test_callback_fn)generate_data_with_stats }, - {"get_read", 0, (test_callback_fn)get_read_count }, - {"cleanup", 1, (test_callback_fn)cleanup_pairs }, - {0, 0, (test_callback_fn)0} + {"generate_pairs", 1, (test_callback_fn*)generate_pairs }, + {"generate_data", 1, (test_callback_fn*)generate_data_with_stats }, + {"get_read", 0, (test_callback_fn*)get_read_count }, + {"cleanup", 1, (test_callback_fn*)cleanup_pairs }, + {0, 0, (test_callback_fn*)0} }; test_st hsieh_availability[] ={ - {"hsieh_avaibility_test", 0, (test_callback_fn)hsieh_avaibility_test}, - {0, 0, (test_callback_fn)0} + {"hsieh_avaibility_test", 0, (test_callback_fn*)hsieh_avaibility_test}, + {0, 0, (test_callback_fn*)0} }; test_st murmur_availability[] ={ - {"murmur_avaibility_test", 0, (test_callback_fn)murmur_avaibility_test}, - {0, 0, (test_callback_fn)0} + {"murmur_avaibility_test", 0, (test_callback_fn*)murmur_avaibility_test}, + {0, 0, (test_callback_fn*)0} }; #if 0 test_st hash_sanity[] ={ - {"hash sanity", 0, (test_callback_fn)hash_sanity_test}, - {0, 0, (test_callback_fn)0} + {"hash sanity", 0, (test_callback_fn*)hash_sanity_test}, + {0, 0, (test_callback_fn*)0} }; #endif test_st ketama_auto_eject_hosts[] ={ - {"auto_eject_hosts", 1, (test_callback_fn)auto_eject_hosts }, - {"output_ketama_weighted_keys", 1, (test_callback_fn)output_ketama_weighted_keys }, - {0, 0, (test_callback_fn)0} + {"auto_eject_hosts", 1, (test_callback_fn*)auto_eject_hosts }, + {"output_ketama_weighted_keys", 1, (test_callback_fn*)output_ketama_weighted_keys }, + {0, 0, (test_callback_fn*)0} }; test_st hash_tests[] ={ - {"one_at_a_time_run", 0, (test_callback_fn)one_at_a_time_run }, - {"md5", 0, (test_callback_fn)md5_run }, - {"crc", 0, (test_callback_fn)crc_run }, - {"fnv1_64", 0, (test_callback_fn)fnv1_64_run }, - {"fnv1a_64", 0, (test_callback_fn)fnv1a_64_run }, - {"fnv1_32", 0, (test_callback_fn)fnv1_32_run }, - {"fnv1a_32", 0, (test_callback_fn)fnv1a_32_run }, - {"hsieh", 0, (test_callback_fn)hsieh_run }, - {"murmur", 0, (test_callback_fn)murmur_run }, - {"jenkis", 0, (test_callback_fn)jenkins_run }, - {"memcached_get_hashkit", 0, (test_callback_fn)memcached_get_hashkit_test }, - {0, 0, (test_callback_fn)0} + {"one_at_a_time_run", 0, (test_callback_fn*)one_at_a_time_run }, + {"md5", 0, (test_callback_fn*)md5_run }, + {"crc", 0, (test_callback_fn*)crc_run }, + {"fnv1_64", 0, (test_callback_fn*)fnv1_64_run }, + {"fnv1a_64", 0, (test_callback_fn*)fnv1a_64_run }, + {"fnv1_32", 0, (test_callback_fn*)fnv1_32_run }, + {"fnv1a_32", 0, (test_callback_fn*)fnv1a_32_run }, + {"hsieh", 0, (test_callback_fn*)hsieh_run }, + {"murmur", 0, (test_callback_fn*)murmur_run }, + {"jenkis", 0, (test_callback_fn*)jenkins_run }, + {"memcached_get_hashkit", 0, (test_callback_fn*)memcached_get_hashkit_test }, + {0, 0, (test_callback_fn*)0} }; test_st error_conditions[] ={ - {"memcached_get(MEMCACHED_ERRNO)", 0, (test_callback_fn)memcached_get_MEMCACHED_ERRNO }, - {"memcached_get(MEMCACHED_NOTFOUND)", 0, (test_callback_fn)memcached_get_MEMCACHED_NOTFOUND }, - {"memcached_get_by_key(MEMCACHED_ERRNO)", 0, (test_callback_fn)memcached_get_by_key_MEMCACHED_ERRNO }, - {"memcached_get_by_key(MEMCACHED_NOTFOUND)", 0, (test_callback_fn)memcached_get_by_key_MEMCACHED_NOTFOUND }, - {"memcached_get_by_key(MEMCACHED_NOTFOUND)", 0, (test_callback_fn)memcached_get_by_key_MEMCACHED_NOTFOUND }, - {"memcached_increment(MEMCACHED_NO_SERVERS)", 0, (test_callback_fn)memcached_increment_MEMCACHED_NO_SERVERS }, - {0, 0, (test_callback_fn)0} + {"memcached_get(MEMCACHED_ERRNO)", 0, (test_callback_fn*)memcached_get_MEMCACHED_ERRNO }, + {"memcached_get(MEMCACHED_NOTFOUND)", 0, (test_callback_fn*)memcached_get_MEMCACHED_NOTFOUND }, + {"memcached_get_by_key(MEMCACHED_ERRNO)", 0, (test_callback_fn*)memcached_get_by_key_MEMCACHED_ERRNO }, + {"memcached_get_by_key(MEMCACHED_NOTFOUND)", 0, (test_callback_fn*)memcached_get_by_key_MEMCACHED_NOTFOUND }, + {"memcached_get_by_key(MEMCACHED_NOTFOUND)", 0, (test_callback_fn*)memcached_get_by_key_MEMCACHED_NOTFOUND }, + {"memcached_increment(MEMCACHED_NO_SERVERS)", 0, (test_callback_fn*)memcached_increment_MEMCACHED_NO_SERVERS }, + {0, 0, (test_callback_fn*)0} }; test_st parser_tests[] ={ - {"behavior", 0, (test_callback_fn)behavior_parser_test }, - {"boolean_options", 0, (test_callback_fn)parser_boolean_options_test }, - {"configure_file", 0, (test_callback_fn)memcached_create_with_options_with_filename }, - {"distribtions", 0, (test_callback_fn)parser_distribution_test }, - {"hash", 0, (test_callback_fn)parser_hash_test }, - {"libmemcached_check_configuration", 0, (test_callback_fn)libmemcached_check_configuration_test }, - {"libmemcached_check_configuration_with_filename", 0, (test_callback_fn)libmemcached_check_configuration_with_filename_test }, - {"number_options", 0, (test_callback_fn)parser_number_options_test }, - {"randomly generated options", 0, (test_callback_fn)random_statement_build_test }, - {"prefix_key", 0, (test_callback_fn)parser_key_prefix_test }, - {"server", 0, (test_callback_fn)server_test }, - {"bad server strings", 0, (test_callback_fn)servers_bad_test }, - {"server with weights", 0, (test_callback_fn)server_with_weight_test }, - {"parsing servername, port, and weight", 0, (test_callback_fn)test_hostname_port_weight }, - {0, 0, (test_callback_fn)0} + {"behavior", 0, (test_callback_fn*)behavior_parser_test }, + {"boolean_options", 0, (test_callback_fn*)parser_boolean_options_test }, + {"configure_file", 0, (test_callback_fn*)memcached_create_with_options_with_filename }, + {"distribtions", 0, (test_callback_fn*)parser_distribution_test }, + {"hash", 0, (test_callback_fn*)parser_hash_test }, + {"libmemcached_check_configuration", 0, (test_callback_fn*)libmemcached_check_configuration_test }, + {"libmemcached_check_configuration_with_filename", 0, (test_callback_fn*)libmemcached_check_configuration_with_filename_test }, + {"number_options", 0, (test_callback_fn*)parser_number_options_test }, + {"randomly generated options", 0, (test_callback_fn*)random_statement_build_test }, + {"prefix_key", 0, (test_callback_fn*)parser_key_prefix_test }, + {"server", 0, (test_callback_fn*)server_test }, + {"bad server strings", 0, (test_callback_fn*)servers_bad_test }, + {"server with weights", 0, (test_callback_fn*)server_with_weight_test }, + {"parsing servername, port, and weight", 0, (test_callback_fn*)test_hostname_port_weight }, + {0, 0, (test_callback_fn*)0} }; test_st virtual_bucket_tests[] ={ - {"basic", 0, (test_callback_fn)virtual_back_map }, - {0, 0, (test_callback_fn)0} + {"basic", 0, (test_callback_fn*)virtual_back_map }, + {0, 0, (test_callback_fn*)0} }; collection_st collection[] ={ @@ -6437,61 +6443,61 @@ collection_st collection[] ={ {"hsieh_availability", 0, 0, hsieh_availability}, {"murmur_availability", 0, 0, murmur_availability}, {"block", 0, 0, tests}, - {"binary", (test_callback_fn)pre_binary, 0, tests}, - {"nonblock", (test_callback_fn)pre_nonblock, 0, tests}, - {"nodelay", (test_callback_fn)pre_nodelay, 0, tests}, - {"settimer", (test_callback_fn)pre_settimer, 0, tests}, - {"md5", (test_callback_fn)pre_md5, 0, tests}, - {"crc", (test_callback_fn)pre_crc, 0, tests}, - {"hsieh", (test_callback_fn)pre_hsieh, 0, tests}, - {"jenkins", (test_callback_fn)pre_jenkins, 0, tests}, - {"fnv1_64", (test_callback_fn)pre_hash_fnv1_64, 0, tests}, - {"fnv1a_64", (test_callback_fn)pre_hash_fnv1a_64, 0, tests}, - {"fnv1_32", (test_callback_fn)pre_hash_fnv1_32, 0, tests}, - {"fnv1a_32", (test_callback_fn)pre_hash_fnv1a_32, 0, tests}, - {"ketama", (test_callback_fn)pre_behavior_ketama, 0, tests}, - {"ketama_auto_eject_hosts", (test_callback_fn)pre_behavior_ketama, 0, ketama_auto_eject_hosts}, - {"unix_socket", (test_callback_fn)pre_unix_socket, 0, tests}, - {"unix_socket_nodelay", (test_callback_fn)pre_nodelay, 0, tests}, - {"poll_timeout", (test_callback_fn)poll_timeout, 0, tests}, - {"gets", (test_callback_fn)enable_cas, 0, tests}, - {"consistent_crc", (test_callback_fn)enable_consistent_crc, 0, tests}, - {"consistent_hsieh", (test_callback_fn)enable_consistent_hsieh, 0, tests}, + {"binary", (test_callback_fn*)pre_binary, 0, tests}, + {"nonblock", (test_callback_fn*)pre_nonblock, 0, tests}, + {"nodelay", (test_callback_fn*)pre_nodelay, 0, tests}, + {"settimer", (test_callback_fn*)pre_settimer, 0, tests}, + {"md5", (test_callback_fn*)pre_md5, 0, tests}, + {"crc", (test_callback_fn*)pre_crc, 0, tests}, + {"hsieh", (test_callback_fn*)pre_hsieh, 0, tests}, + {"jenkins", (test_callback_fn*)pre_jenkins, 0, tests}, + {"fnv1_64", (test_callback_fn*)pre_hash_fnv1_64, 0, tests}, + {"fnv1a_64", (test_callback_fn*)pre_hash_fnv1a_64, 0, tests}, + {"fnv1_32", (test_callback_fn*)pre_hash_fnv1_32, 0, tests}, + {"fnv1a_32", (test_callback_fn*)pre_hash_fnv1a_32, 0, tests}, + {"ketama", (test_callback_fn*)pre_behavior_ketama, 0, tests}, + {"ketama_auto_eject_hosts", (test_callback_fn*)pre_behavior_ketama, 0, ketama_auto_eject_hosts}, + {"unix_socket", (test_callback_fn*)pre_unix_socket, 0, tests}, + {"unix_socket_nodelay", (test_callback_fn*)pre_nodelay, 0, tests}, + {"poll_timeout", (test_callback_fn*)poll_timeout, 0, tests}, + {"gets", (test_callback_fn*)enable_cas, 0, tests}, + {"consistent_crc", (test_callback_fn*)enable_consistent_crc, 0, tests}, + {"consistent_hsieh", (test_callback_fn*)enable_consistent_hsieh, 0, tests}, #ifdef MEMCACHED_ENABLE_DEPRECATED - {"deprecated_memory_allocators", (test_callback_fn)deprecated_set_memory_alloc, 0, tests}, + {"deprecated_memory_allocators", (test_callback_fn*)deprecated_set_memory_alloc, 0, tests}, #endif - {"memory_allocators", (test_callback_fn)set_memory_alloc, 0, tests}, - {"prefix", (test_callback_fn)set_prefix, 0, tests}, - {"sasl_auth", (test_callback_fn)pre_sasl, 0, sasl_auth_tests }, - {"sasl", (test_callback_fn)pre_sasl, 0, tests }, - {"version_1_2_3", (test_callback_fn)check_for_1_2_3, 0, version_1_2_3}, + {"memory_allocators", (test_callback_fn*)set_memory_alloc, 0, tests}, + {"prefix", (test_callback_fn*)set_prefix, 0, tests}, + {"sasl_auth", (test_callback_fn*)pre_sasl, 0, sasl_auth_tests }, + {"sasl", (test_callback_fn*)pre_sasl, 0, tests }, + {"version_1_2_3", (test_callback_fn*)check_for_1_2_3, 0, version_1_2_3}, {"string", 0, 0, string_tests}, {"result", 0, 0, result_tests}, - {"async", (test_callback_fn)pre_nonblock, 0, async_tests}, - {"async_binary", (test_callback_fn)pre_nonblock_binary, 0, async_tests}, + {"async", (test_callback_fn*)pre_nonblock, 0, async_tests}, + {"async_binary", (test_callback_fn*)pre_nonblock_binary, 0, async_tests}, {"Cal Haldenbrand's tests", 0, 0, haldenbrand_tests}, {"user", 0, 0, user_tests}, {"generate", 0, 0, generate_tests}, - {"generate_hsieh", (test_callback_fn)pre_hsieh, 0, generate_tests}, - {"generate_ketama", (test_callback_fn)pre_behavior_ketama, 0, generate_tests}, - {"generate_hsieh_consistent", (test_callback_fn)enable_consistent_hsieh, 0, generate_tests}, - {"generate_md5", (test_callback_fn)pre_md5, 0, generate_tests}, - {"generate_murmur", (test_callback_fn)pre_murmur, 0, generate_tests}, - {"generate_jenkins", (test_callback_fn)pre_jenkins, 0, generate_tests}, - {"generate_nonblock", (test_callback_fn)pre_nonblock, 0, generate_tests}, + {"generate_hsieh", (test_callback_fn*)pre_hsieh, 0, generate_tests}, + {"generate_ketama", (test_callback_fn*)pre_behavior_ketama, 0, generate_tests}, + {"generate_hsieh_consistent", (test_callback_fn*)enable_consistent_hsieh, 0, generate_tests}, + {"generate_md5", (test_callback_fn*)pre_md5, 0, generate_tests}, + {"generate_murmur", (test_callback_fn*)pre_murmur, 0, generate_tests}, + {"generate_jenkins", (test_callback_fn*)pre_jenkins, 0, generate_tests}, + {"generate_nonblock", (test_callback_fn*)pre_nonblock, 0, generate_tests}, // Too slow - {"generate_corked", (test_callback_fn)pre_cork, 0, generate_tests}, - {"generate_corked_and_nonblock", (test_callback_fn)pre_cork_and_nonblock, 0, generate_tests}, + {"generate_corked", (test_callback_fn*)pre_cork, 0, generate_tests}, + {"generate_corked_and_nonblock", (test_callback_fn*)pre_cork_and_nonblock, 0, generate_tests}, {"consistent_not", 0, 0, consistent_tests}, - {"consistent_ketama", (test_callback_fn)pre_behavior_ketama, 0, consistent_tests}, - {"consistent_ketama_weighted", (test_callback_fn)pre_behavior_ketama_weighted, 0, consistent_weighted_tests}, + {"consistent_ketama", (test_callback_fn*)pre_behavior_ketama, 0, consistent_tests}, + {"consistent_ketama_weighted", (test_callback_fn*)pre_behavior_ketama_weighted, 0, consistent_weighted_tests}, {"ketama_compat", 0, 0, ketama_compatibility}, {"test_hashes", 0, 0, hash_tests}, - {"replication", (test_callback_fn)pre_replication, 0, replication_tests}, - {"replication_noblock", (test_callback_fn)pre_replication_noblock, 0, replication_tests}, + {"replication", (test_callback_fn*)pre_replication, 0, replication_tests}, + {"replication_noblock", (test_callback_fn*)pre_replication_noblock, 0, replication_tests}, {"regression", 0, 0, regression_tests}, {"behaviors", 0, 0, behavior_tests}, - {"regression_binary_vs_block", (test_callback_fn)key_setup, (test_callback_fn)key_teardown, regression_binary_vs_block}, + {"regression_binary_vs_block", (test_callback_fn*)key_setup, (test_callback_fn*)key_teardown, regression_binary_vs_block}, {"error_conditions", 0, 0, error_conditions}, {"parser", 0, 0, parser_tests}, {"virtual buckets", 0, 0, virtual_bucket_tests}, @@ -6505,17 +6511,17 @@ void get_world(world_st *world) { world->collections= collection; - world->create= (test_callback_create_fn)world_create; - world->destroy= (test_callback_fn)world_destroy; + world->create= (test_callback_create_fn*)world_create; + world->destroy= (test_callback_fn*)world_destroy; - world->test.startup= (test_callback_fn)world_test_startup; - world->test.flush= (test_callback_fn)world_flush; - world->test.pre_run= (test_callback_fn)world_pre_run; - world->test.post_run= (test_callback_fn)world_post_run; - world->test.on_error= (test_callback_error_fn)world_on_error; + world->run_startup= (test_callback_fn*)world_test_startup; + world->flush= (test_callback_fn*)world_flush; + world->pre_run= (test_callback_fn*)world_pre_run; + world->post_run= (test_callback_fn*)world_post_run; + world->on_error= (test_callback_error_fn*)world_on_error; - world->collection.startup= (test_callback_fn)world_container_startup; - world->collection.shutdown= (test_callback_fn)world_container_shutdown; + world->collection_startup= (test_callback_fn*)world_container_startup; + world->collection_shutdown= (test_callback_fn*)world_container_shutdown; world->runner= &defualt_libmemcached_runner; } diff --git a/tests/mem_udp.c b/tests/mem_udp.cc similarity index 85% rename from tests/mem_udp.c rename to tests/mem_udp.cc index 01314dbd..3bee8cc4 100644 --- a/tests/mem_udp.c +++ b/tests/mem_udp.cc @@ -70,8 +70,8 @@ static void increment_request_id(uint16_t *id) static uint16_t *get_udp_request_ids(memcached_st *memc) { - uint16_t *ids= malloc(sizeof(uint16_t) * memcached_server_count(memc)); - assert(ids != NULL); + 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++) { @@ -425,23 +425,23 @@ 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}, + (test_callback_fn*)udp_set_test}, {"udp_set_too_big_test", 0, - (test_callback_fn)udp_set_too_big_test}, + (test_callback_fn*)udp_set_too_big_test}, {"udp_delete_test", 0, - (test_callback_fn)udp_delete_test}, + (test_callback_fn*)udp_delete_test}, {"udp_verbosity_test", 0, - (test_callback_fn)udp_verbosity_test}, + (test_callback_fn*)udp_verbosity_test}, {"udp_quit_test", 0, - (test_callback_fn)udp_quit_test}, + (test_callback_fn*)udp_quit_test}, {"udp_flush_test", 0, - (test_callback_fn)udp_flush_test}, + (test_callback_fn*)udp_flush_test}, {"udp_incr_test", 0, - (test_callback_fn)udp_incr_test}, + (test_callback_fn*)udp_incr_test}, {"udp_decr_test", 0, - (test_callback_fn)udp_decr_test}, + (test_callback_fn*)udp_decr_test}, {"udp_version_test", 0, - (test_callback_fn)udp_version_test} + (test_callback_fn*)udp_version_test} }; for (size_t x= 0; x < 500; x++) @@ -453,34 +453,34 @@ static test_return_t udp_mixed_io_test(memcached_st *memc) } 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}, - {"add_udp_server_tcp_client_test", 0, (test_callback_fn)add_udp_server_tcp_client_test}, + {"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}, + {"add_udp_server_tcp_client_test", 0, (test_callback_fn*)add_udp_server_tcp_client_test}, {0, 0, 0} }; test_st upd_io_tests[] ={ - {"udp_set_test", 0, (test_callback_fn)udp_set_test}, - {"udp_buffered_set_test", 0, (test_callback_fn)udp_buffered_set_test}, - {"udp_set_too_big_test", 0, (test_callback_fn)udp_set_too_big_test}, - {"udp_delete_test", 0, (test_callback_fn)udp_delete_test}, - {"udp_buffered_delete_test", 0, (test_callback_fn)udp_buffered_delete_test}, - {"udp_verbosity_test", 0, (test_callback_fn)udp_verbosity_test}, - {"udp_quit_test", 0, (test_callback_fn)udp_quit_test}, - {"udp_flush_test", 0, (test_callback_fn)udp_flush_test}, - {"udp_incr_test", 0, (test_callback_fn)udp_incr_test}, - {"udp_decr_test", 0, (test_callback_fn)udp_decr_test}, - {"udp_stat_test", 0, (test_callback_fn)udp_stat_test}, - {"udp_version_test", 0, (test_callback_fn)udp_version_test}, - {"udp_get_test", 0, (test_callback_fn)udp_get_test}, - {"udp_mixed_io_test", 0, (test_callback_fn)udp_mixed_io_test}, + {"udp_set_test", 0, (test_callback_fn*)udp_set_test}, + {"udp_buffered_set_test", 0, (test_callback_fn*)udp_buffered_set_test}, + {"udp_set_too_big_test", 0, (test_callback_fn*)udp_set_too_big_test}, + {"udp_delete_test", 0, (test_callback_fn*)udp_delete_test}, + {"udp_buffered_delete_test", 0, (test_callback_fn*)udp_buffered_delete_test}, + {"udp_verbosity_test", 0, (test_callback_fn*)udp_verbosity_test}, + {"udp_quit_test", 0, (test_callback_fn*)udp_quit_test}, + {"udp_flush_test", 0, (test_callback_fn*)udp_flush_test}, + {"udp_incr_test", 0, (test_callback_fn*)udp_incr_test}, + {"udp_decr_test", 0, (test_callback_fn*)udp_decr_test}, + {"udp_stat_test", 0, (test_callback_fn*)udp_stat_test}, + {"udp_version_test", 0, (test_callback_fn*)udp_version_test}, + {"udp_get_test", 0, (test_callback_fn*)udp_get_test}, + {"udp_mixed_io_test", 0, (test_callback_fn*)udp_mixed_io_test}, {0, 0, 0} }; 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}, - {"udp_binary_io", (test_callback_fn)binary_init_udp, 0, upd_io_tests}, + {"udp_setup", (test_callback_fn*)init_udp, 0, udp_setup_server_tests}, + {"udp_io", (test_callback_fn*)init_udp, 0, upd_io_tests}, + {"udp_binary_io", (test_callback_fn*)binary_init_udp, 0, upd_io_tests}, {0, 0, 0, 0} }; @@ -492,17 +492,17 @@ void get_world(world_st *world) { world->collections= collection; - world->create= (test_callback_create_fn)world_create; - world->destroy= (test_callback_fn)world_destroy; + world->create= (test_callback_create_fn*)world_create; + world->destroy= (test_callback_fn*)world_destroy; - world->test.startup= (test_callback_fn)world_test_startup; - world->test.flush= (test_callback_fn)world_flush; - world->test.pre_run= (test_callback_fn)world_pre_run; - world->test.post_run= (test_callback_fn)world_post_run; - world->test.on_error= (test_callback_error_fn)world_on_error; + world->run_startup= (test_callback_fn*)world_test_startup; + world->flush= (test_callback_fn*)world_flush; + world->pre_run= (test_callback_fn*)world_pre_run; + world->post_run= (test_callback_fn*)world_post_run; + world->on_error= (test_callback_error_fn*)world_on_error; - world->collection.startup= (test_callback_fn)world_container_startup; - world->collection.shutdown= (test_callback_fn)world_container_shutdown; + world->collection_startup= (test_callback_fn*)world_container_startup; + world->collection_shutdown= (test_callback_fn*)world_container_shutdown; world->runner= &defualt_libmemcached_runner; } diff --git a/tests/parser.cc b/tests/parser.cc index bb2de83f..e18fd01c 100644 --- a/tests/parser.cc +++ b/tests/parser.cc @@ -334,7 +334,7 @@ test_return_t memcached_create_with_options_with_filename(memcached_st*) return TEST_SKIPPED; memcached_st *memc_ptr; - memc_ptr= memcached(STRING_WITH_LEN("--CONFIGURE-FILE=\"support/example.cnf\"")); + memc_ptr= memcached(test_literal_param("--CONFIGURE-FILE=\"support/example.cnf\"")); test_true_got(memc_ptr, "memcached() failed"); test_strcmp(SUPPORT_EXAMPLE_CNF, memcached_array_string(memc_ptr->configure.filename)); memcached_free(memc_ptr); @@ -350,13 +350,13 @@ test_return_t libmemcached_check_configuration_with_filename_test(memcached_st*) memcached_return_t rc; char buffer[BUFSIZ]; - rc= libmemcached_check_configuration(STRING_WITH_LEN("--CONFIGURE-FILE=\"support/example.cnf\""), buffer, sizeof(buffer)); + rc= libmemcached_check_configuration(test_literal_param("--CONFIGURE-FILE=\"support/example.cnf\""), buffer, sizeof(buffer)); test_true_got(rc == MEMCACHED_SUCCESS, (rc == MEMCACHED_ERRNO) ? strerror(errno) : memcached_strerror(NULL, rc)); - rc= libmemcached_check_configuration(STRING_WITH_LEN("--CONFIGURE-FILE=support/example.cnf"), buffer, sizeof(buffer)); + rc= libmemcached_check_configuration(test_literal_param("--CONFIGURE-FILE=support/example.cnf"), buffer, sizeof(buffer)); test_false_with(rc == MEMCACHED_SUCCESS, memcached_strerror(NULL, rc)); - rc= libmemcached_check_configuration(STRING_WITH_LEN("--CONFIGURE-FILE=\"bad-path/example.cnf\""), buffer, sizeof(buffer)); + rc= libmemcached_check_configuration(test_literal_param("--CONFIGURE-FILE=\"bad-path/example.cnf\""), buffer, sizeof(buffer)); test_true_got(rc == MEMCACHED_ERRNO, memcached_strerror(NULL, rc)); return TEST_SUCCESS; @@ -367,10 +367,10 @@ test_return_t libmemcached_check_configuration_test(memcached_st*) memcached_return_t rc; char buffer[BUFSIZ]; - rc= libmemcached_check_configuration(STRING_WITH_LEN("--server=localhost"), buffer, sizeof(buffer)); + rc= libmemcached_check_configuration(test_literal_param("--server=localhost"), buffer, sizeof(buffer)); test_true_got(rc == MEMCACHED_SUCCESS, buffer); - rc= libmemcached_check_configuration(STRING_WITH_LEN("--dude=localhost"), buffer, sizeof(buffer)); + rc= libmemcached_check_configuration(test_literal_param("--dude=localhost"), buffer, sizeof(buffer)); test_false_with(rc == MEMCACHED_SUCCESS, buffer); test_true(rc == MEMCACHED_PARSE_ERROR); @@ -380,11 +380,11 @@ test_return_t libmemcached_check_configuration_test(memcached_st*) test_return_t memcached_create_with_options_test(memcached_st*) { memcached_st *memc_ptr; - memc_ptr= memcached(STRING_WITH_LEN("--server=localhost")); + memc_ptr= memcached(test_literal_param("--server=localhost")); test_true_got(memc_ptr, memcached_last_error_message(memc_ptr)); memcached_free(memc_ptr); - memc_ptr= memcached(STRING_WITH_LEN("--dude=localhost")); + memc_ptr= memcached(test_literal_param("--dude=localhost")); test_false_with(memc_ptr, memcached_last_error_message(memc_ptr)); return TEST_SUCCESS; @@ -397,7 +397,7 @@ test_return_t test_include_keyword(memcached_st*) char buffer[BUFSIZ]; memcached_return_t rc; - rc= libmemcached_check_configuration(STRING_WITH_LEN("INCLUDE \"support/example.cnf\""), buffer, sizeof(buffer)); + rc= libmemcached_check_configuration(test_literal_param("INCLUDE \"support/example.cnf\""), buffer, sizeof(buffer)); test_true_got(rc == MEMCACHED_SUCCESS, buffer); return TEST_SUCCESS; @@ -407,7 +407,7 @@ test_return_t test_end_keyword(memcached_st*) { char buffer[BUFSIZ]; memcached_return_t rc; - rc= libmemcached_check_configuration(STRING_WITH_LEN("--server=localhost END bad keywords"), buffer, sizeof(buffer)); + rc= libmemcached_check_configuration(test_literal_param("--server=localhost END bad keywords"), buffer, sizeof(buffer)); test_true_got(rc == MEMCACHED_SUCCESS, buffer); return TEST_SUCCESS; @@ -417,7 +417,7 @@ test_return_t test_reset_keyword(memcached_st*) { char buffer[BUFSIZ]; memcached_return_t rc; - rc= libmemcached_check_configuration(STRING_WITH_LEN("--server=localhost reset --server=bad.com"), buffer, sizeof(buffer)); + rc= libmemcached_check_configuration(test_literal_param("--server=localhost reset --server=bad.com"), buffer, sizeof(buffer)); test_true_got(rc == MEMCACHED_SUCCESS, buffer); return TEST_SUCCESS; @@ -427,7 +427,7 @@ test_return_t test_error_keyword(memcached_st*) { char buffer[BUFSIZ]; memcached_return_t rc; - rc= libmemcached_check_configuration(STRING_WITH_LEN("--server=localhost ERROR --server=bad.com"), buffer, sizeof(buffer)); + rc= libmemcached_check_configuration(test_literal_param("--server=localhost ERROR --server=bad.com"), buffer, sizeof(buffer)); test_true_got(rc != MEMCACHED_SUCCESS, buffer); return TEST_SUCCESS; diff --git a/tests/plus.cpp b/tests/plus.cpp index 59ebf555..efb705a7 100644 --- a/tests/plus.cpp +++ b/tests/plus.cpp @@ -199,15 +199,15 @@ test_return_t basic_behavior(memcached_st *original) test_st tests[] ={ { "basic", 0, - reinterpret_cast(basic_test) }, + reinterpret_cast(basic_test) }, { "basic_master_key", 0, - reinterpret_cast(basic_master_key_test) }, + reinterpret_cast(basic_master_key_test) }, { "increment_test", 0, - reinterpret_cast(increment_test) }, + reinterpret_cast(increment_test) }, { "mget", 1, - reinterpret_cast(mget_test) }, + reinterpret_cast(mget_test) }, { "basic_behavior", 0, - reinterpret_cast(basic_behavior) }, + reinterpret_cast(basic_behavior) }, {0, 0, 0} }; @@ -224,17 +224,17 @@ void get_world(world_st *world) { world->collections= collection; - world->create= reinterpret_cast(world_create); - world->destroy= reinterpret_cast(world_destroy); + world->create= reinterpret_cast(world_create); + world->destroy= reinterpret_cast(world_destroy); - world->test.startup= reinterpret_cast(world_test_startup); - world->test.flush= reinterpret_cast(world_flush); - world->test.pre_run= reinterpret_cast(world_pre_run); - world->test.post_run= reinterpret_cast(world_post_run); - world->test.on_error= reinterpret_cast(world_on_error); + world->run_startup= reinterpret_cast(world_test_startup); + world->flush= reinterpret_cast(world_flush); + world->pre_run= reinterpret_cast(world_pre_run); + world->post_run= reinterpret_cast(world_post_run); + world->on_error= reinterpret_cast(world_on_error); - world->collection.startup= reinterpret_cast(world_container_startup); - world->collection.shutdown= reinterpret_cast(world_container_shutdown); + world->collection_startup= reinterpret_cast(world_container_startup); + world->collection_shutdown= reinterpret_cast(world_container_shutdown); world->runner= &defualt_libmemcached_runner; } diff --git a/tests/start.c b/tests/start.cc similarity index 100% rename from tests/start.c rename to tests/start.cc -- 2.30.2