diff options
author | Ross Burton <ross.burton@intel.com> | 2020-05-06 21:31:17 +0100 |
---|---|---|
committer | Ross Burton <ross.burton@intel.com> | 2020-05-06 21:40:30 +0100 |
commit | 4d6630a513a9be44f8185f2fab935b9ebd9e96f4 (patch) | |
tree | 3c663c632d817b3dd6b0e6e56fe181898ce330a9 | |
parent | e5cd9c8470eb1288daf478eb1b3da52f6e3a9708 (diff) | |
download | libsoup-4d6630a513a9be44f8185f2fab935b9ebd9e96f4.tar.gz |
tests: check for curl at runtime
Don't use the presence of curl at configure time to decide whether to
run these tests when installed.
Instead of always respecting HAVE_CURL which makes no sense for the
installed tests, simply check if curl is present at test runtime and
skip if not.
Also remove HAVE_CURL from meson.build as this removes all users.
-rw-r--r-- | meson.build | 2 | ||||
-rw-r--r-- | tests/forms-test.c | 24 | ||||
-rw-r--r-- | tests/server-auth-test.c | 8 | ||||
-rw-r--r-- | tests/test-utils.c | 13 | ||||
-rw-r--r-- | tests/test-utils.h | 2 |
5 files changed, 31 insertions, 18 deletions
diff --git a/meson.build b/meson.build index acfc798c..fffbb42f 100644 --- a/meson.build +++ b/meson.build @@ -280,8 +280,6 @@ if not tests_ready warning('Some regression tests will not be compiled due to missing libraries or modules. Please check the logs for more details.') endif -cdata.set('HAVE_CURL', find_program('curl', required : false).found()) - ################## # GSSAPI support # ################## diff --git a/tests/forms-test.c b/tests/forms-test.c index 349932bf..0ac199d1 100644 --- a/tests/forms-test.c +++ b/tests/forms-test.c @@ -90,10 +90,10 @@ do_hello_tests (gconstpointer uri) { int n; -#ifndef HAVE_CURL - g_test_skip ("/usr/bin/curl is not available"); - return; -#endif + if (!have_curl()) { + g_test_skip ("curl is not available"); + return; + } for (n = 0; n < G_N_ELEMENTS (tests); n++) { do_hello_test (n, FALSE, uri); @@ -139,10 +139,10 @@ do_md5_test_curl (gconstpointer data) char *file_arg, *str_stdout; GError *error = NULL; -#ifndef HAVE_CURL - g_test_skip ("/usr/bin/curl is not available"); - return; -#endif + if (!have_curl()) { + g_test_skip ("curl is not available"); + return; + } md5 = get_md5_data (NULL, NULL); if (!md5) @@ -226,10 +226,10 @@ do_form_decode_test (void) const gchar *value; gchar *tmp; -#ifndef HAVE_CURL - g_test_skip ("/usr/bin/curl is not available"); - return; -#endif + if (!have_curl()) { + g_test_skip ("curl is not available"); + return; + } /* Test that the code handles multiple values with the same key. */ table = soup_form_decode ("foo=first&foo=second&foo=third"); diff --git a/tests/server-auth-test.c b/tests/server-auth-test.c index 34c297bc..dd92f1a6 100644 --- a/tests/server-auth-test.c +++ b/tests/server-auth-test.c @@ -109,10 +109,10 @@ do_server_auth_test (gconstpointer data) { int i = GPOINTER_TO_INT (data); -#ifndef HAVE_CURL - g_test_skip ("/usr/bin/curl is not available"); - return; -#endif + if (!have_curl()) { + g_test_skip ("curl is not available"); + return; + } /* 1. No auth required. The server will ignore the * Authorization headers completely, and the request diff --git a/tests/test-utils.c b/tests/test-utils.c index 8b59a3dd..0c48e506 100644 --- a/tests/test-utils.c +++ b/tests/test-utils.c @@ -131,6 +131,19 @@ debug_printf (int level, const char *format, ...) va_end (args); } +gboolean +have_curl(void) { + char *found; + + found = g_find_program_in_path ("curl"); + if (found) { + g_free (found); + return TRUE; + } else { + return FALSE; + } +} + #ifdef HAVE_APACHE static gboolean diff --git a/tests/test-utils.h b/tests/test-utils.h index 0bc065fc..7beb2b28 100644 --- a/tests/test-utils.h +++ b/tests/test-utils.h @@ -42,6 +42,8 @@ void apache_cleanup (void); } G_STMT_END #endif +gboolean have_curl (void); + typedef enum { SOUP_TEST_REQUEST_NONE = 0, SOUP_TEST_REQUEST_CANCEL_MESSAGE = (1 << 0), |