Subject: 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: Sat, 1 Sep 2012 17:49:22 +0200 (CEST)

On the 8.0 era, I had to switch from /etc/mtab symlinked to /proc/mounts to a real /etc/mtab or one cu test fail to umount

Now depending of /etc/mtab nature, I see 2 df tests behaving differently on my linux chroot used to build

When not using /etc/mtab as symlink
df '.' does not report the intended 'no file systems processed' for total-unprocessed test and that test fail
but df with no parameter report 'no file systems processed' and an error, so df/no-mtab-status is skipped

When using /etc/mtab as symlink to /proc/mounts
df '.' report the intended 'no file systems processed' for total-unprocessed script and test pass
but df with no parameter can't read mount point existing out of chroot and df/no-mtab-status is skipped again

The log that FAIL with real /etc/mtab is as follow

FAIL: df/total-unprocessed
==========================

++ initial_cwd_=/usr/src/coreutils-8.19/tests
++ fail=0
+++ testdir_prefix_
+++ printf gt
++ pfx_=gt
+++ mktempd_ /usr/src/coreutils-8.19/tests gt-total-unprocessed.XXXX
+++ case $# in
+++ destdir_=/usr/src/coreutils-8.19/tests
+++ template_=gt-total-unprocessed.XXXX
+++ MAX_TRIES_=4
+++ case $destdir_ in
+++ case $template_ in
++++ unset TMPDIR
+++ d=/usr/src/coreutils-8.19/tests/gt-total-unprocessed.CId2
+++ case $d in
+++ test -d /usr/src/coreutils-8.19/tests/gt-total-unprocessed.CId2
++++ tr S -
++++ ls -dgo /usr/src/coreutils-8.19/tests/gt-total-unprocessed.CId2
+++ perms='drwx------ 2 4096 Aug 29 00:17 /usr/src/coreutils-8.19/tests/gt-total-unprocessed.CId2'
+++ case $perms in
+++ test 0 = 0
+++ echo /usr/src/coreutils-8.19/tests/gt-total-unprocessed.CId2
+++ return
++ test_dir_=/usr/src/coreutils-8.19/tests/gt-total-unprocessed.CId2
++ cd /usr/src/coreutils-8.19/tests/gt-total-unprocessed.CId2
++ gl_init_sh_nl_='
'
++ IFS=' 	
'
++ for sig_ in 1 2 3 13 15
+++ expr 1 + 128
++ eval 'trap '\''Exit 129'\'' 1'
+++ trap 'Exit 129' 1
++ for sig_ in 1 2 3 13 15
+++ expr 2 + 128
++ eval 'trap '\''Exit 130'\'' 2'
+++ trap 'Exit 130' 2
++ for sig_ in 1 2 3 13 15
+++ expr 3 + 128
++ eval 'trap '\''Exit 131'\'' 3'
+++ trap 'Exit 131' 3
++ for sig_ in 1 2 3 13 15
+++ expr 13 + 128
++ eval 'trap '\''Exit 141'\'' 13'
+++ trap 'Exit 141' 13
++ for sig_ in 1 2 3 13 15
+++ expr 15 + 128
++ eval 'trap '\''Exit 143'\'' 15'
+++ trap 'Exit 143' 15
++ trap remove_tmp_ 0
+ path_prepend_ ../src
+ test 1 '!=' 0
+ path_dir_=../src
+ case $path_dir_ in
+ abs_path_dir_=/usr/src/coreutils-8.19/tests/../src
+ case $abs_path_dir_ in
+ PATH=/usr/src/coreutils-8.19/tests/../src:/usr/src/coreutils-8.19/src:/bin:/usr/bin:/sbin:/usr/sbin
+ create_exe_shims_ /usr/src/coreutils-8.19/tests/../src
+ case $EXEEXT in
+ return 0
+ shift
+ test 0 '!=' 0
+ export PATH
+ print_ver_ df
+ test yes = yes
+ local i
+ for i in '$*'
+ env df --version
df (GNU coreutils) 8.19
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Torbjorn Granlund, David MacKenzie, and Paul Eggert.
+ require_mount_list_
+ local 'mount_list_fail=cannot read table of mounted file systems'
+ grep -F 'cannot read table of mounted file systems'
+ df
+ cat
+ df --local -t nfs --total .
Filesystem     1K-blocks     Used Available Use% Mounted on
-               19228308 16776508   1475048  92% /
total           19228308 16776508   1475048  92%
+ fail=1
+ compare exp out
+ compare_dev_null_ exp out
+ test 2 = 2
+ test xexp = x/dev/null
+ test xout = x/dev/null
+ return 2
+ case $? in
+ compare_ exp out
+ diff -u exp out
--- exp	2012-08-29 00:17:31.000000000 +0200
+++ out	2012-08-29 00:17:31.000000000 +0200
@@ -1 +0,0 @@
-df: no file systems processed
+ fail=1
+ cat
+ df --total _does_not_exist_
+ compare exp out
+ compare_dev_null_ exp out
+ test 2 = 2
+ test xexp = x/dev/null
+ test xout = x/dev/null
+ return 2
+ case $? in
+ compare_ exp out
+ diff -u exp out
+ Exit 1
+ set +e
+ exit 1
+ exit 1
+ remove_tmp_
+ __st=1
+ cleanup_
+ :
+ cd /usr/src/coreutils-8.19/tests
+ chmod -R u+rwx /usr/src/coreutils-8.19/tests/gt-total-unprocessed.CId2
+ rm -rf /usr/src/coreutils-8.19/tests/gt-total-unprocessed.CId2
+ exit 1

With real /etc/mtab, (on my chroot, there is many mount --bind before to enter the chroot)
[chroot-i486] root:/$ mount
/dev on /dev type none (rw)
[chroot-i486] root:/$ df
df: no file systems processed
[chroot-i486] root:/$ ln -sf /proc/mounts /etc/mtab
[chroot-i486] root:/$ mount
rootfs on / type rootfs (rw)
none on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
none on /proc type proc (rw,nosuid,nodev,noexec,relatime)
none on /dev type devtmpfs (rw,relatime,size=512760k,nr_inodes=128190,mode=755)
none on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
/dev/disk/by-uuid/7a235d64-5d04-41ac-a959-70465eb74fc8 on / type ext3 (rw,relatime,errors=remount-ro,data=ordered)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,relatime,mode=755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,relatime)
...
[chroot-i486] root:/$ df
df: '/lib/init/rw': No such file or directory
Filesystem     1K-blocks     Used Available Use% Mounted on
rootfs          19228308 15796388   2455168  87% /
none              512760      156    512604   1% /dev
/dev/sda3       19228308 15796388   2455168  87% /
tmpfs             517208        0    517208   0% /dev/shm
/dev/sda1       19228308 15796388   2455168  87% /boot
none              512760      156    512604   1% /dev
tmpfs             517208        0    517208   0% /dev/shm
...

So df/no-mtab-status is skipped in both case because df returned an error while reading /lib/init/rw that is out of chroot.

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

Gilles