mgetgroups: remove dependency on realloc-gnu
[gnulib.git] / tests / test-net_if.c
index 79a0df2..932f3e3 100644 (file)
@@ -1,5 +1,5 @@
 /* Test of <net/if.h> functions.
-   Copyright (C) 2010-2011 Free Software Foundation, Inc.
+   Copyright (C) 2010-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 
 #include <net/if.h>
 
-#include "signature.h"
+/* We do not yet have replacements for if_* functions on systems that
+   lack a native <net/if.h>.  */
+#if HAVE_NET_IF_H && HAVE_IF_NAMEINDEX
+# include "signature.h"
 SIGNATURE_CHECK (if_freenameindex, void, (struct if_nameindex *));
 SIGNATURE_CHECK (if_indextoname, char *, (unsigned int, char *));
 SIGNATURE_CHECK (if_nameindex, struct if_nameindex *, (void));
 SIGNATURE_CHECK (if_nametoindex, unsigned int, (const char *));
+#endif
 
 #include <stddef.h> /* NULL */
 #include <stdio.h> /* fprintf */
@@ -32,6 +36,7 @@ SIGNATURE_CHECK (if_nametoindex, unsigned int, (const char *));
 int
 main (int argc, char *argv[])
 {
+#if HAVE_NET_IF_H && HAVE_IF_NAMEINDEX
   struct if_nameindex *ifnp, *p;
 
   p = ifnp = if_nameindex ();
@@ -80,6 +85,14 @@ main (int argc, char *argv[])
     }
 
   if_freenameindex (ifnp);
-
+#endif /* HAVE_NET_IF_H */
+
+#if !HAVE_NET_IF_H || HAVE_IF_NAMEINDEX
+  {
+    static struct if_nameindex ni;
+    return !IF_NAMESIZE + ni.if_index + !!ni.if_name;
+  }
+#else
   return 0;
+#endif
 }