X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=clients%2Fmemcapable.c;h=4b10777721754d8daf26c6ff2d013d9ad5c6c323;hb=b30880274b5b866db3780148eaf9bf36e09bb1fb;hp=0519f38c04a2676632f022ed876f7b31e818179e;hpb=90f605b1e1472f5c4400f862e4236be7670cae13;p=awesomized%2Flibmemcached diff --git a/clients/memcapable.c b/clients/memcapable.c index 0519f38c..4b107777 100644 --- a/clients/memcapable.c +++ b/clients/memcapable.c @@ -1,5 +1,6 @@ /* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */ #undef NDEBUG +#include "config.h" #include #include #include @@ -453,8 +454,8 @@ static void arithmetic_command(command *cmd, * @param cc the expected command * @param status the expected status */ -static enum test_return validate_response_header(response *rsp, - uint8_t cc, uint16_t status) +static enum test_return do_validate_response_header(response *rsp, + uint8_t cc, uint16_t status) { verify(rsp->plain.message.header.response.magic == PROTOCOL_BINARY_RES); verify(rsp->plain.message.header.response.opcode == cc); @@ -554,6 +555,14 @@ static enum test_return validate_response_header(response *rsp, return TEST_PASS; } +/* We call verify(validate_response_header), but that macro + * expects a boolean expression, and the function returns + * an enum.... Let's just create a macro to avoid cluttering + * the code with all of the == TEST_PASS ;-) + */ +#define validate_response_header(a,b,c) \ + do_validate_response_header(a,b,c) == TEST_PASS + static enum test_return test_binary_noop(void) { command cmd; @@ -621,6 +630,20 @@ static enum test_return test_binary_set_impl(const char* key, uint8_t cc) execute(test_binary_noop()); } + /* + * We need to get the current CAS id, and at this time we haven't + * verified that we have a working get + */ + if (cc == PROTOCOL_BINARY_CMD_SETQ) + { + cmd.set.message.header.request.opcode= PROTOCOL_BINARY_CMD_SET; + execute(resend_packet(&cmd)); + execute(recv_packet(&rsp)); + verify(validate_response_header(&rsp, PROTOCOL_BINARY_CMD_SET, + PROTOCOL_BINARY_RESPONSE_SUCCESS)); + cmd.set.message.header.request.opcode= PROTOCOL_BINARY_CMD_SETQ; + } + /* try to set with the correct CAS value */ cmd.plain.message.header.request.cas= htonll(rsp.plain.message.header.response.cas); @@ -1169,7 +1192,7 @@ int main(int argc, char **argv) fprintf(stderr, "Usage: %s [-h hostname] [-p port] [-c] [-v] [-t n]\n" "\t-c\tGenerate coredump if a test fails\n" "\t-v\tVerbose test output (print out the assertion)\n" - "\t-c n\tSet the timeout for io-operations to n seconds\n", + "\t-t n\tSet the timeout for io-operations to n seconds\n", argv[0]); return 1; }