tests: Add test to showcase osmo_sock_init2 bug with AF_UNSPEC

The function is checking for IP version matching between local and
remote addresses even if only one is needed based on flags. For example,
if user only desired to bind, the remote address should not be
used nor checked.

Bug was introduced here: 2c962f5de1eeea119cfac7d9d92db31c570353b9

Change-Id: I87afd1db9bd017426abcc959fa515d15784cdf1c
diff --git a/tests/socket/socket_test.c b/tests/socket/socket_test.c
index a2e103c..5cf20b7 100644
--- a/tests/socket/socket_test.c
+++ b/tests/socket/socket_test.c
@@ -24,6 +24,7 @@
 #include <string.h>
 #include <fcntl.h>
 #include <inttypes.h>
+#include <errno.h>
 
 #include <sys/socket.h>
 #include <arpa/inet.h>
@@ -143,6 +144,11 @@
 			     OSMO_SOCK_F_BIND|OSMO_SOCK_F_CONNECT);
 	OSMO_ASSERT(fd >= 0);
 
+	printf("Checking osmo_sock_init2(AF_UNSPEC) BIND on IPv4\n");
+	fd = osmo_sock_init2(AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, "127.0.0.1", 0, NULL, 0,
+			     OSMO_SOCK_F_BIND);
+	OSMO_ASSERT(fd == -ENODEV); /* BUG! */
+
 	talloc_free(name);
 
 	return 0;