├── .appveyor.yml ├── .dir-locals.el ├── .github └── workflows │ ├── build.yml │ ├── build.yml~ │ └── codeql.yml ├── .gitignore ├── COPYING ├── INSTALL ├── LICENCE-GPL-2.txt ├── LICENCE-LGPL-2.1.txt ├── Makefile.am ├── README.md ├── TODO ├── aros ├── Makefile.AROS ├── aros_compat.c ├── aros_compat.h └── iscsi-ls.c ├── autogen.sh ├── ci ├── build.bat ├── build.sh ├── install.bat └── install.sh ├── configure.ac ├── doc ├── Makefile.am ├── iscsi-inq.1 ├── iscsi-inq.xml ├── iscsi-ls.1 ├── iscsi-ls.xml ├── iscsi-md5sum.1 ├── iscsi-md5sum.xml ├── iscsi-swp.1 ├── iscsi-swp.xml ├── iscsi-test-cu.1 └── iscsi-test-cu.xml ├── examples ├── Makefile.am ├── iscsi-dd.c ├── iscsi-pthreads-inq.c ├── iscsi-pthreads-readloop-async.c ├── iscsi-pthreads-readloop.c └── iscsiclient.c ├── include ├── iscsi-multithreading.h ├── iscsi-private.h ├── iscsi.h ├── iser-private.h ├── md5.h ├── scsi-lowlevel.h ├── sha-private.h ├── sha.h ├── sha3.h ├── slist.h └── utils.h ├── lib ├── Makefile.am ├── connect.c ├── crc32c.c ├── discovery.c ├── init.c ├── iscsi-command.c ├── iser.c ├── libiscsi.def ├── libiscsi.syms.in ├── logging.c ├── login.c ├── md5.c ├── multithreading.c ├── nop.c ├── pdu.c ├── scsi-lowlevel.c ├── sha1.c ├── sha224-256.c ├── sha3.c ├── socket.c ├── sync.c ├── task_mgmt.c └── utils.c ├── libiscsi.pc.in ├── packaging └── RPM │ ├── .gitignore │ ├── libiscsi.spec.in │ └── makerpms.sh ├── patches ├── README ├── mtx-iscsi.diff └── sg3_utils-1.32.patch ├── test-tool ├── Makefile.am ├── README ├── data ├── iscsi-multipath.c ├── iscsi-multipath.h ├── iscsi-support.c ├── iscsi-support.h ├── iscsi-test-cu.c ├── iscsi-test-cu.h ├── test_async_abort_simple.c ├── test_async_lu_reset_simple.c ├── test_async_read.c ├── test_async_write.c ├── test_compareandwrite_dpofua.c ├── test_compareandwrite_invalid_dataout_size.c ├── test_compareandwrite_miscompare.c ├── test_compareandwrite_simple.c ├── test_compareandwrite_unwritten.c ├── test_extendedcopy_descr_limits.c ├── test_extendedcopy_descr_type.c ├── test_extendedcopy_param.c ├── test_extendedcopy_simple.c ├── test_extendedcopy_validate_seg_descr.c ├── test_extendedcopy_validate_tgt_descr.c ├── test_get_lba_status_beyond_eol.c ├── test_get_lba_status_simple.c ├── test_get_lba_status_unmap_single.c ├── test_inquiry_alloc_length.c ├── test_inquiry_block_limits.c ├── test_inquiry_evpd.c ├── test_inquiry_mandatory_vpd_sbc.c ├── test_inquiry_standard.c ├── test_inquiry_supported_vpd.c ├── test_inquiry_version_descriptors.c ├── test_iscsi_chap.c ├── test_iscsi_cmdsn_toohigh.c ├── test_iscsi_cmdsn_toolow.c ├── test_iscsi_datasn_invalid.c ├── test_iscsi_nop_simple.c ├── test_iscsi_sendtargets.c ├── test_mandatory_sbc.c ├── test_modesense6_all_pages.c ├── test_modesense6_control.c ├── test_modesense6_control_d_sense.c ├── test_modesense6_control_swp.c ├── test_modesense6_residuals.c ├── test_multipathio_async_caw.c ├── test_multipathio_compareandwrite.c ├── test_multipathio_reset.c ├── test_multipathio_simple.c ├── test_nomedia_sbc.c ├── test_orwrite_0blocks.c ├── test_orwrite_beyond_eol.c ├── test_orwrite_dpofua.c ├── test_orwrite_simple.c ├── test_orwrite_verify.c ├── test_orwrite_wrprotect.c ├── test_prefetch10_0blocks.c ├── test_prefetch10_beyond_eol.c ├── test_prefetch10_flags.c ├── test_prefetch10_simple.c ├── test_prefetch16_0blocks.c ├── test_prefetch16_beyond_eol.c ├── test_prefetch16_flags.c ├── test_prefetch16_simple.c ├── test_preventallow_2_itnexuses.c ├── test_preventallow_cold_reset.c ├── test_preventallow_eject.c ├── test_preventallow_itnexus_loss.c ├── test_preventallow_logout.c ├── test_preventallow_lun_reset.c ├── test_preventallow_simple.c ├── test_preventallow_warm_reset.c ├── test_prin_read_keys_simple.c ├── test_prin_read_keys_truncate.c ├── test_prin_report_caps.c ├── test_prin_serviceaction_range.c ├── test_prout_clear_simple.c ├── test_prout_preempt.c ├── test_prout_register_simple.c ├── test_prout_reserve_access.c ├── test_prout_reserve_ownership.c ├── test_prout_reserve_simple.c ├── test_read10_0blocks.c ├── test_read10_beyond_eol.c ├── test_read10_dpofua.c ├── test_read10_invalid.c ├── test_read10_rdprotect.c ├── test_read10_residuals.c ├── test_read10_simple.c ├── test_read12_0blocks.c ├── test_read12_beyond_eol.c ├── test_read12_dpofua.c ├── test_read12_rdprotect.c ├── test_read12_residuals.c ├── test_read12_simple.c ├── test_read16_0blocks.c ├── test_read16_beyond_eol.c ├── test_read16_dpofua.c ├── test_read16_rdprotect.c ├── test_read16_residuals.c ├── test_read16_simple.c ├── test_read6_beyond_eol.c ├── test_read6_simple.c ├── test_readcapacity10_simple.c ├── test_readcapacity16_alloclen.c ├── test_readcapacity16_protection.c ├── test_readcapacity16_simple.c ├── test_readcapacity16_support.c ├── test_readdefectdata10_simple.c ├── test_readdefectdata12_simple.c ├── test_readonly_sbc.c ├── test_receive_copy_results_copy_status.c ├── test_receive_copy_results_op_params.c ├── test_report_luns.c ├── test_report_supported_opcodes_one_command.c ├── test_report_supported_opcodes_rctd.c ├── test_report_supported_opcodes_servactv.c ├── test_report_supported_opcodes_simple.c ├── test_reserve6_2initiators.c ├── test_reserve6_itnexus_loss.c ├── test_reserve6_logout.c ├── test_reserve6_lun_reset.c ├── test_reserve6_simple.c ├── test_reserve6_target_cold_reset.c ├── test_reserve6_target_warm_reset.c ├── test_sanitize_block_erase.c ├── test_sanitize_block_erase_reserved.c ├── test_sanitize_crypto_erase.c ├── test_sanitize_crypto_erase_reserved.c ├── test_sanitize_exit_failure_mode.c ├── test_sanitize_invalid_serviceaction.c ├── test_sanitize_overwrite.c ├── test_sanitize_overwrite_reserved.c ├── test_sanitize_readonly.c ├── test_sanitize_reservations.c ├── test_sanitize_reset.c ├── test_startstopunit_noloej.c ├── test_startstopunit_pwrcnd.c ├── test_startstopunit_simple.c ├── test_testunitready_simple.c ├── test_unmap_0blocks.c ├── test_unmap_simple.c ├── test_unmap_vpd.c ├── test_verify10_0blocks.c ├── test_verify10_beyond_eol.c ├── test_verify10_dpo.c ├── test_verify10_flags.c ├── test_verify10_mismatch.c ├── test_verify10_mismatch_no_cmp.c ├── test_verify10_simple.c ├── test_verify10_vrprotect.c ├── test_verify12_0blocks.c ├── test_verify12_beyond_eol.c ├── test_verify12_dpo.c ├── test_verify12_flags.c ├── test_verify12_mismatch.c ├── test_verify12_mismatch_no_cmp.c ├── test_verify12_simple.c ├── test_verify12_vrprotect.c ├── test_verify16_0blocks.c ├── test_verify16_beyond_eol.c ├── test_verify16_dpo.c ├── test_verify16_flags.c ├── test_verify16_mismatch.c ├── test_verify16_mismatch_no_cmp.c ├── test_verify16_simple.c ├── test_verify16_vrprotect.c ├── test_write10_0blocks.c ├── test_write10_beyond_eol.c ├── test_write10_dpofua.c ├── test_write10_flags.c ├── test_write10_residuals.c ├── test_write10_simple.c ├── test_write10_wrprotect.c ├── test_write12_0blocks.c ├── test_write12_beyond_eol.c ├── test_write12_dpofua.c ├── test_write12_flags.c ├── test_write12_residuals.c ├── test_write12_simple.c ├── test_write12_wrprotect.c ├── test_write16_0blocks.c ├── test_write16_beyond_eol.c ├── test_write16_dpofua.c ├── test_write16_flags.c ├── test_write16_residuals.c ├── test_write16_simple.c ├── test_write16_wrprotect.c ├── test_write_residuals.c ├── test_write_residuals.h ├── test_writeatomic16_0blocks.c ├── test_writeatomic16_beyond_eol.c ├── test_writeatomic16_dpofua.c ├── test_writeatomic16_simple.c ├── test_writeatomic16_vpd.c ├── test_writeatomic16_wrprotect.c ├── test_writesame10_0blocks.c ├── test_writesame10_beyond_eol.c ├── test_writesame10_check.c ├── test_writesame10_invalid_dataout_size.c ├── test_writesame10_simple.c ├── test_writesame10_unmap.c ├── test_writesame10_unmap_unaligned.c ├── test_writesame10_unmap_until_end.c ├── test_writesame10_unmap_vpd.c ├── test_writesame10_wrprotect.c ├── test_writesame16_0blocks.c ├── test_writesame16_beyond_eol.c ├── test_writesame16_check.c ├── test_writesame16_invalid_dataout_size.c ├── test_writesame16_simple.c ├── test_writesame16_unmap.c ├── test_writesame16_unmap_unaligned.c ├── test_writesame16_unmap_until_end.c ├── test_writesame16_unmap_vpd.c ├── test_writesame16_wrprotect.c ├── test_writeverify10_0blocks.c ├── test_writeverify10_beyond_eol.c ├── test_writeverify10_dpo.c ├── test_writeverify10_flags.c ├── test_writeverify10_residuals.c ├── test_writeverify10_simple.c ├── test_writeverify10_wrprotect.c ├── test_writeverify12_0blocks.c ├── test_writeverify12_beyond_eol.c ├── test_writeverify12_dpo.c ├── test_writeverify12_flags.c ├── test_writeverify12_residuals.c ├── test_writeverify12_simple.c ├── test_writeverify12_wrprotect.c ├── test_writeverify16_0blocks.c ├── test_writeverify16_beyond_eol.c ├── test_writeverify16_dpo.c ├── test_writeverify16_flags.c ├── test_writeverify16_residuals.c ├── test_writeverify16_simple.c └── test_writeverify16_wrprotect.c ├── tests ├── .gitignore ├── Makefile.am ├── README ├── functions.sh ├── prog_header_digest.c ├── prog_noop_reply.c ├── prog_read_all_pdus.c ├── prog_readwrite_iov.c ├── prog_reconnect.c ├── prog_reconnect_timeout.c ├── prog_timeout.c ├── test_0100_login.sh ├── test_0200_discovery.sh ├── test_0300_nop_reply.sh ├── test_0400_readwrite_iow.sh ├── test_0410_read_all_pdus.sh ├── test_0500_header_digest.sh ├── test_0600_ipv6.sh ├── test_1000_chap.sh ├── test_2000_reconnect.sh ├── test_2001_reconnect_timeout.sh ├── test_2100_timeout.sh ├── test_9000_compareandwrite.sh ├── test_9001_extendedcopy.sh ├── test_9002_getlbatatus.sh ├── test_9003_inquiry.sh ├── test_9004_modesense6.sh ├── test_9005_orwrite.sh ├── test_9006_prefetch10.sh ├── test_9007_prefetch16.sh ├── test_9008_prinreadkeys.sh ├── test_9009_read6.sh ├── test_9010_read10.sh ├── test_9011_read12.sh ├── test_9012_read16.sh ├── test_9013_verify10.sh ├── test_9014_verify12.sh ├── test_9015_verify16.sh ├── test_9016_write10.sh ├── test_9017_write12.sh ├── test_9018_write16.sh ├── test_9019_writeverify10.sh ├── test_9020_writeverify12.sh ├── test_9021_writeverify16.sh ├── test_9022_testunitready.sh ├── test_9023_readcapacity10.sh ├── test_9024_readcapacity16.sh ├── test_9025_receivecopyresults.sh ├── test_9026_reportsupportedopcodes.sh ├── test_9027_unmap.sh ├── test_9028_readdefectdata10.sh ├── test_9029_readdefectdata12.sh ├── test_9030_prinreportcapabilities.sh ├── test_9031_proutregister.sh ├── test_9032_proutclear.sh ├── test_9033_proutpreempt.sh ├── test_9034_startstopunit.sh └── test_9035_startstopunit_removable.sh ├── utils ├── Makefile.am ├── iscsi-discard.c ├── iscsi-inq.c ├── iscsi-ls.c ├── iscsi-md5sum.c ├── iscsi-perf.c ├── iscsi-pr.c ├── iscsi-readcapacity16.c └── iscsi-swp.c └── win32 ├── iscsi-ls ├── iscsi-ls.vcxproj └── iscsi-ls.vcxproj.filters ├── libiscsi ├── libiscsi.sln ├── libiscsi.vcxproj ├── libiscsi.vcxproj.filters └── version.rc ├── win32_compat.c └── win32_compat.h /.appveyor.yml: -------------------------------------------------------------------------------- 1 | image: 2 | - Ubuntu 3 | - Ubuntu1604 4 | - Ubuntu2004 5 | - macos 6 | - macos-mojave 7 | - Visual Studio 2019 8 | 9 | clone_depth: 5 10 | 11 | install: 12 | - sh: 'ci/install.sh' 13 | - cmd: 'ci\install.bat' 14 | 15 | build_script: 16 | - sh: 'ci/build.sh' 17 | - cmd: 'ci\build.bat' 18 | -------------------------------------------------------------------------------- /.dir-locals.el: -------------------------------------------------------------------------------- 1 | ((c-mode . ((tab-width . 8) 2 | (c-basic-offset . 8) 3 | (indent-tabs-mode . nil)))) 4 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v2 14 | 15 | - name: Install dependencies 16 | run: sudo ci/install.sh 17 | 18 | - name: Build 19 | run: ci/build.sh 20 | -------------------------------------------------------------------------------- /.github/workflows/build.yml~: -------------------------------------------------------------------------------- 1 | name: Build and test 2 | 3 | # on: [workflow_dispatch] 4 | 5 | on: 6 | push: 7 | branches: 8 | - master 9 | - V5-9-patches 10 | 11 | jobs: 12 | build_and_test: 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v2 17 | 18 | - name: install required packages 19 | run: sudo ci/install.sh 20 | 21 | - name: build 22 | run: ci/build.sh 23 | 24 | - name: test 25 | run: ci/test.sh 26 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yml: -------------------------------------------------------------------------------- 1 | name: "CodeQL" 2 | 3 | on: 4 | push: 5 | branches: [ "master" ] 6 | pull_request: 7 | branches: [ "master" ] 8 | schedule: 9 | - cron: "20 1 * * 4" 10 | 11 | jobs: 12 | analyze: 13 | name: Analyze 14 | runs-on: ubuntu-latest 15 | permissions: 16 | actions: read 17 | contents: read 18 | security-events: write 19 | 20 | strategy: 21 | fail-fast: false 22 | matrix: 23 | language: [ cpp ] 24 | 25 | steps: 26 | - name: Checkout 27 | uses: actions/checkout@v3 28 | 29 | - name: Initialize CodeQL 30 | uses: github/codeql-action/init@v2 31 | with: 32 | languages: ${{ matrix.language }} 33 | queries: +security-and-quality 34 | 35 | - name: Autobuild 36 | uses: github/codeql-action/autobuild@v2 37 | 38 | - name: Perform CodeQL Analysis 39 | uses: github/codeql-action/analyze@v2 40 | with: 41 | category: "/language:${{ matrix.language }}" 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /autom4te.cache/ 2 | /depcomp 3 | /aclocal.m4 4 | /missing 5 | /m4/ 6 | /config.guess 7 | /config.sub 8 | /install-sh 9 | /configure 10 | /config.h.in 11 | /Makefile.in 12 | /Makefile 13 | .deps 14 | .libs 15 | /stamp-h1 16 | *.o 17 | *.lo 18 | *.la 19 | *.so 20 | bin 21 | /config.h 22 | /config.log 23 | /config.status 24 | .dirstamp 25 | /libtool 26 | /ltmain.sh 27 | libiscsi-*.tar.gz 28 | TAGS 29 | /ar-lib 30 | /compile 31 | /doc/Makefile.in 32 | /doc/Makefile 33 | /examples/Makefile.in 34 | /examples/Makefile 35 | /examples/iscsi-dd 36 | /examples/iscsiclient 37 | /examples/ld_iscsi.so 38 | /lib/Makefile.in 39 | /lib/Makefile 40 | /lib/libiscsi.syms 41 | /test-tool/Makefile.in 42 | /test-tool/Makefile 43 | /test-tool/iscsi-test-cu 44 | /tests/Makefile.in 45 | /tests/Makefile 46 | /utils/Makefile.in 47 | /utils/Makefile 48 | /utils/iscsi-discard 49 | /utils/iscsi-inq 50 | /utils/iscsi-ls 51 | /utils/iscsi-md5sum 52 | /utils/iscsi-perf 53 | /utils/iscsi-pr 54 | /utils/iscsi-readcapacity16 55 | /utils/iscsi-swp 56 | /libiscsi.pc 57 | /.cproject 58 | /.project 59 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Libiscsi components fall under two separate licences 2 | 3 | 4 | The lib and include directories 5 | =============================== 6 | The iscsi client library itself, i.e. the lib and include directories, 7 | is licenced under GNU Lesser General Public License as published by 8 | the Free Software Foundation; either version 2.1 of the License, or 9 | (at your option) any later version. 10 | 11 | The library also contains one file : lib/md5.c that is under Public Domain. 12 | 13 | A copy of LGPL 2.1 is included in the file LICENCE-LGPL-2.1.txt but can also be downloaded from http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html 14 | 15 | This is the licence that applies to the libiscsi library and its use. 16 | 17 | 18 | The src, examples and test-tool directories 19 | =========================================== 20 | The utility and example applications using this library, i.e. the src and the 21 | examples directories, are licenced under the GNU General Public License 22 | as published by the Free Software Foundation; either version 2 of the 23 | License, or (at your option) any later version. 24 | 25 | These are executable applications that link with the libiscsi library. 26 | 27 | A copy of GPL 2 is included in the file LICENCE-GPL-2.txt but can also be downloaded from http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 28 | 29 | This licence applies only to the source code for the provided applications that link to and use libiscsi. 30 | 31 | 32 | 33 | To avoid any confusion, every source file also contain a licence boilerplate. 34 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | This installs a new shared library under /usr/lib[64] 2 | and executables under /usr/bin 3 | 4 | 5 | From source: 6 | ============ 7 | ./autogen.sh 8 | ./configure 9 | make 10 | sudo make install 11 | 12 | Building RPM: 13 | ============= 14 | ./packaging/RPM/makerpms.sh 15 | 16 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # Generic definitions 2 | SUBDIRS = lib doc utils 3 | if BUILD_TEST_TOOL 4 | SUBDIRS += test-tool 5 | endif 6 | if BUILD_TESTS 7 | SUBDIRS += tests 8 | endif 9 | if BUILD_EXAMPLES 10 | SUBDIRS += examples 11 | endif 12 | 13 | ACLOCAL_AMFLAGS =-I m4 14 | AUTOMAKE_OPTIONS = foreign subdir-objects 15 | AM_CPPFLAGS=-I. -I$(srcdir)/include 16 | AM_CFLAGS=$(WARN_CFLAGS) 17 | 18 | EXTRA_DIST = autogen.sh COPYING LICENCE-GPL-2.txt LICENCE-LGPL-2.1.txt README.md \ 19 | packaging/RPM/libiscsi.spec.in packaging/RPM/makerpms.sh \ 20 | aros/aros_compat.c aros/aros_compat.h aros/iscsi-ls.c \ 21 | aros/Makefile.AROS test-tool/iscsi-multipath.h \ 22 | win32/win32_compat.c win32/win32_compat.h \ 23 | patches/mtx-iscsi.diff patches/README patches/sg3_utils-1.32.patch \ 24 | lib/libiscsi.syms.in 25 | 26 | pkgconfigdir = $(libdir)/pkgconfig 27 | pkgconfig_DATA = libiscsi.pc 28 | 29 | iscsi_includedir = $(includedir)/iscsi 30 | dist_iscsi_include_HEADERS = include/iscsi.h include/scsi-lowlevel.h 31 | dist_noinst_HEADERS = include/iscsi-private.h include/md5.h include/slist.h \ 32 | include/iser-private.h include/iscsi-multithreading.h include/utils.h 33 | 34 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | Some features that should be added 2 | 3 | * More scsi marshalling and unmarshalling functions in scsi-lowlevel 4 | 5 | * Integrate with other relevant utilities such as 6 | dvdrecord, 7 | ... 8 | 9 | * Data Digest 10 | -------------------------------------------------------------------------------- /aros/Makefile.AROS: -------------------------------------------------------------------------------- 1 | AR=ar 2 | CC=gcc 3 | CFLAGS=-g -O0 -DAROS=1 -DHAVE_SYS_TYPES_H -DHAVE_SOCKADDR_LEN -I. -Iinclude -Iaros 4 | 5 | OBJS=lib/connect.o lib/crc32c.o lib/discovery.o lib/init.o lib/iscsi-command.o lib/logging.o lib/login.o lib/md5.o lib/nop.o lib/pdu.o lib/scsi-lowlevel.o lib/socket.o lib/sync.o lib/task_mgmt.o aros/aros_compat.o 6 | 7 | all: lib/libiscsi.a 8 | 9 | lib/libiscsi.a: $(OBJS) 10 | $(AR) cru $@ $(OBJS) 11 | 12 | .c.o: 13 | echo $(CC) $(CFLAGS) -c -o $@ $< 14 | $(CC) $(CFLAGS) -c -o $@ $< 15 | 16 | aros/iscsi-ls: aros/iscsi-ls.c lib/libiscsi.a 17 | $(CC) $(CFLAGS) -o $@ $< lib/libiscsi.a 18 | 19 | -------------------------------------------------------------------------------- /aros/aros_compat.h: -------------------------------------------------------------------------------- 1 | #ifndef AROS_COMPAT_H 2 | #define AROS_COMPAT_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #define statvfs statfs 14 | #define ioctl IoctlSocket 15 | #define close CloseSocket 16 | 17 | #define writev aros_writev 18 | #define readv aros_readv 19 | #define inet_pton aros_inet_pton 20 | #define freeaddrinfo aros_freeaddrinfo 21 | #define getnameinfo aros_getnameinfo 22 | #define getaddrinfo aros_getaddrinfo 23 | 24 | #define SOL_TCP IPPROTO_TCP 25 | 26 | extern struct Library * SocketBase; 27 | 28 | void aros_init_socket(void); 29 | 30 | #define POLLIN 0x0001 /* There is data to read */ 31 | #define POLLPRI 0x0002 /* There is urgent data to read */ 32 | #define POLLOUT 0x0004 /* Writing now will not block */ 33 | #define POLLERR 0x0008 /* Error condition */ 34 | #define POLLHUP 0x0010 /* Hung up */ 35 | #define POLLNVAL 0x0020 /* Invalid request: fd not open */ 36 | 37 | struct pollfd { 38 | int fd; /* file descriptor */ 39 | short events; /* requested events */ 40 | short revents; /* returned events */ 41 | }; 42 | 43 | #define poll(x, y, z) aros_poll(x, y, z) 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # Commands this script needs 6 | needed='rm mkdir autoreconf echo' 7 | if ! type $needed >/dev/null 2>&1 8 | then 9 | for cmd in $needed 10 | do 11 | if ! type $cmd >/dev/null 2>&1 12 | then 13 | # Have type print an error message for each missing command 14 | type $cmd || true 15 | fi 16 | done 17 | echo A required command is missing. Unable to continue. 18 | exit 1 19 | fi 20 | 21 | rm -rf autom4te.cache 22 | rm -f depcomp aclocal.m4 missing config.guess config.sub install-sh 23 | rm -f configure config.h.in config.h.in~ m4/libtool.m4 m4/lt*.m4 Makefile.in 24 | mkdir -p m4 25 | autoreconf -fvi 26 | (cd m4 && for i in libtool.m4 lt*.m4; do 27 | echo /$i 28 | done) > m4/.gitignore 29 | rm -rf autom4te.cache 30 | 31 | echo "Now run ./configure and then make." 32 | exit 0 33 | 34 | -------------------------------------------------------------------------------- /ci/build.bat: -------------------------------------------------------------------------------- 1 | C:\msys64\usr\bin\bash --login -c 'set -x; cd "${APPVEYOR_BUILD_FOLDER}"; ci/build.sh' 2 | -------------------------------------------------------------------------------- /ci/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | configure_options=( 4 | --enable-manpages 5 | --enable-test-tool 6 | --enable-tests 7 | --enable-examples 8 | ) 9 | 10 | case "$(uname)" in 11 | MSYS*|MINGW*) 12 | export PATH="/mingw64/bin:$PATH" 13 | configure_options+=(--disable-shared) 14 | ;; 15 | esac 16 | 17 | ./autogen.sh && 18 | ./configure "${configure_options[@]}" && 19 | make -j$(nproc) && 20 | case "$(uname)" in 21 | MSYS*|MINGW*) 22 | ;; 23 | *) 24 | sudo make install 25 | ;; 26 | esac 27 | -------------------------------------------------------------------------------- /ci/install.bat: -------------------------------------------------------------------------------- 1 | C:\msys64\usr\bin\bash --login -c 'set -x; cd "${APPVEYOR_BUILD_FOLDER}"; ci/install.sh' 2 | -------------------------------------------------------------------------------- /ci/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | case "$(uname)" in 4 | Linux) 5 | packages=( 6 | autoconf 7 | automake 8 | docbook-xsl 9 | libcunit1-dev 10 | libgcrypt20-dev 11 | librdmacm-dev 12 | libtool 13 | xsltproc 14 | ) 15 | for p in "${packages[@]}"; do 16 | sudo sh -c "apt-get install -y $p" 17 | done 18 | ;; 19 | Darwin) 20 | ;; 21 | MSYS*|MINGW*) 22 | pacman --noconfirm --remove mingw-w64-x86_64-gcc-ada 23 | pacman --noconfirm --remove mingw-w64-x86_64-gcc-fortran 24 | pacman --noconfirm --remove mingw-w64-x86_64-gcc-libgfortran 25 | pacman --noconfirm --remove mingw-w64-x86_64-gcc-objc 26 | pacman --noconfirm --remove mingw-w64-x86_64-libgccjit 27 | pacman --noconfirm --sync --refresh 28 | pacman --noconfirm --sync --needed autoconf 29 | pacman --noconfirm --sync --needed automake 30 | pacman --noconfirm --sync --needed diffutils 31 | pacman --noconfirm --sync --needed docbook-xsl 32 | pacman --noconfirm --sync --needed libtool 33 | pacman --noconfirm --sync --needed make 34 | pacman --noconfirm --sync --needed mingw-w64-x86_64-cunit 35 | pacman --noconfirm --sync --needed mingw-w64-x86_64-gcc 36 | ;; 37 | esac 38 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | XSLTPROC = /usr/bin/xsltproc 2 | 3 | # Manpages 4 | man1_MANS = iscsi-inq.1 iscsi-ls.1 iscsi-swp.1 iscsi-md5sum.1 iscsi-test-cu.1 5 | 6 | EXTRA_DIST = iscsi-inq.1 iscsi-inq.xml \ 7 | iscsi-ls.1 iscsi-ls.xml \ 8 | iscsi-swp.1 iscsi-swp.xml \ 9 | iscsi-md5sum.1 iscsi-md5sum.xml \ 10 | iscsi-test-cu.1 iscsi-test-cu.xml 11 | 12 | .xml.1: 13 | if BUILD_MANPAGES 14 | $(XSLTPROC) -o $@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $< 15 | else 16 | echo "Building without manpages. Use pre-compiled version of" $< 17 | endif 18 | 19 | -------------------------------------------------------------------------------- /examples/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS=-I. -I${srcdir}/../include -I${srcdir}/../win32 2 | AM_CFLAGS=$(WARN_CFLAGS) 3 | AM_LDFLAGS=-no-undefined 4 | LIBS=../lib/libiscsi.la 5 | 6 | noinst_PROGRAMS = iscsiclient iscsi-dd iscsi-pthreads-inq iscsi-pthreads-readloop iscsi-pthreads-readloop-async 7 | -------------------------------------------------------------------------------- /include/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This is the header file for the MD5 message-digest algorithm. 3 | * The algorithm is due to Ron Rivest. This code was 4 | * written by Colin Plumb in 1993, no copyright is claimed. 5 | * This code is in the public domain; do with it what you wish. 6 | * 7 | * Equivalent code is available from RSA Data Security, Inc. 8 | * This code has been tested against that, and is equivalent, 9 | * except that you don't need to include two pages of legalese 10 | * with every copy. 11 | * 12 | * To compute the message digest of a chunk of bytes, declare an 13 | * MD5Context structure, pass it to MD5Init, call MD5Update as 14 | * needed on buffers full of bytes, and then call MD5Final, which 15 | * will fill a supplied 16-byte array with the digest. 16 | * 17 | * Changed so as no longer to depend on Colin Plumb's `usual.h' 18 | * header definitions; now uses stuff from dpkg's config.h 19 | * - Ian Jackson . 20 | * Still in the public domain. 21 | */ 22 | 23 | #ifndef MD5_H 24 | #define MD5_H 25 | 26 | #if defined(_WIN32) 27 | #else 28 | #include 29 | #endif 30 | 31 | #include 32 | #include 33 | #include 34 | #if (__BYTE_ORDER == __BIG_ENDIAN) 35 | # define WORDS_BIGENDIAN 1 36 | #endif 37 | 38 | typedef uint32_t UWORD32; 39 | 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | 46 | #define md5byte unsigned char 47 | 48 | struct MD5Context { 49 | UWORD32 buf[4]; 50 | UWORD32 bytes[2]; 51 | UWORD32 in[16]; 52 | }; 53 | 54 | void MD5Init(struct MD5Context *context); 55 | void MD5Update(struct MD5Context *context, md5byte const *buf, unsigned len); 56 | void MD5Final(unsigned char digest[16], struct MD5Context *context); 57 | void MD5Transform(UWORD32 buf[4], UWORD32 const in[16]); 58 | 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | #endif /* !MD5_H */ 65 | -------------------------------------------------------------------------------- /include/sha-private.h: -------------------------------------------------------------------------------- 1 | /*************************** sha-private.h ***************************/ 2 | /********************** See RFC 4634 for details *********************/ 3 | #ifndef _SHA_PRIVATE__H 4 | #define _SHA_PRIVATE__H 5 | /* 6 | * These definitions are defined in FIPS-180-2, section 4.1. 7 | * Ch() and Maj() are defined identically in sections 4.1.1, 8 | * 4.1.2 and 4.1.3. 9 | * 10 | * The definitions used in FIPS-180-2 are as follows: 11 | */ 12 | 13 | #ifndef USE_MODIFIED_MACROS 14 | #define SHA_Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z))) 15 | #define SHA_Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) 16 | 17 | #else /* USE_MODIFIED_MACROS */ 18 | /* 19 | * The following definitions are equivalent and potentially faster. 20 | */ 21 | 22 | #define SHA_Ch(x, y, z) (((x) & ((y) ^ (z))) ^ (z)) 23 | #define SHA_Maj(x, y, z) (((x) & ((y) | (z))) | ((y) & (z))) 24 | #endif /* USE_MODIFIED_MACROS */ 25 | 26 | #define SHA_Parity(x, y, z) ((x) ^ (y) ^ (z)) 27 | 28 | #endif /* _SHA_PRIVATE__H */ 29 | -------------------------------------------------------------------------------- /include/sha3.h: -------------------------------------------------------------------------------- 1 | // sha3.h 2 | // 19-Nov-11 Markku-Juhani O. Saarinen 3 | 4 | // From https://github.com/mjosaarinen/tiny_sha3 5 | 6 | #ifndef SHA3_H 7 | #define SHA3_H 8 | 9 | #include 10 | #include 11 | 12 | #ifndef KECCAKF_ROUNDS 13 | #define KECCAKF_ROUNDS 24 14 | #endif 15 | 16 | #ifndef ROTL64 17 | #define ROTL64(x, y) (((x) << (y)) | ((x) >> (64 - (y)))) 18 | #endif 19 | 20 | // state context 21 | typedef struct { 22 | union { // state: 23 | uint8_t b[200]; // 8-bit bytes 24 | uint64_t q[25]; // 64-bit words 25 | } st; 26 | int pt, rsiz, mdlen; // these don't overflow 27 | } sha3_ctx_t; 28 | 29 | // Compression function. 30 | void sha3_keccakf(uint64_t st[25]); 31 | 32 | // OpenSSL - like interfece 33 | int sha3_init(sha3_ctx_t *c, int mdlen); // mdlen = hash output in bytes 34 | int sha3_update(sha3_ctx_t *c, const void *data, size_t len); 35 | int sha3_final(void *md, sha3_ctx_t *c); // digest goes to md 36 | 37 | // compute a sha3 hash (md) of given byte length from "in" 38 | void *sha3(const void *in, size_t inlen, void *md, int mdlen); 39 | 40 | // SHAKE128 and SHAKE256 extensible-output functions 41 | #define shake128_init(c) sha3_init(c, 16) 42 | #define shake256_init(c) sha3_init(c, 32) 43 | #define shake_update sha3_update 44 | 45 | void shake_xof(sha3_ctx_t *c); 46 | void shake_out(sha3_ctx_t *c, void *out, size_t len); 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /include/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | Utility helper functions. 3 | 4 | Copyright (C) 2023 by zhenwei pi 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation; either version 2.1 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with this program; if not, see . 18 | */ 19 | #ifndef __iscsi_utils_h__ 20 | #define __iscsi_utils_h__ 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | struct iscsi_value_string { 27 | int value; 28 | const char *string; 29 | }; 30 | 31 | const char *iscsi_value_string_find(struct iscsi_value_string *values, int value, const char *not_found); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif /* __iscsi_utils_h__ */ 38 | -------------------------------------------------------------------------------- /lib/Makefile.am: -------------------------------------------------------------------------------- 1 | # test-tool needs to access private symbols, so build a noinst convenience 2 | # library. 3 | noinst_LTLIBRARIES = libiscsipriv.la 4 | 5 | libiscsipriv_la_SOURCES = \ 6 | connect.c crc32c.c discovery.c init.c \ 7 | login.c nop.c pdu.c iscsi-command.c \ 8 | multithreading.c \ 9 | scsi-lowlevel.c socket.c sync.c task_mgmt.c \ 10 | logging.c utils.c sha1.c sha224-256.c sha3.c 11 | 12 | if TARGET_OS_IS_WIN32 13 | libiscsipriv_la_SOURCES += ../win32/win32_compat.c 14 | endif 15 | 16 | if NEED_MD5 17 | libiscsipriv_la_SOURCES += md5.c 18 | endif 19 | 20 | if HAVE_LINUX_ISER 21 | libiscsipriv_la_SOURCES += iser.c 22 | endif 23 | 24 | if HAVE_LINUX_ISER 25 | libiscsipriv_la_LIBADD = -libverbs -lrdmacm -lpthread 26 | endif 27 | 28 | libiscsipriv_la_LDFLAGS = -no-undefined 29 | 30 | libiscsipriv_la_CPPFLAGS = -I${srcdir}/../include -I$(srcdir)/include 31 | 32 | AM_CFLAGS=$(WARN_CFLAGS) 33 | 34 | # The proper library just pulls in the convenience library and explicitly 35 | # specifies exported symbols. 36 | lib_LTLIBRARIES = libiscsi.la 37 | 38 | libiscsi_la_SOURCES = 39 | libiscsi_la_LIBADD = libiscsipriv.la 40 | 41 | libiscsi.syms: libiscsi.syms.in 42 | cat <$< >$@ 43 | if TARGET_OS_IS_WIN32 44 | echo win32_poll >>$@ 45 | endif 46 | 47 | EXTRA_libiscsi_la_DEPENDENCIES = libiscsi.syms 48 | 49 | SOCURRENT=11 50 | SOREVISON=1 51 | SOAGE=0 52 | libiscsi_la_LDFLAGS = \ 53 | -version-info $(SOCURRENT):$(SOREVISON):$(SOAGE) -bindir $(bindir) \ 54 | -no-undefined -export-symbols ${srcdir}/libiscsi.syms 55 | 56 | dist_noinst_DATA = libiscsi.syms libiscsi.def 57 | -------------------------------------------------------------------------------- /lib/logging.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2012 by Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation; either version 2.1 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with this program; if not, see . 16 | */ 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | #ifdef HAVE_SYS_TYPES_H 22 | #include 23 | #endif 24 | 25 | #ifdef HAVE_ARPA_INET_H 26 | #include 27 | #endif 28 | 29 | #ifdef HAVE_UNISTD_H 30 | #include 31 | #endif 32 | 33 | #if defined(_WIN32) 34 | #include "win32/win32_compat.h" 35 | #endif 36 | 37 | #include 38 | #include 39 | #include "iscsi.h" 40 | #include "iscsi-private.h" 41 | #include "scsi-lowlevel.h" 42 | 43 | void 44 | iscsi_log_to_stderr(int level, const char *message) 45 | { 46 | fprintf(stderr, "libiscsi:%d %s\n", level, message); 47 | } 48 | 49 | void 50 | iscsi_set_log_fn(struct iscsi_context *iscsi, iscsi_log_fn fn) 51 | { 52 | iscsi->log_fn = fn; 53 | } 54 | 55 | void 56 | iscsi_log_message(struct iscsi_context *iscsi, int level, const char *format, ...) 57 | { 58 | va_list ap; 59 | static char message[1024]; 60 | int ret; 61 | 62 | if (iscsi->log_fn == NULL) { 63 | return; 64 | } 65 | 66 | va_start(ap, format); 67 | ret = vsnprintf(message, 1024, format, ap); 68 | va_end(ap); 69 | 70 | if (ret < 0) { 71 | return; 72 | } 73 | 74 | if (iscsi->target_name[0]) { 75 | static char message2[1294]; 76 | 77 | snprintf(message2, sizeof(message2), "%s [%s/%d]", message, iscsi->target_name, iscsi->lun); 78 | iscsi->log_fn(level, message2); 79 | } 80 | else 81 | iscsi->log_fn(level, message); 82 | } 83 | 84 | 85 | -------------------------------------------------------------------------------- /lib/utils.c: -------------------------------------------------------------------------------- 1 | /* 2 | Utility helper functions. 3 | 4 | Copyright (C) 2023 by zhenwei pi 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation; either version 2.1 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with this program; if not, see . 18 | */ 19 | #ifdef HAVE_CONFIG_H 20 | #include "config.h" 21 | #endif 22 | 23 | #include "utils.h" 24 | 25 | const char *iscsi_value_string_find(struct iscsi_value_string *values, 26 | int value, const char *not_found) 27 | { 28 | for ( ; values->string; values++) { 29 | if (value == values->value) { 30 | return values->string; 31 | } 32 | } 33 | 34 | return not_found; 35 | } 36 | -------------------------------------------------------------------------------- /libiscsi.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=${prefix} 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libiscsi 7 | Description: iSCSI initiator library 8 | Version: @VERSION@ 9 | 10 | Libs: -L${libdir} -liscsi 11 | Libs.private: 12 | Cflags: -I${includedir} 13 | -------------------------------------------------------------------------------- /packaging/RPM/.gitignore: -------------------------------------------------------------------------------- 1 | /*.spec 2 | -------------------------------------------------------------------------------- /patches/README: -------------------------------------------------------------------------------- 1 | This directory contains patches to other packages to make them iSCSI 2 | aware. 3 | 4 | sg3_utils-1.32.patch 5 | ==================== 6 | This patch adds iscsi support to the SG3 package. 7 | This is only added for the Linux platform, but adding to other platforms 8 | supported by SG3 should be trivial. 9 | 10 | $ ./src/sg_inq iscsi://127.0.0.1/iqn.ronnie.test/1 11 | standard INQUIRY: 12 | PQual=0 Device_type=0 RMB=0 version=0x05 [SPC-3] 13 | [AERC=0] [TrmTsk=1] NormACA=0 HiSUP=0 Resp_data_format=2 14 | SCCS=0 ACC=0 TPGS=0 3PC=0 Protect=0 BQue=0 15 | EncServ=0 MultiP=0 [MChngr=0] [ACKREQQ=0] Addr16=0 16 | [RelAdr=0] WBus16=0 Sync=0 Linked=0 [TranDis=0] CmdQue=1 17 | [SPI: Clocking=0x0 QAS=0 IUS=0] 18 | length=66 (0x42) Peripheral device type: disk 19 | Vendor identification: IET 20 | Product identification: VIRTUAL-DISK 21 | Product revision level: 0001 22 | Unit serial number: beaf11 23 | 24 | 25 | mtx-iscsi.diff 26 | ============== 27 | Adds iscsi support to the MTX package to manage media changer devices. 28 | 29 | 30 | -------------------------------------------------------------------------------- /test-tool/README: -------------------------------------------------------------------------------- 1 | This directory contains a libiscsi based test tool. 2 | The purpose of this test tool is to validate iscsi and scsi protocol compliance of a target. 3 | 4 | 5 | Initiatornames and LUN-masking 6 | ============================== 7 | If the target uses lun-masking or ACLs you need to set the target up to allow 8 | iscsi-test access to the LUNs you want to test. 9 | By default iscsi-test uses the following two initiator names : 10 | iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-test 11 | iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-test-2 12 | 13 | Most tests only use the first name but some tests, such as the RESERVE/RELEASE 14 | tests, will use both names. 15 | 16 | Optionally you can use different initiatir names for your testing using the 17 | command line flags : 18 | --initiator-name=iqn. 19 | --initiator-name-2=iqn. 20 | 21 | 22 | Listing all tests and test details: 23 | =================================== 24 | The --list argument is used to show a lost of all major tests that are available 25 | iscsi-test --list 26 | 27 | To list all tests and a description of each test and subtests, use 28 | iscsi-test --list --info 29 | 30 | Running tests: 31 | ============== 32 | Running tests you need to specify which test to run using the --test argument. 33 | This can either be the name of one specific test or a set of tests using * as 34 | the wildcard character. 35 | 36 | Example to run one specific test : 37 | iscsi-test --test="T1020_bufferoffset_invalid" iscsi://127.0.0.1/iqn.ronnie.test/1 38 | 39 | Example to run all READ10 tests : 40 | iscsi-test --test="*read10*" iscsi://127.0.0.1/iqn.ronnie.test/1 41 | 42 | Or to run every test : 43 | iscsi-test --test="*" iscsi://127.0.0.1/iqn.ronnie.test/1 44 | 45 | 46 | -------------------------------------------------------------------------------- /test-tool/data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahlberg/libiscsi/2803276f60ddff33a6212c9f89b3c89456517c04/test-tool/data -------------------------------------------------------------------------------- /test-tool/test_get_lba_status_beyond_eol.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-support.h" 25 | #include "iscsi-test-cu.h" 26 | 27 | 28 | void 29 | test_get_lba_status_beyond_eol(void) 30 | { 31 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 32 | logging(LOG_VERBOSE, "Test GETLBASTATUS one block beyond the end of the LUN"); 33 | 34 | GETLBASTATUS(sd, NULL, num_blocks + 1, 24, 35 | EXPECT_LBA_OOB); 36 | 37 | logging(LOG_VERBOSE, "Test GETLBASTATUS at LBA 2^63"); 38 | GETLBASTATUS(sd, NULL, 0x8000000000000000ULL, 24, 39 | EXPECT_LBA_OOB); 40 | 41 | logging(LOG_VERBOSE, "Test GETLBASTATUS at LBA -1"); 42 | GETLBASTATUS(sd, NULL, 0xffffffffffffffffULL, 24, 43 | EXPECT_LBA_OOB); 44 | } 45 | -------------------------------------------------------------------------------- /test-tool/test_get_lba_status_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-support.h" 25 | #include "iscsi-test-cu.h" 26 | 27 | 28 | void 29 | test_get_lba_status_simple(void) 30 | { 31 | int i; 32 | 33 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 34 | logging(LOG_VERBOSE, "Test GETLBASTATUS of 1-256 blocks at the start of the LUN"); 35 | for (i = 1; i <= 256; i++) { 36 | GETLBASTATUS(sd, NULL, i, 24, 37 | EXPECT_STATUS_GOOD); 38 | } 39 | 40 | logging(LOG_VERBOSE, "Test GETLBASTATUS of 1-256 blocks at the end of the LUN"); 41 | for (i = 1; i <= 256; i++) { 42 | GETLBASTATUS(sd, NULL, num_blocks - i, 24, 43 | EXPECT_STATUS_GOOD); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /test-tool/test_inquiry_evpd.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 by Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-support.h" 25 | #include "iscsi-test-cu.h" 26 | 27 | void 28 | test_inquiry_evpd(void) 29 | { 30 | int ret; 31 | 32 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 33 | logging(LOG_VERBOSE, "Test of the INQUIRY EVPD bit"); 34 | 35 | logging(LOG_VERBOSE, "Verify that INQUIRY with EVPD==0 and PC!=0 is an error"); 36 | ret = inquiry(sd, NULL, 0, 1, 256, 37 | EXPECT_INVALID_FIELD_IN_CDB); 38 | CU_ASSERT_EQUAL(ret, 0); 39 | } 40 | -------------------------------------------------------------------------------- /test-tool/test_inquiry_mandatory_vpd_sbc.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 by Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-support.h" 25 | #include "iscsi-test-cu.h" 26 | 27 | void 28 | test_inquiry_mandatory_vpd_sbc(void) 29 | { 30 | int ret; 31 | 32 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 33 | logging(LOG_VERBOSE, "Test INQUIRY support for mandatory SBC VPD"); 34 | 35 | CHECK_FOR_SBC; 36 | 37 | 38 | logging(LOG_VERBOSE, "SUPPORTED_VPD_PAGES is mandatory for SBC devices. Verify we can read it."); 39 | ret = inquiry(sd, NULL, 40 | 1, SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES, 255, 41 | EXPECT_STATUS_GOOD); 42 | CU_ASSERT_EQUAL(ret, 0); 43 | 44 | logging(LOG_VERBOSE, "DEVICE_IDENTIFICATION is mandatory for SBC devices. Verify we can read it."); 45 | ret = inquiry(sd, NULL, 46 | 1, SCSI_INQUIRY_PAGECODE_DEVICE_IDENTIFICATION, 255, 47 | EXPECT_STATUS_GOOD); 48 | CU_ASSERT_EQUAL(ret, 0); 49 | } 50 | -------------------------------------------------------------------------------- /test-tool/test_orwrite_0blocks.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-test-cu.h" 25 | 26 | void 27 | test_orwrite_0blocks(void) 28 | { 29 | CHECK_FOR_DATALOSS; 30 | CHECK_FOR_SBC; 31 | 32 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 33 | logging(LOG_VERBOSE, "Test ORWRITE 0-blocks at LBA==0"); 34 | ORWRITE(sd, 0, 0, block_size, 0, 0, 0, 0, 0, NULL, 35 | EXPECT_STATUS_GOOD); 36 | 37 | logging(LOG_VERBOSE, "Test ORWRITE 0-blocks one block past end-of-LUN"); 38 | ORWRITE(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0, NULL, 39 | EXPECT_LBA_OOB); 40 | 41 | logging(LOG_VERBOSE, "Test ORWRITE 0-blocks at LBA==2^63"); 42 | ORWRITE(sd, 0x8000000000000000ULL, 0, block_size, 0, 0, 0, 0, 0, NULL, 43 | EXPECT_LBA_OOB); 44 | 45 | logging(LOG_VERBOSE, "Test ORWRITE 0-blocks at LBA==-1"); 46 | ORWRITE(sd, -1, 0, block_size, 0, 0, 0, 0, 0, NULL, 47 | EXPECT_LBA_OOB); 48 | } 49 | -------------------------------------------------------------------------------- /test-tool/test_orwrite_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "iscsi.h" 24 | #include "scsi-lowlevel.h" 25 | #include "iscsi-support.h" 26 | #include "iscsi-test-cu.h" 27 | 28 | 29 | void 30 | test_orwrite_simple(void) 31 | { 32 | int i; 33 | 34 | CHECK_FOR_DATALOSS; 35 | CHECK_FOR_SBC; 36 | 37 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 38 | logging(LOG_VERBOSE, "Test ORWRITE of 1-256 blocks at the start of the LUN"); 39 | memset(scratch, 0xa6, 256 * block_size); 40 | for (i = 1; i <= 256; i++) { 41 | if (maximum_transfer_length && maximum_transfer_length < i) { 42 | break; 43 | } 44 | ORWRITE(sd, 0, i * block_size, 45 | block_size, 0, 0, 0, 0, 0, scratch, 46 | EXPECT_STATUS_GOOD); 47 | } 48 | 49 | logging(LOG_VERBOSE, "Test ORWRITE of 1-256 blocks at the end of the LUN"); 50 | for (i = 1; i <= 256; i++) { 51 | if (maximum_transfer_length && maximum_transfer_length < i) { 52 | break; 53 | } 54 | ORWRITE(sd, num_blocks - i, i * block_size, block_size, 55 | 0, 0, 0, 0, 0, scratch, 56 | EXPECT_STATUS_GOOD); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /test-tool/test_orwrite_wrprotect.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "iscsi.h" 26 | #include "scsi-lowlevel.h" 27 | #include "iscsi-test-cu.h" 28 | 29 | void 30 | test_orwrite_wrprotect(void) 31 | { 32 | int i; 33 | 34 | /* 35 | * Try out different non-zero values for WRPROTECT. 36 | */ 37 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 38 | logging(LOG_VERBOSE, "Test ORWRITE with non-zero WRPROTECT"); 39 | 40 | CHECK_FOR_DATALOSS; 41 | CHECK_FOR_SBC; 42 | 43 | memset(scratch, 0xa6, block_size); 44 | if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { 45 | logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); 46 | for (i = 1; i < 8; i++) { 47 | ORWRITE(sd, 0, block_size, 48 | block_size, i, 0, 0, 0, 0, scratch, 49 | EXPECT_INVALID_FIELD_IN_CDB); 50 | } 51 | return; 52 | } 53 | 54 | logging(LOG_NORMAL, "No tests for devices that support protection information yet."); 55 | } 56 | -------------------------------------------------------------------------------- /test-tool/test_prefetch10_0blocks.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-test-cu.h" 25 | 26 | void 27 | test_prefetch10_0blocks(void) 28 | { 29 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 30 | logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks at LBA==0"); 31 | 32 | PREFETCH10(sd, 0, 0, 0, 0, 33 | EXPECT_STATUS_GOOD); 34 | 35 | if (num_blocks > 0x80000000) { 36 | CU_PASS("[SKIPPED] LUN is too big"); 37 | return; 38 | } 39 | 40 | logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks one block past end-of-LUN"); 41 | PREFETCH10(sd, num_blocks + 1, 0, 0, 0, 42 | EXPECT_LBA_OOB); 43 | 44 | logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks at LBA==2^31"); 45 | PREFETCH10(sd, 0x80000000, 0, 0, 0, 46 | EXPECT_LBA_OOB); 47 | 48 | logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks at LBA==-1"); 49 | PREFETCH10(sd, -1, 0, 0, 0, 50 | EXPECT_LBA_OOB); 51 | } 52 | -------------------------------------------------------------------------------- /test-tool/test_prefetch10_beyond_eol.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-test-cu.h" 25 | 26 | 27 | void 28 | test_prefetch10_beyond_eol(void) 29 | { 30 | int i; 31 | 32 | if (num_blocks >= 0x80000000) { 33 | CU_PASS("LUN is too big for read-beyond-eol tests with PREFETCH10. Skipping test.\n"); 34 | return; 35 | } 36 | 37 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 38 | logging(LOG_VERBOSE, "Test PREFETCH10 1-256 blocks one block beyond the end"); 39 | for (i = 1; i <= 256; i++) { 40 | PREFETCH10(sd, num_blocks + 1 - i, i, 0, 0, 41 | EXPECT_LBA_OOB); 42 | } 43 | 44 | logging(LOG_VERBOSE, "Test PREFETCH10 1-256 blocks at LBA==2^31"); 45 | for (i = 1; i <= 256; i++) { 46 | PREFETCH10(sd, 0x80000000, i, 0, 0, 47 | EXPECT_LBA_OOB); 48 | } 49 | 50 | logging(LOG_VERBOSE, "Test PREFETCH10 1-256 blocks at LBA==-1"); 51 | for (i = 1; i <= 256; i++) { 52 | PREFETCH10(sd, -1, i, 0, 0, 53 | EXPECT_LBA_OOB); 54 | } 55 | 56 | logging(LOG_VERBOSE, "Test PREFETCH10 2-256 blocks all but one block beyond the end"); 57 | for (i = 2; i <= 256; i++) { 58 | PREFETCH10(sd, num_blocks - 1, i, 0, 0, 59 | EXPECT_LBA_OOB); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /test-tool/test_prefetch10_flags.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #include "iscsi.h" 25 | #include "scsi-lowlevel.h" 26 | #include "iscsi-test-cu.h" 27 | 28 | void 29 | test_prefetch10_flags(void) 30 | { 31 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 32 | logging(LOG_VERBOSE, "Test PREFETCH10 flags"); 33 | 34 | logging(LOG_VERBOSE, "Test PREFETCH10 with IMMED==1"); 35 | PREFETCH10(sd, 0, 1, 1, 0, 36 | EXPECT_STATUS_GOOD); 37 | 38 | logging(LOG_VERBOSE, "Test PREFETCH10 with GROUP==3"); 39 | PREFETCH10(sd, 0, 1, 0, 3, 40 | EXPECT_STATUS_GOOD); 41 | 42 | logging(LOG_VERBOSE, "Test PREFETCH10 with IMMED=1 and GROUP==3"); 43 | PREFETCH10(sd, 0, 1, 1, 3, 44 | EXPECT_STATUS_GOOD); 45 | } 46 | -------------------------------------------------------------------------------- /test-tool/test_prefetch10_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-support.h" 25 | #include "iscsi-test-cu.h" 26 | 27 | 28 | void 29 | test_prefetch10_simple(void) 30 | { 31 | int i; 32 | 33 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 34 | logging(LOG_VERBOSE, "Test PREFETCH10 of 1-256 blocks at the start of the LUN"); 35 | for (i = 1; i <= 256; i++) { 36 | PREFETCH10(sd, 0, i, 0, 0, 37 | EXPECT_STATUS_GOOD); 38 | } 39 | 40 | 41 | logging(LOG_VERBOSE, "Test PREFETCH10 of 1-256 blocks at the end of the LUN"); 42 | for (i = 1; i <= 256; i++) { 43 | PREFETCH10(sd, num_blocks - i, i, 0, 0, 44 | EXPECT_STATUS_GOOD); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /test-tool/test_prefetch16_0blocks.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-test-cu.h" 25 | 26 | void 27 | test_prefetch16_0blocks(void) 28 | { 29 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 30 | logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks at LBA==0"); 31 | 32 | PREFETCH16(sd, 0, 0, 0, 0, 33 | EXPECT_STATUS_GOOD); 34 | 35 | logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks one block past end-of-LUN"); 36 | PREFETCH16(sd, num_blocks + 1, 0, 0, 0, 37 | EXPECT_LBA_OOB); 38 | 39 | logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks at LBA==2^63"); 40 | PREFETCH16(sd, 0x8000000000000000ULL, 0, 0, 0, 41 | EXPECT_LBA_OOB); 42 | 43 | logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks at LBA==-1"); 44 | PREFETCH16(sd, -1, 0, 0, 0, 45 | EXPECT_LBA_OOB); 46 | } 47 | -------------------------------------------------------------------------------- /test-tool/test_prefetch16_beyond_eol.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-test-cu.h" 25 | 26 | 27 | void 28 | test_prefetch16_beyond_eol(void) 29 | { 30 | int i; 31 | 32 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 33 | logging(LOG_VERBOSE, "Test PREFETCH16 1-256 blocks one block beyond the end"); 34 | for (i = 1; i <= 256; i++) { 35 | PREFETCH16(sd, num_blocks + 1 - i, i, 0, 0, 36 | EXPECT_LBA_OOB); 37 | } 38 | 39 | logging(LOG_VERBOSE, "Test PREFETCH16 1-256 blocks at LBA==2^63"); 40 | for (i = 1; i <= 256; i++) { 41 | PREFETCH16(sd, 0x8000000000000000ULL, i, 0, 0, 42 | EXPECT_LBA_OOB); 43 | } 44 | 45 | logging(LOG_VERBOSE, "Test PREFETCH16 1-256 blocks at LBA==-1"); 46 | for (i = 1; i <= 256; i++) { 47 | PREFETCH16(sd, -1, i, 0, 0, 48 | EXPECT_LBA_OOB); 49 | } 50 | 51 | logging(LOG_VERBOSE, "Test PREFETCH16 2-256 blocks all but one block beyond the end"); 52 | for (i = 2; i <= 256; i++) { 53 | PREFETCH16(sd, num_blocks - 1, i, 0, 0, 54 | EXPECT_LBA_OOB); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /test-tool/test_prefetch16_flags.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #include "iscsi.h" 25 | #include "scsi-lowlevel.h" 26 | #include "iscsi-test-cu.h" 27 | 28 | void 29 | test_prefetch16_flags(void) 30 | { 31 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 32 | logging(LOG_VERBOSE, "Test PREFETCH16 flags"); 33 | 34 | logging(LOG_VERBOSE, "Test PREFETCH16 with IMMED==1"); 35 | PREFETCH16(sd, 0, 1, 1, 0, 36 | EXPECT_STATUS_GOOD); 37 | 38 | logging(LOG_VERBOSE, "Test PREFETCH16 with GROUP==3"); 39 | PREFETCH16(sd, 0, 1, 0, 3, 40 | EXPECT_STATUS_GOOD); 41 | 42 | logging(LOG_VERBOSE, "Test PREFETCH16 with IMMED=1 and GROUP==3"); 43 | PREFETCH16(sd, 0, 1, 1, 3, 44 | EXPECT_STATUS_GOOD); 45 | } 46 | -------------------------------------------------------------------------------- /test-tool/test_prefetch16_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-support.h" 25 | #include "iscsi-test-cu.h" 26 | 27 | 28 | void 29 | test_prefetch16_simple(void) 30 | { 31 | int i; 32 | 33 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 34 | logging(LOG_VERBOSE, "Test PREFETCH16 of 1-256 blocks at the start of the LUN"); 35 | for (i = 1; i <= 256; i++) { 36 | PREFETCH16(sd, 0, i, 0, 0, 37 | EXPECT_STATUS_GOOD); 38 | } 39 | 40 | 41 | logging(LOG_VERBOSE, "Test PREFETCH16 of 1-256 blocks at the end of the LUN"); 42 | for (i = 1; i <= 256; i++) { 43 | PREFETCH16(sd, num_blocks - i, i, 0, 0, 44 | EXPECT_STATUS_GOOD); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /test-tool/test_preventallow_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 by Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-support.h" 25 | #include "iscsi-test-cu.h" 26 | 27 | void 28 | test_preventallow_simple(void) 29 | { 30 | CHECK_FOR_SBC; 31 | CHECK_FOR_REMOVABLE; 32 | 33 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 34 | logging(LOG_VERBOSE, "Test PREVENTALLOW basics"); 35 | 36 | logging(LOG_VERBOSE, "Test we can set PREVENT flag"); 37 | PREVENTALLOW(sd, 1); 38 | 39 | logging(LOG_VERBOSE, "Test we can clear PREVENT flag"); 40 | PREVENTALLOW(sd, 0); 41 | } 42 | -------------------------------------------------------------------------------- /test-tool/test_prin_read_keys_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 by Lee Duncan 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "iscsi.h" 24 | #include "scsi-lowlevel.h" 25 | #include "iscsi-support.h" 26 | #include "iscsi-test-cu.h" 27 | 28 | 29 | void 30 | test_prin_read_keys_simple(void) 31 | { 32 | int ret = 0; 33 | int al; 34 | 35 | 36 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 37 | logging(LOG_VERBOSE, "Test Persistent Reserve IN READ_KEYS works."); 38 | 39 | ret = prin_read_keys(sd, &task, NULL, 16384); 40 | if (ret == -2) { 41 | CU_PASS("PERSISTENT RESERVE IN is not implemented."); 42 | return; 43 | } 44 | CU_ASSERT_EQUAL(ret, 0); 45 | 46 | logging(LOG_VERBOSE, "Test DATA-IN is at least 8 bytes."); 47 | if (task->datain.size < 8) { 48 | logging(LOG_NORMAL, 49 | "[FAILED] DATA-IN returned less than 8 bytes"); 50 | return; 51 | } 52 | 53 | logging(LOG_VERBOSE, "Test ADDITIONAL_LENGTH matches DATA_IN size."); 54 | al = scsi_get_uint32(&task->datain.data[4]); 55 | if (al != task->datain.size - 8) { 56 | logging(LOG_NORMAL, 57 | "[FAILED] ADDITIONAL_LENGTH was %d bytes but %d was expected.", 58 | al, task->datain.size - 8); 59 | return; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /test-tool/test_prin_serviceaction_range.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 by Lee Duncan 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "iscsi.h" 24 | #include "scsi-lowlevel.h" 25 | #include "iscsi-support.h" 26 | #include "iscsi-test-cu.h" 27 | 28 | 29 | void 30 | test_prin_serviceaction_range(void) 31 | { 32 | int ret = 0; 33 | int i; 34 | 35 | 36 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 37 | logging(LOG_VERBOSE, "Test Persistent Reserve IN Serviceaction range."); 38 | 39 | /* verify PRIN/READ_KEYS works -- XXX redundant -- remove this? */ 40 | ret = prin_read_keys(sd, &task, NULL, 16384); 41 | if (ret == -2) { 42 | CU_PASS("PERSISTENT RESERVE IN is not implemented."); 43 | return; 44 | } 45 | CU_ASSERT_EQUAL(ret, 0); 46 | 47 | /* verify that PRIN/SA={0,1,2,3} works ... */ 48 | for (i = 0; i < 4; i++) { 49 | ret = prin_task(sd, i, 1); 50 | CU_ASSERT_EQUAL(ret, 0); 51 | } 52 | 53 | /* verify that PRIN/SA={4..0x20} fails ... */ 54 | for (i = 4; i < 0x20; i++) { 55 | ret = prin_task(sd, i, 0); 56 | CU_ASSERT_EQUAL(ret, 0); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /test-tool/test_prout_register_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 by Lee Duncan 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "iscsi.h" 24 | #include "scsi-lowlevel.h" 25 | #include "iscsi-support.h" 26 | #include "iscsi-test-cu.h" 27 | 28 | 29 | void 30 | test_prout_register_simple(void) 31 | { 32 | const unsigned long long key = rand_key(); 33 | int ret = 0; 34 | 35 | 36 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 37 | logging(LOG_VERBOSE, "Test Persistent Reserve IN REGISTER works."); 38 | 39 | /* register our reservation key with the target */ 40 | ret = prout_register_and_ignore(sd, key); 41 | if (ret == -2) { 42 | CU_PASS("PERSISTENT RESERVE OUT is not implemented."); 43 | return; 44 | } 45 | CU_ASSERT_EQUAL(ret, 0); 46 | 47 | /* verify we can read the registration */ 48 | ret = prin_verify_key_presence(sd, key, 1); 49 | CU_ASSERT_EQUAL(ret, 0); 50 | 51 | /* try to reregister, which should fail */ 52 | ret = prout_reregister_key_fails(sd, key+1); 53 | CU_ASSERT_EQUAL(ret, 0); 54 | 55 | /* release from the target */ 56 | ret = prout_register_key(sd, 0, key); 57 | CU_ASSERT_EQUAL(ret, 0); 58 | 59 | /* Verify the registration is gone */ 60 | ret = prin_verify_key_presence(sd, key, 0); 61 | CU_ASSERT_EQUAL(ret, 0); 62 | } 63 | -------------------------------------------------------------------------------- /test-tool/test_read10_0blocks.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2012 by Lee Duncan 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-test-cu.h" 25 | 26 | void 27 | test_read10_0blocks(void) 28 | { 29 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 30 | logging(LOG_VERBOSE, "Test READ10 0-blocks at LBA==0"); 31 | 32 | READ10(sd, NULL, 0, 0, block_size, 0, 0, 0, 0, 0, NULL, 33 | EXPECT_STATUS_GOOD); 34 | 35 | if (num_blocks > 0x80000000) { 36 | CU_PASS("[SKIPPED] LUN is too big"); 37 | return; 38 | } 39 | 40 | logging(LOG_VERBOSE, "Test READ10 0-blocks one block past end-of-LUN"); 41 | READ10(sd, NULL, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0, NULL, 42 | EXPECT_LBA_OOB); 43 | 44 | logging(LOG_VERBOSE, "Test READ10 0-blocks at LBA==2^31"); 45 | READ10(sd, NULL, 0x80000000, 0, block_size, 0, 0, 0, 0, 0, NULL, 46 | EXPECT_LBA_OOB); 47 | 48 | logging(LOG_VERBOSE, "Test READ10 0-blocks at LBA==-1"); 49 | READ10(sd, NULL, -1, 0, block_size, 0, 0, 0, 0, 0, NULL, 50 | EXPECT_LBA_OOB); 51 | } 52 | -------------------------------------------------------------------------------- /test-tool/test_read10_rdprotect.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2012 by Lee Duncan 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #include "iscsi.h" 25 | #include "scsi-lowlevel.h" 26 | #include "iscsi-test-cu.h" 27 | 28 | void 29 | test_read10_rdprotect(void) 30 | { 31 | int i; 32 | 33 | /* 34 | * Try out different non-zero values for RDPROTECT. 35 | */ 36 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 37 | logging(LOG_VERBOSE, "Test READ10 with non-zero RDPROTECT"); 38 | 39 | CHECK_FOR_SBC; 40 | 41 | if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { 42 | logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); 43 | for (i = 1; i < 8; i++) { 44 | READ10(sd, NULL, 0, block_size, block_size, 45 | i, 0, 0, 0, 0, NULL, 46 | EXPECT_INVALID_FIELD_IN_CDB); 47 | } 48 | return; 49 | } 50 | 51 | logging(LOG_NORMAL, "No tests for devices that support protection information yet."); 52 | } 53 | -------------------------------------------------------------------------------- /test-tool/test_read10_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2012 by Lee Duncan 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-support.h" 25 | #include "iscsi-test-cu.h" 26 | 27 | 28 | void 29 | test_read10_simple(void) 30 | { 31 | int i; 32 | 33 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 34 | logging(LOG_VERBOSE, "Test READ10 of 1-256 blocks at the start of the LUN"); 35 | for (i = 1; i <= 256; i++) { 36 | if (maximum_transfer_length && maximum_transfer_length < i) { 37 | break; 38 | } 39 | READ10(sd, NULL, 0, i * block_size, 40 | block_size, 0, 0, 0, 0, 0, NULL, 41 | EXPECT_STATUS_GOOD); 42 | } 43 | 44 | logging(LOG_VERBOSE, "Test READ10 of 1-256 blocks at the end of the LUN"); 45 | for (i = 1; i <= 256; i++) { 46 | if (maximum_transfer_length && maximum_transfer_length < i) { 47 | break; 48 | } 49 | READ10(sd, NULL, num_blocks - i, 50 | i * block_size, block_size, 0, 0, 0, 0, 0, NULL, 51 | EXPECT_STATUS_GOOD); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /test-tool/test_read12_0blocks.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-test-cu.h" 25 | 26 | void 27 | test_read12_0blocks(void) 28 | { 29 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 30 | logging(LOG_VERBOSE, "Test READ12 0-blocks at LBA==0"); 31 | READ12(sd, NULL, 0, 0, block_size, 0, 0, 0, 0, 0, NULL, 32 | EXPECT_STATUS_GOOD); 33 | 34 | if (num_blocks > 0x80000000) { 35 | CU_PASS("[SKIPPED] LUN is too big"); 36 | return; 37 | } 38 | 39 | logging(LOG_VERBOSE, "Test READ12 0-blocks one block past end-of-LUN"); 40 | READ12(sd, NULL, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0, NULL, 41 | EXPECT_LBA_OOB); 42 | 43 | logging(LOG_VERBOSE, "Test READ12 0-blocks at LBA==2^31"); 44 | READ12(sd, NULL, 0x80000000, 0, block_size, 0, 0, 0, 0, 0, NULL, 45 | EXPECT_LBA_OOB); 46 | 47 | logging(LOG_VERBOSE, "Test READ12 0-blocks at LBA==-1"); 48 | READ12(sd, NULL, -1, 0, block_size, 0, 0, 0, 0, 0, NULL, 49 | EXPECT_LBA_OOB); 50 | } 51 | -------------------------------------------------------------------------------- /test-tool/test_read12_rdprotect.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #include "iscsi.h" 25 | #include "scsi-lowlevel.h" 26 | #include "iscsi-test-cu.h" 27 | 28 | void 29 | test_read12_rdprotect(void) 30 | { 31 | int i; 32 | 33 | /* 34 | * Try out different non-zero values for RDPROTECT. 35 | */ 36 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 37 | logging(LOG_VERBOSE, "Test READ12 with non-zero RDPROTECT"); 38 | 39 | CHECK_FOR_SBC; 40 | 41 | if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { 42 | logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); 43 | for (i = 1; i < 8; i++) { 44 | READ12(sd, NULL, 0, block_size, block_size, 45 | i, 0, 0, 0, 0, NULL, 46 | EXPECT_INVALID_FIELD_IN_CDB); 47 | } 48 | return; 49 | } 50 | 51 | logging(LOG_NORMAL, "No tests for devices that support protection information yet."); 52 | } 53 | -------------------------------------------------------------------------------- /test-tool/test_read12_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-support.h" 25 | #include "iscsi-test-cu.h" 26 | 27 | 28 | void 29 | test_read12_simple(void) 30 | { 31 | int i; 32 | 33 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 34 | logging(LOG_VERBOSE, "Test READ12 of 1-256 blocks at the start of the LUN"); 35 | for (i = 1; i <= 256; i++) { 36 | if (maximum_transfer_length && maximum_transfer_length < i) { 37 | break; 38 | } 39 | READ12(sd, NULL, 0, i * block_size, 40 | block_size, 0, 0, 0, 0, 0, NULL, 41 | EXPECT_STATUS_GOOD); 42 | } 43 | 44 | 45 | logging(LOG_VERBOSE, "Test READ12 of 1-256 blocks at the end of the LUN"); 46 | for (i = 1; i <= 256; i++) { 47 | if (maximum_transfer_length && maximum_transfer_length < i) { 48 | break; 49 | } 50 | READ12(sd, NULL, num_blocks - i, 51 | i * block_size, block_size, 0, 0, 0, 0, 0, NULL, 52 | EXPECT_STATUS_GOOD); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /test-tool/test_read16_0blocks.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-test-cu.h" 25 | 26 | void 27 | test_read16_0blocks(void) 28 | { 29 | CHECK_FOR_SBC; 30 | 31 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 32 | logging(LOG_VERBOSE, "Test READ16 0-blocks at LBA==0"); 33 | READ16(sd, NULL, 0, 0, block_size, 0, 0, 0, 0, 0, NULL, 34 | EXPECT_STATUS_GOOD); 35 | 36 | logging(LOG_VERBOSE, "Test READ16 0-blocks one block past end-of-LUN"); 37 | READ16(sd, NULL, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0, NULL, 38 | EXPECT_LBA_OOB); 39 | 40 | logging(LOG_VERBOSE, "Test READ16 0-blocks at LBA==2^63"); 41 | READ16(sd, NULL, 0x8000000000000000ULL, 0, 42 | block_size, 0, 0, 0, 0, 0, NULL, 43 | EXPECT_LBA_OOB); 44 | 45 | logging(LOG_VERBOSE, "Test READ16 0-blocks at LBA==-1"); 46 | READ16(sd, NULL, -1, 0, block_size, 0, 0, 0, 0, 0, NULL, 47 | EXPECT_LBA_OOB); 48 | } 49 | -------------------------------------------------------------------------------- /test-tool/test_read16_rdprotect.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #include "iscsi.h" 25 | #include "scsi-lowlevel.h" 26 | #include "iscsi-test-cu.h" 27 | 28 | void 29 | test_read16_rdprotect(void) 30 | { 31 | int i; 32 | 33 | /* 34 | * Try out different non-zero values for RDPROTECT. 35 | */ 36 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 37 | logging(LOG_VERBOSE, "Test READ16 with non-zero RDPROTECT"); 38 | 39 | CHECK_FOR_SBC; 40 | 41 | if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { 42 | logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); 43 | for (i = 1; i < 8; i++) { 44 | READ16(sd, NULL, 0, block_size, block_size, 45 | i, 0, 0, 0, 0, NULL, 46 | EXPECT_INVALID_FIELD_IN_CDB); 47 | } 48 | return; 49 | } 50 | logging(LOG_NORMAL, "No tests for devices that support protection information yet."); 51 | } 52 | -------------------------------------------------------------------------------- /test-tool/test_read16_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-support.h" 25 | #include "iscsi-test-cu.h" 26 | 27 | 28 | void 29 | test_read16_simple(void) 30 | { 31 | int i; 32 | 33 | CHECK_FOR_SBC; 34 | 35 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 36 | logging(LOG_VERBOSE, "Test READ16 of 1-256 blocks at the start of the LUN"); 37 | for (i = 1; i <= 256; i++) { 38 | if (maximum_transfer_length && maximum_transfer_length < i) { 39 | break; 40 | } 41 | READ16(sd, NULL, 0, i * block_size, 42 | block_size, 0, 0, 0, 0, 0, NULL, 43 | EXPECT_STATUS_GOOD); 44 | } 45 | 46 | 47 | logging(LOG_VERBOSE, "Test READ16 of 1-256 blocks at the end of the LUN"); 48 | for (i = 1; i <= 256; i++) { 49 | if (maximum_transfer_length && maximum_transfer_length < i) { 50 | break; 51 | } 52 | READ16(sd, NULL, num_blocks - i, 53 | i * block_size, block_size, 0, 0, 0, 0, 0, NULL, 54 | EXPECT_STATUS_GOOD); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /test-tool/test_read6_beyond_eol.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-test-cu.h" 25 | 26 | 27 | void 28 | test_read6_beyond_eol(void) 29 | { 30 | int i; 31 | 32 | if (num_blocks > 0x1fffff) { 33 | CU_PASS("LUN is too big for read-beyond-eol tests with READ6. Skipping test.\n"); 34 | return; 35 | } 36 | 37 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 38 | logging(LOG_VERBOSE, "Test READ6 1-255 blocks one block beyond the end"); 39 | for (i = 1; i <= 255 && i + 0U <= num_blocks + 1; i++) { 40 | READ6(sd, NULL, num_blocks + 1 - i, 41 | i * block_size, block_size, NULL, 42 | EXPECT_LBA_OOB); 43 | } 44 | 45 | logging(LOG_VERBOSE, "Test READ6 1-255 blocks at LBA==0x1fffff"); 46 | for (i = 1; i <= 255; i++) { 47 | READ6(sd, NULL, 0x1fffff, i * block_size, block_size, NULL, 48 | EXPECT_LBA_OOB); 49 | } 50 | 51 | if (num_blocks == 0) { 52 | CU_PASS("LUN is too small for read-beyond-eol tests with READ6. Skipping test.\n"); 53 | return; 54 | } 55 | 56 | logging(LOG_VERBOSE, "Test READ6 2-255 blocks all but one block beyond the end"); 57 | for (i = 2; i <= 255; i++) { 58 | READ6(sd, NULL, num_blocks - 1, 59 | i * block_size, block_size, NULL, 60 | EXPECT_LBA_OOB); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /test-tool/test_readcapacity10_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 by Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-support.h" 25 | #include "iscsi-test-cu.h" 26 | 27 | 28 | void 29 | test_readcapacity10_simple(void) 30 | { 31 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 32 | logging(LOG_VERBOSE, "Test basic READCAPACITY10"); 33 | 34 | READCAPACITY10(sd, NULL, 0, 0, 35 | EXPECT_STATUS_GOOD); 36 | } 37 | -------------------------------------------------------------------------------- /test-tool/test_readcapacity16_alloclen.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 by Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-support.h" 25 | #include "iscsi-test-cu.h" 26 | 27 | 28 | void 29 | test_readcapacity16_alloclen(void) 30 | { 31 | int i; 32 | 33 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 34 | logging(LOG_VERBOSE, "Test that READCAPACITY16 with alloc_len 0-15 is not an error"); 35 | 36 | for (i = 0; i < 16; i++) { 37 | READCAPACITY16(sd, NULL, i, 38 | EXPECT_STATUS_GOOD); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /test-tool/test_readcapacity16_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 by Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-support.h" 25 | #include "iscsi-test-cu.h" 26 | 27 | 28 | void 29 | test_readcapacity16_simple(void) 30 | { 31 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 32 | logging(LOG_VERBOSE, "Test that READCAPACITY16 works"); 33 | 34 | READCAPACITY16(sd, NULL, 16, 35 | EXPECT_STATUS_GOOD); 36 | } 37 | -------------------------------------------------------------------------------- /test-tool/test_readcapacity16_support.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 by Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-support.h" 25 | #include "iscsi-test-cu.h" 26 | 27 | 28 | void 29 | test_readcapacity16_support(void) 30 | { 31 | int ret; 32 | 33 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 34 | logging(LOG_VERBOSE, "Test that READCAPACITY16 is supported on SBC3"); 35 | 36 | ret = readcapacity16(sd, NULL, 15, 37 | EXPECT_STATUS_GOOD); 38 | if (ret == -2) { 39 | if (sbc3_support) { 40 | logging(LOG_NORMAL, "[FAILED] READCAPACITY16 is not available but the device claims SBC-3 support."); 41 | CU_FAIL("READCAPACITY16 failed but the device claims SBC-3 support."); 42 | } else { 43 | logging(LOG_NORMAL, "[SKIPPED] READCAPACITY16 is not implemented on this target and it does not claim SBC-3 support."); 44 | } 45 | } else { 46 | CU_ASSERT_EQUAL(ret, 0); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /test-tool/test_readdefectdata10_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 by Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-support.h" 25 | #include "iscsi-test-cu.h" 26 | 27 | 28 | void 29 | test_readdefectdata10_simple(void) 30 | { 31 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 32 | logging(LOG_VERBOSE, "Test basic READDEFECTDATA10"); 33 | 34 | READDEFECTDATA10(sd, NULL, 0, 0, 0, 32, 35 | EXPECT_STATUS_GOOD); 36 | } 37 | -------------------------------------------------------------------------------- /test-tool/test_readdefectdata12_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 by Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-support.h" 25 | #include "iscsi-test-cu.h" 26 | 27 | 28 | void 29 | test_readdefectdata12_simple(void) 30 | { 31 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 32 | logging(LOG_VERBOSE, "Test basic READDEFECTDATA12"); 33 | 34 | READDEFECTDATA12(sd, NULL, 0, 0, 0, 0, 32, 35 | EXPECT_STATUS_GOOD); 36 | } 37 | -------------------------------------------------------------------------------- /test-tool/test_receive_copy_results_op_params.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 SanDisk Corp. 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "iscsi.h" 26 | #include "scsi-lowlevel.h" 27 | #include "iscsi-test-cu.h" 28 | 29 | void 30 | test_receive_copy_results_op_params(void) 31 | { 32 | struct scsi_task *op_task = NULL; 33 | struct scsi_copy_results_op_params *opp; 34 | int ret; 35 | 36 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 37 | logging(LOG_VERBOSE, "Test RECEIVE COPY RESULTS, OPERATING PARAMS"); 38 | 39 | ret = RECEIVE_COPY_RESULTS(&op_task, sd, SCSI_COPY_RESULTS_OP_PARAMS, 0, 40 | (void **)&opp, EXPECT_STATUS_GOOD); 41 | 42 | if (ret == 0) 43 | logging(LOG_NORMAL, 44 | "max_target_desc=%d, max_seg_desc=%d", 45 | opp->max_target_desc_count, 46 | opp->max_segment_desc_count); 47 | 48 | scsi_free_scsi_task(op_task); 49 | } 50 | -------------------------------------------------------------------------------- /test-tool/test_report_luns.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) SUSE LLC 2020 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "iscsi.h" 26 | #include "scsi-lowlevel.h" 27 | #include "iscsi-test-cu.h" 28 | 29 | void 30 | test_report_luns_simple(void) 31 | { 32 | struct scsi_task *rl_task; 33 | struct scsi_reportluns_list *rl_list; 34 | int full_report_size; 35 | uint32_t i; 36 | 37 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 38 | logging(LOG_VERBOSE, "Test REPORT LUNS"); 39 | 40 | rl_task = iscsi_reportluns_sync(sd->iscsi_ctx, 0, 512); 41 | CU_ASSERT_PTR_NOT_NULL_FATAL(rl_task); 42 | 43 | full_report_size = scsi_datain_getfullsize(rl_task); 44 | if (full_report_size > rl_task->datain.size) { 45 | logging(LOG_NORMAL, 46 | "[SKIPPED] REPORT LUNS response truncated."); 47 | CU_PASS("REPORT LUNS response truncated."); 48 | } 49 | 50 | rl_list = scsi_datain_unmarshall(rl_task); 51 | if (rl_list == NULL) { 52 | fprintf(stderr, "failed to unmarshall reportluns datain blob\n"); 53 | exit(10); 54 | } 55 | 56 | for (i = 0; i < rl_list->num; i++) { 57 | uint32_t j; 58 | logging(LOG_VERBOSE, "LUN[%u]: 0x%02hx", (unsigned)i, 59 | (unsigned short)rl_list->luns[i]); 60 | /* inefficiently check for duplicates */ 61 | for (j = i + 1; j < rl_list->num; j++) 62 | CU_ASSERT_NOT_EQUAL(rl_list->luns[i], rl_list->luns[j]); 63 | } 64 | 65 | scsi_free_scsi_task(rl_task); 66 | } 67 | -------------------------------------------------------------------------------- /test-tool/test_report_supported_opcodes_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 by Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-support.h" 25 | #include "iscsi-test-cu.h" 26 | 27 | 28 | void 29 | test_report_supported_opcodes_simple(void) 30 | { 31 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 32 | logging(LOG_VERBOSE, "Test basic READ_SUPPORTED_OPCODES"); 33 | 34 | REPORT_SUPPORTED_OPCODES(sd, NULL, 35 | 0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0, 36 | 1024, 37 | EXPECT_STATUS_GOOD); 38 | } 39 | -------------------------------------------------------------------------------- /test-tool/test_reserve6_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-support.h" 25 | #include "iscsi-test-cu.h" 26 | 27 | 28 | void 29 | test_reserve6_simple(void) 30 | { 31 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 32 | logging(LOG_VERBOSE, "Test basic RESERVE6/RELEASE6 commands if supported"); 33 | 34 | RESERVE6(sd); 35 | 36 | RELEASE6(sd); 37 | } 38 | -------------------------------------------------------------------------------- /test-tool/test_sanitize_invalid_serviceaction.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "iscsi.h" 26 | #include "scsi-lowlevel.h" 27 | #include "iscsi-test-cu.h" 28 | 29 | void 30 | test_sanitize_invalid_serviceaction(void) 31 | { 32 | int i; 33 | 34 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 35 | logging(LOG_VERBOSE, "Test SANITIZE for invalid serviceactions"); 36 | 37 | CHECK_FOR_SANITIZE; 38 | 39 | logging(LOG_VERBOSE, "Test all invalid service actions and make sure " 40 | "they fail with an error"); 41 | for (i = 0; i <= 0x1f; i++) { 42 | switch (i) { 43 | case 1: 44 | case 2: 45 | case 3: 46 | case 0x1f: 47 | continue; 48 | } 49 | 50 | logging(LOG_VERBOSE, "Verify that ServiceAction:0x%02d is " 51 | "an error.", i); 52 | 53 | SANITIZE(sd, 0, 0, i, 0, NULL, 54 | EXPECT_INVALID_FIELD_IN_CDB); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /test-tool/test_startstopunit_pwrcnd.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #include "iscsi.h" 25 | #include "scsi-lowlevel.h" 26 | #include "iscsi-test-cu.h" 27 | 28 | void 29 | test_startstopunit_pwrcnd(void) 30 | { 31 | int i; 32 | 33 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 34 | logging(LOG_VERBOSE, "Test STARTSTOPUNIT PowerCondition"); 35 | if (!inq->rmb) { 36 | logging(LOG_VERBOSE, "[SKIPPED] LUN is not removable. " 37 | "Skipping test."); 38 | return; 39 | } 40 | 41 | logging(LOG_VERBOSE, "Test that media is not ejected when PC!=0"); 42 | for (i = 1; i < 16; i++) { 43 | STARTSTOPUNIT(sd, 1, 0, i, 0, 1, 0, 44 | EXPECT_STATUS_GOOD); 45 | 46 | logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected."); 47 | TESTUNITREADY(sd, 48 | EXPECT_STATUS_GOOD); 49 | } 50 | 51 | logging(LOG_VERBOSE, "In case the target did eject the medium, load it again."); 52 | STARTSTOPUNIT(sd, 1, 0, 0, 0, 1, 1, 53 | EXPECT_STATUS_GOOD); 54 | } 55 | -------------------------------------------------------------------------------- /test-tool/test_testunitready_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2012 by Lee Duncan 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-test-cu.h" 25 | 26 | void 27 | test_testunitready_simple(void) 28 | { 29 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 30 | logging(LOG_VERBOSE, "Test TESTUNITREADY"); 31 | TESTUNITREADY(sd, 32 | EXPECT_STATUS_GOOD); 33 | } 34 | -------------------------------------------------------------------------------- /test-tool/test_verify10_0blocks.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-test-cu.h" 25 | 26 | void 27 | test_verify10_0blocks(void) 28 | { 29 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 30 | logging(LOG_VERBOSE, "Test VERIFY10 0-blocks at LBA==0"); 31 | 32 | logging(LOG_VERBOSE, "Test VERIFY10 0-blocks one block past end-of-LUN"); 33 | VERIFY10(sd, num_blocks + 1, 0, block_size, 0, 0, 1, NULL, 34 | EXPECT_LBA_OOB); 35 | 36 | if (num_blocks - 1 < 0x80000000) { 37 | logging(LOG_VERBOSE, "Test VERIFY10 0-blocks at LBA==2^31"); 38 | VERIFY10(sd, 0x80000000, 0, block_size, 0, 0, 1, NULL, 39 | EXPECT_LBA_OOB); 40 | } 41 | 42 | logging(LOG_VERBOSE, "Test VERIFY10 0-blocks at LBA==-1"); 43 | VERIFY10(sd, -1, 0, block_size, 0, 0, 1, NULL, 44 | EXPECT_LBA_OOB); 45 | } 46 | -------------------------------------------------------------------------------- /test-tool/test_verify10_flags.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-support.h" 25 | #include "iscsi-test-cu.h" 26 | 27 | 28 | void 29 | test_verify10_flags(void) 30 | { 31 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 32 | logging(LOG_VERBOSE, "Test VERIFY10 flags"); 33 | 34 | READ10(sd, NULL, 0, block_size, 35 | block_size, 0, 0, 0, 0, 0, scratch, 36 | EXPECT_STATUS_GOOD); 37 | logging(LOG_VERBOSE, "Test VERIFY10 with BYTCHK==1"); 38 | VERIFY10(sd, 0, block_size, block_size, 0, 0, 1, scratch, 39 | EXPECT_STATUS_GOOD); 40 | } 41 | -------------------------------------------------------------------------------- /test-tool/test_verify10_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "iscsi.h" 24 | #include "scsi-lowlevel.h" 25 | #include "iscsi-support.h" 26 | #include "iscsi-test-cu.h" 27 | 28 | 29 | void 30 | test_verify10_simple(void) 31 | { 32 | int i; 33 | 34 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 35 | logging(LOG_VERBOSE, "Test VERIFY10 of 1-256 blocks at the start of the LUN"); 36 | for (i = 1; i <= 256; i++) { 37 | if (maximum_transfer_length && maximum_transfer_length < i) { 38 | break; 39 | } 40 | READ10(sd, NULL, 0, i * block_size, 41 | block_size, 0, 0, 0, 0, 0, scratch, 42 | EXPECT_STATUS_GOOD); 43 | VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 1, scratch, 44 | EXPECT_STATUS_GOOD); 45 | } 46 | 47 | logging(LOG_VERBOSE, "Test VERIFY10 of 1-256 blocks at the end of the LUN"); 48 | for (i = 1; i <= 256; i++) { 49 | if (maximum_transfer_length && maximum_transfer_length < i) { 50 | break; 51 | } 52 | READ10(sd, NULL, num_blocks - i, 53 | i * block_size, block_size, 0, 0, 0, 0, 0, scratch, 54 | EXPECT_STATUS_GOOD); 55 | VERIFY10(sd, num_blocks - i, 56 | i * block_size, block_size, 0, 0, 1, scratch, 57 | EXPECT_STATUS_GOOD); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /test-tool/test_verify10_vrprotect.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "iscsi.h" 24 | #include "scsi-lowlevel.h" 25 | #include "iscsi-support.h" 26 | #include "iscsi-test-cu.h" 27 | 28 | 29 | void 30 | test_verify10_vrprotect(void) 31 | { 32 | int i; 33 | 34 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 35 | logging(LOG_VERBOSE, "Test VERIFY10 with non-zero VRPROTECT"); 36 | 37 | CHECK_FOR_SBC; 38 | 39 | if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { 40 | logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); 41 | for (i = 1; i < 8; i++) { 42 | READ10(sd, NULL, 0, block_size, 43 | block_size, 0, 0, 0, 0, 0, scratch, 44 | EXPECT_STATUS_GOOD); 45 | VERIFY10(sd, 0, block_size, 46 | block_size, i, 0, 1, scratch, 47 | EXPECT_INVALID_FIELD_IN_CDB); 48 | } 49 | return; 50 | } 51 | 52 | logging(LOG_NORMAL, "No tests for devices that support protection information yet."); 53 | } 54 | -------------------------------------------------------------------------------- /test-tool/test_verify12_0blocks.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-test-cu.h" 25 | 26 | void 27 | test_verify12_0blocks(void) 28 | { 29 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 30 | logging(LOG_VERBOSE, "Test VERIFY12 0-blocks at LBA==0"); 31 | 32 | logging(LOG_VERBOSE, "Test VERIFY12 0-blocks one block past end-of-LUN"); 33 | VERIFY12(sd, num_blocks + 1, 0, block_size, 0, 0, 1, NULL, 34 | EXPECT_LBA_OOB); 35 | 36 | if (num_blocks - 1 < 0x80000000) { 37 | logging(LOG_VERBOSE, "Test VERIFY12 0-blocks at LBA==2^31"); 38 | VERIFY12(sd, 0x80000000, 0, block_size, 0, 0, 1, NULL, 39 | EXPECT_LBA_OOB); 40 | } 41 | 42 | logging(LOG_VERBOSE, "Test VERIFY12 0-blocks at LBA==-1"); 43 | VERIFY12(sd, -1, 0, block_size, 0, 0, 1, NULL, 44 | EXPECT_LBA_OOB); 45 | } 46 | -------------------------------------------------------------------------------- /test-tool/test_verify12_flags.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "iscsi.h" 24 | #include "scsi-lowlevel.h" 25 | #include "iscsi-support.h" 26 | #include "iscsi-test-cu.h" 27 | 28 | 29 | void 30 | test_verify12_flags(void) 31 | { 32 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 33 | logging(LOG_VERBOSE, "Test VERIFY12 flags"); 34 | 35 | READ12(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch, 36 | EXPECT_STATUS_GOOD); 37 | 38 | logging(LOG_VERBOSE, "Test VERIFY12 with BYTCHK==1"); 39 | VERIFY12(sd, 0, block_size, block_size, 0, 0, 1, scratch, 40 | EXPECT_STATUS_GOOD); 41 | } 42 | -------------------------------------------------------------------------------- /test-tool/test_verify12_vrprotect.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "iscsi.h" 24 | #include "scsi-lowlevel.h" 25 | #include "iscsi-support.h" 26 | #include "iscsi-test-cu.h" 27 | 28 | 29 | void 30 | test_verify12_vrprotect(void) 31 | { 32 | int i; 33 | 34 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 35 | logging(LOG_VERBOSE, "Test VERIFY12 with non-zero VRPROTECT"); 36 | 37 | CHECK_FOR_SBC; 38 | 39 | if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { 40 | logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); 41 | for (i = 1; i < 8; i++) { 42 | READ10(sd, NULL, 0, block_size, 43 | block_size, 0, 0, 0, 0, 0, scratch, 44 | EXPECT_STATUS_GOOD); 45 | VERIFY12(sd, 0, block_size, 46 | block_size, i, 0, 1, scratch, 47 | EXPECT_INVALID_FIELD_IN_CDB); 48 | } 49 | return; 50 | } 51 | 52 | logging(LOG_NORMAL, "No tests for devices that support protection information yet."); 53 | } 54 | -------------------------------------------------------------------------------- /test-tool/test_verify16_0blocks.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-test-cu.h" 25 | 26 | void 27 | test_verify16_0blocks(void) 28 | { 29 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 30 | logging(LOG_VERBOSE, "Test VERIFY16 0-blocks at LBA==0"); 31 | 32 | logging(LOG_VERBOSE, "Test VERIFY16 0-blocks one block past end-of-LUN"); 33 | VERIFY16(sd, num_blocks + 1, 0, block_size, 0, 0, 1, NULL, 34 | EXPECT_LBA_OOB); 35 | 36 | logging(LOG_VERBOSE, "Test VERIFY16 0-blocks at LBA==2^63"); 37 | VERIFY16(sd, 0x8000000000000000ULL, 0, block_size, 0, 0, 1, NULL, 38 | EXPECT_LBA_OOB); 39 | 40 | logging(LOG_VERBOSE, "Test VERIFY16 0-blocks at LBA==-1"); 41 | VERIFY16(sd, -1, 0, block_size, 0, 0, 1, NULL, 42 | EXPECT_LBA_OOB); 43 | } 44 | -------------------------------------------------------------------------------- /test-tool/test_verify16_flags.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "iscsi.h" 24 | #include "scsi-lowlevel.h" 25 | #include "iscsi-support.h" 26 | #include "iscsi-test-cu.h" 27 | 28 | 29 | void 30 | test_verify16_flags(void) 31 | { 32 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 33 | logging(LOG_VERBOSE, "Test VERIFY16 flags"); 34 | 35 | READ16(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch, 36 | EXPECT_STATUS_GOOD); 37 | 38 | logging(LOG_VERBOSE, "Test VERIFY16 with BYTCHK==1"); 39 | VERIFY16(sd, 0, block_size, block_size, 0, 0, 1, scratch, 40 | EXPECT_STATUS_GOOD); 41 | } 42 | -------------------------------------------------------------------------------- /test-tool/test_verify16_vrprotect.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "iscsi.h" 24 | #include "scsi-lowlevel.h" 25 | #include "iscsi-support.h" 26 | #include "iscsi-test-cu.h" 27 | 28 | 29 | void 30 | test_verify16_vrprotect(void) 31 | { 32 | int i; 33 | 34 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 35 | logging(LOG_VERBOSE, "Test VERIFY16 with non-zero VRPROTECT"); 36 | 37 | CHECK_FOR_SBC; 38 | 39 | if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { 40 | logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); 41 | for (i = 1; i < 8; i++) { 42 | READ16(sd, NULL, 0, block_size, 43 | block_size, 0, 0, 0, 0, 0, scratch, 44 | EXPECT_STATUS_GOOD); 45 | VERIFY16(sd, 0, block_size, 46 | block_size, i, 0, 1, scratch, 47 | EXPECT_INVALID_FIELD_IN_CDB); 48 | } 49 | return; 50 | } 51 | 52 | logging(LOG_NORMAL, "No tests for devices that support protection information yet."); 53 | } 54 | -------------------------------------------------------------------------------- /test-tool/test_write10_0blocks.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-test-cu.h" 25 | 26 | void 27 | test_write10_0blocks(void) 28 | { 29 | CHECK_FOR_DATALOSS; 30 | 31 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 32 | logging(LOG_VERBOSE, "Test WRITE10 0-blocks at LBA==0"); 33 | WRITE10(sd, 0, 0, block_size, 0, 0, 0, 0, 0, NULL, 34 | EXPECT_STATUS_GOOD); 35 | 36 | if (num_blocks >= 0x80000000) { 37 | CU_PASS("LUN is too big for read-beyond-eol tests with WRITE10. Skipping test.\n"); 38 | return; 39 | } 40 | 41 | logging(LOG_VERBOSE, "Test WRITE10 0-blocks one block past end-of-LUN"); 42 | WRITE10(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0, NULL, 43 | EXPECT_LBA_OOB); 44 | 45 | logging(LOG_VERBOSE, "Test WRITE10 0-blocks at LBA==2^31"); 46 | WRITE10(sd, 0x80000000, 0, block_size, 0, 0, 0, 0, 0, NULL, 47 | EXPECT_LBA_OOB); 48 | 49 | logging(LOG_VERBOSE, "Test WRITE10 0-blocks at LBA==-1"); 50 | WRITE10(sd, -1, 0, block_size, 0, 0, 0, 0, 0, NULL, 51 | EXPECT_LBA_OOB); 52 | } 53 | -------------------------------------------------------------------------------- /test-tool/test_write10_flags.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "iscsi.h" 26 | #include "scsi-lowlevel.h" 27 | #include "iscsi-test-cu.h" 28 | 29 | void 30 | test_write10_flags(void) 31 | { 32 | CHECK_FOR_DATALOSS; 33 | 34 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 35 | logging(LOG_VERBOSE, "Test WRITE10 flags"); 36 | 37 | logging(LOG_VERBOSE, "Test WRITE10 with DPO==1"); 38 | memset(scratch, 0xa6, block_size); 39 | WRITE10(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch, 40 | EXPECT_STATUS_GOOD); 41 | 42 | logging(LOG_VERBOSE, "Test WRITE10 with FUA==1 FUA_NV==0"); 43 | WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch, 44 | EXPECT_STATUS_GOOD); 45 | 46 | logging(LOG_VERBOSE, "Test WRITE10 with FUA==1 FUA_NV==1"); 47 | WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 1, 0, scratch, 48 | EXPECT_STATUS_GOOD); 49 | 50 | logging(LOG_VERBOSE, "Test WRITE10 with FUA==0 FUA_NV==1"); 51 | WRITE10(sd, 0, block_size, block_size, 0, 0, 0, 1, 0, scratch, 52 | EXPECT_STATUS_GOOD); 53 | 54 | logging(LOG_VERBOSE, "Test WRITE10 with DPO==1 FUA==1 FUA_NV==1"); 55 | WRITE10(sd, 0, block_size, block_size, 0, 1, 1, 1, 0, scratch, 56 | EXPECT_STATUS_GOOD); 57 | } 58 | -------------------------------------------------------------------------------- /test-tool/test_write10_wrprotect.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "iscsi.h" 26 | #include "scsi-lowlevel.h" 27 | #include "iscsi-test-cu.h" 28 | 29 | void 30 | test_write10_wrprotect(void) 31 | { 32 | int i; 33 | 34 | /* 35 | * Try out different non-zero values for WRPROTECT. 36 | */ 37 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 38 | logging(LOG_VERBOSE, "Test WRITE10 with non-zero WRPROTECT"); 39 | 40 | CHECK_FOR_DATALOSS; 41 | CHECK_FOR_SBC; 42 | 43 | memset(scratch, 0xa6, block_size); 44 | if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { 45 | logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); 46 | for (i = 1; i < 8; i++) { 47 | WRITE10(sd, 0, block_size, block_size, 48 | i, 0, 0, 0, 0, scratch, 49 | EXPECT_INVALID_FIELD_IN_CDB); 50 | } 51 | return; 52 | } 53 | 54 | logging(LOG_NORMAL, "No tests for devices that support protection information yet."); 55 | } 56 | -------------------------------------------------------------------------------- /test-tool/test_write12_0blocks.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-test-cu.h" 25 | 26 | void 27 | test_write12_0blocks(void) 28 | { 29 | CHECK_FOR_DATALOSS; 30 | 31 | if (num_blocks >= 0x80000000) { 32 | CU_PASS("LUN is too big for read-beyond-eol tests with WRITE12. Skipping test.\n"); 33 | return; 34 | } 35 | 36 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 37 | logging(LOG_VERBOSE, "Test WRITE12 0-blocks at LBA==0"); 38 | WRITE12(sd, 0, 0, block_size, 0, 0, 0, 0, 0, NULL, 39 | EXPECT_STATUS_GOOD); 40 | 41 | logging(LOG_VERBOSE, "Test WRITE12 0-blocks one block past end-of-LUN"); 42 | WRITE12(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0, NULL, 43 | EXPECT_LBA_OOB); 44 | 45 | logging(LOG_VERBOSE, "Test WRITE12 0-blocks at LBA==2^31"); 46 | WRITE12(sd, 0x80000000, 0, block_size, 0, 0, 0, 0, 0, NULL, 47 | EXPECT_LBA_OOB); 48 | 49 | logging(LOG_VERBOSE, "Test WRITE12 0-blocks at LBA==-1"); 50 | WRITE12(sd, -1, 0, block_size, 0, 0, 0, 0, 0, NULL, 51 | EXPECT_LBA_OOB); 52 | } 53 | -------------------------------------------------------------------------------- /test-tool/test_write12_flags.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "iscsi.h" 26 | #include "scsi-lowlevel.h" 27 | #include "iscsi-test-cu.h" 28 | 29 | void 30 | test_write12_flags(void) 31 | { 32 | CHECK_FOR_DATALOSS; 33 | 34 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 35 | logging(LOG_VERBOSE, "Test WRITE12 flags"); 36 | 37 | logging(LOG_VERBOSE, "Test WRITE12 with DPO==1"); 38 | memset(scratch, 0xa6, block_size); 39 | WRITE12(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch, 40 | EXPECT_STATUS_GOOD); 41 | 42 | logging(LOG_VERBOSE, "Test WRITE12 with FUA==1 FUA_NV==0"); 43 | WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch, 44 | EXPECT_STATUS_GOOD); 45 | 46 | logging(LOG_VERBOSE, "Test WRITE12 with FUA==1 FUA_NV==1"); 47 | WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 1, 0, scratch, 48 | EXPECT_STATUS_GOOD); 49 | 50 | logging(LOG_VERBOSE, "Test WRITE12 with FUA==0 FUA_NV==1"); 51 | WRITE12(sd, 0, block_size, block_size, 0, 0, 0, 1, 0, scratch, 52 | EXPECT_STATUS_GOOD); 53 | 54 | logging(LOG_VERBOSE, "Test WRITE12 with DPO==1 FUA==1 FUA_NV==1"); 55 | WRITE12(sd, 0, block_size, block_size, 0, 1, 1, 1, 0, scratch, 56 | EXPECT_STATUS_GOOD); 57 | } 58 | -------------------------------------------------------------------------------- /test-tool/test_write12_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "iscsi.h" 24 | #include "scsi-lowlevel.h" 25 | #include "iscsi-support.h" 26 | #include "iscsi-test-cu.h" 27 | 28 | 29 | void 30 | test_write12_simple(void) 31 | { 32 | int i; 33 | 34 | CHECK_FOR_DATALOSS; 35 | 36 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 37 | logging(LOG_VERBOSE, "Test WRITE12 of 1-256 blocks at the start of the LUN"); 38 | memset(scratch, 0xa6, 256 * block_size); 39 | for (i = 1; i <= 256; i++) { 40 | if (maximum_transfer_length && maximum_transfer_length < i) { 41 | break; 42 | } 43 | WRITE12(sd, 0, i * block_size, block_size, 44 | 0, 0, 0, 0, 0, scratch, 45 | EXPECT_STATUS_GOOD); 46 | } 47 | 48 | logging(LOG_VERBOSE, "Test WRITE12 of 1-256 blocks at the end of the LUN"); 49 | for (i = 1; i <= 256; i++) { 50 | if (maximum_transfer_length && maximum_transfer_length < i) { 51 | break; 52 | } 53 | WRITE12(sd, num_blocks - i, 54 | i * block_size, block_size, 0, 0, 0, 0, 0, scratch, 55 | EXPECT_STATUS_GOOD); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /test-tool/test_write12_wrprotect.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "iscsi.h" 26 | #include "scsi-lowlevel.h" 27 | #include "iscsi-test-cu.h" 28 | 29 | void 30 | test_write12_wrprotect(void) 31 | { 32 | int i; 33 | 34 | /* 35 | * Try out different non-zero values for WRPROTECT. 36 | */ 37 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 38 | logging(LOG_VERBOSE, "Test WRITE12 with non-zero WRPROTECT"); 39 | 40 | CHECK_FOR_DATALOSS; 41 | CHECK_FOR_SBC; 42 | 43 | memset(scratch, 0xa6, block_size); 44 | if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { 45 | logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); 46 | for (i = 1; i < 8; i++) { 47 | WRITE12(sd, 0, block_size, block_size, 48 | i, 0, 0, 0, 0, scratch, 49 | EXPECT_INVALID_FIELD_IN_CDB); 50 | } 51 | return; 52 | } 53 | 54 | logging(LOG_NORMAL, "No tests for devices that support protection information yet."); 55 | } 56 | -------------------------------------------------------------------------------- /test-tool/test_write16_0blocks.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-test-cu.h" 25 | 26 | void 27 | test_write16_0blocks(void) 28 | { 29 | CHECK_FOR_DATALOSS; 30 | CHECK_FOR_SBC; 31 | 32 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 33 | logging(LOG_VERBOSE, "Test WRITE16 0-blocks at LBA==0"); 34 | WRITE16(sd, 0, 0, block_size, 0, 0, 0, 0, 0, NULL, 35 | EXPECT_STATUS_GOOD); 36 | 37 | logging(LOG_VERBOSE, "Test WRITE16 0-blocks one block past end-of-LUN"); 38 | WRITE16(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0, NULL, 39 | EXPECT_LBA_OOB); 40 | 41 | logging(LOG_VERBOSE, "Test WRITE16 0-blocks at LBA==2^63"); 42 | WRITE16(sd, 0x8000000000000000ULL, 0, block_size, 0, 0, 0, 0, 0, NULL, 43 | EXPECT_LBA_OOB); 44 | 45 | logging(LOG_VERBOSE, "Test WRITE16 0-blocks at LBA==-1"); 46 | WRITE16(sd, -1, 0, block_size, 0, 0, 0, 0, 0, NULL, 47 | EXPECT_LBA_OOB); 48 | } 49 | -------------------------------------------------------------------------------- /test-tool/test_write16_flags.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "iscsi.h" 26 | #include "scsi-lowlevel.h" 27 | #include "iscsi-test-cu.h" 28 | 29 | void 30 | test_write16_flags(void) 31 | { 32 | CHECK_FOR_DATALOSS; 33 | CHECK_FOR_SBC; 34 | 35 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 36 | logging(LOG_VERBOSE, "Test WRITE16 flags"); 37 | 38 | logging(LOG_VERBOSE, "Test WRITE16 with DPO==1"); 39 | memset(scratch, 0xa6, block_size); 40 | WRITE16(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch, 41 | EXPECT_STATUS_GOOD); 42 | 43 | logging(LOG_VERBOSE, "Test WRITE16 with FUA==1 FUA_NV==0"); 44 | WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch, 45 | EXPECT_STATUS_GOOD); 46 | 47 | logging(LOG_VERBOSE, "Test WRITE16 with FUA==1 FUA_NV==1"); 48 | WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 1, 0, scratch, 49 | EXPECT_STATUS_GOOD); 50 | 51 | logging(LOG_VERBOSE, "Test WRITE16 with FUA==0 FUA_NV==1"); 52 | WRITE16(sd, 0, block_size, block_size, 0, 0, 0, 1, 0, scratch, 53 | EXPECT_STATUS_GOOD); 54 | 55 | logging(LOG_VERBOSE, "Test WRITE16 with DPO==1 FUA==1 FUA_NV==1"); 56 | WRITE16(sd, 0, block_size, block_size, 0, 1, 1, 1, 0, scratch, 57 | EXPECT_STATUS_GOOD); 58 | } 59 | -------------------------------------------------------------------------------- /test-tool/test_write16_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "iscsi.h" 24 | #include "scsi-lowlevel.h" 25 | #include "iscsi-support.h" 26 | #include "iscsi-test-cu.h" 27 | 28 | 29 | void 30 | test_write16_simple(void) 31 | { 32 | int i; 33 | 34 | CHECK_FOR_DATALOSS; 35 | CHECK_FOR_SBC; 36 | 37 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 38 | logging(LOG_VERBOSE, "Test WRITE16 of 1-256 blocks at the start of the LUN"); 39 | memset(scratch, 0xa6, 256 * block_size); 40 | for (i = 1; i <= 256; i++) { 41 | if (maximum_transfer_length && maximum_transfer_length < i) { 42 | break; 43 | } 44 | WRITE16(sd, 0, i * block_size, block_size, 45 | 0, 0, 0, 0, 0, scratch, 46 | EXPECT_STATUS_GOOD); 47 | } 48 | 49 | logging(LOG_VERBOSE, "Test WRITE16 of 1-256 blocks at the end of the LUN"); 50 | for (i = 1; i <= 256; i++) { 51 | if (maximum_transfer_length && maximum_transfer_length < i) { 52 | break; 53 | } 54 | WRITE16(sd, num_blocks - i, 55 | i * block_size, block_size, 0, 0, 0, 0, 0, scratch, 56 | EXPECT_STATUS_GOOD); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /test-tool/test_write16_wrprotect.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "iscsi.h" 26 | #include "scsi-lowlevel.h" 27 | #include "iscsi-test-cu.h" 28 | 29 | void 30 | test_write16_wrprotect(void) 31 | { 32 | int i; 33 | 34 | /* 35 | * Try out different non-zero values for WRPROTECT. 36 | */ 37 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 38 | logging(LOG_VERBOSE, "Test WRITE16 with non-zero WRPROTECT"); 39 | 40 | CHECK_FOR_DATALOSS; 41 | CHECK_FOR_SBC; 42 | 43 | memset(scratch, 0xa6, block_size); 44 | if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { 45 | logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); 46 | for (i = 1; i < 8; i++) { 47 | WRITE16(sd, 0, block_size, block_size, 48 | i, 0, 0, 0, 0, scratch, 49 | EXPECT_INVALID_FIELD_IN_CDB); 50 | } 51 | return; 52 | } 53 | 54 | logging(LOG_NORMAL, "No tests for devices that support protection information yet."); 55 | } 56 | -------------------------------------------------------------------------------- /test-tool/test_write_residuals.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 by Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #ifndef _ISCSI_TESTS_WRITE_RESIDUALS_H_ 19 | #define _ISCSI_TESTS_WRITE_RESIDUALS_H_ 20 | 21 | #include 22 | #include 23 | #include "scsi-lowlevel.h" 24 | 25 | struct residuals_test_data { 26 | size_t cdb_size; /* CDB size in bytes */ 27 | 28 | /* 29 | * Value of the CDB TRANSFER LENGTH field. The unit of this field is one 30 | * logical block. 31 | */ 32 | unsigned int xfer_len; 33 | 34 | unsigned int buf_len; /* Expected Data Transfer Length in bytes. */ 35 | 36 | enum scsi_residual residual_type; /* SCSI_RESIDUAL_UNDERFLOW or OVERFLOW */ 37 | 38 | size_t residual; /* Number of residual bytes */ 39 | 40 | const char *description; /* Test case description */ 41 | }; 42 | 43 | struct task_status { 44 | int status; 45 | struct scsi_sense sense; 46 | }; 47 | 48 | void write_residuals_test(const struct residuals_test_data *tdata, 49 | bool *command_is_implemented); 50 | 51 | #endif /* _ISCSI_TESTS_WRITE_RESIDUALS_H_ */ 52 | -------------------------------------------------------------------------------- /test-tool/test_writeatomic16_0blocks.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-test-cu.h" 25 | 26 | void 27 | test_writeatomic16_0blocks(void) 28 | { 29 | int align; 30 | 31 | CHECK_FOR_DATALOSS; 32 | CHECK_FOR_SBC; 33 | 34 | if (!inq_bl) { 35 | CU_PASS("BlockLimits VPD is not available. Skipping test.\n"); 36 | return; 37 | } 38 | 39 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 40 | 41 | align = inq_bl->atomic_align ? inq_bl->atomic_align : 1; 42 | logging(LOG_VERBOSE, "Test WRITEATOMIC16 0-blocks at LBA==0"); 43 | WRITEATOMIC16(sd, 0, 0, block_size, 0, 0, 0, 0, NULL, 44 | EXPECT_STATUS_GOOD); 45 | 46 | logging(LOG_VERBOSE, "Test WRITEATOMIC16 0-blocks one alignment past end-of-LUN"); 47 | WRITEATOMIC16(sd, num_blocks + align, 0, block_size, 0, 0, 0, 0, NULL, 48 | EXPECT_LBA_OOB); 49 | 50 | logging(LOG_VERBOSE, "Test WRITEATOMIC16 0-blocks at LBA==2^63"); 51 | WRITEATOMIC16(sd, 0x8000000000000000ULL, 0, 52 | block_size, 0, 0, 0, 0, NULL, 53 | EXPECT_LBA_OOB); 54 | 55 | logging(LOG_VERBOSE, "Test WRITEATOMIC16 0-blocks at LBA==-"); 56 | WRITEATOMIC16(sd, -align, 0, block_size, 0, 0, 0, 0, NULL, 57 | EXPECT_LBA_OOB); 58 | } 59 | -------------------------------------------------------------------------------- /test-tool/test_writesame10_invalid_dataout_size.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-support.h" 25 | #include "iscsi-test-cu.h" 26 | 27 | 28 | void 29 | test_writesame10_invalid_dataout_size(void) 30 | { 31 | CHECK_FOR_DATALOSS; 32 | CHECK_FOR_THIN_PROVISIONING; 33 | CHECK_FOR_LBPWS10; 34 | CHECK_FOR_LBPPB_GT_1; 35 | CHECK_FOR_SBC; 36 | 37 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 38 | logging(LOG_VERBOSE, "Test that WRITESAME10 fails for invalid " 39 | "(too small/too large) DataOut sizes."); 40 | memset(scratch, 0xa6, block_size); 41 | 42 | logging(LOG_VERBOSE, "Check too small DataOut"); 43 | logging(LOG_VERBOSE, "Unmap with DataOut==%zd (block_size==%zd)", 44 | block_size / 2, block_size); 45 | WRITESAME10(sd, 0, block_size / 2, 1, 0, 1, 0, 0, scratch, 46 | EXPECT_STATUS_GENERIC_BAD); 47 | 48 | logging(LOG_VERBOSE, "Check too large DataOut"); 49 | logging(LOG_VERBOSE, "Unmap with DataOut==%zd (block_size==%zd)", 50 | block_size * 2, block_size); 51 | WRITESAME10(sd, 0, block_size * 2, 1, 0, 1, 0, 0, scratch, 52 | EXPECT_STATUS_GENERIC_BAD); 53 | } 54 | -------------------------------------------------------------------------------- /test-tool/test_writesame10_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "iscsi.h" 24 | #include "scsi-lowlevel.h" 25 | #include "iscsi-support.h" 26 | #include "iscsi-test-cu.h" 27 | 28 | 29 | void 30 | test_writesame10_simple(void) 31 | { 32 | int i; 33 | 34 | CHECK_FOR_DATALOSS; 35 | CHECK_FOR_SBC; 36 | 37 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 38 | logging(LOG_VERBOSE, "Test WRITESAME10 of 1-256 blocks at the start of the LUN"); 39 | 40 | memset(scratch, 0, block_size); 41 | for (i = 1; i <= 256; i++) { 42 | WRITESAME10(sd, 0, block_size, i, 0, 0, 0, 0, scratch, 43 | EXPECT_STATUS_GOOD); 44 | } 45 | 46 | logging(LOG_VERBOSE, "Test WRITESAME10 of 1-256 blocks at the end of the LUN"); 47 | for (i = 1; i <= 256; i++) { 48 | WRITESAME10(sd, num_blocks - i, 49 | block_size, i, 0, 0, 0, 0, scratch, 50 | EXPECT_STATUS_GOOD); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /test-tool/test_writesame10_unmap_unaligned.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-support.h" 25 | #include "iscsi-test-cu.h" 26 | 27 | 28 | void 29 | test_writesame10_unmap_unaligned(void) 30 | { 31 | int i; 32 | 33 | CHECK_FOR_DATALOSS; 34 | CHECK_FOR_THIN_PROVISIONING; 35 | CHECK_FOR_LBPWS10; 36 | CHECK_FOR_LBPPB_GT_1; 37 | CHECK_FOR_SBC; 38 | 39 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 40 | logging(LOG_VERBOSE, "Test that unaligned WRITESAME10 Unmap succeeds. LBPPB==%d", lbppb); 41 | memset(scratch, 0xa6, block_size); 42 | for (i = 1; i < lbppb; i++) { 43 | logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10 at LBA:%d", lbppb - i, i); 44 | WRITESAME10(sd, i, block_size, lbppb - i, 0, 1, 0, 0, scratch, 45 | EXPECT_STATUS_GOOD); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /test-tool/test_writesame10_wrprotect.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "iscsi.h" 26 | #include "scsi-lowlevel.h" 27 | #include "iscsi-test-cu.h" 28 | 29 | void 30 | test_writesame10_wrprotect(void) 31 | { 32 | int i; 33 | 34 | /* 35 | * Try out different non-zero values for WRPROTECT. 36 | */ 37 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 38 | logging(LOG_VERBOSE, "Test WRITESAME10 with non-zero WRPROTECT"); 39 | 40 | CHECK_FOR_DATALOSS; 41 | CHECK_FOR_SBC; 42 | 43 | memset(scratch, 0, block_size); 44 | if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { 45 | logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); 46 | for (i = 1; i < 8; i++) { 47 | WRITESAME10(sd, 0, block_size, 1, 0, 0, i, 0, scratch, 48 | EXPECT_INVALID_FIELD_IN_CDB); 49 | } 50 | return; 51 | } 52 | 53 | logging(LOG_NORMAL, "No tests for devices that support protection information yet."); 54 | } 55 | -------------------------------------------------------------------------------- /test-tool/test_writesame16_invalid_dataout_size.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-support.h" 25 | #include "iscsi-test-cu.h" 26 | 27 | 28 | void 29 | test_writesame16_invalid_dataout_size(void) 30 | { 31 | CHECK_FOR_DATALOSS; 32 | CHECK_FOR_THIN_PROVISIONING; 33 | CHECK_FOR_LBPWS10; 34 | CHECK_FOR_LBPPB_GT_1; 35 | CHECK_FOR_SBC; 36 | 37 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 38 | logging(LOG_VERBOSE, "Test that WRITESAME10 fails for invalid " 39 | "(too small/too large) DataOut sizes."); 40 | memset(scratch, 0xa6, block_size); 41 | 42 | logging(LOG_VERBOSE, "Check too small DataOut"); 43 | logging(LOG_VERBOSE, "Unmap with DataOut==%zd (block_size==%zd)", 44 | block_size / 2, block_size); 45 | WRITESAME16(sd, 0, block_size / 2, 1, 0, 1, 0, 0, scratch, 46 | EXPECT_STATUS_GENERIC_BAD); 47 | 48 | logging(LOG_VERBOSE, "Check too large DataOut"); 49 | logging(LOG_VERBOSE, "Unmap with DataOut==%zd (block_size==%zd)", 50 | block_size * 2, block_size); 51 | WRITESAME16(sd, 0, block_size * 2, 1, 0, 1, 0, 0, scratch, 52 | EXPECT_STATUS_GENERIC_BAD); 53 | } 54 | -------------------------------------------------------------------------------- /test-tool/test_writesame16_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "iscsi.h" 24 | #include "scsi-lowlevel.h" 25 | #include "iscsi-support.h" 26 | #include "iscsi-test-cu.h" 27 | 28 | 29 | void 30 | test_writesame16_simple(void) 31 | { 32 | int i; 33 | 34 | CHECK_FOR_DATALOSS; 35 | CHECK_FOR_SBC; 36 | 37 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 38 | logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the start of the LUN"); 39 | 40 | memset(scratch, 0, block_size); 41 | for (i = 1; i <= 256; i++) { 42 | WRITESAME16(sd, 0, block_size, i, 0, 0, 0, 0, scratch, 43 | EXPECT_STATUS_GOOD); 44 | } 45 | 46 | logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the end of the LUN"); 47 | for (i = 1; i <= 256; i++) { 48 | WRITESAME16(sd, num_blocks - i, 49 | block_size, i, 0, 0, 0, 0, scratch, 50 | EXPECT_STATUS_GOOD); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /test-tool/test_writesame16_unmap_unaligned.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-support.h" 25 | #include "iscsi-test-cu.h" 26 | 27 | 28 | void 29 | test_writesame16_unmap_unaligned(void) 30 | { 31 | int i; 32 | 33 | CHECK_FOR_DATALOSS; 34 | CHECK_FOR_THIN_PROVISIONING; 35 | CHECK_FOR_LBPWS; 36 | CHECK_FOR_LBPPB_GT_1; 37 | CHECK_FOR_SBC; 38 | 39 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 40 | logging(LOG_VERBOSE, "Test that unaligned WRITESAME16 Unmap succeeds. LBPPB==%d", lbppb); 41 | 42 | for (i = 1; i < lbppb; i++) { 43 | logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16 at LBA:%d", lbppb - i, i); 44 | WRITESAME16(sd, i, 0, lbppb - i, 0, 1, 0, 0, NULL, 45 | EXPECT_STATUS_GOOD); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /test-tool/test_writesame16_wrprotect.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "iscsi.h" 26 | #include "scsi-lowlevel.h" 27 | #include "iscsi-test-cu.h" 28 | 29 | void 30 | test_writesame16_wrprotect(void) 31 | { 32 | int i; 33 | 34 | /* 35 | * Try out different non-zero values for WRPROTECT. 36 | */ 37 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 38 | logging(LOG_VERBOSE, "Test WRITESAME16 with non-zero WRPROTECT"); 39 | 40 | CHECK_FOR_DATALOSS; 41 | CHECK_FOR_SBC; 42 | 43 | memset(scratch, 0, block_size); 44 | if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { 45 | logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); 46 | for (i = 1; i < 8; i++) { 47 | WRITESAME16(sd, 0, block_size, 1, 0, 0, i, 0, scratch, 48 | EXPECT_INVALID_FIELD_IN_CDB); 49 | } 50 | return; 51 | } 52 | 53 | logging(LOG_NORMAL, "No tests for devices that support protection information yet."); 54 | } 55 | -------------------------------------------------------------------------------- /test-tool/test_writeverify10_0blocks.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-test-cu.h" 25 | 26 | void 27 | test_writeverify10_0blocks(void) 28 | { 29 | CHECK_FOR_DATALOSS; 30 | 31 | if (num_blocks >= 0x80000000) { 32 | CU_PASS("LUN is too big for read-beyond-eol tests with WRITEVERIFY10. Skipping test.\n"); 33 | return; 34 | } 35 | 36 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 37 | logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks at LBA==0"); 38 | WRITEVERIFY10(sd, 0, 0, block_size, 0, 0, 0, 0, NULL, 39 | EXPECT_STATUS_GOOD); 40 | 41 | logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks one block past end-of-LUN"); 42 | WRITEVERIFY10(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, NULL, 43 | EXPECT_LBA_OOB); 44 | 45 | logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks at LBA==2^31"); 46 | WRITEVERIFY10(sd, 0x80000000, 0, block_size, 0, 0, 0, 0, NULL, 47 | EXPECT_LBA_OOB); 48 | 49 | logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks at LBA==-1"); 50 | WRITEVERIFY10(sd, -1, 0, block_size, 0, 0, 0, 0, NULL, 51 | EXPECT_LBA_OOB); 52 | } 53 | -------------------------------------------------------------------------------- /test-tool/test_writeverify10_flags.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "iscsi.h" 26 | #include "scsi-lowlevel.h" 27 | #include "iscsi-test-cu.h" 28 | 29 | void 30 | test_writeverify10_flags(void) 31 | { 32 | CHECK_FOR_DATALOSS; 33 | 34 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 35 | logging(LOG_VERBOSE, "Test WRITEVERIFY10 flags"); 36 | 37 | 38 | logging(LOG_VERBOSE, "Test WRITEVERIFY10 with BYTCHK==1"); 39 | memset(scratch, 0xa6, block_size); 40 | WRITEVERIFY10(sd, 0, block_size, block_size, 0, 0, 1, 0, scratch, 41 | EXPECT_STATUS_GOOD); 42 | } 43 | -------------------------------------------------------------------------------- /test-tool/test_writeverify10_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "iscsi.h" 24 | #include "scsi-lowlevel.h" 25 | #include "iscsi-support.h" 26 | #include "iscsi-test-cu.h" 27 | 28 | 29 | void 30 | test_writeverify10_simple(void) 31 | { 32 | int i; 33 | 34 | CHECK_FOR_DATALOSS; 35 | 36 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 37 | logging(LOG_VERBOSE, "Test WRITEVERIFY10 of 1-256 blocks at the start of the LUN"); 38 | memset(scratch, 0xa6, 256 * block_size); 39 | for (i = 1; i <= 256; i++) { 40 | if (maximum_transfer_length && maximum_transfer_length < i) { 41 | break; 42 | } 43 | WRITEVERIFY10(sd, 0, i * block_size, 44 | block_size, 0, 0, 1, 0, scratch, 45 | EXPECT_STATUS_GOOD); 46 | } 47 | 48 | logging(LOG_VERBOSE, "Test WRITEVERIFY10 of 1-256 blocks at the end of the LUN"); 49 | for (i = 1; i <= 256; i++) { 50 | if (maximum_transfer_length && maximum_transfer_length < i) { 51 | break; 52 | } 53 | WRITEVERIFY10(sd, num_blocks - i, 54 | i * block_size, block_size, 0, 0, 1, 0, scratch, 55 | EXPECT_STATUS_GOOD); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /test-tool/test_writeverify10_wrprotect.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "iscsi.h" 26 | #include "scsi-lowlevel.h" 27 | #include "iscsi-test-cu.h" 28 | 29 | void 30 | test_writeverify10_wrprotect(void) 31 | { 32 | int i; 33 | 34 | /* 35 | * Try out different non-zero values for WRPROTECT. 36 | */ 37 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 38 | logging(LOG_VERBOSE, "Test WRITEVERIFY10 with non-zero WRPROTECT"); 39 | 40 | CHECK_FOR_DATALOSS; 41 | CHECK_FOR_SBC; 42 | 43 | memset(scratch, 0xa6, block_size); 44 | if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { 45 | logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); 46 | for (i = 1; i < 8; i++) { 47 | WRITEVERIFY10(sd, 0, block_size, block_size, 48 | i, 0, 1, 0, scratch, 49 | EXPECT_INVALID_FIELD_IN_CDB); 50 | } 51 | return; 52 | } 53 | 54 | logging(LOG_NORMAL, "No tests for devices that support protection information yet."); 55 | } 56 | -------------------------------------------------------------------------------- /test-tool/test_writeverify12_0blocks.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-test-cu.h" 25 | 26 | void 27 | test_writeverify12_0blocks(void) 28 | { 29 | CHECK_FOR_DATALOSS; 30 | 31 | if (num_blocks >= 0x80000000) { 32 | CU_PASS("LUN is too big for read-beyond-eol tests with WRITEVERIFY12. Skipping test.\n"); 33 | return; 34 | } 35 | 36 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 37 | logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks at LBA==0"); 38 | WRITEVERIFY12(sd, 0, 0, block_size, 0, 0, 0, 0, NULL, 39 | EXPECT_STATUS_GOOD); 40 | 41 | logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks one block past end-of-LUN"); 42 | WRITEVERIFY12(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, NULL, 43 | EXPECT_LBA_OOB); 44 | 45 | logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks at LBA==2^31"); 46 | WRITEVERIFY12(sd, 0x80000000, 0, block_size, 0, 0, 0, 0, NULL, 47 | EXPECT_LBA_OOB); 48 | 49 | logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks at LBA==-1"); 50 | WRITEVERIFY12(sd, -1, 0, block_size, 0, 0, 0, 0, NULL, 51 | EXPECT_LBA_OOB); 52 | } 53 | -------------------------------------------------------------------------------- /test-tool/test_writeverify12_flags.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "iscsi.h" 26 | #include "scsi-lowlevel.h" 27 | #include "iscsi-test-cu.h" 28 | 29 | void 30 | test_writeverify12_flags(void) 31 | { 32 | CHECK_FOR_DATALOSS; 33 | 34 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 35 | logging(LOG_VERBOSE, "Test WRITEVERIFY12 flags"); 36 | 37 | 38 | logging(LOG_VERBOSE, "Test WRITEVERIFY12 with BYTCHK==1"); 39 | memset(scratch, 0xa6, block_size); 40 | WRITEVERIFY12(sd, 0, block_size, block_size, 0, 0, 1, 0, scratch, 41 | EXPECT_STATUS_GOOD); 42 | } 43 | -------------------------------------------------------------------------------- /test-tool/test_writeverify12_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "iscsi.h" 24 | #include "scsi-lowlevel.h" 25 | #include "iscsi-support.h" 26 | #include "iscsi-test-cu.h" 27 | 28 | 29 | void 30 | test_writeverify12_simple(void) 31 | { 32 | int i; 33 | 34 | CHECK_FOR_DATALOSS; 35 | 36 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 37 | logging(LOG_VERBOSE, "Test WRITEVERIFY12 of 1-256 blocks at the start of the LUN"); 38 | memset(scratch, 0xa6, 256 * block_size); 39 | for (i = 1; i <= 256; i++) { 40 | if (maximum_transfer_length && maximum_transfer_length < i) { 41 | break; 42 | } 43 | WRITEVERIFY12(sd, 0, i * block_size, 44 | block_size, 0, 0, 1, 0, scratch, 45 | EXPECT_STATUS_GOOD); 46 | } 47 | 48 | logging(LOG_VERBOSE, "Test WRITE12 of 1-256 blocks at the end of the LUN"); 49 | for (i = 1; i <= 256; i++) { 50 | if (maximum_transfer_length && maximum_transfer_length < i) { 51 | break; 52 | } 53 | WRITEVERIFY12(sd, num_blocks - i, 54 | i * block_size, block_size, 0, 0, 1, 0, scratch, 55 | EXPECT_STATUS_GOOD); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /test-tool/test_writeverify12_wrprotect.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "iscsi.h" 26 | #include "scsi-lowlevel.h" 27 | #include "iscsi-test-cu.h" 28 | 29 | void 30 | test_writeverify12_wrprotect(void) 31 | { 32 | int i; 33 | 34 | /* 35 | * Try out different non-zero values for WRPROTECT. 36 | */ 37 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 38 | logging(LOG_VERBOSE, "Test WRITEVERIFY12 with non-zero WRPROTECT"); 39 | 40 | CHECK_FOR_DATALOSS; 41 | CHECK_FOR_SBC; 42 | 43 | memset(scratch, 0xa6, block_size); 44 | if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { 45 | logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); 46 | for (i = 1; i < 8; i++) { 47 | WRITEVERIFY12(sd, 0, block_size, block_size, 48 | i, 0, 1, 0, scratch, 49 | EXPECT_INVALID_FIELD_IN_CDB); 50 | } 51 | return; 52 | } 53 | 54 | logging(LOG_NORMAL, "No tests for devices that support protection information yet."); 55 | } 56 | -------------------------------------------------------------------------------- /test-tool/test_writeverify16_0blocks.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "iscsi.h" 23 | #include "scsi-lowlevel.h" 24 | #include "iscsi-test-cu.h" 25 | 26 | void 27 | test_writeverify16_0blocks(void) 28 | { 29 | CHECK_FOR_DATALOSS; 30 | CHECK_FOR_SBC; 31 | 32 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 33 | logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks at LBA==0"); 34 | WRITEVERIFY16(sd, 0, 0, block_size, 0, 0, 0, 0, NULL, 35 | EXPECT_STATUS_GOOD); 36 | 37 | logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks one block past end-of-LUN"); 38 | WRITEVERIFY16(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, NULL, 39 | EXPECT_LBA_OOB); 40 | 41 | logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks at LBA==2^63"); 42 | WRITEVERIFY16(sd, 0x8000000000000000ULL, 43 | 0, block_size, 0, 0, 0, 0, NULL, 44 | EXPECT_LBA_OOB); 45 | 46 | logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks at LBA==-1"); 47 | WRITEVERIFY16(sd, -1, 0, block_size, 0, 0, 0, 0, NULL, 48 | EXPECT_LBA_OOB); 49 | } 50 | -------------------------------------------------------------------------------- /test-tool/test_writeverify16_flags.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "iscsi.h" 26 | #include "scsi-lowlevel.h" 27 | #include "iscsi-test-cu.h" 28 | 29 | void 30 | test_writeverify16_flags(void) 31 | { 32 | CHECK_FOR_DATALOSS; 33 | 34 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 35 | logging(LOG_VERBOSE, "Test WRITEVERIFY16 flags"); 36 | 37 | 38 | logging(LOG_VERBOSE, "Test WRITEVERIFY16 with BYTCHK==1"); 39 | memset(scratch, 0xa6, block_size); 40 | WRITEVERIFY16(sd, 0, block_size, block_size, 0, 0, 1, 0, scratch, 41 | EXPECT_STATUS_GOOD); 42 | } 43 | -------------------------------------------------------------------------------- /test-tool/test_writeverify16_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "iscsi.h" 24 | #include "scsi-lowlevel.h" 25 | #include "iscsi-support.h" 26 | #include "iscsi-test-cu.h" 27 | 28 | 29 | void 30 | test_writeverify16_simple(void) 31 | { 32 | int i; 33 | 34 | CHECK_FOR_DATALOSS; 35 | CHECK_FOR_SBC; 36 | 37 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 38 | logging(LOG_VERBOSE, "Test WRITEVERIFY16 of 1-256 blocks at the start of the LUN"); 39 | memset(scratch, 0xa6, 256 * block_size); 40 | for (i = 1; i <= 256; i++) { 41 | if (maximum_transfer_length && maximum_transfer_length < i) { 42 | break; 43 | } 44 | WRITEVERIFY16(sd, 0, i * block_size, 45 | block_size, 0, 0, 1, 0, scratch, 46 | EXPECT_STATUS_GOOD); 47 | } 48 | 49 | logging(LOG_VERBOSE, "Test WRITEVERIFY16 of 1-256 blocks at the end of the LUN"); 50 | for (i = 1; i <= 256; i++) { 51 | if (maximum_transfer_length && maximum_transfer_length < i) { 52 | break; 53 | } 54 | WRITEVERIFY16(sd, num_blocks - i, 55 | i * block_size, block_size, 0, 0, 1, 0, scratch, 56 | EXPECT_STATUS_GOOD); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /test-tool/test_writeverify16_wrprotect.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Ronnie Sahlberg 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "iscsi.h" 26 | #include "scsi-lowlevel.h" 27 | #include "iscsi-test-cu.h" 28 | 29 | 30 | void 31 | test_writeverify16_wrprotect(void) 32 | { 33 | int i; 34 | 35 | /* 36 | * Try out different non-zero values for WRPROTECT. 37 | */ 38 | logging(LOG_VERBOSE, LOG_BLANK_LINE); 39 | logging(LOG_VERBOSE, "Test WRITEVERIFY16 with non-zero WRPROTECT"); 40 | 41 | CHECK_FOR_DATALOSS; 42 | CHECK_FOR_SBC; 43 | 44 | memset(scratch, 0xa6, block_size); 45 | if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { 46 | logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); 47 | for (i = 1; i < 8; i++) { 48 | WRITEVERIFY16(sd, 0, block_size, block_size, 49 | i, 0, 0, 0, scratch, 50 | EXPECT_INVALID_FIELD_IN_CDB); 51 | } 52 | return; 53 | } 54 | 55 | logging(LOG_NORMAL, "No tests for devices that support protection information yet."); 56 | } 57 | -------------------------------------------------------------------------------- /tests/.gitignore: -------------------------------------------------------------------------------- 1 | /prog_header_digest 2 | /prog_noop_reply 3 | /prog_read_all_pdus 4 | /prog_readwrite_iov 5 | /prog_reconnect 6 | /prog_reconnect_timeout 7 | /prog_timeout 8 | -------------------------------------------------------------------------------- /tests/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I${srcdir}/../include -I${srcdir}/../win32 2 | AM_CFLAGS = $(WARN_CFLAGS) 3 | AM_LDFLAGS = -no-undefined 4 | LIBS = ../lib/libiscsi.la 5 | 6 | noinst_PROGRAMS = prog_reconnect prog_reconnect_timeout prog_noop_reply \ 7 | prog_readwrite_iov prog_timeout prog_read_all_pdus \ 8 | prog_header_digest 9 | 10 | T = `ls test_*.sh` 11 | 12 | test: $(noinst_PROGRAMS) 13 | for TEST in $(T); do \ 14 | echo "Running $$TEST"; \ 15 | echo "--------------"; \ 16 | sh $$TEST || exit 1; \ 17 | echo "--------------"; \ 18 | echo; \ 19 | done 20 | -------------------------------------------------------------------------------- /tests/README: -------------------------------------------------------------------------------- 1 | The tests require that TGTD version 1.0.58 or later is installed. 2 | 3 | To run the tests: 4 | make test -------------------------------------------------------------------------------- /tests/test_0100_login.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "Login tests" 6 | 7 | start_target 8 | create_lun 9 | 10 | echo -n "Test logging in to target ... " 11 | ../utils/iscsi-inq -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_lun 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_0200_discovery.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "Discovery tests" 6 | 7 | start_target 8 | create_lun 9 | 10 | TEST_TMP=${0}.tmp 11 | echo -n "Test discovery ... " 12 | ../utils/iscsi-ls -i ${IQNINITIATOR} iscsi://${TGTPORTAL} > ${TEST_TMP} && 13 | grep ${IQNTARGET} ${TEST_TMP} > /dev/null || failure 14 | success 15 | 16 | 17 | shutdown_target 18 | delete_lun 19 | 20 | exit 0 21 | -------------------------------------------------------------------------------- /tests/test_0300_nop_reply.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "NOP reply tests" 6 | 7 | start_target "nop_interval=1,nop_count=3" 8 | create_lun 9 | 10 | echo -n "Test that we reply to target initiated NOPs correctly ... " 11 | ./prog_noop_reply -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_lun 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_0400_readwrite_iow.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "Test Read/Write using iovectors" 6 | 7 | start_target 8 | create_lun 9 | 10 | echo -n "Test read/write using iovectors ... " 11 | ./prog_readwrite_iov -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 || failure 12 | success 13 | 14 | shutdown_target 15 | delete_lun 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_0410_read_all_pdus.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "Test that a single call to iscsi_service will process all queued PDUs" 6 | 7 | start_target 8 | create_lun 9 | 10 | echo -n "Test reading all queued PDUs in a single iscsi_service() call ... " 11 | ./prog_read_all_pdus -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 || failure 12 | success 13 | 14 | shutdown_target 15 | delete_lun 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_0500_header_digest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "Header Digest tests" 6 | 7 | start_target "nop_interval=1,nop_count=3" 8 | enable_header_digest 9 | create_lun 10 | 11 | echo -n "Test that we can connect to a target requiring Header Digest ..." 12 | ./prog_header_digest -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 > /dev/null || failure 13 | success 14 | 15 | shutdown_target 16 | delete_lun 17 | 18 | exit 0 19 | -------------------------------------------------------------------------------- /tests/test_0600_ipv6.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "IPv6 tests" 6 | 7 | start_target "nop_interval=1,nop_count=3,portal=[::1]:3269" 8 | create_lun 9 | 10 | echo -n "Test that we can connect to an IPv6 target ..." 11 | ../utils/iscsi-inq -i ${IQNINITIATOR} iscsi://[::1]:3269/${IQNTARGET}/1 > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_lun 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_2000_reconnect.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "Basic Reconnect test" 6 | 7 | start_target 8 | create_lun 9 | 10 | echo -n "Test reading from the LUN when a reconnect happens ... " 11 | ./prog_reconnect -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_lun 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_2001_reconnect_timeout.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "Basic Reconnect test" 6 | 7 | start_target 8 | create_lun 9 | 10 | echo -n "Test iscsi_which_events return 0 on reconnect failure ... " 11 | ./prog_reconnect_timeout -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 || failure 12 | success 13 | 14 | shutdown_target 15 | delete_lun 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_2100_timeout.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "Basic iSCSI Timeout test" 6 | 7 | start_target 8 | create_lun 9 | 10 | echo -n "Test that timeouts trigger when we get no reply to an iSCSI PDU..." 11 | ./prog_timeout -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 || failure 12 | success 13 | 14 | shutdown_target 15 | delete_lun 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9000_compareandwrite.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu CompareAndWrite test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.CompareAndWrite ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.CompareAndWrite.* --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9001_extendedcopy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu ExtendedCopy test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.ExtendedCopy ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.ExtendedCopy.* --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9002_getlbatatus.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu GetLBAStatus test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.GetLBAStatus ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.GetLBAStatus.Simple --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9003_inquiry.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu Inquiry test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.Inquiry ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.Inquiry --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9004_modesense6.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu ModeSense6 test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.ModeSense6 ... " 11 | 12 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.ModeSense6 --dataloss > /dev/null || failure 13 | success 14 | 15 | shutdown_target 16 | delete_disk_lun 1 17 | 18 | exit 0 19 | -------------------------------------------------------------------------------- /tests/test_9005_orwrite.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu OrWrite test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.OrWrite ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.OrWrite.* --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9006_prefetch10.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu Prefetch10 test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.Prefetch10 ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.Prefetch10.* --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9007_prefetch16.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu Prefetch16 test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.Prefetch16 ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.Prefetch16 --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9008_prinreadkeys.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu PrinReadKeys test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.PrinReadKeys ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.PrinReadKeys --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9009_read6.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu Read6 test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.Read6 ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.Read6 --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9010_read10.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu Read10 test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.Read10 ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.Read10 --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9011_read12.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu Read12 test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.Read12 ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.Read12 --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9012_read16.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu Read16 test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.Read16 ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.Read16 --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9013_verify10.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu Verify10 test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.Verify10 ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.Verify10 --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9014_verify12.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu Verify12 test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.Verify12 ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.Verify12 --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9015_verify16.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu Verify16 test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.Verify16 ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.Verify16 --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9016_write10.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu Write10 test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.Write10 ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.Write10 --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9017_write12.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu Write12 test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.Write12 ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.Write12 --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9018_write16.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu Write16 test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.Write16 ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.Write16 --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9019_writeverify10.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu WriteVerify16 test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.WriteVerify16 ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.WriteVerify16 --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9020_writeverify12.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu WriteVerify12 test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.WriteVerify12 ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.WriteVerify12 --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9021_writeverify16.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu WriteVerify16 test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.WriteVerify16 ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.WriteVerify16 --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9022_testunitready.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu TestUnitReady test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.TestUnitReady ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.TestUnitReady --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9023_readcapacity10.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu ReadCapacity10 test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.ReadCapacity10 ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.ReadCapacity10 --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9024_readcapacity16.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu ReadCapacity16 test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.ReadCapacity16 ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.ReadCapacity16 --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9025_receivecopyresults.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu ReceiveCopyResults test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.ReceiveCopyResults ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.ReceiveCopyResults --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9026_reportsupportedopcodes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu ReportSupportedOpcodes test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.ReportSupportedOpcodes ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.ReportSupportedOpcodes --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9027_unmap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu Unmap test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.Unmap ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.Unmap --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9028_readdefectdata10.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu ReadDefectData10 test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.ReadDefectData10 ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.ReadDefectData10 --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9029_readdefectdata12.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu ReadDefectData12 test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.ReadDefectData12 ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.ReadDefectData12 --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9030_prinreportcapabilities.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu PrinReportCapabilities test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.PrinReportCapabilities ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.PrinReportCapabilities --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9031_proutregister.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu ProutRegister test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.ProutRegister ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.ProutRegister --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9032_proutclear.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu ProutClear test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.ProutClear ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.ProutClear --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9033_proutpreempt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu ProutPreempt test" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.ProutPreempt ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.ProutPreempt --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9034_startstopunit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu StartStopUnit test for fixed media" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | 10 | echo -n "SCSI.StartStopUnit ... " 11 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.StartStopUnit --dataloss > /dev/null || failure 12 | success 13 | 14 | shutdown_target 15 | delete_disk_lun 1 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /tests/test_9035_startstopunit_removable.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./functions.sh 4 | 5 | echo "iscsi-test-cu StartStopUnit test for removable media" 6 | 7 | start_target 8 | create_disk_lun 1 100M 9 | set_lun_removable 1 10 | 11 | echo -n "SCSI.StartStopUnit ... " 12 | ../test-tool/iscsi-test-cu -i ${IQNINITIATOR} iscsi://${TGTPORTAL}/${IQNTARGET}/1 -t SCSI.StartStopUnit --dataloss > /dev/null || failure 13 | success 14 | 15 | shutdown_target 16 | delete_disk_lun 1 17 | 18 | exit 0 19 | -------------------------------------------------------------------------------- /utils/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I${srcdir}/../include -I${srcdir}/../win32 2 | AM_CFLAGS = $(WARN_CFLAGS) 3 | AM_LDFLAGS = -no-undefined 4 | LIBS = ../lib/libiscsi.la 5 | 6 | bin_PROGRAMS = iscsi-inq iscsi-ls iscsi-swp iscsi-pr iscsi-discard iscsi-md5sum 7 | if !TARGET_OS_IS_WIN32 8 | bin_PROGRAMS += iscsi-perf iscsi-readcapacity16 9 | endif 10 | -------------------------------------------------------------------------------- /win32/iscsi-ls/iscsi-ls.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {38246570-1DA0-489E-920A-20A22AAAB787} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | 10 | 11 | Source Files 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /win32/libiscsi/libiscsi.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual C++ Express 2010 4 | Project("{07C74339-C53E-4C5C-B9A5-2AA95ED03B2A}") = "libiscsi", "libiscsi.vcxproj", "{A3B13826-6DEF-4C25-A790-A16B37804064}" 5 | EndProject 6 | Project("{07C74339-C53E-4C5C-B9A5-2AA95ED03B2A}") = "iscsi-ls", "..\iscsi-ls\iscsi-ls.vcxproj", "{C003740B-3E9C-458B-9596-DE4330D8A0BA}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Debug|x64 = Debug|x64 12 | Release|Win32 = Release|Win32 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {A3B13826-6DEF-4C25-A790-A16B37804064}.Debug|Win32.ActiveCfg = Debug|Win32 17 | {A3B13826-6DEF-4C25-A790-A16B37804064}.Debug|Win32.Build.0 = Debug|Win32 18 | {A3B13826-6DEF-4C25-A790-A16B37804064}.Debug|x64.ActiveCfg = Debug|x64 19 | {A3B13826-6DEF-4C25-A790-A16B37804064}.Debug|x64.Build.0 = Debug|x64 20 | {A3B13826-6DEF-4C25-A790-A16B37804064}.Release|Win32.ActiveCfg = Release|Win32 21 | {A3B13826-6DEF-4C25-A790-A16B37804064}.Release|Win32.Build.0 = Release|Win32 22 | {A3B13826-6DEF-4C25-A790-A16B37804064}.Release|x64.ActiveCfg = Release|x64 23 | {A3B13826-6DEF-4C25-A790-A16B37804064}.Release|x64.Build.0 = Release|x64 24 | {C003740B-3E9C-458B-9596-DE4330D8A0BA}.Debug|Win32.ActiveCfg = Debug|Win32 25 | {C003740B-3E9C-458B-9596-DE4330D8A0BA}.Debug|Win32.Build.0 = Debug|Win32 26 | {C003740B-3E9C-458B-9596-DE4330D8A0BA}.Debug|x64.ActiveCfg = Debug|x64 27 | {C003740B-3E9C-458B-9596-DE4330D8A0BA}.Debug|x64.Build.0 = Debug|x64 28 | {C003740B-3E9C-458B-9596-DE4330D8A0BA}.Release|Win32.ActiveCfg = Release|Win32 29 | {C003740B-3E9C-458B-9596-DE4330D8A0BA}.Release|Win32.Build.0 = Release|Win32 30 | {C003740B-3E9C-458B-9596-DE4330D8A0BA}.Release|x64.ActiveCfg = Release|x64 31 | {C003740B-3E9C-458B-9596-DE4330D8A0BA}.Release|x64.Build.0 = Release|x64 32 | EndGlobalSection 33 | GlobalSection(SolutionProperties) = preSolution 34 | HideSolutionNode = FALSE 35 | EndGlobalSection 36 | EndGlobal 37 | -------------------------------------------------------------------------------- /win32/libiscsi/libiscsi.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {38246570-1DA0-489E-920A-20A22AAAB787} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {7F9950EA-C34C-4898-8D50-DF2069176D4B} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | 19 | 20 | Header Files 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | --------------------------------------------------------------------------------