GNOME Bugzilla – Bug 700123
Test failure: g_inet_socket_address_get_scope_id
Last modified: 2013-06-04 12:28:51 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
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.)
Created attachment 245299 [details] [review] gio/tests/inet-address: fix to work on OS X does this fix it?
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
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
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?
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
Attachment 245299 [details] pushed as 16b2623 - gio/tests/inet-address: fix to work on OS X