Merge lp:~brianaker/libmemcached/merge-of-1.0 into lp:libmemcached
- merge-of-1.0
- Merge into 1.2
Proposed by
Brian Aker
Status: | Merged |
---|---|
Merged at revision: | 1109 |
Proposed branch: | lp:~brianaker/libmemcached/merge-of-1.0 |
Merge into: | lp:libmemcached |
Diff against target: |
1745 lines (+475/-347) 39 files modified
bootstrap.sh (+15/-17) clients/generator.cc (+5/-3) clients/memcp.cc (+1/-1) clients/memslap.cc (+5/-3) clients/memtouch.cc (+1/-1) clients/ms_setting.h (+1/-1) docs/memcached_auto.rst (+4/-2) libmemcached-1.2/deprecated_types.h (+1/-0) libmemcached/auto.cc (+5/-0) libmemcached/connect.cc (+1/-1) libmemcached/error.cc (+138/-119) libmemcached/get.cc (+15/-5) libmemcached/io.cc (+9/-4) libmemcached/io.hpp (+2/-1) libmemcached/key.cc (+47/-23) libmemcached/key.hpp (+0/-24) libmemcached/response.cc (+10/-1) libmemcached/stats.cc (+7/-6) libmemcached/string.cc (+11/-9) libmemcached/touch.cc (+2/-2) libtest/cmdline.cc (+1/-1) libtest/core.cc (+2/-2) libtest/main.cc (+6/-3) libtest/unittest.cc (+5/-5) m4/ax_debug.m4 (+4/-2) tests/cli.am (+9/-0) tests/libmemcached-1.0/all_tests.h (+4/-2) tests/libmemcached-1.0/mem_functions.cc (+113/-73) tests/libmemcached-1.0/mem_functions.h (+2/-0) tests/libmemcached-1.0/plus.cpp (+7/-0) tests/libmemcached_world.h (+2/-0) tests/libmemcached_world_socket.h (+3/-0) tests/memcat.cc (+7/-5) tests/memcp.cc (+4/-0) tests/memdump.cc (+6/-13) tests/memexist.cc (+8/-8) tests/memping.cc (+2/-2) tests/memrm.cc (+3/-1) tests/memtouch.cc (+7/-7) |
To merge this branch: | bzr merge lp:~brianaker/libmemcached/merge-of-1.0 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tangent Trunk | Pending | ||
Review via email: mp+190637@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'bootstrap.sh' |
2 | --- bootstrap.sh 2013-06-13 22:13:53 +0000 |
3 | +++ bootstrap.sh 2013-10-11 12:20:38 +0000 |
4 | @@ -420,10 +420,6 @@ |
5 | ret=1; |
6 | # If we are executing on OSX use CLANG, otherwise only use it if we find it in the ENV |
7 | case $HOST_OS in |
8 | - *-darwin-*) |
9 | - run CC=clang CXX=clang++ $top_srcdir/configure "$BUILD_CONFIGURE_ARG" || die "Cannot execute CC=clang CXX=clang++ configure $BUILD_CONFIGURE_ARG" |
10 | - ret=$? |
11 | - ;; |
12 | rhel-5*) |
13 | command_exists 'gcc44' || die "Could not locate gcc44" |
14 | run CC=gcc44 CXX=gcc44 $top_srcdir/configure "$BUILD_CONFIGURE_ARG" || die "Cannot execute CC=gcc44 CXX=gcc44 configure $BUILD_CONFIGURE_ARG" |
15 | @@ -793,18 +789,14 @@ |
16 | |
17 | CC=clang CXX=clang++ |
18 | export CC CXX |
19 | + CONFIGURE='scan-build ./configure' |
20 | CONFIGURE_ARGS='--enable-debug' |
21 | |
22 | - make_skeleton |
23 | - ret=$? |
24 | - |
25 | - make_target 'clean' 'warn' |
26 | + run_configure |
27 | |
28 | scan-build -o clang-html make -j4 -k |
29 | |
30 | restore_BUILD |
31 | - |
32 | - return $ret |
33 | } |
34 | |
35 | # If we are locally testing, we should make sure the environment is setup correctly |
36 | @@ -1010,6 +1002,9 @@ |
37 | { |
38 | if command_exists 'rpmbuild'; then |
39 | if [ -f 'rpm.am' -o -d 'rpm' ]; then |
40 | + mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} |
41 | + mkdir -p ~/rpmbuild/RPMS/{i386,i486,i586,i686,noarch,athlon} |
42 | + |
43 | run_configure_if_required |
44 | make_target 'rpm' |
45 | |
46 | @@ -1507,6 +1502,9 @@ |
47 | |
48 | execute_job () |
49 | { |
50 | + # We should always have a target by this point |
51 | + assert MAKE_TARGET |
52 | + |
53 | determine_target_platform |
54 | |
55 | determine_vcs |
56 | @@ -1518,10 +1516,6 @@ |
57 | return 1 |
58 | fi |
59 | |
60 | - if [ -z "$MAKE_TARGET" ]; then |
61 | - MAKE_TARGET="make_default" |
62 | - fi |
63 | - |
64 | if $print_setup_opt -o $debug; then |
65 | echo |
66 | print_setup |
67 | @@ -1541,9 +1535,6 @@ |
68 | PREFIX_ARG="--prefix=$PREFIX" |
69 | fi |
70 | |
71 | - # We should always have a target by this point |
72 | - assert MAKE_TARGET |
73 | - |
74 | if $CLEAN_OPTION; then |
75 | make_maintainer_clean |
76 | fi |
77 | @@ -1762,6 +1753,13 @@ |
78 | fi |
79 | fi |
80 | |
81 | + if [ -z "$MAKE_TARGET" ]; then |
82 | + MAKE_TARGET="make_default" |
83 | + fi |
84 | + |
85 | + # We should always have a target by this point |
86 | + assert MAKE_TARGET |
87 | + |
88 | execute_job |
89 | local ret=$? |
90 | |
91 | |
92 | === modified file 'clients/generator.cc' |
93 | --- clients/generator.cc 2013-01-08 01:03:28 +0000 |
94 | +++ clients/generator.cc 2013-10-11 12:20:38 +0000 |
95 | @@ -22,6 +22,8 @@ |
96 | |
97 | #include "clients/generator.h" |
98 | |
99 | +#define KEY_BYTES 20 |
100 | + |
101 | /* Use this for string generation */ |
102 | static const char ALPHANUMERICS[]= |
103 | "0123456789ABCDEFGHIJKLMNOPQRSTWXYZabcdefghijklmnopqrstuvwxyz"; |
104 | @@ -75,13 +77,13 @@ |
105 | |
106 | for (uint64_t x= 0; x < number_of; x++) |
107 | { |
108 | - pairs[x].key= (char *)calloc(100, sizeof(char)); |
109 | + pairs[x].key= (char *)calloc(KEY_BYTES, sizeof(char)); |
110 | |
111 | if (pairs[x].key == NULL) |
112 | goto error; |
113 | |
114 | - get_random_string(pairs[x].key, 100); |
115 | - pairs[x].key_length= 100; |
116 | + get_random_string(pairs[x].key, KEY_BYTES); |
117 | + pairs[x].key_length= KEY_BYTES; |
118 | |
119 | if (value_length) |
120 | { |
121 | |
122 | === modified file 'clients/memcp.cc' |
123 | --- clients/memcp.cc 2013-06-11 12:31:47 +0000 |
124 | +++ clients/memcp.cc 2013-10-11 12:20:38 +0000 |
125 | @@ -1,5 +1,5 @@ |
126 | /* LibMemcached |
127 | - * Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/ |
128 | + * Copyright (C) 2011-2013 Data Differential, http://datadifferential.com/ |
129 | * Copyright (C) 2006-2009 Brian Aker |
130 | * All rights reserved. |
131 | * |
132 | |
133 | === modified file 'clients/memslap.cc' |
134 | --- clients/memslap.cc 2013-04-03 13:14:23 +0000 |
135 | +++ clients/memslap.cc 2013-10-11 12:20:38 +0000 |
136 | @@ -66,6 +66,8 @@ |
137 | #define DEFAULT_EXECUTE_NUMBER 10000 |
138 | #define DEFAULT_CONCURRENCY 1 |
139 | |
140 | +#define VALUE_BYTES 4096 |
141 | + |
142 | #define PROGRAM_NAME "memslap" |
143 | #define PROGRAM_DESCRIPTION "Generates a load against a memcached custer of servers." |
144 | |
145 | @@ -336,7 +338,7 @@ |
146 | |
147 | if (opt_test == SET_TEST) |
148 | { |
149 | - context->execute_pairs= pairs_generate(opt_execute_number, 400); |
150 | + context->execute_pairs= pairs_generate(opt_execute_number, VALUE_BYTES); |
151 | context->execute_number= opt_execute_number; |
152 | } |
153 | |
154 | @@ -432,7 +434,7 @@ |
155 | break; |
156 | |
157 | case OPT_DEBUG: /* --debug or -d */ |
158 | - opt_verbose = OPT_DEBUG; |
159 | + opt_verbose= OPT_DEBUG; |
160 | break; |
161 | |
162 | case OPT_VERSION: /* --version or -V */ |
163 | @@ -566,7 +568,7 @@ |
164 | /* We always used non-blocking IO for load since it is faster */ |
165 | memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NO_BLOCK, 0); |
166 | |
167 | - pairs_st *pairs= pairs_generate(number_of, 400); |
168 | + pairs_st *pairs= pairs_generate(number_of, VALUE_BYTES); |
169 | *actual_loaded= execute_set(memc_clone, pairs, number_of); |
170 | |
171 | memcached_free(memc_clone); |
172 | |
173 | === modified file 'clients/memtouch.cc' |
174 | --- clients/memtouch.cc 2013-06-11 12:31:47 +0000 |
175 | +++ clients/memtouch.cc 2013-10-11 12:20:38 +0000 |
176 | @@ -24,7 +24,7 @@ |
177 | #include "clients/utilities.h" |
178 | |
179 | #define PROGRAM_NAME "memtouch" |
180 | -#define PROGRAM_DESCRIPTION "Update the expiration value of an alreasy existing value in the sever" |
181 | +#define PROGRAM_DESCRIPTION "Update the expiration value of an already existing value in the server" |
182 | |
183 | |
184 | /* Prototypes */ |
185 | |
186 | === modified file 'clients/ms_setting.h' |
187 | --- clients/ms_setting.h 2012-07-10 20:34:40 +0000 |
188 | +++ clients/ms_setting.h 2013-10-11 12:20:38 +0000 |
189 | @@ -47,7 +47,7 @@ |
190 | #define MAX_TOKENS 10 |
191 | |
192 | /* server information */ |
193 | -typedef struct mcd_sever |
194 | +typedef struct mcd_server |
195 | { |
196 | char srv_host_name[MCD_HOST_LENGTH]; /* host name of server */ |
197 | int srv_port; /* server port */ |
198 | |
199 | === modified file 'docs/memcached_auto.rst' |
200 | --- docs/memcached_auto.rst 2012-03-08 07:13:01 +0000 |
201 | +++ docs/memcached_auto.rst 2013-10-11 12:20:38 +0000 |
202 | @@ -53,7 +53,8 @@ |
203 | expiration values, the operation will succeed by seeding the value for that |
204 | key with a initial value to expire with the provided expiration time. The |
205 | flags will be set to zero.The value is then returned via the uint32_t |
206 | -value pointer you pass to it. |
207 | +value pointer you pass to it. memcached_increment_with_initial is only available |
208 | +when using the binary protocol. |
209 | |
210 | memcached_decrement_with_initial takes a key and keylength and decrements |
211 | the value by the offset passed to it. If the object specified by key does |
212 | @@ -62,7 +63,8 @@ |
213 | expiration values, the operation will succeed by seeding the value for that |
214 | key with a initial value to expire with the provided expiration time. The |
215 | flags will be set to zero.The value is then returned via the uint32_t |
216 | -value pointer you pass to it. |
217 | +value pointer you pass to it. memcached_decrement_with_initial is only available |
218 | +when using the binary protocol. |
219 | |
220 | :c:func:`memcached_increment_by_key`, :c:func:`memcached_decrement_by_key`, |
221 | :c:func:`memcached_increment_with_initial_by_key`, and |
222 | |
223 | === modified file 'libmemcached-1.2/deprecated_types.h' |
224 | --- libmemcached-1.2/deprecated_types.h 2011-12-12 16:59:07 +0000 |
225 | +++ libmemcached-1.2/deprecated_types.h 2013-10-11 12:20:38 +0000 |
226 | @@ -57,4 +57,5 @@ |
227 | typedef memcached_trigger_key_fn memcached_trigger_key; |
228 | typedef memcached_trigger_delete_key_fn memcached_trigger_delete_key; |
229 | typedef memcached_dump_fn memcached_dump_func; |
230 | +typedef memcached_instance_st *memcached_server_instance_st; |
231 | |
232 | |
233 | === modified file 'libmemcached/auto.cc' |
234 | --- libmemcached/auto.cc 2013-04-03 13:14:23 +0000 |
235 | +++ libmemcached/auto.cc 2013-10-11 12:20:38 +0000 |
236 | @@ -57,8 +57,13 @@ |
237 | assert(memcached_last_error(instance->root) != MEMCACHED_SUCCESS); |
238 | *value= UINT64_MAX; |
239 | } |
240 | + else if (memcached_failed(rc)) |
241 | + { |
242 | + *value= UINT64_MAX; |
243 | + } |
244 | else |
245 | { |
246 | + assert(memcached_last_error(instance->root) != MEMCACHED_NOTFOUND); |
247 | *value= instance->root->result.impl()->numeric_value; |
248 | } |
249 | } |
250 | |
251 | === modified file 'libmemcached/connect.cc' |
252 | --- libmemcached/connect.cc 2013-06-12 08:17:31 +0000 |
253 | +++ libmemcached/connect.cc 2013-10-11 12:20:38 +0000 |
254 | @@ -76,7 +76,7 @@ |
255 | if (server->root->poll_timeout == 0) |
256 | { |
257 | return memcached_set_error(*server, MEMCACHED_TIMEOUT, MEMCACHED_AT, |
258 | - memcached_literal_param("The time to wait for a connection to be established was set to zero, which means it will always timeout (MEMCACHED_TIMEOUT).")); |
259 | + memcached_literal_param("The time to wait for a connection to be established was set to zero which produces a timeout to every call to poll().")); |
260 | } |
261 | |
262 | while (--loop_max) // Should only loop on cases of ERESTART or EINTR |
263 | |
264 | === modified file 'libmemcached/error.cc' |
265 | --- libmemcached/error.cc 2013-03-31 23:24:29 +0000 |
266 | +++ libmemcached/error.cc 2013-10-11 12:20:38 +0000 |
267 | @@ -36,6 +36,9 @@ |
268 | */ |
269 | |
270 | #include <libmemcached/common.h> |
271 | + |
272 | +#include "libmemcached/assert.hpp" |
273 | + |
274 | #include <cerrno> |
275 | #include <cstdarg> |
276 | #include <cstdio> |
277 | @@ -87,111 +90,133 @@ |
278 | memcached_error_free(memc); |
279 | } |
280 | |
281 | - // For memory allocation we use our error since it is a bit more specific |
282 | - if (local_errno == ENOMEM and rc == MEMCACHED_ERRNO) |
283 | - { |
284 | - rc= MEMCACHED_MEMORY_ALLOCATION_FAILURE; |
285 | - } |
286 | - |
287 | - if (rc == MEMCACHED_MEMORY_ALLOCATION_FAILURE) |
288 | - { |
289 | - local_errno= ENOMEM; |
290 | - } |
291 | - |
292 | - if (rc == MEMCACHED_ERRNO and not local_errno) |
293 | - { |
294 | - local_errno= errno; |
295 | - rc= MEMCACHED_ERRNO; |
296 | - } |
297 | - |
298 | - if (rc == MEMCACHED_ERRNO and local_errno == ENOTCONN) |
299 | - { |
300 | - rc= MEMCACHED_CONNECTION_FAILURE; |
301 | - } |
302 | - |
303 | - if (rc == MEMCACHED_ERRNO and local_errno == ECONNRESET) |
304 | - { |
305 | - rc= MEMCACHED_CONNECTION_FAILURE; |
306 | - } |
307 | - |
308 | - if (local_errno == EINVAL) |
309 | - { |
310 | - rc= MEMCACHED_INVALID_ARGUMENTS; |
311 | - } |
312 | - |
313 | - if (local_errno == ECONNREFUSED) |
314 | - { |
315 | - rc= MEMCACHED_CONNECTION_FAILURE; |
316 | - } |
317 | - |
318 | - memcached_error_t *error= libmemcached_xmalloc(&memc, memcached_error_t); |
319 | - if (error == NULL) // Bad business if this happens |
320 | - { |
321 | - return; |
322 | - } |
323 | - |
324 | - error->root= &memc; |
325 | - error->query_id= memc.query_id; |
326 | - error->rc= rc; |
327 | - error->local_errno= local_errno; |
328 | - |
329 | - const char *errmsg_ptr; |
330 | - char errmsg[MAX_ERROR_LENGTH]; |
331 | - errmsg[0]= 0; |
332 | - errmsg_ptr= errmsg; |
333 | - |
334 | - if (local_errno) |
335 | - { |
336 | + if (memcached_fatal(rc) or rc == MEMCACHED_CLIENT_ERROR) |
337 | + { |
338 | + // For memory allocation we use our error since it is a bit more specific |
339 | + if (local_errno == ENOMEM and rc == MEMCACHED_ERRNO) |
340 | + { |
341 | + rc= MEMCACHED_MEMORY_ALLOCATION_FAILURE; |
342 | + } |
343 | + |
344 | + if (rc == MEMCACHED_MEMORY_ALLOCATION_FAILURE) |
345 | + { |
346 | + local_errno= ENOMEM; |
347 | + } |
348 | + |
349 | + if (rc == MEMCACHED_ERRNO and not local_errno) |
350 | + { |
351 | + local_errno= errno; |
352 | + rc= MEMCACHED_ERRNO; |
353 | + } |
354 | + |
355 | + if (rc == MEMCACHED_ERRNO and local_errno == ENOTCONN) |
356 | + { |
357 | + rc= MEMCACHED_CONNECTION_FAILURE; |
358 | + } |
359 | + |
360 | + if (rc == MEMCACHED_ERRNO and local_errno == ECONNRESET) |
361 | + { |
362 | + rc= MEMCACHED_CONNECTION_FAILURE; |
363 | + } |
364 | + |
365 | + if (local_errno == EINVAL) |
366 | + { |
367 | + rc= MEMCACHED_INVALID_ARGUMENTS; |
368 | + } |
369 | + |
370 | + if (local_errno == ECONNREFUSED) |
371 | + { |
372 | + rc= MEMCACHED_CONNECTION_FAILURE; |
373 | + } |
374 | + |
375 | + if (rc == MEMCACHED_TIMEOUT) |
376 | + { |
377 | + } |
378 | + |
379 | + memcached_error_t *error= libmemcached_xmalloc(&memc, memcached_error_t); |
380 | + if (error == NULL) // Bad business if this happens |
381 | + { |
382 | + assert_msg(error, "libmemcached_xmalloc() failed to allocate a memcached_error_t"); |
383 | + return; |
384 | + } |
385 | + |
386 | + error->root= &memc; |
387 | + error->query_id= memc.query_id; |
388 | + error->rc= rc; |
389 | + error->local_errno= local_errno; |
390 | + |
391 | + // MEMCACHED_CLIENT_ERROR is a special case because it is an error coming from the server |
392 | + if (rc == MEMCACHED_CLIENT_ERROR) |
393 | + { |
394 | + assert(str); |
395 | + assert(str->size); |
396 | + if (str and str->size) |
397 | + { |
398 | + assert(error->local_errno == 0); |
399 | + error->local_errno= 0; |
400 | + |
401 | + error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %.*s", |
402 | + error->root, |
403 | + int(str->size), str->c_str); |
404 | + } |
405 | + } |
406 | + else if (local_errno) |
407 | + { |
408 | + const char *errmsg_ptr; |
409 | + char errmsg[MAX_ERROR_LENGTH]; |
410 | + errmsg[0]= 0; |
411 | + errmsg_ptr= errmsg; |
412 | + |
413 | #if defined(STRERROR_R_CHAR_P) && STRERROR_R_CHAR_P |
414 | - errmsg_ptr= strerror_r(local_errno, errmsg, sizeof(errmsg)); |
415 | + errmsg_ptr= strerror_r(local_errno, errmsg, sizeof(errmsg)); |
416 | #elif defined(HAVE_STRERROR_R) && HAVE_STRERROR_R |
417 | - strerror_r(local_errno, errmsg, sizeof(errmsg)); |
418 | - errmsg_ptr= errmsg; |
419 | + strerror_r(local_errno, errmsg, sizeof(errmsg)); |
420 | + errmsg_ptr= errmsg; |
421 | #elif defined(HAVE_STRERROR) && HAVE_STRERROR |
422 | - snprintf(errmsg, sizeof(errmsg), "%s", strerror(local_errno)); |
423 | - errmsg_ptr= errmsg; |
424 | + snprintf(errmsg, sizeof(errmsg), "%s", strerror(local_errno)); |
425 | + errmsg_ptr= errmsg; |
426 | #endif |
427 | - } |
428 | - |
429 | - |
430 | - if (str and str->size and local_errno) |
431 | - { |
432 | - error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s(%s), %.*s -> %s", |
433 | - error->root, |
434 | - memcached_strerror(&memc, rc), |
435 | - errmsg_ptr, |
436 | - memcached_string_printf(*str), at); |
437 | - } |
438 | - else if (local_errno) |
439 | - { |
440 | - error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s(%s) -> %s", |
441 | - error->root, |
442 | - memcached_strerror(&memc, rc), |
443 | - errmsg_ptr, |
444 | - at); |
445 | - } |
446 | - else if (rc == MEMCACHED_PARSE_ERROR and str and str->size) |
447 | - { |
448 | - error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %.*s -> %s", |
449 | - error->root, |
450 | - int(str->size), str->c_str, at); |
451 | - } |
452 | - else if (str and str->size) |
453 | - { |
454 | - error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s, %.*s -> %s", |
455 | - error->root, |
456 | - memcached_strerror(&memc, rc), |
457 | - int(str->size), str->c_str, at); |
458 | - } |
459 | - else |
460 | - { |
461 | - error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s -> %s", |
462 | - error->root, |
463 | - memcached_strerror(&memc, rc), at); |
464 | - } |
465 | - |
466 | - error->next= memc.error_messages; |
467 | - memc.error_messages= error; |
468 | + |
469 | + if (str and str->size and local_errno) |
470 | + { |
471 | + error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s(%s), %.*s -> %s", |
472 | + error->root, |
473 | + memcached_strerror(&memc, rc), |
474 | + errmsg_ptr, |
475 | + memcached_string_printf(*str), at); |
476 | + } |
477 | + else |
478 | + { |
479 | + error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s(%s) -> %s", |
480 | + error->root, |
481 | + memcached_strerror(&memc, rc), |
482 | + errmsg_ptr, |
483 | + at); |
484 | + } |
485 | + } |
486 | + else if (rc == MEMCACHED_PARSE_ERROR and str and str->size) |
487 | + { |
488 | + error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %.*s -> %s", |
489 | + error->root, |
490 | + int(str->size), str->c_str, at); |
491 | + } |
492 | + else if (str and str->size) |
493 | + { |
494 | + error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s, %.*s -> %s", |
495 | + error->root, |
496 | + memcached_strerror(&memc, rc), |
497 | + int(str->size), str->c_str, at); |
498 | + } |
499 | + else |
500 | + { |
501 | + error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s -> %s", |
502 | + error->root, |
503 | + memcached_strerror(&memc, rc), at); |
504 | + } |
505 | + |
506 | + error->next= memc.error_messages; |
507 | + memc.error_messages= error; |
508 | + } |
509 | |
510 | #if 0 |
511 | if (error_log_fd == -1) |
512 | @@ -231,13 +256,11 @@ |
513 | memcached_return_t memcached_set_error(Memcached& memc, memcached_return_t rc, const char *at, memcached_string_t& str) |
514 | { |
515 | assert_msg(rc != MEMCACHED_ERRNO, "Programmer error, MEMCACHED_ERRNO was set to be returned to client"); |
516 | - if (memcached_fatal(rc) == false) |
517 | + if (memcached_fatal(rc)) |
518 | { |
519 | - return rc; |
520 | + _set(memc, &str, rc, at); |
521 | } |
522 | |
523 | - _set(memc, &str, rc, at); |
524 | - |
525 | return rc; |
526 | } |
527 | |
528 | @@ -299,17 +322,15 @@ |
529 | memcached_string_t error_host= { hostname_port_message, size_t(size) }; |
530 | |
531 | assert_msg(self.root, "Programmer error, root was not set on instance"); |
532 | - if (self.root == NULL) |
533 | + if (self.root) |
534 | { |
535 | - return rc; |
536 | + _set(*self.root, &error_host, rc, at); |
537 | + _set(self, (*self.root)); |
538 | + assert(self.error_messages); |
539 | + assert(self.root->error_messages); |
540 | + assert(self.error_messages->rc == self.root->error_messages->rc); |
541 | } |
542 | |
543 | - _set(*self.root, &error_host, rc, at); |
544 | - _set(self, (*self.root)); |
545 | - assert(self.root->error_messages); |
546 | - assert(self.error_messages); |
547 | - assert(self.error_messages->rc == self.root->error_messages->rc); |
548 | - |
549 | return rc; |
550 | } |
551 | |
552 | @@ -326,14 +347,12 @@ |
553 | |
554 | memcached_string_t error_host= { hostname_port, size}; |
555 | |
556 | - if (self.root == NULL) |
557 | + if (self.root) |
558 | { |
559 | - return rc; |
560 | + _set(*self.root, &error_host, rc, at); |
561 | + _set(self, *self.root); |
562 | } |
563 | |
564 | - _set(*self.root, &error_host, rc, at); |
565 | - _set(self, *self.root); |
566 | - |
567 | return rc; |
568 | } |
569 | |
570 | @@ -528,7 +547,7 @@ |
571 | { |
572 | if (memc->error_messages) |
573 | { |
574 | - if (memc->error_messages->size == 0) |
575 | + if (memc->error_messages->size and memc->error_messages->message[0]) |
576 | { |
577 | return memc->error_messages->message; |
578 | } |
579 | |
580 | === modified file 'libmemcached/get.cc' |
581 | --- libmemcached/get.cc 2013-04-03 13:14:23 +0000 |
582 | +++ libmemcached/get.cc 2013-10-11 12:20:38 +0000 |
583 | @@ -114,7 +114,6 @@ |
584 | { |
585 | *error= MEMCACHED_NOTFOUND; |
586 | } |
587 | - |
588 | if (value == NULL) |
589 | { |
590 | if (ptr->get_key_failure and *error == MEMCACHED_NOTFOUND) |
591 | @@ -221,12 +220,14 @@ |
592 | |
593 | if (number_of_keys == 0) |
594 | { |
595 | - return memcached_set_error(*ptr, MEMCACHED_NOTFOUND, MEMCACHED_AT, memcached_literal_param("number_of_keys was zero")); |
596 | + return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Numbers of keys provided was zero")); |
597 | } |
598 | |
599 | - if (memcached_failed(memcached_key_test(*ptr, keys, key_length, number_of_keys))) |
600 | + if (memcached_failed((rc= memcached_key_test(*ptr, keys, key_length, number_of_keys)))) |
601 | { |
602 | - return memcached_last_error(ptr); |
603 | + assert(memcached_last_error(ptr) == rc); |
604 | + |
605 | + return rc; |
606 | } |
607 | |
608 | bool is_group_key_set= false; |
609 | @@ -463,6 +464,11 @@ |
610 | |
611 | bool flush= (number_of_keys == 1); |
612 | |
613 | + if (memcached_failed(rc= memcached_key_test(*ptr, keys, key_length, number_of_keys))) |
614 | + { |
615 | + return rc; |
616 | + } |
617 | + |
618 | /* |
619 | If a server fails we warn about errors and start all over with sending keys |
620 | to the server. |
621 | @@ -502,10 +508,13 @@ |
622 | request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETK; |
623 | } |
624 | |
625 | +#if 0 |
626 | { |
627 | memcached_return_t vk= memcached_validate_key_length(key_length[x], ptr->flags.binary_protocol); |
628 | - if (vk != MEMCACHED_SUCCESS) |
629 | + if (memcached_failed(rc= memcached_key_test(*memc, (const char **)&key, &key_length, 1))) |
630 | { |
631 | + memcached_set_error(ptr, vk, MEMCACHED_AT, memcached_literal_param("Key was too long.")); |
632 | + |
633 | if (x > 0) |
634 | { |
635 | memcached_io_reset(instance); |
636 | @@ -514,6 +523,7 @@ |
637 | return vk; |
638 | } |
639 | } |
640 | +#endif |
641 | |
642 | request.message.header.request.keylen= htons((uint16_t)(key_length[x] + memcached_array_size(ptr->_namespace))); |
643 | request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; |
644 | |
645 | === modified file 'libmemcached/io.cc' |
646 | --- libmemcached/io.cc 2013-03-31 23:24:29 +0000 |
647 | +++ libmemcached/io.cc 2013-10-11 12:20:38 +0000 |
648 | @@ -99,7 +99,7 @@ |
649 | case EWOULDBLOCK: |
650 | #endif |
651 | case EAGAIN: |
652 | -#ifdef TARGET_OS_LINUX |
653 | +#ifdef __linux |
654 | case ERESTART: |
655 | #endif |
656 | break; // No IO is fine, we can just move on |
657 | @@ -265,7 +265,7 @@ |
658 | assert_msg(active_fd == -1 , "poll() returned an unexpected value"); |
659 | switch (local_errno) |
660 | { |
661 | -#ifdef TARGET_OS_LINUX |
662 | +#ifdef __linux |
663 | case ERESTART: |
664 | #endif |
665 | case EINTR: |
666 | @@ -412,6 +412,11 @@ |
667 | return io_wait(instance, MEM_WRITE); |
668 | } |
669 | |
670 | +memcached_return_t memcached_io_wait_for_read(memcached_instance_st* instance) |
671 | +{ |
672 | + return io_wait(instance, MEM_READ); |
673 | +} |
674 | + |
675 | static memcached_return_t _io_fill(memcached_instance_st* instance) |
676 | { |
677 | ssize_t data_read; |
678 | @@ -430,7 +435,7 @@ |
679 | case EWOULDBLOCK: |
680 | #endif |
681 | case EAGAIN: |
682 | -#ifdef TARGET_OS_LINUX |
683 | +#ifdef __linux |
684 | case ERESTART: |
685 | #endif |
686 | { |
687 | @@ -568,7 +573,7 @@ |
688 | case EWOULDBLOCK: |
689 | #endif |
690 | case EAGAIN: |
691 | -#ifdef TARGET_OS_LINUX |
692 | +#ifdef __linux |
693 | case ERESTART: |
694 | #endif |
695 | if (memcached_success(io_wait(instance, MEM_READ))) |
696 | |
697 | === modified file 'libmemcached/io.hpp' |
698 | --- libmemcached/io.hpp 2013-03-31 23:24:29 +0000 |
699 | +++ libmemcached/io.hpp 2013-10-11 12:20:38 +0000 |
700 | @@ -49,7 +49,8 @@ |
701 | libmemcached_io_vector_st vector[], |
702 | const size_t number_of, const bool with_flush); |
703 | |
704 | -memcached_return_t memcached_io_wait_for_write(memcached_instance_st* ptr); |
705 | +memcached_return_t memcached_io_wait_for_write(memcached_instance_st*); |
706 | +memcached_return_t memcached_io_wait_for_read(memcached_instance_st*); |
707 | |
708 | void memcached_io_reset(memcached_instance_st* ptr); |
709 | |
710 | |
711 | === modified file 'libmemcached/key.cc' |
712 | --- libmemcached/key.cc 2012-02-13 20:14:15 +0000 |
713 | +++ libmemcached/key.cc 2013-10-11 12:20:38 +0000 |
714 | @@ -37,47 +37,71 @@ |
715 | |
716 | #include <libmemcached/common.h> |
717 | |
718 | +static inline memcached_return_t memcached_validate_key_length(size_t key_length, bool) |
719 | +{ |
720 | + if (key_length == 0) |
721 | + { |
722 | + return MEMCACHED_BAD_KEY_PROVIDED; |
723 | + } |
724 | + |
725 | + // No one ever reimplemented MEMCACHED to use keys longer then the original ascii length |
726 | +#if 0 |
727 | + if (binary) |
728 | + { |
729 | + if (key_length > 0xffff) |
730 | + { |
731 | + return MEMCACHED_BAD_KEY_PROVIDED; |
732 | + } |
733 | + } |
734 | + else |
735 | +#endif |
736 | + { |
737 | + if (key_length >= MEMCACHED_MAX_KEY) |
738 | + { |
739 | + return MEMCACHED_BAD_KEY_PROVIDED; |
740 | + } |
741 | + } |
742 | + |
743 | + return MEMCACHED_SUCCESS; |
744 | +} |
745 | + |
746 | memcached_return_t memcached_key_test(memcached_st &memc, |
747 | const char * const *keys, |
748 | const size_t *key_length, |
749 | size_t number_of_keys) |
750 | { |
751 | + if (number_of_keys == 0) |
752 | + { |
753 | + return memcached_set_error(memc, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Numbers of keys provided was zero")); |
754 | + } |
755 | + |
756 | if (keys == NULL or key_length == NULL) |
757 | { |
758 | return memcached_set_error(memc, MEMCACHED_BAD_KEY_PROVIDED, MEMCACHED_AT, memcached_literal_param("Key was NULL or length of key was zero.")); |
759 | } |
760 | |
761 | + const bool is_binary= memcached_flag(memc, MEMCACHED_FLAG_BINARY_PROTOCOL); |
762 | + |
763 | // If we don't need to verify the key, or we are using the binary protoocol, |
764 | // we just check the size of the key |
765 | - if (memc.flags.verify_key == false or memc.flags.binary_protocol == true) |
766 | - { |
767 | - for (size_t x= 0; x < number_of_keys; x++) |
768 | - { |
769 | - // We should set binary key, but the memcached server is broken for |
770 | - // longer keys at the moment. |
771 | - memcached_return_t rc= memcached_validate_key_length(*(key_length +x), false /* memc.flags.binary_protocol */); |
772 | - if (memcached_failed(rc)) |
773 | - { |
774 | - return memcached_set_error(memc, rc, MEMCACHED_AT, memcached_literal_param("Key provided was too long.")); |
775 | - } |
776 | - } |
777 | - |
778 | - return MEMCACHED_SUCCESS; |
779 | - } |
780 | - |
781 | - for (size_t x= 0; x < number_of_keys; x++) |
782 | - { |
783 | - memcached_return_t rc= memcached_validate_key_length(*(key_length + x), false); |
784 | + for (size_t x= 0; x < number_of_keys; ++x) |
785 | + { |
786 | + // We should set binary key, but the memcached server is broken for |
787 | + // longer keys at the moment. |
788 | + memcached_return_t rc= memcached_validate_key_length(*(key_length +x), false /* memc.flags.binary_protocol */); |
789 | if (memcached_failed(rc)) |
790 | { |
791 | return memcached_set_error(memc, rc, MEMCACHED_AT, memcached_literal_param("Key provided was too long.")); |
792 | } |
793 | - |
794 | - for (size_t y= 0; y < *(key_length + x); y++) |
795 | + |
796 | + if (memc.flags.verify_key and is_binary == false) |
797 | { |
798 | - if ((isgraph(keys[x][y])) == 0) |
799 | + for (size_t y= 0; y < *(key_length +x); ++y) |
800 | { |
801 | - return memcached_set_error(memc, MEMCACHED_BAD_KEY_PROVIDED, MEMCACHED_AT, memcached_literal_param("Key provided had invalid character.")); |
802 | + if ((isgraph(keys[x][y])) == 0) |
803 | + { |
804 | + return memcached_set_error(memc, MEMCACHED_BAD_KEY_PROVIDED, MEMCACHED_AT, memcached_literal_param("Key provided had invalid character.")); |
805 | + } |
806 | } |
807 | } |
808 | } |
809 | |
810 | === modified file 'libmemcached/key.hpp' |
811 | --- libmemcached/key.hpp 2011-10-02 23:49:04 +0000 |
812 | +++ libmemcached/key.hpp 2013-10-11 12:20:38 +0000 |
813 | @@ -41,27 +41,3 @@ |
814 | const size_t *key_length, |
815 | size_t number_of_keys); |
816 | |
817 | -static inline memcached_return_t memcached_validate_key_length(size_t key_length, bool binary) |
818 | -{ |
819 | - if (key_length == 0) |
820 | - { |
821 | - return MEMCACHED_BAD_KEY_PROVIDED; |
822 | - } |
823 | - |
824 | - if (binary) |
825 | - { |
826 | - if (key_length > 0xffff) |
827 | - { |
828 | - return MEMCACHED_BAD_KEY_PROVIDED; |
829 | - } |
830 | - } |
831 | - else |
832 | - { |
833 | - if (key_length >= MEMCACHED_MAX_KEY) |
834 | - { |
835 | - return MEMCACHED_BAD_KEY_PROVIDED; |
836 | - } |
837 | - } |
838 | - |
839 | - return MEMCACHED_SUCCESS; |
840 | -} |
841 | |
842 | === modified file 'libmemcached/response.cc' |
843 | --- libmemcached/response.cc 2013-06-11 12:31:47 +0000 |
844 | +++ libmemcached/response.cc 2013-10-11 12:20:38 +0000 |
845 | @@ -503,6 +503,8 @@ |
846 | memcached_return_t rc; |
847 | protocol_binary_response_header header; |
848 | |
849 | + assert(memcached_is_binary(instance->root)); |
850 | + |
851 | if ((rc= memcached_safe_read(instance, &header.bytes, sizeof(header.bytes))) != MEMCACHED_SUCCESS) |
852 | { |
853 | WATCHPOINT_ERROR(rc); |
854 | @@ -894,12 +896,19 @@ |
855 | return memcached_set_error(*instance, MEMCACHED_NOT_SUPPORTED, MEMCACHED_AT); |
856 | } |
857 | |
858 | - /* We may have old commands in the buffer not set, first purge */ |
859 | + /* We may have old commands in the buffer not sent, first purge */ |
860 | if ((instance->root->flags.no_block) and (memcached_is_processing_input(instance->root) == false)) |
861 | { |
862 | (void)memcached_io_write(instance); |
863 | } |
864 | |
865 | + /* Before going into loop wait to see if we have any IO waiting for us */ |
866 | + if (0) |
867 | + { |
868 | + memcached_return_t read_rc= memcached_io_wait_for_read(instance); |
869 | + fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, memcached_strerror(NULL, read_rc)); |
870 | + } |
871 | + |
872 | /* |
873 | * The previous implementation purged all pending requests and just |
874 | * returned the last one. Purge all pending messages to ensure backwards |
875 | |
876 | === modified file 'libmemcached/stats.cc' |
877 | --- libmemcached/stats.cc 2013-03-31 23:24:29 +0000 |
878 | +++ libmemcached/stats.cc 2013-10-11 12:20:38 +0000 |
879 | @@ -346,7 +346,7 @@ |
880 | return MEMCACHED_SUCCESS; |
881 | } |
882 | |
883 | -char *memcached_stat_get_value(const memcached_st *, memcached_stat_st *memc_stat, |
884 | +char *memcached_stat_get_value(const memcached_st* shell, memcached_stat_st *memc_stat, |
885 | const char *key, memcached_return_t *error) |
886 | { |
887 | memcached_return_t not_used; |
888 | @@ -456,13 +456,15 @@ |
889 | } |
890 | else |
891 | { |
892 | - *error= MEMCACHED_NOTFOUND; |
893 | + Memcached* memc= (Memcached*)memcached2Memcached(shell); |
894 | + *error= memcached_set_error(*memc, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid key provided")); |
895 | return NULL; |
896 | } |
897 | |
898 | if (length >= SMALL_STRING_LEN || length < 0) |
899 | { |
900 | - *error= MEMCACHED_FAILURE; |
901 | + Memcached* memc= (Memcached*)memcached2Memcached(shell); |
902 | + *error= memcached_set_error(*memc, MEMCACHED_FAILURE, MEMCACHED_AT, memcached_literal_param("Internal failure occured with buffer, please report this bug.")); |
903 | return NULL; |
904 | } |
905 | |
906 | @@ -658,8 +660,7 @@ |
907 | if (args) |
908 | { |
909 | args_length= strlen(args); |
910 | - rc= memcached_validate_key_length(args_length, self->flags.binary_protocol); |
911 | - if (memcached_failed(rc)) |
912 | + if (memcached_failed(rc= memcached_key_test(*self, (const char **)&args, &args_length, 1))) |
913 | { |
914 | *error= memcached_set_error(*self, rc, MEMCACHED_AT); |
915 | return NULL; |
916 | @@ -746,7 +747,7 @@ |
917 | if (args) |
918 | { |
919 | args_length= strlen(args); |
920 | - rc= memcached_validate_key_length(args_length, memc.flags.binary_protocol); |
921 | + rc= memcached_key_test(*memc_ptr, (const char **)&args, &args_length, 1); |
922 | } |
923 | |
924 | if (memcached_success(rc)) |
925 | |
926 | === modified file 'libmemcached/string.cc' |
927 | --- libmemcached/string.cc 2013-01-23 21:28:45 +0000 |
928 | +++ libmemcached/string.cc 2013-10-11 12:20:38 +0000 |
929 | @@ -281,18 +281,20 @@ |
930 | { |
931 | char* value= NULL; |
932 | |
933 | - if (memcached_string_length(self)) |
934 | + assert_msg(self, "Invalid memcached_string_st"); |
935 | + if (self) |
936 | { |
937 | - assert_msg(self, "Invalid memcached_string_st"); |
938 | - // If we fail at adding the null, we copy and move on |
939 | - if (memcached_success(memcached_string_append_null(self))) |
940 | + if (memcached_string_length(self)) |
941 | { |
942 | - return memcached_string_c_copy(self); |
943 | + // If we fail at adding the null, we copy and move on |
944 | + if (memcached_failed(memcached_string_append_null(self))) |
945 | + { |
946 | + return NULL; |
947 | + } |
948 | + |
949 | + value= self->string; |
950 | + _init_string(self); |
951 | } |
952 | - |
953 | - value= self->string; |
954 | - |
955 | - _init_string(self); |
956 | } |
957 | |
958 | return value; |
959 | |
960 | === modified file 'libmemcached/touch.cc' |
961 | --- libmemcached/touch.cc 2013-03-31 23:24:29 +0000 |
962 | +++ libmemcached/touch.cc 2013-10-11 12:20:38 +0000 |
963 | @@ -124,9 +124,9 @@ |
964 | return rc; |
965 | } |
966 | |
967 | - if (memcached_failed(rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol))) |
968 | + if (memcached_failed(rc= memcached_key_test(*ptr, (const char **)&key, &key_length, 1))) |
969 | { |
970 | - return rc; |
971 | + return memcached_set_error(*ptr, rc, MEMCACHED_AT); |
972 | } |
973 | |
974 | uint32_t server_key= memcached_generate_hash_with_redistribution(ptr, group_key, group_key_length); |
975 | |
976 | === modified file 'libtest/cmdline.cc' |
977 | --- libtest/cmdline.cc 2013-06-12 07:11:22 +0000 |
978 | +++ libtest/cmdline.cc 2013-10-11 12:20:38 +0000 |
979 | @@ -359,7 +359,7 @@ |
980 | int error; |
981 | switch ((error= errno)) |
982 | { |
983 | -#ifdef TARGET_OS_LINUX |
984 | +#ifdef __linux |
985 | case ERESTART: |
986 | #endif |
987 | case EINTR: |
988 | |
989 | === modified file 'libtest/core.cc' |
990 | --- libtest/core.cc 2012-12-09 11:40:11 +0000 |
991 | +++ libtest/core.cc 2013-10-11 12:20:38 +0000 |
992 | @@ -42,8 +42,8 @@ |
993 | |
994 | void create_core(void) |
995 | { |
996 | -#if defined(TARGET_OS_OSX) && TARGET_OS_OSX |
997 | - if (TARGET_OS_OSX) |
998 | +#if defined(__APPLE__) && __APPLE__ |
999 | + if (__APPLE__) |
1000 | { |
1001 | return; |
1002 | } |
1003 | |
1004 | === modified file 'libtest/main.cc' |
1005 | --- libtest/main.cc 2013-06-12 07:11:22 +0000 |
1006 | +++ libtest/main.cc 2013-10-11 12:20:38 +0000 |
1007 | @@ -2,7 +2,7 @@ |
1008 | * |
1009 | * Data Differential YATL (i.e. libtest) library |
1010 | * |
1011 | - * Copyright (C) 2012 Data Differential, http://datadifferential.com/ |
1012 | + * Copyright (C) 2012-2013 Data Differential, http://datadifferential.com/ |
1013 | * |
1014 | * Redistribution and use in source and binary forms, with or without |
1015 | * modification, are permitted provided that the following conditions are |
1016 | @@ -43,8 +43,11 @@ |
1017 | #include <cstring> |
1018 | #include <ctime> |
1019 | #include <fnmatch.h> |
1020 | +#include <iostream> |
1021 | +#ifdef HAVE_STRINGS_H |
1022 | +# include <strings.h> |
1023 | +#endif |
1024 | #include <fstream> |
1025 | -#include <iostream> |
1026 | #include <memory> |
1027 | #include <sys/stat.h> |
1028 | #include <sys/time.h> |
1029 | @@ -113,7 +116,7 @@ |
1030 | Valgrind does not currently work reliably, or sometimes at all, on OSX |
1031 | - Fri Jun 15 11:24:07 EDT 2012 |
1032 | */ |
1033 | -#if defined(TARGET_OS_OSX) && TARGET_OS_OSX |
1034 | +#if defined(__APPLE__) && __APPLE__ |
1035 | if (valgrind_is_caller()) |
1036 | { |
1037 | return EXIT_SKIP; |
1038 | |
1039 | === modified file 'libtest/unittest.cc' |
1040 | --- libtest/unittest.cc 2013-06-12 07:11:22 +0000 |
1041 | +++ libtest/unittest.cc 2013-10-11 12:20:38 +0000 |
1042 | @@ -657,7 +657,7 @@ |
1043 | const char *args[]= { "--fubar", 0 }; |
1044 | #if defined(__APPLE__) && __APPLE__ |
1045 | ASSERT_EQ(Application::INVALID_POSIX_SPAWN, true_app.run(args)); |
1046 | -#elif defined(TARGET_OS_FREEBSD) && TARGET_OS_FREEBSD |
1047 | +#elif defined(__FreeBSD__) && __FreeBSD__ |
1048 | ASSERT_EQ(Application::INVALID_POSIX_SPAWN, true_app.run(args)); |
1049 | #else |
1050 | ASSERT_EQ(Application::SUCCESS, true_app.run(args)); |
1051 | @@ -855,8 +855,8 @@ |
1052 | static test_return_t gdb_wait_services_appliction_TEST(void *) |
1053 | { |
1054 | test_skip(true, false); |
1055 | -#if defined(TARGET_OS_OSX) && TARGET_OS_OSX |
1056 | - test_skip(0, TARGET_OS_OSX); |
1057 | +#if defined(__APPLE__) && __APPLE__ |
1058 | + test_skip(0, __APPLE__); |
1059 | #endif |
1060 | |
1061 | test_skip(0, access("/etc/services", R_OK )); |
1062 | @@ -879,8 +879,8 @@ |
1063 | test_skip(0, access("libtest/abort", X_OK )); |
1064 | test_skip(true, false); |
1065 | |
1066 | -#if defined(TARGET_OS_OSX) && TARGET_OS_OSX |
1067 | - test_skip(0, TARGET_OS_OSX); |
1068 | +#if defined(__APPLE__) && __APPLE__ |
1069 | + test_skip(0, __APPLE__); |
1070 | #endif |
1071 | |
1072 | libtest::Application abort_app("libtest/abort", true); |
1073 | |
1074 | === modified file 'm4/ax_debug.m4' |
1075 | --- m4/ax_debug.m4 2013-01-08 01:03:28 +0000 |
1076 | +++ m4/ax_debug.m4 2013-10-11 12:20:38 +0000 |
1077 | @@ -43,7 +43,7 @@ |
1078 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
1079 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
1080 | |
1081 | -#serial 5 |
1082 | +#serial 6 |
1083 | |
1084 | AC_DEFUN([AX_DEBUG], |
1085 | [AC_PREREQ([2.63])dnl |
1086 | @@ -52,7 +52,9 @@ |
1087 | [Add debug code/turns off optimizations (yes|no) @<:@default=no@:>@])], |
1088 | [ax_enable_debug=yes |
1089 | AC_DEFINE([DEBUG],[1],[Define to 1 to enable debugging code.]) |
1090 | - AX_CHECK_LIBRARY([MCHECK],[mcheck.h],[mcheck],[AX_APPEND_LINK_FLAGS([-lmcheck])])], |
1091 | + AX_CHECK_LIBRARY([MCHECK],[mcheck.h],[mcheck],[AX_APPEND_LINK_FLAGS([-lmcheck])]) |
1092 | + AX_ADD_AM_MACRO([--debug],[AM_YFLAGS]) |
1093 | + AX_ADD_AM_MACRO([-D_GLIBCXX_DEBUG],[AM_CPPFLAGS])], |
1094 | [ax_enable_debug=no |
1095 | AC_SUBST([MCHECK]) |
1096 | AC_DEFINE([DEBUG],[0],[Define to 1 to enable debugging code.])]) |
1097 | |
1098 | === modified file 'tests/cli.am' |
1099 | --- tests/cli.am 2013-05-03 20:00:36 +0000 |
1100 | +++ tests/cli.am 2013-10-11 12:20:38 +0000 |
1101 | @@ -122,3 +122,12 @@ |
1102 | |
1103 | valgrind-memtouch: tests/memtouch |
1104 | @$(VALGRIND_COMMAND) tests/memtouch |
1105 | + |
1106 | +test-memdump: tests/memdump |
1107 | + tests/memdump |
1108 | + |
1109 | +gdb-memdump: tests/memdump |
1110 | + @$(GDB_COMMAND) tests/memdump |
1111 | + |
1112 | +valgrind-memdump: tests/memdump |
1113 | + @$(VALGRIND_COMMAND) tests/memdump |
1114 | |
1115 | === modified file 'tests/libmemcached-1.0/all_tests.h' |
1116 | --- tests/libmemcached-1.0/all_tests.h 2013-02-23 21:43:42 +0000 |
1117 | +++ tests/libmemcached-1.0/all_tests.h 2013-10-11 12:20:38 +0000 |
1118 | @@ -70,9 +70,11 @@ |
1119 | {"partial mget", false, (test_callback_fn*)get_test5 }, |
1120 | {"stats_servername", false, (test_callback_fn*)stats_servername_test }, |
1121 | {"increment", false, (test_callback_fn*)increment_test }, |
1122 | - {"increment_with_initial", true, (test_callback_fn*)increment_with_initial_test }, |
1123 | + {"memcached_increment_with_initial(0)", true, (test_callback_fn*)increment_with_initial_test }, |
1124 | + {"memcached_increment_with_initial(999)", true, (test_callback_fn*)increment_with_initial_999_test }, |
1125 | {"decrement", false, (test_callback_fn*)decrement_test }, |
1126 | - {"decrement_with_initial", true, (test_callback_fn*)decrement_with_initial_test }, |
1127 | + {"memcached_decrement_with_initial(3)", true, (test_callback_fn*)decrement_with_initial_test }, |
1128 | + {"memcached_decrement_with_initial(999)", true, (test_callback_fn*)decrement_with_initial_999_test }, |
1129 | {"increment_by_key", false, (test_callback_fn*)increment_by_key_test }, |
1130 | {"increment_with_initial_by_key", true, (test_callback_fn*)increment_with_initial_by_key_test }, |
1131 | {"decrement_by_key", false, (test_callback_fn*)decrement_by_key_test }, |
1132 | |
1133 | === modified file 'tests/libmemcached-1.0/mem_functions.cc' |
1134 | --- tests/libmemcached-1.0/mem_functions.cc 2013-04-20 09:55:24 +0000 |
1135 | +++ tests/libmemcached-1.0/mem_functions.cc 2013-10-11 12:20:38 +0000 |
1136 | @@ -994,6 +994,7 @@ |
1137 | test_compare(MEMCACHED_SUCCESS, |
1138 | memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_VERIFY_KEY, true)); |
1139 | test_compare(query_id, memcached_query_id(memc_clone)); // We should not increase the query_id for memcached_behavior_set() |
1140 | + ASSERT_TRUE(memcached_behavior_get(memc_clone, MEMCACHED_BEHAVIOR_VERIFY_KEY)); |
1141 | |
1142 | /* All keys are valid in the binary protocol (except for length) */ |
1143 | if (memcached_behavior_get(memc_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == false) |
1144 | @@ -1295,24 +1296,39 @@ |
1145 | return TEST_SUCCESS; |
1146 | } |
1147 | |
1148 | +static test_return_t __increment_with_initial_test(memcached_st *memc, uint64_t initial) |
1149 | +{ |
1150 | + uint64_t new_number; |
1151 | + |
1152 | + test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc)); |
1153 | + |
1154 | + if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)) |
1155 | + { |
1156 | + test_compare(MEMCACHED_SUCCESS, |
1157 | + memcached_increment_with_initial(memc, test_literal_param("number"), 1, initial, 0, &new_number)); |
1158 | + test_compare(new_number, initial); |
1159 | + |
1160 | + test_compare(MEMCACHED_SUCCESS, |
1161 | + memcached_increment_with_initial(memc, test_literal_param("number"), 1, initial, 0, &new_number)); |
1162 | + test_compare(new_number, (initial +1)); |
1163 | + } |
1164 | + else |
1165 | + { |
1166 | + test_compare(MEMCACHED_INVALID_ARGUMENTS, |
1167 | + memcached_increment_with_initial(memc, test_literal_param("number"), 1, initial, 0, &new_number)); |
1168 | + } |
1169 | + |
1170 | + return TEST_SUCCESS; |
1171 | +} |
1172 | + |
1173 | test_return_t increment_with_initial_test(memcached_st *memc) |
1174 | { |
1175 | - test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); |
1176 | - |
1177 | - uint64_t new_number; |
1178 | - uint64_t initial= 0; |
1179 | - |
1180 | - test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc)); |
1181 | - |
1182 | - test_compare(MEMCACHED_SUCCESS, |
1183 | - memcached_increment_with_initial(memc, test_literal_param("number"), 1, initial, 0, &new_number)); |
1184 | - test_compare(new_number, initial); |
1185 | - |
1186 | - test_compare(MEMCACHED_SUCCESS, |
1187 | - memcached_increment_with_initial(memc, test_literal_param("number"), 1, initial, 0, &new_number)); |
1188 | - test_compare(new_number, (initial +1)); |
1189 | - |
1190 | - return TEST_SUCCESS; |
1191 | + return __increment_with_initial_test(memc, 0); |
1192 | +} |
1193 | + |
1194 | +test_return_t increment_with_initial_999_test(memcached_st *memc) |
1195 | +{ |
1196 | + return __increment_with_initial_test(memc, 999); |
1197 | } |
1198 | |
1199 | test_return_t decrement_test(memcached_st *memc) |
1200 | @@ -1342,30 +1358,38 @@ |
1201 | return TEST_SUCCESS; |
1202 | } |
1203 | |
1204 | +static test_return_t __decrement_with_initial_test(memcached_st *memc, uint64_t initial) |
1205 | +{ |
1206 | + test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); |
1207 | + |
1208 | + test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc)); |
1209 | + |
1210 | + uint64_t new_number; |
1211 | + test_compare(MEMCACHED_SUCCESS, |
1212 | + memcached_decrement_with_initial(memc, |
1213 | + test_literal_param(__func__), |
1214 | + 1, initial, |
1215 | + 0, &new_number)); |
1216 | + test_compare(new_number, initial); |
1217 | + |
1218 | + test_compare(MEMCACHED_SUCCESS, |
1219 | + memcached_decrement_with_initial(memc, |
1220 | + test_literal_param(__func__), |
1221 | + 1, initial, |
1222 | + 0, &new_number)); |
1223 | + test_compare(new_number, (initial - 1)); |
1224 | + |
1225 | + return TEST_SUCCESS; |
1226 | +} |
1227 | + |
1228 | test_return_t decrement_with_initial_test(memcached_st *memc) |
1229 | { |
1230 | - test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); |
1231 | - |
1232 | - uint64_t initial= 3; |
1233 | - |
1234 | - test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc)); |
1235 | - |
1236 | - uint64_t new_number; |
1237 | - test_compare(MEMCACHED_SUCCESS, |
1238 | - memcached_decrement_with_initial(memc, |
1239 | - test_literal_param(__func__), |
1240 | - 1, initial, |
1241 | - 0, &new_number)); |
1242 | - test_compare(new_number, initial); |
1243 | - |
1244 | - test_compare(MEMCACHED_SUCCESS, |
1245 | - memcached_decrement_with_initial(memc, |
1246 | - test_literal_param(__func__), |
1247 | - 1, initial, |
1248 | - 0, &new_number)); |
1249 | - test_compare(new_number, (initial - 1)); |
1250 | - |
1251 | - return TEST_SUCCESS; |
1252 | + return __decrement_with_initial_test(memc, 3); |
1253 | +} |
1254 | + |
1255 | +test_return_t decrement_with_initial_999_test(memcached_st *memc) |
1256 | +{ |
1257 | + return __decrement_with_initial_test(memc, 999); |
1258 | } |
1259 | |
1260 | test_return_t increment_by_key_test(memcached_st *memc) |
1261 | @@ -1399,24 +1423,32 @@ |
1262 | |
1263 | test_return_t increment_with_initial_by_key_test(memcached_st *memc) |
1264 | { |
1265 | - test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); |
1266 | - |
1267 | uint64_t new_number; |
1268 | const char *master_key= "foo"; |
1269 | const char *key= "number"; |
1270 | uint64_t initial= 0; |
1271 | |
1272 | - test_compare(MEMCACHED_SUCCESS, |
1273 | - memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key), |
1274 | - key, strlen(key), |
1275 | - 1, initial, 0, &new_number)); |
1276 | - test_compare(new_number, initial); |
1277 | + if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)) |
1278 | + { |
1279 | + test_compare(MEMCACHED_SUCCESS, |
1280 | + memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key), |
1281 | + key, strlen(key), |
1282 | + 1, initial, 0, &new_number)); |
1283 | + test_compare(new_number, initial); |
1284 | |
1285 | - test_compare(MEMCACHED_SUCCESS, |
1286 | - memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key), |
1287 | - key, strlen(key), |
1288 | - 1, initial, 0, &new_number)); |
1289 | - test_compare(new_number, (initial +1)); |
1290 | + test_compare(MEMCACHED_SUCCESS, |
1291 | + memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key), |
1292 | + key, strlen(key), |
1293 | + 1, initial, 0, &new_number)); |
1294 | + test_compare(new_number, (initial +1)); |
1295 | + } |
1296 | + else |
1297 | + { |
1298 | + test_compare(MEMCACHED_INVALID_ARGUMENTS, |
1299 | + memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key), |
1300 | + key, strlen(key), |
1301 | + 1, initial, 0, &new_number)); |
1302 | + } |
1303 | |
1304 | return TEST_SUCCESS; |
1305 | } |
1306 | @@ -1457,19 +1489,30 @@ |
1307 | uint64_t new_number; |
1308 | uint64_t initial= 3; |
1309 | |
1310 | - test_compare(MEMCACHED_SUCCESS, |
1311 | - memcached_decrement_with_initial_by_key(memc, |
1312 | - test_literal_param("foo"), |
1313 | - test_literal_param("number"), |
1314 | - 1, initial, 0, &new_number)); |
1315 | - test_compare(new_number, initial); |
1316 | + if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)) |
1317 | + { |
1318 | + test_compare(MEMCACHED_SUCCESS, |
1319 | + memcached_decrement_with_initial_by_key(memc, |
1320 | + test_literal_param("foo"), |
1321 | + test_literal_param("number"), |
1322 | + 1, initial, 0, &new_number)); |
1323 | + test_compare(new_number, initial); |
1324 | |
1325 | - test_compare(MEMCACHED_SUCCESS, |
1326 | - memcached_decrement_with_initial_by_key(memc, |
1327 | - test_literal_param("foo"), |
1328 | - test_literal_param("number"), |
1329 | - 1, initial, 0, &new_number)); |
1330 | - test_compare(new_number, (initial - 1)); |
1331 | + test_compare(MEMCACHED_SUCCESS, |
1332 | + memcached_decrement_with_initial_by_key(memc, |
1333 | + test_literal_param("foo"), |
1334 | + test_literal_param("number"), |
1335 | + 1, initial, 0, &new_number)); |
1336 | + test_compare(new_number, (initial - 1)); |
1337 | + } |
1338 | + else |
1339 | + { |
1340 | + test_compare(MEMCACHED_INVALID_ARGUMENTS, |
1341 | + memcached_decrement_with_initial_by_key(memc, |
1342 | + test_literal_param("foo"), |
1343 | + test_literal_param("number"), |
1344 | + 1, initial, 0, &new_number)); |
1345 | + } |
1346 | |
1347 | return TEST_SUCCESS; |
1348 | } |
1349 | @@ -3040,7 +3083,7 @@ |
1350 | const char *key= "mine"; |
1351 | char *value; |
1352 | |
1353 | - /* Make sure be default none exists */ |
1354 | + /* Make sure by default none exists */ |
1355 | value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc); |
1356 | test_null(value); |
1357 | test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc)); |
1358 | @@ -3051,7 +3094,7 @@ |
1359 | |
1360 | value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc); |
1361 | test_true(value); |
1362 | - test_memcmp(value, key, 4); |
1363 | + test_memcmp(value, key, strlen(key)); |
1364 | test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc)); |
1365 | |
1366 | /* Test that we can turn it off */ |
1367 | @@ -3069,7 +3112,7 @@ |
1368 | value= (char *)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc); |
1369 | test_true(value); |
1370 | test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc)); |
1371 | - test_memcmp(value, key, 4); |
1372 | + test_memcmp(value, key, strlen(key)); |
1373 | |
1374 | /* Set to Zero, and then Set to something too large */ |
1375 | { |
1376 | @@ -3079,9 +3122,7 @@ |
1377 | test_compare(MEMCACHED_SUCCESS, |
1378 | memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, NULL)); |
1379 | |
1380 | - value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc); |
1381 | - test_null(value); |
1382 | - test_compare(MEMCACHED_SUCCESS, rc); |
1383 | + ASSERT_NULL_(memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc), "Setting namespace to NULL did not work"); |
1384 | |
1385 | /* Test a long key for failure */ |
1386 | /* TODO, extend test to determine based on setting, what result should be */ |
1387 | @@ -3109,11 +3150,10 @@ |
1388 | { |
1389 | memcached_return_t rc; |
1390 | const char *key= "mine"; |
1391 | - char *value; |
1392 | |
1393 | // Make sure we default to a null namespace |
1394 | - value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc); |
1395 | - test_null(value); |
1396 | + char* value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc); |
1397 | + ASSERT_NULL_(value, "memc had a value for namespace when none should exist"); |
1398 | test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc)); |
1399 | |
1400 | /* Test a clean set */ |
1401 | @@ -3121,8 +3161,8 @@ |
1402 | memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, (void *)key)); |
1403 | |
1404 | value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc); |
1405 | - test_true(value); |
1406 | - test_memcmp(value, key, 4); |
1407 | + ASSERT_TRUE(value); |
1408 | + test_memcmp(value, key, strlen(key)); |
1409 | test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc)); |
1410 | |
1411 | return TEST_SUCCESS; |
1412 | |
1413 | === modified file 'tests/libmemcached-1.0/mem_functions.h' |
1414 | --- tests/libmemcached-1.0/mem_functions.h 2013-02-23 21:43:42 +0000 |
1415 | +++ tests/libmemcached-1.0/mem_functions.h 2013-10-11 12:20:38 +0000 |
1416 | @@ -67,6 +67,7 @@ |
1417 | test_return_t decrement_test(memcached_st *memc); |
1418 | test_return_t decrement_with_initial_by_key_test(memcached_st *memc); |
1419 | test_return_t decrement_with_initial_test(memcached_st *memc); |
1420 | +test_return_t decrement_with_initial_999_test(memcached_st *memc); |
1421 | test_return_t delete_test(memcached_st *memc); |
1422 | test_return_t deprecated_set_memory_alloc(memcached_st *memc); |
1423 | test_return_t enable_cas(memcached_st *memc); |
1424 | @@ -88,6 +89,7 @@ |
1425 | test_return_t increment_test(memcached_st *memc); |
1426 | test_return_t increment_with_initial_by_key_test(memcached_st *memc); |
1427 | test_return_t increment_with_initial_test(memcached_st *memc); |
1428 | +test_return_t increment_with_initial_999_test(memcached_st *memc); |
1429 | test_return_t init_test(memcached_st *not_used); |
1430 | test_return_t jenkins_run (memcached_st *); |
1431 | test_return_t key_setup(memcached_st *memc); |
1432 | |
1433 | === modified file 'tests/libmemcached-1.0/plus.cpp' |
1434 | --- tests/libmemcached-1.0/plus.cpp 2013-04-03 13:14:23 +0000 |
1435 | +++ tests/libmemcached-1.0/plus.cpp 2013-10-11 12:20:38 +0000 |
1436 | @@ -181,6 +181,13 @@ |
1437 | vector<char> return_value; |
1438 | |
1439 | /* We need to empty the server before we continue the test */ |
1440 | + bool flush_res= memc.flush(); |
1441 | + if (flush_res == false) |
1442 | + { |
1443 | + std::string error_string; |
1444 | + ASSERT_TRUE(memc.error(error_string)); |
1445 | + Error << error_string; |
1446 | + } |
1447 | test_true(memc.flush()); |
1448 | |
1449 | test_true(memc.mget(keys)); |
1450 | |
1451 | === modified file 'tests/libmemcached_world.h' |
1452 | --- tests/libmemcached_world.h 2013-06-12 07:11:22 +0000 |
1453 | +++ tests/libmemcached_world.h 2013-10-11 12:20:38 +0000 |
1454 | @@ -87,12 +87,14 @@ |
1455 | static bool world_destroy(void *object) |
1456 | { |
1457 | libmemcached_test_container_st *container= (libmemcached_test_container_st *)object; |
1458 | +#if 0 |
1459 | #if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT |
1460 | if (LIBMEMCACHED_WITH_SASL_SUPPORT) |
1461 | { |
1462 | sasl_done(); |
1463 | } |
1464 | #endif |
1465 | +#endif |
1466 | |
1467 | delete container; |
1468 | |
1469 | |
1470 | === modified file 'tests/libmemcached_world_socket.h' |
1471 | --- tests/libmemcached_world_socket.h 2013-01-24 11:17:17 +0000 |
1472 | +++ tests/libmemcached_world_socket.h 2013-10-11 12:20:38 +0000 |
1473 | @@ -75,12 +75,15 @@ |
1474 | static bool world_destroy(void *object) |
1475 | { |
1476 | libmemcached_test_container_st *container= (libmemcached_test_container_st *)object; |
1477 | + |
1478 | +#if 0 |
1479 | #if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT |
1480 | if (LIBMEMCACHED_WITH_SASL_SUPPORT) |
1481 | { |
1482 | sasl_done(); |
1483 | } |
1484 | #endif |
1485 | +#endif |
1486 | |
1487 | delete container; |
1488 | |
1489 | |
1490 | === modified file 'tests/memcat.cc' |
1491 | --- tests/memcat.cc 2013-01-28 22:51:05 +0000 |
1492 | +++ tests/memcat.cc 2013-10-11 12:20:38 +0000 |
1493 | @@ -64,10 +64,10 @@ |
1494 | static test_return_t cat_test(void *) |
1495 | { |
1496 | char buffer[1024]; |
1497 | - snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); |
1498 | + int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); |
1499 | const char *args[]= { buffer, "foo", 0 }; |
1500 | |
1501 | - memcached_st *memc= memcached(buffer, strlen(buffer)); |
1502 | + memcached_st *memc= memcached(buffer, length); |
1503 | test_true(memc); |
1504 | |
1505 | test_compare(MEMCACHED_SUCCESS, |
1506 | @@ -77,6 +77,7 @@ |
1507 | test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); |
1508 | test_compare(MEMCACHED_SUCCESS, rc); |
1509 | |
1510 | + snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); |
1511 | test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); |
1512 | |
1513 | test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); |
1514 | @@ -90,11 +91,11 @@ |
1515 | static test_return_t NOT_FOUND_test(void *) |
1516 | { |
1517 | char buffer[1024]; |
1518 | - snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); |
1519 | + int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); |
1520 | const char *args[]= { buffer, "foo", 0 }; |
1521 | |
1522 | - memcached_st *memc= memcached(buffer, strlen(buffer)); |
1523 | - test_true(memc); |
1524 | + memcached_st *memc= memcached(buffer, length); |
1525 | + ASSERT_TRUE(memc); |
1526 | |
1527 | test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0)); |
1528 | |
1529 | @@ -102,6 +103,7 @@ |
1530 | test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); |
1531 | test_compare(MEMCACHED_NOTFOUND, rc); |
1532 | |
1533 | + snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); |
1534 | test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true)); |
1535 | |
1536 | test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); |
1537 | |
1538 | === modified file 'tests/memcp.cc' |
1539 | --- tests/memcp.cc 2013-06-12 07:11:22 +0000 |
1540 | +++ tests/memcp.cc 2013-10-11 12:20:38 +0000 |
1541 | @@ -63,6 +63,7 @@ |
1542 | return TEST_SUCCESS; |
1543 | } |
1544 | |
1545 | +#if 0 |
1546 | static test_return_t server_test(void *) |
1547 | { |
1548 | int fd; |
1549 | @@ -82,10 +83,13 @@ |
1550 | |
1551 | return TEST_SUCCESS; |
1552 | } |
1553 | +#endif |
1554 | |
1555 | test_st memcp_tests[] ={ |
1556 | {"--help", true, help_test }, |
1557 | +#if 0 |
1558 | {"--server_test", true, server_test }, |
1559 | +#endif |
1560 | {0, 0, 0} |
1561 | }; |
1562 | |
1563 | |
1564 | === modified file 'tests/memdump.cc' |
1565 | --- tests/memdump.cc 2013-01-28 22:51:05 +0000 |
1566 | +++ tests/memdump.cc 2013-10-11 12:20:38 +0000 |
1567 | @@ -75,10 +75,10 @@ |
1568 | static test_return_t FOUND_test(void *) |
1569 | { |
1570 | char buffer[1024]; |
1571 | - snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); |
1572 | + int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); |
1573 | const char *args[]= { buffer, 0 }; |
1574 | |
1575 | - memcached_st *memc= memcached(buffer, strlen(buffer)); |
1576 | + memcached_st *memc= memcached(buffer, length); |
1577 | test_true(memc); |
1578 | |
1579 | test_compare(MEMCACHED_SUCCESS, |
1580 | @@ -91,6 +91,7 @@ |
1581 | test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); |
1582 | test_compare(MEMCACHED_SUCCESS, rc); |
1583 | |
1584 | + length= snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); |
1585 | test_true(exec_cmdline(executable, args, true) <= EXIT_FAILURE); |
1586 | |
1587 | memcached_free(memc); |
1588 | @@ -110,19 +111,11 @@ |
1589 | {0, 0, 0, 0} |
1590 | }; |
1591 | |
1592 | -static void *world_create(server_startup_st& servers, test_return_t& error) |
1593 | +static void *world_create(server_startup_st& servers, test_return_t&) |
1594 | { |
1595 | - if (libtest::has_memcached() == false) |
1596 | - { |
1597 | - error= TEST_SKIPPED; |
1598 | - return NULL; |
1599 | - } |
1600 | + SKIP_UNLESS(libtest::has_memcached()); |
1601 | |
1602 | - if (server_startup(servers, "memcached", libtest::default_port(), NULL) == false) |
1603 | - { |
1604 | - error= TEST_FAILURE; |
1605 | - return NULL; |
1606 | - } |
1607 | + ASSERT_TRUE(server_startup(servers, "memcached", libtest::default_port(), NULL)); |
1608 | |
1609 | return &servers; |
1610 | } |
1611 | |
1612 | === modified file 'tests/memexist.cc' |
1613 | --- tests/memexist.cc 2013-01-28 22:51:05 +0000 |
1614 | +++ tests/memexist.cc 2013-10-11 12:20:38 +0000 |
1615 | @@ -64,10 +64,10 @@ |
1616 | static test_return_t exist_test(void *) |
1617 | { |
1618 | char buffer[1024]; |
1619 | - snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); |
1620 | + int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); |
1621 | const char *args[]= { buffer, "foo", 0 }; |
1622 | |
1623 | - memcached_st *memc= memcached(buffer, strlen(buffer)); |
1624 | + memcached_st *memc= memcached(buffer, length); |
1625 | test_true(memc); |
1626 | |
1627 | test_compare(MEMCACHED_SUCCESS, |
1628 | @@ -90,11 +90,11 @@ |
1629 | static test_return_t NOT_FOUND_test(void *) |
1630 | { |
1631 | char buffer[1024]; |
1632 | - snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); |
1633 | + int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); |
1634 | const char *args[]= { buffer, "foo", 0 }; |
1635 | |
1636 | - memcached_st *memc= memcached(buffer, strlen(buffer)); |
1637 | - test_true(memc); |
1638 | + memcached_st *memc= memcached(buffer, length); |
1639 | + ASSERT_TRUE(memc); |
1640 | |
1641 | test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0)); |
1642 | |
1643 | @@ -115,9 +115,9 @@ |
1644 | static test_return_t check_version(void*) |
1645 | { |
1646 | char buffer[1024]; |
1647 | - snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); |
1648 | - memcached_st *memc= memcached(buffer, strlen(buffer)); |
1649 | - test_true(memc); |
1650 | + int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); |
1651 | + memcached_st *memc= memcached(buffer, length); |
1652 | + ASSERT_TRUE(memc); |
1653 | |
1654 | test_return_t result= TEST_SUCCESS; |
1655 | if (libmemcached_util_version_check(memc, 1, 4, 8) == false) |
1656 | |
1657 | === modified file 'tests/memping.cc' |
1658 | --- tests/memping.cc 2013-04-03 13:14:23 +0000 |
1659 | +++ tests/memping.cc 2013-10-11 12:20:38 +0000 |
1660 | @@ -64,7 +64,7 @@ |
1661 | static test_return_t ping_TEST(void *) |
1662 | { |
1663 | char buffer[1024]; |
1664 | - snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); |
1665 | + snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); |
1666 | const char *args[]= { buffer, 0 }; |
1667 | |
1668 | test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); |
1669 | @@ -75,7 +75,7 @@ |
1670 | static test_return_t NOT_FOUND_TEST(void *) |
1671 | { |
1672 | char buffer[1024]; |
1673 | - snprintf(buffer, sizeof(buffer), "--server=nonexist.libmemcached.org:%d", int(default_port())); |
1674 | + snprintf(buffer, sizeof(buffer), "--servers=nonexist.libmemcached.org:%d", int(default_port())); |
1675 | const char *args[]= { buffer, 0 }; |
1676 | |
1677 | test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true)); |
1678 | |
1679 | === modified file 'tests/memrm.cc' |
1680 | --- tests/memrm.cc 2013-01-28 22:51:05 +0000 |
1681 | +++ tests/memrm.cc 2013-10-11 12:20:38 +0000 |
1682 | @@ -84,6 +84,8 @@ |
1683 | test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); |
1684 | test_compare(MEMCACHED_SUCCESS, rc); |
1685 | |
1686 | + char memrm_buffer[1024]; |
1687 | + snprintf(memrm_buffer, sizeof(memrm_buffer), "--servers=localhost:%d", int(default_port())); |
1688 | const char *args[]= { buffer, "foo", 0 }; |
1689 | test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); |
1690 | |
1691 | @@ -121,7 +123,7 @@ |
1692 | static test_return_t multiple_NOT_FOUND_TEST(void *) |
1693 | { |
1694 | char buffer[1024]; |
1695 | - snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); |
1696 | + snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); |
1697 | const char *args[]= { buffer, "protocols", "foo", "mine", "bar", "dog", "cat", "foo", "mine", |
1698 | "eye", "for", "the", "to", "not", "know", "what", "I", "should", "be", "doing", 0 }; |
1699 | |
1700 | |
1701 | === modified file 'tests/memtouch.cc' |
1702 | --- tests/memtouch.cc 2013-01-28 22:51:05 +0000 |
1703 | +++ tests/memtouch.cc 2013-10-11 12:20:38 +0000 |
1704 | @@ -65,9 +65,9 @@ |
1705 | static test_return_t touch_test(void *) |
1706 | { |
1707 | char buffer[1024]; |
1708 | - snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); |
1709 | + int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); |
1710 | |
1711 | - memcached_st *memc= memcached(buffer, strlen(buffer)); |
1712 | + memcached_st *memc= memcached(buffer, length); |
1713 | test_true(memc); |
1714 | |
1715 | test_compare(MEMCACHED_SUCCESS, |
1716 | @@ -89,15 +89,15 @@ |
1717 | static test_return_t NOT_FOUND_test(void *) |
1718 | { |
1719 | char buffer[1024]; |
1720 | - snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); |
1721 | - memcached_st *memc= memcached(buffer, strlen(buffer)); |
1722 | + int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); |
1723 | + memcached_st *memc= memcached(buffer, length); |
1724 | test_true(memc); |
1725 | |
1726 | test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0)); |
1727 | |
1728 | test_compare(MEMCACHED_NOTFOUND, memcached_exist(memc, test_literal_param("foo"))); |
1729 | |
1730 | - snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); |
1731 | + length= snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); |
1732 | const char *args[]= { "--expire=30", buffer, "foo", 0 }; |
1733 | test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true)); |
1734 | |
1735 | @@ -111,8 +111,8 @@ |
1736 | static test_return_t check_version(void*) |
1737 | { |
1738 | char buffer[1024]; |
1739 | - snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); |
1740 | - memcached_st *memc= memcached(buffer, strlen(buffer)); |
1741 | + int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); |
1742 | + memcached_st *memc= memcached(buffer, length); |
1743 | test_true(memc); |
1744 | |
1745 | test_return_t result= TEST_SUCCESS; |