1 /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 * Libmemcached Client and Server
5 * Copyright (C) 2011 Data Differential, http://datadifferential.com/
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following disclaimer
17 * in the documentation and/or other materials provided with the
20 * * The names of its contributors may not be used to endorse or
21 * promote products derived from this software without specific prior
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 #include <libtest/test.hpp>
41 using namespace libtest
;
47 #include <libmemcached/memcached.h>
48 #include <libmemcached/util.h>
50 #include <tests/libmemcached-1.0/parser.h>
51 #include <tests/print.h>
52 #include "libmemcached/instance.h"
63 struct scanner_string_st
{
68 static inline scanner_string_st
scanner_string(const char *arg
, size_t arg_size
)
70 scanner_string_st local
= { arg
, arg_size
};
74 #define make_scanner_string(X) scanner_string((X), static_cast<size_t>(sizeof(X) - 1))
76 static struct scanner_string_st scanner_string_null
= { 0, 0};
78 struct scanner_variable_t
{
79 enum scanner_type_t type
;
80 struct scanner_string_st option
;
81 struct scanner_string_st result
;
82 test_return_t (*check_func
)(memcached_st
*memc
, const scanner_string_st
&hostname
);
85 // Check and make sure the first host is what we expect it to be
86 static test_return_t
__check_host(memcached_st
*memc
, const scanner_string_st
&hostname
)
88 memcached_server_instance_st instance
=
89 memcached_server_instance_by_position(memc
, 0);
93 const char *first_hostname
= memcached_server_name(instance
);
94 test_true(first_hostname
);
95 test_strcmp(first_hostname
, hostname
.c_str
);
100 // Check and make sure the prefix_key is what we expect it to be
101 static test_return_t
__check_namespace(memcached_st
*, const scanner_string_st
&)
104 const char *_namespace
= memcached_get_namespace(memc
);
105 test_true(_namespace
);
106 test_strcmp(_namespace
, arg
.c_str
);
112 static test_return_t
__check_IO_MSG_WATERMARK(memcached_st
*memc
, const scanner_string_st
&value
)
114 uint64_t value_number
;
116 value_number
= atoll(value
.c_str
);
118 test_true(memcached_behavior_get(memc
, MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK
) == value_number
);
122 static test_return_t
__check_REMOVE_FAILED_SERVERS(memcached_st
*memc
, const scanner_string_st
&)
124 test_true(memcached_behavior_get(memc
, MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS
));
128 static test_return_t
__check_NOREPLY(memcached_st
*memc
, const scanner_string_st
&)
130 test_true(memcached_behavior_get(memc
, MEMCACHED_BEHAVIOR_NOREPLY
));
134 static test_return_t
__check_VERIFY_KEY(memcached_st
*memc
, const scanner_string_st
&)
136 test_true(memcached_behavior_get(memc
, MEMCACHED_BEHAVIOR_VERIFY_KEY
));
140 static test_return_t
__check_distribution_RANDOM(memcached_st
*memc
, const scanner_string_st
&)
142 test_true(memcached_behavior_get(memc
, MEMCACHED_BEHAVIOR_DISTRIBUTION
) == MEMCACHED_DISTRIBUTION_RANDOM
);
146 scanner_variable_t test_server_strings
[]= {
147 { ARRAY
, make_scanner_string("--server=localhost"), make_scanner_string("localhost"), __check_host
},
148 { ARRAY
, make_scanner_string("--server=10.0.2.1"), make_scanner_string("10.0.2.1"), __check_host
},
149 { ARRAY
, make_scanner_string("--server=example.com"), make_scanner_string("example.com"), __check_host
},
150 { ARRAY
, make_scanner_string("--server=localhost:30"), make_scanner_string("localhost"), __check_host
},
151 { ARRAY
, make_scanner_string("--server=10.0.2.1:20"), make_scanner_string("10.0.2.1"), __check_host
},
152 { ARRAY
, make_scanner_string("--server=example.com:1024"), make_scanner_string("example.com"), __check_host
},
153 { NIL
, scanner_string_null
, scanner_string_null
, NULL
}
156 scanner_variable_t test_server_strings_with_weights
[]= {
157 { ARRAY
, make_scanner_string("--server=10.0.2.1:30/?40"), make_scanner_string("10.0.2.1"), __check_host
},
158 { ARRAY
, make_scanner_string("--server=example.com:1024/?30"), make_scanner_string("example.com"), __check_host
},
159 { ARRAY
, make_scanner_string("--server=10.0.2.1/?20"), make_scanner_string("10.0.2.1"), __check_host
},
160 { ARRAY
, make_scanner_string("--server=example.com/?10"), make_scanner_string("example.com"), __check_host
},
161 { NIL
, scanner_string_null
, scanner_string_null
, NULL
}
164 scanner_variable_t bad_test_strings
[]= {
165 { ARRAY
, make_scanner_string("-servers=localhost:11221,localhost:11222,localhost:11223,localhost:11224,localhost:11225"), scanner_string_null
, NULL
},
166 { ARRAY
, make_scanner_string("-- servers=a.example.com:81,localhost:82,b.example.com"), scanner_string_null
, NULL
},
167 { ARRAY
, make_scanner_string("--servers=localhost:+80"), scanner_string_null
, NULL
},
168 { ARRAY
, make_scanner_string("--servers=localhost.com."), scanner_string_null
, NULL
},
169 { ARRAY
, make_scanner_string("--server=localhost.com."), scanner_string_null
, NULL
},
170 { ARRAY
, make_scanner_string("--server=localhost.com.:80"), scanner_string_null
, NULL
},
171 { NIL
, scanner_string_null
, scanner_string_null
, NULL
}
174 scanner_variable_t test_number_options
[]= {
175 { ARRAY
, make_scanner_string("--CONNECT-TIMEOUT=456"), scanner_string_null
, NULL
},
176 { ARRAY
, make_scanner_string("--IO-BYTES-WATERMARK=456"), scanner_string_null
, NULL
},
177 { ARRAY
, make_scanner_string("--IO-KEY-PREFETCH=456"), scanner_string_null
, NULL
},
178 { ARRAY
, make_scanner_string("--IO-MSG-WATERMARK=456"), make_scanner_string("456"), __check_IO_MSG_WATERMARK
},
179 { ARRAY
, make_scanner_string("--NUMBER-OF-REPLICAS=456"), scanner_string_null
, NULL
},
180 { ARRAY
, make_scanner_string("--POLL-TIMEOUT=456"), scanner_string_null
, NULL
},
181 { ARRAY
, make_scanner_string("--RCV-TIMEOUT=456"), scanner_string_null
, NULL
},
182 { ARRAY
, make_scanner_string("--REMOVE-FAILED-SERVERS=3"), scanner_string_null
, __check_REMOVE_FAILED_SERVERS
},
183 { ARRAY
, make_scanner_string("--RETRY-TIMEOUT=456"), scanner_string_null
, NULL
},
184 { ARRAY
, make_scanner_string("--SND-TIMEOUT=456"), scanner_string_null
, NULL
},
185 { ARRAY
, make_scanner_string("--SOCKET-RECV-SIZE=456"), scanner_string_null
, NULL
},
186 { ARRAY
, make_scanner_string("--SOCKET-SEND-SIZE=456"), scanner_string_null
, NULL
},
187 { NIL
, scanner_string_null
, scanner_string_null
, NULL
}
190 scanner_variable_t test_boolean_options
[]= {
191 { ARRAY
, make_scanner_string("--FETCH-VERSION"), scanner_string_null
, NULL
},
192 { ARRAY
, make_scanner_string("--BINARY-PROTOCOL"), scanner_string_null
, NULL
},
193 { ARRAY
, make_scanner_string("--BUFFER-REQUESTS"), scanner_string_null
, NULL
},
194 { ARRAY
, make_scanner_string("--HASH-WITH-NAMESPACE"), scanner_string_null
, NULL
},
195 { ARRAY
, make_scanner_string("--NOREPLY"), scanner_string_null
, __check_NOREPLY
},
196 { ARRAY
, make_scanner_string("--RANDOMIZE-REPLICA-READ"), scanner_string_null
, NULL
},
197 { ARRAY
, make_scanner_string("--SORT-HOSTS"), scanner_string_null
, NULL
},
198 { ARRAY
, make_scanner_string("--SUPPORT-CAS"), scanner_string_null
, NULL
},
199 { ARRAY
, make_scanner_string("--TCP-NODELAY"), scanner_string_null
, NULL
},
200 { ARRAY
, make_scanner_string("--TCP-KEEPALIVE"), scanner_string_null
, NULL
},
201 { ARRAY
, make_scanner_string("--TCP-KEEPIDLE"), scanner_string_null
, NULL
},
202 { ARRAY
, make_scanner_string("--USE-UDP"), scanner_string_null
, NULL
},
203 { ARRAY
, make_scanner_string("--VERIFY-KEY"), scanner_string_null
, __check_VERIFY_KEY
},
204 { NIL
, scanner_string_null
, scanner_string_null
, NULL
}
207 scanner_variable_t namespace_strings
[]= {
208 { ARRAY
, make_scanner_string("--NAMESPACE=foo"), make_scanner_string("foo"), __check_namespace
},
209 { ARRAY
, make_scanner_string("--NAMESPACE=\"foo\""), make_scanner_string("foo"), __check_namespace
},
210 { ARRAY
, make_scanner_string("--NAMESPACE=\"This_is_a_very_long_key\""), make_scanner_string("This_is_a_very_long_key"), __check_namespace
},
211 { NIL
, scanner_string_null
, scanner_string_null
, NULL
}
214 scanner_variable_t distribution_strings
[]= {
215 { ARRAY
, make_scanner_string("--DISTRIBUTION=consistent"), scanner_string_null
, NULL
},
216 { ARRAY
, make_scanner_string("--DISTRIBUTION=consistent,CRC"), scanner_string_null
, NULL
},
217 { ARRAY
, make_scanner_string("--DISTRIBUTION=consistent,MD5"), scanner_string_null
, NULL
},
218 { ARRAY
, make_scanner_string("--DISTRIBUTION=random"), scanner_string_null
, __check_distribution_RANDOM
},
219 { ARRAY
, make_scanner_string("--DISTRIBUTION=modula"), scanner_string_null
, NULL
},
220 { NIL
, scanner_string_null
, scanner_string_null
, NULL
}
223 scanner_variable_t hash_strings
[]= {
224 { ARRAY
, make_scanner_string("--HASH=CRC"), scanner_string_null
, NULL
},
225 { ARRAY
, make_scanner_string("--HASH=FNV1A_32"), scanner_string_null
, NULL
},
226 { ARRAY
, make_scanner_string("--HASH=FNV1_32"), scanner_string_null
, NULL
},
228 { ARRAY
, make_scanner_string("--HASH=JENKINS"), scanner_string_null
, NULL
},
230 { ARRAY
, make_scanner_string("--HASH=MD5"), scanner_string_null
, NULL
},
231 { NIL
, scanner_string_null
, scanner_string_null
, NULL
}
235 static test_return_t
_test_option(scanner_variable_t
*scanner
, bool test_true_opt
= true)
237 for (scanner_variable_t
*ptr
= scanner
; ptr
->type
!= NIL
; ptr
++)
239 memcached_st
*memc
= memcached(ptr
->option
.c_str
, ptr
->option
.size
);
241 // The case that it should have parsed, but it didn't. We will inspect for
242 // an error with libmemcached_check_configuration()
243 if (memc
== NULL
and test_true_opt
)
246 bool success
= libmemcached_check_configuration(ptr
->option
.c_str
, ptr
->option
.size
, buffer
, sizeof(buffer
));
248 std::string
temp(buffer
);
249 temp
+= " with option string:";
250 temp
+= ptr
->option
.c_str
;
251 test_true_got(success
, temp
.c_str());
252 Error
<< "Failed for " << temp
;
254 return TEST_FAILURE
; // The line above should fail since memc should be null
261 test_return_t test_rc
= (*ptr
->check_func
)(memc
, ptr
->result
);
262 if (test_rc
!= TEST_SUCCESS
)
264 memcached_free(memc
);
269 memcached_free(memc
);
273 test_false_with(memc
, ptr
->option
.c_str
);
280 test_return_t
server_test(memcached_st
*)
282 return _test_option(test_server_strings
);
285 test_return_t
server_with_weight_test(memcached_st
*)
287 return _test_option(test_server_strings_with_weights
);
290 test_return_t
servers_bad_test(memcached_st
*)
293 if ((rc
= _test_option(bad_test_strings
, false)) != TEST_SUCCESS
)
301 test_return_t
parser_number_options_test(memcached_st
*)
303 return _test_option(test_number_options
);
306 test_return_t
parser_boolean_options_test(memcached_st
*)
308 return _test_option(test_boolean_options
);
311 test_return_t
behavior_parser_test(memcached_st
*)
316 test_return_t
parser_hash_test(memcached_st
*)
318 return _test_option(hash_strings
);
321 test_return_t
parser_distribution_test(memcached_st
*)
323 return _test_option(distribution_strings
);
326 test_return_t
parser_key_prefix_test(memcached_st
*)
328 return _test_option(distribution_strings
);
331 test_return_t
test_namespace_keyword(memcached_st
*)
333 return _test_option(namespace_strings
);
336 #define SUPPORT_EXAMPLE_CNF "support/example.cnf"
338 test_return_t
memcached_create_with_options_with_filename(memcached_st
*)
340 test_skip(0, access(SUPPORT_EXAMPLE_CNF
, R_OK
));
342 memcached_st
*memc_ptr
= memcached(test_literal_param("--CONFIGURE-FILE=\"support/example.cnf\""));
343 test_true_got(memc_ptr
, "memcached() failed");
344 memcached_free(memc_ptr
);
349 test_return_t
libmemcached_check_configuration_with_filename_test(memcached_st
*)
351 test_skip(0, access(SUPPORT_EXAMPLE_CNF
, R_OK
));
355 test_compare_hint(MEMCACHED_SUCCESS
,
356 libmemcached_check_configuration(test_literal_param("--CONFIGURE-FILE=\"support/example.cnf\""), buffer
, sizeof(buffer
)),
359 test_compare_hint(MEMCACHED_SUCCESS
,
360 libmemcached_check_configuration(test_literal_param("--CONFIGURE-FILE=support/example.cnf"), buffer
, sizeof(buffer
)),
363 test_compare_hint(MEMCACHED_ERRNO
,
364 libmemcached_check_configuration(test_literal_param("--CONFIGURE-FILE=\"bad-path/example.cnf\""), buffer
, sizeof(buffer
)),
370 test_return_t
libmemcached_check_configuration_test(memcached_st
*)
373 test_compare(MEMCACHED_SUCCESS
,
374 libmemcached_check_configuration(test_literal_param("--server=localhost"), buffer
, sizeof(buffer
)));
376 test_compare_hint(MEMCACHED_PARSE_ERROR
,
377 libmemcached_check_configuration(test_literal_param("--dude=localhost"), buffer
, sizeof(buffer
)),
383 test_return_t
memcached_create_with_options_test(memcached_st
*)
386 memcached_st
*memc_ptr
;
387 memc_ptr
= memcached(test_literal_param("--server=localhost"));
388 test_true_got(memc_ptr
, memcached_last_error_message(memc_ptr
));
389 memcached_free(memc_ptr
);
393 memcached_st
*memc_ptr
= memcached(test_literal_param("--dude=localhost"));
394 test_false_with(memc_ptr
, memcached_last_error_message(memc_ptr
));
400 test_return_t
test_include_keyword(memcached_st
*)
402 test_skip(0, access(SUPPORT_EXAMPLE_CNF
, R_OK
));
405 test_compare(MEMCACHED_SUCCESS
,
406 libmemcached_check_configuration(test_literal_param("INCLUDE \"support/example.cnf\""), buffer
, sizeof(buffer
)));
411 test_return_t
test_end_keyword(memcached_st
*)
414 test_compare(MEMCACHED_SUCCESS
,
415 libmemcached_check_configuration(test_literal_param("--server=localhost END bad keywords"), buffer
, sizeof(buffer
)));
420 test_return_t
test_reset_keyword(memcached_st
*)
423 test_compare(MEMCACHED_SUCCESS
,
424 libmemcached_check_configuration(test_literal_param("--server=localhost reset --server=bad.com"), buffer
, sizeof(buffer
)));
429 test_return_t
test_error_keyword(memcached_st
*)
432 memcached_return_t rc
;
433 rc
= libmemcached_check_configuration(test_literal_param("--server=localhost ERROR --server=bad.com"), buffer
, sizeof(buffer
));
434 test_true_got(rc
!= MEMCACHED_SUCCESS
, buffer
);
439 #define RANDOM_STRINGS 1000
440 test_return_t
random_statement_build_test(memcached_st
*)
442 std::vector
<scanner_string_st
*> option_list
;
444 for (scanner_variable_t
*ptr
= test_server_strings
; ptr
->type
!= NIL
; ptr
++)
445 option_list
.push_back(&ptr
->option
);
447 for (scanner_variable_t
*ptr
= test_number_options
; ptr
->type
!= NIL
; ptr
++)
448 option_list
.push_back(&ptr
->option
);
450 for (scanner_variable_t
*ptr
= test_boolean_options
; ptr
->type
!= NIL
; ptr
++)
451 option_list
.push_back(&ptr
->option
);
453 for (scanner_variable_t
*ptr
= namespace_strings
; ptr
->type
!= NIL
; ptr
++)
454 option_list
.push_back(&ptr
->option
);
456 for (scanner_variable_t
*ptr
= distribution_strings
; ptr
->type
!= NIL
; ptr
++)
457 option_list
.push_back(&ptr
->option
);
459 for (scanner_variable_t
*ptr
= hash_strings
; ptr
->type
!= NIL
; ptr
++)
460 option_list
.push_back(&ptr
->option
);
462 std::vector
<bool> used_list
;
463 used_list
.resize(option_list
.size());
465 struct used_options_st
{
468 bool has_distribution
;
469 bool has_buffer_requests
;
476 has_namespace(false),
477 has_distribution(false),
478 has_buffer_requests(false),
481 has_verify_key(false)
486 for (uint32_t x
= 0; x
< RANDOM_STRINGS
; x
++)
488 std::string random_options
;
490 uint32_t number_of
= random() % uint32_t(option_list
.size());
491 for (uint32_t options
= 0; options
< number_of
; options
++)
493 size_t option_list_position
= random() % option_list
.size();
495 if (used_list
[option_list_position
])
499 used_list
[option_list_position
]= true;
501 std::string random_string
= option_list
[option_list_position
]->c_str
;
503 if (random_string
.compare(0, test_literal_compare_param("--HASH")) == 0)
505 if (used_options
.has_hash
)
510 if (used_options
.has_distribution
)
514 used_options
.has_hash
= true;
517 if (random_string
.compare(0, test_literal_compare_param("--NAMESPACE")) == 0)
519 if (used_options
.has_namespace
)
523 used_options
.has_namespace
= true;
526 if (random_string
.compare(0, test_literal_compare_param("--USE-UDP")) == 0)
528 if (used_options
.has_udp
)
532 used_options
.has_udp
= true;
534 if (used_options
.has_buffer_requests
)
540 if (random_string
.compare(0, test_literal_compare_param("--BUFFER-REQUESTS")) == 0)
542 if (used_options
.has_buffer_requests
)
546 used_options
.has_buffer_requests
= true;
548 if (used_options
.has_udp
)
554 if (random_string
.compare(0, test_literal_compare_param("--BINARY-PROTOCOL")) == 0)
556 if (used_options
.has_binary
)
560 used_options
.has_binary
= true;
562 if (used_options
.has_verify_key
)
568 if (random_string
.compare(0, test_literal_compare_param("--VERIFY-KEY")) == 0)
570 if (used_options
.has_verify_key
)
574 used_options
.has_verify_key
= true;
576 if (used_options
.has_binary
)
582 if (random_string
.compare(0, test_literal_compare_param("--DISTRIBUTION")) == 0)
584 if (used_options
.has_distribution
)
589 if (used_options
.has_hash
)
593 used_options
.has_distribution
= true;
596 random_options
+= random_string
;
597 random_options
+= " ";
600 if (random_options
.size() <= 1)
605 random_options
.resize(random_options
.size() -1);
608 memcached_return_t rc
= libmemcached_check_configuration(random_options
.c_str(), random_options
.size(), buffer
, sizeof(buffer
));
609 if (memcached_failed(rc
))
611 Error
<< "libmemcached_check_configuration(" << random_options
<< ") : " << buffer
;
619 static memcached_return_t
dump_server_information(const memcached_st
*,
620 memcached_server_instance_st instance
,
623 if (strcmp(memcached_server_name(instance
), "localhost"))
625 fatal_assert(not memcached_server_name(instance
));
626 return MEMCACHED_FAILURE
;
629 if (memcached_server_port(instance
) < 8888 or memcached_server_port(instance
) > 8892)
631 fatal_assert(not memcached_server_port(instance
));
632 return MEMCACHED_FAILURE
;
635 if (instance
->weight
> 5 or instance
->weight
< 2)
637 fatal_assert(not instance
->weight
);
638 return MEMCACHED_FAILURE
;
641 return MEMCACHED_SUCCESS
;
644 test_return_t
test_hostname_port_weight(memcached_st
*)
646 const char *server_string
= "--server=localhost:8888/?2 --server=localhost:8889/?3 --server=localhost:8890/?4 --server=localhost:8891/?5 --server=localhost:8892/?3";
649 test_compare_got(MEMCACHED_SUCCESS
,
650 libmemcached_check_configuration(server_string
, strlen(server_string
), buffer
, sizeof(buffer
)), buffer
);
652 memcached_st
*memc
= memcached(server_string
, strlen(server_string
));
655 memcached_server_fn callbacks
[]= { dump_server_information
};
656 test_true(memcached_success(memcached_server_cursor(memc
, callbacks
, NULL
, 1)));
658 memcached_free(memc
);
663 struct socket_weight_t
{
669 static memcached_return_t
dump_socket_information(const memcached_st
*,
670 memcached_server_instance_st instance
,
673 socket_weight_t
*check
= (socket_weight_t
*)context
;
675 if (strcmp(memcached_server_type(instance
), check
->type
) == 0)
677 if (strcmp(memcached_server_name(instance
), check
->socket
) == 0)
679 if (instance
->weight
== check
->weight
)
681 return MEMCACHED_SUCCESS
;
685 Error
<< instance
->weight
<< " != " << check
->weight
;
690 Error
<< "'" << memcached_server_name(instance
) << "'" << " != " << "'" << check
->socket
<< "'";
695 Error
<< "'" << memcached_server_type(instance
) << "'" << " != " << "'" << check
->type
<< "'";
698 return MEMCACHED_FAILURE
;
701 test_return_t
test_parse_socket(memcached_st
*)
705 memcached_server_fn callbacks
[]= { dump_socket_information
};
707 test_compare_got(MEMCACHED_SUCCESS
,
708 libmemcached_check_configuration(test_literal_param("--socket=\"/tmp/foo\""), buffer
, sizeof(buffer
)),
711 memcached_st
*memc
= memcached(test_literal_param("--socket=\"/tmp/foo\""));
713 socket_weight_t check
= { "/tmp/foo", 1, "SOCKET"};
714 test_compare(MEMCACHED_SUCCESS
,
715 memcached_server_cursor(memc
, callbacks
, &check
, 1));
716 memcached_free(memc
);
720 test_compare_got(MEMCACHED_SUCCESS
,
721 libmemcached_check_configuration(test_literal_param("--socket=\"/tmp/foo\"/?23"), buffer
, sizeof(buffer
)),
724 memcached_st
*memc
= memcached(test_literal_param("--socket=\"/tmp/foo\"/?23"));
726 socket_weight_t check
= { "/tmp/foo", 23, "SOCKET"};
727 test_compare(MEMCACHED_SUCCESS
,
728 memcached_server_cursor(memc
, callbacks
, &check
, 1));
729 memcached_free(memc
);
736 By setting the timeout value to zero, we force poll() to return immediatly.
738 test_return_t
regression_bug_71231153_connect(memcached_st
*)
740 if (libmemcached_util_ping("10.0.2.252", 0, NULL
)) // If for whatever reason someone has a host at this address, skip
743 { // Test the connect-timeout, on a bad host we should get MEMCACHED_CONNECTION_FAILURE
744 memcached_st
*memc
= memcached(test_literal_param("--SERVER=10.0.2.252 --CONNECT-TIMEOUT=0"));
746 test_zero(memc
->connect_timeout
);
747 test_compare(MEMCACHED_DEFAULT_TIMEOUT
, memc
->poll_timeout
);
749 memcached_return_t rc
;
751 char *value
= memcached_get(memc
, test_literal_param("test"), &value_len
, NULL
, &rc
);
753 test_zero(value_len
);
754 test_compare_got(MEMCACHED_TIMEOUT
, rc
, memcached_last_error_message(memc
));
756 memcached_free(memc
);
762 test_return_t
regression_bug_71231153_poll(memcached_st
*)
764 if (libmemcached_util_ping("10.0.2.252", 0, NULL
)) // If for whatever reason someone has a host at this address, skip
769 { // Test the poll timeout, on a bad host we should get MEMCACHED_CONNECTION_FAILURE
770 memcached_st
*memc
= memcached(test_literal_param("--SERVER=10.0.2.252 --POLL-TIMEOUT=0"));
772 test_compare(MEMCACHED_DEFAULT_CONNECT_TIMEOUT
, memc
->connect_timeout
);
773 test_zero(memc
->poll_timeout
);
775 memcached_return_t rc
;
777 char *value
= memcached_get(memc
, test_literal_param("test"), &value_len
, NULL
, &rc
);
779 test_zero(value_len
);
781 test_compare_got(MEMCACHED_CONNECTION_FAILURE
, rc
, memcached_last_error_message(memc
));
783 test_compare_got(MEMCACHED_TIMEOUT
, rc
, memcached_last_error_message(memc
));
786 memcached_free(memc
);