summaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)Author
2012-09-14seq: 70x faster for non-negative whole numbers and incr==1Jim Meyering
Handle non-negative whole numbers robustly and efficiently when the increment is 1 and when no format-changing option is specified. On the correctness front, for very large numbers, seq now works fine: $ b=1000000000000000000000000000 $ src/seq ${b}09 ${b}11 100000000000000000000000000009 100000000000000000000000000010 100000000000000000000000000011 while the old one would infloop, printing garbage: $ seq ${b}09 ${b}11 | head -2 99999999999999999997315645440 99999999999999999997315645440 The new code is much more efficient, too: Old vs new: 55.81s vs 0.82s $ env time --f=%e seq $((10**8)) > /dev/null 55.81 $ env time --f=%e src/seq $((10**8)) > /dev/null 0.82 * seq.c (incr): New function, inspired by the one in cat.c. (cmp, seq_fast): New functions, inspired by code in nt-factor by Torbjörn Granlund and Niels Möller. (trim_leading_zeros): New function, without which cmp would malfunction. (all_digits_p): New function. (main): Hoist the format_str-vs-equal_width check to precede first treatment of operands, and insert code to call seq_fast when possible. * NEWS (Bug fixes): Mention the correctness fix. (Improvements): Mention the speed-up. * tests/misc/seq.pl: Exercise the new code. Improved by: Bernhard Voelker. http://thread.gmane.org/gmane.comp.gnu.coreutils.general/3340
2012-09-14tests: reenable "make -C tests ..." commandsJim Meyering
The README-documented way to run individual tests was invalidated by the conversion of tests/ to non-recursive make. Add a GNUmakefile shim to reenable that usage. * tests/GNUmakefile: New file, so that "make -C tests ..." works like it did before the conversion of tests/ to non-recursive build. Reported by Bernhard Voelker. * Makefile.am (EXTRA_DIST): Add it. * cfg.mk (sc_prohibit_tab_based_indentation): Also exempt any GNUmakefile from this syntax-check.
2012-09-07factor: NEWS and testsJim Meyering
* NEWS (Bug fixes): Mention it. * tests/misc/factor.pl: Add five of Torbjörn's tests.
2012-09-05rm: avoid bogus diagnostic for a slash-decorated symlink-to-dirJim Meyering
These commands would evoke an invalid diagnostic: $ mkdir d && ln -s d s && env rm -r s/ rm: cannot remove 's': Too many levels of symbolic links remove.c was stripping trailing slashes from "s/" before passing the name to "rm". But a trailing slash may change the semantics, and thus should not be stripped. * src/remove.c (rm_fts): Do not strip trailing slashes. * tests/rm/v-slash.sh: Adapt to new expected output. * gnulib: Update to latest, for an improved fts.c that merely normalizes trailing slashes. Reported by Paul Eggert in discussion of http://bugs.gnu.org/12339
2012-09-05tests: depend on the programs we're testingJim Meyering
* tests/local.mk ($(TEST_LOGS)): Depend on $(PROGRAMS), so that tests are rerun when any program is rebuilt. Technically, we could specify precisely which few programs are dependents of each test, but that can come later, if deemed worth the trouble and maintenance burden. Also, there is the issue of the primary program(s) being tested (i.e., those itemized via print_ver_) versus those that are tested incidentally: for example, nearly every test exercises "rm" when its clean-up code removes files.
2012-09-05maint: vc_exe_in_TESTS should actually be a syntax checkStefano Lattarini
Because it requires the presence of the '.git' directory, that is, can be run only for maintainers working from checked-out sources. * tests/local.mk (vc_exe_in_TESTS): Rename and move ... * cfg.mk (sc_tests_list_consistency): ... here, with minor adjustments.
2012-09-05tests: put test-suite.log back in 'tests/'Stefano Lattarini
* tests/local.mk (TEST_SUITE_LOGS): Define to 'tests/test-suite.log'.
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-09-05maint: list of names of built programs available in the MakefilesStefano Lattarini
This is just a preparatory refactoring in view of future changes. * configure.ac (AC_SUBST): New 'built_programs'. * tests/Makefile.am (AM_TESTS_ENVIRONMENT): Simply define the exported variable 'built_programs' to the expansion of the '$(built_programs)' AC_SUBST'd make variable. (.built-programs): Remove this now-unneeded convenience target. (CLEANFILES, check_DATA): Delete, no longer needed.
2012-09-05tests: remove the unused 'root-hint' targetStefano Lattarini
* tests/Makefile.am (root-hint): Here. The interested user can see the reasons why some tests are skipped by looking at the messages they display on the console; here's an excerpt: ... PASS: misc/id-groups.sh id-setgid.sh: skipped test: must be run as root SKIP: misc/id-setgid.sh PASS: misc/md5sum.pl ... PASS: df/total-verify.sh 2g.sh: skipped test: very expensive: disabled by default SKIP: du/2g.sh ... Clear enough, and more specific and precise that a generic "some tests might need to be run as root" message. And if that user is interested in making those tests run anyway, he'll just take a look to the README files to look for info. So there's no reason to pollute the stdout with another "hint" that is subsumed by those messages, and that might go unnoticed anyway. Moreover, and possibly more importantly, that hint wasn't being displayed anyway, even before this change! That's because the 'root-hint' target was listed as prerequisite for the 'check-recursive' target, which however was not a dependency of the 'check' target in 'tests/Makefile.am', because that file contains no $(SUBDIRS) definition.
2012-09-05tests: use suffix, not exec-bit, to tell which files are testsStefano Lattarini
* tests/Makefile.am (vc_exe_in_TESTS): Adjust to look, in the 'tests/' subdirectory, for files that have one of the extensions listed in $(TEST_EXTENSIONS), rather than for executable files.
2012-09-05maint: make vc_exe_in_TESTS also work in VPATH buildsStefano Lattarini
* tests/Makefile.am (vc_exe_in_TESTS): It is easy to adjust this recipe to also work in VPATH setups, also thanks to modifications done by previous changes.
2012-09-05maint: remove useless dependency for vc_exe_in_TESTSStefano Lattarini
* tests/Makefile.am (vc_exe_in_TESTS): No need to depend on Makefile: this target is .PHONY, so it is always run anyway.
2012-09-05maint: avoid parsing of Makefile.am from vc_exe_in_TESTSStefano Lattarini
* tests/Makefile.am (TESTS): Rename ... (all_tests): ... like this, so that we'll still be able to know the complete list of our tests even if the user overrides TESTS from the command line (which he's allowed to do by the test harness API). (root_tests): Rename ... (all_root_tests): ... like this, for similar reasons. (TESTS, root_tests): Redefine their defaults to to $(all_tests) and $(all_root_tests) respectively. (vc_exe_in_TESTS): It can now safely use $(all_tests) to get the complete list of test cases according to the Makefile, instead of having to resort to "parsing" of Makefile.am. (EXTRA_DIST): Use $(all_tests), not $(TESTS). (v_, w_): Delete, no longer needed.
2012-09-05build: use 'check-local' to extend the 'check' targetStefano Lattarini
* tests/Makefile.am (check-local): Here, by making this depend on 'vc_exe_in_TESTS' ... (check): ... rather than making this depend on them. While the old usage worked, it relied on an implementation detail rather than on documented behavior. * src/local.mk (check-local): Similarly, make this depend on 'check-README' and 'check-duplicate-no-install' ... (check): ... rather than on this.
2012-09-01build: don't use recursive make to build the 'src' subdirectoryStefano Lattarini
* Makefile.am (SUBDIRS): Remove 'src'. Ensure '.' is listed before 'tests' and 'gnulib-tests'. (dist-hook): Adjust: we must now tweak the top-level Makefile.in in $(distdir), not the one in the 'src/' subdir (which is gone). (include): The '$(top_srcdir)/src/local.mk' file. * build-aux/gen-lists-of-programs.sh: Adjust the generation of the automake input fragment. * tests/Makefile.am (.built-programs): Adjust. * cfg.mk (all_programs): Remove this convenience rule; it's no longer needed, now that we can rely directly on the contents of $(all_programs). (sc_option_desc_uppercase, check-programs-vs-x:): Adjust lists of prerequisites accordingly. (all-progs-but-lbracket): Simplify definition accordingly. * configure.ac ($OPTIONAL_BIN_PROGS): Adjust definition. ($OPTIONAL_PKGLIB_PROGS): Likewise. ($NO_INSTALL_PROGS_DEFAULT): Tweak definition, for consistency. (AC_CONFIG_FILES): Remove 'src/Makefile'. * src/Makefile.am: Rename ... * src/local.mk: ... like this, with a lot of adjustments. In addition ... (all_programs): ... remove this now-unneeded convenience target.
2012-08-31maint: fixup: don't try to distribute a now-removed fileStefano Lattarini
* tests/Makefile.am (EXTRA_DIST): Drop 'check.mk', which has been removed (being merged into 'tests/Makefile.am') by recent changes.
2012-08-30tests: get rid of the 'shell-or-perl' auxiliary scriptStefano Lattarini
It's now easier and faster to simply run the perl ans shell test scripts directly with the appropriate interpreter and options. * tests/shell-or-perl: Delete. * tests/Makefile.am (EXTRA_DIST): Remove it. (SH_LOG_COMPILER): Re-define to invoke the correct shell. (PL_LOG_COMPILER): Re-define to invoke the correct perl interpreter ... (TESTSUITE_PERL_OPTIONS): ... with the correct options. (XPL_LOG_COMPILER): Use those options instead of inlining their expansion. (LOG_COMPILER): Delete, no longer needed.
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-30tests: detect missing perl at configure runtimeStefano Lattarini
* configure.ac (AM_CONDITIONAL): Set the conditional 'HAVE_PERL' to true if the configure-time checks (as run by gl_PERL) have been able to find a working perl. * tests/no-perl: New script, report a diagnostic about "missing perl" and exit with status 77. * tests/Makefile.am (EXTRA_DIST): Distribute it. (TESTSUITE_PERL): New, define to '$(PERL)' if a perl interpreter has been found at configure time (i.e., if the 'HAVE_PERL' automake conditional is true), and to '$(srcdir)/no-perl' otherwise. (LOG_COMPILER): Use $(TESTSUITE_PERL) instead of $(PERL). (XPL_LOG_COMPILER): Likewise. * tests/shell-or-perl: Simplify: no need to actually check whether perl is working.
2012-08-30tests: avoid use of '-T' in shebang line to enable perl taint modeStefano Lattarini
* tests/rm/fail-eperm: Rename ... * tests/rm/fail-eperm.xpl: ... like this * tests/Makefile.am (TESTS): Adjust. (TEST_EXTENSIONS): New, list '.xpl'. (XPL_TEST_LOGS): New, run a perl test in tainted mode. * tests/shell-or-perl: Simplify this script: we no longer need to parse the shebang line and adjust the flags in the perl invocation accordingly.
2012-08-30tests: prefer AM_TESTS_ENVIRONMENT over TESTS_ENVIRONMENTStefano Lattarini
The latter should be reserved for user overrides. * tests/Makefile.am (TESTS_ENVIRONMENT): Rename ... (AM_TESTS_ENVIRONMENT): ... like this.
2012-08-30tests: merge tests/check.mk into tests/Makefile.amStefano Lattarini
The separation has become unnecessary after all the ancient 'tests/*/Makefile.am' makefiles have been merged into the "more-top-level" one 'tests/Makefile.am'. * tests/check.mk: Merge ... * tests/Makefile.am: ... in here. Some comments tweaking while at it.
2012-08-30build: don't abuse Automake internals (with its 'check-am' rule)Stefano Lattarini
* tests/check.mk (check-am): Remove; obtain the same effect by moving its dependency '.built-programs' ... (check_DATA): ... to this variable.
2012-08-30tests: remove useless defn of REPLACE_GETCWD from TESTS_ENVIRONMENTStefano Lattarini
It's last use had been removed in commit v8.12-3-g3ed91fc of 2011-04-28, "tests: remove useless test: misc/pwd-unreadable-parent". * tests/check.mk (TESTS_ENVIRONMENT): Adjust. Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
2012-08-30tests: fix misc/sort-exit-early to skip if rootNick Alcock
* tests/misc/sort-exit-early: skip_if_root_ as this test requires an unwritable input and an unreadable output.
2012-08-24md5sum, sha*sum: add --tag to output a format indicating the algorithmOndrej Oprala
The format used is the BSD traditional format which looks like: MD5 (/dev/null) = d41d8cd98f00b204e9800998ecf8427e * NEWS: Add new feature info. * doc/coreutils.texi (md5sum invocation): Add detailed information about the new --tag option. * src/md5sum.c: Add the new --tag option for BSD-style output. (bsd_split_3): Add ESCAPED_FILENAME parameter. (print_filename): New function refactored from main(). (filename_unescape): New function refactored from split_3(). * tests/misc/md5sum-bsd: Add tests for the new feature.
2012-08-23rm: fix the new --dir (-d) option to work with -iRob Day
* src/remove.c (prompt): Hoist the computation of is_empty, since we'll need it slightly earlier. Before, this function would arrange to fail with EISDIR when processing a directory without --recursive (-r). Adjust the condition to exempt an empty directory when --dir has been specified. Improve comments. * tests/rm/d-3: New file, to ensure that rm -d -i dir works. * tests/Makefile.am (TESTS): Add it. * NEWS (Bug fixes): Mention it. * THANKS.in: Update. Reported by Michael Price in http://bugs.gnu.org/12260
2012-08-22tests: correct print_ver_ arguments and add a rule to enforce thisBernhard Voelker
We use print_ver_ to run "PROG --version" for each program under test. Some tests have been derived from others, while the argument(s) to print_ver_ have not been adapted. Add a new cfg.mk rule to prohibit this. * cfg.mk (sc_prohibit_test_calls_print_ver_with_irrelevant_argument): New rule, to prohibit a test script from calling print_env_ for a program not actually used by that test. * tests/chown/basic: s/\(print_ver_\) chgrp/\1 chown/ * tests/cp/acl: s/\(print_ver_\) mv/\1 cp/ * tests/cp/capability: s/\(print_ver_\) ls/\1 cp/ * tests/cp/cp-parents: s/(print_ver_\) mv/\1 cp/ * tests/du/bind-mount-dir-cycle: s/(print_ver_\) rm/\1 du/ * tests/misc/wc-parallel: s/(print_ver_\) md5sum/\1 wc/
2012-08-21du: handle bind-mounted directory cycles gracefullyOndrej Oprala
Before this change, a directory cycle induced by a bind mount would be treated as a fatal error, i.e., probable disk corruption. However, such cycles are relatively common, and can be detected efficiently, so now du emits a descriptive warning and arranges to exit nonzero. * NEWS (Bug fixes): Mention it. * src/du.c: Include "mountlist.h". (di_mnt): New global set. (di_files): Rename global from di_set, now that there are two. (fill_mount_table): New function. (hash_ins): Add DI_SET parameter. (process_file): Look up each dir dev/ino pair in the new set. (main): Allocate, initialize, and free the new set. * tests/du/bind-mount-dir-cycle: Add a test for the fix. * tests/Makefile.am (TESTS): Add it. * THANKS.in: Update. This implements the proposal in http://bugs.gnu.org/11844. Originally reported in http://bugs.debian.org/563254 by Alan Jenkins and more recently as http://bugzilla.redhat.com/836557 Improved by: Jim Meyering
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-19tests: avoid split/filter test failure on very low-mem systemJim Meyering
* tests/split/filter: Use xz -1 when compressing, to minimize memory usage. Otherwise, xz could fail due to insufficient virtual memory on a system with very little free memory.
2012-08-18tests: trigger the sort -u free-memory-read bugJim Meyering
* tests/misc/sort-u-FMR: New file. * tests/Makefile.am (TESTS): Add it. * tests/misc/sort: Add the test here, too. * NEWS (Bug fixes): Mention it.
2012-08-18tests: wrap the valgrind-requiring assertion in a functionJim Meyering
* tests/init.cfg (require_valgrind_): New function... * tests/misc/sort-stale-thread-mem: ...extracted from here.
2012-08-17sort: sort --unique (-u) could cause data lossJim Meyering
sort -u could omit one or more lines of expected output. This bug arose because sort recorded the most recently printed line via reference, and if you were unlucky, the storage for that line would be reused (overwritten) as additional input was read into memory. If you were doubly unlucky, the new value of the "saved" line would not only match the very next line, but if that next line were also the first in a series of identical, not-yet-printed lines, then the corrupted "saved" line value would result in the omission of all matching lines. * src/sort.c (saved_line): New static/global, renamed and moved from... (write_unique): ...here. Old name was "saved", which was too generic for its new role as file-scoped global. (fillbuf): With --unique, when we're about to read into a buffer that overlaps the saved "preceding" line (saved_line), copy the line's .text member to a realloc'd-as-needed temporary buffer and adjust the line's key-defining members if they're set. (overlap): New function. * tests/misc/sort: New tests. * NEWS (Bug fixes): Mention it. * THANKS.in: Update. Bug introduced via commit v8.5-89-g9face83. Reported by Rasmus Borup Hansen in http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/23173/focus=24647
2012-08-16tests: reverse args in Coreutils.pm-invoked diff, for consistencyJim Meyering
* tests/Coreutils.pm (_compare_files): Reverse diff arguments so that we invoke diff -c $expected $actual, which is consistent with how init.sh-using tests invoke "compare exp out".
2012-08-14rm: new option --dir (-d) to remove empty directoriesKrzysztof Goj
Add new option to rm (-d/--dir), which allows removal of empty directories, while still safely disallowing removal of non-empty ones. This improves compatibility with Mac OS X and BSD systems, which honor the -d option. * src/remove.c (rm_fts): Remove empty directories when requested. * src/remove.h (rm_options) [remove_empty_directories]: New member. * src/rm.c (long_opts, usage, main): Update usage and option parsing. (rm_option_init): Initialize the new member. * src/mv.c (rm_option_init): Initialize the new member. * tests/rm/d-1: New test case - successfully delete empty dir. * tests/rm/d-2: New test case - refuse to delete nonempty dir. * tests/Makefile.am (TESTS): Add them.
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.
2012-08-08tests: fix validation of local file systemsPádraig Brady
* tests/init.cfg (require_mount_list_): A new function to ensure we can read the list of file systems. (require_local_dir_): Call the above function, as otherwise the check is invalid. * tests/df/total-unprocessed: Ensure df can read the list of mounted file systems so that --local can be honored.
2012-08-06tests: printf-surprise: avoid unwarranted failure on FreeBSD 9.0Jim Meyering
* tests/misc/printf-surprise: A VM size of 10,000KiB was too little in which to run "env printf ..." on FreeBSD 9.0-p3. Increase it to 15,000.
2012-08-04df: fix exit code and error messages with --totalBernhard Voelker
When the combination of the file system options with given files or devices does not lead to output, "df --total" would exit successfully although it should not. Examples: $ df --total --type=xfs / # when / is not an XFS file system $ df --total --local -t nfs DIR # nfs is remote per se ... $ df --total -t qwerty /dev/sdb5 # typo in file system type Furthermore, "df --total" would not print the error message "no file systems processed" when the file argument does not exist or is otherwise not accessible. Example: $ df --total __not_exist__ These 2 bugs are present since --total was added by commit v6.12-166-gea2887b. * src/df.c (get_dev): Do not set file_systems_processed to true when force_fsu is true, i.e. when the row for the "total" line is processed. (main): Don't print totals unless we've processed a file system. Also only print the "no FS processed" message if there was no preceding diagnostic. * tests/df/total-unprocessed: Add a new test. * tests/Makefile.am: Reference the new test. * NEWS: Mention the fix. Improved-by: Jim Meyering
2012-08-04tests: avoid FP ulimit failure with valgrind-wrapped toolsJim Meyering
* tests/init.cfg (require_ulimit_): Raise VM limit from 10MiB to 20MiB, to accommodate overhead of a valgrind-wrapped date program. Also declare this function's local variables "local".
2012-07-23tests: add a test for a previously fixed output format bug in joinPádraig Brady
Add a test and NEWS entry for a bug inadvertently fixed in a refactoring in commit v8.9-32-gd4db0cb * tests/misc/join (v2-format): Add a new test. * THANKS.in: Add the reporter. * NEWS: Mention the old bug. * cfg.mk (old_NEWS_hash): Update. Reported-by: Jean-Pierre Tosoni
2012-07-18tests: fiemap-perf: avoid a false failure on ext2Andrew D Warshall
* tests/cp/fiemap-perf: Skip the test on ext2 file systems, as we do for ext3. Also skip the test if we can't create a 1TiB file, which might not be supported on certain file systems. Signed-off-by: Pádraig Brady <P@draigBrady.com>
2012-07-16maint: move two df tests from tests/misc to tests/dfPádraig Brady
* test/Makefile.am: Reference the moved tests.
2012-07-16df: don't output control characters in a mount point namePádraig Brady
It's awkward to read and problematic for scripts when control characters like '\n' are output. Note other fields are already handled with mbsalign, which converts non printable chars to the replacement char. A caveat to note with that, is the replacement char takes a place in the field and so possibly truncates the field if it was the widest field in the records. Note a more general replacement function, that handles all printable, or non white space characters, would require more sophisticated support for various encodings, and the complexity vs benefit was not deemed beneficial enough at present. Perhaps in future a more general replacement function could be shared between the various utilities. Note <space> is unaffected in any field, which could impact scripts processing the output. However any of the number fields at least could have spaces considering `LANG=fr_FR df -B\'1`, so it's probably best to leave spaces, which also allows scripts to handle mount points with spaces without change. * src/df.c (hide_problematic_chars): Replace control chars with '?'. * tests/df/problematic-chars: Add a new root only test. * tests/Makefile.am: Reference the new test. * NEWS: Mention the fix.
2012-07-06tests: sort-merge-fdlimit: reduce the limit by onePádraig Brady
* tests/misc/sort-merge-fdlimit: As a consequence of commit v8.17-34-g59daf05, we can reduce the descriptor limit by one.
2012-07-04date: fails to diagnose invalid inputJim Meyering
date -d "$(printf '\xb0')" would print 00:00:00 with today's date rather than diagnosing the invalid input. Now it reports this: date: invalid date '\260' * gnulib: Update submodule to latest for fixed parse-datetime.y. * tests/misc/date [invalid-high-bit-set]: New test. * NEWS (Bug fixes): Mention it. * bootstrap, tests/init.sh: Also update to latest. Reported by Peter Evans in http://bugs.gnu.org/11843
2012-07-02sort: avoid redundant processing with inaccessible inputs or outputPádraig Brady
* src/sort.c (check_inputs): A new function to verify all inputs are accessible before further processing. (check_output): A new function to open or create a specified output file, before futher processing. (stream_open): Adjust to truncating the previously opened output file rather than opening directly. (avoid_trashing_input): Optimize to stat the output file descriptor, rather than the file name. (main): Call the new functions to check accessibility of inputs and output, before processing starts. * tests/misc/sort: Adjust to the changed error message. * tests/misc/sort-merge-fdlimit: Account for the earlier opened file descriptor of the specified output file. * tests/misc/sort-exit-early: A new test to exercise the improvements. * tests/Makefile.am: Reference the new test. * NEWS: Mention the improvement. Suggested-by: Bernhard Voelker
2012-06-22split: ensure output doesn't overwrite inputPádraig Brady
* src/split.c (create): Check if output file is the same inode as the input file. * tests/split/guard-input: New test case. * tests/Makefile.am: Reference new test case. * NEWS: Mention the fix. Improved-by: Jim Meyering Reported-by: François Pinard