From: <svn...@op...> - 2009-02-25 16:23:51
|
Author: friedrich.beckmann Date: Wed Feb 25 17:23:43 2009 New Revision: 5274 URL: http://www.opensync.org/changeset/5274 Log: windows port - engine tests and multisync tests did not run on windows. Mainly because the test command is not available in the msys environment. Modified: trunk/tests/engine-tests/check_engine_error.c trunk/tests/support.c trunk/tests/support.h trunk/tests/sync-tests/check_multisync.c Modified: trunk/tests/engine-tests/check_engine_error.c ============================================================================== --- trunk/tests/engine-tests/check_engine_error.c Wed Feb 25 14:58:27 2009 (r5273) +++ trunk/tests/engine-tests/check_engine_error.c Wed Feb 25 17:23:43 2009 (r5274) @@ -433,7 +433,8 @@ fail_unless(!synchronize_once(engine, &error), NULL); fail_unless(error != NULL, NULL); osync_error_unref(&error); - + + fail_unless(osync_engine_finalize(engine, &error), NULL); osync_engine_unref(engine); osync_group_unref(group); g_free(formatdir); @@ -576,12 +577,12 @@ fail_unless(num_engine_errors == 1, NULL); osync_error_unref(&error); - - osync_engine_unref(engine); + fail_unless(osync_engine_finalize(engine, &error), NULL); + osync_engine_unref(engine); osync_group_unref(group); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); + fail_unless(!osync_testing_diff("data1", "data2")); g_free(formatdir); g_free(plugindir); @@ -635,7 +636,7 @@ osync_engine_finalize(engine, &error); osync_engine_unref(engine); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); + fail_unless(!osync_testing_diff("data1", "data2")); g_free(formatdir); g_free(plugindir); @@ -687,9 +688,8 @@ osync_error_unref(&error); osync_engine_finalize(engine, &error); osync_engine_unref(engine); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); + fail_unless(!osync_testing_diff("data1", "data2")); g_free(formatdir); g_free(plugindir); @@ -741,7 +741,7 @@ osync_engine_finalize(engine, &error); osync_engine_unref(engine); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); + fail_unless(!osync_testing_diff("data1", "data2")); g_free(formatdir); g_free(plugindir); @@ -794,7 +794,7 @@ fail_unless(num_engine_errors == 1, NULL); fail_unless(num_client_disconnected == 2, NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); + fail_unless(!osync_testing_diff("data1", "data2")); g_free(formatdir); g_free(plugindir); @@ -908,7 +908,7 @@ 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(!osync_testing_diff("data1", "data2")); g_free(formatdir); g_free(plugindir); @@ -967,7 +967,7 @@ fail_unless(num_engine_errors == 1, "Number of Engine Errors: %u Expected: 1", num_engine_errors); fail_unless(num_engine_successful == 0, NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); + fail_unless(!osync_testing_diff("data1", "data2")); g_free(formatdir); g_free(plugindir); @@ -1023,7 +1023,7 @@ 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(!osync_testing_diff("data1", "data2")); g_free(formatdir); g_free(plugindir); @@ -1080,7 +1080,7 @@ 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(!osync_testing_diff("data1", "data2")); g_free(formatdir); g_free(plugindir); @@ -1138,7 +1138,7 @@ fail_unless(num_engine_successful == 0, NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); + fail_unless(!osync_testing_diff("data1", "data2")); g_free(formatdir); g_free(plugindir); @@ -1198,7 +1198,7 @@ fail_unless(num_engine_successful == 0, NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); + fail_unless(!osync_testing_diff("data1", "data2")); g_free(formatdir); g_free(plugindir); @@ -1256,7 +1256,7 @@ fail_unless(num_engine_successful == 0, NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); + fail_unless(!osync_testing_diff("data1", "data2")); g_free(formatdir); g_free(plugindir); @@ -1314,7 +1314,7 @@ fail_unless(num_engine_successful == 0, NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); + fail_unless(!osync_testing_diff("data1", "data2")); g_free(formatdir); g_free(plugindir); @@ -1375,7 +1375,7 @@ 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(!osync_testing_diff("data1", "data2")); g_free(formatdir); g_free(plugindir); @@ -1437,7 +1437,7 @@ 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(!osync_testing_diff("data1", "data2")); g_free(formatdir); g_free(plugindir); @@ -1506,7 +1506,7 @@ 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(!osync_testing_diff("data1", "data2")); g_free(formatdir); g_free(plugindir); @@ -1571,7 +1571,7 @@ fail_unless(num_engine_successful == 0, NULL); fail_unless(osync_testing_diff("data1", "data2")); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" != \"x\""), NULL); + fail_unless(!osync_testing_diff("data1", "data3")); g_free(formatdir); g_free(plugindir); @@ -1631,8 +1631,8 @@ 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(!osync_testing_diff("data1", "data2")); + fail_unless(!osync_testing_diff("data1", "data3")); g_free(formatdir); g_free(plugindir); @@ -1695,7 +1695,7 @@ fail_unless(num_engine_successful == 0, NULL); fail_unless(osync_testing_diff("data1", "data2")); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" != \"x\""), NULL); + fail_unless(!osync_testing_diff("data1", "data3")); g_free(formatdir); g_free(plugindir); @@ -1757,8 +1757,8 @@ 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(!osync_testing_diff("data1", "data2")); + fail_unless(!osync_testing_diff("data1", "data3")); g_free(formatdir); g_free(plugindir); @@ -1821,8 +1821,8 @@ 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(!osync_testing_diff("data1", "data2")); + fail_unless(!osync_testing_diff("data1", "data3")); g_free(formatdir); g_free(plugindir); @@ -1885,8 +1885,8 @@ 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(!osync_testing_diff("data1", "data2")); + fail_unless(!osync_testing_diff("data1", "data3")); g_free(formatdir); g_free(plugindir); @@ -1958,8 +1958,8 @@ 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(!osync_testing_diff("data1", "data2")); + fail_unless(!osync_testing_diff("data1", "data3")); fail_unless(osync_testing_diff("data2", "data3")); g_free(formatdir); @@ -2032,8 +2032,8 @@ 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(!osync_testing_diff("data1", "data2")); + fail_unless(!osync_testing_diff("data1", "data3")); fail_unless(osync_testing_diff("data2", "data3")); g_free(formatdir); @@ -2956,8 +2956,8 @@ 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); + fail_unless(!osync_testing_diff("data1", "data2")); + fail_unless(!osync_testing_diff("data1", "data3")); g_free(formatdir); g_free(plugindir); Modified: trunk/tests/support.c ============================================================================== --- trunk/tests/support.c Wed Feb 25 14:58:27 2009 (r5273) +++ trunk/tests/support.c Wed Feb 25 17:23:43 2009 (r5274) @@ -771,6 +771,18 @@ return !ret; } +/** + * @brief Test if the directory is empty + */ +osync_bool osync_testing_directory_is_empty(const char *dirname) +{ + gchar *cmd; + int ret; + cmd = g_strdup_printf("ls %s | grep \".*\"", dirname); + ret = system(cmd); + return (ret != 0); +} + /** @brief Creates a simple OSyncPluginConfig with a single resource. * If config is not null the resource information gets added. * Modified: trunk/tests/support.h ============================================================================== --- trunk/tests/support.h Wed Feb 25 14:58:27 2009 (r5273) +++ trunk/tests/support.h Wed Feb 25 17:23:43 2009 (r5274) @@ -130,6 +130,7 @@ osync_bool osync_testing_file_chmod(const char *file, int mode); osync_bool osync_testing_file_copy(const char *source, const char *dest); osync_bool osync_testing_diff(const char *file1, const char *file2); +osync_bool osync_testing_directory_is_empty(const char *dirname); /* Plugin config helper */ OSyncPluginConfig *simple_plugin_config(OSyncPluginConfig *config, const char *path, const char *objtype, const char *objformat, const char *format_config); Modified: trunk/tests/sync-tests/check_multisync.c ============================================================================== --- trunk/tests/sync-tests/check_multisync.c Wed Feb 25 14:58:27 2009 (r5273) +++ trunk/tests/sync-tests/check_multisync.c Wed Feb 25 17:23:43 2009 (r5274) @@ -43,8 +43,8 @@ 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); + fail_unless(osync_testing_diff("data1", "data2")); + fail_unless(osync_testing_diff("data1", "data3")); /* Client checks */ fail_unless(num_client_connected == 3, NULL); @@ -146,8 +146,8 @@ fail_unless(osync_engine_synchronize_and_block(engine, &error), NULL); fail_unless(error == NULL, 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")); /* Client checks */ fail_unless(num_client_connected == 3, NULL); @@ -221,19 +221,22 @@ path = g_strdup_printf("%s/configs/group/1/hashtable.db", testbed); table = hashtable_load(path, "mockobjtype1", 0); + osync_hashtable_unref(table); g_free(path); path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed); table = hashtable_load(path, "mockobjtype1", 0); + osync_hashtable_unref(table); g_free(path); path = g_strdup_printf("%s/configs/group/3/hashtable.db", testbed); table = hashtable_load(path, "mockobjtype1", 0); + osync_hashtable_unref(table); g_free(path); - 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); + fail_unless(osync_testing_directory_is_empty("data1"), NULL); + fail_unless(osync_testing_directory_is_empty("data2"), NULL); + fail_unless(osync_testing_directory_is_empty("data3"), NULL); destroy_testbed(testbed); } @@ -278,8 +281,8 @@ fail_unless(osync_engine_synchronize_and_block(engine, &error), NULL); fail_unless(error == NULL, 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")); /* Client checks */ fail_unless(num_client_connected == 3, NULL); @@ -353,20 +356,23 @@ path = g_strdup_printf("%s/configs/group/1/hashtable.db", testbed); table = hashtable_load(path, "mockobjtype1", 0); + osync_hashtable_unref(table); g_free(path); path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed); table = hashtable_load(path, "mockobjtype1", 0); + osync_hashtable_unref(table); g_free(path); path = g_strdup_printf("%s/configs/group/3/hashtable.db", testbed); table = hashtable_load(path, "mockobjtype1", 0); + osync_hashtable_unref(table); g_free(path); - 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); - + fail_unless(osync_testing_directory_is_empty("data1"), NULL); + fail_unless(osync_testing_directory_is_empty("data2"), NULL); + fail_unless(osync_testing_directory_is_empty("data3"), NULL); + destroy_testbed(testbed); } @@ -388,8 +394,8 @@ 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_written == 2, NULL); fail_unless(num_read == 1, NULL); |