2008-02-27 20:56:47 +03:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "support.h"
|
|
|
|
|
2008-04-26 12:12:16 +04:00
|
|
|
#define CSYNC_TEST 1
|
2008-02-27 20:56:47 +03:00
|
|
|
#include "csync_private.h"
|
|
|
|
|
|
|
|
CSYNC *csync;
|
|
|
|
|
|
|
|
static void setup(void) {
|
2008-05-05 12:48:05 +04:00
|
|
|
system("mkdir -p /tmp/csync1");
|
|
|
|
system("mkdir -p /tmp/csync2");
|
2008-04-22 19:23:26 +04:00
|
|
|
csync_create(&csync, "/tmp/csync1", "/tmp/csync2");
|
2008-02-27 20:56:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void teardown(void) {
|
|
|
|
csync_destroy(csync);
|
2008-05-05 12:48:05 +04:00
|
|
|
system("rm -rf /tmp/csync1");
|
|
|
|
system("rm -rf /tmp/csync2");
|
2008-02-27 20:56:47 +03:00
|
|
|
}
|
|
|
|
|
2008-04-26 12:12:16 +04:00
|
|
|
START_TEST (check_csync_destroy_null)
|
|
|
|
{
|
|
|
|
fail_unless(csync_destroy(NULL) < 0, NULL);
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
START_TEST (check_csync_create)
|
2008-02-27 20:56:47 +03:00
|
|
|
{
|
2008-04-22 19:23:26 +04:00
|
|
|
fail_unless(csync_create(&csync, "/tmp/csync1", "/tmp/csync2") == 0, NULL);
|
2008-02-27 20:56:47 +03:00
|
|
|
|
|
|
|
fail_unless(csync->options.max_depth == MAX_DEPTH, NULL);
|
|
|
|
fail_unless(csync->options.max_time_difference == MAX_TIME_DIFFERENCE, NULL);
|
|
|
|
fail_unless(strcmp(csync->options.config_dir, CSYNC_CONF_DIR) > 0, NULL);
|
|
|
|
|
2008-04-26 12:12:16 +04:00
|
|
|
fail_unless(csync_destroy(csync) == 0, NULL);
|
2008-02-27 20:56:47 +03:00
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2008-04-26 12:12:16 +04:00
|
|
|
START_TEST (check_csync_init)
|
2008-02-27 20:56:47 +03:00
|
|
|
{
|
2008-02-29 13:41:15 +03:00
|
|
|
fail_unless(csync_init(csync) == 0, NULL);
|
2008-02-27 20:56:47 +03:00
|
|
|
|
2008-04-29 13:21:22 +04:00
|
|
|
fail_unless((csync->status & CSYNC_INIT) == 1, NULL);
|
2008-02-27 20:56:47 +03:00
|
|
|
|
2008-02-29 13:41:15 +03:00
|
|
|
fail_unless(csync_init(csync) == 1, NULL);
|
2008-02-27 20:56:47 +03:00
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
static Suite *csync_suite(void) {
|
|
|
|
Suite *s = suite_create("csync");
|
|
|
|
|
2008-04-26 12:12:16 +04:00
|
|
|
create_case(s, "check_csync_destroy_null", check_csync_destroy_null);
|
|
|
|
create_case(s, "check_csync_create", check_csync_create);
|
|
|
|
create_case_fixture(s, "check_csync_init", check_csync_init, setup, teardown);
|
2008-02-27 20:56:47 +03:00
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(void) {
|
|
|
|
int nf;
|
|
|
|
|
|
|
|
Suite *s = csync_suite();
|
|
|
|
|
|
|
|
SRunner *sr;
|
|
|
|
sr = srunner_create(s);
|
2008-05-05 12:48:05 +04:00
|
|
|
#if 0
|
|
|
|
srunner_set_fork_status(sr, CK_NOFORK);
|
|
|
|
#endif
|
2008-02-27 20:56:47 +03:00
|
|
|
srunner_run_all(sr, CK_VERBOSE);
|
|
|
|
nf = srunner_ntests_failed(sr);
|
|
|
|
srunner_free(sr);
|
|
|
|
|
|
|
|
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|