2 Sample test application.
10 #include <sys/types.h>
14 #include "../lib/common.h"
15 #include "../src/generator.h"
16 #include "../src/execute.h"
20 #define GLOBAL_COUNT 100000
21 static pairs_st
*global_pairs
;
22 static char *global_keys
[GLOBAL_COUNT
];
23 static size_t global_keys_length
[GLOBAL_COUNT
];
25 uint8_t init_test(memcached_st
*not_used
)
29 (void)memcached_create(&memc
);
30 memcached_free(&memc
);
35 uint8_t allocation_test(memcached_st
*not_used
)
38 memc
= memcached_create(NULL
);
45 uint8_t clone_test(memcached_st
*memc
)
50 clone
= memcached_clone(NULL
, NULL
);
52 memcached_free(clone
);
55 /* Can we init from null? */
58 clone
= memcached_clone(NULL
, memc
);
60 memcached_free(clone
);
63 /* Can we init from struct? */
65 memcached_st declared_clone
;
67 clone
= memcached_clone(&declared_clone
, NULL
);
69 memcached_free(clone
);
72 /* Can we init from struct? */
74 memcached_st declared_clone
;
76 clone
= memcached_clone(&declared_clone
, memc
);
78 memcached_free(clone
);
84 uint8_t connection_test(memcached_st
*memc
)
88 rc
= memcached_server_add(memc
, "localhost", 0);
89 assert(rc
== MEMCACHED_SUCCESS
);
94 uint8_t error_test(memcached_st
*memc
)
98 for (rc
= MEMCACHED_SUCCESS
; rc
< MEMCACHED_MAXIMUM_RETURN
; rc
++)
100 printf("Error %d -> %s\n", rc
, memcached_strerror(memc
, rc
));
106 uint8_t set_test(memcached_st
*memc
)
110 char *value
= "when we sanitize";
112 rc
= memcached_set(memc
, key
, strlen(key
),
113 value
, strlen(value
),
114 (time_t)0, (uint16_t)0);
115 assert(rc
== MEMCACHED_SUCCESS
);
120 uint8_t append_test(memcached_st
*memc
)
128 rc
= memcached_flush(memc
, 0);
129 assert(rc
== MEMCACHED_SUCCESS
);
131 rc
= memcached_set(memc
, key
, strlen(key
),
132 value
, strlen(value
),
133 (time_t)0, (uint16_t)0);
134 assert(rc
== MEMCACHED_SUCCESS
);
136 rc
= memcached_append(memc
, key
, strlen(key
),
137 " the", strlen(" the"),
138 (time_t)0, (uint16_t)0);
139 assert(rc
== MEMCACHED_SUCCESS
);
141 rc
= memcached_append(memc
, key
, strlen(key
),
142 " people", strlen(" people"),
143 (time_t)0, (uint16_t)0);
144 assert(rc
== MEMCACHED_SUCCESS
);
146 value
= memcached_get(memc
, key
, strlen(key
),
147 &value_length
, &flags
, &rc
);
148 assert(!memcmp(value
, "we the people", strlen("we the people")));
149 assert(strlen("we the people") == value_length
);
150 assert(rc
== MEMCACHED_SUCCESS
);
156 uint8_t append_binary_test(memcached_st
*memc
)
159 char *key
= "numbers";
160 unsigned int *store_ptr
;
161 unsigned int store_list
[] = { 23, 56, 499, 98, 32847, 0 };
167 rc
= memcached_flush(memc
, 0);
168 assert(rc
== MEMCACHED_SUCCESS
);
170 rc
= memcached_set(memc
,
173 (time_t)0, (uint16_t)0);
174 assert(rc
== MEMCACHED_SUCCESS
);
176 for (x
= 0; store_list
[x
] ; x
++)
178 rc
= memcached_append(memc
,
180 (char *)&store_list
[x
], sizeof(unsigned int),
181 (time_t)0, (uint16_t)0);
182 assert(rc
== MEMCACHED_SUCCESS
);
185 value
= memcached_get(memc
, key
, strlen(key
),
186 &value_length
, &flags
, &rc
);
187 assert((value_length
== (sizeof(unsigned int) * x
)));
188 assert(rc
== MEMCACHED_SUCCESS
);
190 store_ptr
= (unsigned int *)value
;
192 while ((size_t)store_ptr
< (size_t)(value
+ value_length
))
194 assert(*store_ptr
== store_list
[x
++]);
202 uint8_t cas2_test(memcached_st
*memc
)
205 char *keys
[]= {"fudge", "son", "food"};
206 size_t key_length
[]= {5, 3, 4};
207 char *value
= "we the people";
208 size_t value_length
= strlen("we the people");
210 memcached_result_st results_obj
;
211 memcached_result_st
*results
;
214 rc
= memcached_flush(memc
, 0);
215 assert(rc
== MEMCACHED_SUCCESS
);
217 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_SUPPORT_CAS
, &set
);
219 for (x
= 0; x
< 3; x
++)
221 rc
= memcached_set(memc
, keys
[x
], key_length
[x
],
222 keys
[x
], key_length
[x
],
223 (time_t)50, (uint16_t)9);
224 assert(rc
== MEMCACHED_SUCCESS
);
227 rc
= memcached_mget(memc
, keys
, key_length
, 3);
229 results
= memcached_result_create(memc
, &results_obj
);
231 results
= memcached_fetch_result(memc
, &results_obj
, &rc
);
233 assert(results
->cas
);
234 assert(rc
== MEMCACHED_SUCCESS
);
235 WATCHPOINT_ASSERT(memcached_result_cas(results
));
237 assert(!memcmp(value
, "we the people", strlen("we the people")));
238 assert(strlen("we the people") == value_length
);
239 assert(rc
== MEMCACHED_SUCCESS
);
241 memcached_result_free(&results_obj
);
246 uint8_t cas_test(memcached_st
*memc
)
250 size_t key_length
= strlen("fun");
251 char *value
= "we the people";
252 size_t value_length
= strlen("we the people");
253 memcached_result_st results_obj
;
254 memcached_result_st
*results
;
257 rc
= memcached_flush(memc
, 0);
258 assert(rc
== MEMCACHED_SUCCESS
);
260 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_SUPPORT_CAS
, &set
);
262 rc
= memcached_set(memc
, key
, strlen(key
),
263 value
, strlen(value
),
264 (time_t)0, (uint16_t)0);
265 assert(rc
== MEMCACHED_SUCCESS
);
267 rc
= memcached_mget(memc
, &key
, &key_length
, 1);
269 results
= memcached_result_create(memc
, &results_obj
);
271 results
= memcached_fetch_result(memc
, &results_obj
, &rc
);
273 assert(rc
== MEMCACHED_SUCCESS
);
274 WATCHPOINT_ASSERT(memcached_result_cas(results
));
276 assert(!memcmp(value
, "we the people", strlen("we the people")));
277 assert(strlen("we the people") == value_length
);
278 assert(rc
== MEMCACHED_SUCCESS
);
280 memcached_result_free(&results_obj
);
285 uint8_t prepend_test(memcached_st
*memc
)
289 char *value
= "people";
293 rc
= memcached_flush(memc
, 0);
294 assert(rc
== MEMCACHED_SUCCESS
);
296 rc
= memcached_set(memc
, key
, strlen(key
),
297 value
, strlen(value
),
298 (time_t)0, (uint16_t)0);
299 assert(rc
== MEMCACHED_SUCCESS
);
301 rc
= memcached_prepend(memc
, key
, strlen(key
),
302 "the ", strlen("the "),
303 (time_t)0, (uint16_t)0);
304 assert(rc
== MEMCACHED_SUCCESS
);
306 rc
= memcached_prepend(memc
, key
, strlen(key
),
307 "we ", strlen("we "),
308 (time_t)0, (uint16_t)0);
309 assert(rc
== MEMCACHED_SUCCESS
);
311 value
= memcached_get(memc
, key
, strlen(key
),
312 &value_length
, &flags
, &rc
);
313 assert(!memcmp(value
, "we the people", strlen("we the people")));
314 assert(strlen("we the people") == value_length
);
315 assert(rc
== MEMCACHED_SUCCESS
);
321 uint8_t add_test(memcached_st
*memc
)
325 char *value
= "when we sanitize";
327 rc
= memcached_add(memc
, key
, strlen(key
),
328 value
, strlen(value
),
329 (time_t)0, (uint16_t)0);
330 assert(rc
== MEMCACHED_NOTSTORED
);
335 uint8_t replace_test(memcached_st
*memc
)
339 char *value
= "when we sanitize";
341 rc
= memcached_replace(memc
, key
, strlen(key
),
342 value
, strlen(value
),
343 (time_t)0, (uint16_t)0);
344 assert(rc
== MEMCACHED_SUCCESS
);
349 uint8_t delete_test(memcached_st
*memc
)
353 char *value
= "when we sanitize";
355 rc
= memcached_set(memc
, key
, strlen(key
),
356 value
, strlen(value
),
357 (time_t)0, (uint16_t)0);
358 assert(rc
== MEMCACHED_SUCCESS
);
360 rc
= memcached_delete(memc
, key
, strlen(key
), (time_t)0);
361 assert(rc
== MEMCACHED_SUCCESS
);
366 uint8_t flush_test(memcached_st
*memc
)
370 rc
= memcached_flush(memc
, 0);
371 assert(rc
== MEMCACHED_SUCCESS
);
376 uint8_t get_test(memcached_st
*memc
)
381 size_t string_length
;
384 rc
= memcached_delete(memc
, key
, strlen(key
), (time_t)0);
385 assert(rc
== MEMCACHED_SUCCESS
|| rc
== MEMCACHED_NOTFOUND
);
387 string
= memcached_get(memc
, key
, strlen(key
),
388 &string_length
, &flags
, &rc
);
390 assert(rc
== MEMCACHED_NOTFOUND
);
391 assert(string_length
== 0);
397 uint8_t get_test2(memcached_st
*memc
)
401 char *value
= "when we sanitize";
403 size_t string_length
;
406 rc
= memcached_set(memc
, key
, strlen(key
),
407 value
, strlen(value
),
408 (time_t)0, (uint16_t)0);
409 assert(rc
== MEMCACHED_SUCCESS
);
411 string
= memcached_get(memc
, key
, strlen(key
),
412 &string_length
, &flags
, &rc
);
415 assert(rc
== MEMCACHED_SUCCESS
);
416 assert(string_length
== strlen(value
));
417 assert(!memcmp(string
, value
, string_length
));
424 uint8_t set_test2(memcached_st
*memc
)
428 char *value
= "train in the brain";
429 size_t value_length
= strlen(value
);
432 for (x
= 0; x
< 10; x
++)
434 rc
= memcached_set(memc
, key
, strlen(key
),
436 (time_t)0, (uint16_t)0);
437 assert(rc
== MEMCACHED_SUCCESS
);
443 uint8_t set_test3(memcached_st
*memc
)
448 size_t value_length
= 8191;
451 value
= (char*)malloc(value_length
);
454 for (x
= 0; x
< value_length
; x
++)
455 value
[x
] = (char) (x
% 127);
457 for (x
= 0; x
< 1; x
++)
459 rc
= memcached_set(memc
, key
, strlen(key
),
461 (time_t)0, (uint16_t)0);
462 assert(rc
== MEMCACHED_SUCCESS
);
470 uint8_t get_test3(memcached_st
*memc
)
475 size_t value_length
= 8191;
477 size_t string_length
;
481 value
= (char*)malloc(value_length
);
484 for (x
= 0; x
< value_length
; x
++)
485 value
[x
] = (char) (x
% 127);
487 rc
= memcached_set(memc
, key
, strlen(key
),
489 (time_t)0, (uint16_t)0);
490 assert(rc
== MEMCACHED_SUCCESS
);
492 string
= memcached_get(memc
, key
, strlen(key
),
493 &string_length
, &flags
, &rc
);
495 assert(rc
== MEMCACHED_SUCCESS
);
497 assert(string_length
== value_length
);
498 assert(!memcmp(string
, value
, string_length
));
506 uint8_t get_test4(memcached_st
*memc
)
511 size_t value_length
= 8191;
513 size_t string_length
;
517 value
= (char*)malloc(value_length
);
520 for (x
= 0; x
< value_length
; x
++)
521 value
[x
] = (char) (x
% 127);
523 rc
= memcached_set(memc
, key
, strlen(key
),
525 (time_t)0, (uint16_t)0);
526 assert(rc
== MEMCACHED_SUCCESS
);
528 for (x
= 0; x
< 10; x
++)
530 string
= memcached_get(memc
, key
, strlen(key
),
531 &string_length
, &flags
, &rc
);
533 assert(rc
== MEMCACHED_SUCCESS
);
535 assert(string_length
== value_length
);
536 assert(!memcmp(string
, value
, string_length
));
545 /* Do not copy the style of this code, I just access hosts to testthis function */
546 uint8_t stats_servername_test(memcached_st
*memc
)
549 memcached_stat_st stat
;
550 rc
= memcached_stat_servername(&stat
, NULL
,
551 memc
->hosts
[0].hostname
,
552 memc
->hosts
[0].port
);
557 uint8_t increment_test(memcached_st
*memc
)
564 rc
= memcached_set(memc
, key
, strlen(key
),
565 value
, strlen(value
),
566 (time_t)0, (uint16_t)0);
567 assert(rc
== MEMCACHED_SUCCESS
);
569 rc
= memcached_increment(memc
, key
, strlen(key
),
571 assert(rc
== MEMCACHED_SUCCESS
);
572 assert(new_number
== 1);
574 rc
= memcached_increment(memc
, key
, strlen(key
),
576 assert(rc
== MEMCACHED_SUCCESS
);
577 assert(new_number
== 2);
582 uint8_t decrement_test(memcached_st
*memc
)
589 rc
= memcached_set(memc
, key
, strlen(key
),
590 value
, strlen(value
),
591 (time_t)0, (uint16_t)0);
592 assert(rc
== MEMCACHED_SUCCESS
);
594 rc
= memcached_decrement(memc
, key
, strlen(key
),
596 assert(rc
== MEMCACHED_SUCCESS
);
597 assert(new_number
== 2);
599 rc
= memcached_decrement(memc
, key
, strlen(key
),
601 assert(rc
== MEMCACHED_SUCCESS
);
602 assert(new_number
== 1);
607 uint8_t quit_test(memcached_st
*memc
)
611 char *value
= "sanford and sun";
613 rc
= memcached_set(memc
, key
, strlen(key
),
614 value
, strlen(value
),
615 (time_t)10, (uint16_t)3);
616 assert(rc
== MEMCACHED_SUCCESS
);
617 memcached_quit(memc
);
619 rc
= memcached_set(memc
, key
, strlen(key
),
620 value
, strlen(value
),
621 (time_t)50, (uint16_t)9);
622 assert(rc
== MEMCACHED_SUCCESS
);
627 uint8_t mget_result_test(memcached_st
*memc
)
630 char *keys
[]= {"fudge", "son", "food"};
631 size_t key_length
[]= {5, 3, 4};
634 memcached_result_st results_obj
;
635 memcached_result_st
*results
;
637 results
= memcached_result_create(memc
, &results_obj
);
639 assert(&results_obj
== results
);
641 /* We need to empty the server before continueing test */
642 rc
= memcached_flush(memc
, 0);
643 assert(rc
== MEMCACHED_SUCCESS
);
645 rc
= memcached_mget(memc
, keys
, key_length
, 3);
646 assert(rc
== MEMCACHED_SUCCESS
);
648 while ((results
= memcached_fetch_result(memc
, &results_obj
, &rc
)) != NULL
)
653 while ((results
= memcached_fetch_result(memc
, &results_obj
, &rc
)) != NULL
)
655 assert(rc
== MEMCACHED_NOTFOUND
);
657 for (x
= 0; x
< 3; x
++)
659 rc
= memcached_set(memc
, keys
[x
], key_length
[x
],
660 keys
[x
], key_length
[x
],
661 (time_t)50, (uint16_t)9);
662 assert(rc
== MEMCACHED_SUCCESS
);
665 rc
= memcached_mget(memc
, keys
, key_length
, 3);
666 assert(rc
== MEMCACHED_SUCCESS
);
668 while ((results
= memcached_fetch_result(memc
, &results_obj
, &rc
)))
671 assert(&results_obj
== results
);
672 assert(rc
== MEMCACHED_SUCCESS
);
673 assert(memcached_result_key_length(results
) == memcached_result_length(results
));
674 assert(!memcmp(memcached_result_key_value(results
),
675 memcached_result_value(results
),
676 memcached_result_length(results
)));
679 memcached_result_free(&results_obj
);
684 uint8_t mget_result_alloc_test(memcached_st
*memc
)
687 char *keys
[]= {"fudge", "son", "food"};
688 size_t key_length
[]= {5, 3, 4};
691 memcached_result_st
*results
;
693 /* We need to empty the server before continueing test */
694 rc
= memcached_flush(memc
, 0);
695 assert(rc
== MEMCACHED_SUCCESS
);
697 rc
= memcached_mget(memc
, keys
, key_length
, 3);
698 assert(rc
== MEMCACHED_SUCCESS
);
700 while ((results
= memcached_fetch_result(memc
, NULL
, &rc
)) != NULL
)
705 assert(rc
== MEMCACHED_NOTFOUND
);
707 for (x
= 0; x
< 3; x
++)
709 rc
= memcached_set(memc
, keys
[x
], key_length
[x
],
710 keys
[x
], key_length
[x
],
711 (time_t)50, (uint16_t)9);
712 assert(rc
== MEMCACHED_SUCCESS
);
715 rc
= memcached_mget(memc
, keys
, key_length
, 3);
716 assert(rc
== MEMCACHED_SUCCESS
);
719 while ((results
= memcached_fetch_result(memc
, NULL
, &rc
)))
722 assert(rc
== MEMCACHED_SUCCESS
);
723 assert(memcached_result_key_length(results
) == memcached_result_length(results
));
724 assert(!memcmp(memcached_result_key_value(results
),
725 memcached_result_value(results
),
726 memcached_result_length(results
)));
727 memcached_result_free(results
);
734 uint8_t mget_test(memcached_st
*memc
)
737 char *keys
[]= {"fudge", "son", "food"};
738 size_t key_length
[]= {5, 3, 4};
742 char return_key
[MEMCACHED_MAX_KEY
];
743 size_t return_key_length
;
745 size_t return_value_length
;
747 /* We need to empty the server before continueing test */
748 rc
= memcached_flush(memc
, 0);
749 assert(rc
== MEMCACHED_SUCCESS
);
751 rc
= memcached_mget(memc
, keys
, key_length
, 3);
752 assert(rc
== MEMCACHED_SUCCESS
);
754 while ((return_value
= memcached_fetch(memc
, return_key
, &return_key_length
,
755 &return_value_length
, &flags
, &rc
)) != NULL
)
757 assert(return_value
);
759 assert(!return_value
);
760 assert(return_value_length
== 0);
761 assert(rc
== MEMCACHED_NOTFOUND
);
763 for (x
= 0; x
< 3; x
++)
765 rc
= memcached_set(memc
, keys
[x
], key_length
[x
],
766 keys
[x
], key_length
[x
],
767 (time_t)50, (uint16_t)9);
768 assert(rc
== MEMCACHED_SUCCESS
);
771 rc
= memcached_mget(memc
, keys
, key_length
, 3);
772 assert(rc
== MEMCACHED_SUCCESS
);
775 while ((return_value
= memcached_fetch(memc
, return_key
, &return_key_length
,
776 &return_value_length
, &flags
, &rc
)))
778 assert(return_value
);
779 assert(rc
== MEMCACHED_SUCCESS
);
780 assert(return_key_length
== return_value_length
);
781 assert(!memcmp(return_value
, return_key
, return_value_length
));
789 uint8_t get_stats_keys(memcached_st
*memc
)
793 memcached_stat_st stat
;
796 list
= memcached_stat_get_keys(memc
, &stat
, &rc
);
797 assert(rc
== MEMCACHED_SUCCESS
);
798 for (ptr
= list
; *ptr
; ptr
++)
799 printf("Found key %s\n", *ptr
);
807 uint8_t get_stats(memcached_st
*memc
)
813 memcached_stat_st
*stat
;
815 stat
= memcached_stat(memc
, NULL
, &rc
);
816 assert(rc
== MEMCACHED_SUCCESS
);
818 assert(rc
== MEMCACHED_SUCCESS
);
821 for (x
= 0; x
< memcached_server_count(memc
); x
++)
823 list
= memcached_stat_get_keys(memc
, &stat
[x
], &rc
);
824 assert(rc
== MEMCACHED_SUCCESS
);
825 for (ptr
= list
; *ptr
; ptr
++)
826 printf("Found key %s\n", *ptr
);
831 memcached_stat_free(NULL
, stat
);
836 uint8_t add_host_test(memcached_st
*memc
)
839 memcached_server_st
*servers
;
841 char servername
[]= "0.example.com";
843 servers
= memcached_server_list_append(NULL
, servername
, 400, &rc
);
845 assert(1 == memcached_server_list_count(servers
));
847 for (x
= 2; x
< 20; x
++)
849 char buffer
[SMALL_STRING_LEN
];
851 snprintf(buffer
, SMALL_STRING_LEN
, "%u.example.com", 400+x
);
852 servers
= memcached_server_list_append(servers
, buffer
, 401,
854 assert(rc
== MEMCACHED_SUCCESS
);
855 assert(x
== memcached_server_list_count(servers
));
858 rc
= memcached_server_push(memc
, servers
);
859 assert(rc
== MEMCACHED_SUCCESS
);
860 rc
= memcached_server_push(memc
, servers
);
861 assert(rc
== MEMCACHED_SUCCESS
);
863 memcached_server_list_free(servers
);
868 /* We don't test the behavior itself, we test the switches */
869 uint8_t behavior_test(memcached_st
*memc
)
871 unsigned long long value
;
874 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_NO_BLOCK
, &set
);
875 value
= memcached_behavior_get(memc
, MEMCACHED_BEHAVIOR_NO_BLOCK
);
878 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_TCP_NODELAY
, &set
);
879 value
= memcached_behavior_get(memc
, MEMCACHED_BEHAVIOR_TCP_NODELAY
);
882 set
= MEMCACHED_HASH_MD5
;
883 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_HASH
, &set
);
884 value
= memcached_behavior_get(memc
, MEMCACHED_BEHAVIOR_HASH
);
885 assert(value
== MEMCACHED_HASH_MD5
);
889 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_NO_BLOCK
, &set
);
890 value
= memcached_behavior_get(memc
, MEMCACHED_BEHAVIOR_NO_BLOCK
);
893 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_TCP_NODELAY
, &set
);
894 value
= memcached_behavior_get(memc
, MEMCACHED_BEHAVIOR_TCP_NODELAY
);
897 set
= MEMCACHED_HASH_DEFAULT
;
898 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_HASH
, &set
);
899 value
= memcached_behavior_get(memc
, MEMCACHED_BEHAVIOR_HASH
);
900 assert(value
== MEMCACHED_HASH_DEFAULT
);
902 set
= MEMCACHED_HASH_CRC
;
903 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_HASH
, &set
);
904 value
= memcached_behavior_get(memc
, MEMCACHED_BEHAVIOR_HASH
);
905 assert(value
== MEMCACHED_HASH_CRC
);
907 value
= memcached_behavior_get(memc
, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE
);
910 value
= memcached_behavior_get(memc
, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE
);
916 /* Test case provided by Cal Haldenbrand */
917 uint8_t user_supplied_bug1(memcached_st
*memc
)
919 unsigned int setter
= 1;
922 unsigned long long total
= 0;
925 char randomstuff
[6 * 1024];
928 memset(randomstuff
, 0, 6 * 1024);
930 /* We just keep looking at the same values over and over */
933 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_NO_BLOCK
, &setter
);
934 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_TCP_NODELAY
, &setter
);
938 for (x
= 0 ; total
< 20 * 1024576 ; x
++ )
942 size
= (rand() % ( 5 * 1024 ) ) + 400;
943 memset(randomstuff
, 0, 6 * 1024);
944 assert(size
< 6 * 1024); /* Being safe here */
946 for (j
= 0 ; j
< size
;j
++)
947 randomstuff
[j
] = (char) (rand() % 26) + 97;
950 sprintf(key
, "%d", x
);
951 rc
= memcached_set(memc
, key
, strlen(key
),
952 randomstuff
, strlen(randomstuff
), 10, 0);
953 /* If we fail, lets try again */
954 if (rc
!= MEMCACHED_SUCCESS
)
955 rc
= memcached_set(memc
, key
, strlen(key
),
956 randomstuff
, strlen(randomstuff
), 10, 0);
957 assert(rc
== MEMCACHED_SUCCESS
);
963 /* Test case provided by Cal Haldenbrand */
964 uint8_t user_supplied_bug2(memcached_st
*memc
)
969 unsigned long long total
;
972 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_NO_BLOCK
, &setter
);
973 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_TCP_NODELAY
, &setter
);
975 setter
= 20 * 1024576;
976 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE
, &setter
);
977 setter
= 20 * 1024576;
978 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE
, &setter
);
979 getter
= memcached_behavior_get(memc
, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE
);
980 getter
= memcached_behavior_get(memc
, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE
);
982 for (x
= 0, errors
= 0, total
= 0 ; total
< 20 * 1024576 ; x
++)
985 for (x
= 0, errors
= 0, total
= 0 ; total
< 24576 ; x
++)
987 memcached_return rc
= MEMCACHED_SUCCESS
;
988 char buffer
[SMALL_STRING_LEN
];
993 memset(buffer
, 0, SMALL_STRING_LEN
);
995 snprintf(buffer
, SMALL_STRING_LEN
, "%u", x
);
996 getval
= memcached_get(memc
, buffer
, strlen(buffer
),
997 &val_len
, &flags
, &rc
);
998 if (rc
!= MEMCACHED_SUCCESS
)
1000 if (rc
== MEMCACHED_NOTFOUND
)
1015 /* Do a large mget() over all the keys we think exist */
1016 #define KEY_COUNT 3000 // * 1024576
1017 uint8_t user_supplied_bug3(memcached_st
*memc
)
1019 memcached_return rc
;
1020 unsigned int setter
;
1023 size_t key_lengths
[KEY_COUNT
];
1026 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_NO_BLOCK
, &setter
);
1027 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_TCP_NODELAY
, &setter
);
1029 setter
= 20 * 1024576;
1030 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE
, &setter
);
1031 setter
= 20 * 1024576;
1032 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE
, &setter
);
1033 getter
= memcached_behavior_get(memc
, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE
);
1034 getter
= memcached_behavior_get(memc
, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE
);
1037 keys
= (char **)malloc(sizeof(char *) * KEY_COUNT
);
1039 memset(keys
, 0, (sizeof(char *) * KEY_COUNT
));
1040 for (x
= 0; x
< KEY_COUNT
; x
++)
1044 snprintf(buffer
, 30, "%u", x
);
1045 keys
[x
]= strdup(buffer
);
1046 key_lengths
[x
]= strlen(keys
[x
]);
1049 rc
= memcached_mget(memc
, keys
, key_lengths
, KEY_COUNT
);
1050 assert(rc
== MEMCACHED_SUCCESS
);
1052 /* Turn this into a help function */
1054 char return_key
[MEMCACHED_MAX_KEY
];
1055 size_t return_key_length
;
1057 size_t return_value_length
;
1060 while ((return_value
= memcached_fetch(memc
, return_key
, &return_key_length
,
1061 &return_value_length
, &flags
, &rc
)))
1063 assert(return_value
);
1064 assert(rc
== MEMCACHED_SUCCESS
);
1069 for (x
= 0; x
< KEY_COUNT
; x
++)
1076 /* Make sure we behave properly if server list has no values */
1077 uint8_t user_supplied_bug4(memcached_st
*memc
)
1079 memcached_return rc
;
1080 char *keys
[]= {"fudge", "son", "food"};
1081 size_t key_length
[]= {5, 3, 4};
1085 /* Here we free everything before running a bunch of mget tests */
1087 memcached_server_list_free(memc
->hosts
);
1089 memc
->number_of_hosts
= 0;
1092 char return_key
[MEMCACHED_MAX_KEY
];
1093 size_t return_key_length
;
1095 size_t return_value_length
;
1097 /* We need to empty the server before continueing test */
1098 rc
= memcached_flush(memc
, 0);
1099 assert(rc
== MEMCACHED_NO_SERVERS
);
1101 rc
= memcached_mget(memc
, keys
, key_length
, 3);
1102 assert(rc
== MEMCACHED_NO_SERVERS
);
1104 while ((return_value
= memcached_fetch(memc
, return_key
, &return_key_length
,
1105 &return_value_length
, &flags
, &rc
)) != NULL
)
1107 assert(return_value
);
1109 assert(!return_value
);
1110 assert(return_value_length
== 0);
1111 assert(rc
== MEMCACHED_NO_SERVERS
);
1113 for (x
= 0; x
< 3; x
++)
1115 rc
= memcached_set(memc
, keys
[x
], key_length
[x
],
1116 keys
[x
], key_length
[x
],
1117 (time_t)50, (uint16_t)9);
1118 assert(rc
== MEMCACHED_NO_SERVERS
);
1121 rc
= memcached_mget(memc
, keys
, key_length
, 3);
1122 assert(rc
== MEMCACHED_NO_SERVERS
);
1125 while ((return_value
= memcached_fetch(memc
, return_key
, &return_key_length
,
1126 &return_value_length
, &flags
, &rc
)))
1128 assert(return_value
);
1129 assert(rc
== MEMCACHED_SUCCESS
);
1130 assert(return_key_length
== return_value_length
);
1131 assert(!memcmp(return_value
, return_key
, return_value_length
));
1139 #define VALUE_SIZE_BUG5 1048064
1140 uint8_t user_supplied_bug5(memcached_st
*memc
)
1142 memcached_return rc
;
1143 char *keys
[]= {"036790384900", "036790384902", "036790384904", "036790384906"};
1144 size_t key_length
[]= {strlen("036790384900"), strlen("036790384902"), strlen("036790384904"), strlen("036790384906")};
1145 char return_key
[MEMCACHED_MAX_KEY
];
1146 size_t return_key_length
;
1148 size_t value_length
;
1152 char insert_data
[VALUE_SIZE_BUG5
];
1154 for (x
= 0; x
< VALUE_SIZE_BUG5
; x
++)
1155 insert_data
[x
]= rand();
1157 memcached_flush(memc
, 0);
1158 value
= memcached_get(memc
, keys
[0], key_length
[0],
1159 &value_length
, &flags
, &rc
);
1160 assert(value
== NULL
);
1161 rc
= memcached_mget(memc
, keys
, key_length
, 4);
1164 while ((value
= memcached_fetch(memc
, return_key
, &return_key_length
,
1165 &value_length
, &flags
, &rc
)))
1169 for (x
= 0; x
< 4; x
++)
1171 rc
= memcached_set(memc
, keys
[x
], key_length
[x
],
1172 insert_data
, VALUE_SIZE_BUG5
,
1173 (time_t)0, (uint16_t)0);
1174 assert(rc
== MEMCACHED_SUCCESS
);
1177 for (x
= 0; x
< 10; x
++)
1179 value
= memcached_get(memc
, keys
[0], key_length
[0],
1180 &value_length
, &flags
, &rc
);
1184 rc
= memcached_mget(memc
, keys
, key_length
, 4);
1186 while ((value
= memcached_fetch(memc
, return_key
, &return_key_length
,
1187 &value_length
, &flags
, &rc
)))
1198 uint8_t user_supplied_bug6(memcached_st
*memc
)
1200 memcached_return rc
;
1201 char *keys
[]= {"036790384900", "036790384902", "036790384904", "036790384906"};
1202 size_t key_length
[]= {strlen("036790384900"), strlen("036790384902"), strlen("036790384904"), strlen("036790384906")};
1203 char return_key
[MEMCACHED_MAX_KEY
];
1204 size_t return_key_length
;
1206 size_t value_length
;
1210 char insert_data
[VALUE_SIZE_BUG5
];
1212 for (x
= 0; x
< VALUE_SIZE_BUG5
; x
++)
1213 insert_data
[x
]= rand();
1215 memcached_flush(memc
, 0);
1216 value
= memcached_get(memc
, keys
[0], key_length
[0],
1217 &value_length
, &flags
, &rc
);
1218 assert(value
== NULL
);
1219 rc
= memcached_mget(memc
, keys
, key_length
, 4);
1222 while ((value
= memcached_fetch(memc
, return_key
, &return_key_length
,
1223 &value_length
, &flags
, &rc
)))
1227 for (x
= 0; x
< 4; x
++)
1229 rc
= memcached_set(memc
, keys
[x
], key_length
[x
],
1230 insert_data
, VALUE_SIZE_BUG5
,
1231 (time_t)0, (uint16_t)0);
1232 assert(rc
== MEMCACHED_SUCCESS
);
1235 for (x
= 0; x
< 10; x
++)
1237 value
= memcached_get(memc
, keys
[0], key_length
[0],
1238 &value_length
, &flags
, &rc
);
1242 rc
= memcached_mget(memc
, keys
, key_length
, 4);
1244 /* We test for purge of partial complete fetches */
1245 for (count
= 3; count
; count
--)
1247 value
= memcached_fetch(memc
, return_key
, &return_key_length
,
1248 &value_length
, &flags
, &rc
);
1250 assert(rc
== MEMCACHED_SUCCESS
);
1257 /* Test flag store/retrieve */
1258 uint8_t user_supplied_bug7(memcached_st
*memc
)
1260 memcached_return rc
;
1261 char *keys
= "036790384900";
1262 size_t key_length
= strlen("036790384900");
1263 char return_key
[MEMCACHED_MAX_KEY
];
1264 size_t return_key_length
;
1266 size_t value_length
;
1269 char insert_data
[VALUE_SIZE_BUG5
];
1271 for (x
= 0; x
< VALUE_SIZE_BUG5
; x
++)
1272 insert_data
[x
]= rand();
1274 memcached_flush(memc
, 0);
1277 rc
= memcached_set(memc
, keys
, key_length
,
1278 insert_data
, VALUE_SIZE_BUG5
,
1280 assert(rc
== MEMCACHED_SUCCESS
);
1283 value
= memcached_get(memc
, keys
, key_length
,
1284 &value_length
, &flags
, &rc
);
1285 assert(flags
== 245);
1289 rc
= memcached_mget(memc
, &keys
, &key_length
, 1);
1292 value
= memcached_fetch(memc
, return_key
, &return_key_length
,
1293 &value_length
, &flags
, &rc
);
1294 assert(flags
== 245);
1302 uint8_t result_static(memcached_st
*memc
)
1304 memcached_result_st result
;
1305 memcached_result_st
*result_ptr
;
1307 result_ptr
= memcached_result_create(memc
, &result
);
1308 assert(result
.is_allocated
== MEMCACHED_NOT_ALLOCATED
);
1310 memcached_result_free(&result
);
1315 uint8_t result_alloc(memcached_st
*memc
)
1317 memcached_result_st
*result
;
1319 result
= memcached_result_create(memc
, NULL
);
1321 memcached_result_free(result
);
1326 uint8_t string_static_null(memcached_st
*memc
)
1328 memcached_string_st string
;
1329 memcached_string_st
*string_ptr
;
1331 string_ptr
= memcached_string_create(memc
, &string
, 0);
1332 assert(string
.is_allocated
== MEMCACHED_NOT_ALLOCATED
);
1334 memcached_string_free(&string
);
1339 uint8_t string_alloc_null(memcached_st
*memc
)
1341 memcached_string_st
*string
;
1343 string
= memcached_string_create(memc
, NULL
, 0);
1345 memcached_string_free(string
);
1350 uint8_t string_alloc_with_size(memcached_st
*memc
)
1352 memcached_string_st
*string
;
1354 string
= memcached_string_create(memc
, NULL
, 1024);
1356 memcached_string_free(string
);
1361 uint8_t string_alloc_with_size_toobig(memcached_st
*memc
)
1363 memcached_string_st
*string
;
1365 string
= memcached_string_create(memc
, NULL
, INT64_MAX
);
1366 assert(string
== NULL
);
1371 uint8_t string_alloc_append(memcached_st
*memc
)
1374 char buffer
[SMALL_STRING_LEN
];
1375 memcached_string_st
*string
;
1377 /* Ring the bell! */
1378 memset(buffer
, 6, SMALL_STRING_LEN
);
1380 string
= memcached_string_create(memc
, NULL
, 100);
1383 for (x
= 0; x
< 1024; x
++)
1385 memcached_return rc
;
1386 rc
= memcached_string_append(string
, buffer
, SMALL_STRING_LEN
);
1387 assert(rc
== MEMCACHED_SUCCESS
);
1389 memcached_string_free(string
);
1394 uint8_t string_alloc_append_toobig(memcached_st
*memc
)
1396 memcached_return rc
;
1398 char buffer
[SMALL_STRING_LEN
];
1399 memcached_string_st
*string
;
1401 /* Ring the bell! */
1402 memset(buffer
, 6, SMALL_STRING_LEN
);
1404 string
= memcached_string_create(memc
, NULL
, 100);
1407 for (x
= 0; x
< 1024; x
++)
1409 rc
= memcached_string_append(string
, buffer
, SMALL_STRING_LEN
);
1410 assert(rc
== MEMCACHED_SUCCESS
);
1412 rc
= memcached_string_append(string
, buffer
, INT64_MAX
);
1413 assert(rc
== MEMCACHED_MEMORY_ALLOCATION_FAILURE
);
1414 memcached_string_free(string
);
1419 uint8_t cleanup_pairs(memcached_st
*memc
)
1421 pairs_free(global_pairs
);
1426 uint8_t generate_data(memcached_st
*memc
)
1428 unsigned long long x
;
1429 global_pairs
= pairs_generate(GLOBAL_COUNT
);
1430 execute_set(memc
, global_pairs
, GLOBAL_COUNT
);
1432 for (x
= 0; x
< GLOBAL_COUNT
; x
++)
1434 global_keys
[x
]= global_pairs
[x
].key
;
1435 global_keys_length
[x
]= global_pairs
[x
].key_length
;
1441 uint8_t get_read(memcached_st
*memc
)
1444 memcached_return rc
;
1448 size_t return_value_length
;
1451 for (x
= 0; x
< GLOBAL_COUNT
; x
++)
1453 return_value
= memcached_get(memc
, global_keys
[x
], global_keys_length
[x
],
1454 &return_value_length
, &flags
, &rc
);
1456 assert(return_value);
1457 assert(rc == MEMCACHED_SUCCESS);
1459 if (rc
== MEMCACHED_SUCCESS
&& return_value
)
1467 uint8_t mget_read(memcached_st
*memc
)
1469 memcached_return rc
;
1471 rc
= memcached_mget(memc
, global_keys
, global_keys_length
, GLOBAL_COUNT
);
1472 assert(rc
== MEMCACHED_SUCCESS
);
1473 /* Turn this into a help function */
1475 char return_key
[MEMCACHED_MAX_KEY
];
1476 size_t return_key_length
;
1478 size_t return_value_length
;
1481 while ((return_value
= memcached_fetch(memc
, return_key
, &return_key_length
,
1482 &return_value_length
, &flags
, &rc
)))
1484 assert(return_value
);
1485 assert(rc
== MEMCACHED_SUCCESS
);
1493 uint8_t mget_read_result(memcached_st
*memc
)
1495 memcached_return rc
;
1497 rc
= memcached_mget(memc
, global_keys
, global_keys_length
, GLOBAL_COUNT
);
1498 assert(rc
== MEMCACHED_SUCCESS
);
1499 /* Turn this into a help function */
1501 memcached_result_st results_obj
;
1502 memcached_result_st
*results
;
1504 results
= memcached_result_create(memc
, &results_obj
);
1506 while ((results
= memcached_fetch_result(memc
, &results_obj
, &rc
)))
1509 assert(rc
== MEMCACHED_SUCCESS
);
1512 memcached_result_free(&results_obj
);
1518 uint8_t free_data(memcached_st
*memc
)
1520 pairs_free(global_pairs
);
1525 uint8_t add_host_test1(memcached_st
*memc
)
1528 memcached_return rc
;
1529 char servername
[]= "0.example.com";
1530 memcached_server_st
*servers
;
1532 servers
= memcached_server_list_append(NULL
, servername
, 400, &rc
);
1534 assert(1 == memcached_server_list_count(servers
));
1536 for (x
= 2; x
< 20; x
++)
1538 char buffer
[SMALL_STRING_LEN
];
1540 snprintf(buffer
, SMALL_STRING_LEN
, "%u.example.com", 400+x
);
1541 servers
= memcached_server_list_append(servers
, buffer
, 401,
1543 assert(rc
== MEMCACHED_SUCCESS
);
1544 assert(x
== memcached_server_list_count(servers
));
1547 rc
= memcached_server_push(memc
, servers
);
1548 assert(rc
== MEMCACHED_SUCCESS
);
1549 rc
= memcached_server_push(memc
, servers
);
1550 assert(rc
== MEMCACHED_SUCCESS
);
1552 memcached_server_list_free(servers
);
1557 memcached_return
pre_nonblock(memcached_st
*memc
)
1559 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_NO_BLOCK
, NULL
);
1561 return MEMCACHED_SUCCESS
;
1564 memcached_return
pre_md5(memcached_st
*memc
)
1566 memcached_hash value
= MEMCACHED_HASH_MD5
;
1567 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_HASH
, &value
);
1569 return MEMCACHED_SUCCESS
;
1572 memcached_return
pre_crc(memcached_st
*memc
)
1574 memcached_hash value
= MEMCACHED_HASH_CRC
;
1575 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_HASH
, &value
);
1577 return MEMCACHED_SUCCESS
;
1580 memcached_return
pre_hash_fnv1_64(memcached_st
*memc
)
1582 memcached_hash value
= MEMCACHED_HASH_FNV1_64
;
1583 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_HASH
, &value
);
1585 return MEMCACHED_SUCCESS
;
1588 memcached_return
pre_hash_fnv1a_64(memcached_st
*memc
)
1590 memcached_hash value
= MEMCACHED_HASH_FNV1A_64
;
1591 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_HASH
, &value
);
1593 return MEMCACHED_SUCCESS
;
1596 memcached_return
pre_hash_fnv1_32(memcached_st
*memc
)
1598 memcached_hash value
= MEMCACHED_HASH_FNV1_32
;
1599 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_HASH
, &value
);
1601 return MEMCACHED_SUCCESS
;
1604 memcached_return
pre_hash_fnv1a_32(memcached_st
*memc
)
1606 memcached_hash value
= MEMCACHED_HASH_FNV1A_32
;
1607 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_HASH
, &value
);
1609 return MEMCACHED_SUCCESS
;
1612 memcached_return
pre_hash_ketama(memcached_st
*memc
)
1614 memcached_hash value
= MEMCACHED_HASH_KETAMA
;
1615 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_HASH
, &value
);
1617 return MEMCACHED_SUCCESS
;
1620 memcached_return
enable_cas(memcached_st
*memc
)
1622 unsigned int set
= 1;
1624 memcached_version(memc
);
1626 if (memc
->hosts
[0].major_version
>= 1 &&
1627 memc
->hosts
[0].minor_version
>= 2 &&
1628 memc
->hosts
[0].micro_version
>= 4)
1630 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_SUPPORT_CAS
, &set
);
1632 return MEMCACHED_SUCCESS
;
1635 return MEMCACHED_FAILURE
;
1638 memcached_return
check_for_1_2_3(memcached_st
*memc
)
1640 memcached_version(memc
);
1642 if (memc
->hosts
[0].major_version
>= 1 &&
1643 memc
->hosts
[0].minor_version
>= 2 &&
1644 memc
->hosts
[0].micro_version
>= 4)
1645 return MEMCACHED_SUCCESS
;
1647 return MEMCACHED_FAILURE
;
1650 memcached_return
pre_unix_socket(memcached_st
*memc
)
1652 memcached_return rc
;
1655 memcached_server_list_free(memc
->hosts
);
1657 memc
->number_of_hosts
= 0;
1659 if (stat("/tmp/memcached.socket", &buf
))
1660 return MEMCACHED_FAILURE
;
1662 rc
= memcached_server_add_unix_socket(memc
, "/tmp/memcached.socket");
1667 memcached_return
pre_udp(memcached_st
*memc
)
1669 memcached_return rc
;
1671 memcached_server_list_free(memc
->hosts
);
1673 memc
->number_of_hosts
= 0;
1676 return MEMCACHED_FAILURE
;
1678 rc
= memcached_server_add_udp(memc
, "localhost", MEMCACHED_DEFAULT_PORT
);
1683 memcached_return
pre_nodelay(memcached_st
*memc
)
1685 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_NO_BLOCK
, NULL
);
1686 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_TCP_NODELAY
, NULL
);
1688 return MEMCACHED_SUCCESS
;
1691 memcached_return
poll_timeout(memcached_st
*memc
)
1697 memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_POLL_TIMEOUT
, &timeout
);
1699 timeout
= (int32_t)memcached_behavior_get(memc
, MEMCACHED_BEHAVIOR_POLL_TIMEOUT
);
1701 assert(timeout
== 100);
1703 return MEMCACHED_SUCCESS
;
1707 /* Clean the server before beginning testing */
1709 {"flush", 0, flush_test
},
1710 {"init", 0, init_test
},
1711 {"allocation", 0, allocation_test
},
1712 {"clone_test", 0, clone_test
},
1713 {"error", 0, error_test
},
1714 {"set", 0, set_test
},
1715 {"set2", 0, set_test2
},
1716 {"set3", 0, set_test3
},
1717 {"add", 0, add_test
},
1718 {"replace", 0, replace_test
},
1719 {"delete", 1, delete_test
},
1720 {"get", 1, get_test
},
1721 {"get2", 0, get_test2
},
1722 {"get3", 0, get_test3
},
1723 {"get4", 0, get_test4
},
1724 {"stats_servername", 0, stats_servername_test
},
1725 {"increment", 0, increment_test
},
1726 {"decrement", 0, decrement_test
},
1727 {"quit", 0, quit_test
},
1728 {"mget", 1, mget_test
},
1729 {"mget_result", 1, mget_result_test
},
1730 {"mget_result_alloc", 1, mget_result_alloc_test
},
1731 {"get_stats", 0, get_stats
},
1732 {"add_host_test", 0, add_host_test
},
1733 {"get_stats_keys", 0, get_stats_keys
},
1734 {"behavior_test", 0, get_stats_keys
},
1738 test_st string_tests
[] ={
1739 {"string static with null", 0, string_static_null
},
1740 {"string alloc with null", 0, string_alloc_null
},
1741 {"string alloc with 1K", 0, string_alloc_with_size
},
1742 {"string alloc with malloc failure", 0, string_alloc_with_size_toobig
},
1743 {"string append", 0, string_alloc_append
},
1744 {"string append failure (too big)", 0, string_alloc_append_toobig
},
1748 test_st result_tests
[] ={
1749 {"result static", 0, result_static
},
1750 {"result alloc", 0, result_alloc
},
1754 test_st version_1_2_3
[] ={
1755 {"append", 0, append_test
},
1756 {"prepend", 0, prepend_test
},
1757 {"cas", 0, cas_test
},
1758 {"cas2", 0, cas2_test
},
1759 {"append_binary", 0, append_binary_test
},
1763 test_st user_tests
[] ={
1764 {"user_supplied_bug1", 0, user_supplied_bug1
},
1765 {"user_supplied_bug2", 0, user_supplied_bug2
},
1766 {"user_supplied_bug3", 0, user_supplied_bug3
},
1767 {"user_supplied_bug4", 0, user_supplied_bug4
},
1768 {"user_supplied_bug5", 1, user_supplied_bug5
},
1769 {"user_supplied_bug6", 1, user_supplied_bug6
},
1770 {"user_supplied_bug7", 1, user_supplied_bug7
},
1774 test_st generate_tests
[] ={
1775 {"generate_data", 0, generate_data
},
1776 {"get_read", 0, get_read
},
1777 {"mget_read", 0, mget_read
},
1778 {"mget_read_result", 0, mget_read_result
},
1779 {"cleanup", 0, cleanup_pairs
},
1784 collection_st collection
[] ={
1785 {"block", 0, 0, tests
},
1786 {"nonblock", pre_nonblock
, 0, tests
},
1787 {"nodelay", pre_nodelay
, 0, tests
},
1788 {"md5", pre_md5
, 0, tests
},
1789 {"crc", pre_crc
, 0, tests
},
1790 {"fnv1_64", pre_hash_fnv1_64
, 0, tests
},
1791 {"fnv1a_64", pre_hash_fnv1a_64
, 0, tests
},
1792 {"fnv1_32", pre_hash_fnv1_32
, 0, tests
},
1793 {"fnv1a_32", pre_hash_fnv1a_32
, 0, tests
},
1794 {"ketama", pre_hash_ketama
, 0, tests
},
1795 {"unix_socket", pre_unix_socket
, 0, tests
},
1796 {"unix_socket_nodelay", pre_nodelay
, 0, tests
},
1797 {"poll_timeout", poll_timeout
, 0, tests
},
1798 {"gets", enable_cas
, 0, tests
},
1799 // {"udp", pre_udp, 0, tests},
1800 {"version_1_2_3", check_for_1_2_3
, 0, version_1_2_3
},
1801 {"string", 0, 0, string_tests
},
1802 {"result", 0, 0, result_tests
},
1803 {"user", 0, 0, user_tests
},
1804 {"generate", 0, 0, generate_tests
},
1805 {"generate_nonblock", pre_nonblock
, 0, generate_tests
},
1809 collection_st
*gets_collections(void)