Mercurial > hg > octave-lyh > gnulib-hg
changeset 13716:2d243bd19a68
net_if: enhance tests
* tests/test-net_if.c (main): Move signature checks earlier.
Print failures to stderr.
* doc/posix-functions/if_freenameindex.texi (if_freenameindex):
Document the bug that we do not yet fix.
Signed-off-by: Eric Blake <eblake@redhat.com>
author | Eric Blake <eblake@redhat.com> |
---|---|
date | Tue, 21 Sep 2010 15:27:59 -0600 |
parents | 04126a7f5fd5 |
children | b747a553a8bb |
files | ChangeLog doc/posix-functions/if_freenameindex.texi modules/net_if-tests tests/test-net_if.c |
diffstat | 4 files changed, 34 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-09-21 Eric Blake <eblake@redhat.com> + + net_if: enhance tests + * tests/test-net_if.c (main): Move signature checks earlier. + Print failures to stderr. + * doc/posix-functions/if_freenameindex.texi (if_freenameindex): + Document the bug that we do not yet fix. + 2010-09-21 Reuben Thomas <rrt@sc3d.org> * doc/gnulib.texi (Out of memory handling): Rewrite section to be
--- a/doc/posix-functions/if_freenameindex.texi +++ b/doc/posix-functions/if_freenameindex.texi @@ -14,5 +14,11 @@ @itemize @item This function is missing on some platforms: -OpenBSD 3.8, HP-UX 11, IRIX 6.5, OSF/1 4.0, Solaris 7, Cygwin 1.5.x, mingw, Interix 3.5, BeOS. +OpenBSD 3.8, HP-UX 11, IRIX 6.5, OSF/1 4.0, Solaris 7, Cygwin 1.5.x, +mingw, Interix 3.5, BeOS. + +@item +This is available only as a macro, rather than a function, on some +platforms: +OpenBSD 4.6, MirBSD 10. @end itemize
--- a/modules/net_if-tests +++ b/modules/net_if-tests @@ -1,5 +1,6 @@ Files: tests/test-net_if.c +tests/signature.h Depends-on:
--- a/tests/test-net_if.c +++ b/tests/test-net_if.c @@ -17,32 +17,33 @@ /* Written by Simon Josefsson <simon@josefsson.org>, 2010. */ #include <config.h> + #include <net/if.h> + +#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 *)); + #include <stddef.h> /* NULL */ -#include <stdio.h> /* printf */ +#include <stdio.h> /* fprintf */ int main (int argc, char *argv[]) { - struct if_nameindex ifn, *ifnp, *p; - void (*if_fni) (struct if_nameindex *) = if_freenameindex; - char *(*if_itn)(unsigned, char *) = if_indextoname; - struct if_nameindex *(*if_ni)(void) = if_nameindex; - unsigned (*if_nti)(const char *) = if_nametoindex; - - ifn.if_index = 42; - ifn.if_name = "foo"; + struct if_nameindex *ifnp, *p; p = ifnp = if_nameindex (); if (ifnp == NULL) { - printf ("if_nameindex returned NULL\n"); + fputs ("if_nameindex returned NULL\n", stderr); return 1; } while (p->if_index) { - unsigned idx; + unsigned int idx; char buf[IF_NAMESIZE]; char *q; @@ -52,25 +53,26 @@ idx = if_nametoindex (p->if_name); if (idx != p->if_index) { - printf ("if_nametoindex (%s) = %d != %d\n", - p->if_name, idx, p->if_index); + fprintf (stderr, "if_nametoindex (%s) = %d != %d\n", + p->if_name, idx, p->if_index); return 1; } q = if_indextoname (p->if_index, buf); if (q == NULL) { - printf ("if_indextoname (%d) returned NULL\n", p->if_index); + fprintf (stderr, "if_indextoname (%d) returned NULL\n", p->if_index); return 1; } if (q != buf) { - printf ("if_indextoname (%d) buffer mismatch?\n", p->if_index); + fprintf (stderr, "if_indextoname (%d) buffer mismatch?\n", + p->if_index); return 1; } if (strcmp (p->if_name, q) != 0) { - printf ("if_indextoname (%s) = %s ?!\n", p->if_name, q); + fprintf (stderr, "if_indextoname (%s) = %s ?!\n", p->if_name, q); return 1; }