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 700123 - Test failure: g_inet_socket_address_get_scope_id
Test failure: g_inet_socket_address_get_scope_id
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: network
2.36.x
Other Mac OS
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-05-11 15:22 UTC by Daniel Macks
Modified: 2013-06-04 12:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gio/tests/inet-address: fix to work on OS X (2.71 KB, patch)
2013-05-25 14:11 UTC, Dan Winship
committed Details | Review

Description Daniel Macks 2013-05-11 15:22:13 UTC
Building glib-2.36.1 on OS X 10.6 in 64-bit mode (single-arch x86_64), there were no warnings while compiling any of the inet sources, but then self-test failed:

TEST: inet-address... (pid=39977)
  /inet-address/parse:                                                 OK
  /inet-address/any:                                                   OK
  /inet-address/loopback:                                              OK
  /inet-address/bytes:                                                 OK
  /inet-address/property:                                              OK
  /socket-address/basic:                                               OK
  /socket-address/scope-id:                                            **
GLib-GIO:ERROR:inet-address.c:245:test_scope_id: assertion failed (g_inet_socket_address_get_scope_id (isaddr) == 1): (0 == 1)
FAIL
GTester: last random seed: R02Sd3ac7f4c16fd24579bd4835881789e51
Comment 1 Dan Winship 2013-05-13 16:09:08 UTC
That test is testing that 'g_network_address_new ("fe80::42%1", 99)' returns an address with scope_id 1.

Unfortunately OS X apparently forces you to identify the scope by name rather than number:

     The scope identifier is hardcoded to the name of the hardware
     interface associated with the link (such as ne0).  An example is
     ''fe80::1%ne0'', which means ''fe80::1 on the link associated with the
     ne0 interface''.

(https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/getaddrinfo.3.html)

So, we need to use if_indextoname() to get the name assocated with id 1, and then g_strdup_printf() up an address using it. (Which should work on Linux too, but if_indextoname() doesn't exist on Windows XP, so we'll need a configure check and #ifdefs and stuff.)
Comment 2 Dan Winship 2013-05-25 14:11:40 UTC
Created attachment 245299 [details] [review]
gio/tests/inet-address: fix to work on OS X

does this fix it?
Comment 3 Daniel Macks 2013-06-03 05:39:50 UTC
Using that patch against glib-2.36.1 I still get

  /socket-address/scope-id:                                            **
GLib-GIO:ERROR:inet-address.c:264:test_scope_id: assertion failed (g_inet_socket_address_get_scope_id (isaddr) == index): (0 == 1)
FAIL
Comment 4 Daniel Macks 2013-06-03 05:41:30 UTC
Forgot to mention that the ac check *does* find the new function:

checking for getprotobyname_r... no
checking for endservent... yes
checking for if_nametoindex... yes
checking for if_indextoname... yes
Comment 5 Dan Winship 2013-06-03 11:48:51 UTC
can you run it in gdb (or add a printf) and see what "str" gets set to? Is the interface it uses a real interface name?

Hm... I wonder if it ends up using "lo", and then getaddrinfo() says "but wait, fe80::42 isn't a valid address on lo" and returns NULL...

Or maybe, if the device isn't up, or doesn't have any IPv6 addresses, it will fail? Can you try playing around with different values of index?
Comment 6 Daniel Macks 2013-06-04 11:47:34 UTC
Aw I'm an idiot, mis-regenerated some of the autotools. Actually doing it *correctly* with the patch from Comment #2:

TEST: inet-address... (pid=92197)
  /inet-address/parse:                                                 OK
  /inet-address/any:                                                   OK
  /inet-address/loopback:                                              OK
  /inet-address/bytes:                                                 OK
  /inet-address/property:                                              OK
  /socket-address/basic:                                               OK
  /socket-address/scope-id:                                            OK
  /address-mask/parse:                                                 OK
  /address-mask/property:                                              OK
  /address-mask/equal:                                                 OK
  /address-mask/match:                                                 OK
PASS: inet-address
Comment 7 Dan Winship 2013-06-04 12:28:47 UTC
Attachment 245299 [details] pushed as 16b2623 - gio/tests/inet-address: fix to work on OS X