Initial test branch for adding tests to libiscsi

These tests depends on not yet released version on TGTD to allow running
both TGTD and TGTADM as unprivileged users to set up and configure
targets to test against during make test.
Update TGTD to tip of master before running these tests.

See STGT mailinglist for patches.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
Ronnie Sahlberg
2015-04-09 08:18:36 -07:00
parent fc6e06ce04
commit e8a2296f94
10 changed files with 923 additions and 3 deletions

54
tests/functions.sh Normal file
View File

@@ -0,0 +1,54 @@
TGTD=tgtd
TGTADM=tgtadm
TGTLUN=`pwd`/100M
TGTPORTAL=127.0.0.1:3260
IQNTARGET=iqn.libiscsi.unittest.target
IQNINITIATOR=iqn.libiscsi.unittest.initiator
TGTURL=iscsi://${TGTPORTAL}/${IQNTARGET}/1
start_target() {
# Setup target
echo "Starting iSCSI target"
${TGTD} --iscsi portal=${TGTPORTAL},nop_interval=3,nop_count=3
sleep 1
${TGTADM} --op new --mode target --tid 1 -T ${IQNTARGET}
${TGTADM} --op bind --mode target --tid 1 -I ALL
#${TGTADM} --op show --mode target
}
shutdown_target() {
# Remove target
echo "Shutting down iSCSI target"
${TGTADM} --op delete --force --mode target --tid 1
${TGTADM} --op delete --mode system
}
create_lun() {
# Setup LUN
truncate --size=100M ${TGTLUN}
${TGTADM} --op new --mode logicalunit --tid 1 --lun 1 -b ${TGTLUN} --blocksize=4096
}
delete_lun() {
# Remove LUN
rm ${TGTLUN}
}
setup_chap() {
${TGTADM} --op new --mode account --user libiscsi --password libiscsi
${TGTADM} --op bind --mode account --tid 1 --user libiscsi
${TGTADM} --op new --mode account --user outgoing --password outgoing
${TGTADM} --op bind --mode account --tid 1 --user outgoing --outgoing
}
success() {
echo "[OK]"
rm ${TEST_TMP} 2> /dev/null
}
failure() {
echo "[FAILED]"
exit 1
}