From 2b0de6b7de7537c7d36ab33a7e5cf0e274ea3e23 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Mon, 17 Feb 2014 22:29:44 -0500 Subject: tests: skip individual tests rather than whole test programs Use g_skip_test() to skip individual tests rather than just returning status 77 from the test program as a whole. In several cases, we still end up skipping more than necessary, due to test cases that need to be split up more. Remove the "MISSING_REGRESSION_TESTS_PACKAGES" functionality, since the skipped tests are now pointed out explicitly. --- configure.ac | 29 ---------------------------- tests/Makefile.am | 5 ----- tests/auth-test.c | 28 +++++++++++++++------------ tests/connection-test.c | 12 ++++-------- tests/forms-test.c | 27 ++++++++++++++------------ tests/ntlm-test.c | 14 ++++++++++---- tests/proxy-test.c | 22 ++++++++------------- tests/pull-api.c | 24 +++++++++++------------ tests/range-test.c | 14 ++------------ tests/server-auth-test.c | 17 +++++----------- tests/ssl-test.c | 27 ++++++++++++++++---------- tests/test-utils.h | 18 +++++++++++++++++ tests/timeout-test.c | 13 ++++--------- tests/xmlrpc-server-test.c | 12 ------------ tests/xmlrpc-test.c | 48 +++++++++++++++++++++++++++++++--------------- 15 files changed, 144 insertions(+), 166 deletions(-) diff --git a/configure.ac b/configure.ac index defe54b8..e216c99f 100644 --- a/configure.ac +++ b/configure.ac @@ -184,11 +184,6 @@ dnl ****************************** dnl *** Stuff for regression tests dnl ****************************** AC_MSG_NOTICE([checking for programs needed for regression tests]) -MISSING_REGRESSION_TEST_PACKAGES="" - -if test "$have_glib_networking" = "no"; then - MISSING_REGRESSION_TEST_PACKAGES="$MISSING_REGRESSION_TEST_PACKAGES glib-networking" -fi AC_ARG_WITH(apache-httpd, AS_HELP_STRING([--with-apache-httpd], [Path to apache httpd (for tests)]), @@ -256,16 +251,8 @@ if test "$APACHE_HTTPD" != "no" -a -n "$APACHE_MODULE_DIR" -a -n "$APACHE_SSL_MO AC_DEFINE(HAVE_APACHE_2_4, 1, [Apache is 2.4.x]) fi have_apache=1 - if test -z "$APACHE_PHP_MODULE_DIR"; then - MISSING_REGRESSION_TEST_PACKAGES="$MISSING_REGRESSION_TEST_PACKAGES mod_php5" - fi else have_apache=0 - if test "$APACHE_HTTPD" = "no" -o -z "$APACHE_MODULE_DIR"; then - MISSING_REGRESSION_TEST_PACKAGES="$MISSING_REGRESSION_TEST_PACKAGES apache" - else - MISSING_REGRESSION_TEST_PACKAGES="$MISSING_REGRESSION_TEST_PACKAGES mod_ssl" - fi fi AM_CONDITIONAL(HAVE_APACHE, test "$have_apache" = 1) AM_CONDITIONAL(HAVE_APACHE_2_2, test "$apache_version" = 2.2) @@ -281,7 +268,6 @@ if test "$have_apache" = 1; then else have_php=no IF_HAVE_PHP="\#" - MISSING_REGRESSION_TEST_PACKAGES="$MISSING_REGRESSION_TEST_PACKAGES php5" fi AC_MSG_RESULT($have_php) AC_SUBST(IF_HAVE_PHP) @@ -290,7 +276,6 @@ if test "$have_apache" = 1; then AC_MSG_CHECKING([for php-xmlrpc]) if $PHP --rf xmlrpc_server_create | grep -q "does not exist"; then have_php_xmlrpc=no - MISSING_REGRESSION_TEST_PACKAGES="$MISSING_REGRESSION_TEST_PACKAGES php-xmlrpc" else have_php_xmlrpc=yes AC_DEFINE(HAVE_PHP_XMLRPC, 1, [Have php-xmlrpc]) @@ -302,13 +287,8 @@ fi AC_PATH_PROG(CURL, curl, no) if test "$CURL" != no; then AC_DEFINE(HAVE_CURL, 1, [Whether or not curl can be used for tests]) -else - MISSING_REGRESSION_TEST_PACKAGES="$MISSING_REGRESSION_TEST_PACKAGES curl" fi -AC_SUBST(MISSING_REGRESSION_TEST_PACKAGES) -AM_CONDITIONAL(MISSING_REGRESSION_TEST_PACKAGES, test -n "$MISSING_REGRESSION_TEST_PACKAGES") - dnl ********************************************************** dnl *** path of NTLM single-sign-on helper ntlm_auth dnl ********************************************************** @@ -322,8 +302,6 @@ if test "$ntlm_auth" != "no"; then dnl --with-ntlm-auth (without path) used, use default path ntlm_auth="/usr/bin/ntlm_auth" fi -else - MISSING_REGRESSION_TEST_PACKAGES="$MISSING_REGRESSION_TEST_PACKAGES ntlm_auth" fi AC_SUBST(ntlm_auth) AC_DEFINE_UNQUOTED(NTLM_AUTH, "$ntlm_auth", [Samba's 'winbind' daemon helper 'ntlm_auth' which can be used for NTLM single-sign-on]) @@ -367,10 +345,3 @@ AC_CONFIG_FILES([ libsoup/soup-version.h ]) AC_OUTPUT - -if test -n "$MISSING_REGRESSION_TEST_PACKAGES"; then - echo "" - echo Some regression tests will not be run due to missing packages: - echo $MISSING_REGRESSION_TEST_PACKAGES - echo "" -fi diff --git a/tests/Makefile.am b/tests/Makefile.am index d9ede804..a8b9d019 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -112,11 +112,6 @@ check: start-httpd check-local: check-TESTS @$(MAKE) kill-httpd -if MISSING_REGRESSION_TEST_PACKAGES - @echo "" - @echo "NOTE: some tests were not run due to missing packages:" $(MISSING_REGRESSION_TEST_PACKAGES) - @echo "" -endif .PHONY: start-httpd kill-httpd diff --git a/tests/auth-test.c b/tests/auth-test.c index c1825205..35b05cc7 100644 --- a/tests/auth-test.c +++ b/tests/auth-test.c @@ -2,8 +2,6 @@ #include "test-utils.h" -#ifdef HAVE_APACHE - static const char *base_uri; static GMainLoop *loop; @@ -294,6 +292,8 @@ do_pipelined_auth_test (void) char *uri; int i; + SOUP_TEST_SKIP_IF_NO_APACHE; + debug_printf (1, "Testing pipelined auth (bug 271540):\n"); session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL); @@ -445,6 +445,8 @@ do_digest_expiration_test (void) SoupSession *session; char *uri; + SOUP_TEST_SKIP_IF_NO_APACHE; + debug_printf (1, "\nTesting digest nonce expiration:\n"); session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL); @@ -549,6 +551,8 @@ do_async_auth_test (void) int remaining; gboolean been_there; + SOUP_TEST_SKIP_IF_NO_APACHE; + debug_printf (1, "\nTesting async auth:\n"); loop = g_main_loop_new (NULL, TRUE); @@ -820,6 +824,8 @@ do_select_auth_test (void) SoupAuthDomain *basic_auth_domain, *digest_auth_domain; SoupURI *uri; + SOUP_TEST_SKIP_IF_NO_APACHE; + debug_printf (1, "\nTesting selection among multiple auths:\n"); /* It doesn't seem to be possible to configure Apache to serve @@ -976,6 +982,8 @@ do_auth_close_test (void) SoupURI *uri; AuthCloseData acd; + SOUP_TEST_SKIP_IF_NO_APACHE; + debug_printf (1, "\nTesting auth when server times out connection:\n"); server = soup_test_server_new (FALSE); @@ -1033,6 +1041,8 @@ do_infinite_auth_test (void) char *uri; int timeout; + SOUP_TEST_SKIP_IF_NO_APACHE; + debug_printf (1, "\nTesting broken infinite-loop auth:\n"); session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL); @@ -1089,6 +1099,8 @@ do_disappearing_auth_test (void) SoupSession *session; int counter; + SOUP_TEST_SKIP_IF_NO_APACHE; + debug_printf (1, "\nTesting auth when server does not repeat challenge on failure:\n"); server = soup_test_server_new (FALSE); @@ -1164,6 +1176,8 @@ do_batch_tests (gconstpointer data) guint signal; int i; + SOUP_TEST_SKIP_IF_NO_APACHE; + session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL); base = soup_uri_new (base_uri); @@ -1246,13 +1260,3 @@ main (int argc, char **argv) test_cleanup (); return ret; } - -#else /* HAVE_APACHE */ - -int -main (int argc, char **argv) -{ - return 77; /* SKIP */ -} - -#endif diff --git a/tests/connection-test.c b/tests/connection-test.c index 3dd2cae5..f092944b 100644 --- a/tests/connection-test.c +++ b/tests/connection-test.c @@ -621,8 +621,6 @@ do_non_idempotent_connection_test (void) soup_test_session_abort_unref (session); } -#ifdef HAVE_APACHE - #define HTTP_SERVER "http://127.0.0.1:47524" #define HTTPS_SERVER "https://127.0.0.1:47525" #define HTTP_PROXY "http://127.0.0.1:47526" @@ -724,6 +722,8 @@ do_connection_state_test (void) { SoupSession *session; + SOUP_TEST_SKIP_IF_NO_APACHE; + debug_printf (1, "\nConnection states\n"); debug_printf (1, " Async session\n"); @@ -832,6 +832,8 @@ do_connection_event_test (void) { SoupSession *session; + SOUP_TEST_SKIP_IF_NO_APACHE; + debug_printf (1, "\nConnection events\n"); debug_printf (1, " Async session\n"); @@ -845,17 +847,13 @@ do_connection_event_test (void) soup_test_session_abort_unref (session); } -#endif - int main (int argc, char **argv) { int ret; test_init (argc, argv, NULL); -#ifdef HAVE_APACHE apache_init (); -#endif server = soup_test_server_new (TRUE); soup_server_add_handler (server, NULL, server_callback, "http", NULL); @@ -867,10 +865,8 @@ main (int argc, char **argv) g_test_add_func ("/connection/max-conns", do_max_conns_test); g_test_add_func ("/connection/non-persistent", do_non_persistent_connection_test); g_test_add_func ("/connection/non-idempotent", do_non_idempotent_connection_test); -#ifdef HAVE_APACHE g_test_add_func ("/connection/state", do_connection_state_test); g_test_add_func ("/connection/event", do_connection_event_test); -#endif ret = g_test_run (); diff --git a/tests/forms-test.c b/tests/forms-test.c index da71569b..6e6334f4 100644 --- a/tests/forms-test.c +++ b/tests/forms-test.c @@ -5,8 +5,6 @@ #include "test-utils.h" -#ifdef HAVE_CURL - static struct { const char *title, *name; const char *result; @@ -92,6 +90,11 @@ do_hello_tests (gconstpointer uri) { int n; +#ifndef HAVE_CURL + g_test_skip ("/usr/bin/curl is not available"); + return; +#endif + debug_printf (1, "Hello tests (GET, application/x-www-form-urlencoded)\n"); for (n = 0; n < G_N_ELEMENTS (tests); n++) { do_hello_test (n, FALSE, uri); @@ -179,6 +182,11 @@ do_md5_tests (gconstpointer uri) gsize length; GError *error = NULL; +#ifndef HAVE_CURL + g_test_skip ("/usr/bin/curl is not available"); + return; +#endif + debug_printf (1, "\nMD5 tests (POST, multipart/form-data)\n"); if (!g_file_get_contents (MD5_TEST_FILE, &contents, &length, &error)) { @@ -204,6 +212,11 @@ do_form_decode_test (void) const gchar *value; gchar *tmp; +#ifndef HAVE_CURL + g_test_skip ("/usr/bin/curl is not available"); + return; +#endif + debug_printf (1, "\nDecode tests\n"); /* Test that the code handles multiple values with the same key. */ @@ -432,13 +445,3 @@ main (int argc, char **argv) test_cleanup (); return ret; } - -#else /* HAVE_CURL */ - -int -main (int argc, char **argv) -{ - return 77; /* SKIP */ -} - -#endif diff --git a/tests/ntlm-test.c b/tests/ntlm-test.c index 0fa4b478..e05213af 100644 --- a/tests/ntlm-test.c +++ b/tests/ntlm-test.c @@ -456,12 +456,16 @@ do_builtin_ntlm_test (gconstpointer data) do_ntlm_tests (uri, TRUE); } -#ifdef USE_NTLM_AUTH static void do_winbind_ntlm_test (gconstpointer data) { SoupURI *uri = (SoupURI *)data; +#ifndef USE_NTLM_AUTH + g_test_skip ("/usr/bin/ntlm_auth is not available"); + return; +#endif + /* Samba winbind /usr/bin/ntlm_auth helper support (via a * helper program that emulates its interface). */ @@ -477,6 +481,11 @@ do_fallback_ntlm_test (gconstpointer data) { SoupURI *uri = (SoupURI *)data; +#ifndef USE_NTLM_AUTH + g_test_skip ("/usr/bin/ntlm_auth is not available"); + return; +#endif + /* Support for when ntlm_auth is installed, but the user has * no cached credentials (and thus we have to fall back to * libsoup's built-in NTLM support). @@ -487,7 +496,6 @@ do_fallback_ntlm_test (gconstpointer data) g_setenv ("SOUP_NTLM_AUTH_DEBUG_NOCREDS", "1", TRUE); do_ntlm_tests (uri, TRUE); } -#endif static void retry_test_authenticate (SoupSession *session, SoupMessage *msg, @@ -582,10 +590,8 @@ main (int argc, char **argv) soup_uri_set_port (uri, soup_server_get_port (server)); g_test_add_data_func ("/ntlm/builtin", uri, do_builtin_ntlm_test); -#ifdef USE_NTLM_AUTH g_test_add_data_func ("/ntlm/winbind", uri, do_winbind_ntlm_test); g_test_add_data_func ("/ntlm/fallback", uri, do_fallback_ntlm_test); -#endif g_test_add_data_func ("/ntlm/retry", uri, do_retrying_test); ret = g_test_run (); diff --git a/tests/proxy-test.c b/tests/proxy-test.c index ceb2ff37..423a5598 100644 --- a/tests/proxy-test.c +++ b/tests/proxy-test.c @@ -2,8 +2,6 @@ #include "test-utils.h" -#ifdef HAVE_APACHE - typedef struct { const char *explanation; const char *url; @@ -231,6 +229,8 @@ do_async_proxy_test (gconstpointer data) { SoupProxyTest *test = (SoupProxyTest *)data; + SOUP_TEST_SKIP_IF_NO_APACHE; + do_proxy_test (test, FALSE); } @@ -239,6 +239,8 @@ do_sync_proxy_test (gconstpointer data) { SoupProxyTest *test = (SoupProxyTest *)data; + SOUP_TEST_SKIP_IF_NO_APACHE; + do_proxy_test (test, TRUE); } @@ -260,6 +262,8 @@ do_proxy_fragment_test (gconstpointer data) SoupURI *proxy_uri, *req_uri; SoupMessage *msg; + SOUP_TEST_SKIP_IF_NO_APACHE; + debug_printf (1, "\nTesting request with fragment via proxy\n"); proxy_uri = soup_uri_new (proxies[SIMPLE_PROXY]); @@ -286,8 +290,8 @@ do_proxy_redirect_test (void) SoupURI *proxy_uri, *req_uri, *new_uri; SoupMessage *msg; - if (!tls_available) - return; + SOUP_TEST_SKIP_IF_NO_APACHE; + SOUP_TEST_SKIP_IF_NO_TLS; debug_printf (1, "\nTesting redirection through proxy\n"); @@ -358,13 +362,3 @@ main (int argc, char **argv) test_cleanup (); return ret; } - -#else /* HAVE_APACHE */ - -int -main (int argc, char **argv) -{ - return 77; /* SKIP */ -} - -#endif diff --git a/tests/pull-api.c b/tests/pull-api.c index 8060646b..2915b9e4 100644 --- a/tests/pull-api.c +++ b/tests/pull-api.c @@ -2,8 +2,6 @@ #include "test-utils.h" -#ifdef HAVE_APACHE - static SoupBuffer *correct_response; static void @@ -14,6 +12,7 @@ authenticate (SoupSession *session, SoupMessage *msg, soup_auth_authenticate (auth, "user2", "realm2"); } +#if HAVE_APACHE static void get_correct_response (const char *uri) { @@ -34,6 +33,7 @@ get_correct_response (const char *uri) g_object_unref (msg); soup_test_session_abort_unref (session); } +#endif /* Pull API version 1: fully-async. More like a "poke" API. Rather * than having SoupMessage emit "got_chunk" signals whenever it wants, @@ -234,6 +234,8 @@ do_fast_async_test (gconstpointer data) const char *base_uri = data; SoupSession *session; + SOUP_TEST_SKIP_IF_NO_APACHE; + session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL); g_signal_connect (session, "authenticate", G_CALLBACK (authenticate), NULL); @@ -252,6 +254,8 @@ do_slow_async_test (gconstpointer data) const char *base_uri = data; SoupSession *session; + SOUP_TEST_SKIP_IF_NO_APACHE; + session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL); g_signal_connect (session, "authenticate", G_CALLBACK (authenticate), NULL); @@ -485,6 +489,8 @@ do_sync_async_test (gconstpointer data) const char *base_uri = data; SoupSession *session; + SOUP_TEST_SKIP_IF_NO_APACHE; + session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL); g_signal_connect (session, "authenticate", G_CALLBACK (authenticate), NULL); @@ -508,7 +514,9 @@ main (int argc, char **argv) apache_init (); base_uri = "http://127.0.0.1:47524/"; +#if HAVE_APACHE get_correct_response (base_uri); +#endif g_test_add_data_func ("/pull-api/async/fast", base_uri, do_fast_async_test); g_test_add_data_func ("/pull-api/async/slow", base_uri, do_slow_async_test); @@ -516,18 +524,10 @@ main (int argc, char **argv) ret = g_test_run (); +#if HAVE_APACHE soup_buffer_free (correct_response); +#endif test_cleanup (); return ret; } - -#else /* HAVE_APACHE */ - -int -main (int argc, char **argv) -{ - return 77; /* SKIP */ -} - -#endif diff --git a/tests/range-test.c b/tests/range-test.c index 4d008d46..c23ba462 100644 --- a/tests/range-test.c +++ b/tests/range-test.c @@ -2,8 +2,6 @@ #include "test-utils.h" -#ifdef HAVE_APACHE - SoupBuffer *full_response; int total_length; char *test_response; @@ -332,6 +330,8 @@ do_apache_range_test (void) { SoupSession *session; + SOUP_TEST_SKIP_IF_NO_APACHE; + session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL); #if HAVE_APACHE_2_2 @@ -397,13 +397,3 @@ main (int argc, char **argv) test_cleanup (); return ret; } - -#else /* HAVE_APACHE */ - -int -main (int argc, char **argv) -{ - return 77; /* SKIP */ -} - -#endif diff --git a/tests/server-auth-test.c b/tests/server-auth-test.c index 77a5dba1..b5580c82 100644 --- a/tests/server-auth-test.c +++ b/tests/server-auth-test.c @@ -5,8 +5,6 @@ #include "test-utils.h" -#ifdef HAVE_CURL - static struct { gboolean client_sent_basic, client_sent_digest; gboolean server_requested_basic, server_requested_digest; @@ -106,6 +104,11 @@ do_auth_tests (gconstpointer data) gboolean use_basic, use_digest, good_user, good_password; gboolean preemptive_basic, good_auth; +#ifndef HAVE_CURL + g_test_skip ("/usr/bin/curl is not available"); + return; +#endif + for (i = 0; i < 16; i++) { use_basic = (i & 1) == 1; use_digest = (i & 2) == 2; @@ -344,13 +347,3 @@ main (int argc, char **argv) test_cleanup (); return ret; } - -#else /* HAVE_CURL */ - -int -main (int argc, char **argv) -{ - return 77; /* SKIP */ -} - -#endif diff --git a/tests/ssl-test.c b/tests/ssl-test.c index 753a980c..3eb61af1 100644 --- a/tests/ssl-test.c +++ b/tests/ssl-test.c @@ -28,6 +28,8 @@ do_async_properties_tests (gconstpointer uri) { SoupSession *session; + SOUP_TEST_SKIP_IF_NO_TLS; + session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL); g_object_set (G_OBJECT (session), SOUP_SESSION_SSL_CA_FILE, "/dev/null", @@ -42,6 +44,8 @@ do_sync_properties_tests (gconstpointer uri) { SoupSession *session; + SOUP_TEST_SKIP_IF_NO_TLS; + session = soup_test_session_new (SOUP_TYPE_SESSION_SYNC, NULL); g_object_set (G_OBJECT (session), SOUP_SESSION_SSL_CA_FILE, "/dev/null", @@ -101,6 +105,8 @@ do_strict_tests (gconstpointer uri) { SoupSession *session; + SOUP_TEST_SKIP_IF_NO_TLS; + debug_printf (1, "\nstrict/nonstrict\n"); session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL); @@ -143,6 +149,8 @@ do_session_property_tests (void) char *ca_file; SoupSession *session; + SOUP_TEST_SKIP_IF_NO_TLS; + debug_printf (1, "session properties\n"); session = soup_session_async_new (); @@ -251,16 +259,13 @@ main (int argc, char **argv) test_init (argc, argv, NULL); - if (!tls_available) { - test_cleanup (); - return 77; /* SKIP */ + if (tls_available) { + server = soup_test_server_new_ssl (TRUE); + soup_server_add_handler (server, NULL, server_handler, NULL, NULL); + uri = g_strdup_printf ("https://127.0.0.1:%u/", + soup_server_get_port (server)); } - server = soup_test_server_new_ssl (TRUE); - soup_server_add_handler (server, NULL, server_handler, NULL, NULL); - uri = g_strdup_printf ("https://127.0.0.1:%u/", - soup_server_get_port (server)); - g_test_add_func ("/ssl/session-properties", do_session_property_tests); g_test_add_data_func ("/ssl/message-properties/async", uri, do_async_properties_tests); g_test_add_data_func ("/ssl/message-properties/sync", uri, do_sync_properties_tests); @@ -270,8 +275,10 @@ main (int argc, char **argv) ret = g_test_run (); - g_free (uri); - soup_test_server_quit_unref (server); + if (tls_available) { + g_free (uri); + soup_test_server_quit_unref (server); + } test_cleanup (); return ret; diff --git a/tests/test-utils.h b/tests/test-utils.h index 315d1117..03637dcf 100644 --- a/tests/test-utils.h +++ b/tests/test-utils.h @@ -17,11 +17,29 @@ void test_cleanup (void); extern int debug_level; extern gboolean tls_available; +extern gboolean apache_available; void debug_printf (int level, const char *format, ...) G_GNUC_PRINTF (2, 3); +#define SOUP_TEST_SKIP_IF_NO_TLS \ + G_STMT_START { \ + if (!tls_available) { \ + g_test_skip ("TLS is not available"); \ + return; \ + } \ + } G_STMT_END + #ifdef HAVE_APACHE void apache_init (void); void apache_cleanup (void); +#define SOUP_TEST_SKIP_IF_NO_APACHE +#else +#define apache_init() +#define apache_cleanup() +#define SOUP_TEST_SKIP_IF_NO_APACHE \ + G_STMT_START { \ + g_test_skip ("apache is not available"); \ + return; \ + } G_STMT_END #endif typedef enum { diff --git a/tests/timeout-test.c b/tests/timeout-test.c index fba515db..48c672bf 100644 --- a/tests/timeout-test.c +++ b/tests/timeout-test.c @@ -208,10 +208,7 @@ do_async_timeout_tests (gconstpointer data) gboolean extra_slow; if (g_str_has_prefix (fast_uri, "https")) { - if (!tls_available) { - g_test_skip ("TLS not available"); - return; - } + SOUP_TEST_SKIP_IF_NO_TLS; extra_slow = slow_https; } else @@ -252,10 +249,7 @@ do_sync_timeout_tests (gconstpointer data) gboolean extra_slow; if (g_str_has_prefix (fast_uri, "https")) { - if (!tls_available) { - g_test_skip ("TLS not available"); - return; - } + SOUP_TEST_SKIP_IF_NO_TLS; extra_slow = slow_https; } else @@ -340,7 +334,8 @@ main (int argc, char **argv) debug_printf (2, "\n"); slow_https = FALSE; } - } + } else + https_uri = g_strdup ("https://fail."); g_test_add_data_func ("/timeout/http/async", uri, do_async_timeout_tests); g_test_add_data_func ("/timeout/http/sync", uri, do_sync_timeout_tests); diff --git a/tests/xmlrpc-server-test.c b/tests/xmlrpc-server-test.c index 89e6e8de..1a046c7a 100644 --- a/tests/xmlrpc-server-test.c +++ b/tests/xmlrpc-server-test.c @@ -5,8 +5,6 @@ #include "test-utils.h" -#ifdef HAVE_PHP_XMLRPC - #ifdef G_GNUC_BEGIN_IGNORE_DEPRECATIONS G_GNUC_BEGIN_IGNORE_DEPRECATIONS #endif @@ -358,13 +356,3 @@ main (int argc, char **argv) test_cleanup (); return ret; } - -#else /* HAVE_PHP_XMLRPC */ - -int -main (int argc, char **argv) -{ - return 77; /* SKIP */ -} - -#endif diff --git a/tests/xmlrpc-test.c b/tests/xmlrpc-test.c index 3a7b20ad..46eee266 100644 --- a/tests/xmlrpc-test.c +++ b/tests/xmlrpc-test.c @@ -5,8 +5,6 @@ #include "test-utils.h" -#ifdef HAVE_PHP_XMLRPC - #ifdef G_GNUC_BEGIN_IGNORE_DEPRECATIONS G_GNUC_BEGIN_IGNORE_DEPRECATIONS #endif @@ -16,6 +14,18 @@ static const char *default_uri = "http://127.0.0.1:47524/xmlrpc-server.php"; static const char *uri = NULL; static gboolean server_test = FALSE; +#ifdef HAVE_PHP_XMLRPC +#define SOUP_TEST_SKIP_IF_NO_XMLRPC_SERVER +#else +#define SOUP_TEST_SKIP_IF_NO_XMLRPC_SERVER \ + G_STMT_START { \ + if (!server_test) { \ + g_test_skip ("php-xmlrpc is not available"); \ + return; \ + } \ + } G_STMT_END +#endif + static const char *const value_type[] = { "BAD", "int", @@ -105,6 +115,8 @@ test_sum (void) GValue retval; gboolean ok; + SOUP_TEST_SKIP_IF_NO_XMLRPC_SERVER; + debug_printf (1, "sum (array of int -> int): "); ints = g_value_array_new (10); @@ -139,6 +151,8 @@ test_countBools (void) gboolean val, ok; GHashTable *result; + SOUP_TEST_SKIP_IF_NO_XMLRPC_SERVER; + debug_printf (1, "countBools (array of boolean -> struct of ints): "); bools = g_value_array_new (10); @@ -182,6 +196,8 @@ test_md5sum (void) GValue retval; gboolean ok; + SOUP_TEST_SKIP_IF_NO_XMLRPC_SERVER; + debug_printf (1, "md5sum (base64 -> base64)\n"); data = g_byte_array_new (); @@ -216,6 +232,8 @@ test_dateChange (void) GValue retval; gboolean ok; + SOUP_TEST_SKIP_IF_NO_XMLRPC_SERVER; + debug_printf (1, "dateChange (date, struct of ints -> time)\n"); date = soup_date_new (1970 + (g_random_int_range (0, 50)), @@ -323,6 +341,8 @@ test_echo (void) GValue retval; int i; + SOUP_TEST_SKIP_IF_NO_XMLRPC_SERVER; + debug_printf (1, "echo (array of string -> array of string):\n"); originals = g_value_array_new (N_ECHO_STRINGS); @@ -376,6 +396,8 @@ test_ping (gconstpointer include_params) char *out; gboolean ret; + SOUP_TEST_SKIP_IF_NO_XMLRPC_SERVER; + debug_printf (1, "ping (void (%s) -> string)\n", include_params ? "empty " : "no "); @@ -443,6 +465,8 @@ do_bad_xmlrpc (const char *body) static void test_fault_malformed (void) { + SOUP_TEST_SKIP_IF_NO_XMLRPC_SERVER; + debug_printf (1, "malformed request: "); do_bad_xmlrpc (""); @@ -451,6 +475,8 @@ test_fault_malformed (void) static void test_fault_method (void) { + SOUP_TEST_SKIP_IF_NO_XMLRPC_SERVER; + debug_printf (1, "request to non-existent method: "); do_bad_xmlrpc ("no_such_method1"); @@ -459,6 +485,8 @@ test_fault_method (void) static void test_fault_args (void) { + SOUP_TEST_SKIP_IF_NO_XMLRPC_SERVER; + debug_printf (1, "request with invalid args: "); do_bad_xmlrpc ("sum1"); @@ -493,9 +521,9 @@ main (int argc, char **argv) g_test_add_func ("/xmlrpc/echo", test_echo); g_test_add_data_func ("/xmlrpc/ping/empty-params", GINT_TO_POINTER (TRUE), test_ping); g_test_add_data_func ("/xmlrpc/ping/no-params", GINT_TO_POINTER (FALSE), test_ping); - g_test_add_func ("/xmlrpc/fault_malformed", test_fault_malformed); - g_test_add_func ("/xmlrpc/fault_method", test_fault_method); - g_test_add_func ("/xmlrpc/fault_args", test_fault_args); + g_test_add_func ("/xmlrpc/fault/malformed", test_fault_malformed); + g_test_add_func ("/xmlrpc/fault/method", test_fault_method); + g_test_add_func ("/xmlrpc/fault/args", test_fault_args); ret = g_test_run (); @@ -504,13 +532,3 @@ main (int argc, char **argv) test_cleanup (); return ret; } - -#else /* HAVE_PHP_XMLRPC */ - -int -main (int argc, char **argv) -{ - return 77; /* SKIP */ -} - -#endif -- cgit v1.2.1