6 #include <memcached/engine.h>
8 #include "suite_stubs.h"
11 bool hasError =
false;
14 static const char *key =
"key";
28 testHarness.time_travel(amt);
33 ENGINE_STORE_OPERATION op) {
38 const void *cookie = NULL;
40 if (op == OPERATION_APPEND) {
42 }
else if (op == OPERATION_PREPEND) {
46 size_t vlen = strlen(value);
48 ENGINE_ERROR_CODE rv = ENGINE_SUCCESS;
53 assert(rv == ENGINE_SUCCESS);
61 memcpy(info.value[0].iov_base, value, vlen);
64 rv = h1->
store(h, cookie, it, &cas, op, 0);
66 hasError = rv != ENGINE_SUCCESS;
70 storeItem(h, h1, OPERATION_ADD);
74 storeItem(h, h1, OPERATION_APPEND);
80 hasError = h1->
arithmetic(h, NULL, key, strlen(key),
false,
false, 1, 0, expiry,
88 hasError = h1->
arithmetic(h, NULL, key, strlen(key),
false,
true, 1, 0, expiry,
94 storeItem(h, h1, OPERATION_PREPEND);
98 hasError = h1->
flush(h, NULL, 0);
102 hasError = h1->
remove(h, NULL, key, strlen(key), 0, 0) != ENGINE_SUCCESS;
106 storeItem(h, h1, OPERATION_SET);
112 hasError = h1->
arithmetic(h, NULL, key, strlen(key),
true,
false, 1, 0, expiry,
114 0) != ENGINE_SUCCESS;
120 hasError = h1->
arithmetic(h, NULL, key, strlen(key),
true,
true, 1, 0, expiry,
122 0) != ENGINE_SUCCESS;
128 ENGINE_ERROR_CODE rv = h1->
get(h, NULL, &i, key, strlen(key), 0);
129 assert(rv == ENGINE_SUCCESS);
135 char buf[info.value[0].iov_len + 1];
136 memcpy(
buf, info.value[0].iov_base, info.value[0].iov_len);
137 buf[
sizeof(
buf) - 1] = 0x00;
138 assert(info.nvalue == 1);
139 if (strlen(exp) > info.value[0].iov_len) {
140 fprintf(stderr,
"Expected at least %d bytes for ``%s'', got %d as ``%s''\n",
141 (
int)strlen(exp), exp, (
int)info.value[0].iov_len,
buf);
145 if (memcmp(info.value[0].iov_base, exp, strlen(exp)) != 0) {
146 fprintf(stderr,
"Expected ``%s'', got ``%s''\n", exp,
buf);
153 ENGINE_ERROR_CODE rv = h1->
get(h, NULL, &i, key, strlen(key), 0);
154 assert(rv == ENGINE_KEY_ENOENT);