Subject: bug#12322: coreutils-8.1{8, 9} with /etc/mtab as real file, df/total-unprocessed fail, df/no-mtab-status is skipped

From: [email-masked]
Date: Mon, 3 Sep 2012 00:07:26 +0200 (CEST)

----- Mail original -----
> De: "Bernhard Voelker" <[email-masked]>
> À: "g esp" <[email-masked]>
> Cc: [email-masked]
> Envoyé: Dimanche 2 Septembre 2012 11:05:28
> Objet: bug#12322: coreutils-8.1{8, 9} with /etc/mtab as real file,	df/total-unprocessed fail, df/no-mtab-status is
> skipped
> 
> On 09/01/2012 05:49 PM, [email-masked] wrote:
> > Maybe both tests could check if /etc/mtab is a symlink and adjust
> > df parameter to not fail?
> > 
> > I made this change on the tests to see if that work
> > 	cd $(DIR_APP) && sed -i "s/ '\.' / /" tests/df/total-unprocessed
> > 	cd $(DIR_APP) && sed -i "s/df ||/df '.' ||/"
> > 	tests/df/no-mtab-status
> > 
> > With /etc/mtab as a real file, both tests passed
> 
> Thank you for the report.
> 
> To make it clear, your change suggests this:
> 
> diff --git a/tests/df/no-mtab-status.sh b/tests/df/no-mtab-status.sh
> index e434f5f..6d19f8b 100755
> --- a/tests/df/no-mtab-status.sh
> +++ b/tests/df/no-mtab-status.sh
> @@ -20,7 +20,7 @@
>  . "${srcdir=.}/init.sh"; path_prepend_ ../src
>  print_ver_ df
> 
> -df || skip_ "df fails"
> +df '.' || skip_ "df fails"
> 
>  # Simulate "mtab" failure.
>  cat > k.c <<'EOF' || framework_failure_
> diff --git a/tests/df/total-unprocessed.sh
> b/tests/df/total-unprocessed.sh
> index aa49836..dbe552e5 100755
> --- a/tests/df/total-unprocessed.sh
> +++ b/tests/df/total-unprocessed.sh
> @@ -28,7 +28,7 @@ EOF
>  # The following simply finds no match for the combination
>  # of the options --local and FS-type nfs together with the
>  # argument ".". It must exit non-Zero nonetheless.
> -df --local -t nfs --total '.' 2>out && fail=1
> +df --local -t nfs --total 2>out && fail=1
>  compare exp out || fail=1
> 
>  cat <<\EOF > exp || framework_failure_
> 
> 
Yes that should fix df/total-unprocessed.sh and df/total-unprocessed.sh in both /etc/mtab cases.

> Additionally to a missing mtab, there is another reason which
> can make df fail: an inaccessible mount point, e.g. when there's
> a file system mounted on /root/backup which is not accessible
> by a normal user.
> 
> The above tests provoke certain error conditions:
> no-mtab-status tests df's behaviour when the mtab cannot be read;
> total-unprocessed tests that df exits non-Zero and writes an error
> message when --total is used but no file system has been processed.
> 
> While your change doesn't make the tests skip under certain
> conditions, it well may trigger a different than the intended
> failure. E.g. in no-mtab-status, there's a test which is supposed
> to fail because we simulated the mtab failure:
> 
>   # These tests are supposed to fail:
>   LD_PRELOAD=./k.so df && fail=1
> 
> That command - a simple df without arguments - could also fail due
> to another reason (see above), so the failure may shadow the expected
> failure from (simulated) missing mtab.
> 
> That said, I'd rather skip a test that cannot otherwise guarantee
> why it fails/succeeds.
> 
> Have a nice day,
> Berny
> 
Yes here df command fail in real /etc/mtab case, so even if this test will not trigger for the intented reason, test will not fail.

Similary total-verify.sh may be fixed to pass in /etc/mtab real file case with this patch (hope nothing will be wrapped)
diff --git a/tests/df/total-verify.sh b/tests/df/total-verify.sh
index 948b002..317cb75 100755
--- a/tests/df/total-verify.sh
+++ b/tests/df/total-verify.sh
@@ -20,7 +20,7 @@
 print_ver_ df
 require_perl_

-df || skip_ "df fails"
+df '.' || skip_ "df fails"

 cat <<\EOF > check-df || framework_failure_
 my ($total, $used, $avail) = (0, 0, 0);
@@ -53,9 +53,9 @@ EOF

 # Use --block-size=512 to keep df from printing rounded-to-kilobyte
 # numbers which wouldn't necessarily add up to the displayed total.
-df --total -P --block-size=512 > space || framework_failure_
+df --total -P --block-size=512 '.' > space || framework_failure_
 cat space  # this helps when debugging any test failure
-df --total -i -P               > inode || framework_failure_
+df --total -i -P               '.' > inode || framework_failure_
 cat inode

 $PERL check-df space || fail=1

Gilles