Commit Graph

581 Commits

Author SHA1 Message Date
Ronnie Sahlberg
2f10f05084 TESTS: improve text output for test_report_supported_opcodes_rctd
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-13 19:54:50 -07:00
Ronnie Sahlberg
6e4a84f815 TESTS Add the modesense tests to the linux family
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-13 19:50:24 -07:00
Ronnie Sahlberg
d9352865c2 TESTS: Skip the test with a warning if BlockDevChar VPD page is missing
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-12 20:30:04 -07:00
Ronnie Sahlberg
2a6264f76e TESTS: Change ModeSense6.Control D_SENSE test to work with /dev/* devices
Stop calling out to libiscsi specific interfaces for faling a command
and checking the sense data. Use the now generic read16() which now works
also for normal device nodes.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-12 20:25:29 -07:00
Ronnie Sahlberg
b2b474f3ad TESTS: Allow inquiry(block dev characteristics) to fail
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-12 20:25:11 -07:00
Ronnie Sahlberg
811c04f01a TESTS: read12/read16 change signature to return an optional task structure
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-12 20:25:04 -07:00
Craig Rodrigues
3aec1a37a9 Skip unsupported tests instead of failing
* SCSI_REPORT_SUPPORTING_OPCODE
* SCSI_REPORT_SUPPORTING_SERVICEACTION
2015-05-07 07:09:13 -04:00
Peter Lieven
b4098c535e init: make LIBISCSI_CACHE_ALLOCATIONS a public environment variable
this variable was introduced for iscsi-test-cu only. This patch
makes it a generic environment variable that can be set per context.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-05-05 14:10:44 +02:00
Bart Van Assche
e7a90f7ecb test_sanitize_overwrite: Fix three log messages
check_lun_is_wiped() verifies whether the 256 blocks following LBA
'lba' contain byte value 'c'. Modify the log messages such that these
refer to byte value 'c' instead of to zero. Change the argument type
of 'c' from char into unsigned char to avoid that 'c' is sign
extended in the log statements.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-04-27 19:19:30 -07:00
Bart Van Assche
52a57d26f2 test-tool: Improve reliability of status_is_invalid_opcode()
The test_report_supported_opcodes_one_command() sends SCSI commands
to the target for which the target has to reply with ILLEGAL REQUEST
/ INVALID FIELD IN CDB. Avoid that such a reply is misinterpret as
"command not supported" by checking the field offset in the sense
descriptor. See also patch "test tool: Detect unsupported opcodes
correctly" (commit ID fe9620092c).

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-04-27 19:18:41 -07:00
Bart Van Assche
8435f9722e lib: Parse sense specific descriptor
Extend struct scsi_sense with sense specific descriptor information,
introduce the function scsi_parse_sense_data() and let that function
parse the sense specific descriptor.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-04-27 19:17:51 -07:00
Bart Van Assche
fbc87ab12f test_compareandwrite_dpofua: Fix this test
Initialize the buffer with data from the medium to avoid to
trigger a miscompare and double the compareandwrite() xferlen
argument.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-04-27 19:15:54 -07:00
Chris Zankel
a4bde6adfd test_writesame16_unmap_until_end: pass 0 blocks instead of 0-length block
The test:
  "Test WRITESAME16 of 1-256 blocks at the end of the LUN by setting
number-of-blocks==0"
was passing 0 for the data length instead of the block count.

Signed-off-by: Chris Zankel <chris@zankel.net>
2015-04-23 17:40:02 -07:00
Chris Zankel
de512a5888 test_unmap_0blocks: skip multi-descriptor test if unsupported
Some targets only support a single descriptor for unmap operations,
so skip (CU_PASS) the test cases that use multiple descriptors in
those cases. Only run the tests if maximum_unmap_block_descriptor_count
is less than 2.

Also the test
  "Test UNMAP of 0 blocks at LBA:0-255  with one descriptor per block")
was passing one less descriptor.

Signed-off-by: Chris Zankel <chris@zankel.net>
2015-04-23 17:39:49 -07:00
Chris Zankel
fff67ba7dd test_writesame*_0blocks: skip 0-block test if unsupported
Skip 0-block WRITE SAME tests for targets that don't support these
operations, ie. they have write_same_no_zero (WSNZ) set in the
block limits vpd.

Also, fix the test:
  "Test WRITESAME10 of 1-256 blocks at the end of the LUN by setting
number-of-blocks==0"
to actually pass 0 blocks instead of the number of remaining blocks to the end.

Signed-off-by: Chris Zankel <chris@zankel.net>
2015-04-23 17:36:38 -07:00
Chris Zankel
9068f23f95 test-tool: print (logging) the actual sense code if mismatch
Print (log) the actual sense code that was returned if it doesn't match the
expected value.

Signed-off-by: Chris Zankel <chris@zankel.net>
2015-04-22 18:18:27 -07:00
Chris Zankel
e186169064 build: fix 'out-of-tree' build
Prefix include paths with '${srcdir}' to allow 'out-of-tree' builds:

  cd $BUILD
  $LIBISCSI/configure
  make

Signed-off-by: Chris Zankel <chris@zankel.net>
2015-04-22 18:18:14 -07:00
Bart Van Assche
cf4076dba9 test-tool: Make it possible to disable memory caching
Disable memory caching in libiscsi if the environment variable
LIBISCSI_CACHE_ALLOCATIONS has been set to zero. This makes
Valgrind reports more meaningful.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-04-20 07:01:17 -07:00
Bart Van Assche
e3e4d8730c test_write*_residuals: Fix overflow tests
RFC 3720 is not clear about whether a target should return SUCCESS
or CHECK CONDITION if SPDTL > EDTL. Hence accept both. See also
Fred Knight, Re: [Ips] Data Out residual overflow/underflow handling,
IETF mailing list archive, 21 September 2012
(http://www.ietf.org/mail-archive/web/ips/current/msg02756.html).

This patch reworks the changes introduced via commit
cfce944b35 and applies similar changes
to the other WRITE and WRITE VERIFY tests.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-04-20 06:51:02 -07:00
Ronnie Sahlberg
b6fc366b5c TESTS: Add a test for D_SENSE in the CONTROL mode page
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-04-19 18:20:12 -07:00
Ronnie Sahlberg
669998e9d7 TESTS: the CONTROL mode page has SPF==0
When scanning for the CONTROL mode page we must also check that SPF==0
since otherwise we might pick up CONTROL EXTENSIONS or other subpages
that may be returned.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-04-19 17:27:20 -07:00
Christoph Hellwig
60a0289d74 iscsi-test-cu: set up vectored transfer length properly
I didn't set up the transfer length properly for the vectored SG_IO
support in the previous patch, which makes some implementations
of the ioctl unhappy.  Fix this up per the spec.
2015-04-18 12:06:14 -07:00
Ronnie Sahlberg
b745e28573 TESTS: remove some dead code
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-04-18 08:48:43 -07:00
Christoph Hellwig
b89f6592c4 iscsi-test-cu: fix implicit DATA OUT buffers with SG_IO
Command like PERSISTENT RESERVE OUT fill out DATA OUT data in their
CDB setup routine, but the SG_IO code doesn't look at that, leading
to a segfault when issueing such commands.  Fix this by copying over
some code from the iSCSI path.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2015-04-18 08:44:24 -07:00
Christoph Hellwig
e2e401c50c iscsi-test-cu: support arbitrary device nodes
We support SG_IO on various block devices, including but not limited to:
SCSI disks, CDROMs and tapes, virtio-blk and nvmve.

Instead of checking a filename prefix just treat anything that isn't
an iscsi:// url as a device node.  The ioctl checks after open will weed
out devices (or files) that don't support SG_IO.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2015-04-18 08:43:00 -07:00
Ronnie Sahlberg
ba120e4347 TESTS: Add a test for the SWP flag in the CONTROL mode page
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-04-18 08:27:03 -07:00
Ronnie Sahlberg
4e174f5d7c TESTS: Add basic test for CONTROL mode page
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-04-18 08:03:15 -07:00
Bart Van Assche
b3783b961b test-tool: Avoid that Valgrind complains about uninitialized data
Avoid that Valgrind reports complaints similar to the following:

Syscall param writev(vector[...]) points to uninitialised byte(s)
   at 0x5567087: writev (writev.c:49)
   by 0x5265AE0: iscsi_iovector_readv_writev (socket.c:492)
   by 0x52666B5: iscsi_write_to_socket (socket.c:710)
   by 0x5266CCC: iscsi_service (socket.c:852)
   by 0x526751F: event_loop (sync.c:67)
   by 0x5269B41: iscsi_scsi_command_sync (sync.c:1153)
   by 0x4050F6: send_scsi_command (iscsi-support.c:245)
   by 0x408007: compareandwrite (iscsi-support.c:1512)
   by 0x40B6AD: test_compareandwrite_dpofua (test_compareandwrite_dpofua.c:69)
   by 0x503EC99: ??? (in /usr/lib/libcunit.so.1.0.1)
   by 0x503EF27: ??? (in /usr/lib/libcunit.so.1.0.1)
   by 0x503F2A5: CU_run_all_tests (in /usr/lib/libcunit.so.1.0.1)
 Address 0xffeffff10 is on thread 1's stack
 in frame #8, created by test_compareandwrite_dpofua (test_compareandwrite_dpofua.c:30)

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-04-11 08:49:59 -07:00
Bart Van Assche
0995b0aa2b test_*_dpo*: Fix NULL pointer dereferences
Avoid that the DPO / DPOFUA tests triggers a NULL pointer dereference
if the MODE SENSE command in these tests fails.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-04-11 08:48:51 -07:00
Bart Van Assche
dbc4e33db2 test-tool: Fix a few sporadic crashes
Avoid that Valgrind reports complaints similar to the following:

Conditional jump or move depends on uninitialised value(s)
   at 0x405097: send_scsi_command (iscsi-support.c:240)
   by 0x40904B: reserve6_conflict (iscsi-support.c:1915)
   by 0x42231C: test_reserve6_logout (test_reserve6_logout.c:63)
   by 0x503EC99: ??? (in /usr/lib/libcunit.so.1.0.1)
   by 0x503EF27: ??? (in /usr/lib/libcunit.so.1.0.1)
   by 0x503F2A5: CU_run_all_tests (in /usr/lib/libcunit.so.1.0.1)
   by 0x404B43: main (iscsi-test-cu.c:1292)

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-04-09 19:56:19 -07:00
Bart Van Assche
12eea9756b test_writesame*_unmap: Optimize result buffer comparison
While running the test tool I noticed that a significant number
of CPU cycles was spent in test_writesame10_unmap(). Rewrite the
comparison loop such that it needs fewer CPU cycles. Use the same
comparison code in test_writesame16_unmap().

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-03-31 06:52:09 -07:00
Bart Van Assche
52e45096df Do not pass NULL to access()
Avoid that Valgrind complains about passing a NULL pointer as first
argument to access().

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-03-31 06:50:43 -07:00
Christoph Hellwig
c72edd514d test-tool: always use low-level SCSI APIs
This allows all tests to properly work on /dev/sg nodes instead
of segfaulting when a test is written the iSCSI-specific APIs.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2015-03-30 22:24:41 -07:00
Stefan Weil
86adf5847c Fix wrong checks for username
The variable user in struct iscsi_url is a character array, not a pointer.
Therefore its address will never be NULL.

When libscsi is built using clang instead of gcc, those errors are reported:

iscsi-perf.c:256:17: error:
 comparison of array 'iscsi_url->user' not equal to a null
 pointer is always true [-Werror,-Wtautological-pointer-compare]
iscsi-dd.c:272:17: error:
 comparison of array 'iscsi_url->user' not equal to a null
 pointer is always true [-Werror,-Wtautological-pointer-compare]
iscsi-dd.c:331:17: error:
 comparison of array 'iscsi_url->user' not equal to a null
 pointer is always true [-Werror,-Wtautological-pointer-compare]
ld_iscsi.c:99:18: error:
 comparison of array 'iscsi_url->user' not equal to a null
 pointer is always true [-Werror,-Wtautological-pointer-compare]

Fix those errors and also similar code patterns in aros/iscsi-ls.c and
test-tool/iscsi-support.c.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2015-03-07 09:54:38 +01:00
Stefan Weil
d7a8ab0f1e Remove trailing blanks
The files touched here need a bug fix which is applied with the
following patch.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2015-03-07 09:54:38 +01:00
Sitsofe Wheeler
5629afa364 test_preventallow_*.c: Silence clang empty body warning
Clang whinges about an empty loop body when it sees code like
while (i = 0; i++; i < 2);
but in test_preventallow_*.c this looks intentional, so move the
semi-colon to a line of its own to make clang happy.

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
2015-03-01 16:13:45 +00:00
Sebastian Herbszt
7dfd42ebfe test-tool: fix unregister of initiator 2 in test_prout_reserve_access
Initiator 2 registered with key2.

Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
2015-02-17 19:21:46 -08:00
Ronnie Sahlberg
51bd0ce3ec test-tool: remove the --usb argument and use BLCSECTGET to read max xfer
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-16 16:04:28 -08:00
Sebastian Herbszt
cb7882a84c test-tool: fix SG_IO
Handle io_hdr.resid and adjust datain.size.

Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
2015-02-16 15:39:31 -08:00
Ronnie Sahlberg
68acbb7c3f rand_key: fix non-randomness in rand_key()
If rand_key() is called twive within the same second it would return the
same key both times. Not very random.
Redo how rand_key() works to make it more likely to be random and more likely
that two consequtive calls do not yield the same result.

Reported-by: CyberLoiter <yanming.xiao@gmail.com>
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-10 16:57:22 -08:00
Ronnie Sahlberg
d69d955fa6 test-tool: SEGV when dereferencing a NULL pointer ascq array
ascq is NULL if there are no ascqs provided for this failure mode.
Do not try to dereference the 0-th element in this array before checking
that the array has at least one element.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-01-26 17:56:12 -08:00
Ronnie Sahlberg
b84119611c test-tool: fix segv in reserve6_2initiators
Fix a SEGV in one of the reserve6 tests.

Signed-off-by: Vadim Finkelstein <vadim@pi-coral.com>
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-01-26 17:56:12 -08:00
Ronnie Sahlberg
52d9d84f9c README: update the readme and describe the family/suite/test better
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-12-30 19:54:56 -08:00
Ronnie Sahlberg
d33a0438a4 TESTS: replace read* flags tests with dedicated dpo/fua tests
Remove the flags tests for READ* and replace them with a test for the DPO
and FUA bits.
IF the device claims DPOFUA support in modesense then the READ* CDBs
MUST allow these two flags. IF the device does NOT claim DPOFUA then any
READ* CDB with these flags must fail with invalod field in cdb.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-12-22 20:05:29 -08:00
Ronnie Sahlberg
58f06b0e74 TESTS: get rid of a sanitize helper
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-10-14 19:39:27 -07:00
Ronnie Sahlberg
8ac7d64082 TESTS: convert most of SANITIZE to new saner api
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-10-14 19:25:17 -07:00
Bart Van Assche
fe9620092c test tool: Detect unsupported opcodes correctly
There is no agreement among the T10 committee whether a SCSI target should
report "invalid opcode", "invalid field in CDB" or "invalid field in
parameter list" if the opcode consists of two bytes. Hence accept all three
sense codes for two-byte opcodes. For more information see also Frederick
Knight, RE: INVALID COMMAND OPERATION CODE, T10 Reflector, 16 May 2008
(http://t10.org/ftp/t10/t10r/2008/r0805167.htm).

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2014-10-14 18:51:56 -07:00
Bart Van Assche
30355f8cc0 test_inquiry_block_limits: Only query VPD page B2h if LBPME = 1
In the READ CAPACITY response support for logical block provisioning
is indicated via the LBPME (logical block provisioning management
enabled) bit. Since the logical block provisioning VPD page (B2h)
is optional, only query it if LBPME = 1.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2014-10-14 18:03:45 -07:00
Bart Van Assche
eee66727a7 test_iscsi_datasn_invalid: Make terminology consistent with RFC 3720
According to RFC 3720 the data associated with a SCSI WRITE command
is sent via Data-Out PDU's. Update log texts accordingly and also
make the capitalization of DataSN consistent with RFC 3720.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2014-10-14 18:02:48 -07:00
Bart Van Assche
0763dc5743 libiscsi: Clear PS bit before sending MODE SELECT
A quote from SPC-4: "When using the MODE SENSE command, a
parameters saveable (PS) bit set to one indicates that the mode
page may be saved by the logical unit in a nonvolatile, vendor
specific location. A PS bit set to zero indicates that the device
server is not able to save the supported parameters. When using
the MODE SELECT command, the PS bit is reserved."

Hence clear the PS bit after having queried a mode page via MODE
SENSE and before changing it via MODE SELECT.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2014-10-14 17:56:40 -07:00