Commit Graph

807 Commits

Author SHA1 Message Date
David Disseldorp
957cc96232 test-tool: add COMPARE AND WRITE MiscompareSense test
This test checks regular sense/ascq values on miscompare as well as
the Information sense field, which should be set as follows:
  sense key set to MISCOMPARE and the additional sense code set to
  MISCOMPARE DURING VERIFY OPERATION. In the sense data (see 4.18 and
  SPC-5) the offset from the start of the Data-Out Buffer to the first
  byte of data that was not equal shall be reported in the INFORMATION
  field.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-10-19 14:54:58 +02:00
Aleksandr Miloserdov
f342056a52 test-tool: add version descriptor checks for more SBC-3 versions
If device claims SBC-3 version in its version descriptors it won't be marked as SBC-3 compliant.

This commit adds checks for:
* SBC-3 T10/BSR INCITS 514 revision 35
* SBC-3 T10/BSR INCITS 514 revision 36
* SBC-3 ANSI INCITS 514-2014
2020-09-11 13:26:26 +03:00
Consus
859070854d test-tool: Fix CmdSN tests
After commit 10868c491d CmdSN tests no
longer work because iscsi->cmdsn is incremented during the second test
phase (sending "good" TUR after "bad" TUR), so the resulting CmdSN is
not ExpCmdSN, but ExpCmdSN + 1 that is not acknowledged by the target.
This commit fixes the issue by setting iscsi->cmdsn to iscsi->expcmdsn - 1.

Affected tests:

 * iSCSI.iSCSIcmdsn.iSCSICmdSnTooLow
 * iSCSI.iSCSIcmdsn.iSCSICmdSnTooHigh
2020-09-03 09:56:52 +03:00
Dharmesh Shah
5553d6bddf test-tool/test_async_lu_reset_simple: Move an assert statement
In the test iSCSI.iSCSITMF.LUNResetSimpleAsync
CU_ASSERT_EQUAL(reconnect_succeeded, 1) must be called after the async
TMF command completes. Hence move that assert into the TMF completion
callback.

This patch fixes a race condition.

[bvanassche: edited commit message]
2020-09-01 13:37:20 -07:00
David Disseldorp
54b3dcaa30 test-tool: add LogoutDuringIOAsync test case
This attempts to reproduce upstream LIO reports of a use after free bug
when logout occurs alongside concurrent I/O.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-08-18 17:12:28 +02:00
David Disseldorp
4080c09839 test-tool: rename async write dispatch/complete counters
Add an io_ prefix, to differentiate between I/O and future iSCSI Logout
request tracking.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-08-18 16:43:54 +02:00
Consus
9e160e02b6 test-tool: Use block_size instead of hardcoded 512 bytes
Fix another couple of tests that fail on 4Kn drives:

* iSCSI.iSCSITMF.AbortTaskSimpleAsync
* iSCSI.iSCSITMF.LUNResetSimpleAsync
2020-08-10 15:59:49 +03:00
Consus
7258fbfd83 test-tool: Use block_size instead of hardcoded 512 bytes
This commit fixes some tests (like ProutReserve) on pure 4k devices.
2020-06-17 15:50:44 +03:00
Bart Van Assche
33c66f2c39 test-tool, compare and write: Reduce maximum number of blocks from 256 to 255
Since the NUMBER OF LOGICAL BLOCKS field in the COMPARE AND WRITE command
is an 8 bit field, the maximum value that can be encoded is 255.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-05-21 18:39:49 -07:00
Bart Van Assche
b4d59cd29c test_compareandwrite_invalid_dataout_size: Simplify this test
Assign the NUMBER OF LOGICAL BLOCKS field in the COMPARE AND WRITE PDU
directly. Use the terminology from SBC-4, namely NUMBER OF LOGICAL BLOCKS
instead of TL.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-05-21 18:39:49 -07:00
Bart Van Assche
9fcdce3101 test-tool: Use asprintf() in sg_send_scsi_cmd()
Use asprintf() instead of snprintf() + strdup().

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-05-15 10:40:00 -07:00
Bart Van Assche
b9effb556f test-tool: Fix a comment in sg_send_scsi_cmd()
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-05-14 11:50:57 -07:00
Bart Van Assche
6aa5acb659 test-tool: Split send_scsi_command()
This patch does not change any functionality.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-05-14 11:47:56 -07:00
David Disseldorp
a89583aec3 test/xcopy_simple: add XCOPY test with 0x0A segment descriptor
Check for 0x0A descriptor support via SCSI_COPY_RESULTS_OP_PARAMS. If
supported, perform a 0x0A type XCOPY using target's
maximum_segment_length (or 256M if larger).

Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-03-18 18:59:43 +01:00
David Disseldorp
c8992f45b1 test: add support for 0x0A type XCOPY segment descriptors
Type 0x0A segment descriptors provide a 32-bit wide number-of-bytes
field, allowing for much larger copy offloads with a single segment
descriptor.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-03-18 18:59:34 +01:00
David Disseldorp
385c6e8ae9 test/xcopy_simple: zero destination range before copy
Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-03-18 18:59:34 +01:00
David Disseldorp
da7c1c4b0a test: use spec defined XCOPY segment descriptor lengths
The SPC4r37 specification defines XCOPY Segment Descriptor lengths for
each SD type. The spec defined SD lengths don't account for the four SD
header bytes. To make it easier to match the spec to the implementation,
use the spec defined lengths in get_desc_len() with a four byte SD
header addition.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-03-18 00:49:36 +01:00
David Disseldorp
8dbf6e51e2 test: use scsi_set_uintX marshalling helpers for XCOPY
Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-03-18 00:49:36 +01:00
shawn
dfff7e9d16 specify number of blocks in write_same command
If "number of blocks" is 0, write_same will not erase the LBA range and
read-verify will fail.
2020-03-03 17:31:50 -08:00
Bart Van Assche
529350eab1 Do not cast away constness
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-02-28 21:54:49 -08:00
Bart Van Assche
3804f3c2e0 Remove the discard_const() macro
Declare dynamically allocated strings as 'char *' instead of 'const char *'.
Remove the discard_const() macro. Do not test whether or not a pointer is
NULL before calling free() because it is allowed to pass NULL to free().

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-02-28 21:54:49 -08:00
Bart Van Assche
69c4783d2d test-tool: Give up if READ CAPACITY reports that the block size is zero
Since the test tool can't proceed in a meaningful way if the block size
is zero, give up if the SCSI target reports that the block size is zero.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-02-23 20:11:14 -08:00
Bart Van Assche
eeb7ebaeab Merge pull request #306 from bvanassche/master
Improve robustness of the code that restores .queue_pdu()
2020-02-23 20:09:31 -08:00
Cole Robinson
ea89dcdbf1 test-tool: Use 'extern int' in headers
Without this, linking fails on Fedora rawhide. Example:

...
/usr/bin/ld: test_async_lu_reset_simple.o:/root/libiscsi/libiscsi.git/test-tool/iscsi-support.h:59: multiple definition of `param_list_len_err_ascqs'; iscsi-test-cu.o:/root/libiscsi/libiscsi.git/test-tool/iscsi-support.h:59: first defined here
/usr/bin/ld: test_async_lu_reset_simple.o:/root/libiscsi/libiscsi.git/test-tool/iscsi-support.h:58: multiple definition of `invalid_cdb_ascqs'; iscsi-test-cu.o:/root/libiscsi/libiscsi.git/test-tool/iscsi-support.h:58: first defined here
...

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-02-15 18:03:11 -05:00
Bart Van Assche
cc3ddbff42 Improve robustness of the code that restores .queue_pdu()
In my tests I hit a stack overflow caused by infinite recursion of
.queue_pdu() calls, caused by .queue_pdu() not being restored in an
error path. Make the approach for restoring .queue_pdu() more robust.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2019-11-12 18:12:27 -08:00
Ronnie Sahlberg
10599fcd4f Merge pull request #305 from bvanassche/master
Use dynamic memory allocation instead of variable-length arrays
2019-11-12 18:46:46 +10:00
Khazhismel Kumykov
2b9c928bce test-tool: avoid use-after-free on iscsi_logout_sync
iscsi_logout_sync in lu_reset_simple will still refer to wtask in the
case that we bail out due to reconnect failure.

abort_simple would sometimes refer to wtask during iscsi_logout_sync,
even if the test passed.

Signed-off-by: Khazhismel Kumykov <khazhy@google.com>
2019-11-12 18:45:08 +10:00
Bart Van Assche
9d2493248b Use dynamic memory allocation instead of variable-length arrays
Since it is easy to trigger a stack overflow with variable-length arrays,
use dynamic memory allocation instead of VLAs. Add -Wvla to the compiler
options such that no new VLAs get introduced.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2019-11-09 13:39:34 -08:00
Bart Van Assche
2bbf7b5017 test-tool: If SG_IO fails, report why it failed
See also https://github.com/sahlberg/libiscsi/issues/302.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2019-10-31 14:16:56 -07:00
David Disseldorp
84d80878a6 test-tool: add iSCSI CHAP_A negotiation tests
The iSCSICHAP.Simple test ensures that CHAP_A comma separated lists
are correctly handled. iSCSICHAP.Invalid tests a range of invalid
CHAP_A parameters.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2019-09-23 16:46:26 +02:00
David Disseldorp
e716691a45 test-tool: use CHECK_FOR_ISCSI() helper macro
This removes a large amount of boilerplate code.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2019-09-22 16:40:13 +02:00
David Disseldorp
2600e538d8 test-tool: add CHECK_FOR_ISCSI() test filter macro
Skip the test if the provided iscsi_ctx is null.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2019-09-22 16:40:13 +02:00
David Disseldorp
1511ddcbe4 test-tool: add simple iSCSI NOP-Out test
Send a ping with/without data and expect a valid response.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2019-09-22 16:40:13 +02:00
David Disseldorp
98d383d159 test-tool: add iSCSI SendTargets.Invalid test case
This test sends a series of Text request PDUs with key-value data that
doesn't match SendTargets=All.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2019-09-22 16:40:13 +02:00
David Disseldorp
955b16b3e3 test-tool: add iSCSI SendTargets.Simple test
This test currently only sends a SendTargets request via existing normal
iSCSI sessions.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2019-09-22 16:07:52 +02:00
David Disseldorp
d8946c4548 test-tool: replace some manual PDU tweaks with helper calls
For now this only changes iSCSIDataSnInvalid to use
iscsi_pdu_set_datasn() instead of scsi_set_uint32().
iSCSICmdSnTooHigh/Low changes should also be possible, as noted, but
haven't been converted yet.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2019-09-18 01:25:39 +02:00
David Disseldorp
2714f7705a test-tool/build: link against libiscsipriv.la
libiscsipriv.la exposes all symbols, so allows tests to perform low
level PDU manipulation, etc. without duplicating code.
As a trade-off, this results in a larger iscsi-test-cu, with libiscsi.so
linking removed.

Link: https://github.com/sahlberg/libiscsi/issues/297
Signed-off-by: David Disseldorp <ddiss@suse.de>
2019-09-18 01:25:34 +02:00
David Disseldorp
dd17293bcc test-tool: remove unused iscsi_queue_pdu() symbol overload
All users have now been changed to overload via the iscsi_ctx transport
callback, so the dlsym based overloading can now be dropped.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2019-09-16 19:29:52 +02:00
David Disseldorp
2ae45ac15d test-tool/OverwriteReserved: override driver queue_pdu() callback
In preparation for removing the test-tool iscsi_queue_pdu() dlsym
overload hack, convert this test to use the regular transport driver
callback for this purpose.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2019-09-16 19:29:52 +02:00
David Disseldorp
e5cc079e7c test-tool/OverwriteReserved: skip unless iSCSI
This test performs PDU manipulation so should only be run against iSCSI
devices.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2019-09-16 19:29:52 +02:00
David Disseldorp
77279dd44f test-tool/CryptoEraseReserved: override driver queue_pdu() callback
In preparation for removing the test-tool iscsi_queue_pdu() dlsym
overload hack, convert this test to use the regular transport driver
callback for this purpose.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2019-09-16 19:29:52 +02:00
David Disseldorp
c830a3b55e test-tool/CryptoEraseReserved: skip unless iSCSI
This test performs PDU manipulation so should only be run against iSCSI
devices.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2019-09-16 19:29:52 +02:00
David Disseldorp
b705f9e524 test-tool/BlockEraseReserved: override driver queue_pdu() callback
In preparation for removing the test-tool iscsi_queue_pdu() dlsym
overload hack, convert this test to use the regular transport driver
callback for this purpose.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2019-09-16 19:29:52 +02:00
David Disseldorp
fdc45fadfa test-tool/BlockEraseReserved: skip unless iSCSI
This test performs PDU manipulation so should only be run against iSCSI
devices.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2019-09-16 19:29:52 +02:00
David Disseldorp
153ca193fa test-tool/iSCSIDataSnInvalid: override driver queue_pdu() callback
In preparation for removing the test-tool iscsi_queue_pdu() dlsym
overload hack, convert this test to use the regular transport driver
callback for this purpose.
This commit also removes a number of unnecessary "WRITE10 is not
implemented" checks, which should all be caught by the first check.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2019-09-16 19:29:52 +02:00
David Disseldorp
575ba2244c test-tool/iSCSICmdSnTooHigh: override driver queue_pdu() callback
In preparation for removing the test-tool iscsi_queue_pdu() dlsym
overload hack, convert this test to use the regular transport driver
callback for this purpose.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2019-09-16 19:16:30 +02:00
David Disseldorp
c067eef9c1 test-tool/iSCSICmdSnTooLow: override driver queue_pdu() callback
In preparation for removing the test-tool iscsi_queue_pdu() dlsym
overload hack, convert this test to use the regular transport driver
callback for this purpose.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2019-09-16 19:16:30 +02:00
David Disseldorp
310e9ace02 test-tool/Compare&Write: override driver queue_pdu() callback
In preparation for removing the test-tool iscsi_queue_pdu() dlsym
overload hack, convert the Compare&Write InvalidDataOutSize test to use
the regular transport driver callback for this purpose.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2019-09-16 19:16:30 +02:00
David Disseldorp
60a5856f00 test-tool/Compare&Write: skip InvalidDataOutSize unless iSCSI
This test performs PDU manipulation so should only be run against iSCSI
devices.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2019-09-16 19:16:30 +02:00
Khazhismel Kumykov
22648d9dbf add some missing includes
avoids forward referenced enums, and includes standard type defns

Signed-off-by: Khazhismel Kumykov <khazhy@google.com>
2019-07-14 12:49:05 +10:00