test-tool: add test_get_clock_sec() helper
Useful for test IO timeouts. Signed-off-by: David Disseldorp <ddiss@suse.de>
This commit is contained in:
@@ -3028,3 +3028,22 @@ test_iscsi_tur_until_good(struct scsi_device *iscsi_sd, int *num_uas)
|
|||||||
|
|
||||||
return -ETIMEDOUT;
|
return -ETIMEDOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t
|
||||||
|
test_get_clock_sec(void)
|
||||||
|
{
|
||||||
|
uint64_t secs;
|
||||||
|
int res;
|
||||||
|
|
||||||
|
#ifdef HAVE_CLOCK_GETTIME
|
||||||
|
struct timespec ts;
|
||||||
|
res = clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
|
secs = ts.tv_sec;
|
||||||
|
#else
|
||||||
|
struct timeval tv;
|
||||||
|
res = gettimeofday(&tv, NULL);
|
||||||
|
secs = tv.tv_sec;
|
||||||
|
#endif
|
||||||
|
assert(res == 0);
|
||||||
|
return secs;
|
||||||
|
}
|
||||||
|
|||||||
@@ -859,4 +859,7 @@ int receive_copy_results(struct scsi_task **task, struct scsi_device *sdev,
|
|||||||
void **datap, int status, enum scsi_sense_key key,
|
void **datap, int status, enum scsi_sense_key key,
|
||||||
int *ascq, int num_ascq);
|
int *ascq, int num_ascq);
|
||||||
int test_iscsi_tur_until_good(struct scsi_device *iscsi_sd, int *num_uas);
|
int test_iscsi_tur_until_good(struct scsi_device *iscsi_sd, int *num_uas);
|
||||||
|
|
||||||
|
uint64_t test_get_clock_sec(void);
|
||||||
|
|
||||||
#endif /* _ISCSI_SUPPORT_H_ */
|
#endif /* _ISCSI_SUPPORT_H_ */
|
||||||
|
|||||||
Reference in New Issue
Block a user