scstadmin: Eliminate $SCST->{'err_string'}

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5127 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2013-11-19 17:00:50 +00:00
parent 3f1e616262
commit 136cbaebb9
7 changed files with 575 additions and 573 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -11,7 +11,7 @@ use SCST::SCST;
sub getScstThreadCount {
my $SCST = shift;
my $scstAttributes = $SCST->scstAttributes();
my ($scstAttributes, $errorString) = $SCST->scstAttributes();
my $threadHash = $scstAttributes->{'threads'};
return exists($threadHash->{'keys'}) ? $threadHash->{'keys'}->{'0'}->{'value'} : $threadHash->{'value'};
}

View File

@@ -4,7 +4,7 @@ use strict;
use Test;
BEGIN {
plan tests => 181;
plan tests => 177;
}
use Data::Dumper;
@@ -13,17 +13,18 @@ use SCST::SCST;
sub addTargets {
my $SCST = shift;
ok($SCST->targets('no-such-driver'), undef);
ok($SCST->{'err_string'},
"targets(): Driver 'no-such-driver' is not available");
ok(Dumper($SCST->targets('no-such-driver')),
Dumper(undef, "targets(): Driver 'no-such-driver' is not available"));
my %drivers = map { $_ => 1 } @{$SCST->drivers()};
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 (@{$SCST->drivers()}) {
for my $target (@{$SCST->targets($driver)}) {
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;
@@ -32,35 +33,36 @@ sub addTargets {
}
ok($all_hw_tgt);
ok(Dumper($SCST->targets()), Dumper(undef));
ok(Dumper($SCST->targets('no-such-driver')), Dumper(undef));
ok($SCST->{'err_string'},
"targets(): Driver 'no-such-driver' is not available");
ok(Dumper($SCST->targets('scst_local')), Dumper([]));
ok(Dumper($SCST->targets('iscsi')), Dumper([]));
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));
ok(Dumper($SCST->targetType('scst_local')), Dumper(undef));
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']));
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']));
ok(Dumper($SCST->targets('scst_local')), Dumper(['local1'], undef));
ok($SCST->removeVirtualTarget('scst_local', 'local1'), 0);
ok(Dumper($SCST->targets('scst_local')), Dumper([]));
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']));
ok(Dumper($SCST->targets('scst_local')),
Dumper(['local1', 'local2'], undef));
ok($SCST->targetExists(), 0);
ok($SCST->targetExists('no-such-driver'), 0);
@@ -75,9 +77,10 @@ sub addTargets {
sub sessTest {
my $SCST = shift;
ok(Dumper($SCST->sessions()), Dumper(undef));
ok(Dumper($SCST->sessions('scst_local')), Dumper(undef));
my $s = $SCST->sessions('scst_local', 'local1');
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');
}
@@ -85,19 +88,22 @@ sub sessTest {
sub driverDynamicAttributesTest {
my $SCST = shift;
ok(Dumper($SCST->driverDynamicAttributes()), Dumper(undef));
ok(Dumper($SCST->driverDynamicAttributes('no-such-driver')), Dumper(undef));
ok($SCST->{'err_string'},
"driverDynamicAttributes(): Driver 'no-such-driver' is not available");
ok(Dumper($SCST->driverDynamicAttributes('scst_local')), Dumper({}));
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));
ok(Dumper($SCST->groups('scst_local')), Dumper(undef));
ok(Dumper($SCST->groups('scst_local', 'local1')), Dumper([]));
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'),
@@ -110,7 +116,7 @@ sub iniGrpTest {
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']));
Dumper(['group1', 'group2', 'group3'], undef));
ok($SCST->groupExists(), 0);
ok($SCST->groupExists('no-such-driver', '', ''), 0);
@@ -128,7 +134,7 @@ sub iniGrpTest {
$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([]));
ok(Dumper($SCST->groups('scst_local', 'local1')), Dumper([], undef));
ok($SCST->addGroup('scst_local', 'local1', 'group1'), 0);
ok($SCST->addInitiator('scst_local', 'local1', 'group1'),
@@ -143,11 +149,13 @@ sub iniGrpTest {
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));
ok(Dumper($SCST->initiators('scst_local')), Dumper(undef));
ok(Dumper($SCST->initiators('scst_local', 'local1')), Dumper(undef));
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']));
Dumper(['ini1', 'ini2'], undef));
ok($SCST->initiatorExists(), 0);
ok($SCST->initiatorExists('no-such-driver', '', '', ''), 0);
@@ -180,7 +188,8 @@ sub iniGrpTest {
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([]));
ok(Dumper($SCST->initiators('scst_local', 'local1', 'group1')),
Dumper([], undef));
ok($SCST->removeGroup('scst_local', 'local1', 'group1'), 0);
}
@@ -190,7 +199,7 @@ sub lunReadOnly {
my $target = shift;
my $lun = shift;
my $a = $SCST->lunAttributes($driver, $target, $lun);
my ($a, $errorString) = $SCST->lunAttributes($driver, $target, $lun);
my $roHash = $a->{'read_only'};
return exists($roHash->{'keys'}) ? $roHash->{'keys'}->{'0'}->{'value'} :
$roHash->{'value'};
@@ -207,6 +216,8 @@ sub lunTest {
$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);
@@ -255,20 +266,18 @@ sub lunTest {
$SCST->SCST_C_GRP_NO_GROUP);
ok($SCST->lunExists('scst_local', 'local1', 0, 'group1'), 1);
ok(Dumper($SCST->luns()), Dumper(undef));
ok(Dumper($SCST->luns('scst_local')), Dumper(undef));
ok(Dumper($SCST->luns('no-such-driver', 'local1')), Dumper(undef));
ok($SCST->{'err_string'},
"luns(): Driver 'no-such-driver' is not available");
ok(Dumper($SCST->luns('scst_local', 'no-such-target')), Dumper(undef));
ok($SCST->{'err_string'},
"luns(): Target 'no-such-target' is not available");
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' }));
'3' => 'disk02' }, undef));
ok(Dumper($SCST->luns('scst_local', 'local1', 'group1')),
Dumper({ '0' => 'disk01', '2' => 'disk02', '4' => 'disk01',
'6' => 'disk02' }));
'6' => 'disk02' }, undef));
ok(lunReadOnly($SCST, 'scst_local', 'local1', 0), '0');
ok($SCST->setLunAttribute(), $SCST->SCST_C_LUN_SETATTR_FAIL);
@@ -293,11 +302,11 @@ sub lunTest {
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' }));
'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' }));
'3' => 'disk02' }, undef));
ok($SCST->clearLuns(undef, undef), $SCST->SCST_C_TGT_CLR_LUN_FAIL);
ok($SCST->clearLuns(undef, undef, 'group1'),
@@ -313,15 +322,16 @@ sub lunTest {
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({ }));
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' }));
'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' }));
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({ }));
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);
@@ -339,7 +349,7 @@ sub remTargets {
ok($SCST->removeVirtualTarget('scst_local', 'local2'), 0);
ok($SCST->removeVirtualTarget('scst_local', 'local1'), 0);
ok(Dumper($SCST->targets('scst_local')), Dumper([]));
ok(Dumper($SCST->targets('scst_local')), Dumper([], undef));
}
my $_DEBUG_ = 0;

View File

@@ -4,7 +4,7 @@ use strict;
use Test;
BEGIN {
plan tests => 65;
plan tests => 62;
}
use Data::Dumper;
@@ -13,7 +13,8 @@ use SCST::SCST;
sub setup {
my $SCST = shift;
my %drivers = map { $_ => 1 } @{$SCST->drivers()};
my ($drivers, $errorString) = $SCST->drivers();
my %drivers = map { $_ => 1 } @{$drivers};
ok(exists($drivers{'iscsi'}));
ok(exists($drivers{'scst_local'}));
@@ -37,17 +38,18 @@ sub setup {
sub test {
my $SCST = shift;
ok(Dumper($SCST->deviceGroups()), Dumper([]));
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']));
ok(Dumper($SCST->deviceGroups()),
Dumper(['dg1', 'dg2', 'dg3', 'dg4'], undef));
ok(Dumper($SCST->deviceGroupDevices()), Dumper(undef));
ok(Dumper($SCST->deviceGroupDevices('dg1')), Dumper([]));
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);
@@ -56,26 +58,28 @@ sub test {
$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']));
ok(Dumper($SCST->deviceGroupDevices('dg2')), Dumper(['disk02']));
ok(Dumper($SCST->deviceGroupDevices('dg3')), Dumper(['disk03']));
ok(Dumper($SCST->deviceGroupDevices('dg4')), Dumper(['disk04']));
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($SCST->targetGroups(), undef);
ok($SCST->targetGroups('no-such-device-group'), undef);
ok($SCST->{'err_string'},
"targetGroups(): Device group 'no-such-device-group' does not exist");
ok(Dumper($SCST->targetGroups('dg1')), Dumper([]));
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($SCST->targetGroupTargets(), undef);
ok($SCST->targetGroupTargets('no-such-device-group'), undef);
ok($SCST->targetGroupTargets('no-such-device-group', 'tg1'), undef);
ok($SCST->{'err_string'},
"targetGroupTargets(): Device group 'no-such-device-group' does not exist");
ok($SCST->targetGroupTargets('dg1', 'no-such-target-group'), undef);
ok($SCST->{'err_string'},
"targetGroupTargets(): Target group 'no-such-target-group' does not exist");
ok($SCST->targetGroupTargets('dg1', 'tg1'), 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);
@@ -83,13 +87,13 @@ sub test {
ok($SCST->addTargetGroup('dg1', 'tg1'), $SCST->SCST_C_DGRP_GROUP_EXISTS);
ok($SCST->addTargetGroup('dg1', 'tg2'), 0);
ok(Dumper($SCST->targetGroupAttributes('dg1', 'tg1')->{'group_id'}),
Dumper({ 'keys' => { '0' => { 'value' => '0' } },
'static' => 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);
ok(Dumper($SCST->targetGroupAttributes('dg1', 'tg1')->{'group_id'}),
Dumper({ 'keys' => { '0' => { 'value' => '7' } },
'static' => 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'),
@@ -101,23 +105,24 @@ sub test {
$SCST->SCST_C_TGRP_TGT_EXISTS);
ok($SCST->addTargetGroupTarget('dg1', 'tg2', 'tgt2'), 0);
ok(Dumper($SCST->targetGroupTargetAttributes('dg1', 'tg1', 'tgt1')
->{'rel_tgt_id'}),
Dumper({ 'keys' => { '0' => { 'value' => '0' } },
'static' => 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);
ok(Dumper($SCST->targetGroupTargetAttributes('dg1', 'tg1', 'tgt1')
->{'rel_tgt_id'}),
Dumper({ 'keys' => { '0' => { 'value' => '8' } },
'static' => 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([]));
ok(Dumper($SCST->deviceGroups()), Dumper([], undef));
}
sub teardown {

View File

@@ -4,7 +4,7 @@ use strict;
use Test;
BEGIN {
plan tests => 57;
plan tests => 55;
}
use Data::Dumper;
@@ -13,7 +13,8 @@ use SCST::SCST;
sub setup {
my $SCST = shift;
my %drivers = map { $_ => 1 } @{$SCST->drivers()};
my ($drivers, $errorString) = $SCST->drivers();
my %drivers = map { $_ => 1 } @{$drivers};
ok(exists($drivers{'iscsi'}));
ok(exists($drivers{'scst_local'}));
@@ -28,13 +29,14 @@ sub setup {
sub testDriverDynAttr {
my $SCST = shift;
ok($SCST->driverDynamicAttributes(), undef);
ok($SCST->driverDynamicAttributes('no-such-driver'), undef);
ok($SCST->{'err_string'},
"driverDynamicAttributes(): Driver 'no-such-driver' is not available");
ok(Dumper($SCST->driverDynamicAttributes('scst_local')), Dumper({}));
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' => '' }));
Dumper({ 'IncomingUser' => '', 'OutgoingUser' => '' }, undef));
ok($SCST->checkDriverDynamicAttributes('no-such-driver'),
$SCST->SCST_C_DRV_NO_DRIVER);
ok($SCST->checkDriverDynamicAttributes('no-such-driver', { }),
@@ -60,7 +62,8 @@ sub testDriverDynAttr {
'bar 12CharSecret'), 0);
ok($SCST->addDriverDynamicAttribute('iscsi', 'IncomingUser',
'joe 12charsecret'), 0);
ok(Dumper($SCST->driverAttributes('iscsi')->{'IncomingUser'}),
my ($da, $errorString) = $SCST->driverAttributes('iscsi');
ok(Dumper($da->{'IncomingUser'}),
Dumper({ 'keys' => { '0' => { 'value' => 'bar 12CharSecret' },
'1' => { 'value' => 'joe 12charsecret' } },
'static' => 0 }));
@@ -73,21 +76,23 @@ sub testDriverDynAttr {
'joe 12charsecret'), 0);
ok($SCST->removeDriverDynamicAttribute('iscsi', 'IncomingUser',
'bar 12CharSecret'), 0);
ok(!exists($SCST->driverAttributes('iscsi')->{'IncomingUser'}));
($da, $errorString) = $SCST->driverAttributes('iscsi');
ok(!exists($da->{'IncomingUser'}));
}
sub testTargetDynAttr {
my $SCST = shift;
ok($SCST->targetDynamicAttributes(), undef);
ok($SCST->targetDynamicAttributes('no-such-driver'), undef);
ok($SCST->{'err_string'},
"targetDynamicAttributes(): Driver 'no-such-driver' is not available");
ok(Dumper($SCST->targetDynamicAttributes('scst_local')), Dumper({}));
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' => '' }));
'allowed_portal' => '' }, undef));
ok($SCST->checkTargetDynamicAttributes('no-such-driver'),
$SCST->SCST_C_DRV_NO_DRIVER);
ok($SCST->checkTargetDynamicAttributes('no-such-driver', { }),
@@ -116,7 +121,8 @@ sub testTargetDynAttr {
'bar 12CharSecret'), 0);
ok($SCST->addTargetDynamicAttribute('iscsi', 'tgt1', 'IncomingUser',
'joe 12charsecret'), 0);
ok(Dumper($SCST->targetAttributes('iscsi', 'tgt1')->{'IncomingUser'}),
my ($ta, $errorString) = $SCST->targetAttributes('iscsi', 'tgt1');
ok(Dumper($ta->{'IncomingUser'}),
Dumper({ 'keys' => { '0' => { 'value' => 'bar 12CharSecret' },
'1' => { 'value' => 'joe 12charsecret' } },
'static' => 0 }));
@@ -132,7 +138,8 @@ sub testTargetDynAttr {
'joe 12charsecret'), 0);
ok($SCST->removeTargetDynamicAttribute('iscsi', 'tgt1', 'IncomingUser',
'bar 12CharSecret'), 0);
ok(!exists($SCST->targetAttributes('iscsi', 'tgt1')->{'IncomingUser'}));
($ta, $errorString) = $SCST->targetAttributes('iscsi', 'tgt1');
ok(!exists($ta->{'IncomingUser'}));
}
sub teardown {

View File

@@ -29,7 +29,8 @@ use File::Temp qw/tempfile/;
sub setup {
my $SCST = shift;
my %drivers = map { $_ => 1 } @{$SCST->drivers()};
my ($drivers, $errorString) = $SCST->drivers();
my %drivers = map { $_ => 1 } @{$drivers};
ok(exists($drivers{'ib_srpt'}));
}

File diff suppressed because it is too large Load Diff