2008-03-06 19:43:58 +03:00
|
|
|
#include <string.h>
|
|
|
|
|
2012-10-17 19:03:22 +04:00
|
|
|
#include "torture.h"
|
2008-03-06 19:43:58 +03:00
|
|
|
|
2008-04-25 12:56:23 +04:00
|
|
|
#define CSYNC_TEST 1
|
2008-03-06 19:43:58 +03:00
|
|
|
#include "csync_config.c"
|
|
|
|
|
2012-10-17 19:03:22 +04:00
|
|
|
#define TESTCONF "/tmp/check_csync1/csync.conf"
|
2008-03-06 19:43:58 +03:00
|
|
|
|
2012-10-17 19:03:22 +04:00
|
|
|
static void setup(void **state) {
|
|
|
|
CSYNC *csync;
|
|
|
|
int rc;
|
2008-03-06 19:43:58 +03:00
|
|
|
|
2012-10-17 19:03:22 +04:00
|
|
|
rc = system("mkdir -p /tmp/check_csync1");
|
|
|
|
assert_int_equal(rc, 0);
|
2008-03-06 19:43:58 +03:00
|
|
|
|
2012-10-17 19:03:22 +04:00
|
|
|
rc = csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
|
|
|
|
assert_int_equal(rc, 0);
|
2008-03-06 19:43:58 +03:00
|
|
|
|
2012-10-17 19:03:22 +04:00
|
|
|
free(csync->options.config_dir);
|
|
|
|
csync->options.config_dir = c_strdup("/tmp/check_csync1/");
|
2008-03-06 19:43:58 +03:00
|
|
|
|
2012-10-17 19:03:22 +04:00
|
|
|
*state = csync;
|
2008-03-06 19:43:58 +03:00
|
|
|
}
|
|
|
|
|
2012-10-17 19:03:22 +04:00
|
|
|
static void teardown(void **state) {
|
|
|
|
CSYNC *csync = *state;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = csync_destroy(csync);
|
|
|
|
assert_int_equal(rc, 0);
|
2008-03-06 19:43:58 +03:00
|
|
|
|
2012-11-23 14:26:10 +04:00
|
|
|
rc = system("rm -rf /tmp/check_csync1");
|
|
|
|
assert_int_equal(rc, 0);
|
|
|
|
|
|
|
|
rc = system("rm -rf /tmp/check_csync2");
|
2012-10-17 19:03:22 +04:00
|
|
|
assert_int_equal(rc, 0);
|
2008-03-06 19:43:58 +03:00
|
|
|
|
2012-10-17 19:03:22 +04:00
|
|
|
*state = NULL;
|
2008-03-06 19:43:58 +03:00
|
|
|
}
|
|
|
|
|
2012-10-17 19:03:22 +04:00
|
|
|
static void check_csync_config_copy_default(void **state)
|
|
|
|
{
|
|
|
|
int rc;
|
2008-03-06 19:43:58 +03:00
|
|
|
|
2012-10-17 19:03:22 +04:00
|
|
|
(void) state; /* unused */
|
|
|
|
rc = _csync_config_copy_default(TESTCONF);
|
|
|
|
assert_int_equal(rc, 0);
|
|
|
|
}
|
2008-05-07 13:09:56 +04:00
|
|
|
|
2012-10-17 19:03:22 +04:00
|
|
|
static void check_csync_config_load(void **state)
|
|
|
|
{
|
|
|
|
CSYNC *csync = *state;
|
|
|
|
int rc;
|
2008-05-07 13:09:56 +04:00
|
|
|
|
2012-10-17 19:03:22 +04:00
|
|
|
rc = csync_config_load(csync, TESTCONF);
|
|
|
|
assert_int_equal(rc, 0);
|
|
|
|
}
|
2008-03-06 19:43:58 +03:00
|
|
|
|
2012-10-17 19:03:22 +04:00
|
|
|
int torture_run_tests(void)
|
|
|
|
{
|
|
|
|
const UnitTest tests[] = {
|
|
|
|
unit_test_setup_teardown(check_csync_config_copy_default, setup, teardown),
|
|
|
|
unit_test_setup_teardown(check_csync_config_load, setup, teardown),
|
|
|
|
};
|
2008-03-06 19:43:58 +03:00
|
|
|
|
2012-10-17 19:03:22 +04:00
|
|
|
return run_tests(tests);
|
2008-03-06 19:43:58 +03:00
|
|
|
}
|
|
|
|
|