Exemplo n.º 1
0
static void test_cstat_remove_teardown(struct conf ***globalcs,
	struct cstat **clist)
{
	confs_free(globalcs);
	cstat_list_free_sdirs(*clist);
	cstat_list_free(clist);
	clean();
	alloc_check();
}
Exemplo n.º 2
0
static void do_test_json_send_clients_with_backup(const char *path,
        struct sd *sd, int s, const char *specific_client)
{
    struct asfd *asfd;
    struct cstat *c=NULL;
    struct cstat *clist=NULL;
    const char *cnames[] = {"cli1", "cli2", "cli3", NULL};
    fail_unless(recursive_delete(CLIENTCONFDIR)==0);
    build_clientconfdir_files(cnames, NULL);
    fail_unless(!cstat_get_client_names(&clist, CLIENTCONFDIR));
    assert_cstat_list(clist, cnames);
    for(c=clist; c; c=c->next)
    {
        c->permitted=1;
        c->protocol=PROTO_1;
        fail_unless((c->sdirs=setup_sdirs(c->protocol, c->name))!=NULL);
        build_storage_dirs((struct sdirs *)c->sdirs, sd, s);
        fail_unless(!cstat_set_backup_list(c));
        fail_unless(c->bu!=NULL);
        // Hack the cntr timestamps so that they are always the same.
        c->cntr->ent[(uint8_t)CMD_TIMESTAMP]->count=200;
        c->cntr->ent[(uint8_t)CMD_TIMESTAMP_END]->count=400;

    }
    asfd=asfd_setup(path);

    c=NULL;
    if(specific_client)
        fail_unless((c=cstat_get_by_name(clist, specific_client))!=NULL);

    fail_unless(!json_send(asfd, clist, c, NULL, NULL, NULL, 0/*cache*/));
    cstat_list_free_sdirs(clist);
    cstat_list_free(&clist);
    fail_unless(!recursive_delete(SDIRS));
    tear_down(&asfd);
}