diff --git a/CMakeLists.txt b/CMakeLists.txt index 38193d006..976f19aec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -180,8 +180,6 @@ if (NOT DEFINED APPLICATION_ICON_NAME) set(APPLICATION_ICON_NAME ${APPLICATION_SHORTNAME}) endif() -configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) - include(OwnCloudCPack.cmake) add_definitions(-DUNICODE) @@ -213,7 +211,14 @@ endif() file( GLOB TRANS_FILES ${CMAKE_SOURCE_DIR}/translations/client_*.ts) set(TRANSLATIONS ${TRANS_FILES}) -add_subdirectory(csync) +if(UNIT_TESTING) + # Make sure we set this before recursing into child folders. + set(WITH_TESTING ON) + include(CTest) + enable_testing() + add_subdirectory(test) +endif(UNIT_TESTING) + add_subdirectory(src) if(NOT BUILD_LIBRARIES_ONLY) add_subdirectory(shell_integration) @@ -222,11 +227,7 @@ add_subdirectory(doc/dev) add_subdirectory(admin) endif(NOT BUILD_LIBRARIES_ONLY) -if(UNIT_TESTING) - include(CTest) - enable_testing() - add_subdirectory(test) -endif(UNIT_TESTING) +configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) if(BUILD_OWNCLOUD_OSX_BUNDLE) install(FILES sync-exclude.lst DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/) diff --git a/config.h.in b/config.h.in index 0cc0ab9cd..dfd243a09 100644 --- a/config.h.in +++ b/config.h.in @@ -24,6 +24,6 @@ #cmakedefine SYSCONFDIR "@SYSCONFDIR@" #cmakedefine SHAREDIR "@SHAREDIR@" -#cmakedefine WITH_UNIT_TESTING 1 +#cmakedefine WITH_TESTING 1 #endif diff --git a/csync/CMakeLists.txt b/csync/CMakeLists.txt deleted file mode 100644 index d5be43a29..000000000 --- a/csync/CMakeLists.txt +++ /dev/null @@ -1,51 +0,0 @@ - - -# global needed variables -set(APPLICATION_NAME "ocsync") - -set(LIBRARY_VERSION ${MIRALL_VERSION}) -set(LIBRARY_SOVERSION "0") - -# add definitions -include(DefineCMakeDefaults) -include(DefinePlatformDefaults) -include(DefineCompilerFlags) -include(DefineOptions.cmake) - -include(DefineInstallationPaths) - -# add macros -include(MacroAddPlugin) -include(MacroCopyFile) - -find_package(SQLite3 3.8.0 REQUIRED) - -include(ConfigureChecks.cmake) - - -set(SOURCE_DIR ${CMAKE_SOURCE_DIR}) - -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -macro_copy_file(${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake) - -if (MEM_NULL_TESTS) - add_definitions(-DCSYNC_MEM_NULL_TESTS) -endif (MEM_NULL_TESTS) - -add_subdirectory(src) - -if (UNIT_TESTING) - set(WITH_TESTING ON) - - find_package(CMocka) - if (CMOCKA_FOUND) - include(AddCMockaTest) - add_subdirectory(tests) - endif (CMOCKA_FOUND) -endif (UNIT_TESTING) - -configure_file(config_csync.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config_csync.h) -configure_file(config_test.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config_test.h) - - diff --git a/csync/CTestConfig.cmake b/csync/CTestConfig.cmake deleted file mode 100644 index a65999e68..000000000 --- a/csync/CTestConfig.cmake +++ /dev/null @@ -1,12 +0,0 @@ -set(UPDATE_TYPE "true") - -set(MEMORYCHECK_SUPPRESSIONS_FILE ${CMAKE_SOURCE_DIR}/tests/valgrind-csync.supp) - -set(CTEST_PROJECT_NAME "csync") -set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") - -set(CTEST_DROP_METHOD "http") -set(CTEST_DROP_SITE "mock.cryptomilk.org") -set(CTEST_DROP_LOCATION "/submit.php?project=${CTEST_PROJECT_NAME}") -set(CTEST_DROP_SITE_CDASH TRUE) - diff --git a/csync/CTestCustom.cmake b/csync/CTestCustom.cmake deleted file mode 100644 index 4afc9ab6a..000000000 --- a/csync/CTestCustom.cmake +++ /dev/null @@ -1,4 +0,0 @@ -set(CTEST_CUSTOM_MEMCHECK_IGNORE - ${CTEST_CUSTOM_MEMCHECK_IGNORE} - check_std_c_jhash -) diff --git a/csync/config_test.h.cmake b/csync/config_test.h.cmake deleted file mode 100644 index 118676b6c..000000000 --- a/csync/config_test.h.cmake +++ /dev/null @@ -1,7 +0,0 @@ - -/* mind to have trailing slashes! */ - -#define TESTFILES_DIR "@SOURCE_DIR@/csync/tests/ownCloud/testfiles/" - -#define TEST_CONFIG_DIR "@SOURCE_DIR@/csync/tests/ownCloud/" - diff --git a/csync/tests/csync_tests/check_csync_update.cpp b/csync/tests/csync_tests/check_csync_update.cpp new file mode 100644 index 000000000..cc11bad83 --- /dev/null +++ b/csync/tests/csync_tests/check_csync_update.cpp @@ -0,0 +1,460 @@ +/* + * libcsync -- a library to sync a directory with another + * + * Copyright (c) 2008-2013 by Andreas Schneider + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include "csync_update.cpp" + +extern "C" { + +#include "torture.h" + +#define TESTDB "/tmp/check_csync/journal.db" + +static int firstrun = 1; + +static void statedb_create_metadata_table(sqlite3 *db) +{ + int rc = 0; + + if( db ) { + const char *sql = "CREATE TABLE IF NOT EXISTS metadata(" + "phash INTEGER(8)," + "pathlen INTEGER," + "path VARCHAR(4096)," + "inode INTEGER," + "uid INTEGER," + "gid INTEGER," + "mode INTEGER," + "modtime INTEGER(8)," + "type INTEGER," + "md5 VARCHAR(32)," + "fileid VARCHAR(128)," + "remotePerm VARCHAR(128)," + "filesize BIGINT," + "ignoredChildrenRemote INT," + "contentChecksum TEXT," + "contentChecksumTypeId INTEGER," + "PRIMARY KEY(phash));"; + + rc = sqlite3_exec(db, sql, NULL, NULL, NULL); + //const char *msg = sqlite3_errmsg(db); + assert_int_equal( rc, SQLITE_OK ); + + sql = "CREATE TABLE IF NOT EXISTS checksumtype(" + "id INTEGER PRIMARY KEY," + "name TEXT UNIQUE" + ");"; + rc = sqlite3_exec(db, sql, NULL, NULL, NULL); + assert_int_equal( rc, SQLITE_OK ); + } +} + +static void statedb_insert_metadata(sqlite3 *db) +{ + int rc = 0; + + if( db ) { + char *stmt = sqlite3_mprintf("INSERT INTO metadata" + "(phash, pathlen, path, inode, uid, gid, mode, modtime,type,md5) VALUES" + "(%lld, %d, '%q', %d, %d, %d, %d, %lld, %d, '%q');", + (long long signed int)42, + 42, + "I_was_wurst_before_I_became_wurstsalat", + 619070, + 42, + 42, + 42, + (long long signed int)42, + 0, + "4711"); + + char *errmsg; + rc = sqlite3_exec(db, stmt, NULL, NULL, &errmsg); + sqlite3_free(stmt); + assert_int_equal( rc, SQLITE_OK ); + } +} + +static int setup(void **state) +{ + CSYNC *csync; + int rc; + + unlink(TESTDB); + rc = system("mkdir -p /tmp/check_csync"); + assert_int_equal(rc, 0); + rc = system("mkdir -p /tmp/check_csync1"); + assert_int_equal(rc, 0); + csync_create(&csync, "/tmp/check_csync1"); + csync_init(csync, TESTDB); + + /* Create a new db with metadata */ + sqlite3 *db; + csync->statedb.file = c_strdup(TESTDB); + rc = sqlite3_open(csync->statedb.file, &db); + statedb_create_metadata_table(db); + if( firstrun ) { + statedb_insert_metadata(db); + firstrun = 0; + } + sqlite3_close(db); + + rc = csync_statedb_load(csync, TESTDB, &csync->statedb.db); + assert_int_equal(rc, 0); + + *state = csync; + + return 0; +} + +static int setup_ftw(void **state) +{ + CSYNC *csync; + int rc; + + rc = system("mkdir -p /tmp/check_csync"); + assert_int_equal(rc, 0); + rc = system("mkdir -p /tmp/check_csync1"); + assert_int_equal(rc, 0); + csync_create(&csync, "/tmp"); + csync_init(csync, TESTDB); + + sqlite3 *db = NULL; + rc = sqlite3_open_v2(TESTDB, &db, SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, NULL); + assert_int_equal(rc, SQLITE_OK); + statedb_create_metadata_table(db); + rc = sqlite3_close(db); + assert_int_equal(rc, SQLITE_OK); + + rc = csync_statedb_load(csync, TESTDB, &csync->statedb.db); + assert_int_equal(rc, 0); + + csync->statedb.file = c_strdup( TESTDB ); + *state = csync; + + return 0; +} + +static int teardown(void **state) +{ + CSYNC *csync = (CSYNC*)*state; + int rc; + + unlink( csync->statedb.file); + rc = csync_destroy(csync); + assert_int_equal(rc, 0); + + *state = NULL; + + return 0; +} + +static int teardown_rm(void **state) { + int rc; + + teardown(state); + + rc = system("rm -rf /tmp/check_csync"); + assert_int_equal(rc, 0); + rc = system("rm -rf /tmp/check_csync1"); + assert_int_equal(rc, 0); + + return 0; +} + +/* create a file stat, caller must free memory */ +static csync_vio_file_stat_t* create_fstat(const char *name, + ino_t inode, + time_t mtime) +{ + csync_vio_file_stat_t *fs = NULL; + time_t t; + + fs = csync_vio_file_stat_new(); + if (fs == NULL) { + return NULL; + } + + if (name && *name) { + fs->name = c_strdup(name); + } else { + fs->name = c_strdup("file.txt"); + } + + if (fs->name == NULL) { + csync_vio_file_stat_destroy(fs); + return NULL; + } + + fs->fields = CSYNC_VIO_FILE_STAT_FIELDS_NONE; + + fs->type = CSYNC_VIO_FILE_TYPE_REGULAR; + fs->fields |= CSYNC_VIO_FILE_STAT_FIELDS_TYPE; + + + if (inode == 0) { + fs->inode = 619070; + } else { + fs->inode = inode; + } + fs->fields |= CSYNC_VIO_FILE_STAT_FIELDS_INODE; + + + fs->size = 157459; + fs->fields |= CSYNC_VIO_FILE_STAT_FIELDS_SIZE; + + + + if (mtime == 0) { + fs->atime = fs->ctime = fs->mtime = time(&t); + } else { + fs->atime = fs->ctime = fs->mtime = mtime; + } + fs->fields |= CSYNC_VIO_FILE_STAT_FIELDS_ATIME; + fs->fields |= CSYNC_VIO_FILE_STAT_FIELDS_CTIME; + fs->fields |= CSYNC_VIO_FILE_STAT_FIELDS_MTIME; + + return fs; +} + +static int failing_fn(CSYNC *ctx, + const char *file, + const csync_vio_file_stat_t *fs, + int flag) +{ + (void) ctx; + (void) file; + (void) fs; + (void) flag; + + return -1; +} + +/* detect a new file */ +static void check_csync_detect_update(void **state) +{ + CSYNC *csync = (CSYNC*)*state; + csync_file_stat_t *st; + csync_vio_file_stat_t *fs; + int rc; + + fs = create_fstat("file.txt", 0, 1217597845); + assert_non_null(fs); + + rc = _csync_detect_update(csync, + "/tmp/check_csync1/file.txt", + fs, + CSYNC_FTW_TYPE_FILE); + assert_int_equal(rc, 0); + + /* the instruction should be set to new */ + st = (csync_file_stat_t*)c_rbtree_node_data(csync->local.tree->root); + assert_int_equal(st->instruction, CSYNC_INSTRUCTION_NEW); + + /* create a statedb */ + csync_set_status(csync, 0xFFFF); + + csync_vio_file_stat_destroy(fs); +} + +/* Test behaviour in case no db is there. For that its important that the + * test before this one uses teardown_rm. + */ +static void check_csync_detect_update_db_none(void **state) +{ + CSYNC *csync = (CSYNC*)*state; + csync_file_stat_t *st; + csync_vio_file_stat_t *fs; + int rc; + + fs = create_fstat("file.txt", 0, 1217597845); + assert_non_null(fs); + + rc = _csync_detect_update(csync, + "/tmp/check_csync1/file.txt", + fs, + CSYNC_FTW_TYPE_FILE); + assert_int_equal(rc, 0); + + /* the instruction should be set to new */ + st = (csync_file_stat_t*)c_rbtree_node_data(csync->local.tree->root); + assert_int_equal(st->instruction, CSYNC_INSTRUCTION_NEW); + + + /* create a statedb */ + csync_set_status(csync, 0xFFFF); + + csync_vio_file_stat_destroy(fs); +} + +static void check_csync_detect_update_db_eval(void **state) +{ + CSYNC *csync = (CSYNC*)*state; + csync_file_stat_t *st; + csync_vio_file_stat_t *fs; + int rc; + + fs = create_fstat("file.txt", 0, 42); + assert_non_null(fs); + + rc = _csync_detect_update(csync, + "/tmp/check_csync1/file.txt", + fs, + CSYNC_FTW_TYPE_FILE); + assert_int_equal(rc, 0); + + /* the instruction should be set to new */ + st = (csync_file_stat_t*)c_rbtree_node_data(csync->local.tree->root); + assert_int_equal(st->instruction, CSYNC_INSTRUCTION_NEW); + + /* create a statedb */ + csync_set_status(csync, 0xFFFF); + + csync_vio_file_stat_destroy(fs); +} + + +static void check_csync_detect_update_db_rename(void **state) +{ + CSYNC *csync = (CSYNC*)*state; + // csync_file_stat_t *st; + + csync_vio_file_stat_t *fs; + int rc = 0; + + fs = create_fstat("wurst.txt", 0, 42); + assert_non_null(fs); + csync_set_statedb_exists(csync, 1); + + rc = _csync_detect_update(csync, + "/tmp/check_csync1/wurst.txt", + fs, + CSYNC_FTW_TYPE_FILE); + assert_int_equal(rc, 0); + + /* the instruction should be set to rename */ + /* + * temporarily broken. + st = (csync_file_stat_t*)c_rbtree_node_data(csync->local.tree->root); + assert_int_equal(st->instruction, CSYNC_INSTRUCTION_RENAME); + + st->instruction = CSYNC_INSTRUCTION_UPDATED; + */ + /* create a statedb */ + csync_set_status(csync, 0xFFFF); + + csync_vio_file_stat_destroy(fs); +} + +static void check_csync_detect_update_db_new(void **state) +{ + CSYNC *csync = (CSYNC*)*state; + csync_file_stat_t *st; + csync_vio_file_stat_t *fs; + int rc; + + fs = create_fstat("file.txt", 42000, 0); + assert_non_null(fs); + + rc = _csync_detect_update(csync, + "/tmp/check_csync1/file.txt", + fs, + CSYNC_FTW_TYPE_FILE); + assert_int_equal(rc, 0); + + /* the instruction should be set to new */ + st = (csync_file_stat_t*)c_rbtree_node_data(csync->local.tree->root); + assert_int_equal(st->instruction, CSYNC_INSTRUCTION_NEW); + + + /* create a statedb */ + csync_set_status(csync, 0xFFFF); + + csync_vio_file_stat_destroy(fs); +} + +static void check_csync_detect_update_null(void **state) +{ + CSYNC *csync = (CSYNC*)*state; + csync_vio_file_stat_t *fs; + int rc; + + fs = create_fstat("file.txt", 0, 0); + assert_non_null(fs); + + rc = _csync_detect_update(csync, + NULL, + fs, + CSYNC_FTW_TYPE_FILE); + assert_int_equal(rc, -1); + + rc = _csync_detect_update(csync, + "/tmp/check_csync1/file.txt", + NULL, + CSYNC_FTW_TYPE_FILE); + assert_int_equal(rc, -1); + + csync_vio_file_stat_destroy(fs); +} + +static void check_csync_ftw(void **state) +{ + CSYNC *csync = (CSYNC*)*state; + int rc; + + rc = csync_ftw(csync, "/tmp", csync_walker, MAX_DEPTH); + assert_int_equal(rc, 0); +} + +static void check_csync_ftw_empty_uri(void **state) +{ + CSYNC *csync = (CSYNC*)*state; + int rc; + + rc = csync_ftw(csync, "", csync_walker, MAX_DEPTH); + assert_int_equal(rc, -1); +} + +static void check_csync_ftw_failing_fn(void **state) +{ + CSYNC *csync = (CSYNC*)*state; + int rc; + + rc = csync_ftw(csync, "/tmp", failing_fn, MAX_DEPTH); + assert_int_equal(rc, -1); +} + +int torture_run_tests(void) +{ + const struct CMUnitTest tests[] = { + cmocka_unit_test_setup_teardown(check_csync_detect_update, setup, teardown_rm), + cmocka_unit_test_setup_teardown(check_csync_detect_update_db_none, setup, teardown), + cmocka_unit_test_setup_teardown(check_csync_detect_update_db_eval, setup, teardown), + cmocka_unit_test_setup_teardown(check_csync_detect_update_db_rename, setup, teardown), + cmocka_unit_test_setup_teardown(check_csync_detect_update_db_new, setup, teardown_rm), + cmocka_unit_test_setup_teardown(check_csync_detect_update_null, setup, teardown_rm), + + cmocka_unit_test_setup_teardown(check_csync_ftw, setup_ftw, teardown_rm), + cmocka_unit_test_setup_teardown(check_csync_ftw_empty_uri, setup_ftw, teardown_rm), + cmocka_unit_test_setup_teardown(check_csync_ftw_failing_fn, setup_ftw, teardown_rm), + }; + + return cmocka_run_group_tests(tests, NULL, NULL); +} + +} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3cbacd537..f871836cf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,6 +8,7 @@ if(NOT TOKEN_AUTH_ONLY) find_package(Qt5Keychain REQUIRED) endif() +add_subdirectory(csync) add_subdirectory(libsync) if (NOT BUILD_LIBRARIES_ONLY) add_subdirectory(gui) diff --git a/src/cmd/CMakeLists.txt b/src/cmd/CMakeLists.txt index 4a0d76d71..26b641f21 100644 --- a/src/cmd/CMakeLists.txt +++ b/src/cmd/CMakeLists.txt @@ -12,9 +12,8 @@ include_directories(${CMAKE_SOURCE_DIR}/src/libsync ) # csync is required. -include_directories(${CMAKE_SOURCE_DIR}/csync/src - ${CMAKE_BINARY_DIR}/csync - ${CMAKE_BINARY_DIR}/csync/src +include_directories(${CMAKE_SOURCE_DIR}/src/csync + ${CMAKE_BINARY_DIR}/src/csync ) # Need tokenizer for netrc parser diff --git a/csync/AUTHORS b/src/csync/AUTHORS similarity index 100% rename from csync/AUTHORS rename to src/csync/AUTHORS diff --git a/csync/src/CMakeLists.txt b/src/csync/CMakeLists.txt similarity index 74% rename from csync/src/CMakeLists.txt rename to src/csync/CMakeLists.txt index 8bce5f418..09f320202 100644 --- a/csync/src/CMakeLists.txt +++ b/src/csync/CMakeLists.txt @@ -1,4 +1,31 @@ project(libcsync) +# global needed variables +set(APPLICATION_NAME "ocsync") + +set(LIBRARY_VERSION ${MIRALL_VERSION}) +set(LIBRARY_SOVERSION "0") + +# add definitions +include(DefineCMakeDefaults) +include(DefinePlatformDefaults) +include(DefineCompilerFlags) +include(DefineOptions.cmake) + +include(DefineInstallationPaths) + +# add macros +include(MacroAddPlugin) +include(MacroCopyFile) + +find_package(SQLite3 3.8.0 REQUIRED) + +include(ConfigureChecks.cmake) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +if (MEM_NULL_TESTS) + add_definitions(-DCSYNC_MEM_NULL_TESTS) +endif (MEM_NULL_TESTS) add_subdirectory(std) @@ -35,30 +62,30 @@ if(NO_RENAME_EXTENSION) endif() set(csync_SRCS - csync.c - csync_exclude.c - csync_log.c - csync_statedb.c + csync.cpp + csync_exclude.cpp + csync_log.cpp + csync_statedb.cpp csync_time.c - csync_util.c - csync_misc.c + csync_util.cpp + csync_misc.cpp - csync_update.c - csync_reconcile.c + csync_update.cpp + csync_reconcile.cpp - csync_rename.cc + csync_rename.cpp - vio/csync_vio.c - vio/csync_vio_file_stat.c + vio/csync_vio.cpp + vio/csync_vio_file_stat.cpp ) if (WIN32) list(APPEND csync_SRCS - vio/csync_vio_local_win.c + vio/csync_vio_local_win.cpp ) else() list(APPEND csync_SRCS - vio/csync_vio_local_unix.c + vio/csync_vio_local_unix.cpp ) endif() @@ -136,4 +163,4 @@ else() ) endif() - +configure_file(config_csync.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config_csync.h) diff --git a/csync/COPYING b/src/csync/COPYING similarity index 100% rename from csync/COPYING rename to src/csync/COPYING diff --git a/csync/ChangeLog b/src/csync/ChangeLog similarity index 100% rename from csync/ChangeLog rename to src/csync/ChangeLog diff --git a/csync/ConfigureChecks.cmake b/src/csync/ConfigureChecks.cmake similarity index 100% rename from csync/ConfigureChecks.cmake rename to src/csync/ConfigureChecks.cmake diff --git a/csync/DefineOptions.cmake b/src/csync/DefineOptions.cmake similarity index 100% rename from csync/DefineOptions.cmake rename to src/csync/DefineOptions.cmake diff --git a/csync/INSTALL b/src/csync/INSTALL similarity index 100% rename from csync/INSTALL rename to src/csync/INSTALL diff --git a/csync/README b/src/csync/README similarity index 100% rename from csync/README rename to src/csync/README diff --git a/csync/config_csync.h.cmake b/src/csync/config_csync.h.cmake similarity index 100% rename from csync/config_csync.h.cmake rename to src/csync/config_csync.h.cmake diff --git a/csync/src/csync.c b/src/csync/csync.cpp similarity index 99% rename from csync/src/csync.c rename to src/csync/csync.cpp index 1f75ac3bd..6ef3d0d1d 100644 --- a/csync/src/csync.c +++ b/src/csync/csync.cpp @@ -86,7 +86,7 @@ void csync_create(CSYNC **csync, const char *local) { CSYNC *ctx; size_t len = 0; - ctx = c_malloc(sizeof(CSYNC)); + ctx = (CSYNC*)c_malloc(sizeof(CSYNC)); ctx->status_code = CSYNC_STATUS_OK; @@ -604,7 +604,7 @@ int csync_set_status(CSYNC *ctx, int status) { CSYNC_STATUS csync_get_status(CSYNC *ctx) { if (ctx == NULL) { - return -1; + return CSYNC_STATUS_ERROR; } return ctx->status_code; diff --git a/csync/src/csync.h b/src/csync/csync.h similarity index 99% rename from csync/src/csync.h rename to src/csync/csync.h index daf778c24..73eb5790a 100644 --- a/csync/src/csync.h +++ b/src/csync/csync.h @@ -40,10 +40,6 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif - enum csync_status_codes_e { CSYNC_STATUS_OK = 0, @@ -221,7 +217,7 @@ struct csync_vio_file_stat_s { int fields; // actually enum csync_vio_file_stat_fields_e fields; enum csync_vio_file_type_e type; - enum csync_vio_file_flags_e flags; + int flags; char *original_name; // only set if locale conversion fails @@ -504,10 +500,6 @@ int OCSYNC_EXPORT csync_abort_requested(CSYNC *ctx); char OCSYNC_EXPORT *csync_normalize_etag(const char *); time_t OCSYNC_EXPORT oc_httpdate_parse( const char *date ); -#ifdef __cplusplus -} -#endif - /** * }@ */ diff --git a/csync/src/csync_exclude.c b/src/csync/csync_exclude.cpp similarity index 98% rename from csync/src/csync_exclude.c rename to src/csync/csync_exclude.cpp index fea662504..9ab187e71 100644 --- a/csync/src/csync_exclude.c +++ b/src/csync/csync_exclude.cpp @@ -71,7 +71,7 @@ int _csync_exclude_add(c_strlist_t **inList, const char *string) { static const char *csync_exclude_expand_escapes(const char * input) { size_t i_len = strlen(input) + 1; - char *out = c_malloc(i_len); // out can only be shorter + char *out = (char*)c_malloc(i_len); // out can only be shorter size_t i = 0; size_t o = 0; @@ -141,7 +141,7 @@ int csync_exclude_load(const char *fname, c_strlist_t **list) { rc = 0; goto out; } - buf = c_malloc(size + 1); + buf = (char*)c_malloc(size + 1); if (read(fd, buf, size) != size) { rc = -1; goto out; @@ -220,6 +220,7 @@ static CSYNC_EXCLUDE_TYPE _csync_excluded_common(c_strlist_t *excludes, const ch int rc = -1; CSYNC_EXCLUDE_TYPE match = CSYNC_NOT_EXCLUDED; CSYNC_EXCLUDE_TYPE type = CSYNC_NOT_EXCLUDED; + c_strlist_t *path_components = NULL; /* split up the path */ bname = strrchr(path, '/'); @@ -274,8 +275,7 @@ static CSYNC_EXCLUDE_TYPE _csync_excluded_common(c_strlist_t *excludes, const ch } // Filter out characters not allowed in a filename on windows - const char *p = NULL; - for (p = path; *p; p++) { + for (const char *p = path; *p; p++) { switch (*p) { case '\\': case ':': @@ -331,7 +331,6 @@ static CSYNC_EXCLUDE_TYPE _csync_excluded_common(c_strlist_t *excludes, const ch goto out; } - c_strlist_t *path_components = NULL; if (check_leading_dirs) { /* Build a list of path components to check. */ path_components = c_strlist_new(32); diff --git a/csync/src/csync_exclude.h b/src/csync/csync_exclude.h similarity index 100% rename from csync/src/csync_exclude.h rename to src/csync/csync_exclude.h diff --git a/csync/src/csync_log.c b/src/csync/csync_log.cpp similarity index 100% rename from csync/src/csync_log.c rename to src/csync/csync_log.cpp diff --git a/csync/src/csync_log.h b/src/csync/csync_log.h similarity index 100% rename from csync/src/csync_log.h rename to src/csync/csync_log.h diff --git a/csync/src/csync_macros.h b/src/csync/csync_macros.h similarity index 100% rename from csync/src/csync_macros.h rename to src/csync/csync_macros.h diff --git a/csync/src/csync_misc.c b/src/csync/csync_misc.cpp similarity index 99% rename from csync/src/csync_misc.c rename to src/csync/csync_misc.cpp index d23236113..cf719439f 100644 --- a/csync/src/csync_misc.c +++ b/src/csync/csync_misc.cpp @@ -198,7 +198,7 @@ char *csync_normalize_etag(const char *etag) len -= 2; } - buf = c_malloc( len+1 ); + buf = (char*)c_malloc( len+1 ); strncpy( buf, etag, len ); buf[len] = '\0'; return buf; diff --git a/csync/src/csync_misc.h b/src/csync/csync_misc.h similarity index 100% rename from csync/src/csync_misc.h rename to src/csync/csync_misc.h diff --git a/csync/src/csync_private.h b/src/csync/csync_private.h similarity index 99% rename from csync/src/csync_private.h rename to src/csync/csync_private.h index 2edc26019..3d1632e41 100644 --- a/csync/src/csync_private.h +++ b/src/csync/csync_private.h @@ -163,7 +163,7 @@ struct csync_file_stat_s { size_t pathlen; /* u64 */ uint64_t inode; /* u64 */ mode_t mode; /* u32 */ - unsigned int type : 4; + enum csync_ftw_type_e type : 4; unsigned int child_modified : 1; unsigned int has_ignored_files : 1; /* specify that a directory, or child directory contains ignored files */ diff --git a/csync/src/csync_reconcile.c b/src/csync/csync_reconcile.cpp similarity index 99% rename from csync/src/csync_reconcile.c rename to src/csync/csync_reconcile.cpp index 59156e800..3b02398fc 100644 --- a/csync/src/csync_reconcile.c +++ b/src/csync/csync_reconcile.cpp @@ -31,6 +31,8 @@ #define CSYNC_LOG_CATEGORY_NAME "csync.reconciler" #include "csync_log.h" +// Needed for PRIu64 on MinGW in C++ mode. +#define __STDC_FORMAT_MACROS #include "inttypes.h" /* Check if a file is ignored because one parent is ignored. diff --git a/csync/src/csync_reconcile.h b/src/csync/csync_reconcile.h similarity index 100% rename from csync/src/csync_reconcile.h rename to src/csync/csync_reconcile.h diff --git a/csync/src/csync_rename.cc b/src/csync/csync_rename.cpp similarity index 99% rename from csync/src/csync_rename.cc rename to src/csync/csync_rename.cpp index 5cc43ce22..79bb78e34 100644 --- a/csync/src/csync_rename.cc +++ b/src/csync/csync_rename.cpp @@ -18,10 +18,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -extern "C" { #include "csync_private.h" #include "csync_rename.h" -} #include #include @@ -55,7 +53,6 @@ struct csync_rename_s { std::vector todo; }; -extern "C" { void csync_rename_destroy(CSYNC* ctx) { delete reinterpret_cast(ctx->rename_info); @@ -98,5 +95,3 @@ bool csync_rename_count(CSYNC *ctx) { csync_rename_s* d = csync_rename_s::get(ctx); return d->folder_renamed_from.size(); } - -} diff --git a/csync/src/csync_rename.h b/src/csync/csync_rename.h similarity index 95% rename from csync/src/csync_rename.h rename to src/csync/csync_rename.h index 53968324c..7702a1376 100644 --- a/csync/src/csync_rename.h +++ b/src/csync/csync_rename.h @@ -22,10 +22,6 @@ #include "csync.h" -#ifdef __cplusplus -extern "C" { -#endif - /* Return the final destination path of a given patch in case of renames */ char OCSYNC_EXPORT *csync_rename_adjust_path(CSYNC *ctx, const char *path); /* Return the source of a given path in case of renames */ @@ -34,7 +30,3 @@ void OCSYNC_EXPORT csync_rename_destroy(CSYNC *ctx); void OCSYNC_EXPORT csync_rename_record(CSYNC *ctx, const char *from, const char *to); /* Return the amount of renamed item recorded */ bool OCSYNC_EXPORT csync_rename_count(CSYNC *ctx); - -#ifdef __cplusplus -} -#endif diff --git a/csync/src/csync_statedb.c b/src/csync/csync_statedb.cpp similarity index 98% rename from csync/src/csync_statedb.c rename to src/csync/csync_statedb.cpp index 056ca48dd..63eb813e7 100644 --- a/csync/src/csync_statedb.c +++ b/src/csync/csync_statedb.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include "c_lib.h" #include "csync_private.h" @@ -48,6 +47,10 @@ #include "csync_log.h" #include "csync_rename.h" +// Needed for PRIu64 on MinGW in C++ mode. +#define __STDC_FORMAT_MACROS +#include + #define BUF_SIZE 16 #define sqlite_open(A, B) sqlite3_open_v2(A,B, SQLITE_OPEN_READONLY+SQLITE_OPEN_NOMUTEX, NULL) @@ -257,7 +260,7 @@ static int _csync_file_stat_from_metadata_table( csync_file_stat_t **st, sqlite3 /* phash, pathlen, path, inode, uid, gid, mode, modtime */ len = sqlite3_column_int(stmt, 1); - *st = c_malloc(sizeof(csync_file_stat_t) + len + 1); + *st = (csync_file_stat_t*)c_malloc(sizeof(csync_file_stat_t) + len + 1); /* clear the whole structure */ ZERO_STRUCTP(*st); @@ -272,7 +275,7 @@ static int _csync_file_stat_from_metadata_table( csync_file_stat_t **st, sqlite3 (*st)->modtime = strtoul((char*)sqlite3_column_text(stmt, 7), NULL, 10); if(*st && column_count > 8 ) { - (*st)->type = sqlite3_column_int(stmt, 8); + (*st)->type = static_cast(sqlite3_column_int(stmt, 8)); } if(column_count > 9 && sqlite3_column_text(stmt, 9)) { diff --git a/csync/src/csync_statedb.h b/src/csync/csync_statedb.h similarity index 98% rename from csync/src/csync_statedb.h rename to src/csync/csync_statedb.h index 601e34a1b..dc58a9b08 100644 --- a/csync/src/csync_statedb.h +++ b/src/csync/csync_statedb.h @@ -33,10 +33,6 @@ #ifndef _CSYNC_STATEDB_H #define _CSYNC_STATEDB_H -#ifdef __cplusplus -extern "C" { -#endif - #include "c_lib.h" #include "csync_private.h" @@ -96,10 +92,6 @@ int csync_statedb_get_below_path(CSYNC *ctx, const char *path); */ c_strlist_t *csync_statedb_query(sqlite3 *db, const char *statement); -#ifdef __cplusplus -} -#endif - /** * }@ */ diff --git a/csync/src/csync_time.c b/src/csync/csync_time.c similarity index 98% rename from csync/src/csync_time.c rename to src/csync/csync_time.c index 85bdd5ff4..3092819a3 100644 --- a/csync/src/csync_time.c +++ b/src/csync/csync_time.c @@ -34,6 +34,8 @@ #ifndef _WIN32 #include #include +#else +#include #endif #define CSYNC_LOG_CATEGORY_NAME "csync.time" diff --git a/csync/src/csync_time.h b/src/csync/csync_time.h similarity index 93% rename from csync/src/csync_time.h rename to src/csync/csync_time.h index 1492bef8d..55aa09841 100644 --- a/csync/src/csync_time.h +++ b/src/csync/csync_time.h @@ -21,6 +21,10 @@ #ifndef _CSYNC_TIME_H #define _CSYNC_TIME_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include "csync_private.h" @@ -28,4 +32,8 @@ int csync_gettime(struct timespec *tp); void csync_sleep(unsigned int msecs); +#ifdef __cplusplus +} +#endif + #endif /* _CSYNC_TIME_H */ diff --git a/csync/src/csync_update.c b/src/csync/csync_update.cpp similarity index 99% rename from csync/src/csync_update.c rename to src/csync/csync_update.cpp index 1a069442e..927290b1a 100644 --- a/csync/src/csync_update.c +++ b/src/csync/csync_update.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include @@ -48,6 +47,10 @@ #include "csync_log.h" #include "csync_rename.h" +// Needed for PRIu64 on MinGW in C++ mode. +#define __STDC_FORMAT_MACROS +#include + /* calculate the hash of a given uri */ static uint64_t _hash_of_file(CSYNC *ctx, const char *file) { const char *path; @@ -159,7 +162,7 @@ static bool _csync_mtime_equal(time_t a, time_t b) * See doc/dev/sync-algorithm.md for an overview. */ static int _csync_detect_update(CSYNC *ctx, const char *file, - const csync_vio_file_stat_t *fs, const int type) { + const csync_vio_file_stat_t *fs, enum csync_ftw_type_e type) { uint64_t h = 0; size_t len = 0; size_t size = 0; @@ -224,7 +227,7 @@ static int _csync_detect_update(CSYNC *ctx, const char *file, } size = sizeof(csync_file_stat_t) + len + 1; - st = c_malloc(size); + st = static_cast(c_malloc(size)); /* Set instruction by default to none */ st->instruction = CSYNC_INSTRUCTION_NONE; @@ -540,9 +543,9 @@ out: } int csync_walker(CSYNC *ctx, const char *file, const csync_vio_file_stat_t *fs, - enum csync_ftw_flags_e flag) { + int flag) { int rc = -1; - int type = CSYNC_FTW_TYPE_SKIP; + enum csync_ftw_type_e type = CSYNC_FTW_TYPE_SKIP; csync_file_stat_t *st = NULL; uint64_t h; @@ -648,13 +651,13 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn, int rc = 0; int res = 0; + bool do_read_from_db = (ctx->current == REMOTE_REPLICA && ctx->remote.read_from_db); + if (!depth) { mark_current_item_ignored(ctx, previous_fs, CSYNC_STATUS_INDIVIDUAL_TOO_DEEP); goto done; } - bool do_read_from_db = (ctx->current == REMOTE_REPLICA && ctx->remote.read_from_db); - read_from_db = ctx->remote.read_from_db; // if the etag of this dir is still the same, its content is restored from the diff --git a/csync/src/csync_update.h b/src/csync/csync_update.h similarity index 96% rename from csync/src/csync_update.h rename to src/csync/csync_update.h index 4a7495e3a..d83ee91e8 100644 --- a/csync/src/csync_update.h +++ b/src/csync/csync_update.h @@ -53,7 +53,7 @@ enum csync_ftw_flags_e { }; typedef int (*csync_walker_fn) (CSYNC *ctx, const char *file, - const csync_vio_file_stat_t *fs, enum csync_ftw_flags_e flag); + const csync_vio_file_stat_t *fs, int flag); /** * @brief The walker function to use in the file tree walker. @@ -68,8 +68,7 @@ typedef int (*csync_walker_fn) (CSYNC *ctx, const char *file, * * @return 0 on success, < 0 on error. */ -int csync_walker(CSYNC *ctx, const char *file, const csync_vio_file_stat_t *fs, - enum csync_ftw_flags_e flag); +int csync_walker(CSYNC *ctx, const char *file, const csync_vio_file_stat_t *fs, int flag); /** * @brief The file tree walker. diff --git a/csync/src/csync_util.c b/src/csync/csync_util.cpp similarity index 99% rename from csync/src/csync_util.c rename to src/csync/csync_util.cpp index 1bc09c35c..4fc13a471 100644 --- a/csync/src/csync_util.c +++ b/src/csync/csync_util.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include "c_jhash.h" #include "csync_util.h" diff --git a/csync/src/csync_util.h b/src/csync/csync_util.h similarity index 100% rename from csync/src/csync_util.h rename to src/csync/csync_util.h diff --git a/csync/src/csync_version.h.in b/src/csync/csync_version.h.in similarity index 93% rename from csync/src/csync_version.h.in rename to src/csync/csync_version.h.in index 9471734b8..3bf379db9 100644 --- a/csync/src/csync_version.h.in +++ b/src/csync/csync_version.h.in @@ -21,17 +21,9 @@ #ifndef _CSYNC_VERSION_H #define _CSYNC_VERSION_H -#ifdef __cplusplus -extern "C" { -#endif - #define CSYNC_STRINGIFY(s) CSYNC_TOSTRING(s) #define CSYNC_TOSTRING(s) #s #define MIRALL_VERSION @MIRALL_VERSION@ -#ifdef __cplusplus -} -#endif - #endif // _CSYNC_VERSION_H diff --git a/csync/src/std/CMakeLists.txt b/src/csync/std/CMakeLists.txt similarity index 98% rename from csync/src/std/CMakeLists.txt rename to src/csync/std/CMakeLists.txt index 519cada86..8cfd48531 100644 --- a/csync/src/std/CMakeLists.txt +++ b/src/csync/std/CMakeLists.txt @@ -20,7 +20,7 @@ set(cstdlib_SRCS c_rbtree.c c_string.c c_time.c - c_utf8.cc + c_utf8.cpp ) if(NOT HAVE_ASPRINTF AND NOT HAVE___MINGW_ASPRINTF) diff --git a/csync/src/std/asprintf.c b/src/csync/std/asprintf.c similarity index 100% rename from csync/src/std/asprintf.c rename to src/csync/std/asprintf.c diff --git a/csync/src/std/asprintf.h b/src/csync/std/asprintf.h similarity index 96% rename from csync/src/std/asprintf.h rename to src/csync/std/asprintf.h index d6dd2e859..21693ca89 100644 --- a/csync/src/std/asprintf.h +++ b/src/csync/std/asprintf.h @@ -34,6 +34,10 @@ #ifndef ASPRINTF_H #define ASPRINTF_H 1 +#ifdef __cplusplus +extern "C" { +#endif + #include /** @@ -56,5 +60,9 @@ vasprintf (char **, const char *, va_list); int asprintf (char **, const char *, ...); +#ifdef __cplusplus +} +#endif + #endif #endif diff --git a/csync/src/std/c_alloc.c b/src/csync/std/c_alloc.c similarity index 100% rename from csync/src/std/c_alloc.c rename to src/csync/std/c_alloc.c diff --git a/csync/src/std/c_alloc.h b/src/csync/std/c_alloc.h similarity index 98% rename from csync/src/std/c_alloc.h rename to src/csync/std/c_alloc.h index 6eeccd69d..8ff2eb08b 100644 --- a/csync/src/std/c_alloc.h +++ b/src/csync/std/c_alloc.h @@ -34,6 +34,10 @@ #ifndef _C_ALLOC_H #define _C_ALLOC_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include "c_macro.h" @@ -113,4 +117,9 @@ char *c_strndup(const char *str, size_t size); /** * }@ */ + +#ifdef __cplusplus +} +#endif + #endif /* _C_ALLOC_H */ diff --git a/csync/src/std/c_jhash.h b/src/csync/std/c_jhash.h similarity index 100% rename from csync/src/std/c_jhash.h rename to src/csync/std/c_jhash.h diff --git a/csync/src/std/c_lib.h b/src/csync/std/c_lib.h similarity index 100% rename from csync/src/std/c_lib.h rename to src/csync/std/c_lib.h diff --git a/csync/src/std/c_macro.h b/src/csync/std/c_macro.h similarity index 100% rename from csync/src/std/c_macro.h rename to src/csync/std/c_macro.h diff --git a/csync/src/std/c_path.c b/src/csync/std/c_path.c similarity index 100% rename from csync/src/std/c_path.c rename to src/csync/std/c_path.c diff --git a/csync/src/std/c_path.h b/src/csync/std/c_path.h similarity index 98% rename from csync/src/std/c_path.h rename to src/csync/std/c_path.h index 291b1b8d3..f17c5f480 100644 --- a/csync/src/std/c_path.h +++ b/src/csync/std/c_path.h @@ -32,6 +32,10 @@ #ifndef _C_PATH_H #define _C_PATH_H +#ifdef __cplusplus +extern "C" { +#endif + #include "c_macro.h" #include "c_private.h" @@ -139,4 +143,9 @@ mbchar_t* c_utf8_path_to_locale(const char *str); /** * }@ */ + +#ifdef __cplusplus +} +#endif + #endif /* _C_PATH_H */ diff --git a/csync/src/std/c_private.h b/src/csync/std/c_private.h similarity index 100% rename from csync/src/std/c_private.h rename to src/csync/std/c_private.h diff --git a/csync/src/std/c_rbtree.c b/src/csync/std/c_rbtree.c similarity index 100% rename from csync/src/std/c_rbtree.c rename to src/csync/std/c_rbtree.c diff --git a/csync/src/std/c_rbtree.h b/src/csync/std/c_rbtree.h similarity index 99% rename from csync/src/std/c_rbtree.h rename to src/csync/std/c_rbtree.h index 635458fd2..69b4c0d73 100644 --- a/csync/src/std/c_rbtree.h +++ b/src/csync/std/c_rbtree.h @@ -66,6 +66,10 @@ #ifndef _C_RBTREE_H #define _C_RBTREE_H +#ifdef __cplusplus +extern "C" { +#endif + /* Forward declarations */ struct c_rbtree_s; typedef struct c_rbtree_s c_rbtree_t; struct c_rbnode_s; typedef struct c_rbnode_s c_rbnode_t; @@ -306,4 +310,9 @@ int c_rbtree_check_sanity(c_rbtree_t *tree); /** * }@ */ + +#ifdef __cplusplus +} +#endif + #endif /* _C_RBTREE_H */ diff --git a/csync/src/std/c_string.c b/src/csync/std/c_string.c similarity index 100% rename from csync/src/std/c_string.c rename to src/csync/std/c_string.c diff --git a/csync/src/std/c_string.h b/src/csync/std/c_string.h similarity index 98% rename from csync/src/std/c_string.h rename to src/csync/std/c_string.h index 304c598a2..4d7d9b599 100644 --- a/csync/src/std/c_string.h +++ b/src/csync/std/c_string.h @@ -32,6 +32,10 @@ #ifndef _C_STR_H #define _C_STR_H +#ifdef __cplusplus +extern "C" { +#endif + #include "c_private.h" #include "c_macro.h" @@ -217,5 +221,10 @@ mbchar_t* c_utf8_string_to_locale(const char *wstr); /** * }@ */ + +#ifdef __cplusplus +} +#endif + #endif /* _C_STR_H */ diff --git a/csync/src/std/c_time.c b/src/csync/std/c_time.c similarity index 98% rename from csync/src/std/c_time.c rename to src/csync/std/c_time.c index ad43fed02..561cd4763 100644 --- a/csync/src/std/c_time.c +++ b/src/csync/std/c_time.c @@ -25,10 +25,6 @@ #include "c_path.h" #include "c_time.h" -#ifndef _WIN32 -#include -#endif - struct timespec c_tspecdiff(struct timespec time1, struct timespec time0) { struct timespec ret; int xsec = 0; diff --git a/csync/src/std/c_time.h b/src/csync/std/c_time.h similarity index 93% rename from csync/src/std/c_time.h rename to src/csync/std/c_time.h index aa8ef2f16..67e7fcbad 100644 --- a/csync/src/std/c_time.h +++ b/src/csync/std/c_time.h @@ -21,7 +21,15 @@ #ifndef _C_TIME_H #define _C_TIME_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _WIN32 #include +#else +#include +#endif /** * @brief Calculate time difference @@ -52,4 +60,8 @@ double c_secdiff(struct timespec clock1, struct timespec clock0); int c_utimes(const char *uri, const struct timeval *times); +#ifdef __cplusplus +} +#endif + #endif /* _C_TIME_H */ diff --git a/csync/src/std/c_utf8.cc b/src/csync/std/c_utf8.cpp similarity index 100% rename from csync/src/std/c_utf8.cc rename to src/csync/std/c_utf8.cpp diff --git a/csync/src/vio/csync_vio.c b/src/csync/vio/csync_vio.cpp similarity index 100% rename from csync/src/vio/csync_vio.c rename to src/csync/vio/csync_vio.cpp diff --git a/csync/src/vio/csync_vio.h b/src/csync/vio/csync_vio.h similarity index 100% rename from csync/src/vio/csync_vio.h rename to src/csync/vio/csync_vio.h diff --git a/csync/src/vio/csync_vio_file_stat.c b/src/csync/vio/csync_vio_file_stat.cpp similarity index 100% rename from csync/src/vio/csync_vio_file_stat.c rename to src/csync/vio/csync_vio_file_stat.cpp diff --git a/csync/src/vio/csync_vio_local.h b/src/csync/vio/csync_vio_local.h similarity index 100% rename from csync/src/vio/csync_vio_local.h rename to src/csync/vio/csync_vio_local.h diff --git a/csync/src/vio/csync_vio_local_unix.c b/src/csync/vio/csync_vio_local_unix.cpp similarity index 99% rename from csync/src/vio/csync_vio_local_unix.c rename to src/csync/vio/csync_vio_local_unix.cpp index 5d5666688..40e4794c3 100644 --- a/csync/src/vio/csync_vio_local_unix.c +++ b/src/csync/vio/csync_vio_local_unix.cpp @@ -48,7 +48,7 @@ csync_vio_handle_t *csync_vio_local_opendir(const char *name) { dhandle_t *handle = NULL; mbchar_t *dirname = NULL; - handle = c_malloc(sizeof(dhandle_t)); + handle = (dhandle_t*)c_malloc(sizeof(dhandle_t)); dirname = c_utf8_path_to_locale(name); @@ -89,6 +89,7 @@ csync_vio_file_stat_t *csync_vio_local_readdir(csync_vio_handle_t *dhandle) { csync_vio_file_stat_t *file_stat = NULL; handle = (dhandle_t *) dhandle; + struct _tdirent *dirent = NULL; errno = 0; file_stat = csync_vio_file_stat_new(); @@ -97,8 +98,6 @@ csync_vio_file_stat_t *csync_vio_local_readdir(csync_vio_handle_t *dhandle) { } file_stat->fields = CSYNC_VIO_FILE_STAT_FIELDS_NONE; - struct _tdirent *dirent = NULL; - dirent = _treaddir(handle->dh); if (dirent == NULL) { goto err; diff --git a/csync/src/vio/csync_vio_local_win.c b/src/csync/vio/csync_vio_local_win.cpp similarity index 98% rename from csync/src/vio/csync_vio_local_win.c rename to src/csync/vio/csync_vio_local_win.cpp index fc4eea512..e9d2ba566 100644 --- a/csync/src/vio/csync_vio_local_win.c +++ b/src/csync/vio/csync_vio_local_win.cpp @@ -52,7 +52,7 @@ csync_vio_handle_t *csync_vio_local_opendir(const char *name) { dhandle_t *handle = NULL; mbchar_t *dirname = NULL; - handle = c_malloc(sizeof(dhandle_t)); + handle = (dhandle_t*)c_malloc(sizeof(dhandle_t)); // the file wildcard has to be attached int len_name = strlen(name); @@ -60,7 +60,7 @@ csync_vio_handle_t *csync_vio_local_opendir(const char *name) { char *h = NULL; // alloc an enough large buffer to take the name + '/*' + the closing zero. - h = c_malloc(len_name+3); + h = (char*)c_malloc(len_name+3); strncpy( h, name, 1+len_name); strncat(h, "/*", 2); diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 2157d3cd6..f7cc0a9db 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -181,11 +181,9 @@ set(3rdparty_INC include_directories(${3rdparty_INC}) # csync is required. -include_directories(${CMAKE_SOURCE_DIR}/csync/src - ${CMAKE_BINARY_DIR}/csync - ${CMAKE_BINARY_DIR}/csync/src +include_directories(${CMAKE_SOURCE_DIR}/src/csync + ${CMAKE_BINARY_DIR}/src/csync ) - include_directories(../libsync ${CMAKE_CURRENT_BINARY_DIR}/../libsync) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} diff --git a/src/libsync/CMakeLists.txt b/src/libsync/CMakeLists.txt index 65d68823d..865dad895 100644 --- a/src/libsync/CMakeLists.txt +++ b/src/libsync/CMakeLists.txt @@ -5,9 +5,8 @@ configure_file( version.h.in "${CMAKE_CURRENT_BINARY_DIR}/version.h" ) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) # csync is required. -include_directories(${CMAKE_SOURCE_DIR}/csync/src - ${CMAKE_BINARY_DIR}/csync - ${CMAKE_BINARY_DIR}/csync/src +include_directories(${CMAKE_SOURCE_DIR}/src/csync + ${CMAKE_BINARY_DIR}/src/csync ) if ( APPLE ) diff --git a/src/libsync/excludedfiles.cpp b/src/libsync/excludedfiles.cpp index 7bd66ac9c..289164efb 100644 --- a/src/libsync/excludedfiles.cpp +++ b/src/libsync/excludedfiles.cpp @@ -12,16 +12,15 @@ * for more details. */ +#include "config.h" #include "excludedfiles.h" #include "utility.h" #include -extern "C" { #include "std/c_string.h" #include "csync.h" #include "csync_exclude.h" -} using namespace OCC; diff --git a/src/libsync/excludedfiles.h b/src/libsync/excludedfiles.h index f8a18cd8d..d090f8aa6 100644 --- a/src/libsync/excludedfiles.h +++ b/src/libsync/excludedfiles.h @@ -20,11 +20,9 @@ #include #include -extern "C" { #include "std/c_string.h" #include "csync.h" #include "csync_exclude.h" // for CSYNC_EXCLUDE_TYPE -} namespace OCC { diff --git a/src/libsync/filesystem.cpp b/src/libsync/filesystem.cpp index 18e6f800f..8299fcc04 100644 --- a/src/libsync/filesystem.cpp +++ b/src/libsync/filesystem.cpp @@ -39,14 +39,11 @@ // We use some internals of csync: extern "C" int c_utimes(const char *, const struct timeval *); -extern "C" void csync_win32_set_file_hidden(const char *file, bool h); -extern "C" { #include "csync.h" #include "vio/csync_vio_local.h" #include "std/c_path.h" #include "std/c_string.h" -} namespace OCC { diff --git a/src/libsync/owncloudpropagator.h b/src/libsync/owncloudpropagator.h index 02145fa19..b9b60034f 100644 --- a/src/libsync/owncloudpropagator.h +++ b/src/libsync/owncloudpropagator.h @@ -25,6 +25,7 @@ #include #include +#include "csync_util.h" #include "syncfileitem.h" #include "syncjournaldb.h" #include "bandwidthmanager.h" @@ -35,8 +36,6 @@ namespace OCC { Q_DECLARE_LOGGING_CATEGORY(lcPropagator) -extern "C" const char *csync_instruction_str(enum csync_instructions_e instr); - /** Free disk space threshold below which syncs will abort and not even start. */ qint64 criticalFreeSpaceLimit(); diff --git a/src/libsync/syncjournaldb.cpp b/src/libsync/syncjournaldb.cpp index 0eb34e609..e46d35db6 100644 --- a/src/libsync/syncjournaldb.cpp +++ b/src/libsync/syncjournaldb.cpp @@ -21,8 +21,6 @@ #include "ownsql.h" -#include - #include "syncjournaldb.h" #include "syncjournalfilerecord.h" #include "utility.h" @@ -31,7 +29,7 @@ #include "asserts.h" #include "checksums.h" -#include "../../csync/src/std/c_jhash.h" +#include "std/c_jhash.h" namespace OCC { diff --git a/src/libsync/utility.cpp b/src/libsync/utility.cpp index b3813f14b..c73b48d91 100644 --- a/src/libsync/utility.cpp +++ b/src/libsync/utility.cpp @@ -275,7 +275,7 @@ void Utility::usleep(int usec) bool Utility::fsCasePreserving() { -#ifndef WITH_TESTING +#ifdef WITH_TESTING QByteArray env = qgetenv("OWNCLOUD_TEST_CASE_PRESERVING"); if (!env.isEmpty()) return env.toInt(); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 860f140e9..d6b68cb5c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,7 +1,17 @@ -include_directories(${CMAKE_BINARY_DIR}/csync ${CMAKE_BINARY_DIR}/csync/src ${CMAKE_BINARY_DIR}/src) -include_directories(${CMAKE_SOURCE_DIR}/csync/src/) -include_directories(${CMAKE_SOURCE_DIR}/csync/src/std ${CMAKE_SOURCE_DIR}/src) -include_directories(${CMAKE_SOURCE_DIR}/src/3rdparty/qtokenizer) +include_directories(${QT_INCLUDES} + ${CMAKE_SOURCE_DIR}/src + ${CMAKE_SOURCE_DIR}/src/3rdparty/qtokenizer + ${CMAKE_SOURCE_DIR}/src/csync + ${CMAKE_SOURCE_DIR}/src/csync/std + ${CMAKE_SOURCE_DIR}/src/gui + ${CMAKE_SOURCE_DIR}/src/libsync + ${CMAKE_BINARY_DIR}/src/csync + ${CMAKE_BINARY_DIR}/src/libsync + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ) + +include_directories() include(QtVersionAbstraction) setup_qt() @@ -61,3 +71,9 @@ list(APPEND FolderMan_SRC stub.cpp ) owncloud_add_test(FolderMan "${FolderMan_SRC}") configure_file(test_journal.db "${PROJECT_BINARY_DIR}/bin/test_journal.db" COPYONLY) + +find_package(CMocka) +if (CMOCKA_FOUND) + include(AddCMockaTest) + add_subdirectory(csync) +endif (CMOCKA_FOUND) diff --git a/test/csync/AUTHORS b/test/csync/AUTHORS new file mode 100644 index 000000000..5fd81c08e --- /dev/null +++ b/test/csync/AUTHORS @@ -0,0 +1,3 @@ +Andreas Schneider +Klaas Freitag +Olivier Goffart diff --git a/csync/tests/CMakeLists.txt b/test/csync/CMakeLists.txt similarity index 64% rename from csync/tests/CMakeLists.txt rename to test/csync/CMakeLists.txt index fcfe80a83..a27505d12 100644 --- a/csync/tests/CMakeLists.txt +++ b/test/csync/CMakeLists.txt @@ -3,6 +3,7 @@ project(tests C) set(TORTURE_LIBRARY torture) include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} ${CSYNC_PUBLIC_INCLUDE_DIRS} ${CSTDLIB_PUBLIC_INCLUDE_DIRS} ${CMAKE_BINARY_DIR} @@ -28,28 +29,28 @@ add_cmocka_test(check_std_c_time std_tests/check_std_c_time.c ${TEST_TARGET_LIBR # csync tests # This will be rewritten soon anyway. -#add_cmocka_test(check_logger log_tests/check_log.c ${TEST_TARGET_LIBRARIES}) +#add_cmocka_test(check_logger log_tests/check_log.cpp ${TEST_TARGET_LIBRARIES}) -add_cmocka_test(check_csync_create csync_tests/check_csync_create.c ${TEST_TARGET_LIBRARIES}) -add_cmocka_test(check_csync_log csync_tests/check_csync_log.c ${TEST_TARGET_LIBRARIES}) -add_cmocka_test(check_csync_exclude csync_tests/check_csync_exclude.c ${TEST_TARGET_LIBRARIES}) -add_cmocka_test(check_csync_statedb_load csync_tests/check_csync_statedb_load.c ${TEST_TARGET_LIBRARIES}) -add_cmocka_test(check_csync_util csync_tests/check_csync_util.c ${TEST_TARGET_LIBRARIES}) -add_cmocka_test(check_csync_misc csync_tests/check_csync_misc.c ${TEST_TARGET_LIBRARIES}) +add_cmocka_test(check_csync_create csync_tests/check_csync_create.cpp ${TEST_TARGET_LIBRARIES}) +add_cmocka_test(check_csync_log csync_tests/check_csync_log.cpp ${TEST_TARGET_LIBRARIES}) +add_cmocka_test(check_csync_exclude csync_tests/check_csync_exclude.cpp ${TEST_TARGET_LIBRARIES}) +add_cmocka_test(check_csync_statedb_load csync_tests/check_csync_statedb_load.cpp ${TEST_TARGET_LIBRARIES}) +add_cmocka_test(check_csync_util csync_tests/check_csync_util.cpp ${TEST_TARGET_LIBRARIES}) +add_cmocka_test(check_csync_misc csync_tests/check_csync_misc.cpp ${TEST_TARGET_LIBRARIES}) # csync tests which require init -add_cmocka_test(check_csync_init csync_tests/check_csync_init.c ${TEST_TARGET_LIBRARIES}) -add_cmocka_test(check_csync_statedb_query csync_tests/check_csync_statedb_query.c ${TEST_TARGET_LIBRARIES}) -add_cmocka_test(check_csync_commit csync_tests/check_csync_commit.c ${TEST_TARGET_LIBRARIES}) +add_cmocka_test(check_csync_init csync_tests/check_csync_init.cpp ${TEST_TARGET_LIBRARIES}) +add_cmocka_test(check_csync_statedb_query csync_tests/check_csync_statedb_query.cpp ${TEST_TARGET_LIBRARIES}) +add_cmocka_test(check_csync_commit csync_tests/check_csync_commit.cpp ${TEST_TARGET_LIBRARIES}) # vio -add_cmocka_test(check_vio_file_stat vio_tests/check_vio_file_stat.c ${TEST_TARGET_LIBRARIES}) -add_cmocka_test(check_vio vio_tests/check_vio.c ${TEST_TARGET_LIBRARIES}) -add_cmocka_test(check_vio_ext vio_tests/check_vio_ext.c ${TEST_TARGET_LIBRARIES}) +add_cmocka_test(check_vio_file_stat vio_tests/check_vio_file_stat.cpp ${TEST_TARGET_LIBRARIES}) +add_cmocka_test(check_vio vio_tests/check_vio.cpp ${TEST_TARGET_LIBRARIES}) +add_cmocka_test(check_vio_ext vio_tests/check_vio_ext.cpp ${TEST_TARGET_LIBRARIES}) # sync -add_cmocka_test(check_csync_update csync_tests/check_csync_update.c ${TEST_TARGET_LIBRARIES}) +add_cmocka_test(check_csync_update csync_tests/check_csync_update.cpp ${TEST_TARGET_LIBRARIES}) # encoding -add_cmocka_test(check_encoding_functions encoding_tests/check_encoding.c ${TEST_TARGET_LIBRARIES}) +add_cmocka_test(check_encoding_functions encoding_tests/check_encoding.cpp ${TEST_TARGET_LIBRARIES}) diff --git a/test/csync/COPYING b/test/csync/COPYING new file mode 100644 index 000000000..4362b4915 --- /dev/null +++ b/test/csync/COPYING @@ -0,0 +1,502 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/csync/tests/cmdline.c b/test/csync/cmdline.c similarity index 100% rename from csync/tests/cmdline.c rename to test/csync/cmdline.c diff --git a/csync/tests/csync_tests/check_csync_commit.c b/test/csync/csync_tests/check_csync_commit.cpp similarity index 95% rename from csync/tests/csync_tests/check_csync_commit.c rename to test/csync/csync_tests/check_csync_commit.cpp index 16c89bf9e..b3d77913b 100644 --- a/csync/tests/csync_tests/check_csync_commit.c +++ b/test/csync/csync_tests/check_csync_commit.cpp @@ -53,7 +53,7 @@ static int setup_module(void **state) { } static int teardown(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; int rc; rc = csync_destroy(csync); @@ -71,7 +71,7 @@ static int teardown(void **state) { static void check_csync_commit(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; int rc; rc = csync_commit(csync); @@ -82,7 +82,7 @@ static void check_csync_commit(void **state) static void check_csync_commit_dummy(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; int rc; rc = csync_commit(csync); diff --git a/csync/tests/csync_tests/check_csync_create.c b/test/csync/csync_tests/check_csync_create.cpp similarity index 100% rename from csync/tests/csync_tests/check_csync_create.c rename to test/csync/csync_tests/check_csync_create.cpp diff --git a/csync/tests/csync_tests/check_csync_exclude.c b/test/csync/csync_tests/check_csync_exclude.cpp similarity index 97% rename from csync/tests/csync_tests/check_csync_exclude.c rename to test/csync/csync_tests/check_csync_exclude.cpp index ea9ca0e2f..5841eddf0 100644 --- a/csync/tests/csync_tests/check_csync_exclude.c +++ b/test/csync/csync_tests/check_csync_exclude.cpp @@ -25,9 +25,9 @@ #include "torture.h" #define CSYNC_TEST 1 -#include "csync_exclude.c" +#include "csync_exclude.cpp" -#define EXCLUDE_LIST_FILE SOURCEDIR"/../sync-exclude.lst" +#define EXCLUDE_LIST_FILE SOURCEDIR"/../../sync-exclude.lst" static int setup(void **state) { CSYNC *csync; @@ -64,7 +64,7 @@ static int setup_init(void **state) { } static int teardown(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; int rc; rc = csync_destroy(csync); @@ -82,14 +82,14 @@ static int teardown(void **state) { static void check_csync_exclude_add(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; _csync_exclude_add(&(csync->excludes), "/tmp/check_csync1/*"); assert_string_equal(csync->excludes->vector[0], "/tmp/check_csync1/*"); } static void check_csync_exclude_load(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; int rc; rc = csync_exclude_load(EXCLUDE_LIST_FILE, &(csync->excludes) ); @@ -101,7 +101,7 @@ static void check_csync_exclude_load(void **state) static void check_csync_excluded(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; int rc; rc = csync_excluded_no_ctx(csync->excludes, "", CSYNC_FTW_TYPE_FILE); @@ -221,7 +221,7 @@ static void check_csync_excluded(void **state) static void check_csync_excluded_traversal(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; int rc; _csync_exclude_add( &(csync->excludes), "/exclude" ); @@ -271,7 +271,7 @@ static void check_csync_excluded_traversal(void **state) static void check_csync_pathes(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; int rc; _csync_exclude_add( &(csync->excludes), "/exclude" ); @@ -319,7 +319,7 @@ static void check_csync_pathes(void **state) assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST); } -static void check_csync_is_windows_reserved_word() { +static void check_csync_is_windows_reserved_word(void **) { assert_true(csync_is_windows_reserved_word("CON")); assert_true(csync_is_windows_reserved_word("con")); assert_true(csync_is_windows_reserved_word("CON.")); @@ -339,7 +339,7 @@ static void check_csync_is_windows_reserved_word() { static void check_csync_excluded_performance(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; const int N = 10000; int totalRc = 0; diff --git a/csync/tests/csync_tests/check_csync_init.c b/test/csync/csync_tests/check_csync_init.cpp similarity index 96% rename from csync/tests/csync_tests/check_csync_init.c rename to test/csync/csync_tests/check_csync_init.cpp index 41876d638..c0b4cdd6b 100644 --- a/csync/tests/csync_tests/check_csync_init.c +++ b/test/csync/csync_tests/check_csync_init.cpp @@ -50,7 +50,7 @@ static int setup_module(void **state) { } static int teardown(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; int rc; rc = csync_destroy(csync); @@ -68,7 +68,7 @@ static int teardown(void **state) { static void check_csync_init(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; csync_init(csync, ""); diff --git a/csync/tests/csync_tests/check_csync_log.c b/test/csync/csync_tests/check_csync_log.cpp similarity index 98% rename from csync/tests/csync_tests/check_csync_log.c rename to test/csync/csync_tests/check_csync_log.cpp index 9523d9627..c5f312ff5 100644 --- a/csync/tests/csync_tests/check_csync_log.c +++ b/test/csync/csync_tests/check_csync_log.cpp @@ -23,7 +23,7 @@ #include "torture.h" #include "csync.h" -#include "csync_log.c" +#include "csync_log.cpp" #include "c_private.h" static int setup(void **state) { @@ -41,7 +41,7 @@ static int setup(void **state) { } static int teardown(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; int rc; rc = csync_destroy(csync); diff --git a/csync/tests/csync_tests/check_csync_misc.c b/test/csync/csync_tests/check_csync_misc.cpp similarity index 100% rename from csync/tests/csync_tests/check_csync_misc.c rename to test/csync/csync_tests/check_csync_misc.cpp diff --git a/csync/tests/csync_tests/check_csync_statedb_load.c b/test/csync/csync_tests/check_csync_statedb_load.cpp similarity index 95% rename from csync/tests/csync_tests/check_csync_statedb_load.c rename to test/csync/csync_tests/check_csync_statedb_load.cpp index c4b34b500..a7bccd7ea 100644 --- a/csync/tests/csync_tests/check_csync_statedb_load.c +++ b/test/csync/csync_tests/check_csync_statedb_load.cpp @@ -22,7 +22,7 @@ #include "torture.h" #define CSYNC_TEST 1 -#include "csync_statedb.c" +#include "csync_statedb.cpp" #define TESTDB "/tmp/check_csync1/test.db" @@ -52,7 +52,7 @@ static int setup(void **state) { } static int teardown(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; int rc; rc = csync_destroy(csync); @@ -68,7 +68,7 @@ static int teardown(void **state) { static void check_csync_statedb_load(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; int rc; rc = csync_statedb_load(csync, TESTDB, &csync->statedb.db); @@ -79,7 +79,7 @@ static void check_csync_statedb_load(void **state) static void check_csync_statedb_close(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; csync_stat_t sb; time_t modtime; mbchar_t *testdb = c_utf8_path_to_locale(TESTDB); diff --git a/csync/tests/csync_tests/check_csync_statedb_query.c b/test/csync/csync_tests/check_csync_statedb_query.cpp similarity index 93% rename from csync/tests/csync_tests/check_csync_statedb_query.c rename to test/csync/csync_tests/check_csync_statedb_query.cpp index 603195e8c..843900ec2 100644 --- a/csync/tests/csync_tests/check_csync_statedb_query.c +++ b/test/csync/csync_tests/check_csync_statedb_query.cpp @@ -20,7 +20,7 @@ #include "torture.h" #define CSYNC_TEST 1 -#include "csync_statedb.c" +#include "csync_statedb.cpp" #define TESTDB "/tmp/check_csync1/test.db" #define TESTDBTMP "/tmp/check_csync1/test.db.ctmp" @@ -97,7 +97,7 @@ static int setup_db(void **state) } static int teardown(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; int rc = 0; rc = csync_destroy(csync); @@ -115,7 +115,7 @@ static int teardown(void **state) { static void check_csync_statedb_query_statement(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; c_strlist_t *result; result = csync_statedb_query(csync->statedb.db, ""); @@ -133,7 +133,7 @@ static void check_csync_statedb_query_statement(void **state) static void check_csync_statedb_drop_tables(void **state) { - // CSYNC *csync = *state; + // CSYNC *csync = (CSYNC*)*state; int rc = 0; (void) state; @@ -147,7 +147,7 @@ static void check_csync_statedb_drop_tables(void **state) static void check_csync_statedb_insert_metadata(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; csync_file_stat_t *st; int i, rc = 0; @@ -155,7 +155,7 @@ static void check_csync_statedb_insert_metadata(void **state) assert_int_equal(rc, 0); for (i = 0; i < 100; i++) { - st = c_malloc(sizeof(csync_file_stat_t) + 30 ); + st = (csync_file_stat_t*)c_malloc(sizeof(csync_file_stat_t) + 30 ); snprintf(st->path, 29, "file_%d" , i ); st->phash = i; @@ -169,12 +169,12 @@ static void check_csync_statedb_insert_metadata(void **state) static void check_csync_statedb_write(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; csync_file_stat_t *st; int i, rc; for (i = 0; i < 100; i++) { - st = c_malloc(sizeof(csync_file_stat_t) + 30); + st = (csync_file_stat_t*)c_malloc(sizeof(csync_file_stat_t) + 30); snprintf(st->path, 29, "file_%d" , i ); st->phash = i; @@ -189,7 +189,7 @@ static void check_csync_statedb_write(void **state) static void check_csync_statedb_get_stat_by_hash_not_found(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; csync_file_stat_t *tmp; tmp = csync_statedb_get_stat_by_hash(csync, (uint64_t) 666); @@ -201,7 +201,7 @@ static void check_csync_statedb_get_stat_by_hash_not_found(void **state) static void check_csync_statedb_get_stat_by_inode_not_found(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; csync_file_stat_t *tmp; tmp = csync_statedb_get_stat_by_inode(csync, (ino_t) 666); diff --git a/csync/tests/csync_tests/check_csync_update.c b/test/csync/csync_tests/check_csync_update.cpp similarity index 94% rename from csync/tests/csync_tests/check_csync_update.c rename to test/csync/csync_tests/check_csync_update.cpp index 695616b2c..237687e4c 100644 --- a/csync/tests/csync_tests/check_csync_update.c +++ b/test/csync/csync_tests/check_csync_update.cpp @@ -19,7 +19,7 @@ */ #include "torture.h" -#include "csync_update.c" +#include "csync_update.cpp" #define TESTDB "/tmp/check_csync/journal.db" @@ -150,7 +150,7 @@ static int setup_ftw(void **state) static int teardown(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; int rc; unlink( csync->statedb.file); @@ -233,7 +233,7 @@ static csync_vio_file_stat_t* create_fstat(const char *name, static int failing_fn(CSYNC *ctx, const char *file, const csync_vio_file_stat_t *fs, - enum csync_ftw_flags_e flag) + int flag) { (void) ctx; (void) file; @@ -246,7 +246,7 @@ static int failing_fn(CSYNC *ctx, /* detect a new file */ static void check_csync_detect_update(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; csync_file_stat_t *st; csync_vio_file_stat_t *fs; int rc; @@ -261,7 +261,7 @@ static void check_csync_detect_update(void **state) assert_int_equal(rc, 0); /* the instruction should be set to new */ - st = c_rbtree_node_data(csync->local.tree->root); + st = (csync_file_stat_t*)c_rbtree_node_data(csync->local.tree->root); assert_int_equal(st->instruction, CSYNC_INSTRUCTION_NEW); /* create a statedb */ @@ -275,7 +275,7 @@ static void check_csync_detect_update(void **state) */ static void check_csync_detect_update_db_none(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; csync_file_stat_t *st; csync_vio_file_stat_t *fs; int rc; @@ -290,7 +290,7 @@ static void check_csync_detect_update_db_none(void **state) assert_int_equal(rc, 0); /* the instruction should be set to new */ - st = c_rbtree_node_data(csync->local.tree->root); + st = (csync_file_stat_t*)c_rbtree_node_data(csync->local.tree->root); assert_int_equal(st->instruction, CSYNC_INSTRUCTION_NEW); @@ -302,7 +302,7 @@ static void check_csync_detect_update_db_none(void **state) static void check_csync_detect_update_db_eval(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; csync_file_stat_t *st; csync_vio_file_stat_t *fs; int rc; @@ -317,7 +317,7 @@ static void check_csync_detect_update_db_eval(void **state) assert_int_equal(rc, 0); /* the instruction should be set to new */ - st = c_rbtree_node_data(csync->local.tree->root); + st = (csync_file_stat_t*)c_rbtree_node_data(csync->local.tree->root); assert_int_equal(st->instruction, CSYNC_INSTRUCTION_NEW); /* create a statedb */ @@ -329,7 +329,7 @@ static void check_csync_detect_update_db_eval(void **state) static void check_csync_detect_update_db_rename(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; // csync_file_stat_t *st; csync_vio_file_stat_t *fs; @@ -348,7 +348,7 @@ static void check_csync_detect_update_db_rename(void **state) /* the instruction should be set to rename */ /* * temporarily broken. - st = c_rbtree_node_data(csync->local.tree->root); + st = (csync_file_stat_t*)c_rbtree_node_data(csync->local.tree->root); assert_int_equal(st->instruction, CSYNC_INSTRUCTION_RENAME); st->instruction = CSYNC_INSTRUCTION_UPDATED; @@ -361,7 +361,7 @@ static void check_csync_detect_update_db_rename(void **state) static void check_csync_detect_update_db_new(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; csync_file_stat_t *st; csync_vio_file_stat_t *fs; int rc; @@ -376,7 +376,7 @@ static void check_csync_detect_update_db_new(void **state) assert_int_equal(rc, 0); /* the instruction should be set to new */ - st = c_rbtree_node_data(csync->local.tree->root); + st = (csync_file_stat_t*)c_rbtree_node_data(csync->local.tree->root); assert_int_equal(st->instruction, CSYNC_INSTRUCTION_NEW); @@ -388,7 +388,7 @@ static void check_csync_detect_update_db_new(void **state) static void check_csync_detect_update_null(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; csync_vio_file_stat_t *fs; int rc; @@ -412,7 +412,7 @@ static void check_csync_detect_update_null(void **state) static void check_csync_ftw(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; int rc; rc = csync_ftw(csync, "/tmp", csync_walker, MAX_DEPTH); @@ -421,7 +421,7 @@ static void check_csync_ftw(void **state) static void check_csync_ftw_empty_uri(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; int rc; rc = csync_ftw(csync, "", csync_walker, MAX_DEPTH); @@ -430,7 +430,7 @@ static void check_csync_ftw_empty_uri(void **state) static void check_csync_ftw_failing_fn(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; int rc; rc = csync_ftw(csync, "/tmp", failing_fn, MAX_DEPTH); @@ -454,4 +454,3 @@ int torture_run_tests(void) return cmocka_run_group_tests(tests, NULL, NULL); } - diff --git a/csync/tests/csync_tests/check_csync_util.c b/test/csync/csync_tests/check_csync_util.cpp similarity index 95% rename from csync/tests/csync_tests/check_csync_util.c rename to test/csync/csync_tests/check_csync_util.cpp index e55c4ce77..0df637741 100644 --- a/csync/tests/csync_tests/check_csync_util.c +++ b/test/csync/csync_tests/check_csync_util.cpp @@ -30,7 +30,7 @@ static void check_csync_instruction_str(void **state) str = csync_instruction_str(CSYNC_INSTRUCTION_ERROR); assert_string_equal(str, "INSTRUCTION_ERROR"); - str = csync_instruction_str(0xFFFF); + str = csync_instruction_str((enum csync_instructions_e)0xFFFF); assert_string_equal(str, "ERROR!"); } diff --git a/csync/tests/encoding_tests/check_encoding.c b/test/csync/encoding_tests/check_encoding.cpp similarity index 89% rename from csync/tests/encoding_tests/check_encoding.c rename to test/csync/encoding_tests/check_encoding.cpp index eb761d318..443d2c625 100644 --- a/csync/tests/encoding_tests/check_encoding.c +++ b/test/csync/encoding_tests/check_encoding.cpp @@ -27,16 +27,6 @@ #endif -static void setup(void **state) -{ - (void) state; /* unused */ -} - -static void teardown(void **state) -{ - (void) state; /* unused */ -} - static void check_iconv_to_native_normalization(void **state) { mbchar_t *out = NULL; @@ -191,15 +181,15 @@ static void check_long_win_path(void **state) int torture_run_tests(void) { - const UnitTest tests[] = { - unit_test_setup_teardown(check_long_win_path, setup, teardown), - unit_test_setup_teardown(check_to_multibyte, setup, teardown), - unit_test_setup_teardown(check_iconv_ascii, setup, teardown), - unit_test_setup_teardown(check_iconv_to_native_normalization, setup, teardown), - unit_test_setup_teardown(check_iconv_from_native_normalization, setup, teardown), + const struct CMUnitTest tests[] = { + cmocka_unit_test(check_long_win_path), + cmocka_unit_test(check_to_multibyte), + cmocka_unit_test(check_iconv_ascii), + cmocka_unit_test(check_iconv_to_native_normalization), + cmocka_unit_test(check_iconv_from_native_normalization), }; - return run_tests(tests); + return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/csync/tests/log_tests/check_log.c b/test/csync/log_tests/check_log.cpp similarity index 100% rename from csync/tests/log_tests/check_log.c rename to test/csync/log_tests/check_log.cpp diff --git a/csync/tests/std_tests/check_std_c_alloc.c b/test/csync/std_tests/check_std_c_alloc.c similarity index 87% rename from csync/tests/std_tests/check_std_c_alloc.c rename to test/csync/std_tests/check_std_c_alloc.c index 80a6a58da..bcdf7e1cf 100644 --- a/csync/tests/std_tests/check_std_c_alloc.c +++ b/test/csync/std_tests/check_std_c_alloc.c @@ -77,13 +77,13 @@ static void check_c_strndup(void **state) int torture_run_tests(void) { - const UnitTest tests[] = { - unit_test(check_c_malloc), - unit_test(check_c_malloc_zero), - unit_test(check_c_strdup), - unit_test(check_c_strndup), + const struct CMUnitTest tests[] = { + cmocka_unit_test(check_c_malloc), + cmocka_unit_test(check_c_malloc_zero), + cmocka_unit_test(check_c_strdup), + cmocka_unit_test(check_c_strndup), }; - return run_tests(tests); + return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/csync/tests/std_tests/check_std_c_jhash.c b/test/csync/std_tests/check_std_c_jhash.c similarity index 95% rename from csync/tests/std_tests/check_std_c_jhash.c rename to test/csync/std_tests/check_std_c_jhash.c index 9d8384de9..29dc32207 100644 --- a/csync/tests/std_tests/check_std_c_jhash.c +++ b/test/csync/std_tests/check_std_c_jhash.c @@ -278,15 +278,15 @@ static void check_c_jhash64_null_strings(void **state) int torture_run_tests(void) { - const UnitTest tests[] = { - unit_test(check_c_jhash_trials), - unit_test(check_c_jhash_alignment_problems), - unit_test(check_c_jhash_null_strings), - unit_test(check_c_jhash64_trials), - unit_test(check_c_jhash64_alignment_problems), - unit_test(check_c_jhash64_null_strings), + const struct CMUnitTest tests[] = { + cmocka_unit_test(check_c_jhash_trials), + cmocka_unit_test(check_c_jhash_alignment_problems), + cmocka_unit_test(check_c_jhash_null_strings), + cmocka_unit_test(check_c_jhash64_trials), + cmocka_unit_test(check_c_jhash64_alignment_problems), + cmocka_unit_test(check_c_jhash64_null_strings), }; - return run_tests(tests); + return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/csync/tests/std_tests/check_std_c_path.c b/test/csync/std_tests/check_std_c_path.c similarity index 93% rename from csync/tests/std_tests/check_std_c_path.c rename to test/csync/std_tests/check_std_c_path.c index 208a0b90a..25a250aab 100644 --- a/csync/tests/std_tests/check_std_c_path.c +++ b/test/csync/std_tests/check_std_c_path.c @@ -172,14 +172,14 @@ static void check_c_parse_uri(void **state) int torture_run_tests(void) { - const UnitTest tests[] = { - unit_test(check_c_basename), - unit_test(check_c_basename_uri), - unit_test(check_c_dirname), - unit_test(check_c_dirname_uri), - unit_test(check_c_parse_uri), + const struct CMUnitTest tests[] = { + cmocka_unit_test(check_c_basename), + cmocka_unit_test(check_c_basename_uri), + cmocka_unit_test(check_c_dirname), + cmocka_unit_test(check_c_dirname_uri), + cmocka_unit_test(check_c_parse_uri), }; - return run_tests(tests); + return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/csync/tests/std_tests/check_std_c_rbtree.c b/test/csync/std_tests/check_std_c_rbtree.c similarity index 87% rename from csync/tests/std_tests/check_std_c_rbtree.c rename to test/csync/std_tests/check_std_c_rbtree.c index 735096541..a493ae3c9 100644 --- a/csync/tests/std_tests/check_std_c_rbtree.c +++ b/test/csync/std_tests/check_std_c_rbtree.c @@ -82,15 +82,16 @@ static void destructor(void *data) { SAFE_FREE(freedata); } -static void setup(void **state) { +static int setup(void **state) { c_rbtree_t *tree = NULL; c_rbtree_create(&tree, key_cmp, data_cmp); *state = tree; + return 0; } -static void setup_complete_tree(void **state) { +static int setup_complete_tree(void **state) { c_rbtree_t *tree = NULL; int i = 0; int rc; @@ -110,15 +111,17 @@ static void setup_complete_tree(void **state) { } *state = tree; + return 0; } -static void teardown(void **state) { +static int teardown(void **state) { c_rbtree_t *tree = *state; c_rbtree_destroy(tree, destructor); c_rbtree_free(tree); *state = NULL; + return 0; } static void check_c_rbtree_create_free(void **state) @@ -345,19 +348,19 @@ static void check_c_rbtree_x) int torture_run_tests(void) { - const UnitTest tests[] = { - unit_test(check_c_rbtree_create_free), - unit_test(check_c_rbtree_free_null), - unit_test(check_c_rbtree_insert_delete), - unit_test_setup_teardown(check_c_rbtree_insert_random, setup, teardown), - unit_test_setup_teardown(check_c_rbtree_insert_duplicate, setup, teardown), - unit_test_setup_teardown(check_c_rbtree_find, setup_complete_tree, teardown), - unit_test_setup_teardown(check_c_rbtree_delete, setup_complete_tree, teardown), - unit_test_setup_teardown(check_c_rbtree_walk, setup_complete_tree, teardown), - unit_test_setup_teardown(check_c_rbtree_walk_null, setup_complete_tree, teardown), - unit_test_setup_teardown(check_c_rbtree_dup, setup_complete_tree, teardown), + const struct CMUnitTest tests[] = { + cmocka_unit_test(check_c_rbtree_create_free), + cmocka_unit_test(check_c_rbtree_free_null), + cmocka_unit_test(check_c_rbtree_insert_delete), + cmocka_unit_test_setup_teardown(check_c_rbtree_insert_random, setup, teardown), + cmocka_unit_test_setup_teardown(check_c_rbtree_insert_duplicate, setup, teardown), + cmocka_unit_test_setup_teardown(check_c_rbtree_find, setup_complete_tree, teardown), + cmocka_unit_test_setup_teardown(check_c_rbtree_delete, setup_complete_tree, teardown), + cmocka_unit_test_setup_teardown(check_c_rbtree_walk, setup_complete_tree, teardown), + cmocka_unit_test_setup_teardown(check_c_rbtree_walk_null, setup_complete_tree, teardown), + cmocka_unit_test_setup_teardown(check_c_rbtree_dup, setup_complete_tree, teardown), }; - return run_tests(tests); + return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/csync/tests/std_tests/check_std_c_str.c b/test/csync/std_tests/check_std_c_str.c similarity index 88% rename from csync/tests/std_tests/check_std_c_str.c rename to test/csync/std_tests/check_std_c_str.c index 08cb1aac7..20921b100 100644 --- a/csync/tests/std_tests/check_std_c_str.c +++ b/test/csync/std_tests/check_std_c_str.c @@ -117,15 +117,15 @@ static void check_c_strlist_expand(void **state) int torture_run_tests(void) { - const UnitTest tests[] = { - unit_test(check_c_streq_equal), - unit_test(check_c_streq_not_equal), - unit_test(check_c_streq_null), - unit_test(check_c_strlist_new), - unit_test(check_c_strlist_add), - unit_test(check_c_strlist_expand), + const struct CMUnitTest tests[] = { + cmocka_unit_test(check_c_streq_equal), + cmocka_unit_test(check_c_streq_not_equal), + cmocka_unit_test(check_c_streq_null), + cmocka_unit_test(check_c_strlist_new), + cmocka_unit_test(check_c_strlist_add), + cmocka_unit_test(check_c_strlist_expand), }; - return run_tests(tests); + return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/csync/tests/std_tests/check_std_c_time.c b/test/csync/std_tests/check_std_c_time.c similarity index 88% rename from csync/tests/std_tests/check_std_c_time.c rename to test/csync/std_tests/check_std_c_time.c index df1abbe05..56fc6ad40 100644 --- a/csync/tests/std_tests/check_std_c_time.c +++ b/test/csync/std_tests/check_std_c_time.c @@ -88,13 +88,13 @@ static void check_c_secdiff_three(void **state) int torture_run_tests(void) { - const UnitTest tests[] = { - unit_test(check_c_tspecdiff), - unit_test(check_c_tspecdiff_five), - unit_test(check_c_secdiff), - unit_test(check_c_secdiff_three), + const struct CMUnitTest tests[] = { + cmocka_unit_test(check_c_tspecdiff), + cmocka_unit_test(check_c_tspecdiff_five), + cmocka_unit_test(check_c_secdiff), + cmocka_unit_test(check_c_secdiff_three), }; - return run_tests(tests); + return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/csync/tests/torture.c b/test/csync/torture.c similarity index 100% rename from csync/tests/torture.c rename to test/csync/torture.c diff --git a/csync/tests/torture.h b/test/csync/torture.h similarity index 95% rename from csync/tests/torture.h rename to test/csync/torture.h index b3272b8c1..045518ecc 100644 --- a/csync/tests/torture.h +++ b/test/csync/torture.h @@ -20,6 +20,10 @@ #ifndef _TORTURE_H #define _TORTURE_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include #include @@ -41,4 +45,8 @@ int torture_csync_verbosity(void); */ int torture_run_tests(void); +#ifdef __cplusplus +} +#endif + #endif /* _TORTURE_H */ diff --git a/csync/tests/valgrind-csync.supp b/test/csync/valgrind-csync.supp similarity index 100% rename from csync/tests/valgrind-csync.supp rename to test/csync/valgrind-csync.supp diff --git a/csync/tests/vio_tests/check_vio.c b/test/csync/vio_tests/check_vio.cpp similarity index 82% rename from csync/tests/vio_tests/check_vio.c rename to test/csync/vio_tests/check_vio.cpp index 6d4afd7ef..fc87485bf 100644 --- a/csync/tests/vio_tests/check_vio.c +++ b/test/csync/vio_tests/check_vio.cpp @@ -38,7 +38,7 @@ static char wd_buffer[WD_BUFFER_SIZE]; -static void setup(void **state) +static int setup(void **state) { CSYNC *csync; int rc; @@ -53,9 +53,10 @@ static void setup(void **state) csync->replica = LOCAL_REPLICA; *state = csync; + return 0; } -static void setup_dir(void **state) { +static int setup_dir(void **state) { int rc; mbchar_t *dir = c_utf8_path_to_locale(CSYNC_TEST_DIR); @@ -69,10 +70,11 @@ static void setup_dir(void **state) { rc = chdir(CSYNC_TEST_DIR); assert_int_equal(rc, 0); + return 0; } -static void teardown(void **state) { - CSYNC *csync = *state; +static int teardown(void **state) { + CSYNC *csync = (CSYNC*)*state; int rc; rc = csync_destroy(csync); @@ -85,6 +87,7 @@ static void teardown(void **state) { assert_int_equal(rc, 0); *state = NULL; + return 0; } @@ -94,7 +97,7 @@ static void teardown(void **state) { static void check_csync_vio_opendir(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; csync_vio_handle_t *dh; int rc; @@ -107,7 +110,7 @@ static void check_csync_vio_opendir(void **state) static void check_csync_vio_opendir_perm(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; csync_vio_handle_t *dh; int rc; mbchar_t *dir = c_utf8_path_to_locale(CSYNC_TEST_DIR); @@ -127,7 +130,7 @@ static void check_csync_vio_opendir_perm(void **state) static void check_csync_vio_closedir_null(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; int rc; rc = csync_vio_closedir(csync, NULL); @@ -136,7 +139,7 @@ static void check_csync_vio_closedir_null(void **state) static void check_csync_vio_readdir(void **state) { - CSYNC *csync = *state; + CSYNC *csync = (CSYNC*)*state; csync_vio_handle_t *dh; csync_vio_file_stat_t *dirent; int rc; @@ -155,13 +158,12 @@ static void check_csync_vio_readdir(void **state) int torture_run_tests(void) { - const UnitTest tests[] = { - unit_test_setup_teardown(check_csync_vio_opendir, setup_dir, teardown), - unit_test_setup_teardown(check_csync_vio_opendir_perm, setup, teardown), - unit_test(check_csync_vio_closedir_null), - unit_test_setup_teardown(check_csync_vio_readdir, setup_dir, teardown), + const struct CMUnitTest tests[] = { + cmocka_unit_test_setup_teardown(check_csync_vio_opendir, setup_dir, teardown), + cmocka_unit_test_setup_teardown(check_csync_vio_opendir_perm, setup, teardown), + cmocka_unit_test(check_csync_vio_closedir_null), + cmocka_unit_test_setup_teardown(check_csync_vio_readdir, setup_dir, teardown), }; - return run_tests(tests); + return cmocka_run_group_tests(tests, NULL, NULL); } - diff --git a/csync/tests/vio_tests/check_vio_ext.c b/test/csync/vio_tests/check_vio_ext.cpp similarity index 95% rename from csync/tests/vio_tests/check_vio_ext.c rename to test/csync/vio_tests/check_vio_ext.cpp index c34e708c0..fa2c771c3 100644 --- a/csync/tests/vio_tests/check_vio_ext.c +++ b/test/csync/vio_tests/check_vio_ext.cpp @@ -74,7 +74,7 @@ static int wipe_testdir() return rc; } -static void setup_testenv(void **state) { +static int setup_testenv(void **state) { int rc; rc = wipe_testdir(); @@ -93,7 +93,7 @@ static void setup_testenv(void **state) { c_free_locale_string(dir); /* --- initialize csync */ - statevar *mystate = malloc( sizeof(statevar) ); + statevar *mystate = (statevar*)malloc( sizeof(statevar) ); mystate->result = NULL; csync_create(&(mystate->csync), "/tmp/csync1"); @@ -101,6 +101,7 @@ static void setup_testenv(void **state) { mystate->csync->replica = LOCAL_REPLICA; *state = mystate; + return 0; } static void output( const char *text ) @@ -115,7 +116,7 @@ static void output( const char *text ) c_free_locale_string(wtext); } -static void teardown(void **state) { +static int teardown(void **state) { statevar *sv = (statevar*) *state; CSYNC *csync = sv->csync; int rc; @@ -132,6 +133,7 @@ static void teardown(void **state) { assert_int_equal(rc, 0); *state = NULL; + return 0; } /* This function takes a relative path, prepends it with the CSYNC_TEST_DIR @@ -140,7 +142,7 @@ static void teardown(void **state) { static void create_dirs( const char *path ) { int rc; - char *mypath = c_malloc( 2+strlen(CSYNC_TEST_DIR)+strlen(path)); + char *mypath = (char*)c_malloc( 2+strlen(CSYNC_TEST_DIR)+strlen(path)); *mypath = '\0'; strcat(mypath, CSYNC_TEST_DIR); strcat(mypath, "/"); @@ -229,7 +231,7 @@ static void traverse_dir(void **state, const char *dir, int *cnt) } else { int newlen = 1+strlen(sv->result)+strlen(subdir_out); char *tmp = sv->result; - sv->result = c_malloc(newlen); + sv->result = (char*)c_malloc(newlen); strcpy( sv->result, tmp); SAFE_FREE(tmp); @@ -284,7 +286,7 @@ static void create_file( const char *path, const char *name, const char *content SAFE_FREE(dst); c_free_locale_string(w_fname); #else - char *filepath = c_malloc( 1+strlen(path) + strlen(name) ); + char *filepath = (char*)c_malloc( 1+strlen(path) + strlen(name) ); *filepath = '\0'; strcpy(filepath, path); @@ -406,7 +408,7 @@ static void check_readdir_longtree(void **state) /* assemble the result string ... */ int overall_len = 1+strlen(r1)+strlen(r2)+strlen(r3); int files_cnt = 0; - char *result = c_malloc(overall_len); + char *result = (char*)c_malloc(overall_len); *result = '\0'; strcat(result, r1); @@ -453,12 +455,12 @@ static void check_readdir_bigunicode(void **state) int torture_run_tests(void) { - const UnitTest tests[] = { - unit_test_setup_teardown(check_readdir_shorttree, setup_testenv, teardown), - unit_test_setup_teardown(check_readdir_with_content, setup_testenv, teardown), - unit_test_setup_teardown(check_readdir_longtree, setup_testenv, teardown), - unit_test_setup_teardown(check_readdir_bigunicode, setup_testenv, teardown), + const struct CMUnitTest tests[] = { + cmocka_unit_test_setup_teardown(check_readdir_shorttree, setup_testenv, teardown), + cmocka_unit_test_setup_teardown(check_readdir_with_content, setup_testenv, teardown), + cmocka_unit_test_setup_teardown(check_readdir_longtree, setup_testenv, teardown), + cmocka_unit_test_setup_teardown(check_readdir_bigunicode, setup_testenv, teardown), }; - return run_tests(tests); + return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/csync/tests/vio_tests/check_vio_file_stat.c b/test/csync/vio_tests/check_vio_file_stat.cpp similarity index 88% rename from csync/tests/vio_tests/check_vio_file_stat.c rename to test/csync/vio_tests/check_vio_file_stat.cpp index a67255e81..3bca997a1 100644 --- a/csync/tests/vio_tests/check_vio_file_stat.c +++ b/test/csync/vio_tests/check_vio_file_stat.cpp @@ -36,10 +36,10 @@ static void check_csync_vio_file_stat_new(void **state) int torture_run_tests(void) { - const UnitTest tests[] = { - unit_test(check_csync_vio_file_stat_new), + const struct CMUnitTest tests[] = { + cmocka_unit_test(check_csync_vio_file_stat_new), }; - return run_tests(tests); + return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/test/owncloud_add_test.cmake b/test/owncloud_add_test.cmake index cefe264ea..7e7cc5057 100644 --- a/test/owncloud_add_test.cmake +++ b/test/owncloud_add_test.cmake @@ -1,11 +1,4 @@ macro(owncloud_add_test test_class additional_cpp) - include_directories(${QT_INCLUDES} - "${PROJECT_SOURCE_DIR}/src/gui" - "${PROJECT_SOURCE_DIR}/src/libsync" - "${CMAKE_BINARY_DIR}/src/libsync" - "${CMAKE_CURRENT_BINARY_DIR}" - ) - set(CMAKE_AUTOMOC TRUE) set(OWNCLOUD_TEST_CLASS ${test_class}) string(TOLOWER "${OWNCLOUD_TEST_CLASS}" OWNCLOUD_TEST_CLASS_LOWERCASE) @@ -27,14 +20,6 @@ macro(owncloud_add_test test_class additional_cpp) endmacro() macro(owncloud_add_benchmark test_class additional_cpp) - include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${QT_INCLUDES} - "${PROJECT_SOURCE_DIR}/src/gui" - "${PROJECT_SOURCE_DIR}/src/libsync" - "${CMAKE_BINARY_DIR}/src/libsync" - "${CMAKE_CURRENT_BINARY_DIR}" - ) - set(CMAKE_AUTOMOC TRUE) set(OWNCLOUD_TEST_CLASS ${test_class}) string(TOLOWER "${OWNCLOUD_TEST_CLASS}" OWNCLOUD_TEST_CLASS_LOWERCASE) diff --git a/csync/tests/ownCloud/.gitignore b/test/scripts/txpl/.gitignore similarity index 100% rename from csync/tests/ownCloud/.gitignore rename to test/scripts/txpl/.gitignore diff --git a/csync/tests/ownCloud/README b/test/scripts/txpl/README similarity index 100% rename from csync/tests/ownCloud/README rename to test/scripts/txpl/README diff --git a/csync/tests/ownCloud/exclude.cfg b/test/scripts/txpl/exclude.cfg similarity index 100% rename from csync/tests/ownCloud/exclude.cfg rename to test/scripts/txpl/exclude.cfg diff --git a/csync/tests/ownCloud/ownCloud/Test.pm b/test/scripts/txpl/ownCloud/Test.pm similarity index 100% rename from csync/tests/ownCloud/ownCloud/Test.pm rename to test/scripts/txpl/ownCloud/Test.pm diff --git a/csync/tests/ownCloud/t1.cfg.in b/test/scripts/txpl/t1.cfg.in similarity index 100% rename from csync/tests/ownCloud/t1.cfg.in rename to test/scripts/txpl/t1.cfg.in diff --git a/csync/tests/ownCloud/t1.pl b/test/scripts/txpl/t1.pl similarity index 100% rename from csync/tests/ownCloud/t1.pl rename to test/scripts/txpl/t1.pl diff --git a/csync/tests/ownCloud/t2.pl b/test/scripts/txpl/t2.pl similarity index 100% rename from csync/tests/ownCloud/t2.pl rename to test/scripts/txpl/t2.pl diff --git a/csync/tests/ownCloud/t3.pl b/test/scripts/txpl/t3.pl similarity index 100% rename from csync/tests/ownCloud/t3.pl rename to test/scripts/txpl/t3.pl diff --git a/csync/tests/ownCloud/t4.pl b/test/scripts/txpl/t4.pl similarity index 100% rename from csync/tests/ownCloud/t4.pl rename to test/scripts/txpl/t4.pl diff --git a/csync/tests/ownCloud/t5.pl b/test/scripts/txpl/t5.pl similarity index 100% rename from csync/tests/ownCloud/t5.pl rename to test/scripts/txpl/t5.pl diff --git a/csync/tests/ownCloud/t6.pl b/test/scripts/txpl/t6.pl similarity index 100% rename from csync/tests/ownCloud/t6.pl rename to test/scripts/txpl/t6.pl diff --git a/csync/tests/ownCloud/t7.pl b/test/scripts/txpl/t7.pl similarity index 100% rename from csync/tests/ownCloud/t7.pl rename to test/scripts/txpl/t7.pl diff --git a/csync/tests/ownCloud/t8.pl b/test/scripts/txpl/t8.pl similarity index 100% rename from csync/tests/ownCloud/t8.pl rename to test/scripts/txpl/t8.pl diff --git a/csync/tests/ownCloud/t9.pl b/test/scripts/txpl/t9.pl similarity index 100% rename from csync/tests/ownCloud/t9.pl rename to test/scripts/txpl/t9.pl diff --git a/csync/tests/ownCloud/t_recall.pl b/test/scripts/txpl/t_recall.pl similarity index 100% rename from csync/tests/ownCloud/t_recall.pl rename to test/scripts/txpl/t_recall.pl diff --git a/csync/tests/ownCloud/testfiles.tar.xz b/test/scripts/txpl/testfiles.tar.xz similarity index 100% rename from csync/tests/ownCloud/testfiles.tar.xz rename to test/scripts/txpl/testfiles.tar.xz diff --git a/csync/tests/ownCloud/testfiles/church.jpg b/test/scripts/txpl/testfiles/church.jpg similarity index 100% rename from csync/tests/ownCloud/testfiles/church.jpg rename to test/scripts/txpl/testfiles/church.jpg diff --git a/csync/tests/ownCloud/testfiles/red_is_the_rose.jpg b/test/scripts/txpl/testfiles/red_is_the_rose.jpg similarity index 100% rename from csync/tests/ownCloud/testfiles/red_is_the_rose.jpg rename to test/scripts/txpl/testfiles/red_is_the_rose.jpg diff --git a/csync/tests/ownCloud/testfiles/test.txt b/test/scripts/txpl/testfiles/test.txt similarity index 100% rename from csync/tests/ownCloud/testfiles/test.txt rename to test/scripts/txpl/testfiles/test.txt diff --git a/csync/tests/ownCloud/testfiles/zerofile.txt b/test/scripts/txpl/testfiles/zerofile.txt similarity index 100% rename from csync/tests/ownCloud/testfiles/zerofile.txt rename to test/scripts/txpl/testfiles/zerofile.txt diff --git a/csync/tests/ownCloud/toremote1/My Document.doc b/test/scripts/txpl/toremote1/My Document.doc similarity index 100% rename from csync/tests/ownCloud/toremote1/My Document.doc rename to test/scripts/txpl/toremote1/My Document.doc diff --git a/csync/tests/ownCloud/toremote1/kernelcrash.txt b/test/scripts/txpl/toremote1/kernelcrash.txt similarity index 100% rename from csync/tests/ownCloud/toremote1/kernelcrash.txt rename to test/scripts/txpl/toremote1/kernelcrash.txt diff --git a/csync/tests/ownCloud/toremote1/kraft_logo.gif b/test/scripts/txpl/toremote1/kraft_logo.gif similarity index 100% rename from csync/tests/ownCloud/toremote1/kraft_logo.gif rename to test/scripts/txpl/toremote1/kraft_logo.gif diff --git a/csync/tests/ownCloud/toremote1/rtl1/La ced b/test/scripts/txpl/toremote1/rtl1/La ced similarity index 100% rename from csync/tests/ownCloud/toremote1/rtl1/La ced rename to test/scripts/txpl/toremote1/rtl1/La ced diff --git a/csync/tests/ownCloud/toremote1/rtl1/rtl11/file.txt b/test/scripts/txpl/toremote1/rtl1/rtl11/file.txt similarity index 100% rename from csync/tests/ownCloud/toremote1/rtl1/rtl11/file.txt rename to test/scripts/txpl/toremote1/rtl1/rtl11/file.txt diff --git a/csync/tests/ownCloud/toremote1/rtl2/kb1.jpg b/test/scripts/txpl/toremote1/rtl2/kb1.jpg similarity index 100% rename from csync/tests/ownCloud/toremote1/rtl2/kb1.jpg rename to test/scripts/txpl/toremote1/rtl2/kb1.jpg diff --git a/csync/tests/ownCloud/toremote1/rtl4/quitte.pdf b/test/scripts/txpl/toremote1/rtl4/quitte.pdf similarity index 100% rename from csync/tests/ownCloud/toremote1/rtl4/quitte.pdf rename to test/scripts/txpl/toremote1/rtl4/quitte.pdf diff --git a/csync/tests/ownCloud/toremote1/rtl4/red_is_the_rose.jpg b/test/scripts/txpl/toremote1/rtl4/red_is_the_rose.jpg similarity index 100% rename from csync/tests/ownCloud/toremote1/rtl4/red_is_the_rose.jpg rename to test/scripts/txpl/toremote1/rtl4/red_is_the_rose.jpg diff --git a/csync/tests/ownCloud/toremote1/special_chars.tar.gz b/test/scripts/txpl/toremote1/special_chars.tar.gz similarity index 100% rename from csync/tests/ownCloud/toremote1/special_chars.tar.gz rename to test/scripts/txpl/toremote1/special_chars.tar.gz diff --git a/test/syncenginetestutils.h b/test/syncenginetestutils.h index 062b62cea..2feacd11f 100644 --- a/test/syncenginetestutils.h +++ b/test/syncenginetestutils.h @@ -8,6 +8,7 @@ #include "account.h" #include "creds/abstractcredentials.h" +#include "logger.h" #include "filesystem.h" #include "syncengine.h" #include "syncjournaldb.h" @@ -806,7 +807,7 @@ public: { // Needs to be done once OCC::SyncEngine::minimumFileAgeForUpload = 0; - csync_set_log_level(11); + OCC::Logger::instance()->setLogFile("-"); QDir rootDir{_tempDir.path()}; toDisk(rootDir, fileTemplate); diff --git a/test/testexcludedfiles.cpp b/test/testexcludedfiles.cpp index b52bfb5a9..cfaf73499 100644 --- a/test/testexcludedfiles.cpp +++ b/test/testexcludedfiles.cpp @@ -11,7 +11,7 @@ using namespace OCC; -#define EXCLUDE_LIST_FILE SOURCEDIR"/../sync-exclude.lst" +#define EXCLUDE_LIST_FILE SOURCEDIR"/../../sync-exclude.lst" class TestExcludedFiles: public QObject { diff --git a/test/testsyncjournaldb.cpp b/test/testsyncjournaldb.cpp index 881bb865d..9e412aa85 100644 --- a/test/testsyncjournaldb.cpp +++ b/test/testsyncjournaldb.cpp @@ -8,8 +8,8 @@ #include -#include "libsync/syncjournaldb.h" -#include "libsync/syncjournalfilerecord.h" +#include "syncjournaldb.h" +#include "syncjournalfilerecord.h" using namespace OCC;