From 051e317c4455c0e53686138bdbdc045218472bbd Mon Sep 17 00:00:00 2001 From: Yongqin Liu Date: Mon, 3 Nov 2014 00:43:38 +0800 Subject: bionic libc tests: clean up test_udp.c clean up the file and setting for file tests/bionic/libc/common/test_udp.c Change-Id: Id7889910e87309415b9504e6693322697907f426 Signed-off-by: Yongqin Liu --- tests/bionic/libc/Android.mk | 1 - tests/bionic/libc/common/test_udp.c | 121 ------------------------------------ 2 files changed, 122 deletions(-) delete mode 100644 tests/bionic/libc/common/test_udp.c (limited to 'tests') diff --git a/tests/bionic/libc/Android.mk b/tests/bionic/libc/Android.mk index d54e1b51..c35d6707 100644 --- a/tests/bionic/libc/Android.mk +++ b/tests/bionic/libc/Android.mk @@ -64,7 +64,6 @@ sources := \ common/test_pthread_mutex.c \ common/test_pthread_rwlock.c \ common/test_seteuid.c \ - common/test_udp.c \ # _XOPEN_SOURCE=600 is needed to get pthread_mutexattr_settype() on GLibc # diff --git a/tests/bionic/libc/common/test_udp.c b/tests/bionic/libc/common/test_udp.c deleted file mode 100644 index 3c9dd079..00000000 --- a/tests/bionic/libc/common/test_udp.c +++ /dev/null @@ -1,121 +0,0 @@ -/* this program is used to test UDP networking in Android. - * used to debug the emulator's networking implementation - */ -#define PROGNAME "test_udp" -#define DEFAULT_PORT 7000 - -#include -#include -#include -#include -#include -#include -#include -#include - -#define BUFLEN 512 -#define NPACK 10 - -void diep(char *s) -{ - perror(s); - exit(1); -} - -static void -usage(int code) -{ - printf("usage: %s [options]\n", PROGNAME); - printf("options:\n"); - printf(" -p use specific port (default %d)\n", DEFAULT_PORT); - printf(" -a use specific IP address\n"); - printf(" -s run server (default is client)\n"); - exit(code); -} - -int main(int argc, char** argv) -{ - int runServer = 0; - int udpPort = DEFAULT_PORT; - int useLocal = 0; - int address = htonl(INADDR_ANY); - - struct sockaddr_in si_me, si_other; - int s, i, slen=sizeof(si_other); - char buf[BUFLEN]; - - while (argc > 1 && argv[1][0] == '-') { - const char* optName = argv[1]+1; - argc--; - argv++; - - switch (optName[0]) { - case 'p': - udpPort = atoi(optName+1); - if (udpPort < 1024 || udpPort > 65535) { - fprintf(stderr, "UDP port must be between 1024 and 65535\n"); - exit(1); - } - break; - - case 's': - runServer = 1; - break; - - case 'a': - if (inet_aton(optName+1, &si_other.sin_addr) == 0) - diep("inet_aton"); - address = si_other.sin_addr.s_addr; - break; - - default: - usage(1); - } - } - - if (runServer) { - if ((s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))==-1) - diep("socket"); - - memset((char *) &si_me, 0, sizeof(si_me)); - si_me.sin_family = AF_INET; - si_me.sin_port = htons(udpPort); - si_me.sin_addr.s_addr = address; - if (bind(s, (struct sockaddr*)&si_me, sizeof(si_me))==-1) - diep("bind"); - - printf("UDP server listening on %s:%d\n", inet_ntoa(si_me.sin_addr), udpPort); - for (i=0; i