(file) Return to sock.c CVS log (file) (dir) Up to [RizwankCVS] / wine4 / wine / dlls / winsock / tests

Diff for /wine4/wine/dlls/winsock/tests/sock.c between version 1.18 and 1.20

version 1.18, 2005/03/15 15:54:05 version 1.20, 2005/03/15 23:14:15
Line 942 
Line 942 
  
 static void test_UDP() static void test_UDP()
 { {
       /* This function tests UDP sendto() and recvfrom(). UDP is unreliable, so it is
          possible that this test fails due to dropped packets. */
   
     /* peer 0 receives from all other peers */     /* peer 0 receives from all other peers */
         struct sock_info peer[NUM_UDP_PEERS];         struct sock_info peer[NUM_UDP_PEERS];
         char testdata[16];      char buf[16];
     char recvbuf[16];      int ss, i, n_recv, n_sent;
     int sl, i;  
  
     for ( i = NUM_UDP_PEERS - 1; i >= 0; i-- ) {     for ( i = NUM_UDP_PEERS - 1; i >= 0; i-- ) {
         ok ( ( peer[i].s = socket ( AF_INET, SOCK_DGRAM, 0 ) ) != INVALID_SOCKET, "UDP: socket failed\n" );         ok ( ( peer[i].s = socket ( AF_INET, SOCK_DGRAM, 0 ) ) != INVALID_SOCKET, "UDP: socket failed\n" );
Line 963 
Line 965 
         do_bind ( peer[i].s, (struct sockaddr *) &peer[i].addr, sizeof( peer[i].addr ) );         do_bind ( peer[i].s, (struct sockaddr *) &peer[i].addr, sizeof( peer[i].addr ) );
  
         /* test getsockname() to get peer's port */         /* test getsockname() to get peer's port */
         sl = sizeof ( peer[i].addr );          ss = sizeof ( peer[i].addr );
         ok ( getsockname ( peer[i].s, (struct sockaddr *) &peer[i].addr, &sl ) != SOCKET_ERROR, "UDP: could not getsockname()\n" );          ok ( getsockname ( peer[i].s, (struct sockaddr *) &peer[i].addr, &ss ) != SOCKET_ERROR, "UDP: could not getsockname()\n" );
         ok ( peer[i].addr.sin_port != htons ( 0 ), "UDP: bind() did not associate port\n" );         ok ( peer[i].addr.sin_port != htons ( 0 ), "UDP: bind() did not associate port\n" );
     }     }
  
Line 973 
Line 975 
  
     for ( i = 1; i < NUM_UDP_PEERS; i++ ) {     for ( i = 1; i < NUM_UDP_PEERS; i++ ) {
         /* send client's ip */         /* send client's ip */
         strcpy ( testdata, inet_ntoa ( peer[i].addr.sin_addr ) );          memcpy( buf, &peer[i].addr.sin_port, sizeof(peer[i].addr.sin_port) );
         ok ( sendto ( peer[i].s, testdata, sizeof(testdata), 0, (struct sockaddr*) &peer[0].addr, sizeof(peer[0].addr) ) != SOCKET_ERROR, "UDP: socket error on sendto(): %d\n", WSAGetLastError() );          n_sent = sendto ( peer[i].s, buf, sizeof(buf), 0, (struct sockaddr*) &peer[0].addr, sizeof(peer[0].addr) );
           ok ( n_sent == sizeof(buf), "UDP: sendto() sent wrong amount of data or socket error: %d\n", n_sent );
     }     }
  
     for ( i = 1; i < NUM_UDP_PEERS; i++ ) {     for ( i = 1; i < NUM_UDP_PEERS; i++ ) {
         ok ( recvfrom ( peer[0].s, recvbuf, sizeof(recvbuf), 0,(struct sockaddr *) &peer[0].peer, &sl ) != SOCKET_ERROR, "UDP: socket error on recvfrom(): %d\n", WSAGetLastError() );          n_recv = recvfrom ( peer[0].s, buf, sizeof(buf), 0,(struct sockaddr *) &peer[0].peer, &ss );
         ok ( ! strcmp ( inet_ntoa ( peer[0].peer.sin_addr), recvbuf ), "UDP: port numbers do not match\n" );          ok ( n_recv == sizeof(buf), "UDP: recvfrom() received wrong amount of data or socket error: %d\n", n_recv );
           ok ( memcmp ( &peer[0].peer.sin_port, buf, sizeof(peer[0].addr.sin_port) ) == 0, "UDP: port numbers do not match\n" );
     }     }
 } }
  
 static void WINAPI do_getservbyname( HANDLE *starttest ) static void WINAPI do_getservbyname( HANDLE *starttest )
 { {
     int i;      struct {
     struct servent *pserv1, *pserv2;          char *name;
           char *proto;
     WaitForSingleObject ( *starttest, INFINITE );          int port;
       } serv[2] = { {"domain", "udp", 53}, {"telnet", "tcp", 23} };
     /* first time through, should resize buffer */  
     pserv1 = getservbyname ( "telnet", "tcp" );      int i, j;
     pserv2 = getservbyname ( "kerberos" , "udp" );      struct servent *pserv[2];
     ok ( pserv1 != pserv2, "getservbyname: winsock did not reallocate servent buffer\n" );  
       ok ( WaitForSingleObject ( *starttest, TEST_TIMEOUT * 1000 ) != WAIT_TIMEOUT, "test_getservbyname: timeout waiting for start signal\n");
   
       // ensure that necessary buffer resizes are completed
       for ( j = 0; j < 2; j++) {
           pserv[j] = getservbyname ( serv[j].name, serv[j].proto );
       }
  
     for ( i = 0; i < NUM_QUERIES / 2; i++ ) {     for ( i = 0; i < NUM_QUERIES / 2; i++ ) {
         pserv1 = getservbyname ( "telnet", "tcp" );          for ( j = 0; j < 2; j++ ) {
         ok ( pserv1 != NULL, "getservbyname could not retreive information for telnet: %d\n", WSAGetLastError() );              pserv[j] = getservbyname ( serv[j].name, serv[j].proto );
         ok ( pserv1->s_port == htons(23), "getservbyname returned the wrong port for telnet: %d\n", ntohs(pserv1->s_port) );              ok ( pserv[j] != NULL, "getservbyname could not retreive information for %s: %d\n", serv[j].name, WSAGetLastError() );
         ok ( !strcmp ( pserv1->s_proto, "tcp" ), "getservbyname returned the wrong protocol for telnet: %s\n", pserv1->s_proto );              ok ( pserv[j]->s_port == htons(serv[j].port), "getservbyname returned the wrong port for %s: %d\n", serv[j].name, ntohs(pserv[j]->s_port) );
         ok ( !strcmp ( pserv1->s_name, "telnet" ), "getservbyname returned the wrong name for telnet: %s\n", pserv1->s_name );              ok ( !strcmp ( pserv[j]->s_proto, serv[j].proto ), "getservbyname returned the wrong protocol for %s: %s\n", serv[j].name, pserv[j]->s_proto );
               ok ( !strcmp ( pserv[j]->s_name, serv[j].name ), "getservbyname returned the wrong name for %s: %s\n", serv[j].name, pserv[j]->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, "getservbyname: winsock resized servent buffer when not necessary\n" );          ok ( pserv[0] == pserv[1], "getservbyname: winsock resized servent buffer when not necessary\n" );
     }     }
 } }
  


Legend:
Removed from v.1.18  
changed lines
  Added in v.1.20

Rizwan Kassim
Powered by
ViewCVS 0.9.2