mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-21 20:51:27 +00:00
scstadmin: Merge r4875:5189 from trunk
git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/2.2.x@5192 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -1,10 +1,21 @@
|
||||
ifndef PREFIX
|
||||
PREFIX=/usr/local
|
||||
endif
|
||||
|
||||
VERSION = $(shell echo -n "$$(sed -n 's/^[[:blank:]]*\$$VERSION[[:blank:]]*=[[:blank:]]*[\"'"'"']\([0-9.]*\)[\"'"'"'];$$/\1/p' scstadmin/scst-*/lib/SCST/SCST.pm)."; \
|
||||
if svn info >/dev/null 2>&1; \
|
||||
then svn info | sed -n 's/^Revision:[[:blank:]]*/r/p';\
|
||||
else git show | sed -n 's/^commit[[:blank:]]*\(.......\).*/\1/p'; \
|
||||
fi)
|
||||
|
||||
SCSTADMIN_DIR = $(shell if [ ! -h scstadmin ]; then \
|
||||
rm -f scstadmin; \
|
||||
ln -s scstadmin.sysfs scstadmin; \
|
||||
fi; \
|
||||
echo scstadmin)
|
||||
|
||||
MANDIR := $(DESTDIR)/usr/local/man
|
||||
MANDIR ?= $(DESTDIR)$(PREFIX)/man
|
||||
|
||||
INITDIR := $(shell if [ -f /etc/slackware-version ]; then \
|
||||
echo /etc/rc.d; \
|
||||
else \
|
||||
@@ -57,15 +68,12 @@ DEFAULTDIR := $(shell if [ -f /etc/gentoo-release ]; then \
|
||||
all:
|
||||
cd $(SCSTADMIN_DIR) && $(MAKE) $@
|
||||
|
||||
install:
|
||||
install install_vendor:
|
||||
@if [ -z "$(DESTDIR)" ] && rpm -q scstadmin >/dev/null 2>&1; then \
|
||||
echo Error: the scstadmin RPM must be uninstalled first; false; fi
|
||||
@if ! perl -MExtUtils::MakeMaker -e '' >/dev/null 2>&1; then \
|
||||
echo Error: the Perl module ExtUtils::MakeMaker must be installed \
|
||||
first; false; fi
|
||||
@if [ ! -e /etc/slackware-version -a ! -e /etc/gentoo-release \
|
||||
-a ! -e /lib/lsb/init-functions ]; then \
|
||||
echo "Error: the lsb-core (Debian, Ubuntu), redhat-lsb (RHEL, CentOS,"\
|
||||
"Scientific Linux, Fedora) or insserv (SLES, openSUSE) package must" \
|
||||
"be installed first"; false; fi
|
||||
cd $(SCSTADMIN_DIR) && $(MAKE) $@
|
||||
for m in scstadmin/man*/*.[1-9]; do \
|
||||
if [ -e $$m ]; then \
|
||||
@@ -111,6 +119,34 @@ uninstall:
|
||||
perl-module:
|
||||
cd $(SCSTADMIN_DIR) && $(MAKE) $@
|
||||
|
||||
test:
|
||||
$(MAKE) -C scstadmin test
|
||||
|
||||
dist-gzip:
|
||||
name=$(shell basename $$PWD) && \
|
||||
mkdir $${name}-$(VERSION) && \
|
||||
{ ../scripts/list-source-files | tar -T- -cf- | \
|
||||
tar -C $${name}-$(VERSION) -xf-; } && \
|
||||
rm -f $${name}-$(VERSION).tar.bz2 && \
|
||||
tar -cjf $${name}-$(VERSION).tar.bz2 $${name}-$(VERSION) && \
|
||||
rm -rf $${name}-$(VERSION)
|
||||
|
||||
rpm:
|
||||
name=$(shell basename $$PWD) && \
|
||||
rpmtopdir="$$(if [ $$(id -u) = 0 ]; then echo /usr/src/packages;\
|
||||
else echo $$PWD/rpmbuilddir; fi)" && \
|
||||
$(MAKE) dist-gzip && \
|
||||
rm -rf $${rpmtopdir} && \
|
||||
for d in BUILD RPMS SOURCES SPECS SRPMS; do \
|
||||
mkdir -p $${rpmtopdir}/$$d; \
|
||||
done && \
|
||||
cp $${name}-$(VERSION).tar.bz2 $${rpmtopdir}/SOURCES && \
|
||||
sed "s/@rpm_version@/$(VERSION)/g" \
|
||||
<$${name}.spec.in >$${name}.spec && \
|
||||
MAKE="$(MAKE)" \
|
||||
rpmbuild --define="%_topdir $${rpmtopdir}" -ba $${name}.spec && \
|
||||
rm -f $${name}-$(VERSION).tar.bz2
|
||||
|
||||
clean:
|
||||
cd $(SCSTADMIN_DIR) && $(MAKE) $@
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ fi
|
||||
cat <<"EOF"
|
||||
|
||||
SCST_CFG=/etc/scst.conf
|
||||
ISCSI_DAEMON="$(which iscsi-scstd)"
|
||||
|
||||
show_status() {
|
||||
_rc_status_ret=$?
|
||||
@@ -159,7 +160,7 @@ parse_scst_conf() {
|
||||
SCST_OPT_MODULES="crc32c-intel $SCST_OPT_MODULES";;
|
||||
esac
|
||||
SCST_OPT_MODULES="crc32c $SCST_OPT_MODULES"
|
||||
SCST_DAEMONS="/usr/local/sbin/iscsi-scstd $SCST_DAEMONS"
|
||||
SCST_DAEMONS="${ISCSI_DAEMON} $SCST_DAEMONS"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
ifndef PREFIX
|
||||
PREFIX=/usr/local
|
||||
endif
|
||||
|
||||
MODULE_VERSION = 0.8.22
|
||||
TOOL = scstadmin
|
||||
|
||||
SBINDIR := $(PREFIX)/usr/local/sbin
|
||||
SBINDIR := $(PREFIX)/sbin
|
||||
|
||||
all: perl-module
|
||||
|
||||
install: all
|
||||
$(MAKE) -C scst-$(MODULE_VERSION) install
|
||||
install install_vendor: all
|
||||
$(MAKE) -C scst-$(MODULE_VERSION) $@ DESTDIR=$(DESTDIR)
|
||||
install -d $(DESTDIR)$(SBINDIR)
|
||||
install -m 755 $(TOOL) $(DESTDIR)$(SBINDIR)
|
||||
|
||||
@@ -19,6 +23,9 @@ perl-module:
|
||||
perl Makefile.PL;
|
||||
$(MAKE) -C scst-$(MODULE_VERSION)
|
||||
|
||||
test:
|
||||
$(MAKE) -C scst-$(MODULE_VERSION) test
|
||||
|
||||
clean:
|
||||
-$(MAKE) -C scst-$(MODULE_VERSION) clean
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ $IOTYPE_PHYSICAL = 100;
|
||||
$IOTYPE_VIRTUAL = 101;
|
||||
$IOTYPE_PERFORMANCE = 102;
|
||||
|
||||
$VERSION = 0.8.22;
|
||||
$VERSION = '0.8.22';
|
||||
|
||||
my $_SCST_MIN_MAJOR_ = 2;
|
||||
my $_SCST_MIN_MINOR_ = 0;
|
||||
|
||||
80
scstadmin/scstadmin.spec.in
Normal file
80
scstadmin/scstadmin.spec.in
Normal file
@@ -0,0 +1,80 @@
|
||||
%define rpm_version @rpm_version@
|
||||
%define make %{expand:%%(echo ${MAKE:-make})}
|
||||
|
||||
Name: scstadmin
|
||||
Version: %{rpm_version}
|
||||
Release: 1
|
||||
Summary: SCST configuration tool
|
||||
Group: Productivity/Networking/Other
|
||||
License: GPLv2
|
||||
Vendor: http://scst.sourceforge.net/
|
||||
URL: http://scst.sourceforge.net/
|
||||
|
||||
Source: %{name}-%{version}.tar.bz2
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
AutoReqProv: yes
|
||||
|
||||
%description
|
||||
A tool for configuring SCST via the SCST sysfs interface. Allows to save,
|
||||
restore and modify any aspect of the SCST configuration. An extensive set of
|
||||
commands is available to modify any configurable parameter of target drivers,
|
||||
target ports, SCST devices, LUNs, initiator groups and ALUA configuration
|
||||
information.
|
||||
|
||||
Authors:
|
||||
--------
|
||||
Mark R. Buechler, Bart Van Assche and others
|
||||
|
||||
%define scstadmin_perl_installvendorman3dir \
|
||||
%(perl -V:installvendorman3dir | sed "s|.*='||;s|'.*||")
|
||||
%define scstadmin_perl_process_packlist \
|
||||
set -x;\
|
||||
if test -n "$RPM_BUILD_ROOT" -a -d $RPM_BUILD_ROOT%perl_vendorarch/auto; then \
|
||||
find $RPM_BUILD_ROOT%perl_vendorarch/auto -name .packlist -print0 | \
|
||||
xargs -0 -r rm; \
|
||||
if [ %{_target_cpu} == noarch ]; then \
|
||||
find $RPM_BUILD_ROOT%perl_vendorarch/auto -depth -type d -print0 | \
|
||||
xargs -0 -r rmdir; \
|
||||
fi; \
|
||||
fi; \
|
||||
rm -f $RPM_BUILD_ROOT%{perl_archlib}/perllocal.pod; set +x
|
||||
|
||||
%prep
|
||||
|
||||
%setup -q
|
||||
|
||||
%build
|
||||
export PREFIX=%{_prefix} DESTDIR=%{buildroot} MANDIR=%{buildroot}%{_mandir}
|
||||
%{make}
|
||||
|
||||
%install
|
||||
export PREFIX=%{_prefix} DESTDIR=%{buildroot} MANDIR=%{buildroot}%{_mandir}
|
||||
%{make} install_vendor
|
||||
%scstadmin_perl_process_packlist
|
||||
rm -rf %{buildroot}/var/adm/perl-modules/scst
|
||||
|
||||
%clean
|
||||
rm -rf %{buildroot}
|
||||
|
||||
%pre
|
||||
rm -f /usr/local/sbin/scstadmin
|
||||
rm -f /usr/local/man/man1/scstadmin.1*
|
||||
rm -f /usr/local/man/man3/SCST::SCST.3pm*
|
||||
rm -f /usr/local/man/man5/scst.5*
|
||||
rm -f /usr/local/man/man5/scst.conf.5*
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%config(noreplace) /etc/default/scst
|
||||
/etc/init.d/scst
|
||||
%{_sbindir}/scstadmin
|
||||
%{perl_vendorlib}/SCST
|
||||
%{perl_vendorarch}/auto/SCST-SCST
|
||||
%{_mandir}/man1/scstadmin.1*
|
||||
%{scstadmin_perl_installvendorman3dir}/SCST::SCST.3pm*
|
||||
%{_mandir}/man5/scst.5*
|
||||
%{_mandir}/man5/scst.conf.5*
|
||||
|
||||
%changelog
|
||||
* Fri Oct 04 2013 Bart Van Assche <bvanassche@acm.org>
|
||||
- Initial spec file.
|
||||
@@ -1,12 +1,16 @@
|
||||
ifndef PREFIX
|
||||
PREFIX=/usr/local
|
||||
endif
|
||||
|
||||
MODULE_VERSION = 0.9.10
|
||||
TOOL = scstadmin
|
||||
|
||||
SBINDIR := /usr/local/sbin
|
||||
SBINDIR := $(PREFIX)/sbin
|
||||
|
||||
all: perl-module
|
||||
|
||||
install: all
|
||||
$(MAKE) -C scst-$(MODULE_VERSION) install
|
||||
install install_vendor: all
|
||||
$(MAKE) -C scst-$(MODULE_VERSION) $@ DESTDIR=$(DESTDIR)
|
||||
install -d $(DESTDIR)$(SBINDIR)
|
||||
install -m 755 $(TOOL) $(DESTDIR)$(SBINDIR)
|
||||
|
||||
@@ -19,6 +23,9 @@ perl-module:
|
||||
perl Makefile.PL;
|
||||
$(MAKE) -C scst-$(MODULE_VERSION)
|
||||
|
||||
test:
|
||||
$(MAKE) -C scst-$(MODULE_VERSION) test
|
||||
|
||||
clean:
|
||||
-$(MAKE) -C scst-$(MODULE_VERSION) clean
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
27
scstadmin/scstadmin.sysfs/scst-0.9.10/t/01-start-scst.t
Normal file
27
scstadmin/scstadmin.sysfs/scst-0.9.10/t/01-start-scst.t
Normal file
@@ -0,0 +1,27 @@
|
||||
#!perl
|
||||
|
||||
use strict;
|
||||
use Test;
|
||||
|
||||
BEGIN {
|
||||
plan tests => ($> == 0) ? 3 : 0;
|
||||
}
|
||||
|
||||
if ($> == 0) {
|
||||
ok(system("killall iscsi-scstd >/dev/null 2>&1; " .
|
||||
"modprobe -r scst_local; " .
|
||||
"modprobe -r iscsi-scst; " .
|
||||
"modprobe -r ib_srpt; " .
|
||||
"modprobe -r qla2x00tgt; " .
|
||||
"modprobe -r qla2xxx_scst; " .
|
||||
"modprobe -r scst_vdisk"), 0);
|
||||
|
||||
ok(!(-d "/sys/module/scst"));
|
||||
|
||||
ok(system("modprobe scst_local add_default_tgt=0 && " .
|
||||
"modprobe iscsi-scst && " .
|
||||
"modprobe ib_srpt && " .
|
||||
"modprobe qla2x00tgt && " .
|
||||
"modprobe scst_vdisk && " .
|
||||
"iscsi-scstd"), 0);
|
||||
}
|
||||
46
scstadmin/scstadmin.sysfs/scst-0.9.10/t/02-scst-attr.t
Normal file
46
scstadmin/scstadmin.sysfs/scst-0.9.10/t/02-scst-attr.t
Normal file
@@ -0,0 +1,46 @@
|
||||
#!perl
|
||||
|
||||
use strict;
|
||||
use Test;
|
||||
|
||||
BEGIN {
|
||||
plan tests => 6 + ($> == 0 ? 4 : 0);
|
||||
}
|
||||
|
||||
use SCST::SCST;
|
||||
|
||||
sub getScstThreadCount {
|
||||
my $SCST = shift;
|
||||
my ($scstAttributes, $errorString) = $SCST->scstAttributes();
|
||||
my $threadHash = $scstAttributes->{'threads'};
|
||||
return exists($threadHash->{'keys'}) ? $threadHash->{'keys'}->{'0'}->{'value'} : $threadHash->{'value'};
|
||||
}
|
||||
|
||||
my $_DEBUG_ = 0;
|
||||
|
||||
my $SCST = eval { new SCST::SCST($_DEBUG_) };
|
||||
die("Creation of SCST object failed") if (!defined($SCST));
|
||||
|
||||
ok($SCST->setScstAttribute(), 1);
|
||||
|
||||
ok($SCST->setScstAttribute('no-such-attribute'), 1);
|
||||
|
||||
ok($SCST->setScstAttribute('no-such-attribute', '1'),
|
||||
$SCST->SCST_C_BAD_ATTRIBUTES);
|
||||
|
||||
ok($SCST->setScstAttribute('last_sysfs_mgmt_res', '1'),
|
||||
$SCST->SCST_C_ATTRIBUTE_STATIC);
|
||||
|
||||
my $threads = getScstThreadCount($SCST);
|
||||
ok(ref(\$threads), "SCALAR");
|
||||
ok(defined($threads));
|
||||
|
||||
if ($> == 0) {
|
||||
ok($SCST->setScstAttribute('threads', $threads + 1), 0);
|
||||
|
||||
ok(getScstThreadCount($SCST), $threads + 1);
|
||||
|
||||
ok($SCST->setScstAttribute('threads', $threads), 0);
|
||||
|
||||
ok(getScstThreadCount($SCST), $threads);
|
||||
}
|
||||
365
scstadmin/scstadmin.sysfs/scst-0.9.10/t/03-targets.t
Normal file
365
scstadmin/scstadmin.sysfs/scst-0.9.10/t/03-targets.t
Normal file
@@ -0,0 +1,365 @@
|
||||
#!perl
|
||||
|
||||
use strict;
|
||||
use Test;
|
||||
|
||||
BEGIN {
|
||||
plan tests => 177;
|
||||
}
|
||||
|
||||
use Data::Dumper;
|
||||
use SCST::SCST;
|
||||
|
||||
sub addTargets {
|
||||
my $SCST = shift;
|
||||
|
||||
ok(Dumper($SCST->targets('no-such-driver')),
|
||||
Dumper(undef, "targets(): Driver 'no-such-driver' is not available"));
|
||||
|
||||
my ($drivers, $errorString) = $SCST->drivers();
|
||||
my %drivers = map { $_ => 1 } @{$drivers};
|
||||
ok(exists($drivers{'iscsi'}));
|
||||
ok(exists($drivers{'scst_local'}));
|
||||
|
||||
my $all_hw_tgt = 1;
|
||||
for my $driver (@{$drivers}) {
|
||||
my ($targets, $errorString) = $SCST->targets($driver);
|
||||
for my $target (@{$targets}) {
|
||||
if ($SCST->targetType($driver, $target) !=
|
||||
$SCST::SCST::TGT_TYPE_HARDWARE) {
|
||||
$all_hw_tgt = undef;
|
||||
}
|
||||
}
|
||||
}
|
||||
ok($all_hw_tgt);
|
||||
|
||||
ok(Dumper($SCST->targets()), Dumper(undef, "Too few arguments"));
|
||||
ok(Dumper($SCST->targets('no-such-driver')),
|
||||
Dumper(undef, "targets(): Driver 'no-such-driver' is not available"));
|
||||
ok(Dumper($SCST->targets('scst_local')), Dumper([], undef));
|
||||
ok(Dumper($SCST->targets('iscsi')), Dumper([], undef));
|
||||
|
||||
ok($SCST->addVirtualTarget('no-such-driver', ''),
|
||||
$SCST->SCST_C_DRV_NO_DRIVER);
|
||||
ok($SCST->removeVirtualTarget('no-such-driver', ''),
|
||||
$SCST->SCST_C_DRV_NO_DRIVER);
|
||||
ok($SCST->addVirtualTarget('scst_local', 'local1'), 0);
|
||||
ok(Dumper($SCST->targetType()), Dumper(undef, "Too few arguments"));
|
||||
ok(Dumper($SCST->targetType('scst_local')),
|
||||
Dumper(undef, "Too few arguments"));
|
||||
ok($SCST->targetType('scst_local', 'no-such-target'),
|
||||
$SCST::SCST::TGT_TYPE_VIRTUAL);
|
||||
ok($SCST->targetType('scst_local', 'local1'),
|
||||
$SCST::SCST::TGT_TYPE_VIRTUAL);
|
||||
ok(Dumper($SCST->targets('scst_local')), Dumper(['local1'], undef));
|
||||
ok($SCST->removeVirtualTarget('scst_local', 'local2'),
|
||||
$SCST->SCST_C_TGT_NO_TARGET);
|
||||
ok(Dumper($SCST->targets('scst_local')), Dumper(['local1'], undef));
|
||||
ok($SCST->removeVirtualTarget('scst_local', 'local1'), 0);
|
||||
ok(Dumper($SCST->targets('scst_local')), Dumper([], undef));
|
||||
ok($SCST->addVirtualTarget('scst_local', 'local1',
|
||||
{ 'session_name' => 'local1' }), 0);
|
||||
ok($SCST->addVirtualTarget('scst_local', 'local2',
|
||||
{ 'session_name' => 'local2' }), 0);
|
||||
ok(Dumper($SCST->targets('scst_local')),
|
||||
Dumper(['local1', 'local2'], undef));
|
||||
|
||||
ok($SCST->targetExists(), 0);
|
||||
ok($SCST->targetExists('no-such-driver'), 0);
|
||||
ok($SCST->targetExists('no-such-driver', ''), 0);
|
||||
ok($SCST->targetExists('scst_local', 'no-such-target'), 0);
|
||||
ok($SCST->targetExists('scst_local', '.'), 0);
|
||||
ok($SCST->targetExists('scst_local', '..'), 0);
|
||||
ok($SCST->targetExists('scst_local', 'module'), 0);
|
||||
ok($SCST->targetExists('scst_local', 'local1'), 1);
|
||||
}
|
||||
|
||||
sub sessTest {
|
||||
my $SCST = shift;
|
||||
|
||||
ok(Dumper($SCST->sessions()), Dumper(undef, "Too few arguments"));
|
||||
ok(Dumper($SCST->sessions('scst_local')),
|
||||
Dumper(undef, "Too few arguments"));
|
||||
my ($s, $errorString) = $SCST->sessions('scst_local', 'local1');
|
||||
ok(Dumper(sort(keys(%$s))), Dumper('local1'));
|
||||
ok($s->{'local1'}->{'commands'}->{'value'}, '0');
|
||||
}
|
||||
|
||||
sub driverDynamicAttributesTest {
|
||||
my $SCST = shift;
|
||||
|
||||
ok(Dumper($SCST->driverDynamicAttributes()),
|
||||
Dumper(undef, "Too few arguments"));
|
||||
ok(Dumper($SCST->driverDynamicAttributes('no-such-driver')),
|
||||
Dumper(undef, "driverDynamicAttributes(): Driver 'no-such-driver' is " .
|
||||
"not available"));
|
||||
ok(Dumper($SCST->driverDynamicAttributes('scst_local')),
|
||||
Dumper({}, undef));
|
||||
}
|
||||
|
||||
sub iniGrpTest {
|
||||
my $SCST = shift;
|
||||
|
||||
ok(Dumper($SCST->groups()), Dumper(undef, "Too few arguments"));
|
||||
ok(Dumper($SCST->groups('scst_local')),
|
||||
Dumper(undef, "Too few arguments"));
|
||||
ok(Dumper($SCST->groups('scst_local', 'local1')), Dumper([], undef));
|
||||
|
||||
ok($SCST->addGroup(), $SCST->SCST_C_GRP_ADD_FAIL);
|
||||
ok($SCST->addGroup('no-such-driver', 'local1', 'group1'),
|
||||
$SCST->SCST_C_DRV_NO_DRIVER);
|
||||
ok($SCST->addGroup('scst_local', 'no-such-target', 'group1'),
|
||||
$SCST->SCST_C_TGT_NO_TARGET);
|
||||
ok($SCST->addGroup('scst_local', 'local1', 'group1'), 0);
|
||||
ok($SCST->addGroup('scst_local', 'local1', 'group1'),
|
||||
$SCST->SCST_C_GRP_EXISTS);
|
||||
ok($SCST->addGroup('scst_local', 'local1', 'group2'), 0);
|
||||
ok($SCST->addGroup('scst_local', 'local1', 'group3'), 0);
|
||||
ok(Dumper($SCST->groups('scst_local', 'local1')),
|
||||
Dumper(['group1', 'group2', 'group3'], undef));
|
||||
|
||||
ok($SCST->groupExists(), 0);
|
||||
ok($SCST->groupExists('no-such-driver', '', ''), 0);
|
||||
ok($SCST->groupExists('scst_local', 'no-such-target', ''), 0);
|
||||
ok($SCST->groupExists('scst_local', 'local1', 'no-such-group'), 0);
|
||||
ok($SCST->groupExists('scst_local', 'local1', 'group1'), 1);
|
||||
|
||||
ok($SCST->removeGroup(), $SCST->SCST_C_GRP_REM_FAIL);
|
||||
ok($SCST->removeGroup('no-such-driver', 'local1', 'group1'),
|
||||
$SCST->SCST_C_DRV_NO_DRIVER);
|
||||
ok($SCST->removeGroup('scst_local', 'no-such-target', 'group1'),
|
||||
$SCST->SCST_C_TGT_NO_TARGET);
|
||||
ok($SCST->removeGroup('scst_local', 'local1', 'group1'), 0);
|
||||
ok($SCST->removeGroup('scst_local', 'local1', 'group1'),
|
||||
$SCST->SCST_C_GRP_NO_GROUP);
|
||||
ok($SCST->removeGroup('scst_local', 'local1', 'group2'), 0);
|
||||
ok($SCST->removeGroup('scst_local', 'local1', 'group3'), 0);
|
||||
ok(Dumper($SCST->groups('scst_local', 'local1')), Dumper([], undef));
|
||||
|
||||
ok($SCST->addGroup('scst_local', 'local1', 'group1'), 0);
|
||||
ok($SCST->addInitiator('scst_local', 'local1', 'group1'),
|
||||
$SCST->SCST_C_GRP_ADD_INI_FAIL);
|
||||
ok($SCST->addInitiator('no-such-driver', 'local1', 'group1', 'ini1'),
|
||||
$SCST->SCST_C_DRV_NO_DRIVER);
|
||||
ok($SCST->addInitiator('scst_local', 'no-such-target', 'group1', 'ini1'),
|
||||
$SCST->SCST_C_TGT_NO_TARGET);
|
||||
ok($SCST->addInitiator('scst_local', 'local1', 'no-such-group', 'ini1'),
|
||||
$SCST->SCST_C_GRP_NO_GROUP);
|
||||
ok($SCST->addInitiator('scst_local', 'local1', 'group1', 'ini1'), 0);
|
||||
ok($SCST->addInitiator('scst_local', 'local1', 'group1', 'ini2'), 0);
|
||||
ok($SCST->addInitiator('scst_local', 'local1', 'group1', 'ini1'),
|
||||
$SCST->SCST_C_GRP_INI_EXISTS);
|
||||
ok(Dumper($SCST->initiators()), Dumper(undef, "Too few arguments"));
|
||||
ok(Dumper($SCST->initiators('scst_local')),
|
||||
Dumper(undef, "Too few arguments"));
|
||||
ok(Dumper($SCST->initiators('scst_local', 'local1')),
|
||||
Dumper(undef, "Too few arguments"));
|
||||
ok(Dumper($SCST->initiators('scst_local', 'local1', 'group1')),
|
||||
Dumper(['ini1', 'ini2'], undef));
|
||||
|
||||
ok($SCST->initiatorExists(), 0);
|
||||
ok($SCST->initiatorExists('no-such-driver', '', '', ''), 0);
|
||||
ok($SCST->initiatorExists('scst_local', 'no-such-target', '', ''), 0);
|
||||
ok($SCST->initiatorExists('scst_local', 'local1', 'no-such-group', ''), 0);
|
||||
ok($SCST->initiatorExists('scst_local', 'local1', 'group1', 'no-such-ini'),
|
||||
0);
|
||||
ok($SCST->initiatorExists('scst_local', 'local1', 'group1', 'ini1'), 1);
|
||||
|
||||
ok($SCST->addGroup('scst_local', 'local1', 'group2'), 0);
|
||||
ok($SCST->moveInitiator('scst_local', 'local1', 'group1', 'group2', 'ini1'),
|
||||
0);
|
||||
ok($SCST->initiatorExists('scst_local', 'local1', 'group1', 'ini1'), 0);
|
||||
ok($SCST->initiatorExists('scst_local', 'local1', 'group2', 'ini1'), 1);
|
||||
ok($SCST->moveInitiator('scst_local', 'local1', 'group2', 'group1', 'ini1'),
|
||||
0);
|
||||
ok($SCST->initiatorExists('scst_local', 'local1', 'group1', 'ini1'), 1);
|
||||
ok($SCST->initiatorExists('scst_local', 'local1', 'group2', 'ini1'), 0);
|
||||
|
||||
ok($SCST->removeGroup('scst_local', 'local1', 'group2'), 0);
|
||||
ok($SCST->removeInitiator('no-such-driver', 'local1', 'group1'),
|
||||
$SCST->SCST_C_GRP_REM_INI_FAIL);
|
||||
ok($SCST->removeInitiator('no-such-driver', 'local1', 'group1', 'ini1'),
|
||||
$SCST->SCST_C_DRV_NO_DRIVER);
|
||||
ok($SCST->removeInitiator('scst_local', 'no-such-target', 'group1', 'ini1'),
|
||||
$SCST->SCST_C_TGT_NO_TARGET);
|
||||
ok($SCST->removeInitiator('scst_local', 'local1', 'no-such-group', 'ini1'),
|
||||
$SCST->SCST_C_GRP_NO_GROUP);
|
||||
ok($SCST->removeInitiator('scst_local', 'local1', 'group1', 'ini1'), 0);
|
||||
ok($SCST->removeInitiator('scst_local', 'local1', 'group1', 'ini2'), 0);
|
||||
ok($SCST->removeInitiator('scst_local', 'local1', 'group1', 'ini2'),
|
||||
$SCST->SCST_C_GRP_NO_INI);
|
||||
ok(Dumper($SCST->initiators('scst_local', 'local1', 'group1')),
|
||||
Dumper([], undef));
|
||||
ok($SCST->removeGroup('scst_local', 'local1', 'group1'), 0);
|
||||
}
|
||||
|
||||
sub lunReadOnly {
|
||||
my $SCST = shift;
|
||||
my $driver = shift;
|
||||
my $target = shift;
|
||||
my $lun = shift;
|
||||
|
||||
my ($a, $errorString) = $SCST->lunAttributes($driver, $target, $lun);
|
||||
my $roHash = $a->{'read_only'};
|
||||
return exists($roHash->{'keys'}) ? $roHash->{'keys'}->{'0'}->{'value'} :
|
||||
$roHash->{'value'};
|
||||
}
|
||||
|
||||
sub lunTest {
|
||||
my $SCST = shift;
|
||||
|
||||
ok($SCST->openDevice("no-such-handler", "disk01", { }),
|
||||
$SCST->SCST_C_HND_NO_HANDLER);
|
||||
ok($SCST->openDevice("vdisk_fileio", "disk01", undef),
|
||||
$SCST->SCST_C_DEV_OPEN_FAIL);
|
||||
ok($SCST->openDevice("vdisk_fileio", "disk01", { }),
|
||||
$SCST->SCST_C_DEV_OPEN_FAIL);
|
||||
ok($SCST->openDevice("vdisk_fileio", "disk01",
|
||||
{ 'filename' => '/proc/cpuinfo' }), 0);
|
||||
ok(Dumper($SCST->devicesByHandler("vdisk_fileio")),
|
||||
Dumper(["disk01"], undef));
|
||||
ok($SCST->openDevice("vdisk_fileio", "disk01",
|
||||
{ 'filename' => '/proc/cpuinfo' }),
|
||||
$SCST->SCST_C_DEV_EXISTS);
|
||||
ok($SCST->openDevice("vdisk_fileio", "disk02",
|
||||
{ 'filename' => '/proc/cpuinfo' }), 0);
|
||||
|
||||
ok($SCST->addLun('scst_local', 'local1', 'disk01', 0),
|
||||
$SCST->SCST_C_TGT_ADD_LUN_FAIL);
|
||||
ok($SCST->addLun('scst_local', 'local3', 'disk01', 0, { }),
|
||||
$SCST->SCST_C_TGT_NO_TARGET);
|
||||
ok($SCST->addLun('scst_local', 'local1', 'disk01', 0, { }), 0);
|
||||
ok($SCST->addLun('scst_local', 'local1', 'disk02', 1, { }), 0);
|
||||
ok($SCST->addLun('scst_local', 'local1', 'disk01', 2, { }), 0);
|
||||
ok($SCST->addLun('scst_local', 'local1', 'disk02', 3, { }), 0);
|
||||
ok($SCST->addLun('scst_local', 'local1', 'disk01', 3, { }),
|
||||
$SCST->SCST_C_TGT_LUN_EXISTS);
|
||||
|
||||
ok($SCST->lunExists(), 0);
|
||||
ok($SCST->lunExists('scst_local'), 0);
|
||||
ok($SCST->lunExists('scst_local', 'local1'), 0);
|
||||
ok($SCST->lunExists('no-such-driver', 'local1', 0),
|
||||
$SCST->SCST_C_DRV_NO_DRIVER);
|
||||
ok($SCST->lunExists('scst_local', 'no-such-target', 0),
|
||||
$SCST->SCST_C_TGT_NO_TARGET);
|
||||
ok($SCST->lunExists('scst_local', 'local1', 99), 0);
|
||||
ok($SCST->lunExists('scst_local', 'local1', 0), 1);
|
||||
|
||||
ok($SCST->addGroup('scst_local', 'local1', 'group1'), 0);
|
||||
ok($SCST->addInitiator('scst_local', 'local1', 'group1', 'ini1'), 0);
|
||||
|
||||
ok($SCST->addLun('scst_local', 'local1', 'disk01', 0, undef, 'group1'),
|
||||
$SCST->SCST_C_GRP_ADD_LUN_FAIL);
|
||||
ok($SCST->addLun('scst_local', 'local1', 'disk01', 0, { }, 'group1'), 0);
|
||||
ok($SCST->addLun('scst_local', 'local1', 'disk02', 2, { }, 'group1'), 0);
|
||||
ok($SCST->addLun('scst_local', 'local1', 'disk01', 4, { }, 'group1'), 0);
|
||||
ok($SCST->addLun('scst_local', 'local1', 'disk02', 6, { }, 'group1'), 0);
|
||||
ok($SCST->addLun('scst_local', 'local1', 'disk01', 6, { }, 'group1'),
|
||||
$SCST->SCST_C_GRP_LUN_EXISTS);
|
||||
|
||||
ok($SCST->lunExists('no-such-driver', 'local1', 0, 'group1'),
|
||||
$SCST->SCST_C_DRV_NO_DRIVER);
|
||||
ok($SCST->lunExists('scst_local', 'no-such-target', 0, 'group1'),
|
||||
$SCST->SCST_C_TGT_NO_TARGET);
|
||||
ok($SCST->lunExists('scst_local', 'local1', 99, 'group1'), 0);
|
||||
ok($SCST->lunExists('scst_local', 'local1', 0, 'no-such-group'),
|
||||
$SCST->SCST_C_GRP_NO_GROUP);
|
||||
ok($SCST->lunExists('scst_local', 'local1', 0, 'group1'), 1);
|
||||
|
||||
ok(Dumper($SCST->luns()), Dumper(undef, "Too few arguments"));
|
||||
ok(Dumper($SCST->luns('scst_local')), Dumper(undef, "Too few arguments"));
|
||||
ok(Dumper($SCST->luns('no-such-driver', 'local1')),
|
||||
Dumper(undef, "luns(): Driver 'no-such-driver' is not available"));
|
||||
ok(Dumper($SCST->luns('scst_local', 'no-such-target')),
|
||||
Dumper(undef, "luns(): Target 'no-such-target' is not available"));
|
||||
ok(Dumper($SCST->luns('scst_local', 'local1')),
|
||||
Dumper({ '0' => 'disk01', '1' => 'disk02', '2' => 'disk01',
|
||||
'3' => 'disk02' }, undef));
|
||||
ok(Dumper($SCST->luns('scst_local', 'local1', 'group1')),
|
||||
Dumper({ '0' => 'disk01', '2' => 'disk02', '4' => 'disk01',
|
||||
'6' => 'disk02' }, undef));
|
||||
|
||||
ok(lunReadOnly($SCST, 'scst_local', 'local1', 0), '0');
|
||||
ok($SCST->setLunAttribute(), $SCST->SCST_C_LUN_SETATTR_FAIL);
|
||||
ok($SCST->setLunAttribute('no-such-driver', 'local1', 0, 'read_only', '1'),
|
||||
$SCST->SCST_C_DRV_NO_DRIVER);
|
||||
ok($SCST->setLunAttribute('scst_local', 'no-such-target', 0, 'read_only', '1'),
|
||||
$SCST->SCST_C_TGT_NO_TARGET);
|
||||
ok($SCST->setLunAttribute('scst_local', 'local1', 99, 'read_only', '1'),
|
||||
$SCST->SCST_C_TGT_NO_LUN);
|
||||
ok($SCST->setLunAttribute('scst_local', 'local1', 0, 'read_only', '1'),
|
||||
$SCST->SCST_C_LUN_ATTRIBUTE_STATIC);
|
||||
ok(lunReadOnly($SCST, 'scst_local', 'local1', 0), '0');
|
||||
ok(lunReadOnly($SCST, 'scst_local', 'local1', 0, 'group1'), '0');
|
||||
ok($SCST->setLunAttribute('scst_local', 'local1', 0, 'read_only', '1', 'no-such-group'),
|
||||
$SCST->SCST_C_GRP_NO_GROUP);
|
||||
ok($SCST->setLunAttribute('scst_local', 'local1', 99, 'read_only', '1', 'group1'),
|
||||
$SCST->SCST_C_GRP_NO_LUN);
|
||||
ok($SCST->setLunAttribute('scst_local', 'local1', 0, 'read_only', '1', 'group1'),
|
||||
$SCST->SCST_C_LUN_ATTRIBUTE_STATIC);
|
||||
ok(lunReadOnly($SCST, 'scst_local', 'local1', 0, 'group1'), '0');
|
||||
|
||||
ok($SCST->replaceLun('scst_local', 'local1', 0, 'disk02', {}), 0);
|
||||
ok(Dumper($SCST->luns('scst_local', 'local1')),
|
||||
Dumper({ '0' => 'disk02', '1' => 'disk02', '2' => 'disk01',
|
||||
'3' => 'disk02' }, undef));
|
||||
ok($SCST->replaceLun('scst_local', 'local1', 0, 'disk01', {}), 0);
|
||||
ok(Dumper($SCST->luns('scst_local', 'local1')),
|
||||
Dumper({ '0' => 'disk01', '1' => 'disk02', '2' => 'disk01',
|
||||
'3' => 'disk02' }, undef));
|
||||
|
||||
ok($SCST->clearLuns(undef, undef), $SCST->SCST_C_TGT_CLR_LUN_FAIL);
|
||||
ok($SCST->clearLuns(undef, undef, 'group1'),
|
||||
$SCST->SCST_C_GRP_CLR_LUN_FAIL);
|
||||
ok($SCST->removeLun(undef, undef, undef), $SCST->SCST_C_TGT_ADD_LUN_FAIL);
|
||||
ok($SCST->removeLun('no-such-driver', 'local1', '0'),
|
||||
$SCST->SCST_C_DRV_NO_DRIVER);
|
||||
ok($SCST->removeLun('scst_local', 'no-such-target', '0'),
|
||||
$SCST->SCST_C_TGT_NO_TARGET);
|
||||
ok($SCST->removeLun(undef, undef, undef, 'group1'),
|
||||
$SCST->SCST_C_GRP_REM_LUN_FAIL);
|
||||
ok($SCST->removeLun('scst_local', 'local1', '4'), $SCST->SCST_C_TGT_NO_LUN);
|
||||
ok($SCST->removeLun('scst_local', 'local1', '8', 'group1'),
|
||||
$SCST->SCST_C_GRP_NO_LUN);
|
||||
ok($SCST->clearLuns('scst_local', 'local1'), 0);
|
||||
ok(Dumper($SCST->luns('scst_local', 'local1')), Dumper({ }, undef));
|
||||
ok(Dumper($SCST->luns('scst_local', 'local1', 'group1')),
|
||||
Dumper({ '0' => 'disk01', '2' => 'disk02', '4' => 'disk01',
|
||||
'6' => 'disk02' }, undef));
|
||||
ok($SCST->removeLun('scst_local', 'local1', '4', 'group1'), 0);
|
||||
ok(Dumper($SCST->luns('scst_local', 'local1', 'group1')),
|
||||
Dumper({ '0' => 'disk01', '2' => 'disk02', '6' => 'disk02' }, undef));
|
||||
ok($SCST->clearLuns('scst_local', 'local1', 'group1'), 0);
|
||||
ok(Dumper($SCST->luns('scst_local', 'local1', 'group1')),
|
||||
Dumper({ }, undef));
|
||||
|
||||
ok($SCST->removeInitiator('scst_local', 'local1', 'group1', 'ini1'), 0);
|
||||
ok($SCST->removeGroup('scst_local', 'local1', 'group1'), 0);
|
||||
|
||||
ok($SCST->closeDevice("no-such-handler", "disk01"),
|
||||
$SCST->SCST_C_HND_NO_HANDLER);
|
||||
ok($SCST->closeDevice("vdisk_fileio", "disk02"), 0);
|
||||
ok($SCST->closeDevice("vdisk_fileio", "disk01"), 0);
|
||||
ok($SCST->closeDevice("vdisk_fileio", "disk01"),
|
||||
$SCST->SCST_C_DEV_NO_DEVICE);
|
||||
}
|
||||
|
||||
sub remTargets {
|
||||
my $SCST = shift;
|
||||
|
||||
ok($SCST->removeVirtualTarget('scst_local', 'local2'), 0);
|
||||
ok($SCST->removeVirtualTarget('scst_local', 'local1'), 0);
|
||||
ok(Dumper($SCST->targets('scst_local')), Dumper([], undef));
|
||||
}
|
||||
|
||||
my $_DEBUG_ = 0;
|
||||
|
||||
my $SCST = eval { new SCST::SCST($_DEBUG_) };
|
||||
die("Creation of SCST object failed") if (!defined($SCST));
|
||||
|
||||
addTargets($SCST);
|
||||
sessTest($SCST);
|
||||
driverDynamicAttributesTest($SCST);
|
||||
iniGrpTest($SCST);
|
||||
lunTest($SCST);
|
||||
remTargets($SCST);
|
||||
143
scstadmin/scstadmin.sysfs/scst-0.9.10/t/04-alua.t
Normal file
143
scstadmin/scstadmin.sysfs/scst-0.9.10/t/04-alua.t
Normal file
@@ -0,0 +1,143 @@
|
||||
#!perl
|
||||
|
||||
use strict;
|
||||
use Test;
|
||||
|
||||
BEGIN {
|
||||
plan tests => 62;
|
||||
}
|
||||
|
||||
use Data::Dumper;
|
||||
use SCST::SCST;
|
||||
|
||||
sub setup {
|
||||
my $SCST = shift;
|
||||
|
||||
my ($drivers, $errorString) = $SCST->drivers();
|
||||
my %drivers = map { $_ => 1 } @{$drivers};
|
||||
ok(exists($drivers{'iscsi'}));
|
||||
ok(exists($drivers{'scst_local'}));
|
||||
|
||||
ok($SCST->openDevice("vdisk_fileio", "disk01",
|
||||
{ 'filename' => '/proc/cpuinfo' }), 0);
|
||||
ok($SCST->openDevice("vdisk_fileio", "disk02",
|
||||
{ 'filename' => '/proc/cpuinfo' }), 0);
|
||||
ok($SCST->openDevice("vdisk_fileio", "disk03",
|
||||
{ 'filename' => '/proc/cpuinfo' }), 0);
|
||||
ok($SCST->openDevice("vdisk_fileio", "disk04",
|
||||
{ 'filename' => '/proc/cpuinfo' }), 0);
|
||||
|
||||
ok($SCST->addVirtualTarget('scst_local', 'local1'), 0);
|
||||
|
||||
ok($SCST->addLun('scst_local', 'local1', 'disk01', 0, { }), 0);
|
||||
ok($SCST->addLun('scst_local', 'local1', 'disk02', 1, { }), 0);
|
||||
ok($SCST->addLun('scst_local', 'local1', 'disk03', 2, { }), 0);
|
||||
ok($SCST->addLun('scst_local', 'local1', 'disk04', 3, { }), 0);
|
||||
}
|
||||
|
||||
sub test {
|
||||
my $SCST = shift;
|
||||
|
||||
ok(Dumper($SCST->deviceGroups()), Dumper([], undef));
|
||||
|
||||
ok($SCST->addDeviceGroup('dg1'), 0);
|
||||
ok($SCST->addDeviceGroup('dg2'), 0);
|
||||
ok($SCST->addDeviceGroup('dg3'), 0);
|
||||
ok($SCST->addDeviceGroup('dg4'), 0);
|
||||
|
||||
ok(Dumper($SCST->deviceGroups()),
|
||||
Dumper(['dg1', 'dg2', 'dg3', 'dg4'], undef));
|
||||
|
||||
ok(Dumper($SCST->deviceGroupDevices()), Dumper(undef, "Too few arguments"));
|
||||
ok(Dumper($SCST->deviceGroupDevices('dg1')), Dumper([], undef));
|
||||
ok($SCST->addDeviceGroupDevice('dg1', 'disk01'), 0);
|
||||
ok($SCST->addDeviceGroupDevice('dg1', 'disk01'),
|
||||
$SCST->SCST_C_DGRP_DEVICE_EXISTS);
|
||||
ok($SCST->addDeviceGroupDevice('dg2', 'disk02'), 0);
|
||||
ok($SCST->addDeviceGroupDevice('dg2', 'disk01'),
|
||||
$SCST->SCST_C_DGRP_DEVICE_OTHER);
|
||||
ok($SCST->addDeviceGroupDevice('dg3', 'disk03'), 0);
|
||||
ok($SCST->addDeviceGroupDevice('dg4', 'disk04'), 0);
|
||||
ok(Dumper($SCST->deviceGroupDevices('dg1')), Dumper(['disk01'], undef));
|
||||
ok(Dumper($SCST->deviceGroupDevices('dg2')), Dumper(['disk02'], undef));
|
||||
ok(Dumper($SCST->deviceGroupDevices('dg3')), Dumper(['disk03'], undef));
|
||||
ok(Dumper($SCST->deviceGroupDevices('dg4')), Dumper(['disk04'], undef));
|
||||
|
||||
ok(Dumper($SCST->targetGroups()), Dumper(undef, "Too few arguments"));
|
||||
ok(Dumper($SCST->targetGroups('no-such-device-group')),
|
||||
Dumper(undef, "targetGroups(): Device group 'no-such-device-group'" .
|
||||
" does not exist"));
|
||||
ok(Dumper($SCST->targetGroups('dg1')), Dumper([], undef));
|
||||
|
||||
ok(Dumper($SCST->targetGroupTargets()), Dumper(undef, "Too few arguments"));
|
||||
ok(Dumper($SCST->targetGroupTargets('no-such-device-group')),
|
||||
Dumper(undef, "Too few arguments"));
|
||||
ok(Dumper($SCST->targetGroupTargets('no-such-device-group', 'tg1')),
|
||||
Dumper(undef, "targetGroupTargets(): Device group 'no-such-device-".
|
||||
"group' does not exist"));
|
||||
ok(Dumper($SCST->targetGroupTargets('dg1', 'no-such-target-group')),
|
||||
Dumper(undef, "targetGroupTargets(): Target group 'no-such-target-".
|
||||
"group' does not exist"));
|
||||
ok(Dumper($SCST->targetGroupTargets('dg1', 'tg1')), Dumper(undef,
|
||||
"targetGroupTargets(): Target group 'tg1' does not exist"));
|
||||
ok($SCST->addTargetGroup(), $SCST->SCST_C_DGRP_ADD_GRP_FAIL);
|
||||
ok($SCST->addTargetGroup('no-such-device-group', 'tg1'),
|
||||
$SCST->SCST_C_DEV_GRP_NO_GROUP);
|
||||
ok($SCST->addTargetGroup('dg1', 'tg1'), 0);
|
||||
ok($SCST->addTargetGroup('dg1', 'tg1'), $SCST->SCST_C_DGRP_GROUP_EXISTS);
|
||||
ok($SCST->addTargetGroup('dg1', 'tg2'), 0);
|
||||
|
||||
my ($tga, $errorString) = $SCST->targetGroupAttributes('dg1', 'tg1');
|
||||
ok(Dumper($tga->{'group_id'}),
|
||||
Dumper({ 'keys' => { '0' => { 'value' => '0' } }, 'static' => 0 }));
|
||||
ok($SCST->setTargetGroupAttribute('dg1', 'tg1', 'group_id', 7), 0);
|
||||
($tga, $errorString) = $SCST->targetGroupAttributes('dg1', 'tg1');
|
||||
ok(Dumper($tga->{'group_id'}),
|
||||
Dumper({ 'keys' => { '0' => { 'value' => '7' } }, 'static' => 0 }));
|
||||
|
||||
ok($SCST->addTargetGroupTarget(), $SCST->SCST_C_TGRP_ADD_TGT_FAIL);
|
||||
ok($SCST->addTargetGroupTarget('no-such-device-group', 'tg1', 'tgt1'),
|
||||
$SCST->SCST_C_DEV_GRP_NO_GROUP);
|
||||
ok($SCST->addTargetGroupTarget('dg1', 'no-such-target-group', 'tgt1'),
|
||||
$SCST->SCST_C_DGRP_NO_GROUP);
|
||||
ok($SCST->addTargetGroupTarget('dg1', 'tg1', 'tgt1'), 0);
|
||||
ok($SCST->addTargetGroupTarget('dg1', 'tg1', 'tgt1'),
|
||||
$SCST->SCST_C_TGRP_TGT_EXISTS);
|
||||
ok($SCST->addTargetGroupTarget('dg1', 'tg2', 'tgt2'), 0);
|
||||
|
||||
my $tgta;
|
||||
($tgta, $errorString) =
|
||||
$SCST->targetGroupTargetAttributes('dg1', 'tg1', 'tgt1');
|
||||
ok(Dumper($tgta->{'rel_tgt_id'}),
|
||||
Dumper({ 'keys' => { '0' => { 'value' => '0' } }, 'static' => 0 }));
|
||||
ok($SCST->setTargetGroupTargetAttribute('dg1', 'tg1', 'tgt1', 'rel_tgt_id',
|
||||
8), 0);
|
||||
($tgta, $errorString) =
|
||||
$SCST->targetGroupTargetAttributes('dg1', 'tg1', 'tgt1');
|
||||
ok(Dumper($tgta->{'rel_tgt_id'}),
|
||||
Dumper({ 'keys' => { '0' => { 'value' => '8' } }, 'static' => 0 }));
|
||||
|
||||
ok($SCST->removeDeviceGroup('dg1'), 0);
|
||||
ok($SCST->removeDeviceGroup('dg2'), 0);
|
||||
ok($SCST->removeDeviceGroup('dg3'), 0);
|
||||
ok($SCST->removeDeviceGroup('dg4'), 0);
|
||||
|
||||
ok(Dumper($SCST->deviceGroups()), Dumper([], undef));
|
||||
}
|
||||
|
||||
sub teardown {
|
||||
my $SCST = shift;
|
||||
|
||||
ok($SCST->removeVirtualTarget('scst_local', 'local1'), 0);
|
||||
ok($SCST->closeDevice("vdisk_fileio", "disk01"), 0);
|
||||
ok($SCST->closeDevice("vdisk_fileio", "disk02"), 0);
|
||||
}
|
||||
|
||||
my $_DEBUG_ = 0;
|
||||
|
||||
my $SCST = eval { new SCST::SCST($_DEBUG_) };
|
||||
die("Creation of SCST object failed") if (!defined($SCST));
|
||||
|
||||
setup($SCST);
|
||||
test($SCST);
|
||||
teardown($SCST);
|
||||
160
scstadmin/scstadmin.sysfs/scst-0.9.10/t/05-dynattr.t
Normal file
160
scstadmin/scstadmin.sysfs/scst-0.9.10/t/05-dynattr.t
Normal file
@@ -0,0 +1,160 @@
|
||||
#!perl
|
||||
|
||||
use strict;
|
||||
use Test;
|
||||
|
||||
BEGIN {
|
||||
plan tests => 55;
|
||||
}
|
||||
|
||||
use Data::Dumper;
|
||||
use SCST::SCST;
|
||||
|
||||
sub setup {
|
||||
my $SCST = shift;
|
||||
|
||||
my ($drivers, $errorString) = $SCST->drivers();
|
||||
my %drivers = map { $_ => 1 } @{$drivers};
|
||||
ok(exists($drivers{'iscsi'}));
|
||||
ok(exists($drivers{'scst_local'}));
|
||||
|
||||
ok($SCST->openDevice("vdisk_fileio", "disk01",
|
||||
{ 'filename' => '/proc/cpuinfo' }), 0);
|
||||
|
||||
ok($SCST->addVirtualTarget('iscsi', 'tgt1'), 0);
|
||||
|
||||
ok($SCST->addLun('iscsi', 'tgt1', 'disk01', 0, { }), 0);
|
||||
}
|
||||
|
||||
sub testDriverDynAttr {
|
||||
my $SCST = shift;
|
||||
|
||||
ok(Dumper($SCST->driverDynamicAttributes()),
|
||||
Dumper(undef, "Too few arguments"));
|
||||
ok(Dumper($SCST->driverDynamicAttributes('no-such-driver')),
|
||||
Dumper(undef, "driverDynamicAttributes(): Driver 'no-such-driver' is " .
|
||||
"not available"));
|
||||
ok(Dumper($SCST->driverDynamicAttributes('scst_local')), Dumper({}, undef));
|
||||
ok(Dumper($SCST->driverDynamicAttributes('iscsi')),
|
||||
Dumper({ 'IncomingUser' => '', 'OutgoingUser' => '' }, undef));
|
||||
ok($SCST->checkDriverDynamicAttributes('no-such-driver'),
|
||||
$SCST->SCST_C_DRV_NO_DRIVER);
|
||||
ok($SCST->checkDriverDynamicAttributes('no-such-driver', { }),
|
||||
$SCST->SCST_C_DRV_NO_DRIVER);
|
||||
ok($SCST->checkDriverDynamicAttributes('scst_local', { }), 0);
|
||||
ok($SCST->checkDriverDynamicAttributes('iscsi', { }), 0);
|
||||
ok($SCST->checkDriverDynamicAttributes('iscsi',
|
||||
{ 'IncomingUser' => ''}), 0);
|
||||
ok($SCST->checkDriverDynamicAttributes('iscsi',
|
||||
{ 'IncomingUser' => '',
|
||||
'OutgoingUser' => '' }), 0);
|
||||
ok($SCST->checkDriverDynamicAttributes('iscsi',
|
||||
{ 'IncomingUser' => '',
|
||||
'OutgoingUser' => '',
|
||||
'NoSuchAttribute' => '' }), 1);
|
||||
|
||||
ok($SCST->addDriverDynamicAttribute(), $SCST->SCST_C_DRV_ADDATTR_FAIL);
|
||||
ok($SCST->addDriverDynamicAttribute('no-such-driver', '', ''),
|
||||
$SCST->SCST_C_DRV_NO_DRIVER);
|
||||
ok($SCST->addDriverDynamicAttribute('iscsi', 'no-such-attribute', ''),
|
||||
$SCST->SCST_C_DRV_BAD_ATTRIBUTES);
|
||||
ok($SCST->addDriverDynamicAttribute('iscsi', 'IncomingUser',
|
||||
'bar 12CharSecret'), 0);
|
||||
ok($SCST->addDriverDynamicAttribute('iscsi', 'IncomingUser',
|
||||
'joe 12charsecret'), 0);
|
||||
my ($da, $errorString) = $SCST->driverAttributes('iscsi');
|
||||
ok(Dumper($da->{'IncomingUser'}),
|
||||
Dumper({ 'keys' => { '0' => { 'value' => 'bar 12CharSecret' },
|
||||
'1' => { 'value' => 'joe 12charsecret' } },
|
||||
'static' => 0 }));
|
||||
ok($SCST->removeDriverDynamicAttribute(), $SCST->SCST_C_DRV_REMATTR_FAIL);
|
||||
ok($SCST->removeDriverDynamicAttribute('no-such-driver', '', ''),
|
||||
$SCST->SCST_C_DRV_NO_DRIVER);
|
||||
ok($SCST->removeDriverDynamicAttribute('iscsi', 'no-such-attribute', ''),
|
||||
$SCST->SCST_C_DRV_BAD_ATTRIBUTES);
|
||||
ok($SCST->removeDriverDynamicAttribute('iscsi', 'IncomingUser',
|
||||
'joe 12charsecret'), 0);
|
||||
ok($SCST->removeDriverDynamicAttribute('iscsi', 'IncomingUser',
|
||||
'bar 12CharSecret'), 0);
|
||||
($da, $errorString) = $SCST->driverAttributes('iscsi');
|
||||
ok(!exists($da->{'IncomingUser'}));
|
||||
}
|
||||
|
||||
sub testTargetDynAttr {
|
||||
my $SCST = shift;
|
||||
|
||||
ok(Dumper($SCST->targetDynamicAttributes()),
|
||||
Dumper(undef, "Too few arguments"));
|
||||
ok(Dumper($SCST->targetDynamicAttributes('no-such-driver')),
|
||||
Dumper(undef, "targetDynamicAttributes(): Driver 'no-such-driver' is" .
|
||||
" not available"));
|
||||
ok(Dumper($SCST->targetDynamicAttributes('scst_local')), Dumper({}, undef));
|
||||
ok(Dumper($SCST->targetDynamicAttributes('iscsi')),
|
||||
Dumper({ 'IncomingUser' => '',
|
||||
'OutgoingUser' => '',
|
||||
'allowed_portal' => '' }, undef));
|
||||
ok($SCST->checkTargetDynamicAttributes('no-such-driver'),
|
||||
$SCST->SCST_C_DRV_NO_DRIVER);
|
||||
ok($SCST->checkTargetDynamicAttributes('no-such-driver', { }),
|
||||
$SCST->SCST_C_DRV_NO_DRIVER);
|
||||
ok($SCST->checkTargetDynamicAttributes('scst_local', { }), 0);
|
||||
ok($SCST->checkTargetDynamicAttributes('iscsi', { }), 0);
|
||||
ok($SCST->checkTargetDynamicAttributes('iscsi',
|
||||
{ 'IncomingUser' => ''}), 0);
|
||||
ok($SCST->checkTargetDynamicAttributes('iscsi',
|
||||
{ 'IncomingUser' => '',
|
||||
'OutgoingUser' => '' }), 0);
|
||||
ok($SCST->checkTargetDynamicAttributes('iscsi',
|
||||
{ 'IncomingUser' => '',
|
||||
'OutgoingUser' => '',
|
||||
'NoSuchAttribute' => '' }), 1);
|
||||
|
||||
ok($SCST->addTargetDynamicAttribute(), $SCST->SCST_C_TGT_ADDATTR_FAIL);
|
||||
ok($SCST->addTargetDynamicAttribute('no-such-driver', '', '', ''),
|
||||
$SCST->SCST_C_DRV_NO_DRIVER);
|
||||
ok($SCST->addTargetDynamicAttribute('iscsi', 'no-such-target', '', ''),
|
||||
$SCST->SCST_C_TGT_NO_TARGET);
|
||||
ok($SCST->addTargetDynamicAttribute('iscsi', 'tgt1', 'no-such-attribute',
|
||||
'', ''),
|
||||
$SCST->SCST_C_TGT_BAD_ATTRIBUTES);
|
||||
ok($SCST->addTargetDynamicAttribute('iscsi', 'tgt1', 'IncomingUser',
|
||||
'bar 12CharSecret'), 0);
|
||||
ok($SCST->addTargetDynamicAttribute('iscsi', 'tgt1', 'IncomingUser',
|
||||
'joe 12charsecret'), 0);
|
||||
my ($ta, $errorString) = $SCST->targetAttributes('iscsi', 'tgt1');
|
||||
ok(Dumper($ta->{'IncomingUser'}),
|
||||
Dumper({ 'keys' => { '0' => { 'value' => 'bar 12CharSecret' },
|
||||
'1' => { 'value' => 'joe 12charsecret' } },
|
||||
'static' => 0 }));
|
||||
ok($SCST->removeTargetDynamicAttribute(), $SCST->SCST_C_TGT_REMATTR_FAIL);
|
||||
ok($SCST->removeTargetDynamicAttribute('no-such-driver', '', '', ''),
|
||||
$SCST->SCST_C_DRV_NO_DRIVER);
|
||||
ok($SCST->removeTargetDynamicAttribute('iscsi', 'no-such-target', '', ''),
|
||||
$SCST->SCST_C_TGT_NO_TARGET);
|
||||
ok($SCST->removeTargetDynamicAttribute('iscsi', 'tgt1', 'no-such-attribute',
|
||||
''),
|
||||
$SCST->SCST_C_TGT_BAD_ATTRIBUTES);
|
||||
ok($SCST->removeTargetDynamicAttribute('iscsi', 'tgt1', 'IncomingUser',
|
||||
'joe 12charsecret'), 0);
|
||||
ok($SCST->removeTargetDynamicAttribute('iscsi', 'tgt1', 'IncomingUser',
|
||||
'bar 12CharSecret'), 0);
|
||||
($ta, $errorString) = $SCST->targetAttributes('iscsi', 'tgt1');
|
||||
ok(!exists($ta->{'IncomingUser'}));
|
||||
}
|
||||
|
||||
sub teardown {
|
||||
my $SCST = shift;
|
||||
|
||||
ok($SCST->removeVirtualTarget('iscsi', 'tgt1'), 0);
|
||||
ok($SCST->closeDevice("vdisk_fileio", "disk01"), 0);
|
||||
}
|
||||
|
||||
my $_DEBUG_ = 0;
|
||||
|
||||
my $SCST = eval { new SCST::SCST($_DEBUG_) };
|
||||
die("Creation of SCST object failed") if (!defined($SCST));
|
||||
|
||||
setup($SCST);
|
||||
testDriverDynAttr($SCST);
|
||||
testTargetDynAttr($SCST);
|
||||
teardown($SCST);
|
||||
67
scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t
Normal file
67
scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t
Normal file
@@ -0,0 +1,67 @@
|
||||
#!perl
|
||||
|
||||
use strict;
|
||||
use Cwd qw(abs_path);
|
||||
use File::Basename;
|
||||
use File::Spec;
|
||||
use Test;
|
||||
|
||||
my $testdir;
|
||||
my $scstadmin_pm_dir;
|
||||
my $scstadmin_dir;
|
||||
my $scstadmin;
|
||||
|
||||
BEGIN {
|
||||
$testdir = dirname(abs_path($0));
|
||||
$scstadmin_pm_dir = dirname($testdir);
|
||||
$scstadmin_dir = dirname($scstadmin_pm_dir);
|
||||
$scstadmin = File::Spec->catfile($scstadmin_dir, "scstadmin");
|
||||
unless(grep /blib/, @INC) {
|
||||
unshift(@INC, File::Spec->catdir($scstadmin_pm_dir, "lib"));
|
||||
}
|
||||
plan tests => 2;
|
||||
}
|
||||
|
||||
use Data::Dumper;
|
||||
use SCST::SCST;
|
||||
use File::Temp qw/tempfile/;
|
||||
|
||||
sub setup {
|
||||
my $SCST = shift;
|
||||
|
||||
my ($drivers, $errorString) = $SCST->drivers();
|
||||
my %drivers = map { $_ => 1 } @{$drivers};
|
||||
ok(exists($drivers{'ib_srpt'}));
|
||||
}
|
||||
|
||||
sub testRestoreConfig {
|
||||
my $to_be_restored = shift;
|
||||
my $expected = shift;
|
||||
my $tmpfilename1 = File::Spec->catfile(File::Spec->tmpdir(),
|
||||
"scstadmin-test-06-$$-1");
|
||||
my $tmpfilename2 = File::Spec->catfile(File::Spec->tmpdir(),
|
||||
"scstadmin-test-06-$$-2");
|
||||
|
||||
system("$scstadmin -clear_config -force -noprompt -no_lip >/dev/null");
|
||||
system("$scstadmin -cont_on_err -no_lip -config $to_be_restored" .
|
||||
" >/dev/null");
|
||||
system("$scstadmin -write_config $tmpfilename1 >/dev/null");
|
||||
system("awk 'BEGIN {t = 0 } /^TARGET_DRIVER.*{\$/ { if (\$0 != \"TARGET_DRIVER scst_local {\") t = 1 } /^}\$/ { if (t == 1) t = 2 } /^\$/ { if (t == 2) { t = 3 } } /^./ { if (t == 3) { t = 0 } } { if (t == 0) print }' <$tmpfilename1 >$tmpfilename2");
|
||||
my $compare_result = system("diff -u $tmpfilename2 $expected");
|
||||
ok($compare_result, 0);
|
||||
if ($compare_result == 0) {
|
||||
unlink($tmpfilename2);
|
||||
unlink($tmpfilename1);
|
||||
}
|
||||
}
|
||||
|
||||
my $_DEBUG_ = 0;
|
||||
|
||||
my $SCST = eval { new SCST::SCST($_DEBUG_) };
|
||||
die("Creation of SCST object failed") if (!defined($SCST));
|
||||
|
||||
setup($SCST);
|
||||
|
||||
testRestoreConfig(File::Spec->catfile($testdir, "to-be-restored.conf"),
|
||||
File::Spec->catfile($testdir, "after-restore.conf"));
|
||||
|
||||
21
scstadmin/scstadmin.sysfs/scst-0.9.10/t/99-stop-scst.t
Normal file
21
scstadmin/scstadmin.sysfs/scst-0.9.10/t/99-stop-scst.t
Normal file
@@ -0,0 +1,21 @@
|
||||
#!perl
|
||||
|
||||
use strict;
|
||||
use Test;
|
||||
|
||||
BEGIN {
|
||||
plan tests => 2;
|
||||
}
|
||||
|
||||
if ($> == 0) {
|
||||
ok(system("killall iscsi-scstd; " .
|
||||
"modprobe -r scst_local; " .
|
||||
"modprobe -r iscsi-scst; " .
|
||||
"modprobe -r ib_srpt; " .
|
||||
"modprobe -r qla2x00tgt; " .
|
||||
"modprobe -r qla2xxx_scst; " .
|
||||
"modprobe -r scst_vdisk"), 0);
|
||||
ok(!(-d "/sys/module/scst"));
|
||||
} else {
|
||||
ok(1);
|
||||
}
|
||||
56
scstadmin/scstadmin.sysfs/scst-0.9.10/t/after-restore.conf
Normal file
56
scstadmin/scstadmin.sysfs/scst-0.9.10/t/after-restore.conf
Normal file
@@ -0,0 +1,56 @@
|
||||
# Automatically generated by SCST Configurator v3.0.0-pre2.
|
||||
|
||||
|
||||
HANDLER vdisk_fileio {
|
||||
DEVICE disk01 {
|
||||
filename /proc/cpuinfo
|
||||
}
|
||||
}
|
||||
|
||||
TARGET_DRIVER scst_local {
|
||||
TARGET local1 {
|
||||
session_name local1_session
|
||||
|
||||
LUN 0 disk01
|
||||
LUN 1 disk01
|
||||
|
||||
GROUP initator_group {
|
||||
LUN 0 disk01
|
||||
LUN 1 disk01 {
|
||||
read_only 1
|
||||
}
|
||||
LUN 2 disk01
|
||||
|
||||
INITIATOR ini1
|
||||
|
||||
INITIATOR ini2
|
||||
|
||||
INITIATOR ini3
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DEVICE_GROUP dg01 {
|
||||
DEVICE disk01
|
||||
|
||||
TARGET_GROUP tg01a {
|
||||
group_id 1
|
||||
preferred 1
|
||||
state active
|
||||
|
||||
TARGET tgt_a {
|
||||
rel_tgt_id 2
|
||||
}
|
||||
}
|
||||
|
||||
TARGET_GROUP tg01b {
|
||||
group_id 2
|
||||
preferred 0
|
||||
state active
|
||||
|
||||
TARGET tgt_b {
|
||||
rel_tgt_id 3
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
62
scstadmin/scstadmin.sysfs/scst-0.9.10/t/to-be-restored.conf
Normal file
62
scstadmin/scstadmin.sysfs/scst-0.9.10/t/to-be-restored.conf
Normal file
@@ -0,0 +1,62 @@
|
||||
# Automatically generated by SCST Configurator v3.0.0-pre2.
|
||||
|
||||
|
||||
HANDLER vdisk_fileio {
|
||||
DEVICE disk01 {
|
||||
filename /proc/cpuinfo
|
||||
}
|
||||
}
|
||||
|
||||
TARGET_DRIVER ib_srpt {
|
||||
TARGET no_such_target {
|
||||
enabled 1
|
||||
}
|
||||
}
|
||||
|
||||
TARGET_DRIVER scst_local {
|
||||
TARGET local1 {
|
||||
session_name local1_session
|
||||
|
||||
LUN 0 disk01
|
||||
LUN 1 disk01
|
||||
|
||||
GROUP initator_group {
|
||||
LUN 0 disk01
|
||||
LUN 1 disk01 {
|
||||
read_only 1
|
||||
}
|
||||
LUN 2 disk01
|
||||
|
||||
INITIATOR ini1
|
||||
|
||||
INITIATOR ini2
|
||||
|
||||
INITIATOR ini3
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DEVICE_GROUP dg01 {
|
||||
DEVICE disk01
|
||||
|
||||
TARGET_GROUP tg01a {
|
||||
group_id 1
|
||||
preferred 1
|
||||
state active
|
||||
|
||||
TARGET tgt_a {
|
||||
rel_tgt_id 2
|
||||
}
|
||||
}
|
||||
|
||||
TARGET_GROUP tg01b {
|
||||
group_id 2
|
||||
preferred 0
|
||||
state active
|
||||
|
||||
TARGET tgt_b {
|
||||
rel_tgt_id 3
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user