version 1.15, 2005/03/10 02:51:33
|
version 1.16, 2005/03/10 07:36:31
|
|
|
#define TEST_TIMEOUT 30 /* seconds to wait before killing child threads | #define TEST_TIMEOUT 30 /* seconds to wait before killing child threads |
after server initialization, if something hangs */ | after server initialization, if something hangs */ |
| |
|
#define NUM_THREADS 3 /* Number of threads to run getservbyname */ |
|
#define NUM_QUERIES 500 /* Number of getservbyname queries per thread */ |
|
|
#define wsa_ok(op, cond, msg) \ | #define wsa_ok(op, cond, msg) \ |
do { \ | do { \ |
int tmp, err = 0; \ | int tmp, err = 0; \ |
|
|
} | } |
}; | }; |
| |
|
static void WINAPI do_getservbyname( HANDLE *starttest ) |
|
{ |
|
int i; |
|
|
|
struct servent *pserv1, *pserv2; |
|
|
|
WaitForSingleObject ( *starttest, INFINITE ); |
|
|
|
for ( i = 0; i < NUM_QUERIES / 2; i++ ) { |
|
pserv1 = getservbyname ( "telnet", "tcp" ); |
|
ok ( pserv1 != NULL, "getservbyname could not retreive information for telnet: %d\n", WSAGetLastError() ); |
|
ok ( pserv1->s_port == htons(23), "getservbyname returned the wrong port for telnet: %d\n", ntohs(pserv1->s_port) ); |
|
ok ( !strcmp ( pserv1->s_proto, "tcp" ), "getservbyname returned the wrong protocol for telnet: %s\n", pserv1->s_proto ); |
|
ok ( !strcmp ( pserv1->s_name, "telnet" ), "getservbyname returned the wrong name for telnet: %s\n", pserv1->s_name ); |
|
|
|
pserv2 = getservbyname ( "domain", "udp" ); |
|
ok ( pserv2 != NULL, "getservbyname could not retreive information for domain: %d\n", WSAGetLastError() ); |
|
ok ( pserv2->s_port == htons(53), "getservbyname returned the wrong port for domain: %d\n", ntohs(pserv2->s_port) ); |
|
ok ( !strcmp ( pserv2->s_proto, "udp" ), "getservbyname returned the wrong protocol for domain: %s\n", pserv2->s_proto ); |
|
ok ( !strcmp ( pserv2->s_name, "domain" ), "getservbyname returned the wrong name for domain: %s\n", pserv2->s_name ); |
|
|
|
ok ( pserv1 == pserv2, "winsock allocated more than one servent structure per thread\n" ); |
|
} |
|
} |
|
|
|
static void test_getservbyname() |
|
{ |
|
int i; |
|
HANDLE starttest, thread[NUM_THREADS]; |
|
DWORD thread_id[NUM_THREADS]; |
|
|
|
starttest = CreateEvent ( NULL, 1, 0, "test_getservbyname_starttest" ); |
|
|
|
/* create threads */ |
|
for ( i = 0; i < NUM_THREADS; i++ ) { |
|
thread[i] = CreateThread ( NULL, 0, (LPTHREAD_START_ROUTINE) &do_getservbyname, &starttest, 0, &thread_id[i] ); |
|
} |
|
|
|
/* signal threads to start */ |
|
SetEvent ( starttest ); |
|
|
|
for ( i = 0; i < NUM_THREADS; i++) { |
|
WaitForSingleObject ( thread[i], TEST_TIMEOUT * 1000 ); |
|
} |
|
} |
|
|
static void test_WSAAddressToStringA() | static void test_WSAAddressToStringA() |
{ | { |
INT ret; | INT ret; |
|
|
trace ( " **** TEST %d COMPLETE **** \n", i ); | trace ( " **** TEST %d COMPLETE **** \n", i ); |
} | } |
| |
|
test_getservbyname(); |
|
|
test_WSAAddressToStringA(); | test_WSAAddressToStringA(); |
test_WSAAddressToStringW(); | test_WSAAddressToStringW(); |
| |