Added test for randomized reads
[m6w6/libmemcached] / tests / udp.c
1 /*
2 Sample test application.
3 */
4 #include <assert.h>
5 #include <libmemcached/memcached.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <sys/time.h>
10 #include <sys/types.h>
11 #include <sys/stat.h>
12 #include <unistd.h>
13 #include <time.h>
14 #include "test.h"
15 #include "server.h"
16
17 /* Prototypes */
18 test_return_t set_test(memcached_st *memc);
19 void *world_create(void);
20 void world_destroy(void *p);
21
22 test_return_t set_test(memcached_st *memc)
23 {
24 memcached_return rc;
25 const char *key= "foo";
26 const char *value= "when we sanitize";
27
28 rc= memcached_set(memc, key, strlen(key),
29 value, strlen(value),
30 (time_t)0, (uint32_t)0);
31 test_truth(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
32
33 return TEST_SUCCESS;
34 }
35
36 test_st tests[] ={
37 {"set", 1, set_test },
38 {0, 0, 0}
39 };
40
41 collection_st collection[] ={
42 {"udp", 0, 0, tests},
43 {0, 0, 0, 0}
44 };
45
46 #define SERVERS_TO_CREATE 1
47
48 void *world_create(void)
49 {
50 server_startup_st *construct;
51
52 construct= (server_startup_st *)malloc(sizeof(server_startup_st));
53 memset(construct, 0, sizeof(server_startup_st));
54 construct->count= SERVERS_TO_CREATE;
55 construct->udp= 1;
56 server_startup(construct);
57
58 return construct;
59 }
60
61 void world_destroy(void *p)
62 {
63 server_startup_st *construct= (server_startup_st *)p;
64 memcached_server_st *servers= (memcached_server_st *)construct->servers;
65 memcached_server_list_free(servers);
66
67 server_shutdown(construct);
68 free(construct);
69 }
70
71 void get_world(world_st *world)
72 {
73 world->collections= collection;
74 world->create= world_create;
75 world->destroy= world_destroy;
76 }