mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-25 13:55:47 +03:00
82 lines
2 KiB
C
82 lines
2 KiB
C
#include <string.h>
|
|
|
|
#include "support.h"
|
|
|
|
#define CSYNC_TEST 1
|
|
#include "csync_private.h"
|
|
|
|
CSYNC *csync;
|
|
|
|
static void setup(void) {
|
|
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");
|
|
}
|
|
|
|
static void teardown(void) {
|
|
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");
|
|
}
|
|
|
|
START_TEST (check_csync_destroy_null)
|
|
{
|
|
fail_unless(csync_destroy(NULL) < 0, NULL);
|
|
}
|
|
END_TEST
|
|
|
|
START_TEST (check_csync_create)
|
|
{
|
|
fail_unless(csync_create(&csync, "/tmp/csync1", "/tmp/csync2") == 0, NULL);
|
|
|
|
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);
|
|
|
|
fail_unless(csync_destroy(csync) == 0, NULL);
|
|
}
|
|
END_TEST
|
|
|
|
START_TEST (check_csync_init)
|
|
{
|
|
fail_unless(csync_init(csync) == 0, NULL);
|
|
|
|
fail_unless((csync->status & CSYNC_INIT) == 1, NULL);
|
|
|
|
fail_unless(csync_init(csync) == 1, NULL);
|
|
}
|
|
END_TEST
|
|
|
|
static Suite *make_csync_suite(void) {
|
|
Suite *s = suite_create("csync");
|
|
|
|
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);
|
|
|
|
return s;
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
Suite *s = NULL;
|
|
SRunner *sr = NULL;
|
|
struct argument_s arguments;
|
|
int nf;
|
|
|
|
ZERO_STRUCT(arguments);
|
|
|
|
cmdline_parse(argc, argv, &arguments);
|
|
|
|
s = make_csync_suite();
|
|
|
|
sr = srunner_create(s);
|
|
if (arguments.nofork) {
|
|
srunner_set_fork_status(sr, CK_NOFORK);
|
|
}
|
|
srunner_run_all(sr, CK_VERBOSE);
|
|
nf = srunner_ntests_failed(sr);
|
|
srunner_free(sr);
|
|
|
|
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
}
|
|
|