nextcloud-desktop/tests/csync_tests/check_csync.c

83 lines
2 KiB
C
Raw Normal View History

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-08 19:28:12 +04:00
fail_if(system("mkdir -p /tmp/csync1") < 0, "Setup failed");
fail_if(system("mkdir -p /tmp/csync2") < 0, "Setup failed");
fail_if(csync_create(&csync, "/tmp/csync1", "/tmp/csync2") < 0, "Setup failed");
2008-02-27 20:56:47 +03:00
}
static void teardown(void) {
2008-05-08 19:28:12 +04:00
fail_if(csync_destroy(csync) < 0, "Teardown failed");
fail_if(system("rm -rf /tmp/csync1") < 0, "Teardown failed");
fail_if(system("rm -rf /tmp/csync2") < 0, "Teardown failed");
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
{
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
{
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
fail_unless(csync_init(csync) == 1, NULL);
2008-02-27 20:56:47 +03:00
}
END_TEST
2008-05-07 13:09:56 +04:00
static Suite *make_csync_suite(void) {
2008-02-27 20:56:47 +03:00
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;
}
2008-05-07 13:09:56 +04:00
int main(int argc, char **argv) {
Suite *s = NULL;
SRunner *sr = NULL;
struct argument_s arguments;
2008-02-27 20:56:47 +03:00
int nf;
2008-05-07 13:09:56 +04:00
ZERO_STRUCT(arguments);
cmdline_parse(argc, argv, &arguments);
s = make_csync_suite();
2008-02-27 20:56:47 +03:00
sr = srunner_create(s);
2008-05-07 13:09:56 +04:00
if (arguments.nofork) {
srunner_set_fork_status(sr, CK_NOFORK);
}
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;
}