840 Commits

Author SHA1 Message Date
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
Khazhismel Kumykov
08cd206c4a test-tool: fix async read/write test for bs != 512
Signed-off-by: Khazhismel Kumykov <khazhy@google.com>
2019-07-14 12:47:47 +10:00
Khazhismel Kumykov
4409521cb6 test-tool: fix mpio_async_caw for bs != 512
wr_buf was hardcoded with blocksize 512, resulting in incorrect behavior
for larger block sizes, and buffer overflow. Use the block_size global.

Signed-off-by: Khazhismel Kumykov <khazhy@google.com>
2019-07-14 07:46:08 +10:00
David Disseldorp
cdf32e64d7 test_multipathio_simple: change data with path
This makes the data consistency check slightly more useful.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2019-07-09 11:24:33 +02:00
David Disseldorp
1af3314e2b test-tool: fix MPIO clear_pr() behaviour
clear_pr() can be called before connect_scsi_device() has been invoked
on each MPIO sdev. This results in a NULL pointer dereference in the
send_scsi_command() MPIO NOP-responder code-path.

Fix this by invoking clear_pr() after the MPIO connect_scsi_device()
loop has run. clear_pr() also only needs to be invoked via a single
path, so do so via the first path only.

Link: https://github.com/sahlberg/libiscsi/issues/289
Fixes: 16435a9 ("iscsi-test-cu: Improve persistent reservation clearing")
Signed-off-by: David Disseldorp <ddiss@suse.de>
2019-04-15 14:32:54 +02:00
Tim Crawford
9347cfebf2 Replace file variables with .dir-locals.el
Signed-off-by: Tim Crawford <tcrawford@datto.com>
2019-02-21 11:54:02 -05:00
Bart Van Assche
16435a917d iscsi-test-cu: Improve persistent reservation clearing
Clear persistent reservations before sending the first SCSI command to the
target to avoid that that command fails due to persistent reservations left
behind by a previous run of the test tool.

Avoid that a subsequent test fails if a test did not remove the persistent
reservations it obtained.

Make sure that clear_pr() returns -1 if clearing persistent reservations
fails.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2019-01-13 11:53:09 -08:00
Bart Van Assche
1bd1232a2a Move the clear_pr() function definition
This patch does not change any functionality.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2019-01-13 11:52:47 -08:00
Bart Van Assche
a15c2a5c61 test-tool/test_prin_read_keys_truncate: Do not crash if PERSISTENT RESERVE IN fails
Do not try to dereference the 'rk' pointer if it is NULL.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2019-01-13 11:48:08 -08:00
Ronnie Sahlberg
a7a14cc66c Merge pull request #271 from SexyC/master
Fix the 0 blocks writesame failed when target claims supporting maxim…
2018-10-02 06:45:14 +10:00
yayang1
8a3375e459 Fix the 0 blocks writesame failed when target claims supporting maximum writesame length to LUN's total blocks number.
When target claim it support maximum writesame length to the total blocks number, when
we trigger 0blocks writesame opertion, we should expect it to be succeed instread of failure.
2018-09-28 02:31:28 +00:00
David Disseldorp
ab0e40d689 test-tool: add PrinReadKeys.Truncate test
This test registers PR key and then sends a PR-In read-keys request with
an ALLOCATION LENGTH value that forces response truncation. Ensure that
the ADDITIONAL LENGTH is *not* modified as a result of the truncation.

This test currently passes against TGT but fails against LIO (fix
pending).

Signed-off-by: David Disseldorp <ddiss@suse.de>
2018-05-31 23:31:17 +02:00
David Disseldorp
31ab1e1ac9 test-tool: add prin_read_keys() allocation_len parameter
Accepting an Allocation Length parameter allows us to test for
truncation of response data, as per SPC5r17 4.2.5.6:
  The device server shall terminate transfers to the Data-In Buffer when
  the number of bytes or blocks specified by the ALLOCATION LENGTH field
  have been transferred or when all available data have been
  transferred, whichever is less.

With this change, all existing prin_read_keys() callers continue to use
same ALLOCATION LENGTH value as earlier (16K).

Signed-off-by: David Disseldorp <ddiss@suse.de>
2018-05-31 23:08:39 +02:00
David Disseldorp
58642c6d72 tests: drop duplicate PR-unsupported log messages
The helper function -2 return paths already print this message, so the
duplicate in the caller can be dropped.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2018-05-29 16:43:19 +02:00
Bart Van Assche
4d1918859f 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>
2018-03-02 14:02:25 -08:00
Bart Van Assche
8f2abea4de test-tool/test_compareandwrite_simple: Limit the number of blocks used
Make sure that 'maxbl' does not exceed the LUN capacity.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
2018-03-02 14:02:25 -08:00
Bart Van Assche
18de10174b test-tool/test_compareandwrite_simple(): Fix end-of-LUN test
Make sure that the end-of-LUN test happens at the end of the LUN instead
of at the start of the LUN.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
2018-03-02 14:02:22 -08:00
Bart Van Assche
8f468b14fc test-tool/test_compareandwrite_*: Stop at end of medium
Since the argument num_blocks - i is passed as the LBA argument
to COMPAREANDWRITE(), avoid that a negative number is passed.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
2018-03-02 14:02:18 -08:00