static void test_en_us (const char *other_name) { init_loc (other_name, en_us_name); test_pair (&en_us); freelocale (loc); }
int main (void) { setup_test_environment(); test_req_rep(); test_pair(); test_client_server(); return 0 ; }
static void test_pipe (void) { int fd[2]; pipe (fd); test_pair (fd[0], fd[1]); close (fd[0]); close (fd[1]); }
static void test_pipe (void) { int fd[2]; ASSERT (pipe (fd) >= 0); test_pair (fd[0], fd[1]); close (fd[0]); if ((poll1_wait (fd[1], POLLIN | POLLOUT) & (POLLHUP | POLLERR)) == 0) failed ("expecting POLLHUP after shutdown"); close (fd[1]); }
static int do_test (void) { for (const struct locale_pair *test = tests; test->locale_name != NULL; ++test) { init_loc (en_us_name, test->locale_name); test_pair (&test->pair); freelocale (loc); test_en_us (test->locale_name); } return errors; }
static void test_socket_pair (void) { struct sockaddr_in ia; socklen_t addrlen = sizeof (ia); int s = open_server_socket (); int c1 = connect_to_socket (false); int c2 = accept (s, (struct sockaddr *) &ia, &addrlen); close (s); test_pair (c1, c2); close (c1); write (c2, "foo", 3); close (c2); }
static void test_socket_pair (void) { struct sockaddr_in ia; socklen_t addrlen = sizeof (ia); int s = open_server_socket (); int c1 = connect_to_socket (false); int c2 = accept (s, (struct sockaddr *) &ia, &addrlen); ASSERT (s >= 0); ASSERT (c1 >= 0); ASSERT (c2 >= 0); close (s); test_pair (c1, c2); close (c1); ASSERT (write (c2, "foo", 3) == 3); if ((poll1_nowait (c2, POLLIN | POLLOUT) & (POLLHUP | POLLERR)) == 0) failed ("expecting POLLHUP after shutdown"); close (c2); }
int main() { begin_test_data(expected_t) test_data( "nothing to skip!", 0, test_pair(1,1), PDS_OK ), test_data( "\t \r\n end", 8, test_pair(1,2), PDS_OK ), test_data( "/**/ end", 5, test_pair(1,1), PDS_OK ), test_data( "/* a\tlonger\tcomment */\t\r\n\r\nend", 27, test_pair(1,3), PDS_OK ), test_data(" \t/*line 1 */\n \t\t/*line 2*/\n \t\t\t/*line 3*/\nend", 44, test_pair(1,4), PDS_OK ), test_data( " /* /* nested comment */", 5, test_pair(0,1), PDS_INVALID_VALUE ), test_data( " /* muti-line \n comment */", 15, test_pair(0,1), PDS_INVALID_VALUE ), end_test_data() PDS_parser parser; memset(&parser, 0, sizeof(PDS_parser)); PDS_set_error_callback(&parser.callbacks, dummy_error); size_t i; test_foreach(i) { parser.line_num = 1; parser.first = test_str(i); parser.current = parser.first; parser.last = parser.first + strlen(parser.first) - 1; parser.status = PDS_OK; int ret; ret = PDS_skip_whitespaces(&parser); check(test_status(i) == parser.status); check(test_end(i) == parser.current); check(test_expected(i).ret == ret); check(test_expected(i).line == parser.line_num); } return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { int ierr; int rank; static char buffer[80]; MPI_Request req = MPI_REQUEST_NULL; MPI_Status status, status2; #ifdef V_T double ts; int messageframe; #endif ierr = MPI_Init(&argc,&argv); #ifdef V_T ts = VT_timestamp(); #endif /* this used to be buggy... */ MPI_Wait( &req, &status ); ierr = MPI_Barrier(MPI_COMM_WORLD); test_pair(); MPI_Comm_rank ( MPI_COMM_WORLD, &rank ); if ( getenv ("VT_ABORT_BEFORE_FINALIZE") ) { if ( atoi ( getenv ("VT_ABORT_BEFORE_FINALIZE") ) < 2 ) MPI_Abort( MPI_COMM_WORLD, 10 ); if ( !rank ) { *((char *)NULL) = 0; } else { MPI_Barrier ( MPI_COMM_WORLD ); } } /* test some other aspects of message transfer: persistent send with MPI_PROC_NULL */ MPI_Send_init( &ierr, 1, MPI_INT, MPI_PROC_NULL, 100, MPI_COMM_WORLD, &req ); MPI_Start( &req ); MPI_Wait( &req, &status ); MPI_Start( &req ); MPI_Wait( &req, &status ); MPI_Request_free( &req ); /* persistent receive with MPI_PROC_NULL */ MPI_Recv_init( &ierr, 1, MPI_INT, MPI_PROC_NULL, 100, MPI_COMM_WORLD, &req ); MPI_Start( &req ); MPI_Wait( &req, &status ); MPI_Start( &req ); MPI_Wait( &req, &status ); MPI_Request_free( &req ); /* real reuse of persistent communication */ if( rank & 1 ) { MPI_Recv_init( buffer, sizeof(buffer), MPI_CHAR, rank^1, 101, MPI_COMM_WORLD, &req ); } else { MPI_Send_init( buffer, sizeof(buffer), MPI_CHAR, rank^1, 101, MPI_COMM_WORLD, &req ); } MPI_Start( &req ); MPI_Wait( &req, &status ); MPI_Start( &req ); MPI_Wait( &req, &status ); MPI_Request_free( &req ); /* send to MPI_PROC_NULL */ MPI_Send( buffer, sizeof(buffer), MPI_CHAR, MPI_PROC_NULL, 103, MPI_COMM_WORLD ); /* cancelled receive */ MPI_Irecv( buffer, sizeof(buffer), MPI_CHAR, rank^1, 105, MPI_COMM_WORLD, &req ); MPI_Cancel( &req ); MPI_Wait( &req, &status2 ); #ifdef V_T printf( "Time: %f\n", VT_timestamp()-ts ); #endif ierr = MPI_Finalize(); return ierr; }