Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Apr 2017 23:30:03 +0000 (UTC)
From:      Ngie Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r317309 - head/tools/regression/geom_gpt
Message-ID:  <201704222330.v3MNU3el046280@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Sat Apr 22 23:30:02 2017
New Revision: 317309
URL: https://svnweb.freebsd.org/changeset/base/317309

Log:
  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

Modified:
  head/tools/regression/geom_gpt/gctl_test.t

Modified: head/tools/regression/geom_gpt/gctl_test.t
==============================================================================
--- head/tools/regression/geom_gpt/gctl_test.t	Sat Apr 22 23:27:40 2017	(r317308)
+++ head/tools/regression/geom_gpt/gctl_test.t	Sat Apr 22 23:30:02 2017	(r317309)
@@ -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");



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201704222330.v3MNU3el046280>