summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2017-10-17 15:52:02 +0000
committerngie <ngie@FreeBSD.org>2017-10-17 15:52:02 +0000
commit2dfbb409bb2b3a1f2b28d3c853040a3cf9dccef9 (patch)
tree1972b5767aa7acfec1b250e2a9e3ad18c8511196
parentb8515f8f387edbf541e0be5a7b346ad69e2db1ea (diff)
downloadFreeBSD-src-2dfbb409bb2b3a1f2b28d3c853040a3cf9dccef9.zip
FreeBSD-src-2dfbb409bb2b3a1f2b28d3c853040a3cf9dccef9.tar.gz
MFC r324478:
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 with: r323923
-rwxr-xr-xsbin/growfs/tests/legacy_test.pl30
-rw-r--r--tests/sys/geom/class/eli/resize_test.sh33
2 files changed, 37 insertions, 26 deletions
diff --git a/sbin/growfs/tests/legacy_test.pl b/sbin/growfs/tests/legacy_test.pl
index 7316951..814617e 100755
--- a/sbin/growfs/tests/legacy_test.pl
+++ b/sbin/growfs/tests/legacy_test.pl
@@ -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);
}
}
diff --git a/tests/sys/geom/class/eli/resize_test.sh b/tests/sys/geom/class/eli/resize_test.sh
index 67d6291..e5ce6fd 100644
--- a/tests/sys/geom/class/eli/resize_test.sh
+++ b/tests/sys/geom/class/eli/resize_test.sh
@@ -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,12 +51,7 @@ 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,12 +86,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
# Now do the resize properly
@@ -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
OpenPOWER on IntegriCloud