Add an unittest for if_nameindex to network kit tests pool

This commit is contained in:
Philippe Houdoin 2013-05-24 09:36:30 +02:00
parent 7c8e63e171
commit 415962e25f
2 changed files with 19 additions and 0 deletions

View File

@ -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) ;

View File

@ -0,0 +1,17 @@
#include <stdlib.h>
#include <stdio.h>
#include <net/if.h>
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;
}