test_multipathio_simple: Only compare if READ10 succeeded

Since the data in the read buffer is not valid if READ10() failed,
only compare the data in the read buffer if READ10() succeeded.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
This commit is contained in:
Bart Van Assche
2017-02-21 17:10:18 -08:00
committed by Ronnie Sahlberg
parent 0241fe8014
commit e5296920e9
2 changed files with 17 additions and 11 deletions

View File

@@ -320,7 +320,7 @@ do { \
} while (0); } while (0);
#define READ10(...) \ #define READ10(...) \
do { \ ({ \
int _r; \ int _r; \
_r = read10(__VA_ARGS__); \ _r = read10(__VA_ARGS__); \
if (_r == -2) { \ if (_r == -2) { \
@@ -331,7 +331,8 @@ do { \
return; \ return; \
} \ } \
CU_ASSERT_EQUAL(_r, 0); \ CU_ASSERT_EQUAL(_r, 0); \
} while (0); _r; \
})
#define READ12(...) \ #define READ12(...) \
do { \ do { \
@@ -602,7 +603,7 @@ do { \
} while (0); } while (0);
#define WRITE10(...) \ #define WRITE10(...) \
do { \ ({ \
int _r; \ int _r; \
_r = write10(__VA_ARGS__); \ _r = write10(__VA_ARGS__); \
if (_r == -2) { \ if (_r == -2) { \
@@ -613,7 +614,8 @@ do { \
return; \ return; \
} \ } \
CU_ASSERT_EQUAL(_r, 0); \ CU_ASSERT_EQUAL(_r, 0); \
} while (0); _r; \
})
#define WRITE12(...) \ #define WRITE12(...) \
do { \ do { \

View File

@@ -34,6 +34,7 @@ test_multipathio_simple(void)
int write_path; int write_path;
unsigned char *write_buf = alloca(256 * block_size); unsigned char *write_buf = alloca(256 * block_size);
unsigned char *read_buf = alloca(256 * block_size); unsigned char *read_buf = alloca(256 * block_size);
int ret;
CHECK_FOR_DATALOSS; CHECK_FOR_DATALOSS;
CHECK_FOR_SBC; CHECK_FOR_SBC;
@@ -58,16 +59,19 @@ test_multipathio_simple(void)
&& maximum_transfer_length < i) { && maximum_transfer_length < i) {
break; break;
} }
WRITE10(mp_sds[write_path], 0, i * block_size, ret = WRITE10(mp_sds[write_path], 0, i * block_size,
block_size, 0, 0, 0, 0, 0, write_buf, block_size, 0, 0, 0, 0, 0, write_buf,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
READ10(mp_sds[read_path], NULL, 0, i * block_size, if (ret < 0)
block_size, 0, 0, 0, 0, 0, read_buf, continue;
EXPECT_STATUS_GOOD); ret = READ10(mp_sds[read_path], NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, read_buf,
EXPECT_STATUS_GOOD);
if (ret < 0)
continue;
/* compare written and read data */ /* compare written and read data */
CU_ASSERT_EQUAL(0, ret = memcmp(write_buf, read_buf, i * block_size);
memcmp(write_buf, read_buf, i * block_size)); CU_ASSERT_EQUAL(0, ret);
} }
} }