From owner-svn-src-head@freebsd.org Tue Oct 10 05:58:34 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BF8E2E25340; Tue, 10 Oct 2017 05:58:34 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 985486DA88; Tue, 10 Oct 2017 05:58:34 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9A5wXHV003971; Tue, 10 Oct 2017 05:58:33 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9A5wXkR003969; Tue, 10 Oct 2017 05:58:33 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201710100558.v9A5wXkR003969@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Tue, 10 Oct 2017 05:58:33 +0000 (UTC) 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 X-SVN-Group: head X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: in head: sbin/growfs/tests tests/sys/geom/class/eli X-SVN-Commit-Revision: 324478 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Oct 2017 05:58:34 -0000 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