summaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)Author
2014-01-17ln: fix replacing symbolic links whose targets can't existPádraig Brady
* src/ln.c (errno_nonexisting): A new function to determine if the errno implies that a file doesn't or can't (currently) exist. (target_directory_operand): Use the new function to expand the set of errors we handle. * tests/ln/sf-1.sh: Add test cases for the newly handled errors. * THANKS.in: Mention the reporter. * NEWS: Mention the bug fix.
2014-01-14tests: restrict a recent SELinux test to SELinux systemsPádraig Brady
* tests/cp/no-ctx.sh: Since the test diagnoses whether the intercepted lgetfilecon() calls are actually called or not, restrict the test to systems where that occurs. The test cases are minimal on non SELinux systems and should be well covered by other tests. Reported-by: Bernhard Voelker
2014-01-13copy: fix a segfault in SELinux context copying codeNicolas Iooss
* src/selinux.c (restorecon_private): On ArchLinux the `fakeroot cp -a file1 file2` command segfaulted due to getfscreatecon() returning a NULL context. So map this to the sometimes ignored ENODATA error, rather than crashing. * tests/cp/no-ctx.sh: Add a new test case. * tests/local.mk: Reference the new test. * NEWS: Mention the fix. Fixes http://bugs.gnu.org/16335
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-13copy: fix SELinux context preservation for existing directoriesPádraig Brady
* src/copy.c (copy_internal): Use the global process context to set the context of existing directories before they're populated. This is more consistent with the new directory case, and fixes a bug for existing directories where we erroneously set the context to the last copied descendent, rather than to that of the source directory itself. * tests/cp/cp-a-selinux.sh: Add a test for this case. * NEWS: Mention the fix. * THANKS.in: Add reporter Michal Trunecka.
2014-01-09tests: avoid FP failure when cp fails for /proc/cpuinfoBernhard Voelker
On emulated aarch64 systems like in the qemu-based OpenBuildService of openSUSE, cp fails to copy /proc/cpuinfo because the inode number changes between the initial stat() call and copying the file: $ cp /proc/cpuinfo exp cp: skipping file '/proc/cpuinfo', as it was \ replaced while being copied * tests/cp/proc-zero-len.sh: When cp fails, check on the above error message to skip the test.
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.
2014-01-02build: update gnulib submodule, bootstrap and tests/init.sh to latestBernhard Voelker
* gnulib: Update to latest. * bootstrap: Update from gnulib. * tests/init.sh: Likewise.
2013-12-13tests: avoid unlikely deadlock in dd/no-allocate on some shellsPádraig Brady
* test/dd/no-allocate.sh: Use 'wait' to ensure we don't have multiple writers to the fifo, which was seen to trigger a very hard to reproduce deadlock with make -j20 on solaris. Also avoid writing to the fifo with the shell; instead using dd. (check_dd_seek_alloc): A new function refactored from the various cases, which are now constructed from function parameters.
2013-12-13tests: restrict cp --link inode comparisons to compatible systemsPádraig Brady
* tests/cp/link-deref.sh: On systems were cp can't determine if gnulib linkat() emulation might create a symlink instead of a hardlink to a symlink, copy.c will create a symlink to the symlink so that it has more control over its metadata. Also even if the system supports this operation, the particular file system under test may not. So avoid the hardlinked symlink verification in these cases. This fixes a false failure on aix, solaris and freebsd.
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-11tests: avoid warnings due to new filefrag -v formatPádraig Brady
* tests/cp/sparse-fiemap.sh: Newer versions of filefrag output more fields, in different orders, so handle that to avoid warnings.
2013-12-09tests: fix false failure due to xargs usagePádraig Brady
* tests/readlink/multi.sh: Ensure there is a trailing delimeter or xargs may (on AIX 7 at least) suppress the last argument.
2013-12-09tests: fix false failure on systems without /dev/stdinPádraig Brady
* tests/rm/interactive-once.sh: Ensure the expected output matches with the output on systems without /dev/stdin (like AIX 7). Also change some fail=1 to a more appropriate framework_failure_.
2013-12-09tests: fix false failure due to gdb inline function handlingPádraig Brady
Inline functions are awkward to breakpoint as mentioned at: https://sourceware.org/bugzilla/show_bug.cgi?id=10738 The normal case here was for the breakpoint on the inline function to fail, resulting in a 10s delay before skipping the test. However on GCC 4.7.2 on ppc64 at least it was seen that the test failed erroneously due to the breakpoint being successfully set on an "out of line" function, but an inline function was actually being called. * tests/tail-2/inotify-race.sh: Switch to a line based breakpoint, rather than a symbol base one, which avoids issues with breakpoints on inline functions. Also skip_ on the initial breakpoint check in case the breakpoint is not traversed which would be the case on remote file systems for example.
2013-12-09tail: use consistent diagnostics with and without inotifyPádraig Brady
* src/tail.c: With inotify, when a file is initially absent, we fstat(-1) for that file spec, thus recording an errnum of EBADF, which caused the "has become accessible" diagnostic to be issued, when the file first appears. Instead we avoid the fstat(-1) and thus emit the more natural and consistent "has appeared" diagnostic. * tests/tail-2/retry.sh: Use the new diagnostic which also causes this test to pass on systems without inotify.
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-07tests: avoid problematic $(< file) shell constructPádraig Brady
* tests/cp/link-deref.sh: This was seen to cause an issue with dash v0.5.6 at least, so change to a simpler expression.
2013-12-07tests: fix false failure on platforms using newfstatatPádraig Brady
* tests/ls/stat-free-color.sh: Add newfstatat to the list of syscalls to trace. Also add all "stat" syscalls to the list of syscalls that we verify that strace supports. Also only create a single dangling symlink to check, since we already only check for a single "stat" call. Fixes http://bugs.gnu.org/16075 seen on AArch64
2013-12-07tests: avoid a false memory leak test failurePádraig Brady
* tests/misc/shuf-reservoir.sh: Restrict the valgrind "exit on leak" behavior to developer environments where specific "lint" code is enabled to avoid inconsequential leaks.
2013-12-06tests: fix shuf test verifying that -i and -e can not be combinedBernhard Voelker
Previously, the test triggered another error diagnostic: shuf: invalid input range ‘-e’ and therefore eclipsed the expected one: shuf: cannot combine -e and -i options While at it, reindent a line with more than 80 characters, present since the previous commit to silence sc_long_lines. * tests/misc/shuf.sh: Pass a valid range to the -i option.
2013-12-06shuf: --repeat, not --repetitions; default --head-count is infinityPaul Eggert
Original problem reported by Philipp Thomas in <http://bugs.gnu.org/16061>. * NEWS: shuf --repeat, not shuf --repetitions. * doc/coreutils.texi (shuf invocation): * src/shuf.c (usage, long_opts, main): * tests/misc/shuf.sh: Likewise. Also, the default head-count is infinity.
2013-12-05selinux: fix --context=CTX for cp and diagnose defaultcon() errorsPádraig Brady
* src/selinux.h (ignorable_ctx_err): A new function used to determine if a warning should be given after a call to defaultcon() or restorecon(). * src/cp.c (main): Fix the setfscreatecon() call to use the argument passed by the user. * src/mkdir.c (make_ancestor): Show all but "ignoreable" errors from defaultcon() and restorecon(). * tests/misc/selinux.sh: Add a test run as root in selinux enforcing mode, to ensure cp --context=invalid is honored and fails immediately.
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-29tests: add a test for rm -r "/"Bernhard Voelker
* tests/rm/r-root.sh: Add a non-root test. * tests/local.mk (all_tests): Mention the test.
2013-11-27selinux: adjust utils to run restorecon with -ZPádraig Brady
cp, mv, install, mkdir, mkfifo, mknod are adjusted so that: -Z no longer accepts an argument. -Z or --context without an argument do not warn without SELinux. --context with an argument will warn without SELinux. * src/local.mk: Reference the new selinux module where required. * src/system.h: Make the argument to --context optional. * src/mkdir.c: Likewise. Also handle the SMACK case for --context. Note we currently silently ignore -Z with SMACK. * src/mkfifo.c: Likewise. * src/mknod.c: Likewise. * src/install.c: Likewise. Note install(1) by default already set the context for target files to their system default, albeit with an older method. Use the -Z option to select between the old and new context restoration behavior, and document the differences and details for how context restoration is done in new and old methods, with a view disabling the old method entirely in future. * src/cp.c: Make the argument to --context optional. Note -Z implies --no-preserve=context. I.E. -Z overrides that aspect of -a no matter what order specified. (struct cp_options): Document the context handling options. (main): Check/adjust option combinations after all options are processed, to both simplify processing and to make handling independent of order of options on the command line. Also improve the diagnostics from a failed call to setfscreatecon(). (set_process_security_ctx): A new function, refactored to set the default context from the source file, or with the type adjusted as per the system default for the destination path. (set_file_security_ctx): A new function refactored to set the security context of an existing file, either based on the process context or the default system context for a path. (copy_internal): Use the refactored functions to simplify error handling and consistently fail or warn as needed. (copy_reg): Likewise. (copy_internal): With --preserve=context, also copy context from non regular files. Note for directories this may impact the copying of subsequent files to that directory? (copy_attr): If we're handling SELinux explicitly, then exclude to avoid the redudant copy with --preserve=context, and the problematic copy with -Z. Note SELinux attribute exclusion also now honors cp -a --no-preserve=context. Note there was a very small window over 10 years ago, where attr_copy_file was available, while attr_copy_check_permissions was not, so we don't bother adding an explicit m4 check for the latter function. * src/mv.c: Support --context, but don't allow specifying an argument. * src/chcon.c: Adjust a comment to be specific to SELinux. * src/runcon.c: Likewise. * src/copy.c: Honor the context settings to "restorecon" as appropriate. * src/copy.h: Add a new setting to select "restorecon" functionality. * tests/mkdir/selinux.sh: s/-Z/--context=/ * tests/cp/cp-a-selinux.sh: Augment this test with cases testing basic -Z functionality, and also test the various invalid option combinations and option precedence. * tests/mkdir/restorecon.sh: Add a new test for the more involved mkdir -Z handling, since the directory changing and non existent directories need to be specially handled. Also check the similar but simpler handling of -Z by mk{nod,fifo}. * tests/local.mk: Reference the new test. * doc/coreutils.texi (cp invocation): Update as per interface changes. (mv invocation): Likewise. (install invocation): Likewise. (mkfifo invocation): Likewise. (mknod invocation): Likewise. (mkdir invocation): Likewise. * NEWS: Mention the new feature and change in behavior.
2013-11-27shred: provide --remove methods to avoid excessive syncingPádraig Brady
A sync operation is very often expensive. For illustration I timed the following python script which indicated that each ext4 dir sync was taking about 2ms and 12ms, on an SSD and traditional disk respectively. import os d=os.open(".", os.O_DIRECTORY|os.O_RDONLY) for i in range(1000): os.fdatasync(d) So syncing for each character for each file can result in significant delays. Often this overhead is redundant, as only the data is sensitive and not the file name. Even if the names are sensitive, your file system may employ synchronous metadata updates, which also makes explicit syncing redundant. * tests/misc/shred-remove.sh: Ensure all the new parameters actually unlink the file. * doc/coreutils.texi (shred invocation): Describe the new parameters to the --remove option. * src/shred.c (Usage): Likewise. (main): Parse the new options. (wipename): Inspect the new enum to see which of the now optional tasks to perform. * NEWS: Mention the new feature. * THANKS.in: Add reporter Joseph D. Wagner
2013-11-27tail: improve inotify handling of symlinksPádraig Brady
Previous behavior failed to read contents of a (re)appearing file, when symlinked by tail's watched file. Also we now diagnose other edge cases when running in inotify mode, where an initially missing or regular file changes to a symlink. * src/tail.c (main): If any arg is a symlink, use polling mode. (recheck): Diagnose the edge case where a symlink appears during inotify processing. * tests/tail-2/symlink.sh: Test the fix. Mention the edge cases. * tests/local.mk: Reference 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-11-27tests: ensure factor tests can be regeneratedPádraig Brady
* tests/local.mk (factor-tests:) Add -f to the mv command that replaces any existing generated tests. This is required to avoid prompts when root initially generates the tests, and they subsequently need to be regenerated by a non root user.
2013-11-22tests: enhance rm test regarding "." and ".."Bernhard Voelker
Recent commit 2da7009d changed the error diagnostic of rm(1) trying to remove "." or "..". Enhance the corresponding test. * tests/rm/r-4.sh: Ensure rm(1) outputs the expected error diagnostic.
2013-11-18tests: fix false rm -I test failure when run as rootPádraig Brady
Fix a recent regression introduced in commit v8.21-127-g5ee7d8f Also related to this is the recent query about root run `rm -I` ignoring the mode bits of a file: https://bugzilla.redhat.com/1013171 * tests/rm/interactive-once.sh: Avoid the messages and corresponding file presence checks with write protected files when running as root.
2013-11-17stty: add support for mark/space parityColin Leitner
This adds support for using a constant or "stick" parity bit. * src/stty.c (usage): Mention the new flag. * tests/misc/stty.sh: Adjust for the new flag. * NEWS: Mention the improvement. * docs/coreutils.texi (stty invocation): Mention the new flag.
2013-11-08shred: avoid data write pass with --size=0Pádraig Brady
* src/shred.c (dopass): Exit early to avoid redundant heap allocation, and more importantly avoiding a file sync when we're writting no data, as this can have side effects. Also with --verbose, this avoids printing of "pass status" which could be confusing as to whether data was actually written. * tests/misc/shred-passes.sh: Ensure the status for data passes are not written when not doing any data writes.
2013-11-08shred: fix direct I/O failures for last write to filePádraig Brady
Since direct I/O is now enabled with commit v8.21-139-gebaf961 we must handle the case where we write an odd size at the end of a file (with --exact), or we specify an odd --size that is larger than 64KiB, or in the very unlikely case of a device with an odd size. This issue was present since direct I/O support was first added in v5.3.0, but latent since v6.0. Theoretically this could have also been an issue after that on systems which didn't have alignment constraints, but did have size constraints for direct I/O. * src/shred.c (dopass): On the first pass for a file, always retry a write that fails with EINVAL, so we handle direct I/O failure at either the start or end of the file. Adjust the comment as the original case is out of date and implicitly handled by this more general fix. * tests/misc/shred-exact.sh: Add a test case. * NEWS: Add a "bug fix" entry for shred since there are two related issues now fixed.
2013-11-07cp: fix --link regarding the dereferencing of symbolic linksGian Piero Carrubba
* src/copy.c (create_hard_link): Add a bool 'dereference' parameter, and pass AT_SYMLINK_FOLLOW as 'flags' to linkat() when dereference is true. (should_dereference): Add new 'bool' function to determine if a file should be dereferenced or not. (copy_internal): Use the above new should_dereference() and remember its return value in a new local bool 'dereference' variable. Use that in all three calls to create_hard_link(). * src/cp.c (main): after parsing the options, if x.dereference is still DEFEF_UNDEFINED and the x.recursive is true, then only set x.dereference to DEREF_NEVER iff --link was not specified. * doc/coreutils.texi (cp invocation): Mention that cp(1) does not follow symbolic links in the source when --link is specified. Likewise in the description of the -R option when used together with that option. * tests/cp/same-file.sh: Adapt the expected results for the -fl, the -bl and the -bfl tests. * tests/cp/link-deref.sh: Add a new test. * tests/local.mk (all_tests): Reference the above new test. * NEWS (Changes in behavior): Mention the change. This fixes http://bugs.gnu.org/15173 Co-authored-by: Bernhard Voelker <mail@bernhard-voelker.de>
2013-11-01maint: simplify printing of md5sum file namesPádraig Brady
* src/md5sum.c (main): Add a comment as to why we continue to escape names that do not have '\n' but do have '\\' chars. (print_filename): Use the predetermined boolean to decide whether to escape or not, so that in the common case we can output the file name directly, rather than inspecting each char. * tests/misc/md5sum.pl: Add case to show '\\' chars cause escaping. * tests/misc/sha1sum.pl: Likewise.
2013-10-06mktemp: with --quiet, only suppress I/O errorsPádraig Brady
The reason for having a --quiet option is to suppress only some subset of possible errors. The most useful separation here is with usage/internal errors, and errors due to file creation etc. (i.e. I/O errors). * src/mktemp.c (main): Match the --help and info docs and only suppress the file/dir creation error messages. * tests/misc/mktemp.pl: Adjust accordingly.
2013-09-26rm: with -I, prompt before deleting a write protected fileSergio Durigan Junior
This regression was introduced in commit v6.7-71-g0928c24 * src/rm.c (main): Make the -I option behave like --interactive=once. * tests/rm/interactive-once.sh: Add cases for single and multiple files. * NEWS: Mention the bug fix. Fixes http://bugs.gnu.org/9308
2013-09-22maint: move all id(1) tests to the same directoryPádraig Brady
* tests/misc/id-context.sh -> tests/id/context.sh * tests/misc/id-setgid.sh -> tests/id/setgid.sh * tests/misc/id-uid.sh -> tests/id/uid.sh * tests/misc/id-zero.sh -> tests/id/zero.sh * tests/local.mk: Reference the renamed tests
2013-09-22tests: parameterize the "root" usernamePádraig Brady
* tests/misc/chroot-credentials.sh: Don't assume uid 0 has the "root" name, nor any name for that matter.
2013-09-22id: support specifying the user by user IDPádraig Brady
* src/id.c (usage): Remove 'name' from the synopsis, implying that one can also specify by user ID. (main): Like chown(1), call parse_user_spec() to implement user name or ID lookup with appropriate precedence. * doc/coreutils.texi (id invocation): Mention that a user ID is supported and how '+' affects lookup order. * tests/misc/id-groups.sh: Remove test now subsumed into... * tests/misc/id-uid.sh: New test covering new interface. * tests/local.mk: Rename the test. * NEWS: Mention the new feature. Addresses http://bugs.gnu.org/15421
2013-09-22tests: avoid a failure when there isn't a name for all user IDsPádraig Brady
* tests/misc/id-zero.sh: Don't check exit status when in -n mode. Prompted by the continuous integration build failure at: http://hydra.nixos.org/build/6196762
2013-09-21id: add -z, --zero optionBernhard Voelker
* src/group-list.h (print_group_list): Add a parameter for the delimiter of type char. * src/group-list.c (print_group_list): Likewise, and use it instead of a white space character to delimit the group entries. * src/groups.c (main): Pass white space character to print_group_list(). * src/id.c (longopts): Add array element for the new long option. (usage): Document the new option. While at it, fix the alignment of the descriptions to match that of HELP_OPTION_DESCRIPTION. (main): Define the bool flag opt_zero indicating the use of the new option. In the getopt_long loop, handle it. Output an error diagnostic in the case the --zero option has been specified together with the default format. In the case of -gG, pass either a NUL or a white space character to print_group_list() - depending on the above new flag. Likewise change the printing of the final newline character: output a NUL instead if the --zero option has been specified. * doc/coreutils.texi (id invocation): Document the new option. While at it, move the @exitstatus macro down after the macro @primaryAndSupplementaryGroups in order to be consistent with other texinfo documents. (groups invocation): Move @exitstatus down after the macro @primaryAndSupplementaryGroups here, too. * tests/misc/id-zero.sh: Add new test exercising the new option. * tests/local.mk (all_tests): Reference it. * NEWS (New features): Mention the new option. Fixes http://bugs.gnu.org/9987
2013-08-02maint: update copyright year number ranges of numfmt sourcesBernhard Voelker
Run "make update-copyright". * src/numfmt.c: Update copyright year number range. This file has obviously been added to coreutils after and without the annual update. * tests/misc/numfmt.pl: Likewise.
2013-07-29tests: fix another test failure in test/du/inodes.shBernhard Voelker
Prompted by the continuous integration build failure at: http://hydra.nixos.org/build/5584121 du(1) uses the first file object of the two test files linked to the same inode, 'd/f' and 'd/h', whatever the system returns first. Use 'd/f' in both the expected and the actual output. * test/du/inodes.sh: Change the expected output as described above when returning the --all directory entries (without -l). Also replace the name of the hardlink 'd/h' by 'd/f' in the actual output.
2013-07-28maint: cleanup compare calls in test/du/inodes.shBernhard Voelker
* test/du/inodes.sh: In the cases where compare() fails, that function would show the unified diff automatically. Therefore, remove the excess "cat out". In the cases where expecting an empty file, use compare() again rather than the simpler "test -s" because possible error reports will then include the file's content for the same reason as above.
2013-07-28tests: fix intermittent failure in test/du/inodes.shPádraig Brady
Prompted by the continuous integration build failure at: http://hydra.nixos.org/build/5582213 * test/du/inodes.sh: Due to undefined order in returned directory entries, the expected output might not match, so sort both expected and actual output when returning --all directory entries. Also use a simpler test for ensuring no errors are output.
2013-07-27du: add --inodes optionBernhard Voelker
This new option can be used to find directories with a huge amount of files. The GNU find utility has the printf format "%h" which prints the number of entries in a directory, but this is non-cumulative and doesn't handle hard links. * src/du.c (struct duinfo): Add new member for counting inodes. (duinfo_init): Initialize inodes member with Zero. (duinfo_set): Set inodes counter to 1. (duinfo_add): Sum up the 2 given inodes counters. (opt_inodes): Add new boolean flag to remember if the --inodes option has been specified. (INODES_OPTION): Add new enum value to be used ... (long_options): ... here. (usage): Add description of the new option. (print_size): Pass inodes counter or size to print_only_size, depending on the inodes mode. (process_file): Adapt threshold handling: with --inodes, print or elide the entries according to the struct member inodes. (main): Add a case for accepting the new INODES_OPTION. Print a warning diagnostic when --inodes is used together with the option --apparent-size or -b. Reset the output_block_size to 1 ... and thus ignoring the options -m and -k. * tests/du/inodes.sh: Add a new test. * tests/local.mk (all_tests): Mention it. * doc/coreutils.texi (du invocation): Document the new option. * NEWS: Mention the new option.
2013-07-25mv: replace empty directories in cross file system moveKen Booth
src/copy.c (copy_internal): Use rmdir() rather than unlink() when the source is a directory, so that empty directories are replaced in the destination as per POSIX. * tests/mv/part-rename.sh: Augment with various combinations. * NEWS: Mention the bug fix. Fixes http://bugs.gnu.org/14763