[glib] gio/tests/network-address: fix when no network is available
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gio/tests/network-address: fix when no network is available
- Date: Tue, 27 May 2014 13:42:47 +0000 (UTC)
commit 84fd73b2fa098ff63656e7cbe1ef211f948123c2
Author: Dan Winship <danw gnome org>
Date: Tue May 27 09:39:46 2014 -0400
gio/tests/network-address: fix when no network is available
GResolver doesn't do full validation of its inputs, so in some of
these tests, the fact that we were getting back
G_RESOLVER_ERROR_NOT_FOUND is because the junk string was getting
passed to an upstream DNS resolver, which returned NXDOMAIN. But if
there's no network on the machine then we'd get
G_RESOLVER_ERROR_INTERNAL instead in that case.
gio/tests/network-address.c | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/gio/tests/network-address.c b/gio/tests/network-address.c
index ac4842c..44b6990 100644
--- a/gio/tests/network-address.c
+++ b/gio/tests/network-address.c
@@ -210,7 +210,24 @@ test_resolve_address_gresolver (gconstpointer d)
else
{
g_assert_false (test->valid_resolve);
- g_assert_error (error, G_RESOLVER_ERROR, G_RESOLVER_ERROR_NOT_FOUND);
+
+ if (!test->valid_parse)
+ {
+ /* GResolver should have rejected the address internally, in
+ * which case we're guaranteed to get G_RESOLVER_ERROR_NOT_FOUND.
+ */
+ g_assert_error (error, G_RESOLVER_ERROR, G_RESOLVER_ERROR_NOT_FOUND);
+ }
+ else
+ {
+ /* If GResolver didn't reject the string itself, then we
+ * might have attempted to send it over the network. If that
+ * attempt succeeded, we'd get back NOT_FOUND, but if
+ * there's no network available we might have gotten some
+ * other error instead.
+ */
+ }
+
g_error_free (error);
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]