diff --git a/csync/tests/csync_tests/check_csync_exclude.c b/csync/tests/csync_tests/check_csync_exclude.c index 50c87808d0..1d216eba06 100644 --- a/csync/tests/csync_tests/check_csync_exclude.c +++ b/csync/tests/csync_tests/check_csync_exclude.c @@ -141,6 +141,38 @@ static void check_csync_excluded(void **state) } +static void check_csync_pathes(void **state) +{ + CSYNC *csync = *state; + int rc; + + _csync_exclude_add( &(csync->excludes), "/exclude" ); + + /* Check toplevel dir, the pattern only works for toplevel dir. */ + rc = csync_excluded(csync, "/exclude", CSYNC_FTW_TYPE_DIR); + assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST); + + rc = csync_excluded(csync, "/foo/exclude", CSYNC_FTW_TYPE_DIR); + assert_int_equal(rc, CSYNC_NOT_EXCLUDED); + + /* check for a file called exclude. Must still work */ + rc = csync_excluded(csync, "/exclude", CSYNC_FTW_TYPE_FILE); + assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST); + + rc = csync_excluded(csync, "/foo/exclude", CSYNC_FTW_TYPE_FILE); + assert_int_equal(rc, CSYNC_NOT_EXCLUDED); + + /* Add an exclude for directories only: excl/ */ + _csync_exclude_add( &(csync->excludes), "excl/" ); + rc = csync_excluded(csync, "/excl", CSYNC_FTW_TYPE_DIR); + assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST); + + rc = csync_excluded(csync, "meep/excl", CSYNC_FTW_TYPE_DIR); + assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST); + + rc = csync_excluded(csync, "/excl", CSYNC_FTW_TYPE_FILE); + assert_int_equal(rc, CSYNC_NOT_EXCLUDED); +} int torture_run_tests(void) { @@ -148,6 +180,7 @@ int torture_run_tests(void) unit_test_setup_teardown(check_csync_exclude_add, setup, teardown), unit_test_setup_teardown(check_csync_exclude_load, setup, teardown), unit_test_setup_teardown(check_csync_excluded, setup_init, teardown), + unit_test_setup_teardown(check_csync_pathes, setup_init, teardown), }; return run_tests(tests);