Add an unittest for if_nameindex to network kit tests pool
This commit is contained in:
parent
7c8e63e171
commit
415962e25f
@ -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) ;
|
||||
|
||||
|
17
src/tests/kits/net/if_nameindex.c
Normal file
17
src/tests/kits/net/if_nameindex.c
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user