Commit Graph

650 Commits

Author SHA1 Message Date
Bart Van Assche
be9b803334 test-tool: Avoid that using receive_copy_results() triggers a use-after-free
Move the scsi_free_scsi_task() call from receive_copy_results() to the
callers of this function to avoid that accessing the unmarshalled data
triggers a use-after-free.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-12-24 10:38:38 -08:00
Bart Van Assche
cacc144a29 test-tool: Initialize parameter buffers
This patch avoids that Valgrind reports that an uninitialized buffer
is passed to writev():

Syscall param writev(vector[...]) points to uninitialised byte(s)
   at 0x5557D07: writev (in /lib64/libc-2.19.so)
   by 0x5269BFD: iscsi_iovector_readv_writev (socket.c:509)
   by 0x526A7A9: iscsi_write_to_socket (socket.c:727)
   by 0x526AE47: iscsi_service (socket.c:888)
   by 0x526B632: event_loop (sync.c:67)
   by 0x526D925: iscsi_scsi_command_sync (sync.c:1223)
   by 0x405970: send_scsi_command (iscsi-support.c:276)
   by 0x40B190: extendedcopy (iscsi-support.c:2673)
   by 0x40E9FE: test_extendedcopy_param (test_extendedcopy_param.c:63)
   by 0x503E260: ??? (in /usr/lib64/libcunit.so.1.0.1)
   by 0x503E56E: ??? (in /usr/lib64/libcunit.so.1.0.1)
   by 0x503E8A5: CU_run_all_tests (in /usr/lib64/libcunit.so.1.0.1)
 Address 0xffefff864 is on thread 1's stack
 in frame #8, created by test_extendedcopy_param (test_extendedcopy_param.c:31)

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-12-24 10:36:55 -08:00
Bart Van Assche
9ab1cc8baa test-tool/*_dpofua: Fix memory leaks in error paths
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-12-24 08:55:25 -08:00
Bart Van Assche
e9536d3333 test-tool: Avoid that login failure causes a segmentation fault
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-12-24 08:54:40 -08:00
Ronnie Sahlberg
5532325042 Test-tool: call iscsi_service on MP devices once every second so we respond to NOP
The test tool is simplistic and uses the synchronous API. In this API
we will only poll() the socket and process events during the lifetime of any
iscsi_*_sync() calls.

A problem with this approach arises with multipath tests. When iscsi-test-cu
is used with multiple devices we will first open a session for each
multipath leg, but then as most tests are only using the first device we end
up with creating secondary sessions we don't do any iscsi_*_sync() calls on
for very long times. If a target is set up to send NOPs on these
secondary paths it will not get any responses and eventually tear down the
connection.

To avoid this, try to make sure we service any secondary paths we have
created by calling iscsi_service(POLLIN|POLLOUT) every few seconds
to make sure we do service and respond to any NOPs.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-12-15 21:55:03 -08:00
Ronnie Sahlberg
cda985167d Merge branch 'master' of github.com:sahlberg/libiscsi 2015-12-13 14:34:19 -08:00
Ronnie Sahlberg
3c44092635 Add a feature to request transparent reconnects without any UA
Normal applications want the current behaviour where we have the library
consume any/all of the UnitAttentions that the target may have queued on the
initial connection, but when we reconnect the session after a failure the
library will pass all the UAs back to the application to process.

Some applications, such as the test suite or really trivial applications
might not want to have to deal with handling of UAs and just "make it work".
Those applications can now request that upon any reconnection of the session
that libiscsi will automatically consume any and all UAs and hide them from
the application.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-12-13 14:29:32 -08:00
David Disseldorp
086f1d1903 test/pr: fix key deregistration in PRout PREEMPT test
Remove duplicate k2 deregistration.

Reported-by: Chris Zankel <czankel@purestorage.com>
Signed-off-by: David Disseldorp <ddiss@suse.de>
2015-12-10 12:02:03 +01:00
Bart Van Assche
0e0073e818 test-tool: Clear persistent reservation keys before tests are run
If a previous run of the test tool had been interrupted one or
more persistent reservation keys can still be registered. This
can cause tests in the new run to fail. Avoid this by clearing
these keys before running any tests. Do this only if --dataloss
has been specified.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-10-07 07:45:32 -07:00
Bart Van Assche
0bddefca95 test_report_supported_opcodes_one_command: Make reporting more detailed
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-10-07 07:44:59 -07:00
Bart Van Assche
2d412530c1 test-tool: Move all_zeroes() helper function to iscsi-support.c
This patch does not change any functionality.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-10-07 07:44:18 -07:00
Bart Van Assche
5231923bc8 test_read6_beyond_eol: Fix an assertion failure
Avoid that running the regression tests against a LUN with size zero triggers
the following assertion failure:

lt-iscsi-test-cu: iscsi-support.c:1666: read6: Assertion `task != ((void *)0)' failed.
Aborted

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-10-07 07:43:41 -07:00
Bart Van Assche
393165d66a test-tool: Remove three casts
This patch does not change any functionality but removes the number
of casts in the test tool source code.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-10-07 07:43:00 -07:00
David Disseldorp
b9b414981c test/pr: PRout PREEMPT remove registration test
Check that the Persistent Reserve Out PREEMT request removes the
registration referenced by the service action key.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2015-09-30 11:00:25 +02:00
David Disseldorp
a1d11eb0f9 test: move UA drain helper function into iscsi-support
test_iscsi_tur_until_good() dispatches TUR requests until the target has
cleared all UAs for the given sd, or the maximum number of retries is
reached.
This helper function is useful for any test that needs to deal with UAs
(e.g. PRs), so should be moved out into common code.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2015-09-30 11:00:25 +02:00
David Disseldorp
760ae95d9c test: add prout_preempt() helper function
Issue a Persistent Reservation Out PREEMPT request, with keys and type
provided.
PREEMPT allows for the removal of registrations, and replacement of
reservations.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2015-09-30 11:00:25 +02:00
David Disseldorp
9aa5b55b41 test/pr: simple PRin REPORT CAPABILITIES test
Check that the Persistent Reserve In REPORT CAPABILITIES response
carries valid LENGTH, ALLOW COMMANDS, and PERSISTENT RESERVATION TYPE
MASK fields.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2015-09-30 11:00:19 +02:00
David Disseldorp
9c524b37fa test: add prin_report_caps() helper function
Issue a Persistent Reservation In REPORT CAPABILITIES request and parse
the response. Callers can obtain the unmarshalled response data via the
_rcaps parameter.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2015-09-30 11:00:19 +02:00
David Disseldorp
4f55a3f5c3 test/preventallow: use multipath session if available
This test currently reconnects to the base sd for multi-initiator
testing. Use the secondary multipath device instead, if available.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2015-09-21 15:53:31 +02:00
David Disseldorp
69d9a77f14 test/sanitize: use multipath session if available
These tests currently reconnect to the base sd for multi-initiator
testing. Use the secondary multipath device instead, if available.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2015-09-21 15:52:40 +02:00
David Disseldorp
638d58dd57 test/prout: use multipath session if available
These tests currently reconnect to the base sd for multi-initiator
testing. Use the secondary multipath device instead, if available.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2015-09-21 15:47:21 +02:00
David Disseldorp
89c1749ae7 test/reserve6: use multipath session if available
Many tests currently reconnect to the base sd for multi-initiator
testing. Use the secondary multipath device instead, if available.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2015-09-21 15:40:18 +02:00
David Disseldorp
0cfc593bbd test/multipath: add helper to obtain secondary sessions
A number of existing tests create a secondary iSCSI session by logging
into the target specified in the base sd during the test.

With multipath sessions now connected during iscsi-test-cu startup
(when launched with multiple URIs), secondary sessions can be
provided via multipath when available, rather than reconnecting.

This change adds a helper that conditionally returns the secondary
multipath device if available, or falls back to creating a new session
via the base sd target details.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2015-09-21 15:11:37 +02:00
Ronnie Sahlberg
1540ab460d TESTS: remove extra assert
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-19 16:48:26 -07:00
Ronnie Sahlberg
fae0d70260 TESTS: Dont try to eject the media if preventallow is not supported
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-19 16:29:29 -07:00
Ronnie Sahlberg
e725788eeb TESTS: WriteAtomic fixes to handle devices that do not return BlockLimits VPD
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-19 16:12:01 -07:00
Ronnie Sahlberg
fe1017fe2a TESTS: Don't test WriteSame10/16 if we do not have BlockLimits VPD
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-19 16:06:05 -07:00
Ronnie Sahlberg
67932e870e TEST: Fix number of blocks in Get_LBA_STATUS simple
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-19 15:58:03 -07:00
Ronnie Sahlberg
7924ae5385 TEST: Skip CompareAndWrite DPO/FUA test early if the opcode is not supported.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-19 15:52:44 -07:00
Ronnie Sahlberg
f7ea45e053 TESTS: ReportSuppOpcodes, handle broken targets that return success but no data.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-19 15:47:13 -07:00
Ronnie Sahlberg
d7606c44e2 TESTS: Update checks for DPUFUA bits in CDB_USAE_DATA fields
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-19 15:24:04 -07:00
Ronnie Sahlberg
ac3b1d6e3c TEST: Fix the READ6 tests so they work for linux usb devices
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-19 14:55:58 -07:00
Ronnie Sahlberg
e57b266e91 TESTS: Fix how we compute the max transfer length the bus can handle was broken
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-19 14:41:52 -07:00
David Disseldorp
5c0b1b9913 test/pr: simple PR Out CLEAR test
Check that a Persistent Reserve Out CLEAR request:
- clears an existing reservation
- clears existing registration keys
- bumps the PRgeneration number

Signed-off-by: David Disseldorp <ddiss@suse.de>
2015-09-18 18:06:25 +02:00
David Disseldorp
a90e5a3d4c test/iscsi-support: PR Out CLEAR helper function
Add a helper function to dispatch Persistent Reserve Out requests with
CLEAR service action.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2015-09-18 18:06:19 +02:00
David Disseldorp
a569d55a0e test/multipath: add COMPARE AND WRITE test
Confirm that data is consistent across paths when using the atomic
COMPARE AND WRITE operation.
This should be extended in future to issue the requests simultaneously
across both paths, in an attempt to trigger a read/write race.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2015-09-17 19:13:39 +02:00
David Disseldorp
b9dd210194 test/multipath: add logical unit reset test
This test issues a logical unit reset iSCSI TMF request, and then
confirms that all paths report a subsequent unit attention condition.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2015-09-17 19:13:39 +02:00
David Disseldorp
6b3ee9931a 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>
2015-09-17 19:13:39 +02:00
Ronnie Sahlberg
2e59742b1f TESTS: Dont assume atomic align/granularity is always reported as non-0
From Alexander Motin <mav@freebsd.org>
Treat BlockLimits VPD atomic granulatity/alignment reported as 0
(no restrictions) as == 1 (also means no restriction).

Both 0 and 1 mean that there is no restriction on alignment or
granularity but with the difference being that the second value can
be used to increment to the next valid LBA.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-12 13:38:02 -07:00
Ronnie Sahlberg
e59d2ce1d3 TESTS: ifdef out iov_tot_len if we do not have SG_IO
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-12 12:43:07 -07:00
Ronnie Sahlberg
fa9df7fdd3 TESTS: Fix the writeatomic tests for targets where atomic granularity != 1
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-10 17:20:06 -07:00
Ronnie Sahlberg
fd55600d39 TESTS: Print correct sense data when a command fail that were expected to succeed 2015-09-10 16:45:24 -07:00
Ronnie Sahlberg
126bbd8b29 TESTS: Add WriteAtomic tests for alignment and granularity
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-09 09:53:09 -07:00
Ronnie Sahlberg
4c87f455ae TESTS: Verify that MAX_ATOMIC_XFER_LEN is <= MAX_XFER_LEN
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-09 06:55:13 -07:00
Ronnie Sahlberg
b4cdf07271 Add tests that BlockLimits VPD matches the AtomicWrite16 support
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-09 06:49:51 -07:00
Ronnie Sahlberg
6c16f9e322 Add tests for WRITE_ATOMIC_16
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-08 10:17:15 -07:00
Bart Van Assche
9826147581 test_extendedcopy_descr_limits: Fix a crash if this command is not supported
Avoid that this test crashes as follows if the RECEIVE COPY RESULTS
command is not supported:

    [FAILED] RECEIVECOPYRESULT command failed with sense. (null)
Segmentation fault

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Sushma Gurram <Sushma.Gurram@sandisk.com>
2015-09-06 07:05:36 -07:00
Ronnie Sahlberg
3b8b42d976 TESTS: Add missing check for not supported : RECEIVE_COPY_RESULTS
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-08-02 12:57:45 -07:00
Ronnie Sahlberg
0bb846c0f5 Don't use alloca for large blobs.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-08-02 12:57:32 -07:00
Ronnie Sahlberg
a6f7c06119 Add support and tests for ExtendedCopy and ReceiveCopyResults
From sushma.gurram@sandisk.com
Add support to libiscsi and tests for these two opcodes.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-08-02 12:57:21 -07:00