From 53eca40fad6e636b4de35a1fceaa46f96b68b6d0 Mon Sep 17 00:00:00 2001 From: Alex Young Date: Mon, 23 Jul 2012 15:45:39 +0100 Subject: [PATCH] Fix tests broken by entrust removal Missed check_readwrite and check_flexnbd --- tests/unit/check_flexnbd.c | 5 +---- tests/unit/check_readwrite.c | 33 +++++++++++++++------------------ 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/tests/unit/check_flexnbd.c b/tests/unit/check_flexnbd.c index aa64bbe..bff82e4 100644 --- a/tests/unit/check_flexnbd.c +++ b/tests/unit/check_flexnbd.c @@ -7,15 +7,12 @@ START_TEST( test_listening_assigns_sock ) { struct flexnbd * flexnbd = flexnbd_create_listening( "127.0.0.1", - NULL, "4777", - NULL, "fakefile", "fakesock", 0, 0, - NULL, - 1 ); + NULL ); fail_if( NULL == flexnbd->control->socket_name, "No socket was copied" ); } END_TEST diff --git a/tests/unit/check_readwrite.c b/tests/unit/check_readwrite.c index d72fc3c..88a0ece 100644 --- a/tests/unit/check_readwrite.c +++ b/tests/unit/check_readwrite.c @@ -9,6 +9,9 @@ #include #include #include +#include +#include +#include #include #include @@ -56,6 +59,7 @@ void * responder( void *respond_uncast ) else { fd_write_reply( sock_fd, resp->received.handle, 0 ); } + write( sock_fd, "12345678", 8 ); } return NULL; } @@ -85,14 +89,16 @@ void respond_destroy( struct respond * respond ){ } -void * entruster( void * nothing __attribute__((unused))) +void * reader( void * nothing __attribute__((unused))) { DECLARE_ERROR_CONTEXT( error_context ); error_set_handler( (cleanup_handler *)error_marker, error_context ); struct respond * respond = respond_create( 1 ); + int devnull = open("/dev/null", O_WRONLY); + char outbuf[8] = {0}; - socket_nbd_entrust( respond->sock_fds[0] ); + socket_nbd_read( respond->sock_fds[0], 0, 8, devnull, outbuf, 1 ); return NULL; } @@ -101,13 +107,14 @@ START_TEST( test_rejects_mismatched_handle ) { error_init(); - pthread_t entruster_thread; + pthread_t reader_thread; log_level=5; marker = 0; - pthread_create( &entruster_thread, NULL, entruster, NULL ); - FATAL_UNLESS( 0 == pthread_join( entruster_thread, NULL ), "pthread_join failed"); + pthread_create( &reader_thread, NULL, reader, NULL ); + FATAL_UNLESS( 0 == pthread_join( reader_thread, NULL ), + "pthread_join failed"); log_level=2; @@ -120,19 +127,10 @@ START_TEST( test_accepts_matched_handle ) { struct respond * respond = respond_create( 0 ); - socket_nbd_entrust( respond->sock_fds[0] ); + int devnull = open("/dev/null", O_WRONLY); + char outbuf[8] = {0}; - respond_destroy( respond ); -} -END_TEST - - -START_TEST( test_entrust_type_sent ) -{ - struct respond * respond = respond_create( 0 ); - - socket_nbd_entrust( respond->sock_fds[0] ); - fail_unless( respond->received.type == REQUEST_ENTRUST, "Wrong type sent." ); + socket_nbd_read( respond->sock_fds[0], 0, 8, devnull, outbuf, 1 ); respond_destroy( respond ); } @@ -159,7 +157,6 @@ Suite* readwrite_suite(void) tcase_add_test(tc_transfer, test_rejects_mismatched_handle); tcase_add_exit_test(tc_transfer, test_accepts_matched_handle, 0); - tcase_add_test( tc_transfer, test_entrust_type_sent ); /* This test is a little funny. We respond with a dodgy handle * and check that this *doesn't* cause a message rejection,