After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 701401 - gtest: add function for testing for WINE
gtest: add function for testing for WINE
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-06-01 01:54 UTC by Allison Karlitskaya (desrt)
Modified: 2018-05-24 15:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gtest: add function for testing for WINE (3.07 KB, patch)
2013-06-01 01:54 UTC, Allison Karlitskaya (desrt)
reviewed Details | Review
inet-address: disable some testcases under WINE (5.03 KB, patch)
2013-06-01 01:54 UTC, Allison Karlitskaya (desrt)
rejected Details | Review
ginetaddress: fix addr/string conversions on windows (2.88 KB, patch)
2013-06-02 21:39 UTC, Dan Winship
committed Details | Review
tests: add a few more invalid IPv6 address tests (1.03 KB, patch)
2013-06-05 19:52 UTC, Allison Karlitskaya (desrt)
none Details | Review
tests: add a few more invalid IPv6 address tests (1.03 KB, patch)
2013-06-05 20:00 UTC, Allison Karlitskaya (desrt)
committed Details | Review

Description Allison Karlitskaya (desrt) 2013-06-01 01:54:13 UTC
See patches.
Comment 1 Allison Karlitskaya (desrt) 2013-06-01 01:54:15 UTC
Created attachment 245804 [details] [review]
gtest: add function for testing for WINE

We have some testcases that are failing due to what appears to be
limitations in WINE.  Introduce a function called g_test_is_under_wine()
in order to determine if we are running under WINE so that we can
disable some testcases.
Comment 2 Allison Karlitskaya (desrt) 2013-06-01 01:54:18 UTC
Created attachment 245805 [details] [review]
inet-address: disable some testcases under WINE

WINE appears not to parse IPv6 addresses containing '::' properly, so
disable some tests of this functionality.
Comment 3 Dan Winship 2013-06-02 21:02:00 UTC
Comment on attachment 245805 [details] [review]
inet-address: disable some testcases under WINE

>WINE appears not to parse IPv6 addresses containing '::' properly, so
>disable some tests of this functionality.

Not true. In fact, WINE's own test suite contains exactly the same test that is failing here... The bug must be in glib.

(Though I would swear this test used to pass...)
Comment 4 Dan Winship 2013-06-02 21:09:31 UTC
Comment on attachment 245804 [details] [review]
gtest: add function for testing for WINE

Although the specific case in this bug was wrong, there certainly are things that fail under WINE, but not Windows. So this might be useful. Although I feel like it should be versioned, since hopefully the things that don't work in WINE now will be fixed in later versions. Figuring out the WINE version would obviously be tricky though since there's not even a real API for determining if we're under WINE...

>+      g_once_init_leave (&result_plus_1, result + 1);
>+    }
>+
>+  return result_plus_1 - 1;

Ugh. Just use a separate "inited" variable.
Comment 5 Dan Winship 2013-06-02 21:39:00 UTC
Created attachment 245883 [details] [review]
ginetaddress: fix addr/string conversions on windows

When parsing an address, we need to re-set "len" between IPv4 and
IPv6, since WSAStringToAddress() might set it to sizeof(struct sin_addr)
when trying to parse the string as IPv4, even if it fails. Also, we
need to make sure to not pass strings to WSAStringToAddress() that it
will accept but that we don't want it to.

When stringifying an address, we need to clear the sockaddr before
filling it in, so we don't accidentally end up with an unwanted
scope_id or the like.
Comment 6 Allison Karlitskaya (desrt) 2013-06-05 19:40:55 UTC
Review of attachment 245883 [details] [review]:

This causes the testcase to pass for me.

Your comment about WINE suggests that it may be possible to get it to accept an invalid string as a inet6 address via our API, which seems a bit worrying...
Comment 7 Allison Karlitskaya (desrt) 2013-06-05 19:52:14 UTC
Created attachment 246111 [details] [review]
tests: add a few more invalid IPv6 address tests
Comment 8 Allison Karlitskaya (desrt) 2013-06-05 20:00:28 UTC
Created attachment 246112 [details] [review]
tests: add a few more invalid IPv6 address tests

An off-by-1 made the last iteration of this patch less useful than it should have been.

Anyway... these tests pass for both wine and Linux native, so I guess I'm happy... the comment still seems confusing to me, though -- if the Linux native functions are rejecting a "[0:1:2:3:4:5:6:7]" type string then why does wine have to do extra checks?
Comment 9 Dan Winship 2013-06-05 20:36:39 UTC
It's just that WSAStringToAddress() doesn't have exactly the right semantics for g_inet_address_new_from_string(); we only want to accept IP addresses, but it also accepts IP address + port combos (eg, 127.0.0.1:80 or [fe80::1]:22). Alternatively, we could just call g_host_is_ip_address() on @string before passing it to WSAStringToAddress()...

The WINE-specific bit is that when checking for the IPv6+port form, it looks for the "]:", and if it finds it, it skips over the first character of the address without actually checking that it's "[", so you could put anything there and it would still accept it.
Comment 10 Allison Karlitskaya (desrt) 2013-06-05 21:08:01 UTC
Review of attachment 245883 [details] [review]:

Approved, but maybe update the comment to be as clear as your comments on bugzilla are? (ie: the part about wine's behaviour with ']:').
Comment 11 Dan Winship 2013-06-05 22:50:45 UTC
pushed, along with your added tests, plus two more tests of the
specific kinds of strings that WSAStringToAddress() accepts that we
want to reject.

Attachment 245883 [details] pushed as 59ed934 - ginetaddress: fix addr/string conversions on windows
Attachment 246112 [details] pushed as 74a0340 - tests: add a few more invalid IPv6 address tests
Comment 12 Colin Walters 2013-06-05 23:25:24 UTC
The inet address test is consistently failing in the gnome-ostree CI system:

"GLib-GIO:ERROR:../../../gio/tests/inet-address.c:70:test_parse: assertion failed: (addr != NULL)" }
Comment 13 Allison Karlitskaya (desrt) 2013-06-06 02:14:12 UTC
Dan: looks like you meant "== NULL" in this case?

+  addr = g_inet_address_new_from_string ("204.152.189.116:80");
+  g_assert (addr != NULL);

Matthias backed out the commit for now...
Comment 14 Dan Winship 2013-06-06 02:52:34 UTC
argh. I typed "make" and then ran inet-address again, and it passed, and so I committed it. Of course, "make" doesn't re-build test programs any more, so I was still running the old version. :-/
Comment 15 GNOME Infrastructure Team 2018-05-24 15:22:45 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/709.