MXS-2020 Replace ss[_info]_dassert with mxb_assert[_message]

This commit is contained in:
Johan Wikman
2018-08-22 09:59:02 +03:00
parent b1e405442f
commit 3f53eddbde
161 changed files with 1640 additions and 1643 deletions

View File

@ -109,9 +109,9 @@ void split_buffer(int n, int offset)
int len = gwbuf_length(buffer);
GWBUF* newbuf = gwbuf_split(&buffer, cutoff);
ss_info_dassert(buffer && newbuf, "Both buffers should be non-NULL");
ss_info_dassert(gwbuf_length(newbuf) == cutoff, "New buffer should be have correct length");
ss_info_dassert(gwbuf_length(buffer) == len - cutoff, "Old buffer should be have correct length");
mxb_assert_message(buffer && newbuf, "Both buffers should be non-NULL");
mxb_assert_message(gwbuf_length(newbuf) == cutoff, "New buffer should be have correct length");
mxb_assert_message(gwbuf_length(buffer) == len - cutoff, "Old buffer should be have correct length");
gwbuf_free(buffer);
gwbuf_free(newbuf);
}
@ -124,8 +124,8 @@ void consume_buffer(int n, int offset)
int len = gwbuf_length(buffer);
buffer = gwbuf_consume(buffer, cutoff);
ss_info_dassert(buffer, "Buffer should be non-NULL");
ss_info_dassert(gwbuf_length(buffer) == len - cutoff, "Buffer should be have correct length");
mxb_assert_message(buffer, "Buffer should be non-NULL");
mxb_assert_message(gwbuf_length(buffer) == len - cutoff, "Buffer should be have correct length");
gwbuf_free(buffer);
}
@ -138,8 +138,8 @@ void copy_buffer(int n, int offset)
uint8_t dest[cutoff];
memset(dest, 0, sizeof(dest));
ss_info_dassert(gwbuf_copy_data(buffer, 0, cutoff, dest) == cutoff, "All bytes should be read");
ss_info_dassert(memcmp(data, dest, sizeof(dest)) == 0, "Data should be OK");
mxb_assert_message(gwbuf_copy_data(buffer, 0, cutoff, dest) == cutoff, "All bytes should be read");
mxb_assert_message(memcmp(data, dest, sizeof(dest)) == 0, "Data should be OK");
gwbuf_free(buffer);
MXS_FREE(data);
}
@ -151,56 +151,56 @@ void test_split()
size_t tailsize = 20;
GWBUF* oldchain = gwbuf_append(gwbuf_alloc(headsize), gwbuf_alloc(tailsize));
ss_info_dassert(gwbuf_length(oldchain) == headsize + tailsize, "Allocated buffer should be 30 bytes");
mxb_assert_message(gwbuf_length(oldchain) == headsize + tailsize, "Allocated buffer should be 30 bytes");
GWBUF* newchain = gwbuf_split(&oldchain, headsize + 5);
ss_info_dassert(newchain && oldchain, "Both chains should be non-NULL");
ss_info_dassert(gwbuf_length(newchain) == headsize + 5, "New chain should be 15 bytes long");
ss_info_dassert(GWBUF_LENGTH(newchain) == headsize && GWBUF_LENGTH(newchain->next) == 5,
mxb_assert_message(newchain && oldchain, "Both chains should be non-NULL");
mxb_assert_message(gwbuf_length(newchain) == headsize + 5, "New chain should be 15 bytes long");
mxb_assert_message(GWBUF_LENGTH(newchain) == headsize && GWBUF_LENGTH(newchain->next) == 5,
"The new chain should have a 10 byte buffer and a 5 byte buffer");
ss_info_dassert(gwbuf_length(oldchain) == tailsize - 5, "Old chain should be 15 bytes long");
ss_info_dassert(GWBUF_LENGTH(oldchain) == tailsize - 5 && oldchain->next == NULL,
mxb_assert_message(gwbuf_length(oldchain) == tailsize - 5, "Old chain should be 15 bytes long");
mxb_assert_message(GWBUF_LENGTH(oldchain) == tailsize - 5 && oldchain->next == NULL,
"The old chain should have a 15 byte buffer and no next buffer");
gwbuf_free(oldchain);
gwbuf_free(newchain);
oldchain = gwbuf_append(gwbuf_alloc(headsize), gwbuf_alloc(tailsize));
newchain = gwbuf_split(&oldchain, headsize);
ss_info_dassert(gwbuf_length(newchain) == headsize, "New chain should be 10 bytes long");
ss_info_dassert(gwbuf_length(oldchain) == tailsize, "Old chain should be 20 bytes long");
ss_info_dassert(oldchain->tail == oldchain, "Old chain tail should point to old chain");
ss_info_dassert(oldchain->next == NULL, "Old chain should not have next buffer");
ss_info_dassert(newchain->tail == newchain, "Old chain tail should point to old chain");
ss_info_dassert(newchain->next == NULL, "new chain should not have next buffer");
mxb_assert_message(gwbuf_length(newchain) == headsize, "New chain should be 10 bytes long");
mxb_assert_message(gwbuf_length(oldchain) == tailsize, "Old chain should be 20 bytes long");
mxb_assert_message(oldchain->tail == oldchain, "Old chain tail should point to old chain");
mxb_assert_message(oldchain->next == NULL, "Old chain should not have next buffer");
mxb_assert_message(newchain->tail == newchain, "Old chain tail should point to old chain");
mxb_assert_message(newchain->next == NULL, "new chain should not have next buffer");
gwbuf_free(oldchain);
gwbuf_free(newchain);
oldchain = gwbuf_append(gwbuf_alloc(headsize), gwbuf_alloc(tailsize));
newchain = gwbuf_split(&oldchain, headsize + tailsize);
ss_info_dassert(newchain, "New chain should be non-NULL");
ss_info_dassert(gwbuf_length(newchain) == headsize + tailsize, "New chain should be 30 bytes long");
ss_info_dassert(oldchain == NULL, "Old chain should be NULL");
mxb_assert_message(newchain, "New chain should be non-NULL");
mxb_assert_message(gwbuf_length(newchain) == headsize + tailsize, "New chain should be 30 bytes long");
mxb_assert_message(oldchain == NULL, "Old chain should be NULL");
gwbuf_free(newchain);
/** Splitting of contiguous memory */
GWBUF* buffer = gwbuf_alloc(10);
GWBUF* newbuf = gwbuf_split(&buffer, 5);
ss_info_dassert(buffer != newbuf, "gwbuf_split should return different pointers");
ss_info_dassert(gwbuf_length(buffer) == 5 && GWBUF_LENGTH(buffer) == 5, "Old buffer should be 5 bytes");
ss_info_dassert(gwbuf_length(newbuf) == 5 && GWBUF_LENGTH(newbuf) == 5, "New buffer should be 5 bytes");
ss_info_dassert(buffer->tail == buffer, "Old buffer's tail should point to itself");
ss_info_dassert(newbuf->tail == newbuf, "New buffer's tail should point to itself");
ss_info_dassert(buffer->next == NULL, "Old buffer's next pointer should be NULL");
ss_info_dassert(newbuf->next == NULL, "New buffer's next pointer should be NULL");
mxb_assert_message(buffer != newbuf, "gwbuf_split should return different pointers");
mxb_assert_message(gwbuf_length(buffer) == 5 && GWBUF_LENGTH(buffer) == 5, "Old buffer should be 5 bytes");
mxb_assert_message(gwbuf_length(newbuf) == 5 && GWBUF_LENGTH(newbuf) == 5, "New buffer should be 5 bytes");
mxb_assert_message(buffer->tail == buffer, "Old buffer's tail should point to itself");
mxb_assert_message(newbuf->tail == newbuf, "New buffer's tail should point to itself");
mxb_assert_message(buffer->next == NULL, "Old buffer's next pointer should be NULL");
mxb_assert_message(newbuf->next == NULL, "New buffer's next pointer should be NULL");
gwbuf_free(buffer);
gwbuf_free(newbuf);
/** Bad parameter tests */
GWBUF* ptr = NULL;
ss_info_dassert(gwbuf_split(NULL, 0) == NULL, "gwbuf_split with NULL parameter should return NULL");
ss_info_dassert(gwbuf_split(&ptr, 0) == NULL, "gwbuf_split with pointer to a NULL value should return NULL");
mxb_assert_message(gwbuf_split(NULL, 0) == NULL, "gwbuf_split with NULL parameter should return NULL");
mxb_assert_message(gwbuf_split(&ptr, 0) == NULL, "gwbuf_split with pointer to a NULL value should return NULL");
buffer = gwbuf_alloc(10);
ss_info_dassert(gwbuf_split(&buffer, 0) == NULL, "gwbuf_split with length of 0 should return NULL");
ss_info_dassert(gwbuf_length(buffer) == 10, "Buffer should be 10 bytes");
mxb_assert_message(gwbuf_split(&buffer, 0) == NULL, "gwbuf_split with length of 0 should return NULL");
mxb_assert_message(gwbuf_length(buffer) == 10, "Buffer should be 10 bytes");
gwbuf_free(buffer);
/** Splitting near buffer boudaries */
@ -223,45 +223,45 @@ void test_load_and_copy()
GWBUF* head = gwbuf_alloc_and_load(4, data);
GWBUF* tail = gwbuf_alloc_and_load(4, data + 4);
ss_info_dassert(memcmp(GWBUF_DATA(head), data, 4) == 0, "Loading 4 bytes should succeed");
ss_info_dassert(memcmp(GWBUF_DATA(tail), data + 4, 4) == 0, "Loading 4 bytes should succeed");
mxb_assert_message(memcmp(GWBUF_DATA(head), data, 4) == 0, "Loading 4 bytes should succeed");
mxb_assert_message(memcmp(GWBUF_DATA(tail), data + 4, 4) == 0, "Loading 4 bytes should succeed");
memset(dest, 0, sizeof(dest));
ss_info_dassert(gwbuf_copy_data(head, 0, 4, dest) == 4, "Copying 4 bytes should succeed");
ss_info_dassert(memcmp(dest, data, 4) == 0, "Copied data should be from 1 to 4");
mxb_assert_message(gwbuf_copy_data(head, 0, 4, dest) == 4, "Copying 4 bytes should succeed");
mxb_assert_message(memcmp(dest, data, 4) == 0, "Copied data should be from 1 to 4");
memset(dest, 0, sizeof(dest));
ss_info_dassert(gwbuf_copy_data(tail, 0, 4, dest) == 4, "Copying 4 bytes should succeed");
ss_info_dassert(memcmp(dest, data + 4, 4) == 0, "Copied data should be from 5 to 8");
mxb_assert_message(gwbuf_copy_data(tail, 0, 4, dest) == 4, "Copying 4 bytes should succeed");
mxb_assert_message(memcmp(dest, data + 4, 4) == 0, "Copied data should be from 5 to 8");
head = gwbuf_append(head, tail);
memset(dest, 0, sizeof(dest));
ss_info_dassert(gwbuf_copy_data(head, 0, 8, dest) == 8, "Copying 8 bytes should succeed");
ss_info_dassert(memcmp(dest, data, 8) == 0, "Copied data should be from 1 to 8");
mxb_assert_message(gwbuf_copy_data(head, 0, 8, dest) == 8, "Copying 8 bytes should succeed");
mxb_assert_message(memcmp(dest, data, 8) == 0, "Copied data should be from 1 to 8");
memset(dest, 0, sizeof(dest));
ss_info_dassert(gwbuf_copy_data(head, 4, 4, dest) == 4, "Copying 4 bytes at offset 4 should succeed");
ss_info_dassert(memcmp(dest, data + 4, 4) == 0, "Copied data should be from 5 to 8");
mxb_assert_message(gwbuf_copy_data(head, 4, 4, dest) == 4, "Copying 4 bytes at offset 4 should succeed");
mxb_assert_message(memcmp(dest, data + 4, 4) == 0, "Copied data should be from 5 to 8");
memset(dest, 0, sizeof(dest));
ss_info_dassert(gwbuf_copy_data(head, 2, 4, dest) == 4, "Copying 4 bytes at offset 2 should succeed");
ss_info_dassert(memcmp(dest, data + 2, 4) == 0, "Copied data should be from 5 to 8");
mxb_assert_message(gwbuf_copy_data(head, 2, 4, dest) == 4, "Copying 4 bytes at offset 2 should succeed");
mxb_assert_message(memcmp(dest, data + 2, 4) == 0, "Copied data should be from 5 to 8");
memset(dest, 0, sizeof(dest));
ss_info_dassert(gwbuf_copy_data(head, 0, 10, dest) == 8, "Copying 10 bytes should only copy 8 bytes");
ss_info_dassert(memcmp(dest, data, 8) == 0, "Copied data should be from 1 to 8");
mxb_assert_message(gwbuf_copy_data(head, 0, 10, dest) == 8, "Copying 10 bytes should only copy 8 bytes");
mxb_assert_message(memcmp(dest, data, 8) == 0, "Copied data should be from 1 to 8");
memset(dest, 0, sizeof(dest));
ss_info_dassert(gwbuf_copy_data(head, 0, 0, dest) == 0, "Copying 0 bytes should not copy any bytes");
mxb_assert_message(gwbuf_copy_data(head, 0, 0, dest) == 0, "Copying 0 bytes should not copy any bytes");
memset(dest, 0, sizeof(dest));
ss_info_dassert(gwbuf_copy_data(head, 0, -1, dest) == sizeof(data),
mxb_assert_message(gwbuf_copy_data(head, 0, -1, dest) == sizeof(data),
"Copying -1 bytes should copy all available data (cast to unsigned)");
ss_info_dassert(memcmp(dest, data, 8) == 0, "Copied data should be from 1 to 8");
mxb_assert_message(memcmp(dest, data, 8) == 0, "Copied data should be from 1 to 8");
ss_info_dassert(gwbuf_copy_data(head, -1, -1, dest) == 0,
mxb_assert_message(gwbuf_copy_data(head, -1, -1, dest) == 0,
"Copying -1 bytes at an offset of -1 should not copy any bytes");
ss_info_dassert(gwbuf_copy_data(head, -1, 0, dest) == 0,
mxb_assert_message(gwbuf_copy_data(head, -1, 0, dest) == 0,
"Copying 0 bytes at an offset of -1 should not copy any bytes");
gwbuf_free(head);
@ -283,27 +283,27 @@ void test_consume()
GWBUF* buffer = gwbuf_append(gwbuf_alloc_and_load(5, data),
gwbuf_alloc_and_load(5, data + 5));
ss_info_dassert(gwbuf_consume(buffer, 0) == buffer,
mxb_assert_message(gwbuf_consume(buffer, 0) == buffer,
"Consuming 0 bytes from a buffer should return original buffer");
ss_info_dassert(gwbuf_length(buffer) == 10, "Buffer should be 10 bytes after consuming 0 bytes");
mxb_assert_message(gwbuf_length(buffer) == 10, "Buffer should be 10 bytes after consuming 0 bytes");
buffer = gwbuf_consume(buffer, 1);
ss_info_dassert(GWBUF_LENGTH(buffer) == 4, "First buffer should be 4 bytes long");
ss_info_dassert(buffer->next, "Buffer should have next pointer set");
ss_info_dassert(GWBUF_LENGTH(buffer->next) == 5, "Next buffer should be 5 bytes long");
ss_info_dassert(gwbuf_length(buffer) == 9, "Buffer should be 9 bytes after consuming 1 bytes");
ss_info_dassert(*((uint8_t*)buffer->start) == 2, "First byte should be 2");
mxb_assert_message(GWBUF_LENGTH(buffer) == 4, "First buffer should be 4 bytes long");
mxb_assert_message(buffer->next, "Buffer should have next pointer set");
mxb_assert_message(GWBUF_LENGTH(buffer->next) == 5, "Next buffer should be 5 bytes long");
mxb_assert_message(gwbuf_length(buffer) == 9, "Buffer should be 9 bytes after consuming 1 bytes");
mxb_assert_message(*((uint8_t*)buffer->start) == 2, "First byte should be 2");
buffer = gwbuf_consume(buffer, 5);
ss_info_dassert(buffer->next == NULL, "Buffer should not have the next pointer set");
ss_info_dassert(GWBUF_LENGTH(buffer) == 4, "Buffer should be 4 bytes after consuming 6 bytes");
ss_info_dassert(gwbuf_length(buffer) == 4, "Buffer should be 4 bytes after consuming 6 bytes");
ss_info_dassert(*((uint8_t*)buffer->start) == 7, "First byte should be 7");
ss_info_dassert(gwbuf_consume(buffer, 4) == NULL, "Consuming all bytes should return NULL");
mxb_assert_message(buffer->next == NULL, "Buffer should not have the next pointer set");
mxb_assert_message(GWBUF_LENGTH(buffer) == 4, "Buffer should be 4 bytes after consuming 6 bytes");
mxb_assert_message(gwbuf_length(buffer) == 4, "Buffer should be 4 bytes after consuming 6 bytes");
mxb_assert_message(*((uint8_t*)buffer->start) == 7, "First byte should be 7");
mxb_assert_message(gwbuf_consume(buffer, 4) == NULL, "Consuming all bytes should return NULL");
buffer = gwbuf_append(gwbuf_alloc_and_load(5, data),
gwbuf_alloc_and_load(5, data + 5));
ss_info_dassert(gwbuf_consume(buffer, 100) == NULL,
mxb_assert_message(gwbuf_consume(buffer, 100) == NULL,
"Consuming more bytes than are available should return NULL");
@ -329,26 +329,26 @@ void test_compare()
GWBUF* rhs = NULL;
// Both NULL
ss_dassert(gwbuf_compare(lhs, rhs) == 0);
mxb_assert(gwbuf_compare(lhs, rhs) == 0);
// Either (but not both) NULL
lhs = gwbuf_alloc_and_load(10, data);
ss_dassert(gwbuf_compare(lhs, rhs) > 0);
ss_dassert(gwbuf_compare(rhs, lhs) < 0);
mxb_assert(gwbuf_compare(lhs, rhs) > 0);
mxb_assert(gwbuf_compare(rhs, lhs) < 0);
// The same array
ss_dassert(gwbuf_compare(lhs, lhs) == 0);
mxb_assert(gwbuf_compare(lhs, lhs) == 0);
// Identical array
gwbuf_free(rhs);
rhs = gwbuf_alloc_and_load(10, data);
ss_dassert(gwbuf_compare(lhs, rhs) == 0);
mxb_assert(gwbuf_compare(lhs, rhs) == 0);
// One shorter
gwbuf_free(rhs);
rhs = gwbuf_alloc_and_load(9, data + 1);
ss_dassert(gwbuf_compare(lhs, rhs) > 0);
ss_dassert(gwbuf_compare(rhs, lhs) < 0);
mxb_assert(gwbuf_compare(lhs, rhs) > 0);
mxb_assert(gwbuf_compare(rhs, lhs) < 0);
// One segmented, but otherwise identical.
gwbuf_free(rhs);
@ -357,8 +357,8 @@ void test_compare()
rhs = gwbuf_append(rhs, gwbuf_alloc_and_load(3, data + 3));
rhs = gwbuf_append(rhs, gwbuf_alloc_and_load(4, data + 3 + 3));
ss_dassert(gwbuf_compare(lhs, rhs) == 0);
ss_dassert(gwbuf_compare(rhs, rhs) == 0);
mxb_assert(gwbuf_compare(lhs, rhs) == 0);
mxb_assert(gwbuf_compare(rhs, rhs) == 0);
// Both segmented, but otherwise identical.
gwbuf_free(lhs);
@ -366,8 +366,8 @@ void test_compare()
lhs = gwbuf_append(lhs, gwbuf_alloc_and_load(5, data));
lhs = gwbuf_append(lhs, gwbuf_alloc_and_load(5, data + 5));
ss_dassert(gwbuf_compare(lhs, rhs) == 0);
ss_dassert(gwbuf_compare(rhs, lhs) == 0);
mxb_assert(gwbuf_compare(lhs, rhs) == 0);
mxb_assert(gwbuf_compare(rhs, lhs) == 0);
// Both segmented and of same length, but different.
gwbuf_free(lhs);
@ -375,8 +375,8 @@ void test_compare()
lhs = gwbuf_append(lhs, gwbuf_alloc_and_load(5, data + 5)); // Values in different order
lhs = gwbuf_append(lhs, gwbuf_alloc_and_load(5, data));
ss_dassert(gwbuf_compare(lhs, rhs) > 0); // 5 > 1
ss_dassert(gwbuf_compare(rhs, lhs) < 0); // 5 > 1
mxb_assert(gwbuf_compare(lhs, rhs) > 0); // 5 > 1
mxb_assert(gwbuf_compare(rhs, lhs) < 0); // 5 > 1
// Identical, but one containing empty segments.
gwbuf_free(rhs);
@ -387,8 +387,8 @@ void test_compare()
rhs = gwbuf_append(rhs, gwbuf_alloc_and_load(5, data));
rhs = gwbuf_append(rhs, gwbuf_alloc_and_load(0, data));
ss_dassert(gwbuf_compare(lhs, rhs) == 0);
ss_dassert(gwbuf_compare(rhs, lhs) == 0);
mxb_assert(gwbuf_compare(lhs, rhs) == 0);
mxb_assert(gwbuf_compare(rhs, lhs) == 0);
gwbuf_free(lhs);
gwbuf_free(rhs);
@ -413,12 +413,12 @@ void test_clone()
GWBUF* o = original;
GWBUF* c = clone;
ss_dassert(gwbuf_length(o) == gwbuf_length(c));
mxb_assert(gwbuf_length(o) == gwbuf_length(c));
while (o)
{
ss_dassert(c);
ss_dassert(GWBUF_LENGTH(o) == GWBUF_LENGTH(c));
mxb_assert(c);
mxb_assert(GWBUF_LENGTH(o) == GWBUF_LENGTH(c));
const char* i = (char*)GWBUF_DATA(o);
const char* end = i + GWBUF_LENGTH(o);
@ -426,7 +426,7 @@ void test_clone()
while (i != end)
{
ss_dassert(*i == *j);
mxb_assert(*i == *j);
++i;
++j;
}
@ -435,7 +435,7 @@ void test_clone()
c = c->next;
}
ss_dassert(c == NULL);
mxb_assert(c == NULL);
gwbuf_free(clone);
gwbuf_free(original);
@ -464,48 +464,48 @@ test1()
fprintf(stderr, "\t..done\nAllocated buffer of size %lu.", size);
buflen = GWBUF_LENGTH(buffer);
fprintf(stderr, "\nBuffer length is now %lu", buflen);
ss_info_dassert(size == buflen, "Incorrect buffer size");
ss_info_dassert(0 == GWBUF_EMPTY(buffer), "Buffer should not be empty");
ss_info_dassert(GWBUF_IS_TYPE_UNDEFINED(buffer), "Buffer type should be undefined");
mxb_assert_message(size == buflen, "Incorrect buffer size");
mxb_assert_message(0 == GWBUF_EMPTY(buffer), "Buffer should not be empty");
mxb_assert_message(GWBUF_IS_TYPE_UNDEFINED(buffer), "Buffer type should be undefined");
fprintf(stderr, "\t..done\nSet a property for the buffer");
gwbuf_add_property(buffer, (char*)"name", (char*)"value");
ss_info_dassert(0 == strcmp("value", gwbuf_get_property(buffer, (char*)"name")),
mxb_assert_message(0 == strcmp("value", gwbuf_get_property(buffer, (char*)"name")),
"Should now have correct property");
strcpy((char*)GWBUF_DATA(buffer), "The quick brown fox jumps over the lazy dog");
fprintf(stderr, "\t..done\nLoad some data into the buffer");
ss_info_dassert('q' == GWBUF_DATA_CHAR(buffer, 4), "Fourth character of buffer must be 'q'");
ss_info_dassert(-1 == GWBUF_DATA_CHAR(buffer, 105), "Hundred and fifth character of buffer must return -1");
ss_info_dassert(0 == GWBUF_IS_SQL(buffer), "Must say buffer is not SQL, as it does not have marker");
mxb_assert_message('q' == GWBUF_DATA_CHAR(buffer, 4), "Fourth character of buffer must be 'q'");
mxb_assert_message(-1 == GWBUF_DATA_CHAR(buffer, 105), "Hundred and fifth character of buffer must return -1");
mxb_assert_message(0 == GWBUF_IS_SQL(buffer), "Must say buffer is not SQL, as it does not have marker");
strcpy((char*)GWBUF_DATA(buffer), "1234\x03SELECT * FROM sometable");
fprintf(stderr, "\t..done\nLoad SQL data into the buffer");
ss_info_dassert(1 == GWBUF_IS_SQL(buffer), "Must say buffer is SQL, as it does have marker");
mxb_assert_message(1 == GWBUF_IS_SQL(buffer), "Must say buffer is SQL, as it does have marker");
clone = gwbuf_clone(buffer);
fprintf(stderr, "\t..done\nCloned buffer");
buflen = GWBUF_LENGTH(clone);
fprintf(stderr, "\nCloned buffer length is now %lu", buflen);
ss_info_dassert(size == buflen, "Incorrect buffer size");
ss_info_dassert(0 == GWBUF_EMPTY(clone), "Cloned buffer should not be empty");
mxb_assert_message(size == buflen, "Incorrect buffer size");
mxb_assert_message(0 == GWBUF_EMPTY(clone), "Cloned buffer should not be empty");
fprintf(stderr, "\t..done\n");
gwbuf_free(clone);
fprintf(stderr, "Freed cloned buffer");
fprintf(stderr, "\t..done\n");
buffer = gwbuf_consume(buffer, bite1);
ss_info_dassert(NULL != buffer, "Buffer should not be null");
mxb_assert_message(NULL != buffer, "Buffer should not be null");
buflen = GWBUF_LENGTH(buffer);
fprintf(stderr, "Consumed %lu bytes, now have %lu, should have %lu", bite1, buflen, size - bite1);
ss_info_dassert((size - bite1) == buflen, "Incorrect buffer size");
ss_info_dassert(0 == GWBUF_EMPTY(buffer), "Buffer should not be empty");
mxb_assert_message((size - bite1) == buflen, "Incorrect buffer size");
mxb_assert_message(0 == GWBUF_EMPTY(buffer), "Buffer should not be empty");
fprintf(stderr, "\t..done\n");
buffer = gwbuf_consume(buffer, bite2);
ss_info_dassert(NULL != buffer, "Buffer should not be null");
mxb_assert_message(NULL != buffer, "Buffer should not be null");
buflen = GWBUF_LENGTH(buffer);
fprintf(stderr, "Consumed %lu bytes, now have %lu, should have %lu", bite2, buflen, size - bite1 - bite2);
ss_info_dassert((size - bite1 - bite2) == buflen, "Incorrect buffer size");
ss_info_dassert(0 == GWBUF_EMPTY(buffer), "Buffer should not be empty");
mxb_assert_message((size - bite1 - bite2) == buflen, "Incorrect buffer size");
mxb_assert_message(0 == GWBUF_EMPTY(buffer), "Buffer should not be empty");
fprintf(stderr, "\t..done\n");
buffer = gwbuf_consume(buffer, bite3);
fprintf(stderr, "Consumed %lu bytes, should have null buffer", bite3);
ss_info_dassert(NULL == buffer, "Buffer should be null");
mxb_assert_message(NULL == buffer, "Buffer should be null");
/* Buffer list tests */
size = 100000;
@ -513,26 +513,26 @@ test1()
fprintf(stderr, "\t..done\nAllocated buffer of size %lu.", size);
buflen = GWBUF_LENGTH(buffer);
fprintf(stderr, "\nBuffer length is now %lu", buflen);
ss_info_dassert(size == buflen, "Incorrect buffer size");
ss_info_dassert(0 == GWBUF_EMPTY(buffer), "Buffer should not be empty");
ss_info_dassert(GWBUF_IS_TYPE_UNDEFINED(buffer), "Buffer type should be undefined");
mxb_assert_message(size == buflen, "Incorrect buffer size");
mxb_assert_message(0 == GWBUF_EMPTY(buffer), "Buffer should not be empty");
mxb_assert_message(GWBUF_IS_TYPE_UNDEFINED(buffer), "Buffer type should be undefined");
extra = gwbuf_alloc(size);
buflen = GWBUF_LENGTH(buffer);
fprintf(stderr, "\t..done\nAllocated extra buffer of size %lu.", size);
ss_info_dassert(size == buflen, "Incorrect buffer size");
mxb_assert_message(size == buflen, "Incorrect buffer size");
buffer = gwbuf_append(buffer, extra);
buflen = gwbuf_length(buffer);
fprintf(stderr, "\t..done\nAppended extra buffer to original buffer to create list of size %lu", buflen);
ss_info_dassert((size * 2) == gwbuf_length(buffer), "Incorrect size for set of buffers");
mxb_assert_message((size * 2) == gwbuf_length(buffer), "Incorrect size for set of buffers");
buffer = gwbuf_rtrim(buffer, 60000);
buflen = GWBUF_LENGTH(buffer);
fprintf(stderr, "\t..done\nTrimmed 60 bytes from buffer, now size is %lu.", buflen);
ss_info_dassert((size - 60000) == buflen, "Incorrect buffer size");
mxb_assert_message((size - 60000) == buflen, "Incorrect buffer size");
buffer = gwbuf_rtrim(buffer, 60000);
buflen = GWBUF_LENGTH(buffer);
fprintf(stderr, "\t..done\nTrimmed another 60 bytes from buffer, now size is %lu.", buflen);
ss_info_dassert(100000 == buflen, "Incorrect buffer size");
ss_info_dassert(buffer == extra, "The buffer pointer should now point to the extra buffer");
mxb_assert_message(100000 == buflen, "Incorrect buffer size");
mxb_assert_message(buffer == extra, "The buffer pointer should now point to the extra buffer");
fprintf(stderr, "\t..done\n");
gwbuf_free(buffer);
/** gwbuf_clone_all test */
@ -541,16 +541,16 @@ test1()
size_t tailsize = 20;
GWBUF* tail = gwbuf_alloc(tailsize);
ss_info_dassert(head && tail, "Head and tail buffers should both be non-NULL");
mxb_assert_message(head && tail, "Head and tail buffers should both be non-NULL");
GWBUF* append = gwbuf_append(head, tail);
ss_info_dassert(append == head, "gwbuf_append should return head");
ss_info_dassert(append->next == tail, "After append tail should be in the next pointer of head");
ss_info_dassert(append->tail == tail, "After append tail should be in the tail pointer of head");
mxb_assert_message(append == head, "gwbuf_append should return head");
mxb_assert_message(append->next == tail, "After append tail should be in the next pointer of head");
mxb_assert_message(append->tail == tail, "After append tail should be in the tail pointer of head");
GWBUF* all_clones = gwbuf_clone(head);
ss_info_dassert(all_clones && all_clones->next, "Cloning all should work");
ss_info_dassert(GWBUF_LENGTH(all_clones) == headsize, "First buffer should be 10 bytes");
ss_info_dassert(GWBUF_LENGTH(all_clones->next) == tailsize, "Second buffer should be 20 bytes");
ss_info_dassert(gwbuf_length(all_clones) == headsize + tailsize, "Total buffer length should be 30 bytes");
mxb_assert_message(all_clones && all_clones->next, "Cloning all should work");
mxb_assert_message(GWBUF_LENGTH(all_clones) == headsize, "First buffer should be 10 bytes");
mxb_assert_message(GWBUF_LENGTH(all_clones->next) == tailsize, "Second buffer should be 20 bytes");
mxb_assert_message(gwbuf_length(all_clones) == headsize + tailsize, "Total buffer length should be 30 bytes");
gwbuf_free(all_clones);
gwbuf_free(head);