From 5231923bc8896fd8992c38005b79f5e9fba0288a Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 2 Oct 2015 14:25:29 -0700 Subject: [PATCH] test_read6_beyond_eol: Fix an assertion failure Avoid that running the regression tests against a LUN with size zero triggers the following assertion failure: lt-iscsi-test-cu: iscsi-support.c:1666: read6: Assertion `task != ((void *)0)' failed. Aborted Signed-off-by: Bart Van Assche --- test-tool/test_read6_beyond_eol.c | 6 +++++- test-tool/test_read6_simple.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test-tool/test_read6_beyond_eol.c b/test-tool/test_read6_beyond_eol.c index b0020ef..4ceee34 100644 --- a/test-tool/test_read6_beyond_eol.c +++ b/test-tool/test_read6_beyond_eol.c @@ -37,7 +37,7 @@ test_read6_beyond_eol(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test READ6 1-255 blocks one block beyond the end"); - for (i = 1; i <= 255; i++) { + for (i = 1; i <= 255 && i + 0U <= num_blocks + 1; i++) { ret = read6(sd, NULL, num_blocks + 1 - i, i * block_size, block_size, NULL, EXPECT_LBA_OOB); @@ -58,6 +58,10 @@ test_read6_beyond_eol(void) CU_ASSERT_EQUAL(ret, 0); } + if (num_blocks == 0) { + CU_PASS("LUN is too small for read-beyond-eol tests with READ6. Skipping test.\n"); + return; + } logging(LOG_VERBOSE, "Test READ6 2-255 blocks all but one block beyond the end"); for (i = 2; i <= 255; i++) { diff --git a/test-tool/test_read6_simple.c b/test-tool/test_read6_simple.c index b215dd3..c426393 100644 --- a/test-tool/test_read6_simple.c +++ b/test-tool/test_read6_simple.c @@ -54,7 +54,7 @@ test_read6_simple(void) if (num_blocks > 0x200000) { CU_PASS("LUN is too big for read-at-eol tests with READ6. Skipping test.\n"); } else { - for (i = 1; i <= 255; i++) { + for (i = 1; i <= 255 && i + 0U <= num_blocks; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; }