-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflags.c
41 lines (35 loc) · 1.13 KB
/
flags.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "libmemc.h"
#include "libmemctest.h"
int main(int argc, char **argv)
{
test_init(argc, argv);
// start the server
struct memcached_process_handle* mchandle = new_memcached(0, "");
if (!mchandle) {
fprintf(stderr,"Could not start memcached process\n\n");
exit(0);
}
struct Memcache* memcache = libmemc_create(Automatic);
if (libmemc_add_server(memcache, "127.0.0.1", mchandle->port) == -1) {
fprintf(stderr,"Could not add server\n\n");
exit(0);
}
struct Item item = {0};
setItem(&item, 0, "foo", 3, 0, "fooval", 6, 0);
int flags[3] = {0, 123, 65535};
char ok_msg[50];
char not_ok_msg[50];
for (int i=0; i<3; i++) {
item.flags = flags[i];
ok_test(!libmemc_set(memcache, &item), "stored foo", "failed to store foo");
sprintf(ok_msg, "got flags %d back", flags[i]);
sprintf(not_ok_msg, "did not get flags %d back", flags[i]);
mem_get_is(memcache, &item, ok_msg, not_ok_msg);
}
libmemc_destroy(memcache);
test_report();
}