nextcloud-desktop/tests/csync_tests/check_csync_config.c

69 lines
1.6 KiB
C
Raw Normal View History

2008-03-06 19:43:58 +03:00
#define _GNU_SOURCE /* asprintf */
#include <string.h>
#include "support.h"
#define CSYNC_TEST 1
2008-03-06 19:43:58 +03:00
#include "csync_config.c"
CSYNC *csync;
2008-05-05 12:55:05 +04:00
const char *testconf = "/tmp/check_csync1/csync.conf";
2008-03-06 19:43:58 +03:00
static void setup(void) {
2008-05-08 19:28:12 +04:00
fail_if(system("mkdir -p /tmp/check_csync1") < 0, "Setup failed");
fail_if(csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2") < 0, "Setup failed");
2008-03-06 19:43:58 +03:00
SAFE_FREE(csync->options.config_dir);
2008-05-05 12:55:05 +04:00
csync->options.config_dir = c_strdup("/tmp/check_csync1/");
2008-03-06 19:43:58 +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/check_csync") < 0, "Teardown failed");
2008-03-06 19:43:58 +03:00
}
START_TEST (check_csync_config_copy_default)
{
fail_unless(_csync_config_copy_default(testconf) == 0, NULL);
2008-03-06 19:43:58 +03:00
}
END_TEST
START_TEST (check_csync_config_load)
{
fail_unless(csync_config_load(csync, testconf) == 0, NULL);
}
END_TEST
2008-05-07 13:09:56 +04:00
static Suite *make_csync_suite(void) {
2008-03-06 19:43:58 +03:00
Suite *s = suite_create("csync_config");
create_case_fixture(s, "check_csync_config_copy_default", check_csync_config_copy_default, setup, teardown);
create_case_fixture(s, "check_csync_config_load", check_csync_config_load, setup, teardown);
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-03-06 19:43:58 +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-03-06 19:43:58 +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-03-06 19:43:58 +03:00
srunner_run_all(sr, CK_VERBOSE);
nf = srunner_ntests_failed(sr);
srunner_free(sr);
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}