Commit Graph

555 Commits

Author SHA1 Message Date
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
Ronnie Sahlberg
14461757c4 TESTS: Allow Hardware/Software write protect as valid ASCQ
Add 0x2701/0x2702 to the list of valid ASCQ values we accept for devices
that are write protected.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-10-08 06:23:43 -07:00
Ronnie Sahlberg
d411f12bbc TESTS: tweak inquiry blocklimits test
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-27 12:54:34 -07:00
Ronnie Sahlberg
edbfb12232 TESTS: Allow inquiry data to contain padding IFF it is all zero
Some implementations may send oversized data coming back from Inquiry.
Warn about this instead of failing the test but then perform additional
checks that the padding MUST be zero or else fail the test.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-27 09:27:02 -07:00
Ronnie Sahlberg
45d87238e2 TESTS: Flag a whole bunch of tests as not supported on non-iSCSI backends
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-27 08:58:24 -07:00
Ronnie Sahlberg
abbf9a11b0 TESTS: change modeselect to become /dev/sg-aware
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-27 08:10:14 -07:00
Ronnie Sahlberg
0666691b2a TESTS: pass an actual block to the ritesame16/0blocks test
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-23 20:57:59 -07:00
Ronnie Sahlberg
47d7e4b0ac TESTS: make sure ascq_ok is initialized
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-21 15:30:40 -07:00
Ronnie Sahlberg
839276dd7c TESTS: fix memory leaks in report supported opcodes tests
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-21 15:24:41 -07:00
Ronnie Sahlberg
264ea509c8 iscsi-support.c: fix memory leaks. Thanks valgrind, you rock
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-21 15:14:51 -07:00
Ronnie Sahlberg
38798e2090 initialize task->datain.data to keep valgrind happy
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-21 15:10:38 -07:00
Ronnie Sahlberg
2af45d9ad4 initialize sense to keep valgrind happy
valgrind does not know that sense will be initialized by the ioctl
so we need to to it explicitely to keep it from warning us.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-21 14:58:12 -07:00
Ronnie Sahlberg
f2904be1f6 Typo
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-21 14:19:58 -07:00
Ronnie Sahlberg
ef20220ac2 iscsi-test-cy.c: drop READ6 from the linux tests. it is obsolete 2014-09-21 14:19:35 -07:00
Ronnie Sahlberg
d11e4175f7 TESTS: Dont memcpy if task==NULL
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-19 17:33:21 -07:00
Ronnie Sahlberg
1e3cc445c8 TESTS: Remove some tests that wont work yet for /dev/sg
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-19 17:15:48 -07:00
Ronnie Sahlberg
59817c7959 TESTS: rename the old and abandoned scsi-usb-sbc testsuite to LINUX
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-19 16:33:03 -07:00
Ronnie Sahlberg
55c1f0d2ec TESTS: Add support to test against a /dev/sg device on linux
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-19 16:26:46 -07:00
Ronnie Sahlberg
bd6570c324 TESTS: create an abstraction to connect to a device
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-19 06:26:53 -07:00
Ronnie Sahlberg
48e14f5ccf TESTS: update main program to use helpers instead of calling directly to libiscsi
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-19 06:21:02 -07:00
Ronnie Sahlberg
8ed2ad9b69 TESTS: start abstracting away the error string handling from transports
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-18 19:20:49 -07:00
Ronnie Sahlberg
5efc7bf925 TESTS: create a helper/wrapper for sending scsi commands
Create a wrapper for sending scsi_commands so that we can hide the
libiscsi function far away from the "opcode" helpers.
This means we only have a single place later to switch to a different
type of device, such as a SG_IO one.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-18 18:52:08 -07:00
Ronnie Sahlberg
74a50052cd TESTS: get rid of iscsic2
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-18 18:37:35 -07:00
Ronnie Sahlberg
072291c852 TESTS: change the function signatures for the helpers
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-18 18:19:04 -07:00
Ronnie Sahlberg
9b768f7de9 TESTS: move the default url, lun and iscsi context into a structure
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-18 16:42:45 -07:00
Ronnie Sahlberg
f015ab095a TESTS: update reportsupportedopcodes to new api
Signed-off-by: Ronnie Sahlberg <sahlberg@localhost>
2014-09-18 14:07:22 -07:00
Ronnie Sahlberg
9be6ddaf09 TESTS: update inquiry to new api
Signed-off-by: Ronnie Sahlberg <sahlberg@localhost>
2014-09-18 14:07:22 -07:00