int main (int argc, char *argv[]) { DBusGConnection *bus; g_type_init (); bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL); compare_ints (); compare_strings (); compare_strv (); compare_garrays (); compare_ptrarrays (); compare_str_hash (); compare_gvalue_hash (); compare_ip6_addresses (); return 0; }
int main(int argc, char *argv[]) { globus_url_t url; int i; int result; globus_bool_t ok; int num_successful = 0; int rc; globus_module_activate(GLOBUS_COMMON_MODULE); globus_libc_printf("Testing globus_url_parse()\n"); if(argc > 1) { globus_libc_printf("Bypassing standard tests, parsing command line arguments\n"); for(i = 1; i < argc; i++) { globus_libc_printf("Parsing \"%s\"\n", argv[i]); result = globus_url_parse(argv[i], &url); globus_libc_printf("Parse returned %d\n", result); if(result == GLOBUS_SUCCESS) { #define printable_string(x) (x==GLOBUS_NULL ? "NULL" : x) globus_libc_printf("url_scheme = \"%s\"\n" "url_scheme_type = %d\n" "user = \"%s\"\n" "password = \"%s\"\n" "host = \"%s\"\n" "port = %u\n" "url_path = \"%s\"\n" "dn = \"%s\"\n" "attributes = \"%s\"\n" "scope = \"%s\"\n" "filter = \"%s\"\n" "url_specific_part = \"%s\"\n", printable_string(url.scheme), url.scheme_type, printable_string(url.user), printable_string(url.password), printable_string(url.host), url.port, printable_string(url.url_path), printable_string(url.dn), printable_string(url.attributes), printable_string(url.scope), printable_string(url.filter), printable_string(url.url_specific_part)); result = globus_url_destroy(&url); globus_libc_printf("globus_url_destroy returned %d\n", result); } } globus_module_deactivate_all(); return 0; } for(i = 0; i < NUM_TESTS; i++) { ok = GLOBUS_TRUE; result = globus_url_parse(test_urls[i].url, &url); if(result != test_urls[i].result) { globus_libc_printf( "test %d: FAILED (url=%s, expected %d, parse returned %d)\n", i+1, test_urls[i].url, test_urls[i].result, result); ok = GLOBUS_FALSE; } if(test_urls[i].result == GLOBUS_SUCCESS) { /* Verify that parse did what we wanted it to do */ if(!compare_strings(url.scheme, test_urls[i].url_result.scheme, i+1, "scheme")) { ok = GLOBUS_FALSE; } if(!compare_ints(url.scheme_type, test_urls[i].url_result.scheme_type, i+1, "scheme_type")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.user, test_urls[i].url_result.user, i+1, "user")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.password, test_urls[i].url_result.password, i+1, "password")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.host, test_urls[i].url_result.host, i+1, "host")) { ok = GLOBUS_FALSE; } if(!compare_ints((int) url.port, (int) test_urls[i].url_result.port, i+1, "port")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.url_path, test_urls[i].url_result.url_path, i+1, "url_path")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.dn, test_urls[i].url_result.dn, i+1, "dn")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.attributes, test_urls[i].url_result.attributes, i+1, "attributes")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.scope, test_urls[i].url_result.scope, i+1, "scope")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.filter, test_urls[i].url_result.filter, i+1, "filter")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.url_specific_part, test_urls[i].url_result.url_specific_part, i+1, "url_specific_part")) { ok = GLOBUS_FALSE; } result = globus_url_destroy(&url); if(result != GLOBUS_SUCCESS) { globus_libc_printf( "test %d: FAILED (could not destroy parsed url)\n", i+1); ok = GLOBUS_FALSE; } } if(ok) { num_successful++; } } globus_libc_printf("------------------------------------\n"); if(num_successful == i) { globus_libc_printf("ALL TESTS SUCCESSFUL\n"); } else { globus_libc_printf("%d OF %d TESTS FAILED\n", i - num_successful, i); } globus_libc_printf("------------------------------------\n"); rc = (num_successful == i) ? 0 : 1; globus_module_deactivate_all(); return rc; }