diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t new file mode 100644 index 000000000..411be7a4e --- /dev/null +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t @@ -0,0 +1,66 @@ +#!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 = map { $_ => 1 } @{$SCST->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")); + diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/after-restore.conf b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/after-restore.conf new file mode 100644 index 000000000..9bcda73e5 --- /dev/null +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/after-restore.conf @@ -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 + } + } +} + diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/to-be-restored.conf b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/to-be-restored.conf new file mode 100644 index 000000000..c5c3d6320 --- /dev/null +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/to-be-restored.conf @@ -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 + } + } +} +