]> git.saurik.com Git - apple/xnu.git/blobdiff - tools/tests/xnu_quick_test/socket_tests.c
xnu-2422.90.20.tar.gz
[apple/xnu.git] / tools / tests / xnu_quick_test / socket_tests.c
index c80172e19efc39608ecd217ec3c7fe0e92e804ce..e9a34380ff3c6b22c474336b407962b9442e256c 100644 (file)
@@ -12,7 +12,6 @@
 #include <mach/mach.h>
 
 extern char  g_target_path[ PATH_MAX ];
-extern int             g_is_under_rosetta;
 
 /*  **************************************************************************************************************
  *     Test accept, bind, connect, listen, socket, recvmsg, sendmsg, recvfrom, sendto, getpeername, getsockname
@@ -211,53 +210,51 @@ int socket_tests( void * the_argp )
                }
 #endif
                
-#if 1
+#if !TARGET_OS_EMBEDDED
                /* sendfile test. Open libsystem, set up some headers, and send it */
-               if (!g_is_under_rosetta) {
-                       struct sf_hdtr          my_sf_hdtr;
-                       int                                     my_libsys_fd;
-                       off_t                           my_libsys_len;
-
-                       my_libsys_fd = open("/usr/lib/libSystem.dylib", O_RDONLY, 0644);
-                       if (my_libsys_fd < 0) {
-                               printf( "test failed - could not open /usr/lib/libSystem.dylib\n" );
-                               close ( my_child_fd );
-                               exit ( -1 );
-                       }
+               struct sf_hdtr          my_sf_hdtr;
+               int                                     my_libsys_fd;
+               off_t                           my_libsys_len;
+
+               my_libsys_fd = open("/usr/lib/libSystem.dylib", O_RDONLY, 0644);
+               if (my_libsys_fd < 0) {
+                       printf( "test failed - could not open /usr/lib/libSystem.dylib\n" );
+                        close ( my_child_fd );
+                       exit ( -1 );
+               }
 
-                       my_libsys_len = 7+2; /* 2 bytes of header */
-                       my_buffer[0] = 's';
-                       my_iov[0].iov_base = &my_buffer[0];
-                       my_iov[0].iov_len = 1;
-                       my_buffer[1] = 'e';
-                       my_iov[1].iov_base = &my_buffer[1];
-                       my_iov[1].iov_len = 1;
-                       my_buffer[2] = 'n';
-                       my_iov[2].iov_base = &my_buffer[2];
-                       my_iov[2].iov_len = 1;
-                       my_buffer[3] = 'd';
-                       my_iov[3].iov_base = &my_buffer[3];
-                       my_iov[3].iov_len = 1;
-
-                       my_sf_hdtr.headers = &my_iov[0];
-                       my_sf_hdtr.hdr_cnt = 2;
-                       my_sf_hdtr.trailers = &my_iov[2];
-                       my_sf_hdtr.trl_cnt = 2;
+               my_libsys_len = 7+2; /* 2 bytes of header */
+               my_buffer[0] = 's';
+               my_iov[0].iov_base = &my_buffer[0];
+               my_iov[0].iov_len = 1;
+               my_buffer[1] = 'e';
+               my_iov[1].iov_base = &my_buffer[1];
+               my_iov[1].iov_len = 1;
+               my_buffer[2] = 'n';
+               my_iov[2].iov_base = &my_buffer[2];
+               my_iov[2].iov_len = 1;
+               my_buffer[3] = 'd';
+               my_iov[3].iov_base = &my_buffer[3];
+               my_iov[3].iov_len = 1;
+
+               my_sf_hdtr.headers = &my_iov[0];
+               my_sf_hdtr.hdr_cnt = 2;
+               my_sf_hdtr.trailers = &my_iov[2];
+               my_sf_hdtr.trl_cnt = 2;
                        
-                       my_result = sendfile(my_libsys_fd, my_child_fd, 3, &my_libsys_len, &my_sf_hdtr, 0);
-                       if (my_result < 0 || my_libsys_len != 11) {
-                               printf( "sendfile failed with error %d - \"%s\" \n", errno, strerror( errno) );
-                               close( my_child_fd );
-                               exit( -1 );
-                       }
+               my_result = sendfile(my_libsys_fd, my_child_fd, 3, &my_libsys_len, &my_sf_hdtr, 0);
+               if (my_result < 0 || my_libsys_len != 11) {
+                       printf( "sendfile failed with error %d - \"%s\" \n", errno, strerror( errno) );
+                       close( my_child_fd );
+                       exit( -1 );
+               }
 
-                       my_result = close ( my_libsys_fd );
-                       if ( my_libsys_fd < 0 ) {
-                               printf ( "close failed with error %d - \"%s\" \n", errno, strerror( errno) );
-                               close ( my_child_fd );
-                               exit ( -1 );
-                       }
-               }               
+               my_result = close ( my_libsys_fd );
+               if ( my_libsys_fd < 0 ) {
+                       printf ( "close failed with error %d - \"%s\" \n", errno, strerror( errno) );
+                       close ( my_child_fd );
+                       exit ( -1 );
+               }
 #endif
 
                /* tell parent we're done */
@@ -331,32 +328,30 @@ int socket_tests( void * the_argp )
                }
 #endif
 
-#if 1
-               if (!g_is_under_rosetta) {
-                       size_t neededBytes = 11;
-                       
-                       /* Check for sendfile output */
-                       bzero( (void *)&my_parent_buffer[0], sizeof(my_parent_buffer) );
-                       while (neededBytes > 0) {
-                               my_result = read( my_accepted_socket, &my_parent_buffer[11-neededBytes], neededBytes );
-                               if ( my_result == -1 ) {
-                                       printf( "read call failed with error %d - \"%s\" \n", errno, strerror( errno) );
-                                       goto test_failed_exit;
-                               } else if (my_result == 0) {
-                                       break;
-                               }
-                               neededBytes -= my_result;
-                       }
+#if !TARGET_OS_EMBEDDED
+               size_t neededBytes = 11;
                        
-                       if ( neededBytes > 0 ) {
-                               printf( "read call returned %ld bytes instead of 11\n", 11 - neededBytes );
+               /* Check for sendfile output */
+               bzero( (void *)&my_parent_buffer[0], sizeof(my_parent_buffer) );
+               while (neededBytes > 0) {
+                       my_result = read( my_accepted_socket, &my_parent_buffer[11-neededBytes], neededBytes );
+                       if ( my_result == -1 ) {
+                               printf( "read call failed with error %d - \"%s\" \n", errno, strerror( errno) );
                                goto test_failed_exit;
+                       } else if (my_result == 0) {
+                               break;
                        }
+                       neededBytes -= my_result;
+               }
+                       
+               if ( neededBytes > 0 ) {
+                       printf( "read call returned %ld bytes instead of 11\n", 11 - neededBytes );
+                       goto test_failed_exit;
+               }
 
-                       if ( ! (my_parent_buffer[0] == 's' && my_parent_buffer[1] == 'e' && my_parent_buffer[9] == 'n' && my_parent_buffer[10] == 'd') ) {
-                               printf( "read wrong sendfile message from child \n" );
-                               goto test_failed_exit;
-                       }
+               if ( ! (my_parent_buffer[0] == 's' && my_parent_buffer[1] == 'e' && my_parent_buffer[9] == 'n' && my_parent_buffer[10] == 'd') ) {
+                       printf( "read wrong sendfile message from child \n" );
+                       goto test_failed_exit;
                }
                
 #endif