[glib/wip/desrt/happier-eyeballs: 18/18] network-address test: add ipv6-fail ipv4-slow case



commit d56ac0edd6b6d51eb9277314f9615ef759e4313b
Author: Allison Karlitskaya <allison karlitskaya redhat com>
Date:   Tue May 28 17:04:51 2019 +0200

    network-address test: add ipv6-fail ipv4-slow case
    
    Add a case for when the IPv6 result comes back negative and the IPv4
    result is significantly delayed.  This is exactly the case that causes
    the bug addressed by GNOME/glib!865

 gio/tests/network-address.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
---
diff --git a/gio/tests/network-address.c b/gio/tests/network-address.c
index 0dcd7b292..a32876aa4 100644
--- a/gio/tests/network-address.c
+++ b/gio/tests/network-address.c
@@ -819,6 +819,28 @@ test_happy_eyeballs_ipv6_error_ipv6_first (HappyEyeballsFixture *fixture,
   g_error_free (ipv6_error);
 }
 
+static void
+test_happy_eyeballs_ipv6_error_ipv4_very_slow (HappyEyeballsFixture *fixture,
+                                               gconstpointer         user_data)
+{
+  AsyncData data = { 0 };
+  GError *ipv6_error;
+
+  /* If ipv6 fails, ensuring that ipv6 errors before ipv4 finishes, we still get ipv4. */
+
+  data.loop = fixture->loop;
+  ipv6_error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_TIMED_OUT, "IPv6 Broken");
+  mock_resolver_set_ipv6_error (fixture->mock_resolver, ipv6_error);
+  mock_resolver_set_ipv4_delay_ms (fixture->mock_resolver, SLOW_DELAY_MORE_THAN_TIMEOUT);
+
+  g_socket_address_enumerator_next_async (fixture->enumerator, NULL, got_addr, &data);
+  g_main_loop_run (fixture->loop);
+
+  assert_list_matches_expected (data.addrs, fixture->input_ipv4_results);
+
+  g_error_free (ipv6_error);
+}
+
 static void
 test_happy_eyeballs_ipv4_error_ipv4_first (HappyEyeballsFixture *fixture,
                                            gconstpointer         user_data)
@@ -1031,6 +1053,8 @@ main (int argc, char *argv[])
               happy_eyeballs_setup, test_happy_eyeballs_ipv6_error_ipv4_first, happy_eyeballs_teardown);
   g_test_add ("/network-address/happy-eyeballs/ipv6-error-ipv6-first", HappyEyeballsFixture, NULL,
               happy_eyeballs_setup, test_happy_eyeballs_ipv6_error_ipv6_first, happy_eyeballs_teardown);
+  g_test_add ("/network-address/happy-eyeballs/ipv6-error-ipv4-very-slow", HappyEyeballsFixture, NULL,
+              happy_eyeballs_setup, test_happy_eyeballs_ipv6_error_ipv4_very_slow, happy_eyeballs_teardown);
   g_test_add ("/network-address/happy-eyeballs/ipv4-error-ipv6-first", HappyEyeballsFixture, NULL,
               happy_eyeballs_setup, test_happy_eyeballs_ipv4_error_ipv6_first, happy_eyeballs_teardown);
   g_test_add ("/network-address/happy-eyeballs/ipv4-error-ipv4-first", HappyEyeballsFixture, NULL,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]