mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-23 21:51:27 +00:00
scstadmin: Add tests for the scstadmin -list_* options
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7932 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -36,3 +36,31 @@ TARGET_DRIVER scst_local {
|
||||
}
|
||||
}
|
||||
|
||||
DEVICE_GROUP dgroup1 {
|
||||
TARGET_GROUP tgroup1 {
|
||||
group_id 256
|
||||
state active
|
||||
|
||||
TARGET local
|
||||
}
|
||||
|
||||
TARGET_GROUP tgroup2 {
|
||||
group_id 257
|
||||
state active
|
||||
}
|
||||
}
|
||||
|
||||
DEVICE_GROUP dgroup2 {
|
||||
TARGET_GROUP tgroup1 {
|
||||
group_id 258
|
||||
state active
|
||||
|
||||
TARGET local
|
||||
}
|
||||
|
||||
TARGET_GROUP tgroup2 {
|
||||
group_id 259
|
||||
state active
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ BEGIN {
|
||||
unless(grep /blib/, @INC) {
|
||||
unshift(@INC, File::Spec->catdir($scstadmin_pm_dir, "lib"));
|
||||
}
|
||||
plan tests => 16;
|
||||
plan tests => 55;
|
||||
}
|
||||
|
||||
use Data::Dumper;
|
||||
@@ -68,6 +68,20 @@ sub attributeTest {
|
||||
"-add_lun 0 -device disk0 $redirect"), 0);
|
||||
ok(system("$scstadmin -driver scst_local -target local -group ig " .
|
||||
"-add_lun 1 -device disk1 $redirect"), 0);
|
||||
ok(system("$scstadmin -add_dgrp dgroup1 $redirect"), 0);
|
||||
ok(system("$scstadmin -add_dgrp dgroup2 $redirect"), 0);
|
||||
ok(system("$scstadmin -add_tgrp tgroup1 -dev_group dgroup1 $redirect"), 0);
|
||||
ok(system("$scstadmin -noprompt -set_tgrp_attr tgroup1 -dev_group dgroup1 -attributes group_id=256 $redirect"), 0);
|
||||
ok(system("$scstadmin -add_tgrp tgroup2 -dev_group dgroup1 $redirect"), 0);
|
||||
ok(system("$scstadmin -noprompt -set_tgrp_attr tgroup2 -dev_group dgroup1 -attributes group_id=257 $redirect"), 0);
|
||||
ok(system("$scstadmin -add_tgrp tgroup1 -dev_group dgroup2 $redirect"), 0);
|
||||
ok(system("$scstadmin -noprompt -set_tgrp_attr tgroup1 -dev_group dgroup2 -attributes group_id=258 $redirect"), 0);
|
||||
ok(system("$scstadmin -add_tgrp tgroup2 -dev_group dgroup2 $redirect"), 0);
|
||||
ok(system("$scstadmin -noprompt -set_tgrp_attr tgroup2 -dev_group dgroup2 -attributes group_id=259 $redirect"), 0);
|
||||
ok(system("$scstadmin -add_tgrp_tgt local -dev_group dgroup1 -tgt_group tgroup1 $redirect"), 0);
|
||||
ok(system("$scstadmin -add_tgrp_tgt local -dev_group dgroup2 -tgt_group tgroup1 $redirect"), 0);
|
||||
ok(system("$scstadmin -noprompt -set_tgrp_attr tgroup1 -dev_group dgroup1 -attributes rel_tgt_id=1 $redirect"), 0);
|
||||
ok(system("$scstadmin -noprompt -set_tgrp_attr tgroup1 -dev_group dgroup2 -attributes rel_tgt_id=2 $redirect"), 0);
|
||||
ok(system("$scstadmin -write_config $tmpfilename1 >/dev/null"), 0);
|
||||
# Keep only the scst_local target driver information.
|
||||
my $cmd = "gawk 'BEGIN { t = 0 } /^# Automatically generated by SCST Configurator v/ {" .
|
||||
@@ -88,6 +102,354 @@ sub attributeTest {
|
||||
}
|
||||
}
|
||||
|
||||
# Run shell command $1 and return what it wrote to stdout and stderr as a
|
||||
# string.
|
||||
sub run {
|
||||
my ($cmd) = @_;
|
||||
my $tmpfile = File::Spec->catfile(File::Spec->tmpdir(),
|
||||
"scstadmin-test-07-$$-3");
|
||||
my $res;
|
||||
my $rc;
|
||||
|
||||
$rc = system("$cmd >$tmpfile 2>&1");
|
||||
if ($rc != 0) {
|
||||
$res = "exit code $rc";
|
||||
} elsif (!open(my $file, $tmpfile)) {
|
||||
$res = "failed to read $tmpfile";
|
||||
} else {
|
||||
local $/ = undef;
|
||||
binmode $file;
|
||||
$res = <$file>;
|
||||
if (!defined($res)) {
|
||||
$res = "";
|
||||
}
|
||||
close $file;
|
||||
}
|
||||
unlink($tmpfile);
|
||||
return $res;
|
||||
}
|
||||
|
||||
# Test the scstadmin -list_* options.
|
||||
sub listTest {
|
||||
my $result;
|
||||
|
||||
$result = <<'EOS';
|
||||
|
||||
Collecting current configuration: done.
|
||||
|
||||
Handler
|
||||
-------------
|
||||
vcdrom
|
||||
vdisk_blockio
|
||||
vdisk_fileio
|
||||
vdisk_nullio
|
||||
|
||||
All done.
|
||||
EOS
|
||||
ok(run("$scstadmin -list_handler"), $result);
|
||||
|
||||
$result = <<'EOS';
|
||||
|
||||
Collecting current configuration: done.
|
||||
|
||||
Handler Device
|
||||
-----------------------
|
||||
vcdrom -
|
||||
vdisk_blockio -
|
||||
vdisk_fileio disk0
|
||||
disk1
|
||||
vdisk_nullio nodev
|
||||
|
||||
All done.
|
||||
EOS
|
||||
ok(run("$scstadmin -list_device"), $result);
|
||||
|
||||
$result = <<'EOS';
|
||||
|
||||
Collecting current configuration: done.
|
||||
|
||||
Attribute Value Writable KEY
|
||||
------------------------------------------------------------------------
|
||||
filename /dev/scstadmin-regression-test-vdisk Yes Yes
|
||||
read_only 1 No Yes
|
||||
size 1048576 No Yes
|
||||
|
||||
All done.
|
||||
EOS
|
||||
ok(run("$scstadmin -list_device disk0"), $result);
|
||||
|
||||
$result = <<'EOS';
|
||||
|
||||
Collecting current configuration: done.
|
||||
|
||||
Device Group
|
||||
------------
|
||||
dgroup1
|
||||
|
||||
dgroup2
|
||||
|
||||
|
||||
All done.
|
||||
EOS
|
||||
ok(run("$scstadmin -list_dgrp"), $result);
|
||||
|
||||
$result = "exit code 256";
|
||||
ok(run("$scstadmin -list_tgrp tgrp"), $result);
|
||||
|
||||
$result = <<'EOS';
|
||||
|
||||
Collecting current configuration: done.
|
||||
|
||||
Driver
|
||||
------------
|
||||
copy_manager
|
||||
ib_srpt
|
||||
iscsi
|
||||
scst_local
|
||||
|
||||
All done.
|
||||
EOS
|
||||
ok(run("$scstadmin -list_driver"), $result);
|
||||
$result = <<'EOS';
|
||||
|
||||
Collecting current configuration: done.
|
||||
|
||||
Driver Target
|
||||
-----------------------------
|
||||
copy_manager copy_manager_tgt
|
||||
scst_local local
|
||||
|
||||
All done.
|
||||
EOS
|
||||
ok(run("$scstadmin -list_target"), $result);
|
||||
|
||||
$result = <<'EOS';
|
||||
|
||||
Collecting current configuration: done.
|
||||
|
||||
Driver: copy_manager
|
||||
Target: copy_manager_tgt
|
||||
|
||||
Assigned LUNs:
|
||||
|
||||
LUN Device
|
||||
----------
|
||||
10 disk1
|
||||
8 nodev
|
||||
9 disk0
|
||||
|
||||
Driver: scst_local
|
||||
Target: local
|
||||
|
||||
Assigned LUNs:
|
||||
|
||||
LUN Device
|
||||
----------
|
||||
0 nodev
|
||||
|
||||
Group: ig
|
||||
|
||||
Assigned LUNs:
|
||||
|
||||
LUN Device
|
||||
----------
|
||||
0 disk0
|
||||
1 disk1
|
||||
|
||||
Assigned Initiators:
|
||||
|
||||
Initiator
|
||||
----
|
||||
ini1
|
||||
ini2
|
||||
|
||||
|
||||
|
||||
All done.
|
||||
EOS
|
||||
ok(run("$scstadmin -list_group"), $result);
|
||||
|
||||
|
||||
$result = <<'EOS';
|
||||
|
||||
Collecting current configuration: done.
|
||||
|
||||
Attribute Value Writable KEY
|
||||
-----------------------------------------
|
||||
(none)
|
||||
|
||||
All done.
|
||||
EOS
|
||||
ok(run("$scstadmin -list_scst_attr"), $result);
|
||||
$result = <<'EOS';
|
||||
|
||||
Collecting current configuration: done.
|
||||
|
||||
Attribute Value Writable KEY
|
||||
-----------------------------------------
|
||||
(none)
|
||||
|
||||
Device CREATE attributes available
|
||||
----------------------------------
|
||||
tst
|
||||
|
||||
All done.
|
||||
EOS
|
||||
ok(run("$scstadmin -list_hnd_attr vcdrom"), $result);
|
||||
|
||||
$result = <<'EOS';
|
||||
|
||||
Collecting current configuration: done.
|
||||
|
||||
Attribute Value Writable KEY
|
||||
-----------------------------------------
|
||||
(none)
|
||||
|
||||
Device CREATE attributes available
|
||||
----------------------------------
|
||||
active
|
||||
bind_alua_state
|
||||
blocksize
|
||||
cluster_mode
|
||||
dif_filename
|
||||
dif_mode
|
||||
dif_static_app_tag
|
||||
dif_type
|
||||
filename
|
||||
numa_node_id
|
||||
nv_cache
|
||||
read_only
|
||||
removable
|
||||
rotational
|
||||
thin_provisioned
|
||||
tst
|
||||
write_through
|
||||
|
||||
All done.
|
||||
EOS
|
||||
ok(run("$scstadmin -list_hnd_attr vdisk_blockio"), $result);
|
||||
|
||||
$result = <<'EOS';
|
||||
|
||||
Collecting current configuration: done.
|
||||
|
||||
Attribute Value Writable KEY
|
||||
-----------------------------------------
|
||||
(none)
|
||||
|
||||
Device CREATE attributes available
|
||||
----------------------------------
|
||||
async
|
||||
blocksize
|
||||
cluster_mode
|
||||
dif_filename
|
||||
dif_mode
|
||||
dif_static_app_tag
|
||||
dif_type
|
||||
filename
|
||||
numa_node_id
|
||||
nv_cache
|
||||
o_direct
|
||||
read_only
|
||||
removable
|
||||
rotational
|
||||
thin_provisioned
|
||||
tst
|
||||
write_through
|
||||
zero_copy
|
||||
|
||||
All done.
|
||||
EOS
|
||||
ok(run("$scstadmin -list_hnd_attr vdisk_fileio"), $result);
|
||||
$result = <<'EOS';
|
||||
|
||||
Collecting current configuration: done.
|
||||
|
||||
Attribute Value Writable KEY
|
||||
-----------------------------------------
|
||||
(none)
|
||||
|
||||
Device CREATE attributes available
|
||||
----------------------------------
|
||||
blocksize
|
||||
cluster_mode
|
||||
dif_mode
|
||||
dif_static_app_tag
|
||||
dif_type
|
||||
dummy
|
||||
numa_node_id
|
||||
read_only
|
||||
removable
|
||||
rotational
|
||||
size
|
||||
size_mb
|
||||
tst
|
||||
|
||||
All done.
|
||||
EOS
|
||||
ok(run("$scstadmin -list_hnd_attr vdisk_nullio"), $result);
|
||||
|
||||
$result = "exit code 256";
|
||||
ok(run("$scstadmin -list_dev_attr disk00"), $result);
|
||||
ok(run("$scstadmin -list_dev_attr disk01"), $result);
|
||||
|
||||
$result = <<'EOS';
|
||||
|
||||
Collecting current configuration: done.
|
||||
|
||||
Attribute Value Writable KEY
|
||||
-----------------------------------------
|
||||
(none)
|
||||
|
||||
All done.
|
||||
EOS
|
||||
ok(run("$scstadmin -list_drv_attr ib_srpt"), $result);
|
||||
|
||||
$result = "exit code 256";
|
||||
ok(run("$scstadmin -list_tgrp_attr"), $result);
|
||||
ok(run("$scstadmin -list_tgtt_attr"), $result);
|
||||
ok(run("$scstadmin -list_tgt_attr local"), $result);
|
||||
ok(run("$scstadmin -list_grp_attr ig"), $result);
|
||||
ok(run("$scstadmin -list_lun_attr 0"), $result);
|
||||
ok(run("$scstadmin -list_lun_attr 1"), $result);
|
||||
ok(run("$scstadmin -list_init_attr ini1"), $result);
|
||||
ok(run("$scstadmin -list_init_attr ini2"), $result);
|
||||
$result = <<'EOS';
|
||||
|
||||
Collecting current configuration: done.
|
||||
|
||||
Driver/Target: copy_manager/copy_manager_tgt
|
||||
|
||||
Session: copy_manager_sess
|
||||
|
||||
Attribute Value Writable KEY
|
||||
---------------------------------------------------------------------
|
||||
active_commands 0 Yes No
|
||||
bidi_cmd_count 0 Yes No
|
||||
bidi_io_count_kb 0 Yes No
|
||||
bidi_unaligned_cmd_count 0 Yes No
|
||||
commands 0 Yes No
|
||||
dif_checks_failed app ref guard Yes No
|
||||
initiator_name copy_manager_sess Yes No
|
||||
none_cmd_count 0 Yes No
|
||||
read_cmd_count 11 Yes No
|
||||
read_io_count_kb 44 Yes No
|
||||
read_unaligned_cmd_count 0 Yes No
|
||||
unknown_cmd_count 0 Yes No
|
||||
write_cmd_count 0 Yes No
|
||||
write_io_count_kb 0 Yes No
|
||||
write_unaligned_cmd_count 0 Yes No
|
||||
|
||||
Driver/Target: scst_local/local
|
||||
|
||||
(no sessions)
|
||||
|
||||
|
||||
All done.
|
||||
EOS
|
||||
ok(run("$scstadmin -list_sessions"), $result);
|
||||
}
|
||||
|
||||
my $_DEBUG_ = 0;
|
||||
if ($_DEBUG_) {
|
||||
$redirect = ">>$redirect_file";
|
||||
@@ -104,4 +466,6 @@ setup($SCST);
|
||||
|
||||
attributeTest(File::Spec->catfile($testdir, "07-result.conf"));
|
||||
|
||||
listTest();
|
||||
|
||||
teardown();
|
||||
|
||||
Reference in New Issue
Block a user