test/multipath: add helper to check that all paths are iSCSI

MPATH_SKIP_UNLESS_ISCSI(_sds, _num_sds) iterates over all _sds, and
skips the test unless all paths are iSCSI based.

Signed-off-by: David Disseldorp <ddiss@suse.de>
This commit is contained in:
David Disseldorp
2015-09-17 18:03:41 +02:00
parent 2e59742b1f
commit 6b3ee9931a
2 changed files with 33 additions and 3 deletions

View File

@@ -369,3 +369,19 @@ mpath_check_matching_ids(int num_sds,
ret = mpath_check_matching_ids_serial_vpd(num_sds, sds);
return ret;
}
int
mpath_count_iscsi(int num_sds,
struct scsi_device **sds)
{
int i;
int found = 0;
for (i = 0; i < num_sds; i++) {
if (sds[i]->iscsi_ctx != NULL) {
found++;
}
}
return found;
}

View File

@@ -24,6 +24,13 @@
extern int mp_num_sds;
extern struct scsi_device *mp_sds[MPATH_MAX_DEVS];
int
mpath_check_matching_ids(int num_sds,
struct scsi_device **sds);
int
mpath_count_iscsi(int num_sds,
struct scsi_device **sds);
#define MPATH_SKIP_IF_UNAVAILABLE(_sds, _num_sds) \
do { \
if (_num_sds <= 1) { \
@@ -35,8 +42,15 @@ do { \
} \
} while (0);
int
mpath_check_matching_ids(int num_sds,
struct scsi_device **sds);
#define MPATH_SKIP_UNLESS_ISCSI(_sds, _num_sds) \
do { \
if (mpath_count_iscsi(_num_sds, _sds) != _num_sds) { \
logging(LOG_NORMAL, "[SKIPPED] Non-iSCSI multipath." \
" Skipping test"); \
CU_PASS("[SKIPPED] Non-iSCSI multipath." \
" Skipping test"); \
return; \
} \
} while (0);
#endif /* _ISCSI_MULTIPATH_H_ */