gctl_test.t: improve error reporting with mdcfg and mount directives

If the commands had failed previously, it would press on and result in a
series of cascading failures. Fail early and continue on to the next case
instead of executing additional commands after a previously failed series
of steps.

MFC after:      5 weeks
Sponsored by:   Dell EMC Isilon
This commit is contained in:
Enji Cooper 2017-04-22 23:30:02 +00:00
parent 9940eaaa17
commit d1f57d5900

View File

@ -161,13 +161,15 @@ foreach my $key (sort keys %steps) {
$res =~ s/%dev%/$dev/g;
if ($action =~ "^gctl") {
my $errmsg = "";
system("$cmd $verbose $args | tee $out 2>&1");
$st = `tail -1 $out`;
if ($st =~ "^$res") {
print "ok $nr \# gctl($key)\n";
} else {
print "not ok $nr \# gctl($key) - $st\n";
chomp($st = `tail -1 $out`);
if ($st ne $res) {
$errmsg = "\"$st\" (actual) != \"$res\" (expected)\n";
}
printf("%sok $nr \# gctl($key)%s\n",
($errmsg eq "" ? "" : "not "),
($errmsg eq "" ? "" : " - $errmsg"));
unlink $out;
} elsif ($action =~ "^mdcfg") {
if ($args =~ "^create") {
@ -194,10 +196,18 @@ foreach my $key (sort keys %steps) {
}
unlink $out;
} elsif ($action =~ "^mount") {
system("mkdir $mntpt_prefix-$args");
system("newfs $args");
system("mount -t ufs /dev/$args $mntpt_prefix-$args");
print "ok $nr \# mount($key)\n";
my $errmsg = "";
mkdir("$mntpt_prefix-$args");
if (system("newfs /dev/$args") == 0) {
if (system("mount /dev/$args $mntpt_prefix-$args") != 0) {
$errmsg = "mount failed";
}
} else {
$errmsg = "newfs failed";
}
printf("%sok $nr # mount($key)%s\n",
($errmsg eq "" ? "" : "not "),
($errmsg eq "" ? "" : " - $errmsg"));
} elsif ($action =~ "^umount") {
system("umount $mntpt_prefix-$args");
system("rmdir $mntpt_prefix-$args");