summaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)Author
2017-02-11ln: replace destination links more atomicallyPaul Eggert
If the file B already exists, commands like 'ln -f A B' and 'cp -fl A B' no longer remove B before creating the new link. Instead, they arrange for the new link to replace B atomically. This should fix a race condition reported by Mike Crowe (Bug#25680). * NEWS, doc/coreutils.texi (cp invocation, ln invocation): Document this. * bootstrap.conf (gnulib_modules): Add symlinkat. * src/copy.c, src/ln.c: Include force-link.h. * src/copy.c (same_file_ok): It's also OK to remove a destination symlink when creating symbolic links, or when the source and destination are on the same file system and when creating hard links. * src/copy.c (create_hard_link, copy_internal): * src/ln.c (do_link): Rewrite using force_linkat and force_symlinkat, to close a window where the destination temporarily does not exist. * src/cp.c (main): Do not set x.unlink_dest_before_opening merely because we are in link-creation mode. * src/force-link.c, src/force-link.h: New files. * src/local.mk (copy_sources, src_ln_SOURCES): Add them. * tests/cp/same-file.sh: Adjust test case to match fixed behavior.
2017-02-08tail: fix output of redundant headers when resumingJanne Snabb
* src/tail.c (check_fspec): Only enable printing of the file header if we've actually read some data and this is a new file. Also move printing of the file header to... (dump_remainder): ...here, to allow printing only when data read. * tests/tail-2/overlay-headers.sh: A new test for suspension and resumption of tail. * tests/local.mk: Reference the new test. * NEWS: Mention the fix. Fixes http://bugs.gnu.org/23539
2017-02-08tests: fix tail test race causing false failurePádraig Brady
* tests/tail-2/retry.sh: The replacement of the "missing" directory is not atomic, and therefore tail(1) can take a different path, especially if there is a delay between the rmdir(2) and creat(2). This is noticeable for example with `make coverage` because in that case the coverage files written by rmdir(1) on exit, induce a significant delay thus triggering the issue.
2017-02-08tail: fix erroneous status about 'giving up' on filePádraig Brady
* src/tail.c (recheck): Set f->ignore before we use it to show the appropriate error. * tests/tail-2/retry.sh: Ensure the "giving up" message is not presented.
2017-01-20date: fix TZ= regressionPaul Eggert
Problem reported by Paul Wise for Debian, in: https://bugs.debian.org/851934 This is fallout from the fix for GNU Bug#23035. * src/date.c (batch_convert): New args TZ and TZSTRING. All uses changed. (batch_convert, main): Adjust to parse_datetime2 API change. (main): Allocate time zone object. * tests/misc/date-debug.sh: Fix incorrect test case, caught by the fix. * tests/misc/date.pl: Test the fix.
2017-01-14maint: modernize URLsPaul Eggert
A lot of this is converting http: to https:. Also, gmane went away, so remove URLs that no longer work and are not easy to figure out what they were. Some of this stuff is so old that it no longer matters anyway.
2017-01-09maint: standardize on "timestamp" as per POSIXPaul Eggert
2017-01-09stty: ensure no side effects from invalid optionsPádraig Brady
* src/stty.c (apply_settings): A new function refactored from main() that is used to both check and apply options. (main): Call apply_settings before we open the device, so all validation is done before interacting with a device. * NEWS: Mention the improvement. * tests/misc/stty.sh: Add a test case.
2017-01-05tests: improve 'date --debug' testsAssaf Gordon
Update tests following improvements to gnulib's parse-datetime.y module. See https://lists.gnu.org/archive/html/bug-gnulib/2017-01/msg00002.html * tests/misc/date-debug.sh: Add tests for each of the gnulib changes.
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-12-28tests: avoid false fails on NFS due to EPERMPádraig Brady
* tests/chgrp/basic.sh: On some NFS setups a user is not allowed to set a group on a file even if a member of that group. Therefore skip this test on remote file systems. * tests/chgrp/default-no-deref.sh: Likewise. * tests/chgrp/no-x.sh: Likewise. * tests/chgrp/posix-H.sh: Likewise. * tests/chgrp/recurse.sh: Likewise. * tests/tail-2/inotify-rotate-resources.sh: Change to skipping on remote file systems in the standard way.
2016-12-26wc: with only --bytes, determine size more efficientlyPádraig Brady
* src/wc.c (wc): Avoid reading the end of the file when the size is not a multiple of PAGE_SIZE, as the special case handling for files in /proc and /sys is only required when st_size is 0 or a multiple of PAGE_SIZE. * tests/misc/wc-proc.sh: Add a test case.
2016-12-20maint: correct the version for the previous bug fixPádraig Brady
While st_size would have been incorrect for subsequent files since v7.1, it was only used since v8.24. * tests/misc/wc-files0.sh: s/7.1/8.24/ * NEWS: Likewise. Reported by Bernhard Voelker
2016-12-19wc: fix wrong byte counts when using --files-from0William R. Fraser
* src/wc.c (main): Reset fstatus[0].failed between files when reusing the fstatus[0] entry in --files-from0 mode. This ensures a stat() is done for each file, avoiding incorrect counts and redundant reading. * NEWS: Mention the bug fix. * tests/misc/wc-files0.sh: Add a test case. Fixes http://bugs.gnu.org/23073
2016-12-18tests: support non-MLS enabled SELinux systemsNicolas Iooss
When running "make check" on a Linux system running SELinux with a non-MLS policy, tests/mkdir/restorecon.sh test fails with: chcon: invalid context: root:object_r:tmp_t:s0: Invalid argument Indeed in such a configuration, contexts cannot have ":s0" suffix. * init.cfg (get_selinux_type): Refactor this function to here from various tests. Update to work with a non-MLS policy. (mls_enabled_): A new function to detect if MLS is enabled. (skip_if_mcstransd_is_running_): Update to not skip when MLS is not enabled. * tests/mkdir/restorecon.sh: Use a valid non-MLS context when needed. * tests/install/install-Z-selinux.sh: Likewise. * tests/cp/cp-a-selinux.sh: Likewise. * tests/misc/selinux.sh: Likewise. * tests/misc/chcon.sh: Skip if non-MLS as --range used throughout. Fixes http://bugs.gnu.org/22631
2016-12-08factor: retry properly if Pollard rho gives a trivial factorizationTorbjörn Granlund
* src/factor.c (factor_using_pollard_rho): Handle trivial factor g = n. (factor_using_pollard_rho2): Handle trivial factor g1 = n1, g0 = n0. * tests/misc/factor.pl: Add a test case. Fixes http://bugs.gnu.org/25135
2016-12-08factor: fix infinite loop in gcd2_oddNiels Möller
* src/factor.c (gcd2_odd): Fix the case a1 == 0, a0 == 0. * NEWS: Mention the bug fix. Fixes http://bugs.gnu.org/25135
2016-11-30tests: fix false failure with spaces in $PWDPádraig Brady
* tests/misc/ptx-overrun.sh: Quote appropriately to avoid this recently added issue, noticed by `make taint-distcheck`.
2016-11-29tests: fix ERRORs and false FAILs on some platformsPádraig Brady
* tests/misc/ls-time.sh: Skip the test rather than ERROR when `touch -m -d ...` fails (Hurd). * tests/tail-2/follow-stdin.sh: Avoid false FAILs by ignoring the variances in sterror output. * tests/rm/rm-readdir-fail.sh: Likewise. Also avoid ERRORs on systems that don't define _D_EXACT_NAMELEN.
2016-11-28tac: fix mem corruption when failing to read non seekable inputsPádraig Brady
This was detected with ASAN, but can also be seen without ASAN with: $ tac - - <&- tac: standard input: read error: Bad file descriptor *** Error in `tac': malloc(): memory corruption: 0x... * src/tac.c (copy_to_temp): Don't close our output stream on (possibly transient) output error, or on input error. (temp_stream): clearerr() on the stream about to be reused, to ensure future stream use is not impacted by transient errors. * tests/misc/tac-2-nonseekable.sh: Add a test case. * NEWS: Mention the bug fix. Fixes http://bugs.gnu.org/25041
2016-11-27tail: fix uninitialized memory read when failing to read filePádraig Brady
Reproduced under UBSAN with `tail -f <&-` giving: tail.c:2220:18: runtime error: load of value 190, which is not a valid value for type ‘_Bool' * src/tail.c (tail_file): Ensure f->ignore is initialized in all cases where we can't tail the specified file. * tests/tail-2/follow-stdin.sh: Add a test case which checks stderr has no UBSAN warnings. Fixes http://bugs.gnu.org/25041
2016-11-27doc: add NEWS entries for recent changesPádraig Brady
* NEWS: Mention in improvements about the workaround for the glibc issue with closed stdin, and the new supported file systems. * tests/misc/b2sum.sh: Spelling fix.
2016-11-26shuf: test input-closed bugPaul Eggert
Problem reported by Alex Ryan (Bug#25029). * tests/misc/shuf.sh: Test for shuffling with stdin closed.
2016-11-25tests: fix false failure on new ls testPádraig Brady
* tests/ls/quote-align.sh: Remove "total" line which can vary per file system depending on allocation. Reported by Assaf Gordon on OpenSolaris (5.11/5.10).
2016-11-25pr: fix read from invalid memory with tabs in separatorPádraig Brady
This was detected with: echo a > a; pr "-S$(printf "\t\t\t")" a -m a > /dev/null Resulting in ASAN triggering: ==================================================== ERROR: AddressSanitizer: global-buffer-overflow READ of size 1 at 0x00000041b622 thread T0 #0 0x40506a in print_sep_string ../src/pr.c:2241 #1 0x407ec4 in read_line ../src/pr.c:2493 #2 0x40985c in print_page ../src/pr.c:1802 #3 0x40985c in print_files ../src/pr.c:1618 #4 0x4036e0 in main ../src/pr.c:1136 * src/pr.c (init_parameters): Ensure we only override the specified separator when it's a single tab, thus matching the calculated separator length. * tests/pr/pr-tests.pl: Add a test case. * NEWS: Mention the fix.
2016-11-24ptx: fix an invalid heap reference with short --widthPádraig Brady
* src/ptx.c (fix_output_parameters): Ensure line_width doesn't go negative, which can happen when the --width is less than the --gap-size. * tests/misc/ptx-overrun.sh: Add a test case that triggers with ASAN. (Note the longer filename is needed to trigger). Fixes http://bugs.gnu.org/25011
2016-11-24tests: fix false failure with ASAN in rm-readdir-failPádraig Brady
* tests/rm/rm-readdir-fail.sh: ASAN correctly indicated that fts was writing to freed memory. This was because we reused a single dirent in our readdir() test wrapper. Since fts was deallocating those dirents, we now get a new dirent for each call to our readdir wrapper.
2016-11-24split: fix memory corruption during chunk extractionPádraig Brady
ASAN reported this error for: split -n2/3 /dev/null ERROR: AddressSanitizer: negative-size-param: (size=-1) #0 0x7f0d4c36951d in __asan_memmove (/lib64/libasan.so.2+0x8d51d) #1 0x404e06 in memmove /usr/include/bits/string3.h:59 #2 0x404e06 in bytes_chunk_extract src/split.c:988 #3 0x404e06 in main src/split.c:1626 Specifically there would be invalid memory access and subsequent processing if the chunk to be extracted was beyond the initial amount read from file (which is currently capped at 128KiB). This issue is not in a released version, only being introduced in commit v8.25-4-g62e7af0 * src/split.c (bytes_chunk_extract): The initial_read != SIZE_MAX should have been combined with && rather than ||, but also this condition is always true in this function so remove entirely. * tests/split/b-chunk.sh: Add a test case. Fixes http://bugs.gnu.org/25003
2016-11-22comm: add --total optionBernhard Voelker
* src/comm.c (total_option): Add bool variable for the new option. (TOTAL_OPTION): Add enum value. (long_options): Add array element for the new option. (usage): Document the new option here. (compare_files): Count the lines in total[3], and output the summary at the end. (main): Accept the new option. * doc/coreutils.texi (comm invocation): Document it. * tests/misc/comm.pl: Test it. While at it, improve the test data to have 1 unique line in the first file, 2 unique lines in the second file, and 3 common lines. * NEWS (New Features): Mention the new option. Fixes http://bugs.gnu.org/24929
2016-11-22all: update gnulib submodule to latestPádraig Brady
Also sync these copies with gnulib: * bootstrap: Sync missed part of AIX support. * tests/init.sh: Support compare_ on AIX.
2016-11-22tests: fix false failure with FreeBSD 11 multibyte quotingPádraig Brady
* tests/misc/printf-quote.sh: FreeBSD 11 was seen to treat \u0378 as a printable character. Therefore change to using the \u0081 C1 control character. We use the UTF-8 representation because our printf implementation explicitly disallows \u0081 as input. Reported by Assaf Gordon
2016-11-22tests: fix false fails due to passing env vars to returns_Pádraig Brady
On BSD /bin/sh it was seen that unexported env vars passed to returns_() would not be propagated to the wrapped command. * cfg.mk (sc_prohibit_env_returns): Add a syntax check to disallow. * tests/misc/csplit-io-err.sh: Rearrange to export vars in a subshell. * tests/rm/rm-readdir-fail.sh: Likewise. * tests/misc/nohup.sh: Export and unset vars around returns_. * tests/misc/printenv.sh: Likewise. Reported by Assaf Gordon
2016-11-22tests: fix recent tail-2 test regressionsPádraig Brady
* tests/tail-2/pipe-f.sh: Avoid issue with readable directories on BSD systems. * tests/tail-2/retry.sh: Likewise. Reported by Assaf Gordon
2016-11-22ls: improve alignment of quoted namesPádraig Brady
This provides better alignment when some names are quoted, which also provides better indication that quotes are not part of the name. * src/ls.c (align_variable_outer_quotes): A new variable set when ls is aligning columns (not using -m, non-zero -w), and has a variable quoting style (shell, shell-escape, c-maybe). (quote_name_buf): Writes to buffer rather than FILE, taking care to avoid data copying if possible. Refactored from... (quote_name): ...here. This now manages the buffer passed to quote_name_buf() and outputs the padding, colors and name in the appropriate order, while managing the --dired offsets. (get_color_indicator): A new function to return the color sequence, refactored from... (print_color_indicator): ...here. This now simply outputs. (print_dir): Refactor common parts to quote_name(). (clear_files): Reset the flag indicating at least one file is quoted in the current directory. (needs_quoting): A new function to indicate at the scan stage whether a name needs quoting. Called from... (gobble_file): ...here, until we find the first quoted file. (print_name_with_quoting): Mostly refactored to quote_name(). * tests/ls/quote-align.sh: A new test for various output formats. * tests/local.mk: Reference the new test. * NEWS: Mention the improvement.
2016-11-22b2sum: a new checksum utility with md5sum like interfacePádraig Brady
Note we don't support the --algorithm option of the b2sum command in the external BLAKE2 project, as that was deemed too confusing for users. "BLAKE2b" was chosen as the default algorithm to use, which is single threaded but performs well on 64 bit. * src/blake2: CC0 source copied from external project. * cfg.mk[VC_LIST_ALWAYS_EXCLUDE_REGEX]: Exclude blake2/ from syntax checks, make update-copyright, etc. * src/local.mk: Reference the sources for b2sum, and set the compilation flags. * doc/coreutils.texi (b2sum invocation): Reference the md5sum invocation node, and add descriptions of -l. * tests/misc/b2sum.sh: Add new test. * tests/local.mk: Reference new test. * AUTHORS: Add new binary. * README: Likewise. * build-aux/gen-lists-of-programs.sh: Likewise. * man/.gitignore: Likewise. * scripts/git-hooks/commit-msg: Likewise. * man/b2sum.x: New man page template. * man/local.mk: Reference new template. * src/.gitignore: Ignore new binaries. * src/blake2/.gitignore: Ignore new build atrifacts. * src/md5sum.c (usage): Describe the new -l option. * NEWS: Mention the new program.
2016-11-19cp: improve status message when omitting directoriesPádraig Brady
* src/copy.h (cp_options): Add a new flag for install(1). * src/copy.c (copy_internal): For cp, also output remediation advice which also indicates why directories aren't copied by default. The message is unchanged for install(1). * src/cp.c (cp_option_init): Init install_mode to false. * src/mv.c (cp_option_init): Likewise. * src/install.c (cp_option_init): Init install_mode to true. * tests/install/basic-1.sh: Add a test case. * tests/cp/link-deref.sh: Adjust test case. Fixes http://bugs.gnu.org/24958
2016-11-16tests: fix non portable date in recent testPádraig Brady
* tests/misc/date.pl: Years < 1900 fail on solaris at least. Reported by Assaf Gordon
2016-11-15tests: fix false failure on OS XPádraig Brady
* tests/misc/sort-h-thousands-sep.sh: The sv_SE locale may be available while sv_SE.utf8 is not. Therefore test and use the same locale, now definfed in a variable. Reported by Jim Meyering.
2016-11-13tests: use "returns_" rather than explicit comparison with "$?"Jim Meyering
The previous "returns_"-using change failed to convert many uses of "$?". Convert all but two of the remaining ones. * tests/ls/stat-vs-dirent.sh: Likewise. * tests/misc/head-write-error.sh: Likewise. * tests/misc/nice.sh: Likewise. * tests/misc/nohup.sh: Likewise. * tests/misc/stdbuf.sh: Likewise. * tests/misc/sync.sh: Likewise. * tests/tail-2/pid.sh: Likewise. * tests/tail-2/wait.sh: Likewise. Thanks to Bernhard Volker for spotting this.
2016-11-13tests: use "returns_" rather than explicit comparison with "$?"Jim Meyering
* tests/chmod/no-x.sh: Likewise. * tests/cp/no-deref-link1.sh: Likewise. * tests/cp/no-deref-link2.sh: Likewise. * tests/cp/no-deref-link3.sh: Likewise. * tests/du/move-dir-while-traversing.sh: Likewise. * tests/ls/infloop.sh: Likewise. * tests/ls/stat-failed.sh: Likewise. * tests/ls/time-style-diag.sh: Likewise. * tests/misc/chroot-fail.sh: Likewise. * tests/misc/env-null.sh: Likewise. * tests/misc/env.sh: Likewise. * tests/misc/nice-fail.sh: Likewise. * tests/misc/printenv.sh: Likewise. * tests/misc/timeout.sh: Likewise. * tests/tail-2/follow-name.sh: Likewise.
2016-11-10tail: only retry file open if --retry specifedPádraig Brady
* src/tail.c (tail_file): On failure to open a file, set ignore=true when --retry is not specified. * tests/tail-2/assert-2.sh: Adjust to the new behavior. * tests/tail-2/retry.sh: Add a test case. Also change from `tail ... && fail=1` to the more robust `returns_ 1 ...` construct which detects segfaults etc. * NEWS: Document the fix.
2016-11-09tail: ensure -f --retry 'missing' handles truncationPádraig Brady
* src/tail.c (tail_forever): The BLOCKING optimization is only enabled for non regular files (which can't be truncated), so ensure we don't enable that unless we've a valid file descriptor. * tests/tail-2/retry.sh: Add a test case. * NEWS: Mention the bug fix.
2016-11-08tail: terminate when following pipes and untailable non pipesPádraig Brady
* src/tail.c (ignore_pipe_or_fifo): Mark the descriptor as -1 for pipes so that any_live_files() detects correctly that the entry is no longer live. * tests/tail-2/pipe-f.sh: Add a test case. * NEWS: Mention the fix. Fixes http://bugs.gnu.org/24903 which was detected using Symbolic Execution techniques developed in the course of the SYMBIOSYS research project at COMSYS, RWTH Aachen University.
2016-11-07maint: misc tweaks to recent changesPádraig Brady
* doc/coreutils.texi(cut invocation): Give a more accurate description of cut field handling limitations. * tests/misc/stat-fmt.sh: Fix the test header to be more general. * tests/tail-2/retry.sh: Spellings.
2016-11-07date: add %q to output the quarter of the yearPádraig Brady
* doc/coreutils.texi (date invocation): Document %q. * src/date.c (usage): Likewise. * tests/misc/date.pl: Add a test case. * cfg.mk (sc_strftime_check): Adjust to allow %q. * NEWS: Mention the new feature.
2016-11-07all: update gnulib submodule to latestPádraig Brady
Incorporating these coreutils specific changes: backupfile: initialize default suffix within the implementation strftime,strptime: support %q to represent the quarter Also sync these copies with gnulib: * bootstrap: Now supports AIX. * gnulib: Update to the latest. * tests/init.sh: dash(1) is now disabled.
2016-11-05stat: make --format=%N honor the QUOTING_STYLE env varPádraig Brady
* doc/coreutils.texi (stat invocation): Describe the QUOTING_STYLE values now supported. * src/stat.c (getenv_quoting_style): A new function called from main, that sets the default quoting style for quotearg. (main): Call getenv_quoting_style() when %N specified. * tests/misc/stat-fmt.sh: Add a test case. * NEWS: Mention the improvement. Fixes http://bugs.gnu.org/23422
2016-11-04dd: warn about counts specified with confusing 0x prefixPádraig Brady
* src/dd.c (parse_integer): Suggest to use "00x" instead of "0x", which is significant for the "count", "seek", and "skip" operands. * tests/dd/misc.sh: Add a test case. Fixes http://bugs.gnu.org/24874
2016-10-26md5sum,sha*sum: fix --ignore-missing with checksums starting with 00Pádraig Brady
* NEWS: Mention the fix. * src/md5sum.c (digest_file): Add a new MISSING parameter to return whether the file was missing, separately from the digest. * tests/misc/md5sum.pl: Add a test case. Fixes http://bugs.gnu.org/24795
2016-10-15gnulib: update to latest and adapt printf-quote.sh testJim Meyering
* .gitignore: Add /lib/limits.h. * tests/misc/printf-quote.sh: Reflect that a single quote is now rendered as "'", rather than as ''\'''.