Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Oct 2017 05:58:33 +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: r324478 - in head: sbin/growfs/tests tests/sys/geom/class/eli
Message-ID:  <201710100558.v9A5wXkR003969@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Tue Oct 10 05:58:33 2017
New Revision: 324478
URL: https://svnweb.freebsd.org/changeset/base/324478

Log:
  Check the exit code from fsck_ffs instead of relying on MODIFIED being in the output
  
  ^/head@r323923 changed when MODIFIED is printed at exit. It's better to follow the
  documented way of determining whether or not a filesystem is clean per fsck_ffs, i.e.,
  ensure that the exit code is either 0 or 7.
  
  The pass/fail determination is brittle prior to this commit, and ^/head@r323923 made
  the issue apparent -- thus this needs to be fixed independent of ^/head@r323923.
  
  PR:		222780
  MFC after:	1 week
  MFC with:	r323923
  Reported by:	Jenkins

Modified:
  head/sbin/growfs/tests/legacy_test.pl
  head/tests/sys/geom/class/eli/resize_test.sh

Modified: head/sbin/growfs/tests/legacy_test.pl
==============================================================================
--- head/sbin/growfs/tests/legacy_test.pl	Tue Oct 10 05:52:28 2017	(r324477)
+++ head/sbin/growfs/tests/legacy_test.pl	Tue Oct 10 05:58:33 2017	(r324478)
@@ -2,6 +2,7 @@
 
 use strict;
 use warnings;
+use POSIX;
 use Test::More tests => 19;
 use Fcntl qw(:DEFAULT :seek);
 
@@ -11,6 +12,22 @@ use constant BLKS_PER_MB => 2048;
 my $unit;
 END { system "mdconfig -du$unit" if defined $unit };
 
+sub fsck_md {
+    my ($is_clean, $md);
+
+    $md = shift;
+
+    chomp(my @fsck_output = `fsck_ffs -Ffy ${md}a`);
+    $is_clean = WIFEXITED($?) &&
+    	(WEXITSTATUS($?) == 0 || WEXITSTATUS($?) == 7);
+    ok($is_clean, "checking ${md}a's filesystem");
+    if ($is_clean) {
+	diag "filesystem reported clean";
+    } else {
+	diag "filesystem not reported clean: " . join("\n", @fsck_output);
+    }
+}
+
 sub setsize {
     my ($partszMB, $unitszMB) = @_;
 
@@ -46,9 +63,8 @@ SKIP: {
 	    ok(setsize(10, 40), "Sized ${md}a to 10m");
 	    system "newfs -O $type -U ${md}a >/dev/null";
 	    is($?, 0, "Initialised the filesystem on ${md}a as UFS$type");
-	    chomp(my @out = `fsck -tufs -y ${md}a`);
-	    ok(!grep(/MODIFIED/, @out), "fsck says ${md}a is clean, " .
-		scalar(@out) . " lines of output");
+
+	    fsck_md($md);
 	}
 
 	extend20_zeroed: {
@@ -62,9 +78,7 @@ SKIP: {
 	    fill(30 * BLKS_PER_MB - $unallocated, $unallocated, chr(0))
 		if $unallocated;
 
-	    chomp(my @out = `fsck -tufs -y ${md}a`);
-	    ok(!grep(/MODIFIED/, @out), "fsck says ${md}a is clean, " .
-		scalar(@out) . " lines of output");
+	    fsck_md($md);
 	}
 
 	extend30_garbaged: {
@@ -78,9 +92,7 @@ SKIP: {
 	    fill(30 * BLKS_PER_MB - $unallocated, $unallocated, chr(0))
 		if $unallocated;
 
-	    chomp(my @out = `fsck -tufs -y ${md}a`);
-	    ok(!grep(/MODIFIED/, @out), "fsck says ${md}a is clean, " .
-		scalar(@out) . " lines of output");
+	    fsck_md($md);
 	}
     }
 

Modified: head/tests/sys/geom/class/eli/resize_test.sh
==============================================================================
--- head/tests/sys/geom/class/eli/resize_test.sh	Tue Oct 10 05:52:28 2017	(r324477)
+++ head/tests/sys/geom/class/eli/resize_test.sh	Tue Oct 10 05:58:33 2017	(r324478)
@@ -12,6 +12,19 @@ md=$(mdconfig -s40m) || exit 1
 unit=${md#md}
 i=1
 
+fsck_md()
+{
+	local is_clean
+
+	out=$(fsck_ffs -Ffy ${md}a.eli)
+	if [ $? -eq 0 -o $? -eq 7 ]; then
+		echo "ok $i - fsck says ${md}a.eli is clean"
+	else
+		echo "not ok $i - fsck says ${md}a.eli is dirty"
+	fi
+	i=$((i + 1))
+}
+
 setsize() {
     partszMB=$1 unitszMB=$2
 
@@ -38,13 +51,8 @@ i=$((i + 1))
 newfs -U ${md}a.eli >/dev/null || echo -n "not "
 echo ok $i - "Initialised the filesystem on ${md}a.eli"
 i=$((i + 1))
-out=$(fsck -tufs -y ${md}a.eli)
-echo "$out" | fgrep -q MODIFIED && echo -n "not "
-echo ok $i - "fsck says ${md}a.eli is clean," $(echo $(echo "$out" | wc -l)) \
-    "lines of output"
-i=$((i + 1))
+fsck_md
 
-
 # Doing a backup, resize & restore must be forced (with -f) as geli
 # verifies that the provider size in the metadata matches the consumer.
 
@@ -78,13 +86,8 @@ growfs -y ${md}a.eli >/dev/null || echo -n "not "
 echo ok $i - "Extended the filesystem on ${md}a.eli"
 i=$((i + 1))
 
-out=$(fsck -tufs -y ${md}a.eli)
-echo "$out" | fgrep -q MODIFIED && echo -n "not "
-echo ok $i - "fsck says ${md}a.eli is clean," $(echo $(echo "$out" | wc -l)) \
-    "lines of output"
-i=$((i + 1))
+fsck_md
 
-
 # Now do the resize properly
 
 geli detach ${md}a.eli || echo -n "not "
@@ -110,11 +113,7 @@ growfs -y ${md}a.eli >/dev/null || echo -n "not "
 echo ok $i - "Extended the filesystem on ${md}a.eli"
 i=$((i + 1))
 
-out=$(fsck -tufs -y ${md}a.eli)
-echo "$out" | fgrep -q MODIFIED && echo -n "not "
-echo ok $i - "fsck says ${md}a.eli is clean," $(echo $(echo "$out" | wc -l)) \
-    "lines of output"
-i=$((i + 1))
+fsck_md
 
 geli detach ${md}a.eli
 gpart destroy -F $md >/dev/null



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