Fix internal test failures

The adminusers test did not properly initialize all subsystems in
MaxScale. The polling and DCB tests weren't updated with the changes to
the DCB closing.
This commit is contained in:
Markus Mäkelä
2017-09-06 12:25:29 +03:00
parent 795722506b
commit c542010e67
5 changed files with 8 additions and 17 deletions

View File

@ -1950,18 +1950,6 @@ dcb_call_callback(DCB *dcb, DCB_REASON reason)
}
}
/**
* Check the passed DCB to ensure it is in the list of all DCBS
*
* @param dcb The DCB to check
* @return 1 if the DCB is in the list, otherwise 0
*/
int
dcb_isvalid(DCB *dcb)
{
return !!dcb;
}
static void dcb_hangup_foreach_worker(int thread_id, struct server* server)
{
for (DCB *dcb = this_unit.all_dcbs[thread_id]; dcb; dcb = dcb->thread.next)

View File

@ -247,6 +247,7 @@ main(int argc, char **argv)
unlink(buf);
admin_users_init();
result += test1();
result += test2();
result += test3();

View File

@ -35,9 +35,10 @@
#include <string.h>
#include <maxscale/config.h>
#include <maxscale/dcb.h>
#include <maxscale/listener.h>
#include "../dcb.cc"
/**
* test1 Allocate a dcb and do lots of other things
*
@ -48,17 +49,16 @@ test1()
DCB *dcb;
SERV_LISTENER dummy;
/* Single buffer tests */
ss_dfprintf(stderr, "testdcb : creating buffer with type DCB_ROLE_SERVICE_LISTENER");
ss_dfprintf(stderr, "testdcb : creating buffer with type DCB_ROLE_INTERNAL");
dcb = dcb_alloc(DCB_ROLE_INTERNAL, &dummy);
printDCB(dcb);
ss_info_dassert(dcb_isvalid(dcb), "New DCB must be valid");
ss_dfprintf(stderr, "\t..done\nAllocated dcb.");
printAllDCBs();
ss_dfprintf(stderr, "\t..done\n");
dcb->state = DCB_STATE_POLLING;
this_thread.current_dcb = dcb;
dcb_close(dcb);
ss_dfprintf(stderr, "Freed original dcb");
ss_info_dassert(!dcb_isvalid(dcb), "Closed DCB must not be valid");
ss_dfprintf(stderr, "\t..done\n");
return 0;

View File

@ -35,6 +35,7 @@
#include <errno.h>
#include <maxscale/dcb.h>
#include <maxscale/listener.h>
#include <maxscale/service.h>
#include "test_utils.h"
@ -97,6 +98,8 @@ test1()
sleep(10);
//TODO, fix this for workers: poll_shutdown();
ss_dfprintf(stderr, "\t..done\nTidy up.");
SERVICE my_service = {};
dcb->service = &my_service;
dcb_close(dcb);
ss_dfprintf(stderr, "\t..done\n");