b6ad2065ed7f68efd4e5a9a0e32d7d116f8c646d
[awesomized/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 uint8_t set_test(memcached_st *memc)
18 {
19 memcached_return rc;
20 char *key= "foo";
21 char *value= "when we sanitize";
22
23 rc= memcached_set(memc, key, strlen(key),
24 value, strlen(value),
25 (time_t)0, (uint32_t)0);
26 assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
27
28 return 0;
29 }
30
31 test_st tests[] ={
32 {"set", 1, set_test },
33 {0, 0, 0}
34 };
35
36 collection_st collection[] ={
37 {"udp", 0, 0, tests},
38 {0, 0, 0, 0}
39 };
40
41 #define SERVERS_TO_CREATE 1
42
43 void *world_create(void)
44 {
45 server_startup_st *construct;
46
47 construct= (server_startup_st *)malloc(sizeof(server_startup_st));
48 memset(construct, 0, sizeof(server_startup_st));
49 construct->count= SERVERS_TO_CREATE;
50 construct->udp= 1;
51 server_startup(construct);
52
53 return construct;
54 }
55
56 void world_destroy(void *p)
57 {
58 server_startup_st *construct= (server_startup_st *)p;
59 memcached_server_st *servers= (memcached_server_st *)construct->servers;
60 memcached_server_list_free(servers);
61
62 server_shutdown(construct);
63 free(construct);
64 }
65
66 void get_world(world_st *world)
67 {
68 world->collections= collection;
69 world->create= world_create;
70 world->destroy= world_destroy;
71 }