summaryrefslogtreecommitdiff
path: root/tests/df
AgeCommit message (Collapse)Author
2017-01-01maint: update all copyright year number rangesPádraig Brady
Run "make update-copyright" and then... * gnulib: Update to latest with copyright year adjusted. * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Likewise. * tests/sample-test: Adjust to use the single most recent year.
2016-04-26tests: avoid false failure when df lists no root file systemPádraig Brady
* tests/df/skip-duplicates.sh: Skip the test when there is no '/' entry listed by df, which was seen in certain chroot setups.
2016-01-16tests: show mount list on failure for df testsPádraig Brady
* init.cfg (dump_mount_list_): A new function to output the system mount list. * tests/df/df-symlink.sh: Call dump_mount_list_ upon failure. * tests/df/over-mount-device.sh: Likewise. * tests/df/problematic-chars.sh: Likewise. * tests/df/skip-rootfs.sh: Likewise. * tests/df/total-verify.sh: Likewise. * tests/df/unreadable.sh: Likewise.
2016-01-16tests: avoid false failure with BTRFS subvolumesPádraig Brady
* tests/df/df-symlink.sh: Only check the symmetry of the source <-> target lookup, when the source is only mounted once, which isn't the case if '.' is a BTRFS subvolume for example. Reported by Assaf Gordon on a default OpenSUSE 42.1 install.
2016-01-01maint: update all copyright year number rangesPádraig Brady
Run "make update-copyright" and then... * gnulib: Update to latest with copyright year adjusted. * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Likewise. * tests/sample-test: Adjust to use the single most recent year.
2015-11-04all: avoid quoting file names when possiblePádraig Brady
Quote file names using the "shell-escape" or "shell-escape-always" methods, which quote as appropriate for most shells, and better support copy and paste of presented names. The "always" variant is used when the file name is embedded in an error message with surrounding spaces. * cfg.mk (sc_error_shell_quotes): A new syntax check rule to suggest quotef() where appropriate. (sc_error_shell_always_quotes): Likewise for quoteaf(). * src/system.h (quotef): A new define to apply shell quoting when needed. I.E. when shell character or ':' is present. (quoteaf): Likewise, but always quote. * src/*.c: Use quotef() and quoteaf() rather than quote() where appropriate. * tests/: Adjust accordingly.
2015-06-25tests: avoid false failures with LD_PRELOAD=libasan.so.2Pádraig Brady
The LD_PRELOAD checks by -fsanitize=address are overly strict: https://groups.google.com/forum/#!topic/address-sanitizer/jEvOJgkDqQk A workaround is to first export LD_PRELOAD=libasan.so.2 The tests below are adjusted so that workaround is not discarded. * tests/cp/no-ctx.sh: Append to $LD_PRELOAD. * tests/df/no-mtab-status.sh: Likewise. * tests/df/skip-duplicates.sh: Likewise. * tests/ls/getxattr-speedup.sh: Likewise. * tests/rm/r-root.sh: Likewise. * tests/cp/nfs-removal-race.sh: Likewise. Also check that LD_PRELOAD is effective to aid future maintainability and avoid false failure if libasan.so.2 is not preloaded.
2015-05-22tests: df-output: accept multiple spaces in headerAssaf Gordon
* tests/df/df-output.sh: Allow for multiple spaces in the header line of 'df', resulting from alignment with disk sizes >= 10TB.
2015-05-19tests: fix non POSIX constructs causing failures with dashPádraig Brady
* tests/cp/no-ctx.sh: Scope of `var=val func` is inconsistent across shells, so avoid that construct with functions. * tests/df/no-mtab-status.sh: Likewise. * tests/tail-2/inotify-race.sh: `read` needs an argument. * tests/tail-2/inotify-race2.sh: Likewise.
2015-04-30tests: don't skip df tests with /proc/self/mountinfoPádraig Brady
* tests/df/no-mtab-status.sh: getmntent is no longer called when /proc/self/mountinfo is present, thus causing the test to be skipped. Therefore wrap fopen() to ignore mountinfo, and use the test genmntent table instead. * tests/df/skip-duplicates.sh: Likewise.
2015-04-13df: fix --local hanging with inaccessible remote mountsPádraig Brady
* src/df.c (filter_mount_list): With -l, avoid stating remote mounts. * init.cfg: Avoid test hangs with inaccessible remote mounts. * tests/df/no-mtab-status.sh: Skip with inaccessible remote mounts. * tests/df/skip-rootfs.sh: Likewise. * tests/df/total-verify.sh: Likewise. * NEWS: Mention the bug fix. Reported at http://bugzilla.redhat.com/1199679
2015-03-27tests: fix false test failure with df on Debian/kFreeBSDAssaf Gordon
* tests/fs/skip-duplicates.sh: On this platform .mnt_opts is significant so define to empty to avoid a NULL deref in read_file_system_list(). Fixes http://bugs.gnu.org/20210
2015-01-31doc,maint: fix use of "i.e." in documentation and commentsBernhard Voelker
To align with all other places (and correct grammar), change all upper-case "I.E." to "I.e.". Furthermore, ensure that "i.e." is followed by a comma. Finally, ensure to use a double-space before "I.e.," at the beginning of a sentence. The following was used to change all offending uses (apart from old ChangeLog files): $ git grep -liF 'i.e.' \ | xargs sed -i \ -e 's/I\.E\./I.e./g' \ -e 's/\. \(I\.e\.\)/. \1/g' \ -e 's/\([Ii]\.e\.\)\( \)/\1,\2/g' \ -e 's/\([Ii]\.e\.\)$/\1,/g' * cfg.mk (sc_prohibit_uppercase_id_est): Add new rule. (sc_ensure_double_space_after_dot_before_id_est): Likewise. (sc_ensure_comma_after_id_est): Likewise. (old_NEWS_hash): Refresh hash via "make update-NEWS-hash". * NEWS: Change use of "id est" abbreviation via the above command. * README: Likewise. * README-prereq: Likewise. * doc/coreutils.texi: Likewise. * gl/lib/rand-isaac.c: Likewise. * gl/lib/tempname.c.diff: Likewise. * man/stdbuf.x: Likewise. * src/cat.c: Likewise. * src/copy.c: Likewise. * src/copy.h: Likewise. * src/cp.c: Likewise. * src/cut.c: Likewise. * src/dd.c: Likewise. * src/df.c: Likewise. * src/fiemap.h: Likewise. * src/longlong.h: Likewise. * src/ls.c: Likewise. * src/numfmt.c: Likewise. * src/pr.c: Likewise. * src/shred.c: Likewise. * src/shuf.c: Likewise. * src/split.c: Likewise. * tests/Coreutils.pm: Likewise. * tests/df/df-symlink.sh: Likewise. * tests/df/skip-rootfs.sh: Likewise. * tests/init.sh: Likewise. * tests/ls/color-norm.sh: Likewise. * tests/misc/basename.pl: Likewise. * tests/misc/ls-misc.pl: Likewise. * tests/misc/md5sum-bsd.sh: Likewise. * tests/misc/shred-exact.sh: Likewise. * tests/misc/sort.pl: Likewise. * tests/misc/stdbuf.sh: Likewise. * tests/misc/tac-continue.sh: Likewise. * tests/rm/r-root.sh: Likewise. * tests/tail-2/symlink.sh: Likewise.
2015-01-14tests: add extra protection against unexpected exitsPádraig Brady
Many tests use `program ... && fail=1` to ensure expected error situations are indicated. However that would mask an unexpected exit (like a crash). Therefore explicitly check the expected exit code. Note where error messages are also verified, the extra protection is not added. * tests/init.sh (returns_): A new helper function to check the return code of a command, and used throughout the tests. * cfg.mk (sc_prohibit_and_fail_1): Add a syntax check to avoid new instances of this issue.
2015-01-12tests: avoid skipping some df tests with libmountPádraig Brady
* tests/df/no-mtab-status.sh: Provide libmount placeholders, to avoid skipping the test when libmount is in use. * tests/df/skip-duplicates.sh: Likewise. * tests/df/skip-rootfs.sh: Comment that the test is moot when libmount (/proc/self/mountinfo) is being used.
2015-01-01maint: update all copyright year number rangesPádraig Brady
Run "make update-copyright" and then... * tests/sample-test: Adjust to use the single most recent year. * tests/du/bind-mount-dir-cycle-v2.sh: Fix case in copyright message, so that year is updated automatically in future.
2014-12-30build: update to latest gnulibPádraig Brady
Included in this are gnulib changes 3ea43e02 2768ceb7 which make the device IDs from /proc/self/mountinfo available to df. This can be leveraged by a subsequent change to df to present a more accurate list of file systems. * bootstrap: Merge from gnulib. * src/ls.c (dev_ino_pop): s/obstack_blank/obstack_blank_fast/ as this API/ABI has changed, giving memory exhausted errors if negative (large positive) numbers are passed to obstack_blank(). * tests/df/skip-duplicates.sh: Adjust as the new gnulib code requires a non NULL mnt_opts even when mnt_type is not "none".
2014-11-24df: only suppress remote mounts of separate exports with --totalPádraig Brady
* src/df.c (filter_mount_list): Separate remote locations are generally explicitly mounted, so list each even if they share the same remote device and thus storage. However with --total keep the suppression to give a more accurate value for the total storage available. (usage): Expand on the new implications of --total and move it in the options list according to alphabetic order. doc/coreutils.texi (df invocation): Mention that --total impacts on deduplication of remote file systems and also move location according to alphabetic order. * tests/df/skip-duplicates.sh: Add remote test cases. * NEWS: Mention the change in behavior. Reported in http://bugs.debian.org/737399 Reported in http://bugzilla.redhat.com/920806 Reported in http://bugzilla.opensuse.org/866010 Reported in http://bugzilla.opensuse.org/901905
2014-07-02tests: avoid errors on systems without getmntentPádraig Brady
* tests/df/no-mtab-status.sh: Skip if getmntent() not available. * tests/df/skip-duplicates.sh: Likewise. Fixes http://bugs.gnu.org/17863
2014-06-25df: report correct device in presence of eclipsed mountsPádraig Brady
* src/df.c (last_device_for_mount): A new function to identify the last device mounted for a mount point. (get_disk): Use the above to discard mount entries for a device, where a later mount entry uses a different device name than that of the user specified device. * tests/df/over-mount-device.sh: A new root test. * tests/local.mk: Reference the new test. * NEWS: Reword for all these related recent fixes. Discussed at: http://bugs.gnu.org/16539#69
2014-06-24df: output placeholder values for inaccessible mount pointsPádraig Brady
A system provided mount entry may be unavailable due to TOCTOU race, or if another device has been over-mounted at that position, or due to access permissions. In all these cases output "-" placeholder values rather than either producing an error, or in the over-mount case outputting values for the wrong device. * src/df.c (device_list): A new global list now updated by filter_mount_list(). (filter_mount_list): Adjust to take a parameter as to whether update the global mount list, or only the mount <-> device ID mapping. (get_dev): Use the device ID mapping to ensure we're not outputting stats for the wrong device. Also output placeholder values when we can't access a system specified mount point. (get_all_entries): Set the DEVICE_ONLY param for filter_mount_list(). (devname_for_dev): A new function to search the mount <-> dev mapping. * test/df/skip-duplicates.sh: Adjust accordingly. * NEWS: Mention the bug fixes. Discussed at: http://bugs.gnu.org/16539
2014-06-18df: use all of the last device details providedPádraig Brady
* src/df.c (filter_mount_list): Recent commit v8.22-108-g25a2c94 failed to copy file system type along with the updated device name. Therefore simply replace the existing mount entry with the current one with all the latest device details. Note the name, even if not shorter in this entry, will be replaced with a shorter name in a subsequent mount entry. * tests/df/skip-duplicates.sh: Add a test case.
2014-05-29df: use the last device name provided by the systemPádraig Brady
The device name reported for a particular mount entry may no longer be valid if the mount point was subsequently mounted on a different device. Therefore honor the order of the mount list returned by the system and use the last reported device name. * src/df.c (filter_mount_list): When discarding the current mount entry, ensure that a new device name is not also discarded. * tests/df/skip-duplicates.sh: Add a test case. Also fix a false failure in the edge case of a system with only a single file system. * NEWS: Mention the fix.
2014-05-13df: ignore non file system entries in /proc/mountsPádraig Brady
Linux with network namespaces contains entries in /proc/mounts like: proc net:[4026532464] proc rw,nosuid,nodev,noexec,relatime 0 0 resulting in a failure to stat 'net:[...]', inducing a warning and an exit with failure status. * src/df.c (get_dev): Ignore all relative mount points. * tests/df/skip-duplicates.sh: Add an entry to test relative dirs.
2014-05-13df: fix handling of symlinks in mount listPádraig Brady
The symlink handling in commit v8.21-172-g33660b4 was incomplete in the case where there were symlinks in the mount list itself. For example, in the case where /dev/mapper/fedora-home was in the mount list and that in turn was a symlink to /dev/dm-2, we have: before> df --out=source /dev/mapper/fedora-home devtmpfs after > df --out=source /dev/mapper/fedora-home /dev/mapper/fedora-home * src/df.c (get_disk): Compare canonicalized device names from the mount list. Note we still display the non canonicalized name, even if longer, as we assume that is the most representative. * tests/df/df-symlink.sh: This could theoretically fail on some systems depending on the content of the mount list, but adjust to fail on any system where symlinks are present in the mount list for the current dir.
2014-05-13df: also deduplicate virtual file systemsPádraig Brady
* src/df.c (filter_mountlist): Remove the constraint that a '/' needs to be in the device name for a mount entry to be considered for deduplication. Virtual file systems also have storage associated with them (like tmpfs for example), and thus need to be deduplicated since they will be shown in the default df output and subject to --total processing also. * test/df/skip-duplicates.sh: Add a test to ensure we deduplicate all entries, even for virtual file systems. Also avoid possible length operations on many remote file systems in the initial check of df operation. Also avoid the assumption that "/root" is on the same file system as "/". * NEWS: Mention the change in behavior.
2014-01-13maint: tests: refactor gcc commands for building shared libPádraig Brady
* init.cfg (gcc_shared_): A new function refactored from tests. (require_gcc_shared_): Adjust to call gcc_shared_() to build the test library, and remove that library before the function returns. * tests/cp/nfs-removal-race.sh: Call the new gcc_shared_(). * tests/df/no-mtab-status.sh: Likewise. * tests/df/skip-duplicates.sh: Likewise. * tests/ls/getxattr-speedup.sh: Likewise. * tests/rm/r-root.sh: Likewise.
2014-01-02maint: update all copyright year number rangesBernhard Voelker
Run "make update-copyright", but then also run this, perl -pi -e 's/2\d\d\d-//' tests/sample-test to make that one script use the single most recent year number.
2013-12-11tests: df/total-unprocessed: fix false failure with lofsPádraig Brady
* tests/df/total-unprocessed.sh: Skip the test when we can't determine the file system type as the exclusion filter is not applied in that case. "lofs" being ignored is effectively an unknown file system type.
2013-12-09tests: avoid false df failure with nfs and lofsBernhard Voelker
* tests/df/total-unprocessed.sh: -t nfs and --local are _not_ mutually exclusive on solaris, with lofs mounts.
2013-12-04df: dereference symlinks to disk device nodesPádraig Brady
This is so the matching for the device is done on the canonical name of the disk node, rather than on the path of the symlink. In any case the user will generally want to use the symlink target. * src/df.c (get_disk): Canonicalize the passed file, before matching against the list of mounted file system devices. Note we pass the original symlink name to the "file" output field, as the symlink target is usually available through the "source" field. * tests/df/df-symlink.sh: Test the dereferencing operation. * tests/local.mk: Mention the new test. * NEWS: Mention the fix. Reported by Ondrej Oprala
2013-11-27df: add --output=file to directly output specified argumentsPádraig Brady
* src/df.c (usage): Document the new 'file' --output field. (get_dev): Add a new parameter to pass the specified argument from the command line through. Use '-' if a command line parameter is not being used. * doc/coreutils.texi (df invocation): Describe the new 'file' field. * tests/df/df-output.sh: Adjust all fields test, and add a specific test for --output=file. * NEWS: Mention the new feature.
2013-07-22maint: make some shell and perl scripts executable in 'tests/'Bernhard Voelker
Some newer test scripts - partially ones from me - are not executable. It does not seem to be a problem, but for consistency and to avoid future problems on unusual platforms or shells change the permissions by adding the executable bit. * cfg.mk (sc_tests_executable): Add new syntax-check rule to ensure that all test scripts are executable. * tests/df/df-output.sh: Change file mode from 644 to 755. * tests/du/threshold.sh: Likewise. * tests/factor/run.sh: Likewise. * tests/init.sh: Likewise. * tests/misc/csplit-suppress-matched.pl: Likewise. * tests/misc/numfmt.pl: Likewise. * tests/tail-2/retry.sh: Likewise.
2013-07-09df: fix mount list processing with unstatable mount dirsPádraig Brady
* src/df.c (filter_mount_list): Initialize devlist->dev_num correctly when unable to stat() a mount point. This will avoid possible invalid deduplication done on the list due to use of uninitialized memory. * tests/df/skip-duplicates.sh: Ensure this code path is exercised. Also refactor the test to be table driven. * NEWS: Mention the bug fix.
2013-04-04tests: avoid shared lib tests on unsupported platformsPádraig Brady
* init.cfg (require_gcc_shared_): A new function to check that we can build shared libraries in the particular manner we use in our tests. * tests/cp/nfs-removal-race.sh: Use require_gcc_shared_. Then fail rather than skip, if the actual shared lib build fails. * tests/df/no-mtab-status.sh: Likewise. * tests/df/skip-duplicates.sh: Likewise. * tests/ls/getxattr-speedup.sh: Likewise. Reported in http://bugs.gnu.org/14024
2013-01-28df: do not treat rootfs speciallyBernhard Voelker
Like any other pseudo file system, df should show rootfs only when the -a option is specified, i.e. specifying -trootfs alone is not sufficient. As the rootfs entry is now elided by the general deduplication in filter_mount_list (commit v8.20-103-gbb116d3), all other references to rootfs can be removed again. * src/df.c (show_rootfs): Remove global variable. (ROOTFS): Remove constant. (filter_mount_list): Remove case to handle rootfs specially. (main): In the case for handling the -t option, remove setting of the show_rootfs variable. * tests/df/skip-rootfs.sh: Adapt the test case "df -t rootfs": the rootfs file system must not be printed (because no -a). * doc/coreutils.texi (df invocation): Correct the documentation about eliding mount entries: it is not the first occurrence of the the device which wins, but now rather the entry with the shortest mount point name. Also adapt the description about eliding pseudo file system types like rootfs. * NEWS (Changes in behavior): Adapt entry.
2013-01-27df: prefer fullpath entries when deduplicatingOndrej Oprala
* src/df.c (struct devlist): Add a new element for storing pointers to mount_entry structures. (devlist_head, dev_examined): Remove. (filter_mount_list): Add new function to filter out the rootfs entry (unless -trootfs is specified), and duplicities. The function favors entries with a '/' character in me_devname or those with the shortest me_mountdir string, if multiple entries fulfill the first condition. Use struct devlist to build up a list of entries already known, and finally rebuild the global mount_list. (get_all_entries): Call the above new function unless the -a option is specified. (get_dev): Remove the code for skipping rootfs and duplicities. * tests/df/skip-duplicates.sh: Add test cases. Co-authored-by: Bernhard Voelker <mail@bernhard-voelker.de>
2013-01-01maint: update all copyright year number rangesJim Meyering
Run "make update-copyright", but then also run this, perl -pi -e 's/2\d\d\d-//' tests/sample-test to make that one script use the single most recent year number.
2012-12-14maint: fix typos found by misspellingsBernhard Voelker
* doc/coreutils.texi (df invocation): s/occurence/occurrence/. * tests/df/skip-rootfs.sh: s/supressed/suppressed/
2012-12-07df: do not print duplicate entries and rootfs by defaultOndrej Oprala
* src/df.c (struct devlist): Add new struct for storing already- examined device numbers. (devlist_head): Add new store of the above type. (show_rootfs): Add new global boolean to not skip rootfs. (dev_examined): Add new function to check if the device has already been traversed. (get_dev): Filter out rootfs unless "-t rootfs" or the -a option is specified. Filter out duplicate entries by calling the above new dev_examined unless the -a option is specified. (main): Set the show_rootfs variable appropriately when the -t option is specified for rootfs. Free device list (guarded by IF_LINT). * tests/df/skip-duplicates.sh: Add test to exercise the skipping of duplicate entries. * tests/df/skip-rootfs.sh: Add test to exercise the skipping of the rootfs pseudo file system. * tests/local.mk: Add the above new tests. * NEWS (Changes in behavior): Mention the changes. * doc/coreutils.texi (df invocation): Document df's behavior about skipping rootfs and duplicate entries. Co-authored-by: Bernhard Voelker.
2012-12-06tests: fix regex to match "-" in ipcent field in df/total-verify.shBernhard Voelker
The regular expression failed to match for file systems that do not provide inode statistics, e.g. VFAT or CIFS (depending on the underlying peer file system). * tests/df/total-verify.sh: Fix the regular expression to match a dash in the ipcent field again. Reported by Assaf Gordon in http://bugs.gnu.org/13099. Bug introduced in commit v8.20-18-gdae8d22.
2012-11-24tests: don't rely on sed -i being availablePádraig Brady
* tests/df/df-output.sh: sed --in-place is not generally available. Also add a couple of simplifications from Bernhard Voelker. Removing all spaces, rather than just leading spaces, suffices. Searching for ' --output' in unadjusted df --help, suffices.
2012-11-22df: reorder default field list of --output optionBernhard Voelker
As the inodes information is usually not so much of interest, and some file systems including btrfs do not even provide it, reading of the full df --output is easier when the block statistic fields come just left of the last field, the mount point. * src/df.c (all_args_string): Move the inodes fields before the block fields. (usage): Likewise. * tests/df/df-output.sh: Likewise. * doc/coreutils.texi (df invocation): Likewise. Additionally, explicitly mention the default order of the --output option.
2012-11-09df: port the new df test to POSIX sed, larger file systemsPaul Eggert
* tests/df/df-output.sh: For the test "df -B1K --output=size", do not assume that the file system size fits in 9 bytes; it might be larger than that, so omit leading space. Also, use portable 'sed' commands: POSIX says sed commands inside { } should all end in newline.
2012-11-08df: add a test for the --output optionBernhard Voelker
* tests/df/df-output.sh: Add a test case. * tests/local.mk (all_tests): Mention the test. * cfg.mk (sc_file_system): Exempt the test from this syntax-check.
2012-11-08df: add --output to select which fields to displayBernhard Voelker
This supports changing the order of the fields displayed, and also allows the simultaneous display of inode and block fields. src/df.c (get_dev): Factor out calling get_header to ... (main): ... here. Call print_table only if file_systems_processed. src/df.c (Displayable fields): Rename DEV_FIELD to SOURCE_FIELD. Rename TYPE_FIELD to FSTYPE_FIELD. Rename FREE_FIELD to AVAIL_FIELD. Rename MNT_FIELD to TARGET_FIELD. * src/df.c (display_field_t): Turn loose enum definition of the displayable fields into a typedef. Add the inode fields ITOTAL_FIELD, IUSED_FIELD, IAVAIL_FIELD, IPCENT_FIELD. (field_data_t): Define structure to hold the display field, the caption, the width and the alignment for each field of the above type. (field_data): Add array the values of field data for each display field. (headers, alignments, widths): Remove arrays. (columns): Add a pointer to the storage for the array of the actual output columns, i.e., fields. (ncolumns): Add counter for the current output columns. (alloc_table_row): Allocate the dynamic ncolumns value of strings. (print_table): Loop over ncolumns instead of constant NFIELDS. Rename loop variable 'field' to 'col' to avoid ambiguity with the 'field' element in the columns structure. Adjust the condition for printing the last column by comparing with the column number instead of the field name (TARGET_FIELD). Use the width and the alignment stored in the columns data. (alloc_field): Add new function to allocate a field in the columns array. (get_field_list): Add new function to fill the array of output columns for each mode. (get_header): Loop over ncolumns instead of constant NFIELDS. Rename the loop variable 'field' to 'col' to avoid ambiguity with the 'field' element in the columns structure. Remove the code for continuing the loop if the current column is the file system type and print_type is not active (which is now impossible). Store the cell in the columns store along with the new width. (get_dev): Loop over ncolumns instead of the constant NFIELDS. Rename the loop variable 'field' to 'col' to avoid ambiguity with the 'field' element in the columns structure; move the definition down to where it is used first. Add cases for the inode fields ITOTAL_FIELD, IUSED_FIELD, IAVAIL_FIELD and IPCENT_FIELD. Store the cell in the columns store along with the new width. (main): Use new get_field_list function to fill the list of output columns. * src/df.c (print_table): Instead of fputs()ing directly, apply ambsalign on the last field, too. Use the new MBA_NO_RIGHT_PAD flag for this. * src/df.c (TOTAL_OPTION): Add new enum value. (long_options): Use it for the "total" option instead of 'c'. (main): Likewise. * src/df.c (get_dev): Remove condition to copy the fstype into the FSTYPE_FIELD - based on whether print_type is non-Null. Since the introduction of get_field_list(), there are only fields added to the columns array which have to be added. * src/df.c (get_dev): Guard the summing up of the values for the grand total: only do it if we have to print the total and if the current invocation is not for processing it. * src/df.c (main): Pass a hyphen "-" for the mount point name to get_dev. (get_dev): As the mount_point is now always there, remove the condition and the else case for the TARGET_FIELD. Instead, simply copy the mount_point. All cells are now always present. Therefore, add an assertion statement if one was not. Furthermore, hide the problematic characters unconditionally. (print_table): Remove the skipping of empty cells. * tests/df/total-verify.sh: Accommodate to the new "-" in the target field of the summary line. * NEWS: Mention the change in behavior. * src/df.c (field_type_t): Add new typedef of 3 enums to distinguish between block, inode and other fields. (field_data_t): Add field_type member of the above new type. (field_data): Add default values for the above field_type, indicating whether a field contains block values, inode values or other, generic values. (field_values_t): Add this struct to store the field values, used by and factored out from get_dev to be able to define such a struct for both the inode and the block values. (get_field_values): Add this function to obtain the block values and the inode values from the file system usage, used by and factored out from get_dev. (add_to_grand_total): Add this function to sum the values of the current mount point up for the grand total, used by and factored out from get_dev. (get_dev): Move the definition of the variables fsu, buf, pct and cell down to where they are used first to give them a better scope. Factor out input_units, output_units, total, available, negate_available, available_to_root, used and negate_used into the above struct field_values_t. Factor out the mapping of the fsu values to the above variables into above function get_field_values. Factor out the summing up of the grand total values into the above function add_to_grand_total. Define block_values and inode_values of the new type and call the new get_field_values to fill them from the fsu values. Call the above function add_to_grand_total for summing up the values for the grand total. Inside the loop over all fields, define a variable 'v' to point to either the block_values or the inode_values, depending on the current field's field_type. Change the code in the cases TOTAL_FIELD/ITOTAL_FIELD, USED_FIELD/IUSED_FIELD, AVAIL_FIELD/ IAVAIL_FIELD and PCENT_FIELD/IPCENT_FIELD to use the field values where 'v' is pointing to, i.e., either the block_values or the inode_values. * src/df.c (main): Remove setting of grand_fsu.fsu_blocks in the inode_format case as this is no longer needed and would lead to wrong results once when mixed block/inode fields will be used. * src/df.c (main): Cleanup the code at the end regarding file_systems_processed to make the code clearer. * src/df.c (inode_format): Remove variable. (main): Remove initialization of the above variable. In getopts loop, directly set the header_mode to INODES_MODE instead of using the above variable. Afterwards, remove the mapping to INODES_MODE as it is already set. * src/df.c (posix_format): Move variable ... (main): ... to here. * src/df.c (print_table): Enhance the comment about 2-line format in cases where the SOURCE_FIELD exceeds 20 chars, as such behavior has been removed long ago by commit v8.10-40-g99679ff. * src/df.c (Display modes): Add OUTPUT_MODE, remove unused NMODES. (display_field_t): Remove unnecessary NFIELDS. (field_data_t): Add member 'arg' for the field name in the --output argument. Add member 'used' to remember if a field is already used in the columns array. (field_data): Add values for the above new members arg and used. (all_args_string): Add variable which represents the argument for the --output option which includes all fields. (OUTPUT_OPTION): Add enum to identify the long --output option. (long_options): Add optional-argument --output option. (alloc_field): Assert that the field is not already used. Mark the field as used. (decode_output_arg): Add function to parse the comma-separated field list passed to the --output option in order to add the appropriate fields to the columns array. (get_field_list): Add case for the new OUTPUT_MODE to add all available fields to columns in the case the --output option has been passed without any values. Use the comma-separated field list form to pass to decode_output_arg to keep the field header mapping for the OUTPUT_MODE only on one place. (main): Define format string msg_mut_excl to be used in the following checks whether the use of --output and the other option is mutually exclusive. In the getopt_long loop, add a check to the case for the -i option to issue an error message when it is used together with --output; Likewise for -T and -P. Add a new case for OUTPUT_OPTION, together with similar checks as above and eventually passing the optarg to decode_output_arg. After the getopt_long loop, consider the OUTPUT_MODE case in order not to run into -h or -P mode. * src/df.c (get_dev): Also xstrdup the dev_name, and free it afterwards to silence a valgrind warning about definitely lost memory. (main): Free the columns store to silence valgrind, guarded by the IF_LINT macro. * src/df.c (main): Pass "total" as the mount point to get_dev if the SOURCE_FIELD is not among the columns to output. * tests/df/df-output.sh: Change the test to ensure the content of the target field of the grand total line: if the source field is present, then the target should be "-", else the target field should be "target". * NEWS (Changes in behavior): Enhance the exiting NEWS entry. * doc/coreutils.texi (df invocation): Document the content of the source and target field in the grand total line. * src/df.c (main): Add another condition to the need_fs_type parameter of read_file_system_list whether the FSTYPE_FIELD is used or not. * src/df.c (get_header): Indicate the block size used, in the "size" header, when using --output without -h. * tests/df/df-output.sh: Adjust for, and add an extra test for, the new behavior.
2012-09-05build: don't use recursive make for tests/ subdirectoryStefano Lattarini
* Makefile.am (SUBDIRS): Remove 'tests'. (include): The '$(top_srcdir)/tests/local.mk' file. (check-root): Remove this convenience target, it's no longer needed now that the "real" check-root target once in 'tests/Makefile' will land in the top-level makefile. * configure.ac (AC_CONFIG_FILES): Remove 'tests/Makefile'. * tests/Makefile.am: Rename ... * tests/local.mk: ... like this, with a lot of adjustments. * tests/init.cfg: Move ... * init.cfg: ... here. This is necessary, for a limitation of the gnulib-provided 'tests/init.sh', which unconditionally look for 'init.cfg' in the $(srcdir) directory. * tests/*/*.sh: Adjust: expect init.sh to be in '$srcdir/tests', not in '$srcdir', and extend $PATH with './src', not with '../src'. * tests/Coreutils.pm: Adjust similarly. * tests/pr/pr-tests.pl ($pfx): Likewise.
2012-08-30tests: add .sh and .pl suffixes to shell and perl tests, respectivelyStefano Lattarini
Not only this shrinks the size of the generated Makefile (from > 6300 lines to ~3000), but will allow further simplifications in future changes. * tests/Makefile.am (TEST_EXTENSIONS): Add '.sh' and '.pl'. (PL_LOG_COMPILER, SH_LOG_COMPILER): New, still defined simply to $(LOG_COMPILER) for the time being. (TESTS, root_tests): Adjust as described. * All tests: Rename as described.
2012-08-19tests: port df/no-mtab-status to SolarisPaul Eggert
* tests/df/no-mtab-status: Include <mntent.h> in test program, so that the getmntent hack compilation fails on Solaris, as it should, since it's not compatible with Solaris. Reported by Stefano Lattarini in <http://bugs.gnu.org/12225>.
2012-08-14df: fail when the mount list is required but cannot be readBernhard Voelker
* src/df.c (main): Add conditions to fail when the mount list cannot be read: this includes the cases when a file name argument is given and any of -a, -l, -t or -x is used. * doc/coreutils.texi: Document the additional error conditions. * tests/df/no-mtab-status: Add a new test. * tests/Makefile.am: Reference the new test. * NEWS: Mention the fix.