From 02702760aa5a9b695b11244a54142209759c908b Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 30 Jan 2012 12:26:09 +0000 Subject: [PATCH] -add test for unsupported AFs (#2123) --- src/vpn/test_gnunet_vpn.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/vpn/test_gnunet_vpn.c b/src/vpn/test_gnunet_vpn.c index 4df9e7eb0..d66e6fc7b 100644 --- a/src/vpn/test_gnunet_vpn.c +++ b/src/vpn/test_gnunet_vpn.c @@ -458,6 +458,31 @@ stop_peer (struct PeerContext *p) } +/** + * Test if the given AF is supported by this system. + * + * @param af to test + * @return GNUNET_OK if the AF is supported + */ +static int +test_af (int af) +{ + int s; + + s = socket (af, SOCK_STREAM, 0); + if (-1 == s) + { + if (EAFNOSUPPORT == errno) + return GNUNET_NO; + fprintf (stderr, "Failed to create test socket: %s\n", STRERROR (errno)); + return GNUNET_SYSERR; + } + close (s); + return GNUNET_OK; +} + + + int main (int argc, char *const *argv) { @@ -535,6 +560,14 @@ main (int argc, char *const *argv) fprintf (stderr, "invalid binary suffix `%s'\n", type); return 1; } + if ( (GNUNET_OK != test_af (src_af)) || + (GNUNET_OK != test_af (dest_af)) ) + { + fprintf (stderr, + "Required address families not supported by this system, skipping test.\n"); + return 0; + } + if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; -- 2.25.1