2012-10-19 18:06:47 +04:00
|
|
|
#include "torture.h"
|
2008-05-09 11:25:50 +04:00
|
|
|
|
|
|
|
#include "csync_time.h"
|
|
|
|
|
2012-10-19 18:06:47 +04:00
|
|
|
static void setup(void **state) {
|
|
|
|
CSYNC *csync;
|
|
|
|
int rc;
|
2008-05-09 11:25:50 +04:00
|
|
|
|
2012-10-19 18:06:47 +04:00
|
|
|
rc = system("mkdir -p /tmp/check_csync1");
|
|
|
|
assert_int_equal(rc, 0);
|
|
|
|
rc = system("mkdir -p /tmp/check_csync2");
|
|
|
|
assert_int_equal(rc, 0);
|
|
|
|
rc = csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
|
|
|
|
assert_int_equal(rc, 0);
|
2008-05-09 11:25:50 +04:00
|
|
|
|
2012-10-19 18:06:47 +04:00
|
|
|
*state = csync;
|
2008-05-09 11:25:50 +04:00
|
|
|
}
|
|
|
|
|
2012-10-19 18:06:47 +04:00
|
|
|
static void teardown(void **state) {
|
|
|
|
CSYNC *csync = *state;
|
|
|
|
int rc;
|
2008-05-09 11:25:50 +04:00
|
|
|
|
2012-10-19 18:06:47 +04:00
|
|
|
rc = csync_destroy(csync);
|
|
|
|
assert_int_equal(rc, 0);
|
2008-05-09 11:25:50 +04:00
|
|
|
|
2012-10-19 18:06:47 +04:00
|
|
|
rc = system("rm -rf /tmp/check_csync1");
|
|
|
|
assert_int_equal(rc, 0);
|
|
|
|
rc = system("rm -rf /tmp/check_csync2");
|
|
|
|
assert_int_equal(rc, 0);
|
2008-05-09 11:25:50 +04:00
|
|
|
}
|
|
|
|
|
2012-10-19 18:06:47 +04:00
|
|
|
static void check_csync_time(void **state)
|
|
|
|
{
|
|
|
|
CSYNC *csync = *state;
|
|
|
|
/*
|
|
|
|
* The creation should took less than 1 second, so the return
|
|
|
|
* value should be 0.
|
|
|
|
*/
|
|
|
|
assert_int_equal(csync_timediff(csync), 0);
|
|
|
|
}
|
2008-05-09 11:25:50 +04:00
|
|
|
|
2012-10-19 18:06:47 +04:00
|
|
|
int torture_run_tests(void)
|
|
|
|
{
|
|
|
|
const UnitTest tests[] = {
|
|
|
|
unit_test_setup_teardown(check_csync_time, setup, teardown),
|
|
|
|
};
|
2008-05-09 11:25:50 +04:00
|
|
|
|
2012-10-19 18:06:47 +04:00
|
|
|
return run_tests(tests);
|
2008-05-09 11:25:50 +04:00
|
|
|
}
|
|
|
|
|