diff --git a/server/core/test/testbuffer.c b/server/core/test/testbuffer.c index 87ebf858b..0ea2ca311 100644 --- a/server/core/test/testbuffer.c +++ b/server/core/test/testbuffer.c @@ -32,6 +32,7 @@ #include #include +#include /** * test1 Allocate a buffer and do lots of things @@ -41,6 +42,7 @@ static int test1() { GWBUF *buffer, *extra, *clone, *partclone, *transform; +HINT *hint; int size = 100; int bite1 = 35; int bite2 = 60; @@ -58,6 +60,10 @@ int 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"); + ss_dfprintf(stderr, "\t..done\nSet a hint for the buffer"); + hint = hint_create_parameter(NULL, strdup("name"), "value"); + gwbuf_add_hint(buffer, hint); + ss_info_dassert(hint == buffer->hint, "Buffer should point to first and only hint"); ss_dfprintf(stderr, "\t..done\nSet a property for the buffer"); gwbuf_add_property(buffer, "name", "value"); ss_info_dassert(0 == strcmp("value", gwbuf_get_property(buffer, "name")), "Should now have correct property"); diff --git a/server/core/test/testdcb.c b/server/core/test/testdcb.c index 5f8e18601..1d26dfb17 100644 --- a/server/core/test/testdcb.c +++ b/server/core/test/testdcb.c @@ -51,6 +51,7 @@ int buflen; ss_dfprintf(stderr, "testdcb : creating buffer with type DCB_ROLE_SERVICE_LISTENER"); dcb = dcb_alloc(DCB_ROLE_SERVICE_LISTENER); + printDCB(dcb); ss_info_dassert(dcb_isvalid(dcb), "New DCB must be valid"); ss_dfprintf(stderr, "\t..done\nAllocated dcb."); clone = dcb_clone(dcb); diff --git a/server/core/test/testgwbitmask.c b/server/core/test/testgwbitmask.c new file mode 100644 index 000000000..f09dbae17 --- /dev/null +++ b/server/core/test/testgwbitmask.c @@ -0,0 +1,83 @@ +/* + * This file is distributed as part of MaxScale. It is free + * software: you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation, + * version 2. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright SkySQL Ab 2014 + */ + +/** + * + * @verbatim + * Revision History + * + * Date Who Description + * 13-10-2014 Martin Brampton Initial implementation + * + * @endverbatim + */ + +#include +#include +#include + +#include + +#include + +/** + * test1 Allocate table of users and mess around with it + * + */ + +static int +test1() +{ +static GWBITMASK bitmask, another; +int i; + + /* Hint tests */ + ss_dfprintf(stderr, + "testgwbitmask : Initialise a bitmask"); + bitmask_init(&bitmask); + ss_info_dassert(BIT_LENGTH_INITIAL == bitmask.length, "Length should be initial length."); + for (i = 0; i < BIT_LENGTH_INITIAL; i++) { + ss_info_dassert(0 == bitmask_isset(&bitmask, i), "All bits should initially be zero"); + } + ss_info_dassert(0 != bitmask_isallclear(&bitmask), "Should be all clear"); + ss_dfprintf(stderr, "\t..done\nSet an arbitrary bit."); + bitmask_set(&bitmask, 17); + bitmask_copy(&another, &bitmask); + ss_info_dassert(0 != bitmask_isset(&another, 17), "Test bit should be set"); + ss_dfprintf(stderr, "\t..done\nClear the arbitrary bit."); + bitmask_clear(&bitmask, 17); + ss_info_dassert(0 == bitmask_isset(&bitmask, 17), "Test bit should be clear"); + ss_info_dassert(0 != bitmask_isallclear(&bitmask), "Should be all clear"); + ss_dfprintf(stderr, "\t..done\nFree the bitmask."); + bitmask_free(&bitmask); + ss_info_dassert(0 == bitmask.length, "Length should be zero after bit mask freed."); + ss_dfprintf(stderr, "\t..done\n"); + + return 0; + +} + +int main(int argc, char **argv) +{ +int result = 0; + + result += test1(); + + exit(result); +} +