test-tool: Avoid crashes due to NULL-pointer dereferences

Avoid that certain test failures cause the test tool to trigger a
segmentation fault.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
This commit is contained in:
Bart Van Assche
2017-10-30 16:58:09 -07:00
parent 8f2abea4de
commit 4d1918859f
3 changed files with 17 additions and 2 deletions
+5 -1
View File
@@ -51,7 +51,7 @@ test_prin_report_caps_simple(void)
int ret = 0;
const unsigned long long key = rand_key();
struct scsi_task *tsk;
struct scsi_persistent_reserve_in_report_capabilities *rcaps;
struct scsi_persistent_reserve_in_report_capabilities *rcaps = NULL;
struct test_prin_report_caps_types *type;
CHECK_FOR_DATALOSS;
@@ -71,6 +71,10 @@ test_prin_report_caps_simple(void)
ret = prin_report_caps(sd, &tsk, &rcaps);
CU_ASSERT_EQUAL(ret, 0);
CU_ASSERT_NOT_EQUAL(rcaps, NULL);
if (!rcaps)
return;
logging(LOG_VERBOSE,
"Checking PERSISTENT RESERVE IN REPORT CAPABILITIES fields.");