2008-03-25 18:13:44 +03:00
|
|
|
#define _GNU_SOURCE /* asprintf */
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "support.h"
|
2008-05-08 12:56:08 +04:00
|
|
|
#include "config.h"
|
2008-03-25 18:13:44 +03:00
|
|
|
|
2008-04-25 12:56:23 +04:00
|
|
|
#define CSYNC_TEST 1
|
2008-03-25 18:13:44 +03:00
|
|
|
#include "csync_exclude.c"
|
|
|
|
|
|
|
|
CSYNC *csync;
|
|
|
|
|
|
|
|
static void setup(void) {
|
2008-05-08 19:28:12 +04:00
|
|
|
fail_if(csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2") < 0, "Setup failed");
|
2008-03-25 18:13:44 +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-25 18:13:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void setup_init(void) {
|
2008-05-08 19:28:12 +04:00
|
|
|
fail_if(csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2") < 0, "Setup failed");
|
2008-03-25 18:13:44 +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-05-08 19:28:12 +04:00
|
|
|
fail_if(csync_exclude_load(csync, BINARYDIR "/config/" CSYNC_EXCLUDE_FILE) < 0, "Setup failed");
|
2008-03-25 18:13:44 +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_csync1") < 0, "Teardown failed");
|
2008-03-25 18:13:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST (check_csync_exclude_add)
|
|
|
|
{
|
2008-06-02 17:11:45 +04:00
|
|
|
_csync_exclude_add(csync, (const char *) "/tmp/check_csync1/*");
|
2008-05-05 12:55:05 +04:00
|
|
|
fail_unless(strcmp(csync->excludes->vector[0], (const char *) "/tmp/check_csync1/*") == 0, NULL);
|
2008-03-25 18:13:44 +03:00
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
START_TEST (check_csync_exclude_load)
|
|
|
|
{
|
2008-05-08 12:56:08 +04:00
|
|
|
fail_unless(csync_exclude_load(csync, BINARYDIR "/config/" CSYNC_EXCLUDE_FILE) == 0, NULL);
|
2008-06-28 22:46:25 +04:00
|
|
|
fail_unless(strcmp(csync->excludes->vector[0], (const char *) ".beagle") == 0, NULL);
|
2008-03-25 18:13:44 +03:00
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
START_TEST (check_csync_excluded)
|
|
|
|
{
|
2008-06-28 22:46:25 +04:00
|
|
|
fail_unless(csync_excluded(csync, ".kde/share/config/kwin.eventsrc") == 0, NULL);
|
|
|
|
fail_unless(csync_excluded(csync, ".kde4/cache-maximegalon/cache1.txt") == 1, NULL);
|
|
|
|
fail_unless(csync_excluded(csync, ".mozilla/plugins") == 1, NULL);
|
2008-03-25 18:13:44 +03:00
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
2008-05-07 13:09:56 +04:00
|
|
|
static Suite *make_csync_suite(void) {
|
2008-03-25 18:13:44 +03:00
|
|
|
Suite *s = suite_create("csync_exclude");
|
|
|
|
|
|
|
|
create_case_fixture(s, "check_csync_exclude_add", check_csync_exclude_add, setup, teardown);
|
|
|
|
create_case_fixture(s, "check_csync_exclude_load", check_csync_exclude_load, setup, teardown);
|
|
|
|
create_case_fixture(s, "check_csync_excluded", check_csync_excluded, setup_init, 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-25 18:13:44 +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-25 18:13:44 +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-25 18:13:44 +03:00
|
|
|
srunner_run_all(sr, CK_VERBOSE);
|
|
|
|
nf = srunner_ntests_failed(sr);
|
|
|
|
srunner_free(sr);
|
|
|
|
|
|
|
|
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|