test_be_ptask.c revision 5d69dd4d62dab877dfc3c88e410816034981915f
/*
Authors:
Pavel Březina <pbrezina@redhat.com>
Copyright (C) 2014 Red Hat
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
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, see <http://www.gnu.org/licenses/>.
*/
#include <talloc.h>
#include <tevent.h>
#include <errno.h>
#include <popt.h>
#include <time.h>
#include "providers/dp_backend.h"
#include "providers/dp_ptask_private.h"
#include "providers/dp_ptask.h"
#include "tests/cmocka/common_mock.h"
#define DELAY 2
#define PERIOD 1
struct test_ctx {
bool done;
bool add_online_cb_called;
bool add_offline_cb_called;
};
#define mark_online(test_ctx) do { \
} while (0)
#define mark_offline(test_ctx) do { \
} while (0)
/* Since both test_ctx->done and ptask->req is marked as finished already
* in the sync _send function before a new execution is scheduled we need to
* rely on the fact that ptask->req is set to zero when a new timer is
* created. This way we guarantee that the condition is true only when
* the ptask is executed and a new one is scheduled. */
static time_t get_current_time(void)
{
int ret;
assert_int_equal(0, ret);
}
/* Mock few backend functions so we don't have to bring the whole
* data provider into this test. */
{
}
void *pvt,
{
test_ctx->add_online_cb_called = true;
return ERR_OK;
}
void *pvt,
struct be_cb **offline_cb)
{
test_ctx->add_offline_cb_called = true;
return ERR_OK;
}
struct test_be_ptask_state {
};
struct tevent_context *ev,
void *pvt)
{
return req;
}
struct tevent_context *ev,
void *pvt)
{
return NULL;
}
struct tevent_context *ev,
void *pvt)
{
/* we won't finish the request */
return req;
}
{
return ERR_OK;
}
{
return ERR_INTERNAL;
}
struct tevent_context *ev,
void *pvt)
{
return ERR_OK;
}
struct tevent_context *ev,
void *pvt)
{
return ERR_INTERNAL;
}
void test_setup(void **state)
{
/* create be_ctx, only ev and offline field should be used */
}
void test_teardown(void **state)
{
}
void test_be_ptask_create_einval_be(void **state)
{
}
void test_be_ptask_create_einval_period(void **state)
{
}
void test_be_ptask_create_einval_send(void **state)
{
}
void test_be_ptask_create_einval_recv(void **state)
{
}
void test_be_ptask_create_einval_name(void **state)
{
}
void test_be_ptask_create_no_delay(void **state)
{
now = get_current_time();
}
}
void test_be_ptask_create_first_delay(void **state)
{
now = get_current_time();
}
}
void test_be_ptask_disable(void **state)
{
}
void test_be_ptask_enable(void **state)
{
now = get_current_time();
now = get_current_time();
}
}
void test_be_ptask_enable_delay(void **state)
{
}
now = get_current_time();
}
}
void test_be_ptask_offline_skip(void **state)
{
now = get_current_time();
}
}
void test_be_ptask_offline_disable(void **state)
{
}
}
void test_be_ptask_offline_execute(void **state)
{
}
}
void test_be_ptask_reschedule_ok(void **state)
{
now = get_current_time();
}
}
void test_be_ptask_reschedule_null(void **state)
{
&ptask);
now = get_current_time();
}
}
void test_be_ptask_reschedule_error(void **state)
{
&ptask);
now = get_current_time();
}
}
void test_be_ptask_reschedule_timeout(void **state)
{
&ptask);
/* first iterate until the task is executed */
}
/* then iterate until the request is destroyed */
now = get_current_time();
}
}
void test_be_ptask_reschedule_backoff(void **state)
{
time_t now_backoff = 0;
/* first run */
/* We need to acquire timestamp for the second test here, since this
* is the closest value to the timestamp when the next event is
* scheduled. */
}
/* second run */
}
}
void test_be_ptask_get_period(void **state)
{
}
void test_be_ptask_create_sync(void **state)
{
now = get_current_time();
}
}
void test_be_ptask_sync_reschedule_ok(void **state)
{
now = get_current_time();
}
}
void test_be_ptask_sync_reschedule_error(void **state)
{
now = get_current_time();
}
}
void test_be_ptask_sync_reschedule_backoff(void **state)
{
time_t now_backoff = 0;
/* first run */
/* We need to acquire timestamp for the second test here, since this
* is the closest value to the timestamp when the next event is
* scheduled. */
}
/* second run */
}
}
{
int opt;
struct poptOption long_options[] = {
};
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
switch(opt) {
default:
return 1;
}
}
}