[libsoup/wip/ci-test] Support running tests without ipv6
- From: Patrick Griffis <pgriffis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup/wip/ci-test] Support running tests without ipv6
- Date: Thu, 26 Nov 2020 17:47:21 +0000 (UTC)
commit 7d7ecf39faa1a57f7825437f6b862cf8f90d3d17
Author: Patrick Griffis <pgriffis igalia com>
Date: Thu Nov 26 11:27:51 2020 -0600
Support running tests without ipv6
.gitlab-ci.yml | 2 +-
tests/server-test.c | 29 ++++++-----------------------
tests/test-utils.c | 9 +++++++--
tests/test-utils.h | 8 ++++++++
4 files changed, 22 insertions(+), 26 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8e3dfa4c..bed976a4 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -47,9 +47,9 @@ fedora-asan:
stage: build
tags:
- asan
- - ipv6
variables:
ASAN_OPTIONS: fast_unwind_on_malloc=0
+ SOUP_TEST_NO_IPV6: 1
script:
- meson _build -Dauto-features=enabled -Db_sanitize=address -Dintrospection=disabled -Dvapi=disabled
- ninja -C _build test
diff --git a/tests/server-test.c b/tests/server-test.c
index c2f79ed2..38fc2721 100644
--- a/tests/server-test.c
+++ b/tests/server-test.c
@@ -385,18 +385,13 @@ do_ipv6_test (ServerData *sd, gconstpointer test_data)
g_test_bug ("666399");
+ SOUP_TEST_SKIP_IF_NO_IPV6;
+
sd->server = soup_test_server_new (SOUP_TEST_SERVER_NO_DEFAULT_LISTENER);
server_add_handler (sd, NULL, ipv6_server_callback, NULL, NULL);
- if (!soup_server_listen_local (sd->server, 0,
- SOUP_SERVER_LISTEN_IPV6_ONLY,
- &error)) {
-#if GLIB_CHECK_VERSION (2, 41, 0)
- g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED);
-#endif
- g_test_skip ("no IPv6 support");
- return;
- }
+ soup_server_listen_local (sd->server, 0, SOUP_SERVER_LISTEN_IPV6_ONLY, &error);
+ g_assert_no_error (error);
sd->base_uri = soup_test_server_get_uri (sd->server, "http", "::1");
@@ -560,6 +555,8 @@ do_multi_family_test (ServerData *sd, gconstpointer test_data)
GUri *uri1, *uri2;
GError *error = NULL;
+ SOUP_TEST_SKIP_IF_NO_IPV6;
+
sd->server = soup_test_server_new (SOUP_TEST_SERVER_NO_DEFAULT_LISTENER);
if (!soup_server_listen_local (sd->server, 0, 0, &error)) {
@@ -569,20 +566,6 @@ do_multi_family_test (ServerData *sd, gconstpointer test_data)
}
uris = soup_server_get_uris (sd->server);
- if (g_slist_length (uris) == 1) {
- gboolean ipv6_works;
-
- /* No IPv6? Double-check */
- ipv6_works = soup_server_listen_local (sd->server, 0,
- SOUP_SERVER_LISTEN_IPV6_ONLY,
- NULL);
- if (ipv6_works)
- g_assert_false (ipv6_works);
- else
- g_test_skip ("no IPv6 support");
- return;
- }
-
g_assert_cmpint (g_slist_length (uris), ==, 2);
uri1 = uris->data;
uri2 = uris->next->data;
diff --git a/tests/test-utils.c b/tests/test-utils.c
index de6479a0..27734d8b 100644
--- a/tests/test-utils.c
+++ b/tests/test-utils.c
@@ -385,8 +385,12 @@ static void
server_listen (SoupServer *server)
{
GError *error = NULL;
+ SoupServerListenOptions options = 0;
- soup_server_listen_local (server, 0, 0, &error);
+ if (g_getenv ("SOUP_TEST_NO_IPV6"))
+ options = SOUP_SERVER_LISTEN_IPV4_ONLY;
+
+ soup_server_listen_local (server, 0, options, &error);
if (error) {
g_printerr ("Unable to create server: %s\n", error->message);
exit (1);
@@ -510,7 +514,8 @@ add_listener (SoupServer *server, const char *scheme, const char *host)
if (!g_strcmp0 (scheme, "https"))
options |= SOUP_SERVER_LISTEN_HTTPS;
- if (!g_strcmp0 (host, "127.0.0.1"))
+
+ if (!g_strcmp0 (host, "127.0.0.1") || g_getenv ("SOUP_TEST_NO_IPV6"))
options |= SOUP_SERVER_LISTEN_IPV4_ONLY;
else if (!g_strcmp0 (host, "::1"))
options |= SOUP_SERVER_LISTEN_IPV6_ONLY;
diff --git a/tests/test-utils.h b/tests/test-utils.h
index 7c8a43a1..7a155495 100644
--- a/tests/test-utils.h
+++ b/tests/test-utils.h
@@ -25,6 +25,14 @@ void debug_printf (int level, const char *format, ...) G_GNUC_PRINTF (2, 3);
} \
} G_STMT_END
+#define SOUP_TEST_SKIP_IF_NO_IPV6 \
+ G_STMT_START { \
+ if (g_getenv ("SOUP_TEST_NO_IPV6")) { \
+ g_test_skip ("IPV6 is not available"); \
+ return; \
+ } \
+ } G_STMT_END \
+
#ifdef HAVE_APACHE
void apache_init (void);
void apache_cleanup (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]