You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
(56) |
Apr
(109) |
May
(15) |
Jun
(3) |
Jul
(37) |
Aug
(96) |
Sep
(40) |
Oct
(4) |
Nov
(54) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(47) |
Feb
(30) |
Mar
(102) |
Apr
(120) |
May
(68) |
Jun
(54) |
Jul
(53) |
Aug
(122) |
Sep
(190) |
Oct
(71) |
Nov
(85) |
Dec
(108) |
2007 |
Jan
(72) |
Feb
(190) |
Mar
(53) |
Apr
(101) |
May
(145) |
Jun
(148) |
Jul
(167) |
Aug
(143) |
Sep
(23) |
Oct
(198) |
Nov
(223) |
Dec
(195) |
2008 |
Jan
(100) |
Feb
(129) |
Mar
(79) |
Apr
(77) |
May
(34) |
Jun
(95) |
Jul
(112) |
Aug
(160) |
Sep
(82) |
Oct
(124) |
Nov
(199) |
Dec
(355) |
2009 |
Jan
(436) |
Feb
(89) |
Mar
(298) |
Apr
(189) |
May
(33) |
Jun
(88) |
Jul
(105) |
Aug
(44) |
Sep
(181) |
Oct
(87) |
Nov
(75) |
Dec
(1) |
2010 |
Jan
(63) |
Feb
(21) |
Mar
(3) |
Apr
(1) |
May
(1) |
Jun
(3) |
Jul
(26) |
Aug
(37) |
Sep
(26) |
Oct
(15) |
Nov
(13) |
Dec
|
From: <svn...@op...> - 2009-03-28 13:59:55
|
Author: dgollub Date: Sat Mar 28 14:59:51 2009 New Revision: 5374 URL: http://www.opensync.org/changeset/5374 Log: Port example plugins to latest hashtable API change. Dropped obbsolate sinkenv userdata structs. Just kept pluginenv struct as example. refs #1082 Deleted: trunk/docs/examples/plugins/src/plugin.h Modified: trunk/docs/examples/plugins/src/plugin.c trunk/docs/examples/plugins/src/simple_plugin.c Modified: trunk/docs/examples/plugins/src/plugin.c ============================================================================== --- trunk/docs/examples/plugins/src/plugin.c Sat Mar 28 14:41:02 2009 (r5373) +++ trunk/docs/examples/plugins/src/plugin.c Sat Mar 28 14:59:51 2009 (r5374) @@ -8,21 +8,11 @@ #include <string.h> -#include "plugin.h" +/* Specify any structs etc here. */ +typedef struct plugin_environment { + /* More stuff you need goes here. */ +} plugin_environment; -static void free_env(plugin_environment *env) -{ - while (env->sink_envs) { - sink_environment *sinkenv = env->sink_envs->data; - - if (sinkenv->sink) - osync_objtype_sink_unref(sinkenv->sink); - - env->sink_envs = osync_list_remove(env->sink_envs, sinkenv); - } - - osync_free(env); -} static void connect(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *userdata) { @@ -30,10 +20,6 @@ //Each time you get passed a context (which is used to track //calls to your plugin) - //cast void* userdata to the sink specific data type - sink_environment *sinkenv = (sink_environment*)userdata; - - OSyncError *error = NULL; /* @@ -50,14 +36,6 @@ */ - //If you need a hashtable you make it here - char *tablepath = osync_strdup_printf("%s/hashtable.db", osync_plugin_info_get_configdir(info)); - sinkenv->hashtable = osync_hashtable_new(tablepath, osync_objtype_sink_get_name(sink), &error); - osync_free(tablepath); - - if (!sinkenv->hashtable) - goto error; - //you can also use the anchor system to detect a device reset //or some parameter change here. Check the docs to see how it works //Now you get the last stored anchor from the device @@ -88,7 +66,7 @@ osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, sink, info, ctx, userdata); OSyncFormatEnv *formatenv = osync_plugin_info_get_format_env(info); - sink_environment *sinkenv = (sink_environment*)userdata; + OSyncHashTable *hashtable = osync_objtype_sink_get_hashtable(sink); OSyncError *error = NULL; @@ -99,7 +77,7 @@ if (slow_sync) { osync_trace(TRACE_INTERNAL, "Slow sync requested"); - if (osync_hashtable_slowsync(sinkenv->hashtable, &error)) { + if (osync_hashtable_slowsync(hashtable, &error)) { osync_context_report_osyncerror(ctx, error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); osync_error_unref(&error); @@ -132,12 +110,12 @@ osync_change_set_uid(change, uid); osync_change_set_hash(change, hash); - OSyncChangeType changetype = osync_hashtable_get_changetype(sinkenv->hashtable, change); + OSyncChangeType changetype = osync_hashtable_get_changetype(hashtable, change); osync_change_set_changetype(change, changetype); // Update entry. // Set the hash of the object (optional, only required if you use hashtabled) - osync_hashtable_update_change(sinkenv->hashtable, change); + osync_hashtable_update_change(hashtable, change); if (changetype == OSYNC_CHANGE_TYPE_UNMODIFIED) { osync_free(hash); @@ -159,7 +137,7 @@ continue; } - osync_data_set_objtype(odata, osync_objtype_sink_get_name(sinkenv->sink)); + osync_data_set_objtype(odata, osync_objtype_sink_get_name(sink)); //Now you can set the data for the object osync_change_set_data(change, odata); @@ -175,7 +153,7 @@ //When you are done looping and if you are using hashtables //check for deleted entries ... via hashtable - OSyncList *u, *uids = osync_hashtable_get_deleted(sinkenv->hashtable); + OSyncList *u, *uids = osync_hashtable_get_deleted(hashtable); for (u = uids; u; u = u->next) { OSyncChange *change = osync_change_new(&error); if (!change) { @@ -198,13 +176,13 @@ continue; } - osync_data_set_objtype(odata, osync_objtype_sink_get_name(sinkenv->sink)); + osync_data_set_objtype(odata, osync_objtype_sink_get_name(sink)); osync_change_set_data(change, odata); osync_data_unref(odata); osync_context_report_change(ctx, change); - osync_hashtable_update_change(sinkenv->hashtable, change); + osync_hashtable_update_change(hashtable, change); osync_change_unref(change); } @@ -217,9 +195,7 @@ static void commit_change(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *change, void *userdata) { - //plugin_environment *env = (plugin_environment *)userdata; - - sink_environment *sinkenv = (sink_environment*)userdata; + OSyncHashTable *hashtable = osync_objtype_sink_get_hashtable(sink); /* * Here you have to add, modify or delete a object @@ -245,7 +221,7 @@ } //If you are using hashtables you have to calculate the hash here: - osync_hashtable_update_change(sinkenv->hashtable, change); + osync_hashtable_update_change(hashtable, change); //Answer the call osync_context_report_success(ctx); @@ -257,7 +233,6 @@ * This function will only be called if the sync was successful */ OSyncError *error = NULL; - sink_environment *sinkenv = (sink_environment*)userdata; //If we use anchors we have to update it now. //Now you get/calculate the current anchor of the device @@ -265,10 +240,6 @@ if (!osync_anchor_update(anchor, "lanchor", &error)) { goto error; } - - //Save hashtable to database - if (!osync_hashtable_save(sinkenv->hashtable, &error)) - goto error; //Answer the call osync_context_report_success(ctx); @@ -281,24 +252,15 @@ static void disconnect(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *userdata) { - sink_environment *sinkenv = (sink_environment*)userdata; - //Close all stuff you need to close - //Close the hashtable - osync_hashtable_unref(sinkenv->hashtable); - sinkenv->hashtable = NULL; - //Answer the call osync_context_report_success(ctx); } static void finalize(void *userdata) { - plugin_environment *env = (plugin_environment *)userdata; - //Free all stuff that you have allocated here. - free_env(env); } @@ -320,12 +282,11 @@ if (!env) goto error; - env->sink_envs = NULL; - osync_trace(TRACE_INTERNAL, "The config: %s", osync_plugin_info_get_config(info)); /* * Process the config here and set the options on your environment + * if required. */ /* * Process plugin specific advanced options @@ -348,16 +309,10 @@ /* * Process Ressource options */ - int i, numobjs = osync_plugin_info_num_objtypes(info); + unsigned int i, numobjs = osync_plugin_info_num_objtypes(info); for (i = 0; i < numobjs; i++) { - sink_environment *sinkenv = osync_try_malloc0(sizeof(sink_environment), error); - if (!sinkenv) - goto error_free_env; - - sinkenv->sink = osync_plugin_info_nth_objtype(info, i); - osync_assert(sinkenv->sink); - - const char *objtype = osync_objtype_sink_get_name(sinkenv->sink); + OSyncObjTypeSink *sink = osync_plugin_info_nth_objtype(info, i); + const char *objtype = osync_objtype_sink_get_name(sink); OSyncPluginResource *res = osync_plugin_config_find_active_resource(config, objtype); /* get objformat sinks */ @@ -378,22 +333,22 @@ functions.commit = commit_change; functions.sync_done = sync_done; - /* We pass the OSyncFileDir object to the sink, so we dont have to look it up - * again once the functions are called */ - osync_objtype_sink_set_functions(sinkenv->sink, functions, sinkenv); + /* The last arguemnt is the userdata you get passed inside + * plugin sink functinos. + */ + osync_objtype_sink_set_functions(sink, functions, NULL); - osync_trace(TRACE_INTERNAL, "The configdir: %s", osync_plugin_info_get_configdir(info)); - char *tablepath = osync_strdup_printf("%s/hashtable.db", osync_plugin_info_get_configdir(info)); - sinkenv->hashtable = osync_hashtable_new(tablepath, objtype, error); - osync_free(tablepath); - env->sink_envs = osync_list_append(env->sink_envs, sinkenv); + /* Request a Hahstable here - if you need it. + * It will be later available via osync_objtype_sink_get_hashtable(OSyncObjTypeSink *) + * in the plugin sink functions (e.g. connect, get_changes, commit, ...) + */ + osync_objtype_sink_enable_hashtable(sink, TRUE); + } - //Now your return your struct. + //Now your return your environemtn struct. return (void *) env; -error_free_env: - free_env(env); error: osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); return NULL; @@ -428,7 +383,7 @@ } -osync_bool get_sync_info(OSyncPluginEnv *env, OSyncError **error) +osync_bool get_sync_info(OSyncPluginEnv *pluginenv, OSyncError **error) { //Now you can create a new plugin information and fill in the details //Note that you can create several plugins here @@ -446,7 +401,7 @@ osync_plugin_set_finalize(plugin, finalize); osync_plugin_set_discover(plugin, discover); - osync_plugin_env_register_plugin(env, plugin); + osync_plugin_env_register_plugin(pluginenv, plugin); osync_plugin_unref(plugin); return TRUE; Modified: trunk/docs/examples/plugins/src/simple_plugin.c ============================================================================== --- trunk/docs/examples/plugins/src/simple_plugin.c Sat Mar 28 14:41:02 2009 (r5373) +++ trunk/docs/examples/plugins/src/simple_plugin.c Sat Mar 28 14:59:51 2009 (r5374) @@ -38,7 +38,7 @@ //calls to your plugin) //cast void* userdata to the sink specific data type - sink_environment *sinkenv = (sink_environment*)userdata; + //sink_environment *sinkenv = (sink_environment*)userdata; OSyncError *error = NULL; @@ -87,7 +87,7 @@ osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, userdata, info, ctx); OSyncFormatEnv *formatenv = osync_plugin_info_get_format_env(info); - sink_environment *sinkenv = (sink_environment*) userdata; + //sink_environment *sinkenv = (sink_environment*) userdata; OSyncError *error = NULL; @@ -137,7 +137,7 @@ continue; } - osync_data_set_objtype(odata, osync_objtype_sink_get_name(sinkenv->sink)); + osync_data_set_objtype(odata, osync_objtype_sink_get_name(sink)); //Now you can set the data for the object osync_change_set_data(change, odata); @@ -158,7 +158,7 @@ static void commit_change(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *change, void *userdata) { - sink_environment *sinkenv = (sink_environment*)userdata;; + //sink_environment *sinkenv = (sink_environment*)userdata;; /* * Here you have to add, modify or delete a object @@ -191,7 +191,7 @@ * This function will only be called if the sync was successful */ OSyncError *error = NULL; - sink_environment *sinkenv = (sink_environment*)userdata; + //sink_environment *sinkenv = (sink_environment*)userdata; //If we use anchors we have to update it now. //Now you get/calculate the current anchor of the device @@ -210,7 +210,7 @@ static void disconnect(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *userdata) { - sink_environment *sinkenv = (sink_environment*)userdata; + //sink_environment *sinkenv = (sink_environment*)userdata; //Close all stuff you need to close |
From: <svn...@op...> - 2009-03-28 13:44:01
|
Author: dgollub Date: Sat Mar 28 14:41:02 2009 New Revision: 5373 URL: http://www.opensync.org/changeset/5373 Log: Introduced osync_objtype_sink_save_hashtable() for osyncplugin tool. Temporarily disabled hashtable dumping inf osyncdump. refs #1082 Modified: trunk/opensync.sym trunk/opensync/client/opensync_client.c trunk/opensync/plugin/opensync_objtype_sink.c trunk/opensync/plugin/opensync_objtype_sink.h trunk/tools/osyncdump.c trunk/tools/osyncplugin.c Modified: trunk/opensync.sym ============================================================================== --- trunk/opensync.sym Sat Mar 28 14:20:04 2009 (r5372) +++ trunk/opensync.sym Sat Mar 28 14:41:02 2009 (r5373) @@ -398,6 +398,7 @@ osync_objtype_sink_read_change osync_objtype_sink_ref osync_objtype_sink_remove_objformat_sink +osync_objtype_sink_save_hashtable osync_objtype_sink_set_available osync_objtype_sink_set_batchcommit_timeout osync_objtype_sink_set_commit_timeout Modified: trunk/opensync/client/opensync_client.c ============================================================================== --- trunk/opensync/client/opensync_client.c Sat Mar 28 14:20:04 2009 (r5372) +++ trunk/opensync/client/opensync_client.c Sat Mar 28 14:41:02 2009 (r5373) @@ -1329,7 +1329,6 @@ OSyncMessage *reply = NULL; OSyncObjTypeSink *sink = NULL; OSyncContext *context = NULL; - OSyncHashTable *hashtable = NULL; osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, client, message, error); @@ -1368,14 +1367,8 @@ osync_context_unref(context); - /* Check if Hashtable is used */ - if ((hashtable = osync_objtype_sink_get_hashtable(sink))) { - - /* Save Hashtable */ - if (!osync_hashtable_save(hashtable, error)) - goto error; - } - + if (!osync_objtype_sink_save_hashtable(sink, error)) + goto error; } osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; Modified: trunk/opensync/plugin/opensync_objtype_sink.c ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink.c Sat Mar 28 14:20:04 2009 (r5372) +++ trunk/opensync/plugin/opensync_objtype_sink.c Sat Mar 28 14:41:02 2009 (r5373) @@ -815,3 +815,21 @@ return FALSE; } +osync_bool osync_objtype_sink_save_hashtable(OSyncObjTypeSink *sink, OSyncError **error) +{ + osync_assert(sink); + + if (!osync_objtype_sink_has_hashtable(sink)) + return TRUE; + + osync_assert(sink->hashtable); + + if (!osync_hashtable_save(sink->hashtable, error)) + goto error; + + return TRUE; + +error: + return FALSE; +} + Modified: trunk/opensync/plugin/opensync_objtype_sink.h ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink.h Sat Mar 28 14:20:04 2009 (r5372) +++ trunk/opensync/plugin/opensync_objtype_sink.h Sat Mar 28 14:41:02 2009 (r5373) @@ -551,6 +551,18 @@ */ OSYNC_EXPORT osync_bool osync_objtype_sink_load_hashtable(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncError **error); +/*! @brief Save the Hashtable for a specific Sink if requested + * + * Write hashes to the hashtable database. If no Hashtable is requested for this sink + * this functions just returns TRUE. + * + * @param sink Pointer to the sink + * @param error Pointer to error struct, get set on any error + * @returns TRUE on success, FALSE on any error + * + */ +OSYNC_EXPORT osync_bool osync_objtype_sink_save_hashtable(OSyncObjTypeSink *sink, OSyncError **error); + /*@}*/ #endif /* _OPENSYNC_OBJTYPE_SINK_H_ */ Modified: trunk/tools/osyncdump.c ============================================================================== --- trunk/tools/osyncdump.c Sat Mar 28 14:20:04 2009 (r5372) +++ trunk/tools/osyncdump.c Sat Mar 28 14:41:02 2009 (r5373) @@ -105,26 +105,37 @@ } +#if 0 static void print_hashtable(const char *uid, const char *hash, void *user_data) { printf("UID: %s\tHASH:%s\n", uid, hash); } +#endif static void dump_hash(OSyncGroupEnv *env, const char *objtype, const char *groupname, char *memberid) { - OSyncError *error = NULL; OSyncGroup *group = osync_group_env_find_group(env, groupname); +#if 0 /* Unused */ + OSyncError *error = NULL; long long int id = 0; OSyncMember *member = NULL; char *path = NULL; OSyncHashTable *table = NULL; - +#endif if (!group) { printf("Unable to find group with name \"%s\"\n", groupname); return; } + + printf("Dumping hashtable is currently not implemented!\n"); + return; + +/* FIXME: public interface osync_hashltable_new() is gone! + * no interface to access the disk directly! + * */ +#if 0 id = atoi(memberid); member = osync_group_find_member(group, id); if (!member) { @@ -144,12 +155,12 @@ osync_hashtable_foreach(table, print_hashtable, NULL); osync_hashtable_unref(table); - - return; error: printf("ERROR: %s", osync_error_print(&error)); osync_error_unref(&error); + +#endif } static void reset(OSyncGroupEnv *osync, char *groupname) Modified: trunk/tools/osyncplugin.c ============================================================================== --- trunk/tools/osyncplugin.c Sat Mar 28 14:20:04 2009 (r5372) +++ trunk/tools/osyncplugin.c Sat Mar 28 14:41:02 2009 (r5373) @@ -459,6 +459,9 @@ if (!osync_objtype_sink_load_anchor(sink, plugin_info, error)) return NULL; + + if (!osync_objtype_sink_load_hashtable(sink, plugin_info, error)) + return NULL; } return plugin_data; @@ -983,6 +986,9 @@ osync_context_unref(context); + if (!osync_objtype_sink_save_hashtable(sink, error)) + goto error; + return TRUE; error: |
From: <svn...@op...> - 2009-03-28 13:20:11
|
Author: dgollub Date: Sat Mar 28 14:20:04 2009 New Revision: 5372 URL: http://www.opensync.org/changeset/5372 Log: Ported mock-sync plugin to latest Hashtable API change r5371 refs #1082 Modified: trunk/tests/mock-plugin/mock_sync.c trunk/tests/support.h Modified: trunk/tests/mock-plugin/mock_sync.c ============================================================================== --- trunk/tests/mock-plugin/mock_sync.c Sat Mar 28 14:19:04 2009 (r5371) +++ trunk/tests/mock-plugin/mock_sync.c Sat Mar 28 14:20:04 2009 (r5372) @@ -288,6 +288,7 @@ osync_trace(TRACE_ENTRY, "%s(%p, %s, %p, %p)", __func__, directory, subdir, ctx, sink); + OSyncHashTable *hashtable = osync_objtype_sink_get_hashtable(sink); OSyncFormatEnv *formatenv = osync_plugin_info_get_format_env(info); osync_assert(formatenv); @@ -322,10 +323,10 @@ osync_change_set_hash(change, hash); g_free(hash); - OSyncChangeType type = osync_hashtable_get_changetype(directory->hashtable, change); + OSyncChangeType type = osync_hashtable_get_changetype(hashtable, change); osync_change_set_changetype(change, type); - osync_hashtable_update_change(directory->hashtable, change); + osync_hashtable_update_change(hashtable, change); if (type == OSYNC_CHANGE_TYPE_UNMODIFIED) { g_free(filename); @@ -379,6 +380,7 @@ osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %i, %p)", __func__, sink, info, ctx, slow_sync, data); MockDir *dir = data; OSyncError *error = NULL; + OSyncHashTable *hashtable = osync_objtype_sink_get_hashtable(sink); osync_assert(dir->committed_all == TRUE); dir->committed_all = FALSE; @@ -402,14 +404,14 @@ if (slow_sync) { osync_trace(TRACE_INTERNAL, "Slow sync requested"); - osync_assert(osync_hashtable_slowsync(dir->hashtable, &error)); + osync_assert(osync_hashtable_slowsync(hashtable, &error)); } osync_trace(TRACE_INTERNAL, "get_changes for %s", osync_objtype_sink_get_name(sink)); mock_report_dir(dir, NULL, ctx, info, sink); - OSyncList *u, *uids = osync_hashtable_get_deleted(dir->hashtable); + OSyncList *u, *uids = osync_hashtable_get_deleted(hashtable); for (u = uids; u; u = u->next) { OSyncChange *change = osync_change_new(&error); osync_assert(change); @@ -428,7 +430,7 @@ osync_context_report_change(ctx, change); - osync_hashtable_update_change(dir->hashtable, change); + osync_hashtable_update_change(hashtable, change); osync_change_unref(change); } @@ -441,6 +443,7 @@ { osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %p)", __func__, sink, info, ctx, change, data); MockDir *dir = data; + OSyncHashTable *hashtable = osync_objtype_sink_get_hashtable(sink); char *filename = NULL; @@ -473,7 +476,7 @@ g_free(filename); - osync_hashtable_update_change(dir->hashtable, change); + osync_hashtable_update_change(hashtable, change); osync_context_report_success(ctx); @@ -484,6 +487,7 @@ { osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %p, %p)", __func__, sink, info, context, contexts, changes, data); MockDir *dir = data; + OSyncHashTable *hashtable = osync_objtype_sink_get_hashtable(sink); osync_assert(dir->committed_all == FALSE); dir->committed_all = TRUE; @@ -502,7 +506,7 @@ } g_free(filename); - osync_hashtable_update_change(dir->hashtable, changes[i]); + osync_hashtable_update_change(hashtable, changes[i]); osync_context_report_success(contexts[i]); } } @@ -555,7 +559,6 @@ return; osync_assert_msg(osync_anchor_update(anchor, dir->path, NULL), "Not expected to fail!"); - osync_assert(osync_hashtable_save(dir->hashtable, NULL)); osync_context_report_success(ctx); @@ -628,16 +631,6 @@ osync_assert(dir->objformat); osync_objformat_ref(dir->objformat); - osync_trace(TRACE_INTERNAL, "The configdir: %s", osync_plugin_info_get_configdir(info)); - char *tablepath = g_strdup_printf("%s/hashtable.db", osync_plugin_info_get_configdir(info)); - dir->hashtable = osync_hashtable_new(tablepath, objtype, error); - g_free(tablepath); - - osync_assert(dir->hashtable); - - osync_assert(osync_hashtable_load(dir->hashtable, error)); - - /* const char *objformat = osync_objformat_get_name(dir->objformat); OSyncObjFormatSink *format_sink = osync_objformat_sink_new(objformat, error); @@ -681,6 +674,9 @@ /* Request an Anchor */ osync_objtype_sink_enable_anchor(sink, TRUE); + /* Request an Hashtable */ + osync_objtype_sink_enable_hashtable(sink, TRUE); + //Lets reduce the timeouts a bit so the checks work faster osync_objtype_sink_set_connect_timeout(sink, 2); osync_objtype_sink_set_getchanges_timeout(sink, 2); @@ -741,7 +737,6 @@ osync_plugin_resource_unref(dir->res); osync_objformat_unref(dir->objformat); - osync_hashtable_unref(dir->hashtable); env->directories = g_list_remove(env->directories, dir); g_free(dir); Modified: trunk/tests/support.h ============================================================================== --- trunk/tests/support.h Sat Mar 28 14:19:04 2009 (r5371) +++ trunk/tests/support.h Sat Mar 28 14:20:04 2009 (r5372) @@ -14,6 +14,8 @@ #include <opensync/opensync-group.h> #include <opensync/opensync-plugin.h> +#include "opensync/helper/opensync_hashtable_internals.h" + #include "config.h" #define OSYNC_TESTCASE_START(x) \ |
From: <svn...@op...> - 2009-03-28 13:19:13
|
Author: dgollub Date: Sat Mar 28 14:19:04 2009 New Revision: 5371 URL: http://www.opensync.org/changeset/5371 Log: Dropped following interfaces: osync_hashtable_new osync_hashtable_ref osync_hashtable_unref osync_hashtable_load osync_hashtable_save This affects all plugins using hashtables! Short Porting instruction: - Drop osync_hashtable_{un,}ref() calls (no replacement required) - Drop osync_hashtable_new() (no replacement required) - Drop calls like osync_plugin_info_get_configdir() if they were used to create a hashtable path (obsolete now) - Drop calls of osync_hashtable_save() (no replacement required) - Call osync_objtype_sink_enable_hashtable(OSyncObjTypeSink *sink, TRUE); in plugin init function for each ObjTypeSink - Hashtable will be initilaized and loaded by the Engine right after the plugin init function. Don't expect to get a HashTable pointer in the init function! - You can get an valid OSyncHashTable pointer by calling inside Plugin Sink Functions (e.g. connect, get_changes, commit, sync_done, ...): OSyncHashTable *hashtable = osync_objtype_sink_get_hashtable(sink); - Hashtable get stored after the sync_done() plugin call. No call by plugin required. refs #1082 refs #1083 Modified: trunk/opensync.sym trunk/opensync/client/opensync_client.c trunk/opensync/helper/opensync_hashtable.h trunk/opensync/helper/opensync_hashtable_internals.h trunk/opensync/plugin/opensync_objtype_sink.c trunk/opensync/plugin/opensync_objtype_sink.h trunk/opensync/plugin/opensync_objtype_sink_internals.h Modified: trunk/opensync.sym ============================================================================== --- trunk/opensync.sym Sat Mar 28 07:00:59 2009 (r5370) +++ trunk/opensync.sym Sat Mar 28 14:19:04 2009 (r5371) @@ -197,13 +197,8 @@ osync_hashtable_get_changetype osync_hashtable_get_deleted osync_hashtable_get_hash -osync_hashtable_load -osync_hashtable_new osync_hashtable_num_entries -osync_hashtable_ref -osync_hashtable_save osync_hashtable_slowsync -osync_hashtable_unref osync_hashtable_update_change osync_list_alloc osync_list_append @@ -396,6 +391,7 @@ osync_objtype_sink_is_available osync_objtype_sink_is_enabled osync_objtype_sink_load_anchor +osync_objtype_sink_load_hashtable osync_objtype_sink_new osync_objtype_sink_nth_objformat_sink osync_objtype_sink_num_objformat_sinks Modified: trunk/opensync/client/opensync_client.c ============================================================================== --- trunk/opensync/client/opensync_client.c Sat Mar 28 07:00:59 2009 (r5370) +++ trunk/opensync/client/opensync_client.c Sat Mar 28 14:19:04 2009 (r5371) @@ -27,6 +27,9 @@ #include "plugin/opensync_objtype_sink_internals.h" #include "plugin/opensync_plugin_info_internals.h" +#include "opensync-helper.h" +#include "helper/opensync_hashtable_internals.h" + #include "opensync-ipc.h" #include "ipc/opensync_serializer_internals.h" #include "ipc/opensync_message_internals.h" @@ -1326,6 +1329,7 @@ OSyncMessage *reply = NULL; OSyncObjTypeSink *sink = NULL; OSyncContext *context = NULL; + OSyncHashTable *hashtable = NULL; osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, client, message, error); @@ -1363,6 +1367,15 @@ osync_objtype_sink_sync_done(sink, client->plugin_info, context); osync_context_unref(context); + + /* Check if Hashtable is used */ + if ((hashtable = osync_objtype_sink_get_hashtable(sink))) { + + /* Save Hashtable */ + if (!osync_hashtable_save(hashtable, error)) + goto error; + } + } osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; Modified: trunk/opensync/helper/opensync_hashtable.h ============================================================================== --- trunk/opensync/helper/opensync_hashtable.h Sat Mar 28 07:00:59 2009 (r5370) +++ trunk/opensync/helper/opensync_hashtable.h Sat Mar 28 14:19:04 2009 (r5371) @@ -84,60 +84,6 @@ */ /*@{*/ -/** @brief Creates a hashtable access object - * - * Hashtables can be used to detect what has been changed since - * the last sync. - * - * @param path the full path and file name of the hashtable .db file to load from or create - * @param objtype the object type of the hashtable - * @param error Pointer to an error struct - * @returns A new hashtable, or NULL if an error occurred. - * - */ -OSYNC_EXPORT OSyncHashTable *osync_hashtable_new(const char *path, const char *objtype, OSyncError **error); - -/** @brief Increase the reference count of a hashtable object. - * - * @param table The hashtable to increase the reference count - * @returns Pointer to increased hashtable object - */ -OSYNC_EXPORT OSyncHashTable *osync_hashtable_ref(OSyncHashTable *table); - -/** @brief Decrease the reference count of a hastable object. - * - * The object will be freed if the reference count reaches zero. - * - * @param table The hashtable to decrease the reference count - * - */ -OSYNC_EXPORT void osync_hashtable_unref(OSyncHashTable *table); - - -/** @brief Loads the data in a hashtable from disk - * - * This function must be called to load the hashtable before attempting - * to use it (eg. in your plugin objtype sink initialization code). - * - * @param table The hashtable to load from - * @param error Pointer to an error struct - * @returns TRUE on success or FALSE if an error occurred. - * - */ -OSYNC_EXPORT osync_bool osync_hashtable_load(OSyncHashTable *table, OSyncError **error); - -/** @brief Saves the data in a hashtable to disk - * - * Call this function in your syncdone() plugin sink function. - * - * @param table The hashtable to save - * @param error Pointer to an error struct - * @returns TRUE on success or FALSE if an error occurred. - * - */ -OSYNC_EXPORT osync_bool osync_hashtable_save(OSyncHashTable *table, OSyncError **error); - - /** @brief Prepares the hashtable for a slowsync and flush the entire hashtable * * This function should be called to prepare the hashtable for a slowsync. Modified: trunk/opensync/helper/opensync_hashtable_internals.h ============================================================================== --- trunk/opensync/helper/opensync_hashtable_internals.h Sat Mar 28 07:00:59 2009 (r5370) +++ trunk/opensync/helper/opensync_hashtable_internals.h Sat Mar 28 14:19:04 2009 (r5371) @@ -45,4 +45,57 @@ GString *query; }; +/** @brief Creates a hashtable access object + * + * Hashtables can be used to detect what has been changed since + * the last sync. + * + * @param path the full path and file name of the hashtable .db file to load from or create + * @param objtype the object type of the hashtable + * @param error Pointer to an error struct + * @returns A new hashtable, or NULL if an error occurred. + * + */ +OSYNC_TEST_EXPORT OSyncHashTable *osync_hashtable_new(const char *path, const char *objtype, OSyncError **error); + +/** @brief Increase the reference count of a hashtable object. + * + * @param table The hashtable to increase the reference count + * @returns Pointer to increased hashtable object + */ +OSYNC_TEST_EXPORT OSyncHashTable *osync_hashtable_ref(OSyncHashTable *table); + +/** @brief Decrease the reference count of a hastable object. + * + * The object will be freed if the reference count reaches zero. + * + * @param table The hashtable to decrease the reference count + * + */ +OSYNC_TEST_EXPORT void osync_hashtable_unref(OSyncHashTable *table); + +/** @brief Loads the hashtable + * + * This function must be called to load the hashtable before attempting + * to use it (eg. in your plugin objtype sink initialization code). + * + * @param table The hashtable to load from + * @param error Pointer to an error struct + * @returns TRUE on success or FALSE if an error occurred. + * + */ +OSYNC_TEST_EXPORT osync_bool osync_hashtable_load(OSyncHashTable *table, OSyncError **error); + +/** @brief Saves the data in a hashtable + * + * Call this function in your syncdone() plugin sink function. + * + * @param table The hashtable to save + * @param error Pointer to an error struct + * @returns TRUE on success or FALSE if an error occurred. + * + */ +OSYNC_TEST_EXPORT osync_bool osync_hashtable_save(OSyncHashTable *table, OSyncError **error); + #endif /*_OPENSYNC_HASHTABLE_INTERNALS_H_*/ + Modified: trunk/opensync/plugin/opensync_objtype_sink.c ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink.c Sat Mar 28 07:00:59 2009 (r5370) +++ trunk/opensync/plugin/opensync_objtype_sink.c Sat Mar 28 14:19:04 2009 (r5371) @@ -785,6 +785,9 @@ if (!osync_objtype_sink_has_hashtable(sink)) return TRUE; + + if (sink->hashtable) + osync_hashtable_unref(sink->hashtable); /* FIXME: Get rid of file lcoation! * Later with fruther OSyncDB modifications this should be file-hiarchy indepdendent. @@ -798,9 +801,15 @@ if (!sink->hashtable) goto error; + if (!osync_hashtable_load(sink->hashtable, error)) + goto error_free_hashtable; + osync_free(hashtablepath); return TRUE; + +error_free_hashtable: + osync_hashtable_unref(sink->hashtable); error: osync_free(hashtablepath); return FALSE; Modified: trunk/opensync/plugin/opensync_objtype_sink.h ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink.h Sat Mar 28 07:00:59 2009 (r5370) +++ trunk/opensync/plugin/opensync_objtype_sink.h Sat Mar 28 14:19:04 2009 (r5371) @@ -538,6 +538,19 @@ */ OSYNC_EXPORT osync_bool osync_objtype_sink_load_anchor(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncError **error); +/*! @brief Load the Hashtable for a specific Sink if requested + * + * Load (i.e. connects) to the Hashtable. If no Hashtable is requested for this sink + * this functions just returns TRUE. + * + * @param sink Pointer to the sink + * @param info Pointer to the plugin info object + * @param error Pointer to error struct, get set on any error + * @returns TRUE on success, FALSE on any error + * + */ +OSYNC_EXPORT osync_bool osync_objtype_sink_load_hashtable(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncError **error); + /*@}*/ #endif /* _OPENSYNC_OBJTYPE_SINK_H_ */ Modified: trunk/opensync/plugin/opensync_objtype_sink_internals.h ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink_internals.h Sat Mar 28 07:00:59 2009 (r5370) +++ trunk/opensync/plugin/opensync_objtype_sink_internals.h Sat Mar 28 14:19:04 2009 (r5371) @@ -68,19 +68,6 @@ */ void osync_objtype_sink_set_hashtable(OSyncObjTypeSink *sink, OSyncHashTable *hashtable); -/*! @brief Load the Hashtable for a specific Sink if requested - * - * Load (i.e. connects) to the Hashtable. If no Hashtable is requested for this sink - * this functions just returns TRUE. - * - * @param sink Pointer to the sink - * @param info Pointer to the plugin info object - * @param error Pointer to error struct, get set on any error - * @returns TRUE on success, FALSE on any error - * - */ -osync_bool osync_objtype_sink_load_hashtable(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncError **error); - /** @brief Checks if sink has a read single entries function (read) * * @param sink Pointer to the sink |
From: <svn...@op...> - 2009-03-28 06:01:12
|
Author: cdfrey Date: Sat Mar 28 07:00:59 2009 New Revision: 5370 URL: http://www.opensync.org/changeset/5370 Log: Fixed typo in comment Modified: trunk/opensync/engine/opensync_engine.h Modified: trunk/opensync/engine/opensync_engine.h ============================================================================== --- trunk/opensync/engine/opensync_engine.h Sat Mar 28 03:13:10 2009 (r5369) +++ trunk/opensync/engine/opensync_engine.h Sat Mar 28 07:00:59 2009 (r5370) @@ -137,7 +137,7 @@ OSYNC_ENGINE_EVENT_MULTIPLIED, /** Engine completed with preparing a write */ OSYNC_ENGINE_EVENT_PREPARED_WRITE, - /** Engien completed with preparing for the mapping */ + /** Engine completed with preparing for the mapping */ OSYNC_ENGINE_EVENT_PREPARED_MAP } OSyncEngineEvent; |
From: <svn...@op...> - 2009-03-28 02:13:14
|
Author: dgollub Date: Sat Mar 28 03:13:10 2009 New Revision: 5369 URL: http://www.opensync.org/changeset/5369 Log: Prepare new hashtable interface to request a OSyncHashTable. Similar to the OSyncAnchor request implementation. refs #1082 Modified: trunk/opensync.sym trunk/opensync/client/opensync_client.c trunk/opensync/plugin/opensync_objtype_sink.c trunk/opensync/plugin/opensync_objtype_sink.h trunk/opensync/plugin/opensync_objtype_sink_internals.h trunk/opensync/plugin/opensync_objtype_sink_private.h Modified: trunk/opensync.sym ============================================================================== --- trunk/opensync.sym Sat Mar 28 03:04:57 2009 (r5368) +++ trunk/opensync.sym Sat Mar 28 03:13:10 2009 (r5369) @@ -382,10 +382,12 @@ osync_objtype_sink_connect_done osync_objtype_sink_disconnect osync_objtype_sink_enable_anchor +osync_objtype_sink_enable_hashtable osync_objtype_sink_find_objformat_sink osync_objtype_sink_get_anchor osync_objtype_sink_get_changes osync_objtype_sink_get_getchanges +osync_objtype_sink_get_hashtable osync_objtype_sink_get_name osync_objtype_sink_get_objformat_sinks osync_objtype_sink_get_preferred_format Modified: trunk/opensync/client/opensync_client.c ============================================================================== --- trunk/opensync/client/opensync_client.c Sat Mar 28 03:04:57 2009 (r5368) +++ trunk/opensync/client/opensync_client.c Sat Mar 28 03:13:10 2009 (r5369) @@ -702,6 +702,11 @@ if (!osync_objtype_sink_load_anchor(sink, client->plugin_info, error)) { goto error_finalize; } + + if (!osync_objtype_sink_load_hashtable(sink, client->plugin_info, error)) { + goto error_finalize; + } + } main_sink = osync_plugin_info_get_main_sink(client->plugin_info); Modified: trunk/opensync/plugin/opensync_objtype_sink.c ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink.c Sat Mar 28 03:04:57 2009 (r5368) +++ trunk/opensync/plugin/opensync_objtype_sink.c Sat Mar 28 03:13:10 2009 (r5369) @@ -23,8 +23,10 @@ #include "opensync-context.h" #include "opensync-format.h" +#include "opensync-helper.h" #include "opensync/helper/opensync_anchor_internals.h" +#include "opensync/helper/opensync_hashtable_internals.h" #include "opensync_plugin_info.h" /* due to osync_plugin_info_get_configdir() */ @@ -80,7 +82,10 @@ if (sink->anchor) osync_anchor_unref(sink->anchor); - + + if (sink->hashtable) + osync_hashtable_unref(sink->hashtable); + if (sink->preferred_format) osync_free(sink->preferred_format); @@ -118,6 +123,33 @@ sink->anchor = osync_anchor_ref(anchor); } +void osync_objtype_sink_enable_hashtable(OSyncObjTypeSink *sink, osync_bool enable) +{ + osync_return_if_fail(sink); + sink->hashtable_requested = enable; +} + +osync_bool osync_objtype_sink_has_hashtable(OSyncObjTypeSink *sink) +{ + osync_return_val_if_fail(sink, FALSE); + return sink->hashtable_requested; +} + +OSyncHashTable *osync_objtype_sink_get_hashtable(OSyncObjTypeSink *sink) +{ + osync_return_val_if_fail(sink, NULL); + return sink->hashtable; +} + +void osync_objtype_sink_set_hashtable(OSyncObjTypeSink *sink, OSyncHashTable *hashtable) +{ + osync_return_if_fail(sink); + if (sink->hashtable) + osync_hashtable_unref(sink->hashtable); + + sink->hashtable = osync_hashtable_ref(hashtable); +} + const char *osync_objtype_sink_get_name(OSyncObjTypeSink *sink) { osync_assert(sink); @@ -745,3 +777,32 @@ return FALSE; } +osync_bool osync_objtype_sink_load_hashtable(OSyncObjTypeSink *sink, OSyncPluginInfo *plugin_info, OSyncError **error) +{ + char *hashtablepath; + + osync_assert(sink); + + if (!osync_objtype_sink_has_hashtable(sink)) + return TRUE; + + /* FIXME: Get rid of file lcoation! + * Later with fruther OSyncDB modifications this should be file-hiarchy indepdendent. + * And The first arg should just consists of the Member ID + */ + hashtablepath = osync_strdup_printf("%s%chashtable.db", + osync_plugin_info_get_configdir(plugin_info), + G_DIR_SEPARATOR); + + sink->hashtable = osync_hashtable_new(hashtablepath, sink->objtype, error); + if (!sink->hashtable) + goto error; + + osync_free(hashtablepath); + + return TRUE; +error: + osync_free(hashtablepath); + return FALSE; +} + Modified: trunk/opensync/plugin/opensync_objtype_sink.h ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink.h Sat Mar 28 03:04:57 2009 (r5368) +++ trunk/opensync/plugin/opensync_objtype_sink.h Sat Mar 28 03:13:10 2009 (r5369) @@ -113,11 +113,37 @@ * or not. * * @param sink Pointer to the sink - * @returns the name of the object type of the specified sink + * @returns Pointer to the requested OSyncAnchor, or NULL if no anchor is requested * */ OSYNC_EXPORT OSyncAnchor *osync_objtype_sink_get_anchor(OSyncObjTypeSink *sink); +/** @brief Request a hashtable for this Sink + * + * If for this sink a hashtable is required, this needs to be requested by this + * function. If hashtable gets enabled/requested inside the plugin, the framework + * will take care about preparing the hashtable. The created hashtable can be accessed + * by using the function osync_objtype_sink_get_hashtable() + * + * By default no hashtable is requested/enabled. + * + * @param sink Pointer to the sink + * @param enable Flag to enable, disbable hashtable. + * + */ +OSYNC_EXPORT void osync_objtype_sink_enable_hashtable(OSyncObjTypeSink *sink, osync_bool enable); + +/** @brief Get the pointer to the sink OSyncHashTable + * + * This Hashtable is sink specific and can store persistent hash values of changes. + * Designed to help to determine the change type of an entry. + * + * @param sink Pointer to the sink + * @returns the name of the object type of the specified sink + * + */ +OSYNC_EXPORT OSyncHashTable *osync_objtype_sink_get_hashtable(OSyncObjTypeSink *sink); + /** @brief Return the name of the object type of a sink * Modified: trunk/opensync/plugin/opensync_objtype_sink_internals.h ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink_internals.h Sat Mar 28 03:04:57 2009 (r5368) +++ trunk/opensync/plugin/opensync_objtype_sink_internals.h Sat Mar 28 03:13:10 2009 (r5369) @@ -51,6 +51,36 @@ */ void osync_objtype_sink_set_anchor(OSyncObjTypeSink *sink, OSyncAnchor *anchor); +/** @brief Check if sink has a hashtable request. + * + * @param sink Pointer to the sink + * @returns TRUE if the sink has a hashtable request, FALSE otherwise + */ +osync_bool osync_objtype_sink_has_hashtable(OSyncObjTypeSink *sink); + +/** @brief Set the OSyncHashTable for this sink + * + * This Hashtable is sink specific and can store persistent hash values of changes. + * + * @param sink Pointer to the sink + * @param hashtable Pointer to the Hashtable object + * + */ +void osync_objtype_sink_set_hashtable(OSyncObjTypeSink *sink, OSyncHashTable *hashtable); + +/*! @brief Load the Hashtable for a specific Sink if requested + * + * Load (i.e. connects) to the Hashtable. If no Hashtable is requested for this sink + * this functions just returns TRUE. + * + * @param sink Pointer to the sink + * @param info Pointer to the plugin info object + * @param error Pointer to error struct, get set on any error + * @returns TRUE on success, FALSE on any error + * + */ +osync_bool osync_objtype_sink_load_hashtable(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncError **error); + /** @brief Checks if sink has a read single entries function (read) * * @param sink Pointer to the sink Modified: trunk/opensync/plugin/opensync_objtype_sink_private.h ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink_private.h Sat Mar 28 03:04:57 2009 (r5368) +++ trunk/opensync/plugin/opensync_objtype_sink_private.h Sat Mar 28 03:13:10 2009 (r5369) @@ -81,6 +81,12 @@ /** Flag if anchor is requested by plugin */ osync_bool anchor_requested; + /** The sink hashtable if requested by the plugin */ + OSyncHashTable *hashtable; + + /** Flag if hashtable is requested by plugin */ + osync_bool hashtable_requested; + /** The preferred step or target format for the conversion path of this sink */ char *preferred_format; /** The format which can be synchronized by this sink */ |
From: <svn...@op...> - 2009-03-28 02:05:02
|
Author: dgollub Date: Sat Mar 28 03:04:57 2009 New Revision: 5368 URL: http://www.opensync.org/changeset/5368 Log: Fixed compiler warnings about unhandled return value of system() in multisync testsuite. Modified: trunk/tests/sync-tests/check_multisync.c Modified: trunk/tests/sync-tests/check_multisync.c ============================================================================== --- trunk/tests/sync-tests/check_multisync.c Sat Mar 28 02:33:55 2009 (r5367) +++ trunk/tests/sync-tests/check_multisync.c Sat Mar 28 03:04:57 2009 (r5368) @@ -488,7 +488,7 @@ fail_unless(num_engine_end_conflicts = 1, NULL); sleep(2); - system("cp newdata data3/testdata"); + osync_testing_system_abort("cp newdata data3/testdata"); synchronize_once(engine, NULL); destroy_engine(engine); @@ -545,8 +545,8 @@ fail_unless(num_engine_end_conflicts == 1, NULL); sleep(2); - system("cp newdata data1/testdata"); - system("cp newdata data3/testdata"); + osync_testing_system_abort("cp newdata data1/testdata"); + osync_testing_system_abort("cp newdata data3/testdata"); synchronize_once(engine, NULL); @@ -607,9 +607,9 @@ fail_unless(num_engine_end_conflicts == 1, NULL); sleep(2); - system("cp newdata data1/testdata"); - system("cp newdata data2/testdata"); - system("cp newdata data3/testdata"); + osync_testing_system_abort("cp newdata data1/testdata"); + osync_testing_system_abort("cp newdata data2/testdata"); + osync_testing_system_abort("cp newdata data3/testdata"); synchronize_once(engine, NULL); destroy_engine(engine); @@ -651,7 +651,7 @@ fail_unless(osync_testing_diff("data1", "data2")); fail_unless(osync_testing_diff("data1", "data3")); - system("rm -f data2/testdata"); + osync_testing_system_abort("rm -f data2/testdata"); synchronize_once(engine, NULL); destroy_engine(engine); @@ -684,8 +684,8 @@ fail_unless(osync_testing_diff("data1", "data2")); fail_unless(osync_testing_diff("data1", "data3")); - system("rm -f data1/testdata"); - system("rm -f data3/testdata"); + osync_testing_system_abort("rm -f data1/testdata"); + osync_testing_system_abort("rm -f data3/testdata"); synchronize_once(engine, NULL); fail_unless(osync_engine_finalize(engine, &error), NULL); @@ -723,9 +723,9 @@ fail_unless(osync_testing_diff("data1", "data2")); fail_unless(osync_testing_diff("data1", "data3")); - system("rm -f data1/testdata"); - system("rm -f data2/testdata"); - system("rm -f data3/testdata"); + osync_testing_system_abort("rm -f data1/testdata"); + osync_testing_system_abort("rm -f data2/testdata"); + osync_testing_system_abort("rm -f data3/testdata"); synchronize_once(engine, NULL); fail_unless(osync_engine_finalize(engine, &error), NULL); @@ -788,7 +788,7 @@ hashtable_simple_load_and_check(testbed, 2); hashtable_simple_load_and_check(testbed, 3); - system("rm -f data3/testdata"); + osync_testing_system_abort("rm -f data3/testdata"); mark_point(); @@ -843,7 +843,7 @@ hashtable_simple_load_and_check(testbed, 2); hashtable_simple_load_and_check(testbed, 3); - system("rm -f data3/testdata"); + osync_testing_system_abort("rm -f data3/testdata"); mark_point(); @@ -883,8 +883,8 @@ sleep(2); - system("rm -f data1/testdata"); - system("cp newdata data3/testdata"); + osync_testing_system_abort("rm -f data1/testdata"); + osync_testing_system_abort("cp newdata data3/testdata"); synchronize_once(engine, NULL); @@ -913,7 +913,7 @@ hashtable_simple_load_and_check(testbed, 2); hashtable_simple_load_and_check(testbed, 3); - system("rm -f data1/testdata"); + osync_testing_system_abort("rm -f data1/testdata"); mark_point(); @@ -950,8 +950,8 @@ sleep(2); - system("rm -f data1/testdata"); - system("cp newdata data3/testdata"); + osync_testing_system_abort("rm -f data1/testdata"); + osync_testing_system_abort("cp newdata data3/testdata"); synchronize_once(engine, NULL); @@ -997,9 +997,9 @@ sleep(2); - system("rm -f data1/testdata"); - system("cp newdata data3/testdata"); - system("cp newdata2 data2/testdata"); + osync_testing_system_abort("rm -f data1/testdata"); + osync_testing_system_abort("cp newdata data3/testdata"); + osync_testing_system_abort("cp newdata2 data2/testdata"); synchronize_once(engine, NULL); @@ -1028,7 +1028,7 @@ hashtable_simple_load_and_check(testbed, 2); hashtable_simple_load_and_check(testbed, 3); - system("rm -f data1/testdata"); + osync_testing_system_abort("rm -f data1/testdata"); mark_point(); @@ -1064,9 +1064,9 @@ sleep(2); - system("rm -f data1/testdata"); - system("cp newdata data3/testdata"); - system("cp newdata2 data2/testdata"); + osync_testing_system_abort("rm -f data1/testdata"); + osync_testing_system_abort("cp newdata data3/testdata"); + osync_testing_system_abort("cp newdata2 data2/testdata"); synchronize_once(engine, NULL); destroy_engine(engine); @@ -1133,7 +1133,7 @@ hashtable_load_and_check(testbed, 3, uids, num_uids); - system("rm -f data3/testdata"); + osync_testing_system_abort("rm -f data3/testdata"); synchronize_once(engine, NULL); @@ -1153,7 +1153,7 @@ hashtable_load_and_check(testbed, 3, uids, num_uids); - system("rm -f data2/testdata-dupe"); + osync_testing_system_abort("rm -f data2/testdata-dupe"); mark_point(); @@ -1220,7 +1220,7 @@ hashtable_load_and_check(testbed, 3, uids, num_uids); /* force the removal of all but test-data-dupe */ - system("rm -f data3/testdata data3/testdata-dupe-dupe"); + osync_testing_system_abort("rm -f data3/testdata data3/testdata-dupe-dupe"); mark_point(); synchronize_once(engine, NULL); @@ -1244,7 +1244,7 @@ hashtable_load_and_check(testbed, 3, uids, num_uids); /* force the removal of the remaining testdata-dupe */ - system("rm -f data2/testdata-dupe"); + osync_testing_system_abort("rm -f data2/testdata-dupe"); mark_point(); synchronize_once(engine, NULL); @@ -1273,8 +1273,8 @@ sleep(2); - system("rm -f data1/testdata"); - system("cp newdata data3/testdata"); + osync_testing_system_abort("rm -f data1/testdata"); + osync_testing_system_abort("cp newdata data3/testdata"); synchronize_once(engine, NULL); @@ -1307,7 +1307,7 @@ check_hash(table, "testdata"); osync_hashtable_close(table); - system("rm -f data1/testdata"); + osync_testing_system_abort("rm -f data1/testdata"); mark_point(); num_mapping_conflicts = 0; @@ -1350,9 +1350,9 @@ sleep(2); - system("rm -f data2/testdata"); - system("rm -f data3/testdata"); - system("cp newdata2 data1/testdata"); + osync_testing_system_abort("rm -f data2/testdata"); + osync_testing_system_abort("rm -f data3/testdata"); + osync_testing_system_abort("cp newdata2 data1/testdata"); synchronize_once(engine, NULL); @@ -1385,7 +1385,7 @@ check_hash(table, "testdata"); osync_hashtable_close(table); - system("rm -f data1/testdata"); + osync_testing_system_abort("rm -f data1/testdata"); mark_point(); num_mapping_conflicts = 0; @@ -1428,9 +1428,9 @@ sleep(2); - system("rm -f data2/testdata"); - system("cp newdata data3/testdata"); - system("cp newdata2 data1/testdata"); + osync_testing_system_abort("rm -f data2/testdata"); + osync_testing_system_abort("cp newdata data3/testdata"); + osync_testing_system_abort("cp newdata2 data1/testdata"); synchronize_once(engine, NULL); @@ -1469,7 +1469,7 @@ check_hash(table, "testdata-dupe"); osync_hashtable_close(table); - system("rm -f data1/testdata data2/testdata-dupe"); + osync_testing_system_abort("rm -f data1/testdata data2/testdata-dupe"); mark_point(); num_mapping_conflicts = 0; @@ -1506,8 +1506,8 @@ OSyncEngine *engine = init_engine(group); osengine_set_conflict_callback(engine, conflict_handler_duplication, GINT_TO_POINTER(3)); - system("cp newdata data3/testdata1"); - system("cp newdata1 data2/testdata2"); + osync_testing_system_abort("cp newdata data3/testdata1"); + osync_testing_system_abort("cp newdata1 data2/testdata2"); synchronize_once(engine, NULL); @@ -1577,15 +1577,15 @@ sleep(2); - system("rm -f data2/testdata"); - system("cp newdata data3/testdata"); + osync_testing_system_abort("rm -f data2/testdata"); + osync_testing_system_abort("cp newdata data3/testdata"); - system("cp newdata3 data1/testdata1"); - system("cp newdata4 data3/testdata1"); + osync_testing_system_abort("cp newdata3 data1/testdata1"); + osync_testing_system_abort("cp newdata4 data3/testdata1"); - system("cp newdata data1/testdata2"); - system("cp newdata5 data3/testdata2"); - system("rm -f data2/testdata2"); + osync_testing_system_abort("cp newdata data1/testdata2"); + osync_testing_system_abort("cp newdata5 data3/testdata2"); + osync_testing_system_abort("rm -f data2/testdata2"); synchronize_once(engine, NULL); @@ -1639,7 +1639,7 @@ check_hash(table, "testdata2-dupe"); osync_hashtable_close(table); - system("rm -f data1/*"); + osync_testing_system_abort("rm -f data1/*"); mark_point(); num_mapping_conflicts = 0; @@ -1676,8 +1676,8 @@ OSyncEngine *engine = init_engine(group); osengine_set_conflict_callback(engine, conflict_handler_delay, GINT_TO_POINTER(3)); - system("cp newdata data3/testdata1"); - system("cp newdata1 data2/testdata2"); + osync_testing_system_abort("cp newdata data3/testdata1"); + osync_testing_system_abort("cp newdata1 data2/testdata2"); synchronize_once(engine, NULL); @@ -1725,15 +1725,15 @@ sleep(2); - system("rm -f data2/testdata"); - system("cp newdata data3/testdata"); + osync_testing_system_abort("rm -f data2/testdata"); + osync_testing_system_abort("cp newdata data3/testdata"); - system("cp newdata3 data1/testdata1"); - system("rm -f data2/testdata1"); + osync_testing_system_abort("cp newdata3 data1/testdata1"); + osync_testing_system_abort("rm -f data2/testdata1"); - system("cp newdata data1/testdata2"); - system("rm -f data3/testdata2"); - system("rm -f data2/testdata2"); + osync_testing_system_abort("cp newdata data1/testdata2"); + osync_testing_system_abort("rm -f data3/testdata2"); + osync_testing_system_abort("rm -f data2/testdata2"); synchronize_once(engine, NULL); @@ -1775,7 +1775,7 @@ check_hash(table, "testdata2"); osync_hashtable_close(table); - system("rm -f data1/*"); + osync_testing_system_abort("rm -f data1/*"); mark_point(); num_mapping_conflicts = 0; @@ -1812,7 +1812,7 @@ OSyncEngine *engine = init_engine(group); osengine_set_conflict_callback(engine, conflict_handler_delay, GINT_TO_POINTER(3)); - system("cp newdata data3/testdata1"); + osync_testing_system_abort("cp newdata data3/testdata1"); setenv("SLOW_REPORT", "2", TRUE); synchronize_once(engine, NULL); @@ -1851,10 +1851,10 @@ sleep(2); - system("cp newdata data3/testdata"); + osync_testing_system_abort("cp newdata data3/testdata"); - system("cp newdata3 data1/testdata1"); - system("rm -f data2/testdata1"); + osync_testing_system_abort("cp newdata3 data1/testdata1"); + osync_testing_system_abort("rm -f data2/testdata1"); synchronize_once(engine, NULL); @@ -1894,7 +1894,7 @@ check_hash(table, "testdata1"); osync_hashtable_close(table); - system("rm -f data1/*"); + osync_testing_system_abort("rm -f data1/*"); mark_point(); num_mapping_conflicts = 0; @@ -1933,7 +1933,7 @@ OSyncEngine *engine = init_engine(group); osengine_set_conflict_callback(engine, conflict_handler_ignore, GINT_TO_POINTER(3)); - system("cp newdata data3/testdata1"); + osync_testing_system_abort("cp newdata data3/testdata1"); synchronize_once(engine, NULL); @@ -1978,12 +1978,12 @@ sleep(2); - system("rm -f data2/testdata"); - system("cp newdata data3/testdata"); + osync_testing_system_abort("rm -f data2/testdata"); + osync_testing_system_abort("cp newdata data3/testdata"); - system("cp newdata3 data1/testdata1"); - system("cp newdata2 data2/testdata1"); - system("cp newdata1 data3/testdata1"); + osync_testing_system_abort("cp newdata3 data1/testdata1"); + osync_testing_system_abort("cp newdata2 data2/testdata1"); + osync_testing_system_abort("cp newdata1 data3/testdata1"); synchronize_once(engine, NULL); @@ -2095,7 +2095,7 @@ check_hash(table, "testdata1"); osync_hashtable_close(table); - system("rm -f data1/*"); + osync_testing_system_abort("rm -f data1/*"); synchronize_once(engine, NULL); osengine_finalize(engine); @@ -2130,8 +2130,8 @@ OSyncEngine *engine = init_engine(group); osengine_set_conflict_callback(engine, conflict_handler_ignore, NULL); - system("cp newdata data3/testdata1"); - system("cp newdata1 data3/testdata"); + osync_testing_system_abort("cp newdata data3/testdata1"); + osync_testing_system_abort("cp newdata1 data3/testdata"); synchronize_once(engine, NULL); @@ -2169,7 +2169,7 @@ check_hash(table, "testdata1"); osync_hashtable_close(table); - system("cp newdata2 data2/testdata"); + osync_testing_system_abort("cp newdata2 data2/testdata"); osengine_set_conflict_callback(engine, conflict_handler_choose_first, GINT_TO_POINTER(3)); synchronize_once(engine, NULL); @@ -2210,7 +2210,7 @@ check_hash(table, "testdata1"); osync_hashtable_close(table); - system("rm -f data1/*"); + osync_testing_system_abort("rm -f data1/*"); synchronize_once(engine, NULL); osengine_finalize(engine); @@ -2365,7 +2365,7 @@ fail_unless(num_change_written == 0, NULL); fail_unless(num_engine_end_conflicts == 0, NULL); - system("rm -f data1/*"); + osync_testing_system_abort("rm -f data1/*"); unsetenv("NUM_BATCH_COMMITS"); |
From: <svn...@op...> - 2009-03-28 01:48:36
|
Author: dgollub Date: Sat Mar 28 02:33:55 2009 New Revision: 5367 URL: http://www.opensync.org/changeset/5367 Log: Unmaintained. Deleted: plugins/sync4j/ |
From: <svn...@op...> - 2009-03-28 01:11:24
|
Author: scriptor Date: Sat Mar 28 02:11:18 2009 New Revision: 5366 URL: http://www.opensync.org/changeset/5366 Log: The filename (with full path) of the configuration file "ldap-sync" as used with "osyncplugin --config ..." can now be overridden by setting CFG="/home/whoever/.opensync/group2/2/ldap-sync.conf", for example, in src/tests/test.conf. As opposed to other software the "make test" target here relies heavily on a running and configured LDAP server and an adequate configuration of the ldap plugin, especially with regard to the credentials, authentication method, store base, search base. tests/check_delete_and_fastsync is superfluous. See tests/check_add_modify_delete_and_sync instead. Therfore I have removed it. Modified: plugins/ldap-sync/tests/check_add_modify_delete_and_sync plugins/ldap-sync/tests/check_add_modify_delete_and_valgrind_and_sync plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_sync plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_valgrind_and_sync plugins/ldap-sync/tests/check_connect plugins/ldap-sync/tests/check_fastsync plugins/ldap-sync/tests/check_init plugins/ldap-sync/tests/check_modify_and_fastsync plugins/ldap-sync/tests/check_slowsync plugins/ldap-sync/tests/check_sync plugins/ldap-sync/tests/test.conf Modified: plugins/ldap-sync/tests/check_add_modify_delete_and_sync ============================================================================== --- plugins/ldap-sync/tests/check_add_modify_delete_and_sync Sat Mar 28 02:10:41 2009 (r5365) +++ plugins/ldap-sync/tests/check_add_modify_delete_and_sync Sat Mar 28 02:11:18 2009 (r5366) @@ -15,13 +15,6 @@ ENTRYMODS=$4 SYNCMETHOD=$5 - -echo "PLUGINPATH = \"$PLUGINPATH\"" -echo "CFG = \"$CFG\"" -echo "LDIF = \"$LDIF\"" -echo "ENTRYMODS = \"$ENTRYMODS\"" -echo "SYNCMETHOD = \"$SYNCMETHOD\"" - SOURCE_DIR=`dirname $FILE` if test ! -d "$SOURCE_DIR"; then echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR\" is not a directory. Exiting." @@ -40,10 +33,30 @@ exit 1 fi + + +echo "PLUGINPATH = \"$PLUGINPATH\"" +echo "CFG = \"$CFG\"" +echo "LDIF = \"$LDIF\"" +echo "ENTRYMODS = \"$ENTRYMODS\"" +echo "SYNCMETHOD = \"$SYNCMETHOD\"" + + +if test ! -f "$CFG"; then + echo "$FILE:$LINENO: ERROR: \"$CFG\" does not exist. Exiting." + exit 1 +fi + +if test ! -r "$CFG"; then + echo "$FILE:$LINENO: ERROR: \"$CFG\" does exist, but it is not readable. Exiting." + exit 1 +fi + + if test "$SYNCMETHOD" != "--fastsync"; then if test "$SYNCMETHOD" != "--slowsync"; then if test "$SYNCMETHOD" != "--sync"; then - echo "$FILE:$FILENO: WARNING: Syncronization method \"$SYNCMETHOD\" is unknown. Forcebly falling back to \"--fastsync\"." + echo "$FILE:$FILENO: WARNING: Synchronization method \"$SYNCMETHOD\" is unknown. Forcibly falling back to \"--fastsync\"." SYNCMETHOD="--fastsync" fi fi Modified: plugins/ldap-sync/tests/check_add_modify_delete_and_valgrind_and_sync ============================================================================== --- plugins/ldap-sync/tests/check_add_modify_delete_and_valgrind_and_sync Sat Mar 28 02:10:41 2009 (r5365) +++ plugins/ldap-sync/tests/check_add_modify_delete_and_valgrind_and_sync Sat Mar 28 02:11:18 2009 (r5366) @@ -47,19 +47,31 @@ fi +if test ! -f "$CFG"; then + echo "$FILE:$LINENO: ERROR: \"$CFG\" does not exist. Exiting." + exit 1 +fi + +if test ! -r "$CFG"; then + echo "$FILE:$LINENO: ERROR: \"$CFG\" does exist, but it is not readable. Exiting." + exit 1 +fi + + + + echo "PLUGINPATH = \"$PLUGINPATH\"" echo "CFG = \"$CFG\"" echo "LDIF = \"$LDIF\"" echo "ENTRYMODS = \"$ENTRYMODS\"" echo "SYNCMETHOD = \"$SYNCMETHOD\"" -echo "VALGRIND = \"$VALGRIND\"" if test "$SYNCMETHOD" != "--fastsync"; then if test "$SYNCMETHOD" != "--slowsync"; then if test "$SYNCMETHOD" != "--sync"; then - echo "$FILE:$FILENO: WARNING: Syncronization method \"$SYNCMETHOD\" is unknown. Forcebly falling back to \"--fastsync\"." + echo "$FILE:$FILENO: WARNING: Synchronization method \"$SYNCMETHOD\" is unknown. Forcibly falling back to \"--fastsync\"." SYNCMETHOD="--fastsync" fi fi Modified: plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_sync ============================================================================== --- plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_sync Sat Mar 28 02:10:41 2009 (r5365) +++ plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_sync Sat Mar 28 02:11:18 2009 (r5366) @@ -19,12 +19,6 @@ SYNCMETHOD=${11} -echo "PLUGINPATH = \"$PLUGINPATH\"" -echo "CFG = \"$CFG\"" -echo "LDIF = \"$LDIF\"" -echo "ENTRYMODS = \"$ENTRYMODS\"" -echo "SYNCMETHOD = \"$SYNCMETHOD\"" - SOURCE_DIR=`dirname $FILE` if test ! -d "$SOURCE_DIR"; then echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR\" is not a directory. Exiting." @@ -43,10 +37,33 @@ exit 1 fi + + + + +echo "PLUGINPATH = \"$PLUGINPATH\"" +echo "CFG = \"$CFG\"" +echo "LDIF = \"$LDIF\"" +echo "ENTRYMODS = \"$ENTRYMODS\"" +echo "SYNCMETHOD = \"$SYNCMETHOD\"" + + +if test ! -f "$CFG"; then + echo "$FILE:$LINENO: ERROR: \"$CFG\" does not exist. Exiting." + exit 1 +fi + +if test ! -r "$CFG"; then + echo "$FILE:$LINENO: ERROR: \"$CFG\" does exist, but it is not readable. Exiting." + exit 1 +fi + + + if test "$SYNCMETHOD" != "--fastsync"; then if test "$SYNCMETHOD" != "--slowsync"; then if test "$SYNCMETHOD" != "--sync"; then - echo "$FILE:$FILENO: WARNING: Syncronization method \"$SYNCMETHOD\" is unknown. Forcebly falling back to \"--fastsync\"." + echo "$FILE:$FILENO: WARNING: Synchronization method \"$SYNCMETHOD\" is unknown. Forcibly falling back to \"--fastsync\"." SYNCMETHOD="--fastsync" fi fi Modified: plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_valgrind_and_sync ============================================================================== --- plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_valgrind_and_sync Sat Mar 28 02:10:41 2009 (r5365) +++ plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_valgrind_and_sync Sat Mar 28 02:11:18 2009 (r5366) @@ -55,16 +55,28 @@ echo "PLUGINPATH = \"$PLUGINPATH\"" echo "CFG = \"$CFG\"" -echo "LDIF = \"$LDIF\"" -echo "ENTRYMODS = \"$ENTRYMODS\"" -echo "SYNCMETHOD = \"$SYNCMETHOD\"" echo "VALGRIND = \"$VALGRIND\"" + +if test ! -f "$CFG"; then + echo "$FILE:$LINENO: ERROR: \"$CFG\" does not exist. Exiting." + exit 1 +fi + +if test ! -r "$CFG"; then + echo "$FILE:$LINENO: ERROR: \"$CFG\" does exist, but it is not readable. Exiting." + exit 1 +fi + + + + + if test "$SYNCMETHOD" != "--fastsync"; then if test "$SYNCMETHOD" != "--slowsync"; then if test "$SYNCMETHOD" != "--sync"; then - echo "$FILE:$FILENO: WARNING: Syncronization method \"$SYNCMETHOD\" is unknown. Forcebly falling back to \"--fastsync\"." + echo "$FILE:$FILENO: WARNING: Synchronization method \"$SYNCMETHOD\" is unknown. Forcibly falling back to \"--fastsync\"." SYNCMETHOD="--fastsync" fi fi Modified: plugins/ldap-sync/tests/check_connect ============================================================================== --- plugins/ldap-sync/tests/check_connect Sat Mar 28 02:10:41 2009 (r5365) +++ plugins/ldap-sync/tests/check_connect Sat Mar 28 02:11:18 2009 (r5366) @@ -24,6 +24,38 @@ fi +SOURCE_DIR=`dirname $FILE` +if test ! -d "$SOURCE_DIR"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR\" is not a directory. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/test.conf"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +source "$SOURCE_DIR/test.conf" + + +echo "PLUGINPATH = \"$PLUGINPATH\"" +echo "CFG = \"$CFG\"" + + +if test ! -f "$CFG"; then + echo "$FILE:$LINENO: ERROR: \"$CFG\" does not exist. Exiting." + exit 1 +fi + +if test ! -r "$CFG"; then + echo "$FILE:$LINENO: ERROR: \"$CFG\" does exist, but it is not readable. Exiting." + exit 1 +fi + + + + + echo "${PLUGINPATH} ${CFG}" TMPDIR=`mktemp -d /tmp/ldap_sync_test.XXXXXX` || exit 1 Modified: plugins/ldap-sync/tests/check_fastsync ============================================================================== --- plugins/ldap-sync/tests/check_fastsync Sat Mar 28 02:10:41 2009 (r5365) +++ plugins/ldap-sync/tests/check_fastsync Sat Mar 28 02:11:18 2009 (r5366) @@ -25,6 +25,36 @@ fi + +SOURCE_DIR=`dirname $FILE` +if test ! -d "$SOURCE_DIR"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR\" is not a directory. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/test.conf"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +source "$SOURCE_DIR/test.conf" + +echo "PLUGINPATH = \"$PLUGINPATH\"" +echo "CFG = \"$CFG\"" + +if test ! -f "$CFG"; then + echo "$FILE:$LINENO: ERROR: \"$CFG\" does not exist. Exiting." + exit 1 +fi + +if test ! -r "$CFG"; then + echo "$FILE:$LINENO: ERROR: \"$CFG\" does exist, but it is not readable. Exiting." + exit 1 +fi + + + + echo "${PLUGINPATH} ${CFG}" TMPDIR=`mktemp -d /tmp/ldap_sync_test.XXXXXX` || exit 1 Modified: plugins/ldap-sync/tests/check_init ============================================================================== --- plugins/ldap-sync/tests/check_init Sat Mar 28 02:10:41 2009 (r5365) +++ plugins/ldap-sync/tests/check_init Sat Mar 28 02:11:18 2009 (r5366) @@ -25,6 +25,39 @@ fi +SOURCE_DIR=`dirname $FILE` +if test ! -d "$SOURCE_DIR"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR\" is not a directory. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/test.conf"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +source "$SOURCE_DIR/test.conf" + + + + +echo "PLUGINPATH = \"$PLUGINPATH\"" +echo "CFG = \"$CFG\"" + + + +if test ! -f "$CFG"; then + echo "$FILE:$LINENO: ERROR: \"$CFG\" does not exist. Exiting." + exit 1 +fi + +if test ! -r "$CFG"; then + echo "$FILE:$LINENO: ERROR: \"$CFG\" does exist, but it is not readable. Exiting." + exit 1 +fi + + + echo "${PLUGINPATH} ${CFG}" Modified: plugins/ldap-sync/tests/check_modify_and_fastsync ============================================================================== --- plugins/ldap-sync/tests/check_modify_and_fastsync Sat Mar 28 02:10:41 2009 (r5365) +++ plugins/ldap-sync/tests/check_modify_and_fastsync Sat Mar 28 02:11:18 2009 (r5366) @@ -13,11 +13,6 @@ LDIF=$3 -echo "PLUGINPATH = \"$PLUGINPATH\"" -echo "CFG = \"$CFG\"" -echo "LDIF = \"$LDIF\"" - - SOURCE_DIR=`dirname $FILE` if test ! -d "$SOURCE_DIR"; then echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR\" is not a directory. Exiting." @@ -38,6 +33,25 @@ +echo "PLUGINPATH = \"$PLUGINPATH\"" +echo "CFG = \"$CFG\"" +echo "LDIF = \"$LDIF\"" + + +if test ! -f "$CFG"; then + echo "$FILE:$LINENO: ERROR: \"$CFG\" does not exist. Exiting." + exit 1 +fi + +if test ! -r "$CFG"; then + echo "$FILE:$LINENO: ERROR: \"$CFG\" does exist, but it is not readable. Exiting." + exit 1 +fi + + + + + LDAPMODIFY=$(which ldapmodify 2>/dev/null) Modified: plugins/ldap-sync/tests/check_slowsync ============================================================================== --- plugins/ldap-sync/tests/check_slowsync Sat Mar 28 02:10:41 2009 (r5365) +++ plugins/ldap-sync/tests/check_slowsync Sat Mar 28 02:11:18 2009 (r5366) @@ -24,6 +24,41 @@ fi + +SOURCE_DIR=`dirname $FILE` +if test ! -d "$SOURCE_DIR"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR\" is not a directory. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/test.conf"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +source "$SOURCE_DIR/test.conf" + + + +echo "PLUGINPATH = \"$PLUGINPATH\"" +echo "CFG = \"$CFG\"" + + + +if test ! -f "$CFG"; then + echo "$FILE:$LINENO: ERROR: \"$CFG\" does not exist. Exiting." + exit 1 +fi + +if test ! -r "$CFG"; then + echo "$FILE:$LINENO: ERROR: \"$CFG\" does exist, but it is not readable. Exiting." + exit 1 +fi + + + + + echo "${PLUGINPATH} ${CFG}" TMPDIR=`mktemp -d /tmp/ldap_sync_test.XXXXXX` || exit 1 Modified: plugins/ldap-sync/tests/check_sync ============================================================================== --- plugins/ldap-sync/tests/check_sync Sat Mar 28 02:10:41 2009 (r5365) +++ plugins/ldap-sync/tests/check_sync Sat Mar 28 02:11:18 2009 (r5366) @@ -26,6 +26,39 @@ fi +SOURCE_DIR=`dirname $FILE` +if test ! -d "$SOURCE_DIR"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR\" is not a directory. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/test.conf"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +source "$SOURCE_DIR/test.conf" + + +echo "PLUGINPATH = \"$PLUGINPATH\"" +echo "CFG = \"$CFG\"" + + + +if test ! -f "$CFG"; then + echo "$FILE:$LINENO: ERROR: \"$CFG\" does not exist. Exiting." + exit 1 +fi + +if test ! -r "$CFG"; then + echo "$FILE:$LINENO: ERROR: \"$CFG\" does exist, but it is not readable. Exiting." + exit 1 +fi + + + + + echo "${PLUGINPATH} ${CFG}" TMPDIR=`mktemp -d /tmp/ldap_sync_test.XXXXXX` || exit 1 Modified: plugins/ldap-sync/tests/test.conf ============================================================================== --- plugins/ldap-sync/tests/test.conf Sat Mar 28 02:10:41 2009 (r5365) +++ plugins/ldap-sync/tests/test.conf Sat Mar 28 02:11:18 2009 (r5366) @@ -1,3 +1,7 @@ +# Here you could override the filename of the configuration file for the plugin. +# But you do not need to configure it, at all, because by default +# "src/ldap-sync" of the source directory is parsed: +# CFG="/home/user1/.opensync/group2/2/ldap-sync.conf" AUTH="-Y DIGEST-MD5 -U ldap_user -w secret -Q" #AUTH="-Y GSSAPI -Q" BASE_CONTACT="ou=addressbook,dc=example,dc=com" |
From: <svn...@op...> - 2009-03-28 01:11:04
|
Author: scriptor Date: Sat Mar 28 02:10:41 2009 New Revision: 5365 URL: http://www.opensync.org/changeset/5365 Log: Replaced http://localhost... links by links that can be reached by everyone. Modified: plugins/ldap-sync/src/ldap_plugin.c plugins/ldap-sync/src/ldap_plugin.h plugins/ldap-sync/src/ldap_sasl.c plugins/ldap-sync/src/md5_crypt.c Modified: plugins/ldap-sync/src/ldap_plugin.c ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.c Fri Mar 27 19:46:42 2009 (r5364) +++ plugins/ldap-sync/src/ldap_plugin.c Sat Mar 28 02:10:41 2009 (r5365) @@ -1862,7 +1862,7 @@ * modified at all on the LDAP server. * * This is necessary because of the following design decision: - * Quoting from http://localhost/libopensync-svn/group__OSyncHashtableAPI.html + * Quoting from http://www.opensync.org/doxygen/group__OSyncHashtableAPI.html * * "Entries get determined as deleted if they got * not reported as osync_hashtable_update_change(), independent of the @@ -2289,8 +2289,9 @@ */ } - // Report all the changes that are to be removed from the hashtable. - /* Quoting from http://localhost/libopensync-svn/group__OSyncHashtableAPI.html + /** + * Report all the changes that are to be removed from the hashtable. + * Quoting from http://www.opensync.org/doxygen/group__OSyncHashtableAPI.html * * "Entries get determined as deleted if they got * not reported as osync_hashtable_update_change(), independent of the Modified: plugins/ldap-sync/src/ldap_plugin.h ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.h Fri Mar 27 19:46:42 2009 (r5364) +++ plugins/ldap-sync/src/ldap_plugin.h Sat Mar 28 02:10:41 2009 (r5365) @@ -345,12 +345,14 @@ ///< NOT NEED TO. ///< ///< Cf. "REALMS" in: "Cyrus SASL for System Administrators" - ///< in: http://localhost/usr_share_doc/cyrus-sasl-lib-2.1.22/sysadmin.html + ///< in: file:///usr/share/doc/cyrus-sasl-2.1.22/sysadmin.html + ///< in: http://www.sendmail.org/~ca/email/cyrus2/sysadmin.html char *authcid; ///< The authentication by which a user wants to ///< authenticate with the LDAP server. ///< Cf. "Authentication and authorization identifiers" ///< in: "Cyrus SASL for System Administrators" - ///< in: http://localhost/usr_share_doc/cyrus-sasl-lib-2.1.22/sysadmin.html + ///< in: file:///usr/share/doc/cyrus-sasl-2.1.22/sysadmin.html + ///< in: http://www.sendmail.org/~ca/email/cyrus2/sysadmin.html char *passwd; ///< The password that corresponds to authcid. char *authzid; ///< If the user wants to act on behalf of someone else, ///< authzid's are used: The user authenticates @@ -358,7 +360,8 @@ ///< he also states the authzid of the other person. ///< Cf. "Authentication and authorization identifiers" ///< in: "Cyrus SASL for System Administrators" - ///< in: http://localhost/usr_share_doc/cyrus-sasl-lib-2.1.22/sysadmin.html + ///< in: file:///usr/share/doc/cyrus-sasl-2.1.22/sysadmin.html + ///< in: http://www.sendmail.org/~ca/email/cyrus2/sysadmin.html char **resps; ///< ??? int nresps; ///< ??? } lutilSASLdefaults; Modified: plugins/ldap-sync/src/ldap_sasl.c ============================================================================== --- plugins/ldap-sync/src/ldap_sasl.c Fri Mar 27 19:46:42 2009 (r5364) +++ plugins/ldap-sync/src/ldap_sasl.c Sat Mar 28 02:10:41 2009 (r5365) @@ -362,7 +362,7 @@ } if (res == NULL) { - // xxx jl: TODO: Produce osync error message. + // TODO: Produce osync error message. osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldap_plugin_call_ldap_search() has failed.\n", __FILE__, __LINE__); Modified: plugins/ldap-sync/src/md5_crypt.c ============================================================================== --- plugins/ldap-sync/src/md5_crypt.c Fri Mar 27 19:46:42 2009 (r5364) +++ plugins/ldap-sync/src/md5_crypt.c Sat Mar 28 02:10:41 2009 (r5365) @@ -221,7 +221,7 @@ // 1 as the format argument works ONLY, if xmlKeepBlanksDefault(0) // was called before. - // http://localhost/usr_share_doc/libxml2-devel-2.7.2/html/libxml-tree.html#xmlDocDumpFormatMemory + // http://xmlsoft.org/html/libxml-tree.html#xmlDocDumpFormatMemory xmlDocDumpFormatMemory((xmlDoc *)xmlcard, &mem, &size2, 1); if (mem) { |
From: <svn...@op...> - 2009-03-27 18:47:06
|
Author: dgollub Date: Fri Mar 27 19:46:42 2009 New Revision: 5364 URL: http://www.opensync.org/changeset/5364 Log: Deleted duplicate testcase of sync_error unit. Those used to be 1:1 the same to engine_error unit. Thanks to Ian for finding this 2000 lines of redudant code! fixes #980 Modified: trunk/tests/sync-tests/check_sync_error.c Modified: trunk/tests/sync-tests/check_sync_error.c ============================================================================== --- trunk/tests/sync-tests/check_sync_error.c Fri Mar 27 19:00:20 2009 (r5363) +++ trunk/tests/sync-tests/check_sync_error.c Fri Mar 27 19:46:42 2009 (r5364) @@ -43,2102 +43,8 @@ } END_TEST -OSYNC_UNUSED START_TEST (sync_error_single_init_error) -{ - char *testbed = setup_testbed("multisync_easy_new"); - - g_setenv("INIT_NULL", "2", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - - /* this is a bug - please see sml_fail_unless for details */ - fail_unless(osync_engine_initialize(engine, &error), osync_error_print(&error)); - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - osync_error_unref(&error); - osync_engine_finalize(engine, &error); - osync_engine_unref(engine); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_dual_connect_error) -{ - char *testbed = setup_testbed("sync_easy_new"); - - g_setenv("CONNECT_ERROR", "3", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - fail_unless(num_client_errors == 2, NULL); - fail_unless(num_client_connected == 0, NULL); - fail_unless(num_client_disconnected == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - - osync_error_unref(&error); - osync_engine_finalize(engine, &error); - osync_engine_unref(engine); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_one_of_two_connect_error) -{ - char *testbed = setup_testbed("sync_easy_new"); - - g_setenv("CONNECT_ERROR", "1", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - fail_unless(num_client_errors == 1, NULL); - fail_unless(num_client_connected == 1, NULL); - fail_unless(num_client_disconnected == 1, NULL); - //fail_unless(num_member_sent_changes == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - - osync_error_unref(&error); - osync_engine_finalize(engine, &error); - osync_engine_unref(engine); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_two_of_three_connect_error) -{ - char *testbed = setup_testbed("multisync_easy_new"); - - g_setenv("CONNECT_ERROR", "5", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - fail_unless(num_client_errors == 2, NULL); - fail_unless(num_client_connected == 1, NULL); - fail_unless(num_client_disconnected == 1, NULL); - //fail_unless(num_member_sent_changes == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - - osync_error_unref(&error); - osync_engine_finalize(engine, &error); - osync_engine_unref(engine); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_two_of_three_connect_error2) -{ - char *testbed = setup_testbed("multisync_easy_new"); - - g_setenv("CONNECT_ERROR", "6", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - fail_unless(num_client_errors == 2, NULL); - fail_unless(num_client_connected == 1, NULL); - fail_unless(num_client_disconnected == 1, NULL); - //fail_unless(num_member_sent_changes == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - - osync_error_unref(&error); - osync_engine_finalize(engine, &error); - osync_engine_unref(engine); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_three_of_three_connect_error) -{ - char *testbed = setup_testbed("multisync_easy_new"); - - g_setenv("CONNECT_ERROR", "7", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - fail_unless(num_client_errors == 3, NULL); - fail_unless(num_client_connected == 0, NULL); - fail_unless(num_client_disconnected == 0, NULL); - //fail_unless(num_member_sent_changes == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - - osync_error_unref(&error); - osync_engine_finalize(engine, &error); - osync_engine_unref(engine); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_one_of_three_connect_error) -{ - char *testbed = setup_testbed("multisync_easy_new"); - - g_setenv("CONNECT_ERROR", "2", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - fail_unless(num_client_errors == 1, NULL); - fail_unless(num_client_connected == 2, NULL); - fail_unless(num_client_disconnected == 2, NULL); - //fail_unless(num_member_sent_changes == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - - osync_error_unref(&error); - osync_engine_finalize(engine, &error); - osync_engine_unref(engine); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_no_connect_error) -{ - char *testbed = setup_testbed("multisync_easy_new"); - - g_setenv("CONNECT_ERROR", "0", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(synchronize_once(engine, &error), NULL); - fail_unless(!osync_error_is_set(&error), NULL); - - fail_unless(num_client_errors == 0, NULL); - fail_unless(num_client_connected == 3, NULL); - fail_unless(num_client_disconnected == 3, NULL); - //fail_unless(num_member_sent_changes == 3, NULL); - fail_unless(num_engine_errors == 0, NULL); - fail_unless(num_engine_successful == 1, NULL); - - osync_engine_finalize(engine, &error); - osync_engine_unref(engine); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" == \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" == \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_single_connect_timeout) -{ - char *testbed = setup_testbed("sync_easy_new"); - - g_setenv("CONNECT_TIMEOUT", "2", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - fail_unless(num_client_errors == 1, NULL); - fail_unless(num_client_connected == 1, NULL); - fail_unless(num_client_disconnected == 1, NULL); - //fail_unless(num_member_sent_changes == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - osync_error_unref(&error); - osync_engine_finalize(engine, &error); - osync_engine_unref(engine); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_dual_connect_timeout) -{ - char *testbed = setup_testbed("sync_easy_new"); - - g_setenv("CONNECT_TIMEOUT", "3", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - fail_unless(num_client_errors == 2, NULL); - fail_unless(num_client_connected == 0, NULL); - fail_unless(num_client_disconnected == 0, NULL); - //fail_unless(num_member_sent_changes == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - osync_error_unref(&error); - osync_engine_finalize(engine, &error); - osync_engine_unref(engine); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_one_of_three_timeout) -{ - char *testbed = setup_testbed("multisync_easy_new"); - - g_setenv("CONNECT_TIMEOUT", "2", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - fail_unless(num_client_errors == 1, NULL); - fail_unless(num_client_connected == 2, NULL); - fail_unless(num_client_disconnected == 2, NULL); - //fail_unless(num_member_sent_changes == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - osync_error_unref(&error); - osync_engine_finalize(engine, &error); - osync_engine_unref(engine); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_timeout_and_error) -{ - char *testbed = setup_testbed("multisync_easy_new"); - - g_setenv("CONNECT_TIMEOUT", "2", TRUE); - g_setenv("CONNECT_ERROR", "4", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - fail_unless(num_client_errors == 2, NULL); - fail_unless(num_client_connected == 1, NULL); - fail_unless(num_client_disconnected == 1, NULL); - //fail_unless(num_member_sent_changes == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - osync_error_unref(&error); - osync_engine_finalize(engine, &error); - osync_engine_unref(engine); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_single_get_changes_error) -{ - char *testbed = setup_testbed("sync_easy_conflict"); - - g_setenv("GET_CHANGES_ERROR", "2", TRUE); - g_setenv("NO_COMMITTED_ALL_CHECK", "1", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - fail_unless(num_client_errors == 0, NULL); - fail_unless(num_client_connected == 2, NULL); - fail_unless(num_client_disconnected == 2, NULL); - //fail_unless(num_member_get_changes_errors == 1, NULL); - fail_unless(num_client_written == 0, NULL); - //fail_unless(num_conflicts == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - osync_error_unref(&error); - osync_engine_finalize(engine, &error); - osync_engine_unref(engine); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_dual_get_changes_error) -{ - char *testbed = setup_testbed("sync_easy_conflict"); - - g_setenv("GET_CHANGES_ERROR", "3", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - fail_unless(num_client_errors == 0, NULL); - fail_unless(num_client_connected == 2, NULL); - fail_unless(num_client_disconnected == 2, NULL); - //fail_unless(num_member_sent_changes == 0, NULL); - fail_unless(num_client_read == 0, NULL); - fail_unless(num_client_written == 0, NULL); - //fail_unless(num_conflicts == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - osync_error_unref(&error); - osync_engine_finalize(engine, &error); - osync_engine_unref(engine); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_two_of_three_get_changes_error) -{ - char *testbed = setup_testbed("multisync_conflict_data_choose2"); - - g_setenv("GET_CHANGES_ERROR", "5", TRUE); - g_setenv("NO_COMMITTED_ALL_CHECK", "1", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - fail_unless(num_client_errors == 0, NULL); - fail_unless(num_client_connected == 3, NULL); - fail_unless(num_client_disconnected == 3, NULL); - fail_unless(num_client_written == 0, NULL); - //fail_unless(num_conflicts == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - osync_error_unref(&error); - osync_engine_finalize(engine, &error); - osync_engine_unref(engine); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_one_of_three_get_changes_error) -{ - char *testbed = setup_testbed("multisync_conflict_data_choose2"); - - g_setenv("GET_CHANGES_ERROR", "1", TRUE); - g_setenv("NO_COMMITTED_ALL_CHECK", "1", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - fail_unless(num_client_errors == 0, NULL); - fail_unless(num_client_connected == 3, NULL); - fail_unless(num_client_disconnected == 3, NULL); - //fail_unless(num_member_get_changes_errors == 1, NULL); - fail_unless(num_client_written == 0, NULL); - //fail_unless(num_conflicts == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - osync_error_unref(&error); - osync_engine_finalize(engine, &error); - osync_engine_unref(engine); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_one_of_three_get_changes_timeout) -{ - char *testbed = setup_testbed("multisync_conflict_data_choose2"); - - g_setenv("GET_CHANGES_TIMEOUT", "1", TRUE); - g_setenv("NO_COMMITTED_ALL_CHECK", "1", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - fail_unless(num_client_errors == 0, NULL); - fail_unless(num_client_connected == 3, NULL); - fail_unless(num_client_disconnected == 3, NULL); - //fail_unless(num_member_get_changes_errors == 1, NULL); - //fail_unless(num_member_sent_changes == 2, NULL); - fail_unless(num_client_read == 2, NULL); - fail_unless(num_client_written == 0, NULL); - //fail_unless(num_conflicts == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - osync_error_unref(&error); - osync_engine_finalize(engine, &error); - osync_engine_unref(engine); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_get_changes_timeout_and_error) -{ - char *testbed = setup_testbed("multisync_conflict_data_choose2"); - - g_setenv("GET_CHANGES_TIMEOUT", "3", TRUE); - g_setenv("GET_CHANGES_ERROR", "4", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - fail_unless(num_client_errors == 0, NULL); - fail_unless(num_client_connected == 3, NULL); - fail_unless(num_client_disconnected == 3, NULL); - //fail_unless(num_member_sent_changes == 0, NULL); - fail_unless(num_client_read == 0, NULL); - fail_unless(num_client_written == 0, NULL); - //fail_unless(num_conflicts == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - osync_error_unref(&error); - osync_engine_finalize(engine, &error); - osync_engine_unref(engine); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_get_changes_timeout_sleep) -{ - char *testbed = setup_testbed("multisync_conflict_data_choose2"); - - g_setenv("GET_CHANGES_TIMEOUT2", "7", TRUE); - g_setenv("NO_COMMITTED_ALL_CHECK", "1", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - mark_point(); - osync_error_unref(&error); - mark_point(); - osync_engine_finalize(engine, &error); - mark_point(); - osync_engine_unref(engine); - - fail_unless(num_client_errors == 0, NULL); - fail_unless(num_client_connected == 3, NULL); - fail_unless(num_client_disconnected == 3, NULL); - //fail_unless(num_member_sent_changes == 0, NULL); - fail_unless(num_client_read == 0, NULL); - fail_unless(num_client_written == 0, NULL); - //fail_unless(num_conflicts == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_single_commit_error) -{ - char *testbed = setup_testbed("multisync_easy_new"); - - g_setenv("COMMIT_ERROR", "4", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_mappingstatus_callback(engine, mapping_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - mark_point(); - osync_error_unref(&error); - mark_point(); - osync_engine_finalize(engine, &error); - mark_point(); - osync_engine_unref(engine); - - fail_unless(num_client_errors == 0, NULL); - fail_unless(num_client_connected == 3, NULL); - fail_unless(num_client_disconnected == 3, NULL); - //fail_unless(num_member_sent_changes == 3, NULL); - fail_unless(num_client_read == 1, NULL); - fail_unless(num_client_written == 1, NULL); - //fail_unless(num_written_errors == 1, NULL); - fail_unless(num_mapping_errors == 1, NULL); - //fail_unless(num_conflicts == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" == \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_dual_commit_error) -{ - char *testbed = setup_testbed("multisync_easy_new"); - - g_setenv("COMMIT_ERROR", "6", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_mappingstatus_callback(engine, mapping_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - mark_point(); - osync_error_unref(&error); - mark_point(); - osync_engine_finalize(engine, &error); - mark_point(); - osync_engine_unref(engine); - - fail_unless(num_client_errors == 0, NULL); - fail_unless(num_client_connected == 3, NULL); - fail_unless(num_client_disconnected == 3, NULL); - //fail_unless(num_member_sent_changes == 3, NULL); - fail_unless(num_client_read == 1, NULL); - fail_unless(num_client_written == 0, NULL); - //fail_unless(num_written_errors == 2, NULL); - fail_unless(num_mapping_errors == 2, NULL); - //fail_unless(num_conflicts == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_single_commit_timeout) -{ - char *testbed = setup_testbed("multisync_easy_new"); - - g_setenv("COMMIT_TIMEOUT", "4", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_mappingstatus_callback(engine, mapping_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - mark_point(); - osync_error_unref(&error); - mark_point(); - osync_engine_finalize(engine, &error); - mark_point(); - osync_engine_unref(engine); - - fail_unless(num_client_errors == 0, NULL); - fail_unless(num_client_connected == 3, NULL); - fail_unless(num_client_disconnected == 3, NULL); - //fail_unless(num_member_sent_changes == 3, NULL); - fail_unless(num_client_read == 1, NULL); - fail_unless(num_client_written == 1, NULL); - //fail_unless(num_written_errors == 1, NULL); - fail_unless(num_mapping_errors == 1, NULL); - //fail_unless(num_conflicts == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" == \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_dual_commit_timeout) -{ - char *testbed = setup_testbed("multisync_easy_new"); - - g_setenv("COMMIT_TIMEOUT", "6", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_mappingstatus_callback(engine, mapping_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - mark_point(); - osync_error_unref(&error); - mark_point(); - osync_engine_finalize(engine, &error); - mark_point(); - osync_engine_unref(engine); - - fail_unless(num_client_errors == 0, NULL); - fail_unless(num_client_connected == 3, NULL); - fail_unless(num_client_disconnected == 3, NULL); - //fail_unless(num_member_sent_changes == 3, NULL); - fail_unless(num_client_read == 1, NULL); - fail_unless(num_client_written == 0, NULL); - //fail_unless(num_written_errors == 2, NULL); - fail_unless(num_mapping_errors == 2, NULL); - //fail_unless(num_conflicts == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_commit_timeout_and_error) -{ - char *testbed = setup_testbed("multisync_easy_new"); - - g_setenv("COMMIT_TIMEOUT", "4", TRUE); - g_setenv("COMMIT_ERROR", "2", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_mappingstatus_callback(engine, mapping_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - mark_point(); - osync_error_unref(&error); - mark_point(); - osync_engine_finalize(engine, &error); - mark_point(); - osync_engine_unref(engine); - - fail_unless(num_client_errors == 0, NULL); - fail_unless(num_client_connected == 3, NULL); - fail_unless(num_client_disconnected == 3, NULL); - //fail_unless(num_member_sent_changes == 3, NULL); - fail_unless(num_client_read == 1, NULL); - fail_unless(num_client_written == 0, NULL); - //fail_unless(num_written_errors == 2, NULL); - fail_unless(num_mapping_errors == 2, NULL); - //fail_unless(num_conflicts == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_commit_timeout_and_error2) -{ - char *testbed = setup_testbed("multisync_easy_new"); - - g_setenv("COMMIT_TIMEOUT", "2", TRUE); - g_setenv("COMMIT_ERROR", "4", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_mappingstatus_callback(engine, mapping_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - mark_point(); - osync_error_unref(&error); - mark_point(); - osync_engine_finalize(engine, &error); - mark_point(); - osync_engine_unref(engine); - - fail_unless(num_client_errors == 0, NULL); - fail_unless(num_client_connected == 3, NULL); - fail_unless(num_client_disconnected == 3, NULL); - //fail_unless(num_member_sent_changes == 3, NULL); - fail_unless(num_client_read == 1, NULL); - fail_unless(num_client_written == 0, NULL); - //fail_unless(num_written_errors == 2, NULL); - fail_unless(num_mapping_errors == 2, NULL); - //fail_unless(num_conflicts == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" != \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_commit_error_modify) -{ - char *testbed = setup_testbed("multisync_easy_new"); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_mappingstatus_callback(engine, mapping_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(synchronize_once(engine, &error), NULL); - fail_unless(!osync_error_is_set(&error), NULL); - - g_setenv("COMMIT_TIMEOUT", "2", TRUE); - g_setenv("COMMIT_ERROR", "4", TRUE); - - g_usleep(2*G_USEC_PER_SEC); - - osync_testing_system_abort("cp newdata2 data1/testdata"); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - mark_point(); - osync_error_unref(&error); - mark_point(); - osync_engine_finalize(engine, &error); - mark_point(); - osync_engine_unref(engine); - - fail_unless(num_client_errors == 0, NULL); - fail_unless(num_client_connected == 3, NULL); - fail_unless(num_client_disconnected == 3, NULL); - //fail_unless(num_member_sent_changes == 3, NULL); - fail_unless(num_client_read == 1, NULL); - fail_unless(num_client_written == 0, NULL); - //fail_unless(num_written_errors == 2, NULL); - fail_unless(num_mapping_errors == 2, NULL); - //fail_unless(num_conflicts == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" != \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data2 data3)\" == \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_commit_error_delete) -{ - char *testbed = setup_testbed("multisync_easy_new"); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_mappingstatus_callback(engine, mapping_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(synchronize_once(engine, &error), NULL); - fail_unless(!osync_error_is_set(&error), NULL); - - g_setenv("COMMIT_TIMEOUT", "2", TRUE); - g_setenv("COMMIT_ERROR", "4", TRUE); - - g_usleep(2*G_USEC_PER_SEC); - - osync_testing_system_abort("rm -f data1/testdata"); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - mark_point(); - osync_error_unref(&error); - mark_point(); - osync_engine_finalize(engine, &error); - mark_point(); - osync_engine_unref(engine); - - fail_unless(num_client_errors == 0, NULL); - fail_unless(num_client_connected == 3, NULL); - fail_unless(num_client_disconnected == 3, NULL); - //fail_unless(num_member_sent_changes == 3, NULL); - fail_unless(num_client_read == 1, NULL); - fail_unless(num_client_written == 0, NULL); - //fail_unless(num_written_errors == 2, NULL); - fail_unless(num_mapping_errors == 2, NULL); - //fail_unless(num_conflicts == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" != \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data2 data3)\" == \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_committed_all_error) -{ - char *testbed = setup_testbed("multisync_easy_new"); - - g_setenv("COMMITTED_ALL_ERROR", "3", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_mappingstatus_callback(engine, mapping_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - mark_point(); - osync_error_unref(&error); - mark_point(); - osync_engine_finalize(engine, &error); - mark_point(); - osync_engine_unref(engine); - - fail_unless(num_client_errors == 0, NULL); - fail_unless(num_client_connected == 3, NULL); - fail_unless(num_client_disconnected == 3, NULL); - //fail_unless(num_member_sent_changes == 3, NULL); - fail_unless(num_client_read == 1, NULL); - fail_unless(num_client_written == 2, NULL); - //fail_unless(num_written_errors == 0, NULL); - fail_unless(num_mapping_errors == 0, NULL); - //fail_unless(num_conflicts == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_committed_all_batch_error) -{ - char *testbed = setup_testbed("multisync_easy_new"); - - g_setenv("BATCH_COMMIT", "7", TRUE); - g_setenv("COMMITTED_ALL_ERROR", "3", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_mappingstatus_callback(engine, mapping_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - mark_point(); - osync_error_unref(&error); - mark_point(); - osync_engine_finalize(engine, &error); - mark_point(); - osync_engine_unref(engine); - - fail_unless(num_client_errors == 0, NULL); - fail_unless(num_client_connected == 3, NULL); - fail_unless(num_client_disconnected == 3, NULL); - //fail_unless(num_member_sent_changes == 3, NULL); - fail_unless(num_client_read == 1, NULL); - fail_unless(num_client_written == 2, NULL); - //fail_unless(num_written_errors == 0, NULL); - fail_unless(num_mapping_errors == 0, NULL); - //fail_unless(num_conflicts == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_single_sync_done_error) -{ - char *testbed = setup_testbed("multisync_easy_new"); - - g_setenv("SYNC_DONE_ERROR", "4", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_mappingstatus_callback(engine, mapping_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - mark_point(); - osync_error_unref(&error); - mark_point(); - osync_engine_finalize(engine, &error); - mark_point(); - osync_engine_unref(engine); - - fail_unless(num_client_errors == 0, NULL); - fail_unless(num_client_connected == 3, NULL); - fail_unless(num_client_disconnected == 3, NULL); - //fail_unless(num_member_sent_changes == 3, NULL); - fail_unless(num_client_read == 1, NULL); - fail_unless(num_client_written == 2, NULL); - //fail_unless(num_written_errors == 0, NULL); - fail_unless(num_mapping_errors == 0, NULL); - //fail_unless(num_member_sync_done_errors == 1, NULL); - //fail_unless(num_conflicts == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" == \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" == \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_dual_sync_done_error) -{ - char *testbed = setup_testbed("multisync_easy_new"); - - g_setenv("SYNC_DONE_ERROR", "6", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_mappingstatus_callback(engine, mapping_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - mark_point(); - osync_error_unref(&error); - mark_point(); - osync_engine_finalize(engine, &error); - mark_point(); - osync_engine_unref(engine); - - fail_unless(num_client_errors == 0, NULL); - fail_unless(num_client_connected == 3, NULL); - fail_unless(num_client_disconnected == 3, NULL); - //fail_unless(num_member_sent_changes == 3, NULL); - fail_unless(num_client_read == 1, NULL); - fail_unless(num_client_written == 2, NULL); - //fail_unless(num_written_errors == 0, NULL); - fail_unless(num_mapping_errors == 0, NULL); - //fail_unless(num_conflicts == 0, NULL); - //fail_unless(num_member_sync_done_errors == 2, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" == \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" == \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_triple_sync_done_error) -{ - char *testbed = setup_testbed("multisync_easy_new"); - - g_setenv("SYNC_DONE_ERROR", "7", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_mappingstatus_callback(engine, mapping_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - mark_point(); - osync_error_unref(&error); - mark_point(); - osync_engine_finalize(engine, &error); - mark_point(); - osync_engine_unref(engine); - - fail_unless(num_client_errors == 0, NULL); - fail_unless(num_client_connected == 3, NULL); - fail_unless(num_client_disconnected == 3, NULL); - //fail_unless(num_member_sent_changes == 3, NULL); - fail_unless(num_client_read == 1, NULL); - fail_unless(num_client_written == 2, NULL); - //fail_unless(num_written_errors == 0, NULL); - fail_unless(num_mapping_errors == 0, NULL); - //fail_unless(num_conflicts == 0, NULL); - //fail_unless(num_member_sync_done_errors == 3, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" == \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" == \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_single_sync_done_timeout) -{ - char *testbed = setup_testbed("multisync_easy_new"); - - g_setenv("SYNC_DONE_TIMEOUT", "4", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_mappingstatus_callback(engine, mapping_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - mark_point(); - osync_error_unref(&error); - mark_point(); - osync_engine_finalize(engine, &error); - mark_point(); - osync_engine_unref(engine); - - fail_unless(num_client_errors == 0, NULL); - fail_unless(num_client_connected == 3, NULL); - fail_unless(num_client_disconnected == 3, NULL); - //fail_unless(num_member_sent_changes == 3, NULL); - fail_unless(num_client_read == 1, NULL); - fail_unless(num_client_written == 2, NULL); - //fail_unless(num_written_errors == 0, NULL); - fail_unless(num_mapping_errors == 0, NULL); - //fail_unless(num_conflicts == 0, NULL); - //fail_unless(num_member_sync_done_errors == 1, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" == \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" == \"x\""), NULL); - - destroy_testbed(testbed); -} -END_TEST - -OSYNC_UNUSED START_TEST (sync_error_dual_sync_done_timeout) -{ - char *testbed = setup_testbed("multisync_easy_new"); - - g_setenv("SYNC_DONE_TIMEOUT", "6", TRUE); - - OSyncError *error = NULL; - OSyncGroup *group = osync_group_new(&error); - fail_unless(group != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_group_set_schemadir(group, testbed); - fail_unless(osync_group_load(group, "configs/group", &error), NULL); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - osync_engine_set_memberstatus_callback(engine, member_status, NULL); - osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - osync_engine_set_changestatus_callback(engine, entry_status, NULL); - osync_engine_set_mappingstatus_callback(engine, mapping_status, NULL); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - fail_unless(osync_engine_initialize(engine, &error), NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - mark_point(); - osync_error_unref(&error); - mark_point(); - osync_engine_finalize(engine, &error); - mark_point(); - osync_engine_unref(engine); - - fail_unless(num_client_errors == 0, NULL); - fail_unless(num_client_connected == 3, NULL); - fail_unless(num_client_disconnected == 3, NULL); - //fail_unless(num_member_sent_changes == 3, NULL); - fail_unless(num_client_read == 1, NULL); - fail_unless(num_client_written == 2, NUL... [truncated message content] |
From: <svn...@op...> - 2009-03-27 18:00:28
|
Author: dgollub Date: Fri Mar 27 19:00:20 2009 New Revision: 5363 URL: http://www.opensync.org/changeset/5363 Log: Add an example how to disable testcases. Currently all are enabled :) Modified: trunk/tests/CMakeLists.txt Modified: trunk/tests/CMakeLists.txt ============================================================================== --- trunk/tests/CMakeLists.txt Fri Mar 27 18:54:00 2009 (r5362) +++ trunk/tests/CMakeLists.txt Fri Mar 27 19:00:20 2009 (r5363) @@ -15,6 +15,11 @@ SET( TEST_TARGET_LIBRARIES support ) ADD_TEST( symbols ${CMAKE_CURRENT_SOURCE_DIR}/abiapi-tests/check-symbols ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ) + +### Example how to diasble a testcase ### +# OSYNC_TESTCASE_DISABLED(lock lock_dual_sync_engine_unclean "1066" ) +# OSYNC_TESTCASE_DISABLED($test_binary $testcase_name "$ticket_number" ) + BUILD_CHECK_TEST( error check_error.c ${TEST_TARGET_LIBRARIES} ) OSYNC_TESTCASE(error error_create) OSYNC_TESTCASE(error error_create_null) |
From: <svn...@op...> - 2009-03-27 17:54:07
|
Author: dgollub Date: Fri Mar 27 18:54:00 2009 New Revision: 5362 URL: http://www.opensync.org/changeset/5362 Log: Remove testcase hack to simulate an unclean shutdown of a synchronization. Since this test is designed just to simulate a "stale lock" situtation - it's enough by just faking a "stale lock" without the need of simulating a crash. Thanks to Friedrich for the initial review of this issue. fixes #1066 Modified: trunk/tests/CMakeLists.txt trunk/tests/group-tests/check_lock.c Modified: trunk/tests/CMakeLists.txt ============================================================================== --- trunk/tests/CMakeLists.txt Fri Mar 27 18:28:07 2009 (r5361) +++ trunk/tests/CMakeLists.txt Fri Mar 27 18:54:00 2009 (r5362) @@ -227,7 +227,7 @@ OSYNC_TESTCASE(lock lock_dual_lock) OSYNC_TESTCASE(lock lock_dual_lock2) OSYNC_TESTCASE(lock lock_dual_sync_engine_lock) -OSYNC_TESTCASE_DISABLED(lock lock_dual_sync_engine_unclean "1066" ) +OSYNC_TESTCASE(lock lock_dual_sync_engine_unclean ) IF (NOT WIN32) BUILD_CHECK_TEST( ipc ipc-tests/check_ipc.c ${TEST_TARGET_LIBRARIES} ) Modified: trunk/tests/group-tests/check_lock.c ============================================================================== --- trunk/tests/group-tests/check_lock.c Fri Mar 27 18:28:07 2009 (r5361) +++ trunk/tests/group-tests/check_lock.c Fri Mar 27 18:54:00 2009 (r5362) @@ -179,18 +179,6 @@ osync_engine_set_enginestatus_callback(engine, engine_status, NULL); - /* Quit the engine thread, before free()ing it - * - * We want to simulate a unclean engine exit (so we can't use - * osync_engine_finalize() here), but we don't want the old engine thread to - * be running and stealing the messages going to the second engine. - */ - if (engine->thread) { - osync_thread_stop(engine->thread); - osync_thread_unref(engine->thread); - engine->thread = NULL; - } - osync_engine_finalize(engine, &error); osync_engine_unref(engine); osync_group_unref(group); |
From: <svn...@op...> - 2009-03-27 17:28:10
|
Author: dgollub Date: Fri Mar 27 18:28:07 2009 New Revision: 5361 URL: http://www.opensync.org/changeset/5361 Log: Reenable ipc_callback_break_pipes which got fixed with r5360. refs #1039 Modified: trunk/tests/CMakeLists.txt Modified: trunk/tests/CMakeLists.txt ============================================================================== --- trunk/tests/CMakeLists.txt Fri Mar 27 18:26:25 2009 (r5360) +++ trunk/tests/CMakeLists.txt Fri Mar 27 18:28:07 2009 (r5361) @@ -250,7 +250,7 @@ OSYNC_TESTCASE(ipc ipc_callback_break) OSYNC_TESTCASE(ipc ipc_pipes) OSYNC_TESTCASE(ipc ipc_pipes_stress) -OSYNC_TESTCASE_DISABLED(ipc ipc_callback_break_pipes "1039") +OSYNC_TESTCASE(ipc ipc_callback_break_pipes) OSYNC_TESTCASE(ipc ipc_timeout) OSYNC_TESTCASE(ipc ipc_loop_with_timeout) OSYNC_TESTCASE(ipc ipc_late_reply) |
From: <svn...@op...> - 2009-03-27 17:26:34
|
Author: dgollub Date: Fri Mar 27 18:26:25 2009 New Revision: 5360 URL: http://www.opensync.org/changeset/5360 Log: Make ipc_callback_break_pipes more reliable by sending and processing message one by one. This avoids that the queue gets flushed to early - which was quite racy if the client was faster then the server processing the callbacks. fixes #1039 Modified: trunk/tests/ipc-tests/check_ipc.c Modified: trunk/tests/ipc-tests/check_ipc.c ============================================================================== --- trunk/tests/ipc-tests/check_ipc.c Fri Mar 27 13:59:25 2009 (r5359) +++ trunk/tests/ipc-tests/check_ipc.c Fri Mar 27 18:26:25 2009 (r5360) @@ -1548,6 +1548,8 @@ END_TEST int stop_after = 500; +GCond *callback_handler2_cond; +GMutex *callback_handler2_mutex; void callback_handler2(OSyncMessage *message, void *user_data) { @@ -1562,6 +1564,10 @@ } num_msgs++; + + g_mutex_lock(callback_handler2_mutex); + g_cond_signal(callback_handler2_cond); + g_mutex_unlock(callback_handler2_mutex); osync_trace(TRACE_EXIT, "%s", __func__); } @@ -1632,6 +1638,9 @@ osync_queue_create(client_queue, &error); fail_unless(error == NULL, NULL); char *data = "this is another test string"; + + callback_handler2_cond = g_cond_new(); + callback_handler2_mutex = g_mutex_new(); pid_t cpid = fork(); if (cpid == 0) { //Child @@ -1699,6 +1708,19 @@ fail_unless(!osync_error_is_set(&error), NULL); osync_message_unref(message); + + /* Send and process one by one and wait for the call + * of the server callback. This avoids that the pipe + * break (e.g. disconnect call) happens to early. + * + * With the disconnect call the queues get flushed + * and the callback_handler2 function would get + * immeditally the error messages. Which is not expected + * or designed in this testcase. + * + * (related) Fixes #1039 + */ + g_cond_wait(callback_handler2_cond, callback_handler2_mutex); } message = osync_queue_get_message(client_queue); @@ -1733,6 +1755,11 @@ osync_queue_unref(client_queue); osync_queue_unref(server_queue); + + g_mutex_free(callback_handler2_mutex); + g_cond_free(callback_handler2_cond); + callback_handler2_cond = NULL; + callback_handler2_mutex = NULL; destroy_testbed(testbed); } @@ -1967,6 +1994,9 @@ osync_assert(error == NULL); char *data = "this is another test string"; + + callback_handler2_cond = g_cond_new(); + callback_handler2_mutex = g_mutex_new(); pid_t cpid = fork(); if (cpid == 0) { //Child @@ -2053,6 +2083,19 @@ fail_unless(!osync_error_is_set(&error), NULL); osync_message_unref(message); + + /* Send and process one by one and wait for the call + * of the server callback. This avoids that the pipe + * break (e.g. disconnect call) happens to early. + * + * With the disconnect call the queues get flushed + * and the callback_handler2 function would get + * immeditally the error messages. Which is not expected + * or designed in this testcase. + * + * Fixes #1039 + */ + g_cond_wait(callback_handler2_cond, callback_handler2_mutex); } message = osync_queue_get_message(client_queue); @@ -2079,6 +2122,11 @@ osync_queue_unref(client_queue); osync_queue_unref(server_queue); + + g_mutex_free(callback_handler2_mutex); + g_cond_free(callback_handler2_cond); + callback_handler2_cond = NULL; + callback_handler2_mutex = NULL; destroy_testbed(testbed); } |
Author: ianmartin Date: Fri Mar 27 13:59:25 2009 New Revision: 5359 URL: http://www.opensync.org/changeset/5359 Log: Updating multisync tests to current API and config file format. Ticket #981 Added: trunk/tests/data/multisync_conflict_changetype_choose/configs/group/1/mock-sync.conf (props changed) - copied unchanged from r5349, trunk/tests/data/multisync_easy_new/configs/group/1/mock-sync.conf trunk/tests/data/multisync_conflict_changetype_choose/configs/group/2/mock-sync.conf (props changed) - copied unchanged from r5349, trunk/tests/data/multisync_easy_new/configs/group/2/mock-sync.conf trunk/tests/data/multisync_conflict_changetype_choose/configs/group/3/mock-sync.conf (props changed) - copied unchanged from r5349, trunk/tests/data/multisync_easy_new/configs/group/3/mock-sync.conf trunk/tests/data/multisync_conflict_data_choose/configs/group/1/mock-sync.conf (props changed) - copied unchanged from r5349, trunk/tests/data/multisync_easy_new/configs/group/1/mock-sync.conf trunk/tests/data/multisync_conflict_data_choose/configs/group/2/mock-sync.conf (props changed) - copied unchanged from r5349, trunk/tests/data/multisync_easy_new/configs/group/2/mock-sync.conf trunk/tests/data/multisync_conflict_data_choose/configs/group/3/mock-sync.conf (props changed) - copied unchanged from r5349, trunk/tests/data/multisync_easy_new/configs/group/3/mock-sync.conf trunk/tests/data/multisync_conflict_data_duplicate2/configs/group/1/mock-sync.conf (props changed) - copied unchanged from r5349, trunk/tests/data/multisync_easy_new/configs/group/1/mock-sync.conf trunk/tests/data/multisync_conflict_data_duplicate2/configs/group/2/mock-sync.conf (props changed) - copied unchanged from r5349, trunk/tests/data/multisync_easy_new/configs/group/2/mock-sync.conf trunk/tests/data/multisync_conflict_data_duplicate2/configs/group/3/mock-sync.conf (props changed) - copied unchanged from r5349, trunk/tests/data/multisync_easy_new/configs/group/3/mock-sync.conf Replaced: trunk/tests/data/multisync_conflict_changetype_choose/configs/group/1/syncmember.conf (props changed) - copied unchanged from r5349, trunk/tests/data/multisync_easy_new/configs/group/1/syncmember.conf trunk/tests/data/multisync_conflict_changetype_choose/configs/group/2/syncmember.conf (props changed) - copied unchanged from r5349, trunk/tests/data/multisync_easy_new/configs/group/2/syncmember.conf trunk/tests/data/multisync_conflict_changetype_choose/configs/group/3/syncmember.conf (props changed) - copied unchanged from r5349, trunk/tests/data/multisync_easy_new/configs/group/3/syncmember.conf trunk/tests/data/multisync_conflict_data_choose/configs/group/1/syncmember.conf (props changed) - copied unchanged from r5349, trunk/tests/data/multisync_easy_new/configs/group/1/syncmember.conf trunk/tests/data/multisync_conflict_data_choose/configs/group/2/syncmember.conf (props changed) - copied unchanged from r5349, trunk/tests/data/multisync_easy_new/configs/group/2/syncmember.conf trunk/tests/data/multisync_conflict_data_choose/configs/group/3/syncmember.conf (props changed) - copied unchanged from r5349, trunk/tests/data/multisync_easy_new/configs/group/3/syncmember.conf trunk/tests/data/multisync_conflict_data_duplicate2/configs/group/1/syncmember.conf (props changed) - copied unchanged from r5349, trunk/tests/data/multisync_easy_new/configs/group/1/syncmember.conf trunk/tests/data/multisync_conflict_data_duplicate2/configs/group/2/syncmember.conf (props changed) - copied unchanged from r5349, trunk/tests/data/multisync_easy_new/configs/group/2/syncmember.conf trunk/tests/data/multisync_conflict_data_duplicate2/configs/group/3/syncmember.conf (props changed) - copied unchanged from r5349, trunk/tests/data/multisync_easy_new/configs/group/3/syncmember.conf Deleted: trunk/tests/data/multisync_conflict_changetype_choose/configs/group/1/file-sync.conf trunk/tests/data/multisync_conflict_changetype_choose/configs/group/2/file-sync.conf trunk/tests/data/multisync_conflict_changetype_choose/configs/group/3/file-sync.conf trunk/tests/data/multisync_conflict_data_choose/configs/group/1/file-sync.conf trunk/tests/data/multisync_conflict_data_choose/configs/group/2/file-sync.conf trunk/tests/data/multisync_conflict_data_choose/configs/group/3/file-sync.conf trunk/tests/data/multisync_conflict_data_duplicate2/configs/group/1/file-sync.conf trunk/tests/data/multisync_conflict_data_duplicate2/configs/group/2/file-sync.conf trunk/tests/data/multisync_conflict_data_duplicate2/configs/group/3/file-sync.conf Modified: trunk/tests/CMakeLists.txt trunk/tests/sync-tests/check_multisync.c Modified: trunk/tests/CMakeLists.txt ============================================================================== --- trunk/tests/CMakeLists.txt Fri Mar 27 12:21:01 2009 (r5358) +++ trunk/tests/CMakeLists.txt Fri Mar 27 13:59:25 2009 (r5359) @@ -280,9 +280,22 @@ OSYNC_TESTCASE(module module_check) BUILD_CHECK_TEST( multisync sync-tests/check_multisync.c ${TEST_TARGET_LIBRARIES} ) -OSYNC_TESTCASE(multisync multisync_easy_new) -OSYNC_TESTCASE(multisync multisync_dual_new) -OSYNC_TESTCASE(multisync multisync_triple_new) +OSYNC_TESTCASE( multisync multisync_easy_new) +OSYNC_TESTCASE( multisync multisync_dual_new) +OSYNC_TESTCASE( multisync multisync_triple_new) +OSYNC_TESTCASE( multisync multisync_easy_mod) +OSYNC_TESTCASE( multisync multisync_dual_mod) +OSYNC_TESTCASE( multisync multisync_triple_mod) +OSYNC_TESTCASE( multisync multisync_easy_del) +OSYNC_TESTCASE( multisync multisync_dual_del) +OSYNC_TESTCASE( multisync multisync_triple_del) + +OSYNC_TESTCASE( multisync multisync_conflict_changetype_choose) +OSYNC_TESTCASE( multisync multisync_conflict_changetype_choose2) +OSYNC_TESTCASE( multisync multisync_conflict_hybrid_choose) +OSYNC_TESTCASE( multisync multisync_conflict_hybrid_choose2) +OSYNC_TESTCASE( multisync multisync_conflict_data_duplicate) +OSYNC_TESTCASE( multisync multisync_conflict_data_duplicate2) BUILD_CHECK_TEST( sync sync-tests/check_sync.c ${TEST_TARGET_LIBRARIES} ) OSYNC_TESTCASE( sync sync_setup_connect) Modified: trunk/tests/sync-tests/check_multisync.c ============================================================================== --- trunk/tests/sync-tests/check_multisync.c Fri Mar 27 12:21:01 2009 (r5358) +++ trunk/tests/sync-tests/check_multisync.c Fri Mar 27 13:59:25 2009 (r5359) @@ -380,61 +380,142 @@ /* FIXME: port testcases, see ticket #981 */ -#if 0 +OSyncEngine *setup_engine(const char *testbed) +{ + char *formatdir = g_strdup_printf("%s/formats", testbed); + char *plugindir = g_strdup_printf("%s/plugins", testbed); + OSyncError *error = NULL; + OSyncGroup *group = osync_group_new(&error); + fail_unless(group != NULL, NULL); + fail_unless(error == NULL, NULL); + + osync_group_set_schemadir(group, testbed); + fail_unless(osync_group_load(group, "configs/group", &error), NULL); + fail_unless(error == NULL, NULL); + + OSyncEngine *engine = osync_engine_new(group, &error); + fail_unless(engine != NULL, NULL); + fail_unless(error == NULL, NULL); + osync_group_unref(group); + + osync_engine_set_schemadir(engine, testbed); + osync_engine_set_plugindir(engine, plugindir); + osync_engine_set_formatdir(engine, formatdir); + g_free(formatdir); + g_free(plugindir); + + osync_engine_set_memberstatus_callback(engine, member_status, GINT_TO_POINTER(1)); + osync_engine_set_enginestatus_callback(engine, engine_status, GINT_TO_POINTER(1)); + osync_engine_set_changestatus_callback(engine, entry_status, GINT_TO_POINTER(1)); + osync_engine_set_mappingstatus_callback(engine, mapping_status, GINT_TO_POINTER(1)); + osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(1)); + + return engine; +} + +void hashtable_simple_load_and_check(const char *testbed, int group) +{ + char *path = g_strdup_printf("%s/configs/group/%d/hashtable.db", testbed, group); + OSyncHashTable *table = hashtable_load(path, "mockobjtype1", 1); + g_free(path); + check_hash(table, "testdata"); + osync_hashtable_unref(table); +} + +void hashtable_load_and_check(const char *testbed, int group, const char *uids[], uint num_uids) +{ + char *path = g_strdup_printf("%s/configs/group/%d/hashtable.db", testbed, group); + OSyncHashTable *table = hashtable_load(path, "mockobjtype1", num_uids); + g_free(path); + uint i; + for (i = 0; i < num_uids; i++) { + check_hash(table, uids[i]); + } + osync_hashtable_unref(table); +} + +void check_empty(const char *testbed) +{ + /* check the mapping table loads */ + char *path = g_strdup_printf("%s/configs/group/archive.db", testbed); + OSyncMappingTable *maptable = mappingtable_load(path, "mockobjtype1", 0); + g_free(path); + osync_mapping_table_close(maptable); + osync_mapping_table_unref(maptable); + + /* check the hash tables load */ + int group; + for (group = 1; group <= 3; group++) { + path = g_strdup_printf("%s/configs/group/%d/hashtable.db", testbed, group); + OSyncHashTable *table = hashtable_load(path, "mockobjtype1", 0); + g_free(path); + osync_hashtable_unref(table); + } + + /* make sure the data directories are empty */ + fail_unless(!system("test \"x$(ls data1)\" = \"x\""), NULL); + fail_unless(!system("test \"x$(ls data2)\" = \"x\""), NULL); + fail_unless(!system("test \"x$(ls data3)\" = \"x\""), NULL); +} + +void destroy_engine(OSyncEngine *engine) +{ + OSyncError *error = NULL; + fail_unless(osync_engine_finalize(engine, &error), NULL); + fail_unless(error == NULL, NULL); + osync_engine_unref(engine); +} + +/* Sync the single item testdata from data 1 to data2 and data3 + * then change testdata in data3 */ START_TEST (multisync_easy_mod) { char *testbed = setup_testbed("multisync_easy_new"); - OSyncEnv *osync = init_env(); - OSyncGroup *group = osync_group_load(osync, "configs/group", NULL); - fail_unless(group != NULL, NULL); - fail_unless(osync_env_num_groups(osync) == 1, NULL); + OSyncError *error = NULL; + OSyncEngine *engine = setup_engine(testbed); + fail_unless(osync_engine_initialize(engine, &error), NULL); + fail_unless(error == NULL, NULL); + mark_point(); - - OSyncEngine *engine = init_engine(group); - + synchronize_once(engine, NULL); fail_unless(osync_testing_diff("data1", "data2")); fail_unless(osync_testing_diff("data1", "data3")); - fail_unless(num_written == 2, NULL); - fail_unless(num_read == 1, NULL); + fail_unless(num_change_written == 2, NULL); + fail_unless(num_change_read == 1, NULL); fail_unless(num_engine_end_conflicts = 1, NULL); sleep(2); system("cp newdata data3/testdata"); synchronize_once(engine, NULL); - osengine_finalize(engine); - osengine_free(engine); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); + destroy_engine(engine); + + fail_unless(osync_testing_diff("data1", "data2")); + fail_unless(osync_testing_diff("data1", "data3")); fail_unless(num_engine_connected == 1, NULL); fail_unless(num_engine_read == 1, NULL); - fail_unless(num_engine_wrote == 1, NULL); + fail_unless(num_engine_written == 1, NULL); fail_unless(num_engine_disconnected == 1, NULL); - fail_unless(num_written == 2, NULL); - fail_unless(num_read == 1, NULL); - - OSyncMappingTable *maptable = mappingtable_load(group, 1, 0); - check_mapping(maptable, 1, 0, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 2, 0, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 3, 0, 3, "testdata", "mockformat", "data"); - mappingtable_close(maptable); - - OSyncHashTable *table = hashtable_load(group, 1, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); - - table = hashtable_load(group, 2, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); - - table = hashtable_load(group, 3, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); + fail_unless(num_change_written == 2, NULL); + fail_unless(num_change_read == 1, NULL); + fail_unless(num_change_error == 0, NULL); + + char *path = g_strdup_printf("%s/configs/group/archive.db", testbed); + OSyncMappingTable *maptable = mappingtable_load(path, "mockobjtype1", 1); + g_free(path); + check_mapping(maptable, 1, 1, 3, "testdata"); + check_mapping(maptable, 2, 1, 3, "testdata"); + check_mapping(maptable, 3, 1, 3, "testdata"); + osync_mapping_table_close(maptable); + osync_mapping_table_unref(maptable); + + hashtable_simple_load_and_check(testbed, 1); + hashtable_simple_load_and_check(testbed, 2); + hashtable_simple_load_and_check(testbed, 3); destroy_testbed(testbed); } @@ -443,25 +524,24 @@ START_TEST (multisync_dual_mod) { char *testbed = setup_testbed("multisync_easy_new"); - OSyncEnv *osync = init_env(); - OSyncGroup *group = osync_group_load(osync, "configs/group", NULL); - fail_unless(group != NULL, NULL); - fail_unless(osync_env_num_groups(osync) == 1, NULL); + OSyncError *error = NULL; + OSyncEngine *engine = setup_engine(testbed); + fail_unless(osync_engine_initialize(engine, &error), NULL); + fail_unless(error == NULL, NULL); + mark_point(); - - OSyncEngine *engine = init_engine(group); - + synchronize_once(engine, NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); + fail_unless(osync_testing_diff("data1", "data2")); + fail_unless(osync_testing_diff("data1", "data3")); fail_unless(num_engine_connected == 1, NULL); fail_unless(num_engine_read == 1, NULL); - fail_unless(num_engine_wrote == 1, NULL); + fail_unless(num_engine_written == 1, NULL); fail_unless(num_engine_disconnected == 1, NULL); - fail_unless(num_written == 2, NULL); - fail_unless(num_read == 1, NULL); + fail_unless(num_change_written == 2, NULL); + fail_unless(num_change_read == 1, NULL); fail_unless(num_engine_end_conflicts == 1, NULL); sleep(2); @@ -469,65 +549,61 @@ system("cp newdata data3/testdata"); synchronize_once(engine, NULL); - osengine_finalize(engine); - osengine_free(engine); + + destroy_engine(engine); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); + fail_unless(osync_testing_diff("data1", "data2")); + fail_unless(osync_testing_diff("data1", "data3")); fail_unless(num_engine_connected == 1, NULL); fail_unless(num_engine_read == 1, NULL); - fail_unless(num_engine_wrote == 1, NULL); + fail_unless(num_engine_written == 1, NULL); fail_unless(num_engine_disconnected == 1, NULL); - fail_unless(num_written == 1, NULL); - fail_unless(num_read == 2, NULL); + fail_unless(num_change_written == 1, NULL); + fail_unless(num_change_read == 2, NULL); fail_unless(num_engine_end_conflicts == 1, NULL); - - OSyncMappingTable *maptable = mappingtable_load(group, 1, 0); - check_mapping(maptable, 1, 0, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 2, 0, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 3, 0, 3, "testdata", "mockformat", "data"); - mappingtable_close(maptable); - - OSyncHashTable *table = hashtable_load(group, 1, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); - - table = hashtable_load(group, 2, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); - - table = hashtable_load(group, 3, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); + + char *path = g_strdup_printf("%s/configs/group/archive.db", testbed); + OSyncMappingTable *maptable = mappingtable_load(path, "mockobjtype1", 1); + g_free(path); + check_mapping(maptable, 1, 1, 3, "testdata"); + check_mapping(maptable, 2, 1, 3, "testdata"); + check_mapping(maptable, 3, 1, 3, "testdata"); + osync_mapping_table_close(maptable); + osync_mapping_table_unref(maptable); + + hashtable_simple_load_and_check(testbed, 1); + hashtable_simple_load_and_check(testbed, 2); + hashtable_simple_load_and_check(testbed, 3); destroy_testbed(testbed); } END_TEST + + + START_TEST (multisync_triple_mod) { char *testbed = setup_testbed("multisync_easy_new"); - OSyncEnv *osync = init_env(); - OSyncGroup *group = osync_group_load(osync, "configs/group", NULL); - fail_unless(group != NULL, NULL); - fail_unless(osync_env_num_groups(osync) == 1, NULL); + OSyncError *error = NULL; + OSyncEngine *engine = setup_engine(testbed); + fail_unless(osync_engine_initialize(engine, &error), NULL); + fail_unless(error == NULL, NULL); + mark_point(); - - OSyncEngine *engine = init_engine(group); - + synchronize_once(engine, NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); - + fail_unless(osync_testing_diff("data1", "data2")); + fail_unless(osync_testing_diff("data1", "data3")); fail_unless(num_engine_connected == 1, NULL); fail_unless(num_engine_read == 1, NULL); - fail_unless(num_engine_wrote == 1, NULL); + fail_unless(num_engine_written == 1, NULL); fail_unless(num_engine_disconnected == 1, NULL); - fail_unless(num_written == 2, NULL); - fail_unless(num_read == 1, NULL); + fail_unless(num_change_written == 2, NULL); + fail_unless(num_change_read == 1, NULL); fail_unless(num_engine_end_conflicts == 1, NULL); sleep(2); @@ -536,32 +612,27 @@ system("cp newdata data3/testdata"); synchronize_once(engine, NULL); - osengine_finalize(engine); + destroy_engine(engine); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); + fail_unless(osync_testing_diff("data1", "data2")); + fail_unless(osync_testing_diff("data1", "data3")); - fail_unless(num_written == 0, NULL); - fail_unless(num_read == 3, NULL); + fail_unless(num_change_written == 0, NULL); + fail_unless(num_change_read == 3, NULL); fail_unless(num_engine_end_conflicts = 1, NULL); - OSyncMappingTable *maptable = mappingtable_load(group, 1, 0); - check_mapping(maptable, 1, 0, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 2, 0, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 3, 0, 3, "testdata", "mockformat", "data"); - mappingtable_close(maptable); - - OSyncHashTable *table = hashtable_load(group, 1, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); - - table = hashtable_load(group, 2, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); - - table = hashtable_load(group, 3, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); + char *path = g_strdup_printf("%s/configs/group/archive.db", testbed); + OSyncMappingTable *maptable = mappingtable_load(path, "mockobjtype1", 1); + g_free(path); + check_mapping(maptable, 1, 1, 3, "testdata"); + check_mapping(maptable, 2, 1, 3, "testdata"); + check_mapping(maptable, 3, 1, 3, "testdata"); + osync_mapping_table_close(maptable); + osync_mapping_table_unref(maptable); + + hashtable_simple_load_and_check(testbed, 1); + hashtable_simple_load_and_check(testbed, 2); + hashtable_simple_load_and_check(testbed, 3); destroy_testbed(testbed); } @@ -569,46 +640,32 @@ START_TEST (multisync_easy_del) { - char *testbed = setup_testbed("multisync_conflict_changetype_choose"); - OSyncEnv *osync = init_env(); - OSyncGroup *group = osync_group_load(osync, "configs/group", NULL); - - OSyncEngine *engine = init_engine(group); - osengine_set_conflict_callback(engine, conflict_handler_duplication, NULL); + char *testbed = setup_testbed("multisync_easy_new"); + OSyncError *error = NULL; + OSyncEngine *engine = setup_engine(testbed); + fail_unless(osync_engine_initialize(engine, &error), NULL); + fail_unless(error == NULL, NULL); synchronize_once(engine, NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); + fail_unless(osync_testing_diff("data1", "data2")); + fail_unless(osync_testing_diff("data1", "data3")); system("rm -f data2/testdata"); synchronize_once(engine, NULL); - osengine_finalize(engine); + destroy_engine(engine); fail_unless(num_engine_connected == 1, NULL); fail_unless(num_engine_read == 1, NULL); - fail_unless(num_engine_wrote == 1, NULL); + fail_unless(num_engine_written == 1, NULL); fail_unless(num_engine_disconnected == 1, NULL); - fail_unless(num_read == 1, NULL); - fail_unless(num_conflicts == 0, NULL); - fail_unless(num_written == 2, NULL); - - OSyncMappingTable *maptable = mappingtable_load(group, 0, 0); - mappingtable_close(maptable); - - OSyncHashTable *table = hashtable_load(group, 1, 0); - osync_hashtable_close(table); - - table = hashtable_load(group, 2, 0); - osync_hashtable_close(table); - - table = hashtable_load(group, 3, 0); - osync_hashtable_close(table); + fail_unless(num_change_read == 1, NULL); + fail_unless(num_engine_end_conflicts == 1, NULL); + fail_unless(num_mapping_conflicts == 0, NULL); + fail_unless(num_change_written == 2, NULL); - fail_unless(!system("test \"x$(ls data1)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data3)\" = \"x\""), NULL); + check_empty(testbed); destroy_testbed(testbed); } @@ -616,336 +673,280 @@ START_TEST (multisync_dual_del) { - char *testbed = setup_testbed("multisync_conflict_changetype_choose"); - OSyncEnv *osync = init_env(); - OSyncGroup *group = osync_group_load(osync, "configs/group", NULL); - - OSyncEngine *engine = init_engine(group); - osengine_set_conflict_callback(engine, conflict_handler_duplication, NULL); + char *testbed = setup_testbed("multisync_easy_new"); + OSyncError *error = NULL; + OSyncEngine *engine = setup_engine(testbed); + fail_unless(osync_engine_initialize(engine, &error), NULL); + fail_unless(error == NULL, NULL); synchronize_once(engine, NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); - + fail_unless(osync_testing_diff("data1", "data2")); + fail_unless(osync_testing_diff("data1", "data3")); + system("rm -f data1/testdata"); system("rm -f data3/testdata"); synchronize_once(engine, NULL); - osengine_finalize(engine); + fail_unless(osync_engine_finalize(engine, &error), NULL); + fail_unless(error == NULL, NULL); + + osync_engine_unref(engine); fail_unless(num_engine_connected == 1, NULL); fail_unless(num_engine_read == 1, NULL); - fail_unless(num_engine_wrote == 1, NULL); + fail_unless(num_engine_written == 1, NULL); fail_unless(num_engine_disconnected == 1, NULL); - fail_unless(num_read == 2, NULL); - fail_unless(num_conflicts == 0, NULL); - fail_unless(num_written == 1, NULL); - - OSyncMappingTable *maptable = mappingtable_load(group, 0, 0); - mappingtable_close(maptable); + fail_unless(num_change_read == 2, NULL); + fail_unless(num_mapping_conflicts == 0, NULL); + fail_unless(num_change_written == 1, NULL); - OSyncHashTable *table = hashtable_load(group, 1, 0); - osync_hashtable_close(table); - - table = hashtable_load(group, 2, 0); - osync_hashtable_close(table); - - table = hashtable_load(group, 3, 0); - osync_hashtable_close(table); - - fail_unless(!system("test \"x$(ls data1)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data3)\" = \"x\""), NULL); + check_empty(testbed); destroy_testbed(testbed); } END_TEST +/* Sync testdata from data1 to data2 and data3. + * Then remove all testdata, should sync with 3 changes read + * and no changes written */ START_TEST (multisync_triple_del) { - char *testbed = setup_testbed("multisync_conflict_changetype_choose"); - OSyncEnv *osync = init_env(); - OSyncGroup *group = osync_group_load(osync, "configs/group", NULL); - - OSyncEngine *engine = init_engine(group); - osengine_set_conflict_callback(engine, conflict_handler_duplication, NULL); + char *testbed = setup_testbed("multisync_easy_new"); + OSyncError *error = NULL; + OSyncEngine *engine = setup_engine(testbed); + fail_unless(osync_engine_initialize(engine, &error), NULL); + fail_unless(error == NULL, NULL); synchronize_once(engine, NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); - + fail_unless(osync_testing_diff("data1", "data2")); + fail_unless(osync_testing_diff("data1", "data3")); + system("rm -f data1/testdata"); system("rm -f data2/testdata"); system("rm -f data3/testdata"); synchronize_once(engine, NULL); - osengine_finalize(engine); + fail_unless(osync_engine_finalize(engine, &error), NULL); + fail_unless(error == NULL, NULL); + + osync_engine_unref(engine); fail_unless(num_engine_connected == 1, NULL); fail_unless(num_engine_read == 1, NULL); - fail_unless(num_engine_wrote == 1, NULL); + fail_unless(num_engine_written == 1, NULL); fail_unless(num_engine_disconnected == 1, NULL); - fail_unless(num_read == 3, NULL); - fail_unless(num_conflicts == 0, NULL); - fail_unless(num_written == 0, NULL); - - OSyncMappingTable *maptable = mappingtable_load(group, 0, 0); - mappingtable_close(maptable); - - OSyncHashTable *table = hashtable_load(group, 1, 0); - osync_hashtable_close(table); + fail_unless(num_change_read == 3, NULL); + fail_unless(num_mapping_conflicts == 0, NULL); + fail_unless(num_change_written == 0, NULL); - table = hashtable_load(group, 2, 0); - osync_hashtable_close(table); - - table = hashtable_load(group, 3, 0); - osync_hashtable_close(table); - - fail_unless(!system("test \"x$(ls data1)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data3)\" = \"x\""), NULL); + check_empty(testbed); destroy_testbed(testbed); } END_TEST + +/* testdata in data1 and data2 are different */ START_TEST (multisync_conflict_data_choose) { char *testbed = setup_testbed("multisync_conflict_data_choose"); - OSyncEnv *osync = init_env(); - OSyncGroup *group = osync_group_load(osync, "configs/group", NULL); - fail_unless(group != NULL, NULL); - fail_unless(osync_env_num_groups(osync) == 1, NULL); + OSyncError *error = NULL; + OSyncEngine *engine = setup_engine(testbed); + osync_engine_set_conflict_callback(engine, conflict_handler_choose_first, GINT_TO_POINTER(2)); + + fail_unless(osync_engine_initialize(engine, &error), NULL); + fail_unless(error == NULL, NULL); + mark_point(); - - OSyncEngine *engine = init_engine(group); - osengine_set_conflict_callback(engine, conflict_handler_choose_first, GINT_TO_POINTER(2)); synchronize_once(engine, NULL); fail_unless(num_engine_connected == 1, NULL); fail_unless(num_engine_read == 1, NULL); - fail_unless(num_engine_wrote == 1, NULL); + fail_unless(num_engine_written == 1, NULL); fail_unless(num_engine_disconnected == 1, NULL); - fail_unless(num_written == 2, NULL); - fail_unless(num_read == 2, NULL); - fail_unless(num_conflicts == 1, NULL); + fail_unless(num_change_written == 1, NULL); + fail_unless(num_change_read == 2, NULL); + fail_unless(num_mapping_conflicts == 1, NULL); fail_unless(num_engine_end_conflicts == 1, NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); - - OSyncMappingTable *maptable = mappingtable_load(group, 1, 0); - check_mapping(maptable, 1, 0, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 2, 0, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 3, 0, 3, "testdata", "mockformat", "data"); - mappingtable_close(maptable); - - OSyncHashTable *table = hashtable_load(group, 1, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); + fail_unless(osync_testing_diff("data1", "data2")); + fail_unless(osync_testing_diff("data1", "data3")); - table = hashtable_load(group, 2, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); - - table = hashtable_load(group, 3, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); + char *path = g_strdup_printf("%s/configs/group/archive.db", testbed); + OSyncMappingTable *maptable = mappingtable_load(path, "mockobjtype1", 1); + g_free(path); + check_mapping(maptable, 1, 1, 3, "testdata"); + check_mapping(maptable, 2, 1, 3, "testdata"); + check_mapping(maptable, 3, 1, 3, "testdata"); + osync_mapping_table_close(maptable); + osync_mapping_table_unref(maptable); + + hashtable_simple_load_and_check(testbed, 1); + hashtable_simple_load_and_check(testbed, 2); + hashtable_simple_load_and_check(testbed, 3); system("rm -f data3/testdata"); mark_point(); - num_conflicts = 0; + synchronize_once(engine, NULL); - osengine_finalize(engine); - - mappingtable_load(group, 0, 0); - mappingtable_close(maptable); - - hashtable_load(group, 1, 0); - osync_hashtable_close(table); - - table = hashtable_load(group, 2, 0); - osync_hashtable_close(table); - - table = hashtable_load(group, 3, 0); - osync_hashtable_close(table); + + destroy_engine(engine); - fail_unless(!system("test \"x$(ls data1)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data3)\" = \"x\""), NULL); + check_empty(testbed); destroy_testbed(testbed); } END_TEST + +/* testdata in data 1 and data3 are the same. data2 is different */ START_TEST (multisync_conflict_data_choose2) { char *testbed = setup_testbed("multisync_conflict_data_choose2"); - OSyncEnv *osync = init_env(); - OSyncGroup *group = osync_group_load(osync, "configs/group", NULL); - fail_unless(group != NULL, NULL); - fail_unless(osync_env_num_groups(osync) == 1, NULL); + OSyncError *error = NULL; + OSyncEngine *engine = setup_engine(testbed); + osync_engine_set_conflict_callback(engine, conflict_handler_choose_first, GINT_TO_POINTER(3)); + + fail_unless(osync_engine_initialize(engine, &error), NULL); + fail_unless(error == NULL, NULL); + mark_point(); - - OSyncEngine *engine = init_engine(group); - osengine_set_conflict_callback(engine, conflict_handler_choose_first, GINT_TO_POINTER(3)); synchronize_once(engine, NULL); fail_unless(num_engine_connected == 1, NULL); fail_unless(num_engine_read == 1, NULL); - fail_unless(num_engine_wrote == 1, NULL); + fail_unless(num_engine_written == 1, NULL); fail_unless(num_engine_disconnected == 1, NULL); - fail_unless(num_read == 3, NULL); - fail_unless(num_conflicts == 1, NULL); + fail_unless(num_change_read == 3, NULL); + fail_unless(num_change_written == 1, "Num change written = '%u' not 1 or I have it wrong...\n", num_change_written); + fail_unless(num_mapping_conflicts == 1, NULL); fail_unless(num_engine_end_conflicts == 1, NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); - - OSyncMappingTable *maptable = mappingtable_load(group, 1, 0); - check_mapping(maptable, 1, 0, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 2, 0, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 3, 0, 3, "testdata", "mockformat", "data"); - mappingtable_close(maptable); - - OSyncHashTable *table = hashtable_load(group, 1, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); - - table = hashtable_load(group, 2, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); + fail_unless(osync_testing_diff("data1", "data2")); + fail_unless(osync_testing_diff("data1", "data3")); - table = hashtable_load(group, 3, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); + char *path = g_strdup_printf("%s/configs/group/archive.db", testbed); + OSyncMappingTable *maptable = mappingtable_load(path, "mockobjtype1", 1); + g_free(path); + check_mapping(maptable, 1, 1, 3, "testdata"); + check_mapping(maptable, 2, 1, 3, "testdata"); + check_mapping(maptable, 3, 1, 3, "testdata"); + osync_mapping_table_close(maptable); + osync_mapping_table_unref(maptable); + + hashtable_simple_load_and_check(testbed, 1); + hashtable_simple_load_and_check(testbed, 2); + hashtable_simple_load_and_check(testbed, 3); system("rm -f data3/testdata"); mark_point(); - num_conflicts = 0; - synchronize_once(engine, NULL);; - osengine_finalize(engine); - - mappingtable_load(group, 0, 0); - mappingtable_close(maptable); - - hashtable_load(group, 1, 0); - osync_hashtable_close(table); - - table = hashtable_load(group, 2, 0); - osync_hashtable_close(table); - - table = hashtable_load(group, 3, 0); - osync_hashtable_close(table); + + synchronize_once(engine, NULL); + + fail_unless(osync_engine_finalize(engine, &error), NULL); + fail_unless(error == NULL, NULL); + osync_engine_unref(engine); - fail_unless(!system("test \"x$(ls data1)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data3)\" = \"x\""), NULL); + check_empty(testbed); destroy_testbed(testbed); } END_TEST + +/* Sync data1/testdata to all + * remove data1/testdata and modify data3/testdata + * using choose_modified conflict handler so data3 should end up eveywhere + */ START_TEST (multisync_conflict_changetype_choose) { char *testbed = setup_testbed("multisync_conflict_changetype_choose"); - OSyncEnv *osync = init_env(); - OSyncGroup *group = osync_group_load(osync, "configs/group", NULL); - - OSyncEngine *engine = init_engine(group); - osengine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - - synchronize_once(engine, NULL); + OSyncError *error = NULL; + OSyncEngine *engine = setup_engine(testbed); + osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(2)); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); + fail_unless(osync_engine_initialize(engine, &error), NULL); + fail_unless(error == NULL, NULL); + + mark_point(); + + synchronize_once(engine, NULL); + + fail_unless(osync_testing_diff("data1", "data2")); + fail_unless(osync_testing_diff("data1", "data3")); sleep(2); system("rm -f data1/testdata"); system("cp newdata data3/testdata"); - num_written = 0; - num_read = 0; - num_conflicts = 0; synchronize_once(engine, NULL); fail_unless(num_engine_connected == 1, NULL); fail_unless(num_engine_read == 1, NULL); - fail_unless(num_engine_wrote == 1, NULL); + fail_unless(num_engine_written == 1, NULL); fail_unless(num_engine_disconnected == 1, NULL); - fail_unless(num_read == 2, NULL); - fail_unless(num_conflicts == 1, NULL); - fail_unless(num_written == 2, NULL); + fail_unless(num_change_read == 2, NULL); + fail_unless(num_mapping_conflicts == 1, NULL); + fail_unless(num_change_written == 2, NULL); fail_unless(num_engine_end_conflicts == 1, NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); - - OSyncMappingTable *maptable = mappingtable_load(group, 1, 0); - check_mapping(maptable, 1, 0, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 2, 0, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 3, 0, 3, "testdata", "mockformat", "data"); - mappingtable_close(maptable); - - OSyncHashTable *table = hashtable_load(group, 1, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); - - table = hashtable_load(group, 2, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); - - table = hashtable_load(group, 3, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); - - system("rm -f data1/testdata"); - - mark_point(); - num_conflicts = 0; - synchronize_once(engine, NULL); - osengine_finalize(engine); - - mappingtable_load(group, 0, 0); - mappingtable_close(maptable); - - hashtable_load(group, 1, 0); - osync_hashtable_close(table); + fail_unless(osync_testing_diff("data1", "data2")); + fail_unless(osync_testing_diff("data1", "data3")); - table = hashtable_load(group, 2, 0); - osync_hashtable_close(table); + char *path = g_strdup_printf("%s/configs/group/archive.db", testbed); + OSyncMappingTable *maptable = mappingtable_load(path, "mockobjtype1", 1); + g_free(path); + check_mapping(maptable, 1, 1, 3, "testdata"); + check_mapping(maptable, 2, 1, 3, "testdata"); + check_mapping(maptable, 3, 1, 3, "testdata"); + osync_mapping_table_close(maptable); + osync_mapping_table_unref(maptable); + + hashtable_simple_load_and_check(testbed, 1); + hashtable_simple_load_and_check(testbed, 2); + hashtable_simple_load_and_check(testbed, 3); - table = hashtable_load(group, 3, 0); - osync_hashtable_close(table); + system("rm -f data1/testdata"); - fail_unless(!system("test \"x$(ls data1)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data3)\" = \"x\""), NULL); + mark_point(); + + synchronize_once(engine, NULL); + + fail_unless(osync_engine_finalize(engine, &error), NULL); + fail_unless(error == NULL, NULL); + osync_engine_unref(engine); + + check_empty(testbed); destroy_testbed(testbed); } END_TEST + +/* As above but use conflict_handler_choose_first so all data should be deleted */ START_TEST (multisync_conflict_changetype_choose2) { char *testbed = setup_testbed("multisync_conflict_changetype_choose"); - OSyncEnv *osync = init_env(); - OSyncGroup *group = osync_group_load(osync, "configs/group", NULL); - - OSyncEngine *engine = init_engine(group); - osengine_set_conflict_callback(engine, conflict_handler_choose_deleted, GINT_TO_POINTER(3)); - + OSyncError *error = NULL; + OSyncEngine *engine = setup_engine(testbed); + osync_engine_set_conflict_callback(engine, conflict_handler_choose_first, GINT_TO_POINTER(2)); + + fail_unless(osync_engine_initialize(engine, &error), NULL); + fail_unless(error == NULL, NULL); + + mark_point(); + synchronize_once(engine, NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); + fail_unless(osync_testing_diff("data1", "data2")); + fail_unless(osync_testing_diff("data1", "data3")); sleep(2); @@ -953,49 +954,46 @@ system("cp newdata data3/testdata"); synchronize_once(engine, NULL); - osengine_finalize(engine); + + destroy_engine(engine); fail_unless(num_engine_connected == 1, NULL); fail_unless(num_engine_read == 1, NULL); - fail_unless(num_engine_wrote == 1, NULL); + fail_unless(num_engine_written == 1, NULL); fail_unless(num_engine_disconnected == 1, NULL); - fail_unless(num_read == 2, NULL); - fail_unless(num_conflicts == 1, NULL); - fail_unless(num_written == 2, NULL); - - OSyncMappingTable *maptable = mappingtable_load(group, 0, 0); - mappingtable_close(maptable); - - OSyncHashTable *table = hashtable_load(group, 1, 0); - osync_hashtable_close(table); - - table = hashtable_load(group, 2, 0); - osync_hashtable_close(table); - - table = hashtable_load(group, 3, 0); - osync_hashtable_close(table); + fail_unless(num_change_read == 2, NULL); + fail_unless(num_mapping_conflicts == 1, NULL); + fail_unless(num_change_written == 2, NULL); - fail_unless(!system("test \"x$(ls data1)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data3)\" = \"x\""), NULL); + check_empty(testbed); destroy_testbed(testbed); } END_TEST +/* Sync from data1/testdata to all + * remove data1 and change data2 to newdata2 and data3 to newdata + * conflict_handler_choose_modified picks the first modified so should get newdata2 + * everywhere. + */ START_TEST (multisync_conflict_hybrid_choose) { char *testbed = setup_testbed("multisync_conflict_changetype_choose"); - OSyncEnv *osync = init_env(); - OSyncGroup *group = osync_group_load(osync, "configs/group", NULL); - - OSyncEngine *engine = init_engine(group); - osengine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - + OSyncError *error = NULL; + OSyncEngine *engine = setup_engine(testbed); + osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); + + fail_unless(osync_engine_initialize(engine, &error), NULL); + fail_unless(error == NULL, NULL); + + mark_point(); + synchronize_once(engine, NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); + fail_unless(osync_testing_diff("data1", "data2")); + fail_unless(osync_testing_diff("data1", "data3")); + + sleep(2); sleep(2); @@ -1007,73 +1005,62 @@ fail_unless(num_engine_connected == 1, NULL); fail_unless(num_engine_read == 1, NULL); - fail_unless(num_engine_wrote == 1, NULL); + fail_unless(num_engine_written == 1, NULL); fail_unless(num_engine_disconnected == 1, NULL); - fail_unless(num_read == 3, NULL); - fail_unless(num_conflicts == 1, NULL); - fail_unless(num_written == 2, NULL); + fail_unless(num_change_read == 3, NULL); + fail_unless(num_mapping_conflicts == 1, NULL); + fail_unless(num_change_written == 2, NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); - - OSyncMappingTable *maptable = mappingtable_load(group, 1, 0); - check_mapping(maptable, 1, 0, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 2, 0, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 3, 0, 3, "testdata", "mockformat", "data"); - mappingtable_close(maptable); - - OSyncHashTable *table = hashtable_load(group, 1, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); - - table = hashtable_load(group, 2, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); + fail_unless(osync_testing_diff("data1", "data2")); + fail_unless(osync_testing_diff("data1", "data3")); + fail_unless(!system("test \"x$(diff newdata2 data2/testdata)\" = \"x\""), NULL); - table = hashtable_load(group, 3, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); + char *path = g_strdup_printf("%s/configs/group/archive.db", testbed); + OSyncMappingTable *maptable = mappingtable_load(path, "mockobjtype1", 1); + g_free(path); + check_mapping(maptable, 1, 1, 3, "testdata"); + check_mapping(maptable, 2, 1, 3, "testdata"); + check_mapping(maptable, 3, 1, 3, "testdata"); + osync_mapping_table_close(maptable); + osync_mapping_table_unref(maptable); + + hashtable_simple_load_and_check(testbed, 1); + hashtable_simple_load_and_check(testbed, 2); + hashtable_simple_load_and_check(testbed, 3); system("rm -f data1/testdata"); mark_point(); - num_conflicts = 0; + synchronize_once(engine, NULL); - osengine_finalize(engine); + destroy_engine(engine); - mappingtable_load(group, 0, 0); - mappingtable_close(maptable); - - hashtable_load(group, 1, 0); - osync_hashtable_close(table); - - table = hashtable_load(group, 2, 0); - osync_hashtable_close(table); - - table = hashtable_load(group, 3, 0); - osync_hashtable_close(table); - - fail_unless(!system("test \"x$(ls data1)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data3)\" = \"x\""), NULL); + check_empty(testbed); destroy_testbed(testbed); } END_TEST +/* Sync data1/testdata to all + * Remove data1/testdata and change the other 2 + * deleted conflict handler should delete all + */ START_TEST (multisync_conflict_hybrid_choose2) { char *testbed = setup_testbed("multisync_conflict_changetype_choose"); - OSyncEnv *osync = init_env(); - OSyncGroup *group = osync_group_load(osync, "configs/group", NULL); - - OSyncEngine *engine = init_engine(group); - osengine_set_conflict_callback(engine, conflict_handler_choose_deleted, GINT_TO_POINTER(3)); - + OSyncError *error = NULL; + OSyncEngine *engine = setup_engine(testbed); + osync_engine_set_conflict_callback(engine, conflict_handler_choose_deleted, GINT_TO_POINTER(3)); + + fail_unless(osync_engine_initialize(engine, &error), NULL); + fail_unless(error == NULL, NULL); + + mark_point(); + synchronize_once(engine, NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); + fail_unless(osync_testing_diff("data1", "data2")); + fail_unless(osync_testing_diff("data1", "data3")); sleep(2); @@ -1082,237 +1069,194 @@ system("cp newdata2 data2/testdata"); synchronize_once(engine, NULL); + destroy_engine(engine); fail_unless(num_engine_connected == 1, NULL); fail_unless(num_engine_read == 1, NULL); - fail_unless(num_engine_wrote == 1, NULL); + fail_unless(num_engine_written == 1, NULL); fail_unless(num_engine_disconnected == 1, NULL); - fail_unless(num_read == 3, NULL); - fail_unless(num_conflicts == 1, NULL); - fail_unless(num_written == 2, NULL); + fail_unless(num_change_read == 3, NULL); + fail_unless(num_mapping_conflicts == 1, NULL); + fail_unless(num_change_written == 2, NULL); - OSyncMappingTable *maptable = mappingtable_load(group, 0, 0); - mappingtable_close(maptable); - - OSyncHashTable *table = hashtable_load(group, 1, 0); - osync_hashtable_close(table); - - table = hashtable_load(group, 2, 0); - osync_hashtable_close(table); - - table = hashtable_load(group, 3, 0); - osync_hashtable_close(table); - - fail_unless(!system("test \"x$(ls data1)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data3)\" = \"x\""), NULL); + check_empty(testbed); destroy_testbed(testbed); } END_TEST +/* data1 and data2 are different + * using duplicate so should end up with 2 entries in all 3 places + * 5 writes are expected as data2/testdata gets moved to data2/testdata-dupe + */ START_TEST (multisync_conflict_data_duplicate) { char *testbed = setup_testbed("multisync_conflict_data_choose"); - OSyncEnv *osync = init_env(); - OSyncGroup *group = osync_group_load(osync, "configs/group", NULL); - fail_unless(group != NULL, NULL); - fail_unless(osync_env_num_groups(osync) == 1, NULL); + OSyncError *error = NULL; + OSyncEngine *engine = setup_engine(testbed); + osync_engine_set_conflict_callback(engine, conflict_handler_duplicate, GINT_TO_POINTER(2)); + + fail_unless(osync_engine_initialize(engine, &error), NULL); + fail_unless(error == NULL, NULL); + mark_point(); - - OSyncEngine *engine = init_engine(group); - osengine_set_conflict_callback(engine, conflict_handler_duplication, GINT_TO_POINTER(2)); synchronize_once(engine, NULL); + fail_unless(osync_testing_diff("data1", "data2")); + fail_unless(osync_testing_diff("data1", "data3")); + fail_unless(num_engine_connected == 1, NULL); fail_unless(num_engine_read == 1, NULL); - fail_unless(num_engine_wrote == 1, NULL); + fail_unless(num_engine_written == 1, NULL); fail_unless(num_engine_disconnected == 1, NULL); - fail_unless(num_read == 2, NULL); - fail_unless(num_conflicts == 1, NULL); - fail_unless(num_written == 5, NULL); + fail_unless(num_change_read == 2, NULL); + fail_unless(num_mapping_conflicts == 1, NULL); + fail_unless(num_change_written == 5, NULL); + + char *path = g_strdup_printf("%s/configs/group/archive.db", testbed); + OSyncMappingTable *maptable = mappingtable_load(path, "mockobjtype1", 2); + g_free(path); + check_mapping(maptable, 1, -1, 3, "testdata"); + check_mapping(maptable, 2, -1, 3, "testdata"); + check_mapping(maptable, 3, -1, 3, "testdata"); + check_mapping(maptable, 1, -1, 3, "testdata-dupe"); + check_mapping(maptable, 2, -1, 3, "testdata-dupe"); + check_mapping(maptable, 3, -1, 3, "testdata-dupe"); + osync_mapping_table_close(maptable); + osync_mapping_table_unref(maptable); + + unsigned int num_uids = 2; + const char *uids[] = {"testdata", "testdata-dupe"}; + hashtable_load_and_check(testbed, 1, uids, num_uids); + hashtable_load_and_check(testbed, 2, uids, num_uids); + hashtable_load_and_check(testbed, 3, uids, num_uids); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); - - OSyncMappingTable *maptable = mappingtable_load(group, 2, 0); - check_mapping(maptable, 1, -1, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 2, -1, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 3, -1, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 1, -1, 3, "testdata-dupe", "mockformat", "data"); - check_mapping(maptable, 2, -1, 3, "testdata-dupe", "mockformat", "data"); - check_mapping(maptable, 3, -1, 3, "testdata-dupe", "mockformat", "data"); - mappingtable_close(maptable); - - OSyncHashTable *table = hashtable_load(group, 1, 2); - check_hash(table, "testdata"); - check_hash(table, "testdata-dupe"); - osync_hashtable_close(table); - - table = hashtable_load(group, 2, 2); - check_hash(table, "testdata"); - check_hash(table, "testdata-dupe"); - osync_hashtable_close(table); - - table = hashtable_load(group, 3, 2); - check_hash(table, "testdata"); - check_hash(table, "testdata-dupe"); - osync_hashtable_close(table); system("rm -f data3/testdata"); synchronize_once(engine, NULL); - maptable = mappingtable_load(group, 1, 0); - check_mapping(maptable, 1, 0, 3, "testdata-dupe", "mockformat", "data"); - check_mapping(maptable, 2, 0, 3, "testdata-dupe", "mockformat", "data"); - check_mapping(maptable, 3, 0, 3, "testdata-dupe", "mockformat", "data"); - mappingtable_close(maptable); - - table = hashtable_load(group, 1, 1); - check_hash(table, "testdata-dupe"); - osync_hashtable_close(table); - - table = hashtable_load(group, 2, 1); - check_hash(table, "testdata-dupe"); - osync_hashtable_close(table); - - table = hashtable_load(group, 3, 1); - check_hash(table, "testdata-dupe"); - osync_hashtable_close(table); + path = g_strdup_printf("%s/configs/group/archive.db", testbed); + maptable = mappingtable_load(path, "mockobjtype1", 1); + g_free(path); + check_mapping(maptable, 1, -1, 3, "testdata-dupe"); + check_mapping(maptable, 2, -1, 3, "testdata-dupe"); + check_mapping(maptable, 3, -1, 3, "testdata-dupe"); + osync_mapping_table_close(maptable); + osync_mapping_table_unref(maptable); + + num_uids = 1; + uids[0] = "testdata-dupe"; + hashtable_load_and_check(testbed, 1, uids, num_uids); + hashtable_load_and_check(testbed, 2, uids, num_uids); + hashtable_load_and_check(testbed, 3, uids, num_uids); + system("rm -f data2/testdata-dupe"); mark_point(); - num_conflicts = 0; + synchronize_once(engine, NULL); - osengine_finalize(engine); - - mappingtable_load(group, 0, 0); - mappingtable_close(maptable); - - hashtable_load(group, 1, 0); - osync_hashtable_close(table); - - table = hashtable_load(group, 2, 0); - osync_hashtable_close(table); - - table = hashtable_load(group, 3, 0); - osync_hashtable_close(table); + destroy_engine(engine); - fail_unless(!system("test \"x$(ls data1)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data3)\" = \"x\""), NULL); + check_empty(testbed); destroy_testbed(testbed); } END_TEST + +/* As above but with 3 conflicts, one from each data member + * should get 3+3+2 writes + */ START_TEST (multisync_conflict_data_duplicate2) { char *testbed = setup_testbed("multisync_conflict_data_duplicate2"); - OSyncEnv *osync = init_env(); - OSyncGroup *group = osync_group_load(osync, "configs/group", NULL); - fail_unless(group != NULL, NULL); - fail_unless(osync_env_num_groups(osync) == 1, NULL); + OSyncError *error = NULL; + OSyncEngine *engine = setup_engine(testbed); + osync_engine_set_conflict_callback(engine, conflict_handler_duplicate, GINT_TO_POINTER(3)); + + fail_unless(osync_engine_initialize(engine, &error), NULL); + fail_unless(error == NULL, NULL); + mark_point(); - - OSyncEngine *engine = init_engine(group); - osengine_set_conflict_callback(engine, conflict_handler_duplication, GINT_TO_POINTER(3)); synchronize_once(engine, NULL); fail_unless(num_engine_connected == 1, NULL); fail_unless(num_engine_read == 1, NULL); - fail_unless(num_engine_wrote == 1, NULL); + fail_unless(num_engine_written == 1, NULL); fail_unless(num_engine_disconnected == 1, NULL); - fail_unless(num_read == 3, NULL); - fail_unless(num_conflicts == 1, NULL); - fail_unless(num_written == 8, NULL); + fail_unless(num_change_read == 3, NULL); + fail_unless(num_mapping_conflicts == 1, NULL); + fail_unless(num_change_written == 8, NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); - - OSyncMappingTable *maptable = mappingtable_load(group, 3, 0); - check_mapping(maptable, 1, -1, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 2, -1, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 3, -1, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 1, -1, 3, "testdata-dupe", "mockformat", "data"); - check_mapping(maptable, 2, -1, 3, "testdata-dupe", "mockformat", "data"); - check_mapping(maptable, 3, -1, 3, "testdata-dupe", "mockformat", "data"); - check_mapping(maptable, 1, -1, 3, "testdata-dupe-dupe", "mockformat", "data"); - check_mapping(maptable, 2, -1, 3, "testdata-dupe-dupe", "mockformat", "data"); - check_mapping(maptable, 3, -1, 3, "testdata-dupe-dupe", "mockformat", "data"); - mappingtable_close(maptable); - - OSyncHashTable *table = hashtable_load(group, 1, 3); - check_hash(table, "testdata"); - check_hash(table, "testdata-dupe"); - check_hash(table, "testdata-dupe-dupe"); - osync_hashtable_close(table); - - table = hashtable_load(group, 2, 3); - check_hash(table, "testdata"); - check_hash(table, "testdata-dupe"); - check_hash(table, "testdata-dupe-dupe"); - osync_hashtable_close(table); - - table = hashtable_load(group, 3, 3); - check_hash(table, "testdata"); - check_hash(table, "testdata-dupe"); - check_hash(table, "testdata-dupe-dupe"); - osync_hashtable_close(table); + fail_unless(osync_testing_diff("data1", "data2")); + fail_unless(osync_testing_diff("data1", "data3")); + /* load mapping table, check for 3 mappings */ + char *path = g_strdup_printf("%s/configs/group/archive.db", testbed); + OSyncMappingTable *maptable = mappingtable_load(path, "mockobjtype1", 3); + g_free(path); + + unsigned int num_members = 3; + unsigned int num_uids = 3; + const char *uids[] = {"testdata", "testdata-dupe", "testdata-dupe-dupe"}; + unsigned int member; + unsigned int uid; + + /* check we have num_members mapping entries for each uid */ + for (uid = 0; uid < num_uids; uid++) { + for (member = 1; member <= num_members; member++) { + check_mapping(maptable, member, -1, num_members, uids[uid]); + } + } + osync_mapping_table_close(maptable); + osync_mapping_table_unref(maptable); + + hashtable_load_and_check(testbed, 1, uids, num_uids); + hashtable_load_and_check(testbed, 2, uids, num_uids); + hashtable_load_and_check(testbed, 3, uids, num_uids); + + /* force the removal of all but test-data-dupe */ system("rm -f data3/testdata data3/testdata-dupe-dupe"); + mark_point(); synchronize_once(engine, NULL); - maptable = mappingtable_load(group, 1, 0); - check_mapping(maptable, 1, 0, 3, "testdata-dupe", "mockformat", "data"); - check_mapping(maptable, 2, 0, 3, "testdata-dupe", "mockformat", "data"); - check_mapping(maptable, 3, 0, 3, "testdata-dupe", "mockformat", "data"); - mappingtable_close(maptable); - - table = hashtable_load(group, 1, 1); - check_hash(table, "testdata-dupe"); - osync_hashtable_close(table); - - table = hashtable_load(group, 2, 1); - check_hash(table, "testdata-dupe"); - osync_hashtable_close(table); - - table = hashtable_load(group, 3, 1); - check_hash(table, "testdata-dupe"); - osync_hashtable_close(table); - + num_uids = 1; + uids[0] = "testdata-dupe"; + + /* load mapping table, check for 1 mappings */ + path = g_strdup_printf("%s/configs/group/archive.db", testbed); + maptable = mappingtable_load(path, "mockobjtype1", 1); + g_free(path); + + check_mapping(maptable, 1, -1, 3, "testdata-dupe"); + check_mapping(maptable, 2, -1, 3, "testdata-dupe"); + check_mapping(maptable, 3, -1, 3, "testdata-dupe"); + osync_mapping_table_close(maptable); + osync_mapping_table_unref(maptable); + + hashtable_load_and_check(testbed, 1, uids, num_uids); + hashtable_load_and_check(testbed, 2, uids, num_uids); + hashtable_load_and_check(testbed, 3, uids, num_uids); + + /* force the removal of the remaining testdata-dupe */ system("rm -f data2/testdata-dupe"); - mark_point(); - num_conflicts = 0; + synchronize_once(engine, NULL); - osengine_finalize(engine); - - mappingtable_load(group, 0, 0); - mappingtable_close(maptable); - - hashtable_load(group, 1, 0); - osync_hashtable_close(table); - - table = hashtable_load(group, 2, 0); - osync_hashtable_close(table); + destroy_engine(engine); - table = hashtable_load(group, 3, 0); - osync_hashtable_close(table); - - fail_unless(!system("test \"x$(ls data1)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data3)\" = \"x\""), NULL); + check_empty(testbed); destroy_testbed(testbed); } END_TEST +#if 0 START_TEST (multisync_conflict_changetype_duplicate) { char *testbed = setup_testbed("multisync_conflict_changetype_choose"); @@ -1336,19 +1280,19 @@ fail_unless(num_engine_connected == 1, NULL); fail_unless(num_engine_read == 1, NULL); - fail_unless(num_engine_wrote == 1, NULL); + fail_unless(num_engine_written == 1, NULL); fail_unless(num_engine_disconnected == 1, NULL); - fail_unless(num_read == 2, NULL); - fail_unless(num_conflicts == 1, NULL); - fail_unless(num_written == 2, NULL); + fail_unless(num_change_read == 2, NULL); + fail_unless(num_mapping_conflicts == 1, NULL); + fail_unless(num_change_written == 2, NULL); fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); OSyncMappingTable *maptable = mappingtable_load(group, 1, 0); - check_mapping(maptable, 1, 0, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 2, 0, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 3, 0, 3, "testdata", "mockformat", "data"); + check_mapping(maptable, 1, 0, 3, "testdata"); + check_mapping(maptable, 2, 0, 3, "testdata"); + check_mapping(maptable, 3, 0, 3, "testdata"); mappingtable_close(maptable); OSyncHashTable *table = hashtable_load(group, 1, 1); @@ -1366,7 +1310,7 @@ system("rm -f data1/testdata"); mark_point(); - num_conflicts = 0; + num_mapping_conflicts = 0; synchronize_once(engine, NULL); osengine_finalize(engine); @@ -1414,19 +1358,19 @@ fail_unless(num_engine_connected == 1, NULL); fail_unless(num_engine_read == 1, NULL); - fail_unless(num_engine_wrote == 1, NULL); + fail_unless(num_engine_written == 1, NULL); fail_unless(num_engine_disconnected == 1, NULL); - fail_unless(num_read == 3, NULL); - fail_unless(num_conflicts == 1, NULL); - fail_unless(num_written == 2, NULL); + fail_unless(num_change_read == 3, NULL); + fail_unless(num_mapping_conflicts == 1, NULL); + fail_unless(num_change_written == 2, NULL); fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); OSyncMappingTable *maptable = mappingtable_load(group, 1, 0); - check_mapping(maptable, 1, 0, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 2, 0, 3, "testdata", "mockformat", "data"); - check_mapping(maptable, 3, 0, 3, "testdata", "mockformat", "data"); + check_mapping(maptable, 1, 0, 3, "testdata"); + check_mapping(m... [truncated message content] |
From: <svn...@op...> - 2009-03-27 11:21:06
|
Author: dgollub Date: Fri Mar 27 12:21:01 2009 New Revision: 5358 URL: http://www.opensync.org/changeset/5358 Log: Test commit to trigger continuous build hosts. Modified: trunk/AUTHORS Modified: trunk/AUTHORS ============================================================================== --- trunk/AUTHORS Fri Mar 27 09:24:18 2009 (r5357) +++ trunk/AUTHORS Fri Mar 27 12:21:01 2009 (r5358) @@ -2,4 +2,4 @@ arm...@de... Daniel Gollub -dg...@cr... +dg...@op... |
From: <svn...@op...> - 2009-03-27 08:24:30
|
Author: bricks Date: Fri Mar 27 09:24:18 2009 New Revision: 5357 URL: http://www.opensync.org/changeset/5357 Log: removed osync_plugin_info_get_sink and osync_objtype_sink_get_slowsync from the public api Added: trunk/opensync/plugin/opensync_plugin_info_internals.h Modified: trunk/opensync.sym trunk/opensync/client/opensync_client.c trunk/opensync/engine/opensync_obj_engine.c trunk/opensync/plugin/opensync_objtype_sink.c trunk/opensync/plugin/opensync_objtype_sink.h trunk/opensync/plugin/opensync_objtype_sink_internals.h trunk/opensync/plugin/opensync_plugin_info.h trunk/tests/mock-plugin/mock_sync.c trunk/tools/osyncplugin.c trunk/wrapper/opensync-plugin.i Modified: trunk/opensync.sym ============================================================================== --- trunk/opensync.sym Thu Mar 26 22:30:35 2009 (r5356) +++ trunk/opensync.sym Fri Mar 27 09:24:18 2009 (r5357) @@ -390,7 +390,6 @@ osync_objtype_sink_get_objformat_sinks osync_objtype_sink_get_preferred_format osync_objtype_sink_get_read -osync_objtype_sink_get_slowsync osync_objtype_sink_get_write osync_objtype_sink_is_available osync_objtype_sink_is_enabled @@ -554,7 +553,6 @@ osync_plugin_info_get_groupname osync_plugin_info_get_loop osync_plugin_info_get_main_sink -osync_plugin_info_get_sink osync_plugin_info_get_version osync_plugin_info_new osync_plugin_info_nth_objtype Modified: trunk/opensync/client/opensync_client.c ============================================================================== --- trunk/opensync/client/opensync_client.c Thu Mar 26 22:30:35 2009 (r5356) +++ trunk/opensync/client/opensync_client.c Fri Mar 27 09:24:18 2009 (r5357) @@ -25,6 +25,7 @@ #include "opensync-plugin.h" #include "plugin/opensync_plugin_internals.h" #include "plugin/opensync_objtype_sink_internals.h" +#include "plugin/opensync_plugin_info_internals.h" #include "opensync-ipc.h" #include "ipc/opensync_serializer_internals.h" Modified: trunk/opensync/engine/opensync_obj_engine.c ============================================================================== --- trunk/opensync/engine/opensync_obj_engine.c Thu Mar 26 22:30:35 2009 (r5356) +++ trunk/opensync/engine/opensync_obj_engine.c Fri Mar 27 09:24:18 2009 (r5357) @@ -1211,7 +1211,7 @@ OSyncSinkEngine *osync_obj_engine_find_proxy_sinkengine(OSyncObjEngine *engine, OSyncClientProxy *proxy) { OSyncList *s; - OSyncSinkEngine *sinkengine; + OSyncSinkEngine *sinkengine = NULL; osync_return_val_if_fail(engine, NULL); osync_return_val_if_fail(proxy, NULL); Modified: trunk/opensync/plugin/opensync_objtype_sink.c ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink.c Thu Mar 26 22:30:35 2009 (r5356) +++ trunk/opensync/plugin/opensync_objtype_sink.c Fri Mar 27 09:24:18 2009 (r5357) @@ -29,6 +29,7 @@ #include "opensync_plugin_info.h" /* due to osync_plugin_info_get_configdir() */ #include "opensync_objtype_sink.h" +#include "opensync_objtype_sink_internals.h" #include "opensync_objtype_sink_private.h" OSyncObjTypeSink *osync_objtype_main_sink_new(OSyncError **error) Modified: trunk/opensync/plugin/opensync_objtype_sink.h ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink.h Thu Mar 26 22:30:35 2009 (r5356) +++ trunk/opensync/plugin/opensync_objtype_sink.h Fri Mar 27 09:24:18 2009 (r5357) @@ -319,24 +319,6 @@ */ OSYNC_EXPORT void osync_objtype_sink_set_read(OSyncObjTypeSink *sink, osync_bool read); - -/** @brief Checks if slow-sync has been requested - * - * When slow-sync is requested, OpenSync synchronizes all entries rather than - * just the changes. - * - * If you are using hashtables, you should call this function in your sink's - * get_changes() function and if slow-sync has been requested, call - * osync_hashtable_slowsync() on your hashtable. If you don't do this, OpenSync - * will assume that all entries should be deleted, which is usually not what - * the user wants. - * - * @param sink Pointer to the sink - * @returns TRUE if slow-sync has been requested, FALSE for normal sync - * - */ -OSYNC_EXPORT osync_bool osync_objtype_sink_get_slowsync(OSyncObjTypeSink *sink); - /** @brief Sets the slow-sync state of a sink * * When slow-sync is requested, OpenSync synchronizes all entries rather than Modified: trunk/opensync/plugin/opensync_objtype_sink_internals.h ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink_internals.h Thu Mar 26 22:30:35 2009 (r5356) +++ trunk/opensync/plugin/opensync_objtype_sink_internals.h Fri Mar 27 09:24:18 2009 (r5357) @@ -272,6 +272,23 @@ */ void *osync_objtype_sink_get_userdata(OSyncObjTypeSink *sink); +/** @brief Checks if slow-sync has been requested + * + * When slow-sync is requested, OpenSync synchronizes all entries rather than + * just the changes. + * + * If you are using hashtables, you should call this function in your sink's + * get_changes() function and if slow-sync has been requested, call + * osync_hashtable_slowsync() on your hashtable. If you don't do this, OpenSync + * will assume that all entries should be deleted, which is usually not what + * the user wants. + * + * @param sink Pointer to the sink + * @returns TRUE if slow-sync has been requested, FALSE for normal sync + * + */ +osync_bool osync_objtype_sink_get_slowsync(OSyncObjTypeSink *sink); + /*@}*/ #endif /*OPENSYNC_SINK_INTERNALS_H_*/ Modified: trunk/opensync/plugin/opensync_plugin_info.h ============================================================================== --- trunk/opensync/plugin/opensync_plugin_info.h Thu Mar 26 22:30:35 2009 (r5356) +++ trunk/opensync/plugin/opensync_plugin_info.h Fri Mar 27 09:24:18 2009 (r5357) @@ -170,15 +170,6 @@ */ OSYNC_EXPORT void osync_plugin_info_set_format_env(OSyncPluginInfo *info, OSyncFormatEnv *env); - -/** @brief Returns the currently running sink - * - * @param info Pointer to the plugin info object - * @returns the current sink - * - */ -OSYNC_EXPORT OSyncObjTypeSink *osync_plugin_info_get_sink(OSyncPluginInfo *info); - /** @brief Sets the current OSyncObjTypeSink * * @param info Pointer to the plugin info object Added: trunk/opensync/plugin/opensync_plugin_info_internals.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/opensync/plugin/opensync_plugin_info_internals.h Fri Mar 27 09:24:18 2009 (r5357) @@ -0,0 +1,42 @@ +/* + * libopensync - A synchronization framework + * Copyright (C) 2009 Bjoern Ricks <bjo...@gm...> + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef _OPENSYNC_PLUGIN_INFO_INTERNALS_H_ +#define _OPENSYNC_PLUGIN_INFO_INTERNALS_H_ + +/** + * @defgroup OSyncPluginInfoInternalAPI OpenSync Plugin Info Internals + * @ingroup OSyncPluginPrivate + */ + +/*@{*/ + +/** @brief Returns the currently running sink + * + * @param info Pointer to the plugin info object + * @returns the current sink + * + */ +OSyncObjTypeSink *osync_plugin_info_get_sink(OSyncPluginInfo *info); + +/*@}*/ + + +#endif /* _OPENSYNC_PLUGIN_INFO_INTERNALS_H_ */ Modified: trunk/tests/mock-plugin/mock_sync.c ============================================================================== --- trunk/tests/mock-plugin/mock_sync.c Thu Mar 26 22:30:35 2009 (r5356) +++ trunk/tests/mock-plugin/mock_sync.c Fri Mar 27 09:24:18 2009 (r5357) @@ -278,7 +278,7 @@ * start with a slash. See note above. * */ -static void mock_report_dir(MockDir *directory, const char *subdir, OSyncContext *ctx, OSyncPluginInfo *info) +static void mock_report_dir(MockDir *directory, const char *subdir, OSyncContext *ctx, OSyncPluginInfo *info, OSyncObjTypeSink *sink) { GError *gerror = NULL; const char *de = NULL; @@ -286,10 +286,7 @@ GDir *dir = NULL; OSyncError *error = NULL; - osync_trace(TRACE_ENTRY, "%s(%p, %s, %p)", __func__, directory, subdir, ctx); - - OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info); - osync_assert(sink); + osync_trace(TRACE_ENTRY, "%s(%p, %s, %p, %p)", __func__, directory, subdir, ctx, sink); OSyncFormatEnv *formatenv = osync_plugin_info_get_format_env(info); osync_assert(formatenv); @@ -403,14 +400,14 @@ if (mock_get_error(info->memberid, "GET_CHANGES_TIMEOUT2")) g_usleep(8*G_USEC_PER_SEC); - if (osync_objtype_sink_get_slowsync(sink)) { + if (slow_sync) { osync_trace(TRACE_INTERNAL, "Slow sync requested"); osync_assert(osync_hashtable_slowsync(dir->hashtable, &error)); } osync_trace(TRACE_INTERNAL, "get_changes for %s", osync_objtype_sink_get_name(sink)); - mock_report_dir(dir, NULL, ctx, info); + mock_report_dir(dir, NULL, ctx, info, sink); OSyncList *u, *uids = osync_hashtable_get_deleted(dir->hashtable); for (u = uids; u; u = u->next) { Modified: trunk/tools/osyncplugin.c ============================================================================== --- trunk/tools/osyncplugin.c Thu Mar 26 22:30:35 2009 (r5356) +++ trunk/tools/osyncplugin.c Fri Mar 27 09:24:18 2009 (r5357) @@ -648,6 +648,7 @@ goto error; } + /* if (osync_objtype_sink_get_slowsync(sink)) { printf("SlowSync got requested by CONNECT function"); if (osync_objtype_sink_get_name(sink)) @@ -655,6 +656,7 @@ printf(".\n"); } + */ g_mutex_lock(cmd->mutex); g_cond_signal(cmd->cond); Modified: trunk/wrapper/opensync-plugin.i ============================================================================== --- trunk/wrapper/opensync-plugin.i Thu Mar 26 22:30:35 2009 (r5356) +++ trunk/wrapper/opensync-plugin.i Fri Mar 27 09:24:18 2009 (r5357) @@ -224,13 +224,6 @@ osync_plugin_info_set_format_env(self, env); } - ObjTypeSink *get_sink() { - ObjTypeSink *ret = osync_plugin_info_get_sink(self); - if (ret) - osync_objtype_sink_ref(ret); - return ret; - } - void set_sink(ObjTypeSink *sink) { osync_plugin_info_set_sink(self, sink); } @@ -444,11 +437,7 @@ void set_read(bool read) { osync_objtype_sink_set_read(self, read); } - - bool get_slowsync() { - return osync_objtype_sink_get_slowsync(self); - } - + void set_slowsync(bool slowsync) { osync_objtype_sink_set_slowsync(self, slowsync); } |
From: <svn...@op...> - 2009-03-26 21:30:43
|
Author: scriptor Date: Thu Mar 26 22:30:35 2009 New Revision: 5356 URL: http://www.opensync.org/changeset/5356 Log: Removing code that has already been commented out. Modified: plugins/ldap-sync/src/ldap_format.c Modified: plugins/ldap-sync/src/ldap_format.c ============================================================================== --- plugins/ldap-sync/src/ldap_format.c Thu Mar 26 22:29:04 2009 (r5355) +++ plugins/ldap-sync/src/ldap_format.c Thu Mar 26 22:30:35 2009 (r5356) @@ -4681,11 +4681,6 @@ goto error; } -/* - *output = (char *)ldap_entries; - *outpsize = sizeof(GList); -*/ - container = (glist_container *)g_malloc0(sizeof(glist_container)); osync_assert(container); @@ -5297,17 +5292,7 @@ osync_trace(TRACE_INTERNAL, "Looks like an xmlDoc."); } else if (inpsize == sizeof(glist_container)) { osync_trace(TRACE_INTERNAL, "Looks like a glist_container."); - } -/* - else if (inpsize == sizeof(struct OSyncChange)) { - osync_trace(TRACE_INTERNAL, "Looks like an OSyncChange struct."); - } else if (inpsize == sizeof(struct OSyncData)) { - osync_trace(TRACE_INTERNAL, "Looks like an OSyncData struct."); - } else if (inpsize == sizeof(struct OSyncObjFormat)) { - osync_trace(TRACE_INTERNAL, "Looks like an OSyncObjFormat struct."); - } -*/ - else if (inpsize == sizeof(GList)) { + } else if (inpsize == sizeof(GList)) { unsigned int length = 0; GList *list = (GList *)input; |
From: <svn...@op...> - 2009-03-26 21:29:28
|
Author: scriptor Date: Thu Mar 26 22:29:04 2009 New Revision: 5355 URL: http://www.opensync.org/changeset/5355 Log: Some further notes about prerequisites of the tests. Modified: plugins/ldap-sync/INSTALL Modified: plugins/ldap-sync/INSTALL ============================================================================== --- plugins/ldap-sync/INSTALL Thu Mar 26 22:24:45 2009 (r5354) +++ plugins/ldap-sync/INSTALL Thu Mar 26 22:29:04 2009 (r5355) @@ -53,6 +53,28 @@ - ldapdelete - valgrind +Also required is a running and adequately configured LDAP server. +This server must be configured in a way that allows sufficient +access to the user that is set in the $AUTH variable in +tests/test.conf. Moreover, the "dc=example,dc=com" DN must exist +in the DIT. This requires in /etc/openldap/slapd.conf at least + +database bdb + +suffix "dc=example,dc=com" + +If you prefer a different DN, you must change + +tests/test.conf and + +tests/*.ldif + +accordingly. + + +Moreover the configuration as laid out in src/ldap-sync must correspond with the settings of the LDAP server. If necessary change src/ldap-sync as needed (username, password, authentication method, base names etc.). + + II. Running the tests: |
From: <svn...@op...> - 2009-03-26 21:24:56
|
Author: scriptor Date: Thu Mar 26 22:24:45 2009 New Revision: 5354 URL: http://www.opensync.org/changeset/5354 Log: Adjusting to the upcoming API change: - osync_plugin_info_get_sink() - osync_objtype_sink_get_slowsync() will be removed. Modified: plugins/ldap-sync/src/ldap_plugin.c Modified: plugins/ldap-sync/src/ldap_plugin.c ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.c Thu Mar 26 20:40:11 2009 (r5353) +++ plugins/ldap-sync/src/ldap_plugin.c Thu Mar 26 22:24:45 2009 (r5354) @@ -2002,6 +2002,8 @@ goto error; } + osync_trace(TRACE_INTERNAL, "%s(): *slow_sync_requested = %i", __func__, *slow_sync_requested); + if (ldaplist_added == NULL) { osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldaplist_added = NULL. \n", __FILE__, __LINE__); goto error; @@ -2029,18 +2031,20 @@ // ----------------- slow-sync ------------------- - if (osync_objtype_sink_get_slowsync(sinkenv->sink)) { + if (*slow_sync_requested) { osync_trace(TRACE_INTERNAL, "Slow sync requested by client"); #ifdef DEBUG_ldapdata_from_server ldap_plugin_printf("%s:%i: Slow sync requested for %s by client", __FILE__, __LINE__, osync_objtype_sink_get_name(sinkenv->sink)); #endif - *slow_sync_requested = TRUE; - // Tell hashtable about slow-sync: if (!osync_hashtable_slowsync(sinkenv->hashtable, error)) { + if (!osync_error_is_set(error)) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: osync_hashtable_slowsync() has failed.", __FILE__, __LINE__); + } + goto error; } @@ -3359,7 +3363,7 @@ #ifdef DEBUG_change_type_modified - osync_trace(TRACE_INTERNAL, "\n\n\n\n%s:%i:%s(): xxx\n*dn_of_modified_entry = \"%s\"", __FILE__, __LINE__, __func__, *dn_of_modified_entry); + osync_trace(TRACE_INTERNAL, "\n\n\n\n%s:%i:%s():\n*dn_of_modified_entry = \"%s\"", __FILE__, __LINE__, __func__, *dn_of_modified_entry); #endif LDAPMessage *dn_list = NULL; @@ -4059,6 +4063,9 @@ osync_bool ldap_plugin_initialize_anchor(sink_environment *sinkenv, OSyncError **error) { + char *timestamp = NULL; + + osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, sinkenv, error); @@ -4084,36 +4091,32 @@ - // if (!osync_objtype_sink_get_slowsync(sinkenv->sink)) - { - char *timestamp = NULL; - + - OSyncAnchor *anchor = osync_objtype_sink_get_anchor(sinkenv->sink); - if (anchor == NULL) { - osync_trace(TRACE_ERROR, "%s:%i: ERROR: anchor = NULL for objtype \"%s\". Ignoring for now.\n", __FILE__, __LINE__, osync_objtype_sink_get_name(sinkenv->sink)); - } else { - timestamp = osync_anchor_retrieve(anchor, error); + OSyncAnchor *anchor = osync_objtype_sink_get_anchor(sinkenv->sink); + if (anchor == NULL) { + osync_trace(TRACE_ERROR, "%s:%i: ERROR: anchor = NULL for objtype \"%s\". Ignoring for now.\n", __FILE__, __LINE__, osync_objtype_sink_get_name(sinkenv->sink)); + } else { + timestamp = osync_anchor_retrieve(anchor, error); #ifdef DEBUG_anchor - ldap_plugin_printf("%s:%i: osync_anchor_retrieve() returned: \"%s\"", __FILE__, __LINE__, timestamp ? timestamp : "NULL"); + ldap_plugin_printf("%s:%i: osync_anchor_retrieve() returned: \"%s\"", __FILE__, __LINE__, timestamp ? timestamp : "NULL"); #endif - } + } - if (timestamp == NULL || timestamp[0] == 0 || strlen(timestamp) < 16) { - sinkenv->latest_timestamp = NULL; - } else { - sinkenv->latest_timestamp = g_strdup(timestamp); - g_free(timestamp); - timestamp = NULL; - } + if (timestamp == NULL || timestamp[0] == 0 || strlen(timestamp) < 16) { + sinkenv->latest_timestamp = NULL; + } else { + sinkenv->latest_timestamp = g_strdup(timestamp); + g_free(timestamp); + timestamp = NULL; + } #ifdef DEBUG_anchor - ldap_plugin_printf("%s:%i: sinkenv->latest_timestamp for objtype \"%s\" has been initialized to \"%s\"\n", __FILE__, __LINE__, osync_objtype_sink_get_name(sinkenv->sink), sinkenv->latest_timestamp ? sinkenv->latest_timestamp : "(NULL)"); + ldap_plugin_printf("%s:%i: sinkenv->latest_timestamp for objtype \"%s\" has been initialized to \"%s\"\n", __FILE__, __LINE__, osync_objtype_sink_get_name(sinkenv->sink), sinkenv->latest_timestamp ? sinkenv->latest_timestamp : "(NULL)"); #endif - } // if (!osync_objtype_sink_get_slowsync(sinkenv->sink)) osync_trace(TRACE_EXIT, "%s"); |
From: <svn...@op...> - 2009-03-26 19:40:18
|
Author: scriptor Date: Thu Mar 26 20:40:11 2009 New Revision: 5353 URL: http://www.opensync.org/changeset/5353 Log: $TMPDIR as produced by many of the tests, must be removed after each test has been finished. Modified: plugins/ldap-sync/tests/check_add_modify_delete_and_sync plugins/ldap-sync/tests/check_add_modify_delete_and_valgrind_and_sync plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_sync plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_valgrind_and_sync plugins/ldap-sync/tests/check_connect plugins/ldap-sync/tests/check_delete_and_fastsync plugins/ldap-sync/tests/check_fastsync plugins/ldap-sync/tests/check_init plugins/ldap-sync/tests/check_modify_and_fastsync plugins/ldap-sync/tests/check_slowsync plugins/ldap-sync/tests/check_sync Modified: plugins/ldap-sync/tests/check_add_modify_delete_and_sync ============================================================================== --- plugins/ldap-sync/tests/check_add_modify_delete_and_sync Thu Mar 26 20:39:18 2009 (r5352) +++ plugins/ldap-sync/tests/check_add_modify_delete_and_sync Thu Mar 26 20:40:11 2009 (r5353) @@ -222,4 +222,8 @@ $OSYNCPLUGIN --plugin $PLUGINNAME --pluginpath $PLUGINPATH --config $CFG --configdir $TMPDIR --initialize --connect $SYNCMETHOD --syncdone --disconnect --finalize || exit 1 +if test -d "$TMPDIR"; then + rm -rf "$TMPDIR" +fi + Modified: plugins/ldap-sync/tests/check_add_modify_delete_and_valgrind_and_sync ============================================================================== --- plugins/ldap-sync/tests/check_add_modify_delete_and_valgrind_and_sync Thu Mar 26 20:39:18 2009 (r5352) +++ plugins/ldap-sync/tests/check_add_modify_delete_and_valgrind_and_sync Thu Mar 26 20:40:11 2009 (r5353) @@ -275,6 +275,10 @@ exit 1 fi +if test -d "$TMPDIR"; then + rm -rf "$TMPDIR" +fi + echo echo echo Modified: plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_sync ============================================================================== --- plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_sync Thu Mar 26 20:39:18 2009 (r5352) +++ plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_sync Thu Mar 26 20:40:11 2009 (r5353) @@ -411,4 +411,8 @@ $OSYNCPLUGIN --plugin $PLUGINNAME --pluginpath $PLUGINPATH --config $CFG --configdir $TMPDIR --initialize --connect $SYNCMETHOD --syncdone --disconnect --finalize || exit 1 +if test -d "$TMPDIR"; then + rm -rf "$TMPDIR" +fi + Modified: plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_valgrind_and_sync ============================================================================== --- plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_valgrind_and_sync Thu Mar 26 20:39:18 2009 (r5352) +++ plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_valgrind_and_sync Thu Mar 26 20:40:11 2009 (r5353) @@ -424,6 +424,12 @@ exit 1 fi + +if test -d "$TMPDIR"; then + rm -rf "$TMPDIR" +fi + + echo echo echo Modified: plugins/ldap-sync/tests/check_connect ============================================================================== --- plugins/ldap-sync/tests/check_connect Thu Mar 26 20:39:18 2009 (r5352) +++ plugins/ldap-sync/tests/check_connect Thu Mar 26 20:40:11 2009 (r5353) @@ -32,3 +32,9 @@ $OSYNCPLUGIN --plugin $PLUGINNAME --pluginpath $PLUGINPATH --config $CFG --configdir $TMPDIR --initialize --connect --disconnect --finalize || exit 1 + +if test -d "$TMPDIR"; then + rm -rf "$TMPDIR" +fi + + Modified: plugins/ldap-sync/tests/check_delete_and_fastsync ============================================================================== --- plugins/ldap-sync/tests/check_delete_and_fastsync Thu Mar 26 20:39:18 2009 (r5352) +++ plugins/ldap-sync/tests/check_delete_and_fastsync Thu Mar 26 20:40:11 2009 (r5353) @@ -119,3 +119,8 @@ $OSYNCPLUGIN --plugin $PLUGINNAME --pluginpath $PLUGINPATH --config $CFG --configdir $TMPDIR --initialize --connect --fastsync --syncdone --disconnect --finalize || exit 1 +if test -d "$TMPDIR"; then + rm -rf "$TMPDIR" +fi + + Modified: plugins/ldap-sync/tests/check_fastsync ============================================================================== --- plugins/ldap-sync/tests/check_fastsync Thu Mar 26 20:39:18 2009 (r5352) +++ plugins/ldap-sync/tests/check_fastsync Thu Mar 26 20:40:11 2009 (r5353) @@ -31,3 +31,8 @@ $OSYNCPLUGIN --plugin $PLUGINNAME --pluginpath $PLUGINPATH --config $CFG --configdir $TMPDIR --initialize --connect --fastsync --syncdone --disconnect --finalize || exit 1 +if test -d "$TMPDIR"; then + rm -rf "$TMPDIR" +fi + + Modified: plugins/ldap-sync/tests/check_init ============================================================================== --- plugins/ldap-sync/tests/check_init Thu Mar 26 20:39:18 2009 (r5352) +++ plugins/ldap-sync/tests/check_init Thu Mar 26 20:40:11 2009 (r5353) @@ -32,3 +32,8 @@ $OSYNCPLUGIN --plugin $PLUGINNAME --pluginpath $PLUGINPATH --config $CFG --configdir $TMPDIR --initialize --finalize || exit 1 +if test -d "$TMPDIR"; then + rm -rf "$TMPDIR" +fi + + Modified: plugins/ldap-sync/tests/check_modify_and_fastsync ============================================================================== --- plugins/ldap-sync/tests/check_modify_and_fastsync Thu Mar 26 20:39:18 2009 (r5352) +++ plugins/ldap-sync/tests/check_modify_and_fastsync Thu Mar 26 20:40:11 2009 (r5353) @@ -110,3 +110,7 @@ $OSYNCPLUGIN --plugin $PLUGINNAME --pluginpath $PLUGINPATH --config $CFG --configdir $TMPDIR --initialize --connect --fastsync --syncdone --disconnect --finalize || exit 1 +if test -d "$TMPDIR"; then + rm -rf "$TMPDIR" +fi + Modified: plugins/ldap-sync/tests/check_slowsync ============================================================================== --- plugins/ldap-sync/tests/check_slowsync Thu Mar 26 20:39:18 2009 (r5352) +++ plugins/ldap-sync/tests/check_slowsync Thu Mar 26 20:40:11 2009 (r5353) @@ -30,3 +30,8 @@ $OSYNCPLUGIN --plugin $PLUGINNAME --pluginpath $PLUGINPATH --config $CFG --configdir $TMPDIR --initialize --connect --slowsync --syncdone --disconnect --finalize || exit 1 +if test -d "$TMPDIR"; then + rm -rf "$TMPDIR" +fi + + Modified: plugins/ldap-sync/tests/check_sync ============================================================================== --- plugins/ldap-sync/tests/check_sync Thu Mar 26 20:39:18 2009 (r5352) +++ plugins/ldap-sync/tests/check_sync Thu Mar 26 20:40:11 2009 (r5353) @@ -32,3 +32,7 @@ $OSYNCPLUGIN --plugin $PLUGINNAME --pluginpath $PLUGINPATH --config $CFG --configdir $TMPDIR --initialize --connect --sync --syncdone --disconnect --finalize || exit 1 +if test -d "$TMPDIR"; then + rm -rf "$TMPDIR" +fi + |
From: <svn...@op...> - 2009-03-26 19:39:26
|
Author: scriptor Date: Thu Mar 26 20:39:18 2009 New Revision: 5352 URL: http://www.opensync.org/changeset/5352 Log: Typos. Modified: plugins/ldap-sync/ChangeLog plugins/ldap-sync/src/ldap_connect.c plugins/ldap-sync/src/ldap_debug.c plugins/ldap-sync/src/ldap_format.c plugins/ldap-sync/src/ldap_plugin.c plugins/ldap-sync/src/md5_crypt.c Modified: plugins/ldap-sync/ChangeLog ============================================================================== --- plugins/ldap-sync/ChangeLog Thu Mar 26 20:38:16 2009 (r5351) +++ plugins/ldap-sync/ChangeLog Thu Mar 26 20:39:18 2009 (r5352) @@ -9,7 +9,7 @@ -- cmake, -- sinks, -- new format of config file, - -- use of stylesheets for conversion, + -- use of style sheets for conversion, -- sourcing out the conversion routines into a separate format plugin -- and dozens of other API changes. - Several issues with the TLS/SSL based encryption of the LDAP session @@ -44,7 +44,7 @@ been resolved. - For the time being the objtype "contact" can be mapped either to the LDAP scheme "evolutionPerson" or to the - LDAP scheme "inetorgPerson". This can be configured. + LDAP scheme "inetOrgPerson". This can be configured. - The other objtypes are mapped to general object classes, like "ou:" and "document:", while some LDAP attribute names are abused for storing "name" and "value" pairs. Modified: plugins/ldap-sync/src/ldap_connect.c ============================================================================== --- plugins/ldap-sync/src/ldap_connect.c Thu Mar 26 20:38:16 2009 (r5351) +++ plugins/ldap-sync/src/ldap_connect.c Thu Mar 26 20:39:18 2009 (r5352) @@ -1151,7 +1151,7 @@ if (res == NULL) { - // xxx jl: TODO: Produce osync error message. + // TODO: Produce osync error message. osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldap_plugin_call_ldap_search() must have failed.\n", __FILE__, __LINE__); ldap_plugin_dump_ldap_error_message(sinkenv, "cn=Subschema", "(objectClass=subschema)", "ldap_plugin_call_ldap_search()"); @@ -1218,9 +1218,9 @@ * @param filter Which attributes are to be shown? * @param scope Which parts of the DIT are to be searched: * - * base: only the currrent location in the DIT, nothing else, - * one: one level deeper in the DIT withouth the current location, - * children: all levels below the current location in the DIT withouth the corrent one, + * base: only the current location in the DIT, nothing else, + * one: one level deeper in the DIT without the current location, + * children: all levels below the current location in the DIT without the current one, * sub: the current location in the DIT and all of its children * * @@ -1380,7 +1380,7 @@ * * @param ctx The libopensync context. * @param sinkenv The object type specific environment. - * @param rv As a result of this function this variabl gets filled with + * @param rv As a result of this function this variable gets filled with * ldap_errno: LDAP_SUCCESS on success, -1 on error. * @param dn The distinguished name of the entry in the DIT. * The entries below this one are to be deleted. @@ -1505,7 +1505,7 @@ (!strncmp(id_values[0]->bv_val, "RecurrenceRule", 14)) || (!strncmp(id_values[0]->bv_val, "RecurrenceRuleExtended", 22)) || (!strncmp(id_values[0]->bv_val, "EMail", 5)) - // Telepone: Not necessary to enter a deeper level. + // Telephone: Not necessary to enter a deeper level. ) { #ifdef DEBUG_change_type_deleted @@ -2539,7 +2539,7 @@ * in the hashtable has been calculated. * * @param ctx The libopensync context. - * @param sinkenv Object type specifi environment + * @param sinkenv Object type specific environment * @param uids_hashtable List of uids stored in the hashtable. * @param uids_ldap_server List of uids present on the LDAP server. * @param new_entries A list of LDAP entries that are new on the LDAP server @@ -2605,7 +2605,7 @@ ) { #ifdef DEBUG_fastsync - ldap_plugin_printf("Ok. Hashes are identical."); + ldap_plugin_printf("OK. Hashes are identical."); #endif } else { #ifdef DEBUG_fastsync @@ -3613,14 +3613,14 @@ /* Check entry attributes */ for (i = 0 ; check_entry->mods[i] ; i++) { - /* Search for checked attribute in LDAP attributel-list */ + /* Search for checked attribute in LDAP attribute-list */ for (list = g_list_first(ldap_attrnames) ; list ; list = g_list_next(list)) { ldap_attribute = (char*)list->data; // If the LDAP attribute in check_entry can be found among // the LDAP attributes present on the server, advance to the next one - // in check_entry (i.e. presetn on the peer) + // in check_entry (i.e. present on the peer) if (!strcmp(check_entry->mods[i]->mod_type, ldap_attribute)) goto next_mod_attribute; } @@ -3775,14 +3775,14 @@ if (mod) { if (mod->mod_type) { if (!strcmp(mod->mod_type, sinkenv->keyattr)) { - osync_trace(TRACE_INTERNAL, "%s(): Ok. Keyattribute \"%s\" found.", __func__, sinkenv->keyattr); + osync_trace(TRACE_INTERNAL, "%s(): OK. Keyattribute \"%s\" found.", __func__, sinkenv->keyattr); found_name = TRUE; if (mod->mod_bvalues) { if (mod->mod_bvalues[0]) { if (mod->mod_bvalues[0]->bv_val) { if (!strcmp(mod->mod_bvalues[0]->bv_val, entry->id)) { - osync_trace(TRACE_INTERNAL, "%s(): Ok. Value of keyattribute is identical to the identifier: \"%s\".", __func__, entry->id); + osync_trace(TRACE_INTERNAL, "%s(): OK. Value of keyattribute is identical to the identifier: \"%s\".", __func__, entry->id); found_value = TRUE; } else { osync_trace(TRACE_ERROR, "%s:%i: WARNING: Value of keyattribute \"%s\" conflicts with identifier \"%s\". Trying to enforce correct one.", __FILE__, __LINE__, mod->mod_bvalues[0]->bv_val, entry->id); @@ -3832,7 +3832,7 @@ /** * @brief Queries the LDAP server about the entryCSN attribute of - * one particular LDAP entry, and adds it to an already exising + * one particular LDAP entry, and adds it to an already existing * hash string, thus gradually building the final hash value. * * @param ctx The libopensync context. Modified: plugins/ldap-sync/src/ldap_debug.c ============================================================================== --- plugins/ldap-sync/src/ldap_debug.c Thu Mar 26 20:38:16 2009 (r5351) +++ plugins/ldap-sync/src/ldap_debug.c Thu Mar 26 20:39:18 2009 (r5352) @@ -128,10 +128,10 @@ ldap_plugin_printf("%s:%i: ERROR: ldap_get_option() has failed. result_code could not be filled in.", __FILE__, __LINE__); } else { if (result_code != 0) { - ldap_plugin_printf("%s:%i: ERROR: \"%s\" has returned NULL. Are your searchbase \"%s\" and your filter \"%s\" for this particular objtype \"%s\" ok?", __FILE__, __LINE__, command, base, filter, osync_objtype_sink_get_name(sinkenv->sink)); + ldap_plugin_printf("%s:%i: ERROR: \"%s\" has returned NULL. Are your searchbase \"%s\" and your filter \"%s\" for this particular objtype \"%s\" OK?", __FILE__, __LINE__, command, base, filter, osync_objtype_sink_get_name(sinkenv->sink)); ldap_plugin_printf("ERROR: %s", ldap_err2string(result_code)); } else { - ldap_plugin_printf("%s:%i: WARNING: \"%s\" has returned NULL. Are your searchbase \"%s\" and and your filter \"%s\" for this particular objtype \"%s\" ok? Or is there really not a single entry under the searchbase?", __FILE__, __LINE__, command, base, filter, osync_objtype_sink_get_name(sinkenv->sink)); + ldap_plugin_printf("%s:%i: WARNING: \"%s\" has returned NULL. Are your searchbase \"%s\" and your filter \"%s\" for this particular objtype \"%s\" OK? Or is there really not a single entry under the searchbase?", __FILE__, __LINE__, command, base, filter, osync_objtype_sink_get_name(sinkenv->sink)); } } } @@ -537,9 +537,9 @@ if (entry) { if (file == NULL) { - ldap_plugin_printf("%s:%i:%s(): \nThis error occured with id = %s, chtype = %i", __FILE__, __LINE__, __func__, entry->id, osync_change_get_changetype(change)); + ldap_plugin_printf("%s:%i:%s(): \nThis error occurred with id = %s, chtype = %i", __FILE__, __LINE__, __func__, entry->id, osync_change_get_changetype(change)); } else { - ldap_plugin_printf("%s:%i: \nThis error occured with id = %s, chtype = %i", file, line, entry->id, osync_change_get_changetype(change)); + ldap_plugin_printf("%s:%i: \nThis error occurred with id = %s, chtype = %i", file, line, entry->id, osync_change_get_changetype(change)); } // TODO @@ -547,9 +547,9 @@ } else if (dn && dn[0]) { if (file) { - ldap_plugin_printf("%s:%i: \nThis error occured with dn = %s, chtype = %i", file, line, dn, osync_change_get_changetype(change)); + ldap_plugin_printf("%s:%i: \nThis error occurred with dn = %s, chtype = %i", file, line, dn, osync_change_get_changetype(change)); } else { - ldap_plugin_printf("%s:%i:%s(): \nThis error occured with dn = %s, chtype = %i", __FILE__, __LINE__, __func__, dn, osync_change_get_changetype(change)); + ldap_plugin_printf("%s:%i:%s(): \nThis error occurred with dn = %s, chtype = %i", __FILE__, __LINE__, __func__, dn, osync_change_get_changetype(change)); } } @@ -570,7 +570,7 @@ #ifdef DEBUG_fastsync /** * @brief translate_changetype - * @parram changetype The changetype. + * @param changetype The changetype. * @returns The human readable name of the changetype in form of a string. * */ @@ -679,9 +679,9 @@ * @param string Sequence of characters to print out * @param len How long is this sequence * @param buffer As a result of this function this variable gets filled with - * a GString containing the dump. This GString must be free'd + * a GString containing the dump. This GString must be freed * later by means of g_string_free(). - * @param error The libopenync error pointer. + * @param error The libopensync error pointer. * * @returns FALSE on failure, TRUE on success * @@ -744,7 +744,7 @@ } } - /* padding spaces between end of binary and beginning of ascii */ + /* padding spaces between end of binary and beginning of ASCII */ g_string_append_printf(*buffer, " "); if (j % 16 != 0) { Modified: plugins/ldap-sync/src/ldap_format.c ============================================================================== --- plugins/ldap-sync/src/ldap_format.c Thu Mar 26 20:38:16 2009 (r5351) +++ plugins/ldap-sync/src/ldap_format.c Thu Mar 26 20:39:18 2009 (r5352) @@ -352,15 +352,16 @@ /** - * @brief A sanitizer for building the LDIF. It tries to avoid duplicate attriLDAPs. Helper function for ldap_format_convert_xmlinternal2ldap(). + * @brief A sanitizer for building the LDIF. It tries to avoid duplicate + * LDAP attributes. Helper function for ldap_format_convert_xmlinternal2ldap(). * * @param ldapmods A list of LDAPMod's that have already been collected * for building up an LDAP entry. \see{ldap_plugin.h} * @param name The LDAP attribute name that is to be checked for any - * potential dublicates + * potential duplicates * * @returns 0 if error - * @returns 1 if ok + * @returns 1 if OK * @returns 2 if duplicate found */ @@ -523,7 +524,7 @@ /** * @brief This function creates an ldap_entry struct out of several ldapmods of a GList * - * It also free's the ldapmods list + * It also frees the ldapmods list * * @param ldapmods: A GList out of LDAPMOD's. * @@ -679,7 +680,7 @@ if (list->data) { // We copy the source LDAP entries by creating a destination LDAP entry. // The memory regions used by the source and the destination LDAP entries - // must be independent from each other, so that they can be free'd + // must be independent from each other, so that they can be freed // separately. single_entry = (ldap_entry *)g_malloc0(sizeof(ldap_entry)); if (single_entry == NULL) { @@ -878,7 +879,7 @@ child_name = node->name; if (child_name == NULL) { - osync_trace(TRACE_ERROR, "%s:%i: ERROR: child_name = NULL. Ignoring thisnode.\n", __FILE__, __LINE__); + osync_trace(TRACE_ERROR, "%s:%i: ERROR: child_name = NULL. Ignoring this node.\n", __FILE__, __LINE__); continue; } @@ -906,7 +907,7 @@ // *attr2_name = g_strdup_printf("%s", xmlNodeGetContent(attribute_node)); *attr2_name = g_strdup_printf("%s", buf); } else { - osync_trace(TRACE_ERROR, "%s:%i: WARNING: Max. number of attributes already exhausted. Ignoring this one (name = \"%s\").\n", __FILE__, __LINE__, xmlNodeGetContent(attribute_node)); + osync_trace(TRACE_ERROR, "%s:%i: WARNING: Maximal number of attributes already exhausted. Ignoring this one (name = \"%s\").\n", __FILE__, __LINE__, xmlNodeGetContent(attribute_node)); } // if (*attr1_name == NULL) xmlFree(buf); @@ -926,7 +927,7 @@ } else if (*attr2_value == NULL) { *attr2_value = g_strdup_printf("%s", content1); } else { - osync_trace(TRACE_ERROR, "%s:%i: WARNING: Max. number of attributes already exhausted. Ignoring this one (value = \"%s\").\n", __FILE__, __LINE__, xmlNodeGetContent(attribute_node)); + osync_trace(TRACE_ERROR, "%s:%i: WARNING: Maximal number of attributes already exhausted. Ignoring this one (value = \"%s\").\n", __FILE__, __LINE__, xmlNodeGetContent(attribute_node)); } // if (*attr1_value == NULL) { xmlFree(content1); @@ -973,14 +974,14 @@ * counter to the element name: "TimezoneRule" turns into * "TimezoneRule_3", for example. Prerequisite is a container * that stores the number of elements with a particular name - * that have already occured. + * that have already occurred. * * @sa struct _complex_elements and typedef complex_elements. * @sa ldap_format_convert_xmlinternal2ldap(). * * @param ptr This is a pointer to a pointer to a GList which holds all * the names of complex XML elements that have already - * occured and have identical names. Thus we can get the number + * occurred and have identical names. Thus we can get the number * of identical names. And this number can be appended to * this common name, if we want to make them unique. * @param name This is the name of an XML element that is considered as @@ -1091,8 +1092,8 @@ xmlChar *value = NULL; GList *ldapmods_subentry = NULL; ldap_entry *ldap_subentry = NULL; - gchar *new_dn = NULL; // must be free'd eventually - gchar *new_id = NULL; // must be free'd eventually + gchar *new_dn = NULL; // must be freed eventually + gchar *new_id = NULL; // must be freed eventually gchar *attr1_name = NULL; gchar *attr1_value = NULL; gchar *attr2_name = NULL; @@ -1484,7 +1485,7 @@ ldapmods_subentry = NULL; } - // new_name is free'd in ldap_format_convert_xmlinternal2ldap() + // new_name is freed in ldap_format_convert_xmlinternal2ldap() if (attr1_name) { g_free(attr1_name); @@ -1522,7 +1523,7 @@ ldapmods_subentry = NULL; } - // new_name is free'd in ldap_format_convert_xmlinternal2ldap() + // new_name is freed in ldap_format_convert_xmlinternal2ldap() if (attr1_name) { g_free(attr1_name); @@ -1600,14 +1601,14 @@ /** * @brief This function validates the XML result as produced by the - * conversion routines and the stylesheets of this plugin + * conversion routines and the style sheets of this plugin * against the xmlformat schemata of libopensync. * * @param input The input for the conversion as a human readable string. * @param inpsize Its size. * @param xmlformat The format object for this XML document. * @param str The XML result to be validated as a human readable string. - * @param stylesheet_file The file name of the stylesheet that has been used + * @param stylesheet_file The file name of the style sheet that has been used * to produce the XML result. * @param error The libopensync error pointer * @@ -1648,7 +1649,7 @@ if (xmlformat_schema) { if (osync_xmlformat_schema_validate (xmlformat_schema, xmlformat, error)) { #ifdef DEBUG_do_apply_stylesheet - ldap_plugin_printf("%s:%i: Ok. XML result as produced by means of \"%s\" is valid.\n", __FILE__, __LINE__, stylesheet_file); + ldap_plugin_printf("%s:%i: OK. XML result as produced by means of \"%s\" is valid.\n", __FILE__, __LINE__, stylesheet_file); #endif @@ -1696,13 +1697,13 @@ /** * @brief This function validates the XML result as produced by the - * conversion routines and the stylesheets of this plugin + * conversion routines and the style sheets of this plugin * against the xmlformat schemata of libopensync. * * @param input The input for the conversion as a human readable string. * @param inpsize Its size. * @param xmlcard The XML result to be validated. This is an xmlDoc *. - * @param stylesheet_file The file name of the stylesheet that has been used + * @param stylesheet_file The file name of the style sheet that has been used * to produce the XML result. * @param error The libopensync error pointer * @@ -1811,10 +1812,10 @@ if (!xmlSchemaValidateDoc(dtd, xmlcard)) { #ifdef DEBUG_do_apply_stylesheet - ldap_plugin_printf("%s:%i: Ok. XML result as produced by means of \"%s\" is valid.", __FILE__, __LINE__, stylesheet_file); + ldap_plugin_printf("%s:%i: OK. XML result as produced by means of \"%s\" is valid.", __FILE__, __LINE__, stylesheet_file); #endif - osync_trace(TRACE_INTERNAL, "%s:%i: Ok. Resulting xmlformat as produced by means of \"%s\" is valid.", __FILE__, __LINE__, stylesheet_file); + osync_trace(TRACE_INTERNAL, "%s:%i: OK. Resulting xmlformat as produced by means of \"%s\" is valid.", __FILE__, __LINE__, stylesheet_file); #ifdef DEBUG_do_apply_stylesheet @@ -1918,17 +1919,17 @@ /** - * @brief This function checks whether the stylesheet file to be applied on - * a particular xml file is suitable for the objecttype that is + * @brief This function checks whether the style sheet file to be applied on + * a particular xml file is suitable for the object type that is * expressed in the root element. For example: * For object type "note" we MUST NOT apply "xmlformat_contact2ldap_evolutionperson.xsl" * * @param root_element The XML root element of an XML document. - * @param stylesheet_file The (short) name of the stylesheet that is intended + * @param stylesheet_file The (short) name of the style sheet that is intended * to be applied on a particular XML document. * @param error The libopensync error pointer. * - * @returns TRUE, if the stylesheet file is adequate for the given root_element, + * @returns TRUE, if the style sheet file is adequate for the given root_element, * FALSE otherwise. * */ @@ -1954,7 +1955,7 @@ if (!strcmp((char *)root_element->name, "contact")) { if (strcmp(stylesheet_file, STYLESHEET_XMLFORMAT_CONTACT2LDAP_EVOLUTIONPERSON) && (strcmp(stylesheet_file, STYLESHEET_XMLFORMAT_CONTACT2LDAP_INETORGPERSON))) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong stylesheet file. %s() is not prepared to convert this.\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __FILE__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong style sheet file. %s() is not prepared to convert this.\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __FILE__); goto error; } } @@ -1962,7 +1963,7 @@ if (!strcmp((char *)root_element->name, "event")) { if (strcmp(stylesheet_file, STYLESHEET_XMLFORMAT_EVENT2LDAP_EVENT)) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong stylesheet file. %s() is not prepared to convert this.\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __func__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong style sheet file. %s() is not prepared to convert this.\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __func__); goto error; } } @@ -1970,7 +1971,7 @@ if (!strcmp((char *)root_element->name, "todo")) { if (strcmp(stylesheet_file, STYLESHEET_XMLFORMAT_TODO2LDAP_TODO)) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong stylesheet file. %s() is not prepared to convert this.\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __func__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong style sheet file. %s() is not prepared to convert this.\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __func__); goto error; } } @@ -1978,14 +1979,14 @@ if (!strcmp((char *)root_element->name, "note")) { if (strcmp(stylesheet_file, STYLESHEET_XMLFORMAT_NOTE2LDAP_NOTE)) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong stylesheet file. %s() is not prepared to convert this.\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __func__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong style sheet file. %s() is not prepared to convert this.\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __func__); goto error; } } if (!strcmp((char *)root_element->name, FORMAT_LDAP_EVOLUTIONPERSON)) { if (strcmp(stylesheet_file, STYLESHEET_LDAP_EVOLUTIONPERSON2XMLFORMAT_CONTACT)) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong stylesheet file. %s() is not prepared to convert this.\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __func__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong style sheet file. %s() is not prepared to convert this.\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __func__); goto error; } } @@ -1993,7 +1994,7 @@ if (!strcmp((char *)root_element->name, FORMAT_LDAP_INETORGPERSON)) { if (strcmp(stylesheet_file, STYLESHEET_LDAP_INETORGPERSON2XMLFORMAT_CONTACT)) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong stylesheet file. %s() is not prepared to convert this.\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __func__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong style sheet file. %s() is not prepared to convert this.\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __func__); goto error; } } @@ -2001,7 +2002,7 @@ if (!strcmp((char *)root_element->name, FORMAT_LDAP_EVENT)) { if (strcmp(stylesheet_file, STYLESHEET_LDAP_EVENT2XMLFORMAT_EVENT)) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong stylesheet file. %s() is not prepared to convert this.\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __func__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong style sheet file. %s() is not prepared to convert this.\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __func__); goto error; } } @@ -2009,7 +2010,7 @@ if (!strcmp((char *)root_element->name, FORMAT_LDAP_TODO)) { if (strcmp(stylesheet_file, STYLESHEET_LDAP_TODO2XMLFORMAT_TODO)) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong stylesheet file. %s() is not prepared to convert this.\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __func__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong style sheet file. %s() is not prepared to convert this.\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __func__); goto error; } } @@ -2017,7 +2018,7 @@ if (!strcmp((char *)root_element->name, FORMAT_LDAP_NOTE)) { if (strcmp(stylesheet_file, STYLESHEET_LDAP_NOTE2XMLFORMAT_NOTE)) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong stylesheet file. %s() is not prepared to convert this.\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __func__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong style sheet file. %s() is not prepared to convert this.\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __func__); goto error; } } @@ -2052,7 +2053,7 @@ * @param outpsize The will contain the size of the output * @param config ??? * @param userdata ??? - * @param stylesheet_file The particular XSLT stylesheet to be used. + * @param stylesheet_file The particular XSLT style sheet to be used. * @param error if something bad happens and you cannot convert, set the error! * */ @@ -2160,7 +2161,7 @@ } - // Construct an absolute path to the stylesheet file + // Construct an absolute path to the style sheet file path = LDAP_PLUGIN_OPENSYNC_CONFIGDIR; errno = 0; @@ -2177,7 +2178,7 @@ goto error; } - // Load the stylesheet file + // Load the style sheet file stylesheet_ptr = xsltParseStylesheetFile((xmlChar *)fullpath); if (stylesheet_ptr == NULL) { osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: xsltParseStylesheetFile() has failed.\n", __FILE__, __LINE__); @@ -2186,7 +2187,7 @@ // Check whether the root element can be found in the input xmlDoc, - // and whether the stylesheet file to be applied upon it is an + // and whether the style sheet file to be applied upon it is an // adequate one in terms of the related objtype: xmlNode *root_element = xmlDocGetRootElement(input_doc); if (!ldap_format_check_adequate_stylesheet(root_element, stylesheet_file, error)) { @@ -2232,7 +2233,7 @@ if (xmlbuffer_size >= 6) { if (!strncmp((char *)xmlbuffer, "<?xml ", 6)) { #ifdef DEBUG_do_apply_stylesheet - ldap_plugin_printf("%s:%i: Ok. xmlbuffer starts with <?xml.", __FILE__, __LINE__); + ldap_plugin_printf("%s:%i: OK. xmlbuffer starts with <?xml.", __FILE__, __LINE__); #endif } else { osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: xmlbuffer starts with \"%.6s\"\n", __FILE__, __LINE__, xmlbuffer); @@ -2277,7 +2278,7 @@ osync_trace(TRACE_INTERNAL, "%s:%i: xmlformat = %p", __FILE__, __LINE__, xmlformat); - osync_trace(TRACE_INTERNAL, "%s:%i: This needs to be free'd eventually. But by whom? And where and when exactly?", __FILE__, __LINE__); + osync_trace(TRACE_INTERNAL, "%s:%i: This needs to be freed eventually. But by whom? And where and when exactly?", __FILE__, __LINE__); #ifdef DEBUG_do_apply_stylesheet @@ -2660,7 +2661,7 @@ continue; } - // Ok. We have found a subentry. + // OK. We have found a subentry. node2 = node->xmlChildrenNode; if (!node2) { @@ -2668,7 +2669,7 @@ continue; } - // Ok. Subentry has children. + // OK. Subentry has children. if (node2->name == NULL) { osync_trace(TRACE_ERROR, "%s:%i: WARNING: node2->name = NULL. Ignoring.", __FILE__, __LINE__); @@ -2775,7 +2776,7 @@ // Generate an xmlDoc - a rather dumb one. - // This is the xmlDoc the various stylesheets can and must + // This is the xmlDoc the various style sheets can and must // be applied on, in order to get a format understood by other // plugins doc = xmlNewDoc((xmlChar*)"1.0"); @@ -3051,7 +3052,7 @@ if (name[0] == 0) { - osync_trace(TRACE_ERROR, "%s:%i: ERROR: name[0] = 0. i = %u, j = %u, k = %u. Continueing.\n", __FILE__, __LINE__, i, j, k); + osync_trace(TRACE_ERROR, "%s:%i: ERROR: name[0] = 0. i = %u, j = %u, k = %u. Continuing.\n", __FILE__, __LINE__, i, j, k); continue; } @@ -3059,7 +3060,7 @@ // Hmmm. value = NULL does NOT ALWAYS seem to be a problem. Strange... if (value == NULL) { #ifdef DEBUG_convert_ldap2xmlinternal - osync_trace(TRACE_INTERNAL, "%s:%i: WARNING: value = NULL. name = \"%s\". i = %u, j = %u, k = %u. Continueing.\n", __FILE__, __LINE__, name, i, j, k); + osync_trace(TRACE_INTERNAL, "%s:%i: WARNING: value = NULL. name = \"%s\". i = %u, j = %u, k = %u. Continuing.\n", __FILE__, __LINE__, name, i, j, k); #endif continue; } @@ -3421,7 +3422,7 @@ * a distinguished name and a unique identifier in order to become * a complete LDAP entry that can be fed to the libldap API. * - * @param xmlnode The childnode of the XML document, containing elements + * @param xmlnode The child node of the XML document, containing elements * which are supposed to be converted into LDAP entries. * @param objtype The object type in terms of libopensync: "contact", "event", * "todo" or "note". @@ -3429,7 +3430,7 @@ * represents, for example,"ou=addressbook" (for contacts) or * "ou=calendar" or the tasks/todos for the notes. Note: Here in the * format plugin dn will be empty: "". - * @param complex_element_lists Several lists of special xmlnodes, + * @param complex_element_lists Several lists of special XML nodes, * which require special treatment, until a * more general approach has been implemented. * See also ldap_format_add_counter_suffix(). @@ -3440,7 +3441,7 @@ * ldapmods (= one level below "ou=addressbook", for example). * @param error The libopensync error pointer. * - * @returns TRUE on sucess, FALSE in case of any error + * @returns TRUE on success, FALSE in case of any error * */ static osync_bool ldap_format_parse_xmlinternal_child_nodes(xmlNode *xmlnode, const char *objtype, const char *dn, complex_elements *complex_element_lists, GList **potential_subentries, GList **ldapmods, OSyncError **error) @@ -3763,7 +3764,7 @@ * for contacts) or the calendar ("ou=calendar" for events, * for instance) or the tasks/todos or the notes. * Note: Here in the format plugin dn is empty: "". - * @param potential_subentries The resuling list of LDAP subentries. + * @param potential_subentries The resulting list of LDAP subentries. * @param ldap_entries The resulting list of LDAP entries. * @param error The libopensync error pointer. * @@ -4219,7 +4220,7 @@ * @param outpsize Its size. * @param free_input * "You need to set this to TRUE if opensync - * can free the input after the conversion (so you dont + * can free the input after the conversion (so you don't * use any reference from or to the input). An example where * *free_input = FALSE; needs to be done would be an encapsulator * that stores the input reference somewhere in its struct." @@ -4428,7 +4429,7 @@ * * @param free_input * "You need to set this to TRUE if opensync - * can free the input after the conversion (so you dont + * can free the input after the conversion (so you don't * use any reference from or to the input). An example where * *free_input = FALSE; needs to be done would be an encapsulator * that stores the input reference somewhere in its struct." @@ -4487,7 +4488,7 @@ * * @param free_input * "You need to set this to TRUE if opensync - * can free the input after the conversion (so you dont + * can free the input after the conversion (so you don't * use any reference from or to the input). An example where * *free_input = FALSE; needs to be done would be an encapsulator * that stores the input reference somewhere in its struct." @@ -4554,7 +4555,7 @@ * first element of this list. It's a linked list.) * @param free_input Whether or not the input is to be freed, eventually. * "You need to set this to TRUE if opensync - * can free the input after the conversion (so you dont + * can free the input after the conversion (so you don't * use any reference from or to the input). An example where * *free_input = FALSE; needs to be done would be an encapsulator * that stores the input reference somewhere in its struct." @@ -4725,19 +4726,19 @@ /** - * @brief Entry function for converting fromi xmlformat-contact to the + * @brief Entry function for converting from xmlformat-contact to the * ldap-sync plugin internal format. * * @param input The data you need to convert * @param inpsize The size of the input data * @param output This will contain the result of the conversion. It will be - * an OSyncXMLFormat, although being transferred bytewise - * as char *. It needs to be free'd, eventually. + * an OSyncXMLFormat, although being transferred byte wise + * as char *. It needs to be freed, eventually. * But by whom? And where and when, exactly? * @param outpsize The will contain the size of the output * @param free_input * "You need to set this to TRUE if opensync - * can free the input after the conversion (so you dont + * can free the input after the conversion (so you don't * use any reference from or to the input). An example where * *free_input = FALSE; needs to be done would be an encapsulator * that stores the input reference somewhere in its struct." @@ -4796,18 +4797,18 @@ /** - * @brief Entry function for converting fromi xmlformat-contact to the + * @brief Entry function for converting from xmlformat-contact to the * ldap-sync plugin internal format. * * @param input The data you need to convert * @param inpsize The size of the input data * @param output This will contain the result of the conversion. It will be - * an OSyncXMLFormat, that needs to be free'd, eventually. + * an OSyncXMLFormat, that needs to be freed, eventually. * But by whom? And where and when, exactly? * @param outpsize The will contain the size of the output * @param free_input * "You need to set this to TRUE if opensync - * can free the input after the conversion (so you dont + * can free the input after the conversion (so you don't * use any reference from or to the input). An example where * *free_input = FALSE; needs to be done would be an encapsulator * that stores the input reference somewhere in its struct." @@ -4878,7 +4879,7 @@ * * @param free_input * "You need to set this to TRUE if opensync - * can free the input after the conversion (so you dont + * can free the input after the conversion (so you don't * use any reference from or to the input). An example where * *free_input = FALSE; needs to be done would be an encapsulator * that stores the input reference somewhere in its struct." @@ -4932,7 +4933,7 @@ * * @param free_input * "You need to set this to TRUE if opensync - * can free the input after the conversion (so you dont + * can free the input after the conversion (so you don't * use any reference from or to the input). An example where * *free_input = FALSE; needs to be done would be an encapsulator * that stores the input reference somewhere in its struct." @@ -4990,7 +4991,7 @@ * * @param free_input * "You need to set this to TRUE if opensync - * can free the input after the conversion (so you dont + * can free the input after the conversion (so you don't * use any reference from or to the input). An example where * *free_input = FALSE; needs to be done would be an encapsulator * that stores the input reference somewhere in its struct." @@ -5042,7 +5043,7 @@ * * @param free_input * "You need to set this to TRUE if opensync - * can free the input after the conversion (so you dont + * can free the input after the conversion (so you don't * use any reference from or to the input). An example where * *free_input = FALSE; needs to be done would be an encapsulator * that stores the input reference somewhere in its struct." @@ -5104,7 +5105,7 @@ * * @param free_input * "You need to set this to TRUE if opensync - * can free the input after the conversion (so you dont + * can free the input after the conversion (so you don't * use any reference from or to the input). An example where * *free_input = FALSE; needs to be done would be an encapsulator * that stores the input reference somewhere in its struct." @@ -5164,7 +5165,7 @@ * * @param free_input * "You need to set this to TRUE if opensync - * can free the input after the conversion (so you dont + * can free the input after the conversion (so you don't * use any reference from or to the input). An example where * *free_input = FALSE; needs to be done would be an encapsulator * that stores the input reference somewhere in its struct." @@ -5236,21 +5237,21 @@ * * I have disabled this currently, because of * memory errors. The destroy function is called twice, - * even if there is only a single LDAP entry to be free'd. + * even if there is only a single LDAP entry to be freed. * * It seems, that the *input is copied anywhere in the * dungeons of libopensync. Of course, this does not work, * as *input is not just a string that can be copied in a simple way. * It is rather a GList, i.e. a container holding pointers to * a linked list of LDAP entries. Such a list and especially the - * LDAP entries MUST NOT be free'd twice! + * LDAP entries MUST NOT be freed twice! * * Only possible workaround, right now, is disabling the destroy * function completely. Which leads to leaks, of course. * * * @param input This seems to be the GList, that I would have - * free'd in ldap_plugin_get_changes() otherwise. + * freed in ldap_plugin_get_changes() otherwise. * @param inpsize * @param user_data And what is this, anyway??? * @@ -5345,7 +5346,7 @@ * This function can be used to duplicate your format. * Duplication does not mean to make 2 objects out of one, * but to change to uid of the object in such a way that it - * differes from the original uid. + * differs from the original uid. * * Most format will never need this. * @@ -5382,7 +5383,7 @@ * @param user_data ????????? * * @returns a string describing the format data. This string was previously - * a GString and as such it is to be free'd eventually by means of + * a GString and as such it is to be freed eventually by means of * g_string_free(). */ @@ -5425,7 +5426,7 @@ g_string_append_printf(str, "---------\n"); entry = (ldap_entry *)g_list_nth_data(list, i); if (entry == NULL) { - osync_trace(TRACE_ERROR, "%s:%i: ERROR: entry = NULL with i = %u. Ignoringthis LDAP entry.\n", __FILE__, __LINE__, i); + osync_trace(TRACE_ERROR, "%s:%i: ERROR: entry = NULL with i = %u. Ignoring this LDAP entry.\n", __FILE__, __LINE__, i); g_string_append_printf(str, "---------\n"); continue; } @@ -5646,7 +5647,7 @@ * * @param free_input * "You need to set this to TRUE if opensync - * can free the input after the conversion (so you dont + * can free the input after the conversion (so you don't * use any reference from or to the input). An example where * *free_input = FALSE; needs to be done would be an encapsulator * that stores the input reference somewhere in its struct." @@ -5795,7 +5796,7 @@ * @param env Format specific environment * @param error libopensync error pointer. * - * @returns TRUE on sucess, FALSE on error. + * @returns TRUE on success, FALSE on error. */ osync_bool get_conversion_info(OSyncFormatEnv *env, OSyncError **error) { @@ -5812,7 +5813,7 @@ errno = 0; if (stat(path, &stat_buffer)) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Path \"%s\" could not be found: %s. The constant LDAP_PLUGIN_OPENSYNC_CONFIGDIR is not correctly set. Please rerun cmake anc check the resulting config.h for LDAP_PLUGIN_OPENSYNC_CONFIGDIR.\n", __FILE__, __LINE__, path, strerror(errno)); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Path \"%s\" could not be found: %s. The constant LDAP_PLUGIN_OPENSYNC_CONFIGDIR is not correctly set. Please rerun cmake and check the resulting config.h for LDAP_PLUGIN_OPENSYNC_CONFIGDIR.\n", __FILE__, __LINE__, path, strerror(errno)); goto error; } Modified: plugins/ldap-sync/src/ldap_plugin.c ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.c Thu Mar 26 20:38:16 2009 (r5351) +++ plugins/ldap-sync/src/ldap_plugin.c Thu Mar 26 20:39:18 2009 (r5352) @@ -236,9 +236,9 @@ * that pass a "plugin_environment *" instead of "sink_environment *". * * @param ctx The libopensync context. - * @param sink The sink specific environ The sink specific environment The sink specific environment The sink specific environment The sink specific environment The sink specific environment The sink specific environment The sink specific environment The sink specific environment ment - * @param userdata - * @param sinkenv + * @param sink The pointer for an objtype. + * @param userdata The void pointer that is expected to carry sinkenv. + * @param sinkenv The sink specific environment. * @param error The libopensync error pointer. * * @returns TRUE on success, FALSE in case of any error @@ -272,7 +272,7 @@ if (((sink_environment *)userdata)->magic) { - // Unexepected case: magic is empty: + // Unexpected case: magic is empty: if (((sink_environment *)userdata)->magic[0] == 0) { if (((plugin_environment *)userdata)->magic) { if (((plugin_environment *)userdata)->magic[0] == 0) { @@ -301,11 +301,11 @@ for (s = ((plugin_environment *)userdata)->sink_envs; s; s = s->next) { sink_environment *tmp = s->data; if (tmp == NULL) { - osync_trace(TRACE_INTERNAL, "%s:%i: INFO: tmp = NULL. Continueing.", __FILE__, __LINE__); + osync_trace(TRACE_INTERNAL, "%s:%i: INFO: tmp = NULL. Continuing.", __FILE__, __LINE__); continue; } else { if (tmp->sink == NULL) { - osync_trace(TRACE_INTERNAL, "%s:%i: INFO: tmp->sink = NULL. Continueing. ", __FILE__, __LINE__); + osync_trace(TRACE_INTERNAL, "%s:%i: INFO: tmp->sink = NULL. Continuing. ", __FILE__, __LINE__); continue; } else { if (sink == tmp->sink) { @@ -314,7 +314,7 @@ break; } else { - osync_trace(TRACE_INTERNAL, "%s:%i: INFO: sink != tmp->sink. Continueing.", __FILE__, __LINE__); + osync_trace(TRACE_INTERNAL, "%s:%i: INFO: sink != tmp->sink. Continuing.", __FILE__, __LINE__); } } } @@ -568,7 +568,7 @@ * @param config Via this pointer the configuration file can be accessed. * @param error libopensync error pointer * - * @returns TRUE on successfull parsing, FALSE on any error. + * @returns TRUE on successful parsing, FALSE on any error. */ osync_bool ldap_plugin_parse_config(OSyncPluginInfo *info, sink_environment *sinkenv, const char *objtype, OSyncPluginConfig * config, OSyncError **error) @@ -734,7 +734,7 @@ sinkenv->storebase = g_strdup(val); } - // Perhaps I should "hardcode" this: + // Perhaps I should "hard code" this? Not sure... sinkenv->keyattr = (char *)"uid"; } else // For objtype "event" only @@ -774,7 +774,7 @@ sinkenv->storebase = g_strdup(val); } - // Perhaps I should "hardcode" this: + // Perhaps I should "hard code" this? Not sure... sinkenv->keyattr = (char *)"documentIdentifier"; } // For objtype "todo" only @@ -814,7 +814,7 @@ sinkenv->storebase = g_strdup(val); } - // Perhaps I should "hardcode" this: + // Perhaps I should "hard code" this? Not sure... sinkenv->keyattr = (char *)"documentIdentifier"; } // For objtype "note" only @@ -856,7 +856,7 @@ sinkenv->storebase = g_strdup(val); } - // Perhaps I should "hardcode" this: + // Perhaps I should "hard code" this? Not sure... sinkenv->keyattr = (char *)"documentIdentifier"; } @@ -2021,11 +2021,11 @@ - //If you use opensync hashtables you can detect if you need - //to do a slow-sync and set this on the hashtable directly. - //Otherwise you have to make 2 functions like "get_changes" and - //"get_all" and decide which one to use by using - //osync_member_get_slow_sync + // If you use opensync hashtables you can detect if you need + // to do a slow-sync and set this on the hashtable directly. + // Otherwise you have to make 2 functions like "get_changes" and + // "get_all" and decide which one to use by using + // osync_member_get_slow_sync // ----------------- slow-sync ------------------- @@ -2265,7 +2265,7 @@ } /** - * ldaplist_added must be free'd later. + * ldaplist_added must be freed later. * Maybe in the destroy function ldap_format_destroy_format1() * But even this seems to be to early. */ @@ -2279,7 +2279,7 @@ } /** - * ldaplist_modified must be free'd later. + * ldaplist_modified must be freed later. * Maybe in the destroy function ldap_format_destroy_format1() * But even this seems to be too early. */ @@ -2704,7 +2704,7 @@ * @param sinkenv Object specific environment * @param debug_id The identifier. * @param hash This is the hash as calculated before. It is to be checked - * agains the real hash value, as found on the LDAP server. + * against the real hash value, as found on the LDAP server. * @param error The libopensync error pointer. * @returns TRUE if both hash values are equal, FALSE, otherwise. * @@ -2763,7 +2763,7 @@ if (strlen(theoretical_hash) == strlen(actual_hash) && !strcmp(theoretical_hash, actual_hash)) { #ifdef DEBUG_hash - ldap_plugin_printf("%s:%i: Ok. Hash has been built correctly for id = \"%s\"", __FILE__, __LINE__, debug_id); + ldap_plugin_printf("%s:%i: OK. Hash has been built correctly for id = \"%s\"", __FILE__, __LINE__, debug_id); #endif rv = TRUE; } else { @@ -2843,7 +2843,7 @@ } if (result == NULL) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: reult = NULL.\n", __FILE__, __LINE__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: result = NULL.\n", __FILE__, __LINE__); goto error; } @@ -3139,7 +3139,7 @@ ldap_get_option(sinkenv->ld, LDAP_OPT_RESULT_CODE, &result_code); - // Ok. This error is expected. ldap_add_ext_s() is due. + // OK. This error is expected. ldap_add_ext_s() is due. if (result_code == LDAP_NO_SUCH_OBJECT) { #ifdef DEBUG_change_type_modified @@ -3154,7 +3154,7 @@ // Check for possibly missing LDAP_MOD_BVALUES if (!ldap_plugin_check_for_mod_op(entry, &mod_op_rv, error)) { if (!osync_error_is_set(error)) - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: dap_plugin_check_for_mod_op() has failed."); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldap_plugin_check_for_mod_op() has failed."); goto error; } @@ -3201,27 +3201,27 @@ } } else { - // Ok. ldap_search has finished successfully. The LDAP entry is + // OK. ldap_search has finished successfully. The LDAP entry is // present both at the server and the peer's side. // Check for possibly missing LDAP_MOD_BVALUES if (!ldap_plugin_check_for_mod_op(entry, &mod_op_rv, error)) { if (!osync_error_is_set(error)) - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: dap_plugin_check_for_mod_op() has failed."); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldap_plugin_check_for_mod_op() has failed."); goto error; } // Detect any changes in order to keep only those attributes - // in the LDAP entry tha have been modified, rather than all of them. + // in the LDAP entry that have been modified, rather than all of them. ldap_plugin_detect_attribute_changes (ctx, sinkenv, entry, error); // Check for possibly missing LDAP_MOD_BVALUES if (!ldap_plugin_check_for_mod_op(entry, &mod_op_rv, error)) { if (!osync_error_is_set(error)) - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: dap_plugin_check_for_mod_op() has failed."); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldap_plugin_check_for_mod_op() has failed."); goto error; } @@ -3236,7 +3236,7 @@ // the identifier. if (!ldap_plugin_check_for_keyattribute(sinkenv, entry, error)) { if (!osync_error_is_set(error)) - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: dap_plugin_check_for_keyattribute() has failed."); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldap_plugin_check_for_keyattribute() has failed."); goto error; } @@ -3799,7 +3799,7 @@ goto error; } - //Dont forget to answer the call on error + // Don't forget to answer the call on error goto check_commit_status; @@ -3829,7 +3829,7 @@ } - //Dont forget to answer the call on error + //Don't forget to answer the call on error goto check_commit_status; @@ -3859,7 +3859,7 @@ ldap_entries = NULL; - //Dont forget to answer the call on error + //Don't forget to answer the call on error goto check_commit_status; @@ -4647,12 +4647,12 @@ sink_environment *sinkenv = s->data; if (sinkenv == NULL) { - osync_trace(TRACE_INTERNAL, "%s:%i: INFO: sinkenv = NULL. Continueing.\n", __FILE__, __LINE__); + osync_trace(TRACE_INTERNAL, "%s:%i: INFO: sinkenv = NULL. Continuing.\n", __FILE__, __LINE__); continue; } if (sinkenv->sink == NULL) { - osync_trace(TRACE_INTERNAL, "%s:%i: INFO: sinkenv->sink = NULL. Continueing.\n", __FILE__, __LINE__); + osync_trace(TRACE_INTERNAL, "%s:%i: INFO: sinkenv->sink = NULL. Continuing.\n", __FILE__, __LINE__); continue; } Modified: plugins/ldap-sync/src/md5_crypt.c ============================================================================== --- plugins/ldap-sync/src/md5_crypt.c Thu Mar 26 20:38:16 2009 (r5351) +++ plugins/ldap-sync/src/md5_crypt.c Thu Mar 26 20:39:18 2009 (r5352) @@ -114,8 +114,8 @@ /** - * @brief Computates the md5 hash for a string of size size - * @param passwd The string of which we want to know the md5 hash + * @brief Computes the md5 hash for a string of size size. + * @param passwd The string of which we want to know the md5 hash. * @param size The length of this string. * @returns The md5 hash of this string. */ @@ -161,7 +161,7 @@ return NULL; } - // Create hexa string from MD5 digest + // Create hexadecimal string from MD5 digest { unsigned char *digest = gcry_md_read (md5, GCRY_MD_MD5); unsigned int i; @@ -182,7 +182,7 @@ /** - * @brief Caculates an md5 hash of a string of xmlChar's. + * @brief Calculates an md5 hash of a string of xmlChar's. * @param mem The string of which we want to know the md5 hash. * @param len Its length. * @returns The md5 hash of this string. |
From: <svn...@op...> - 2009-03-26 16:54:15
|
Author: bellmich Date: Thu Mar 26 17:54:02 2009 New Revision: 1022 URL: http://libsyncml.opensync.org/changeset/1022 Log: fixed a race condition in the manager_receive test Modified: trunk/tests/check_manager.c Modified: trunk/tests/check_manager.c ============================================================================== --- trunk/tests/check_manager.c Thu Mar 26 17:38:21 2009 (r1021) +++ trunk/tests/check_manager.c Thu Mar 26 17:54:02 2009 (r1022) @@ -218,7 +218,14 @@ usleep(100); } - sml_fail_unless(transport_errors == 0, NULL); + /* If the server disconnects actively without a response + * then the service is unavailable. + * The HTTP server transport sends status 503 in this case. + * This is a transport error. + * If the machine is fast enough or a SMP machine + * then the transport error is signalled fast enough. + */ + sml_fail_unless(transport_errors <= 1, NULL); sml_fail_unless(num_sessions == 0, NULL); sml_fail_unless(num_finals == 0, NULL); sml_fail_unless(num_end == 0, NULL); |
From: <svn...@op...> - 2009-03-26 16:38:28
|
Author: bellmich Date: Thu Mar 26 17:38:21 2009 New Revision: 1021 URL: http://libsyncml.opensync.org/changeset/1021 Log: thread safe queue detach Modified: trunk/libsyncml/sml_transport.c Modified: trunk/libsyncml/sml_transport.c ============================================================================== --- trunk/libsyncml/sml_transport.c Thu Mar 26 16:15:02 2009 (r1020) +++ trunk/libsyncml/sml_transport.c Thu Mar 26 17:38:21 2009 (r1021) @@ -1044,6 +1044,19 @@ } } +static SmlBool smlTransportDetachQueueCallback( + gpointer data, + SmlError **error) +{ + smlTrace(TRACE_ENTRY, "%s", __func__); + CHECK_ERROR_REF + smlAssert(data); + SmlQueue *queue = data; + smlQueueDetach(queue); + smlTrace(TRACE_EXIT, "%s", __func__); + return TRUE; +} + static SmlBool smlTransportDispatchQueueCallback( gpointer data, SmlError **error) @@ -1094,8 +1107,21 @@ tsp->type != SML_TRANSPORT_HTTP_SERVER && tsp->thread) _smlTransportStop(tsp); + /* stop the command queue */ + if (tsp->thread) { + /* HTTP - thread safe destroy */ + if (!smlThreadCallFunction( + tsp->thread, + smlTransportDetachQueueCallback, + tsp->command_queue, + error)) + goto error; + } else { + /* OBEX */ + smlQueueDetach(tsp->command_queue); + } + /* give all jobs a chance to finish cleanly */ - smlQueueDetach(tsp->command_queue); int i = 0; unsigned int queueLength = smlQueueLength(tsp->command_queue); for (; i < queueLength; i++) { |