From afe76debf7c713d64b955b966ed52f49bfa3f731 Mon Sep 17 00:00:00 2001 From: nick Date: Mon, 8 Jul 2013 14:27:04 +0100 Subject: [PATCH] flexnbd status: Actually output pass statistics --- src/status.c | 2 ++ tests/unit/check_status.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/status.c b/src/status.c index 4ce697c..841d47f 100644 --- a/src/status.c +++ b/src/status.c @@ -44,6 +44,8 @@ int status_write( struct status * status, int fd ) if ( status->is_mirroring ) { PRINT_INT( migration_pass ); + PRINT_UINT64( pass_dirty_bytes ); + PRINT_UINT64( pass_clean_bytes ); } dprintf(fd, "\n"); diff --git a/tests/unit/check_status.c b/tests/unit/check_status.c index 8697337..ebbb198 100644 --- a/tests/unit/check_status.c +++ b/tests/unit/check_status.c @@ -255,6 +255,39 @@ START_TEST( test_renders_migration_pass ) } END_TEST +START_TEST( test_renders_pass_statistics ) +{ + struct status status; + int fds[2]; + pipe(fds); + char buf[1024] = {0}; + char *found; + + status.is_mirroring = 0; + status.pass_dirty_bytes = 2048; + status.pass_clean_bytes = 4096; + status_write( &status, fds[1] ); + + fail_unless( read_until_newline( fds[0], buf, 1024 ) > 0, + "Couldn't read the result" ); + found = strstr( buf, "pass_dirty_bytes" ); + fail_if( NULL != found, "migration pass output when not migrating" ); + + found = strstr( buf, "pass_clean_bytes" ); + fail_if( NULL != found, "migration pass output when not migrating" ); + + status.is_mirroring = 1; + status_write( &status, fds[1] ); + + fail_unless( read_until_newline( fds[0], buf, 1024 ) > 0, + "Couldn't read the result" ); + found = strstr( buf, "pass_dirty_bytes=2048" ); + fail_if( NULL == found, "migration pass not output when not migrating" ); + found = strstr( buf, "pass_clean_bytes=4096" ); + fail_if( NULL == found, "migration pass not output when not migrating" ); + +} +END_TEST Suite *status_suite(void) @@ -277,6 +310,7 @@ Suite *status_suite(void) tcase_add_test(tc_render, test_renders_pid); tcase_add_test(tc_render, test_renders_size); tcase_add_test(tc_render, test_renders_migration_pass); + tcase_add_test(tc_render, test_renders_pass_statistics); suite_add_tcase(s, tc_create); suite_add_tcase(s, tc_render);