From 415962e25f68eb422f5248713396fad087c58c17 Mon Sep 17 00:00:00 2001 From: Philippe Houdoin Date: Fri, 24 May 2013 09:36:30 +0200 Subject: [PATCH] Add an unittest for if_nameindex to network kit tests pool --- src/tests/kits/net/Jamfile | 2 ++ src/tests/kits/net/if_nameindex.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/tests/kits/net/if_nameindex.c diff --git a/src/tests/kits/net/Jamfile b/src/tests/kits/net/Jamfile index ce66439eab..f133901cc1 100644 --- a/src/tests/kits/net/Jamfile +++ b/src/tests/kits/net/Jamfile @@ -19,6 +19,8 @@ SimpleTest link_echo : link_echo.cpp : $(TARGET_NETWORK_LIBS) bnetapi be ; SimpleTest getpeername : getpeername.cpp : $(TARGET_NETWORK_LIBS) ; +SimpleTest if_nameindex : if_nameindex.c : $(TARGET_NETWORK_LIBS) ; + SimpleTest tcp_connection_test : tcp_connection_test.cpp : $(TARGET_NETWORK_LIBS) ; diff --git a/src/tests/kits/net/if_nameindex.c b/src/tests/kits/net/if_nameindex.c new file mode 100644 index 0000000000..b277ed05d6 --- /dev/null +++ b/src/tests/kits/net/if_nameindex.c @@ -0,0 +1,17 @@ +#include +#include +#include + +int main(int argc, char *argv[]) +{ + struct if_nameindex *ifs; + int i; + + ifs = if_nameindex(); + if (ifs == NULL) { perror("if_nameindex"); exit(EXIT_FAILURE); } + + for (i = 0; ifs[i].if_index != 0 || ifs[i].if_name != NULL; i++) { + printf("%d %s\n", ifs[i].if_index, ifs[i].if_name); + } + return EXIT_SUCCESS; +}