summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
...
* cksum: accept new option: --base64 (-b)Jim Meyering2023-01-312-0/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/digest.c [HASH_ALGO_CKSUM]: Include "base64.h" [HASH_ALGO_CKSUM] (base64_digest): New global. [HASH_ALGO_CKSUM] (enum BASE64_DIGEST_OPTION): New enum. [HASH_ALGO_CKSUM] (long_options): Add "base64". (valid_digits): Rename from hex_digits, now taking an input length argument. Adjust callers. (bsd_split_3): Rename arg from hex_digits to digest. Add new *d_len parameter for length of extracted digest. Move "i" declaration down to first use. (split_3): Rename arg from hex_digits to digest. Add new *d_len parameter for length of extracted digest. Instead of relying on "known" length of digest to find the following must-be-whitespace byte, search for the first whitespace byte. [HASH_ALGO_CKSUM] (output_file): Handle base64_digest. [HASH_ALGO_CKSUM] (main): Set base64_digest. [HASH_ALGO_CKSUM] (b64_equal): New function. (hex_equal): New function, factored out of digest_check. (digest_check) Factored part into b64_equal and hex_equal. Rename local hex_digest to digest. * tests/misc/cksum-base64.pl: Add tests. * tests/local.mk (all_tests): Add to the list. * cfg.mk (_cksum): Define. (exclude_file_name_regexp--sc_prohibit_test_backticks): Exempt new test. (exclude_file_name_regexp--sc_long_lines): Likewise. * doc/coreutils.texi (cksum invocation): Document it. (md5sum invocation) [--check]: Mention digest encoding auto-detect. * NEWS (New Features): Mention this.
* cp,mv: skipping due to -u is success, not failurePaul Eggert2023-01-312-4/+3
| | | | | | | | | | This reverts the previous change, so that when a file is skipped due to -u, this is not considered a failure. * doc/coreutils.texi: Document this. * src/copy.c (copy_internal): If --update says to skip, treat this as success instead of failure. * tests/mv/update.sh, tests/cp/slink-2-slink.sh: Revert previous change, to match reverted behavior.
* cp,ln,mv: when skipping exit with nonzero statusPaul Eggert2023-01-317-15/+16
| | | | | | | | | | | * NEWS, doc/coreutils.texi: Document this. * src/copy.c (copy_internal): * src/ln.c (do_link): Return false when skipping action due to --interactive or --no-clobber. * tests/cp/cp-i.sh, tests/cp/preserve-link.sh: * tests/cp/slink-2-slink.sh, tests/mv/i-1.pl, tests/mv/i-5.sh: * tests/mv/mv-n.sh, tests/mv/update.sh: Adjust expectations of exit status to match revised behavior.
* tests: cksum: fix test to include more casesPádraig Brady2023-01-301-1/+1
| | | | | * tests/misc/cksum-c.sh: Fix typo which caused part of the test data to be ignored.
* tests: ensure we fail if mv --no-copy crashesPádraig Brady2023-01-271-2/+2
| | | | | * tests/mv/no-copy.sh: Honor `make syntax` check and use the `returns_ 1 ...` pattern.
* mv: new option --no-copyPaul Eggert2023-01-272-0/+34
| | | | | | | | | | | Wishlist item from Mike Frysinger (Bug#61050). * src/copy.c (copy_internal): Do not fall back on copying if x->no_copy. * src/copy.h (struct cp_options): New member no_copy. * src/mv.c (NO_COPY_OPTION): New constant. (long_options, usage, main): Support --no-copy. * tests/mv/no-copy.sh: New test. * tests/local.mk (all_tests): Add it.
* all: further adjustments for new Ronna, Quetta SI prefixesPádraig Brady2023-01-061-3/+3
| | | | | | | | | | | | | | * src/dd.c (parse_integer): Support Q,R suffixes. * src/od.c (main): Likewise. * src/split.c (main): Likewise. * src/stdbuf.c (parse_size): Likewise. * src/truncate.c (main): Likewise. * src/sort.c (specify_size_size): Likewise. Also line length syntax check fix. * tests/misc/numfmt.pl: Adust top end large number checks to the new largest values. * doc/coreutils.texi (numfmt invocation): Add a numfmt example. * NEWS: Tweak to aid searchability.
* numfmt: add support for new SI prefixesPaul Eggert2023-01-052-39/+45
| | | | | | | | | | | | | | | | | | | | | * src/dd, src/head.c, src/od.c, src/sort.c, src/stdbuf.c, src/tail.c: (usage): * src/system.h (emit_size_note): Mention new SI prefixes. * src/du.c (main): * src/head.c (head_file): * src/numfmt.c (suffix_power, suffix_power_char, prepare_padded_number): * src/shred.c (main): * src/sort.c (unit_order): * src/tail.c (parse_options): Support new SI prefixes. * src/numfmt.c (MAX_ACCEPTABLE_DIGITS): Increase to 33. (zero_and_valid_suffixes, valid_suffixes): New constants, with new SI prefixes. (valid_suffix, unit_to_umax): Use them. (prepare_padded_number): Diagnose "999Q" instead of "999Y". * tests/misc/numfmt.pl, tests/misc/sort.pl: Adjust tests to match new max.
* maint: update all copyright year number rangesPádraig Brady2023-01-01608-608/+608
| | | | | | | | | | Update to latest gnulib with new copyright year. Run "make update-copyright" and then... * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Manually update copyright year, until we fully sync with gnulib at a later stage. * tests/sample-test: Adjust to use the single most recent year.
* build: update gnulib submodule to latestPádraig Brady2023-01-011-20/+25
| | | | | | mainly to get updated copyright year * tests/init.sh: Sync with gnulib
* stty: fix off by one column wrapping on outputPádraig Brady2022-12-311-0/+6
| | | | | | | | * src/stty.c (wrapf): Adjust the comparison by 1, to account for the space we're adding. * tests/misc/stty.sh: Add a test case. * NEWS: Mention the fix. Reported in https://bugs.debian.org/1027442
* wc: fix regression determining file sizePádraig Brady2022-12-291-0/+7
| | | | | | | | | | | | * src/wc.c (wc): Use off_t rather than size_t when calculating where to seek to, so that we don't seek to a too low offset on systems where size_t < off_t, which would result in many read() calls to determine the file size. * tests/misc/wc-proc.sh: Add a test case sufficient for 32 bit systems at least. * NEWS: Mention the bug fix. Reported at https://bugs.debian.org/1027101
* maint: avoid recent syntax check failurePádraig Brady2022-12-291-2/+3
| | | | * tests/cp/proc-short-read.sh: Adjust so shorter lines.
* tests: accommodate bogomips capitalizationsPaul Eggert2022-12-261-2/+2
| | | | | | * tests/cp/proc-short-read.sh: Kernel on ARMv7 Processor rev 3 (v7l) spells it "BogoMIPS", so allow any capitalization. Patch from Zach van Rijn in <https://bugs.gnu.org/60339>.
* maint: avoid new grep -q syntax-check failuresPádraig Brady2022-11-152-2/+2
| | | | | | | * cfg.mk: Exclude NEWS from the check. * init.cfg: s/grep -q/grep >/dev/null/. * tests/ls/hyperlink.sh: Likewise. * tests/ls/symlink-quote.sh: Likewise.
* printf: with \U, support all valid unicode pointsPádraig Brady2022-10-281-3/+8
| | | | | | | | | | | | | Previously this was restricted to the C99 universal character subset, which restricted most values <= 0x9F, as that simplifies the C lexer. However printf(1) doesn't need this restriction. Note also the bash builtin printf already supports all values <= 0x9F. * src/printf.c (main): Relax the restriction on points <= 0x9F. * doc/coreutils.texi (printf invocation): Adjust description. * tests/misc/printf-cov.pl: Adjust accordingly. Add new cases. * NEWS: Mention the change in behavior. Reported at https://bugs.debian.org/1022857
* runcon: fix inconsistent exit status upon write errorPádraig Brady2022-09-281-0/+1
| | | | | | | * src/runcon.c (main): Call initialize_exit_failure(), so we use an appropriate exit status upon failure to close stdout. This should have been part of recent commit ea3ee6df. * tests/misc/help-version.sh: Adjust test case accordingly.
* wc: add --total={auto,never,always,only} optionPádraig Brady2022-09-262-0/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | without this option, control of when the total is output is quite awkward. Consider trying to suppress the total line, which could be achieved with something like: wc-no-total() { wc "$@" /dev/null | head -n-2; } As well as being non obvious, it's also non general. It would give a non failure, but zero count if passed a file on stdin. Also it doesn't work in conjunction with the --files0-from option, which would need to be handled differently with something like: { find files -print0; printf '%s\0' /dev/null; } | wc --files0-from=- | head -n2 Also getting just the total can be awkward as file names are only suppressed when processing stdin, and also a total line is only printed if processing more than one file. For completness this might be achieved currently with: wc-only-total() { wc "$@" | tail -n1 | sed 's/^ *//; s/ [^ 0-9]*$//' } * src/wc.c: Add new --total option. * tests/misc/wc-total.sh: New test suite for the new option. * tests/local.mk: Reference the new test. * doc/coreutils.texi (wc invocation): Document the new option. * THANKS.in: Add suggestor. * NEWS: Mention the new feature.
* rm: fix diagnostics on I/O errorPaul Eggert2022-09-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I ran into this problem when attempting to recursively remove a directory in a filesystem on flaky hardware. Although the underlying readdir syscall failed with errno == EIO, rm issued no diagnostic about the I/O error. Without this patch I see this behavior: $ rm -fr baddir rm: cannot remove 'baddir': Directory not empty $ rm -ir baddir rm: descend into directory 'baddir'? y rm: remove directory 'baddir'? y rm: cannot remove 'baddir': Directory not empty With this patch I see the following behavior, which lets the user know about the I/O error when rm tries to read baddir's directory entries: $ rm -fr baddir rm: cannot remove 'baddir': Input/output error $ rm -ir baddir rm: cannot remove 'baddir': Input/output error * src/remove.c (Ternary): Remove. All uses removed. (get_dir_status): New static function. (prompt): Last arg is now directory status, not ternary. Return RM_USER_ACCEPTED if user explicitly accepted. All uses changed. Report any significant error in directory status right away. (prompt, rm_fts): Use get_dir_status to get directory status lazily. (excise): Treat any FTS_DNR errno as being more descriptive, not just EPERM and EACCESS. For example, EIO is more descriptive. (rm_fts): Distinguish more clearly between explicit and implied user OK. * src/remove.h (RM_USER_ACCEPTED): New constant. (VALID_STATUS): Treat it as valid. * src/system.h (is_empty_dir): Remove, replacing with ... (directory_status): ... this more-general function. All uses changed. Avoid undefined behavior of looking at a non-null readdir pointer after corresponding closedir. * tests/rm/rm-readdir-fail.sh: Adjust test of internals to match current behavior.
* rm: fix readdir testPaul Eggert2022-09-241-1/+1
| | | | | * tests/rm/rm-readdir-fail.sh [_DIRENT_HAVE_D_NAMELEN]: Fix off-by-1 bug in directory entry length.
* all: prefer HTTPS to HTTPStefan Kangas2022-09-182-2/+2
| | | | | | | | | | | | | | | * README-hacking: * README-prereq: * THANKS.in: * doc/sort-version.texi (Other version/natural sort implementations): * gl/lib/rand-isaac.c: * gl/tests/test-rand-isaac.c: * src/operand2sig.c (operand2sig): * src/remove.c (nonexistent_file_errno): * tests/misc/env-signal-handler.sh: * tests/misc/sort-debug-warn.sh (LC_ALL): Prefer HTTPS to HTTP. Addresses https://bugs.gnu.org/56512 Copyright-paperwork-exempt: yes
* stty: validate ispeed and ospeed argumentsPádraig Brady2022-08-311-0/+3
| | | | | | | | | | * src/stty.c (apply_settings): Validate [io]speed arguments against the internal accepted set. (set_speed): Check the cfset[io]speed() return value so that we validate against the system supported set. * tests/misc/stty-invalid.sh: Add a test case. * NEWS: Mention the bug fix. Reported in https://bugs.debian.org/1018790
* tests: runcon: fix new test to skip on non SELinux systemsPádraig Brady2022-08-271-1/+3
| | | | | * tests/misc/runcon-compute.sh: Use our new internal error 125 status to detect SELinux errors, and skip in this case.
* tests: fix tests after recent runcon changePádraig Brady2022-08-272-1/+2
| | | | | | | Following commit v9.1-49-gea3ee6df2 * tests/misc/invalid-opt.pl: Map runcon failure status to 125. * tests/misc/usage_vs_getopt.sh: Likewise.
* comm: fix NUL --output-delimiter with --totalPádraig Brady2022-08-271-0/+3
| | | | | | | | | | | * src/comm.c (compare_files): Handle the single character --output-delimeter case separately so that NUL is appropriately handled. * doc/coreutils.texi (comm invocation): Fix the description of --output-delimiter to say an empty delimeter is treated as a NUL separator, rather than being disallowed. * tests/misc/comm.pl: Add a test case. Reported at https://bugs.debian.org/1014008
* runcon: distinguish runcon specific errors in exit statusPádraig Brady2022-08-271-0/+2
| | | | | | | | | * src/runcon.c: Use EXIT_CANCELED (125) instead of EXIT_FAILURE (1), so that errors specific to runcon can be distinguished, from those of the invoked program. * doc/coreutils.texi (runcon invocation): Fix the Exit status description to say we return 125 (not 127) for internal errors. * tests/misc/runcon-no-reorder.sh: Add a test case.
* ls: support explicit --time=modification selectionPádraig Brady2022-08-131-1/+1
| | | | | | | | * src/ls.c [time_args]: Add support for explicit 'mtime' or 'modification' arguments to --time. * tests/misc/ls-time.sh: Add explicit --time=mtime usage. * doc/coreutils.texi (ls invocation): Describe --time=mtime. * NEWS: Mention the new feature.
* date: --debug: diagnose discarded -d or -s optionsPádraig Brady2022-07-241-0/+10
| | | | | | | | * src/date.c: (main): Track and diagnose whether any -d or -s options are dropped, as users may think multiple options are supported, given they can be relative. * tests/misc/date-debug.sh: Add a test case. * NEWS: Mention the improvement.
* runcon: ensure --compute runs the file it inspectsPádraig Brady2022-07-242-0/+29
| | | | | | | | | * src/runcon.c (main): With -c avoid searching the path to ensure the file specified to --compute is executed. * tests/misc/runcon-compute.sh: Add a new test. * tests/local.mk: Reference the new test. * NEWS: Mention the bug fix. Reported in https://bugs.debian.org/1013924
* build: update gnulib submodule to latestPaul Eggert2022-06-031-4/+3
| | | | | * bootstrap: Copy from latest Gnulib. * tests/misc/ls-misc.pl (v_files): Adjust to new Gnulib behavior.
* factor: --exponents: new option for printing in p^e formatRasmus Villemoes2022-05-091-1/+4
| | | | | | | | | | | | | | | When factoring numbers that have a large 2^n factor, it can be hard to eyeball just how many 2's there are. Add an option to print each prime power factor in the p^e format (omitting the exponent when it is 1). * src/factor.c: Add -h, --exponents option for printing in p^e format. * doc/coreutils.texi (factor invocation): Document the new option. * tests/misc/factor.pl: Add test case. * THANKS.in: Add previous suggester (https://lists.gnu.org/r/coreutils/2017-11/msg00015.html). Suggested-by: Emanuel Landeholm <emanuel.landeholm@gmail.com> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
* tests: sort-NaN-infloop: augment testing for recent fixPádraig Brady2022-05-021-0/+3
| | | | | | * tests/misc/sort-NaN-infloop.sh: Add test case from https://unix.stackexchange.com/a/700967/37127 * src/sort.c: Avoid syntax-check failure.
* mv: test Bug#55029Paul Eggert2022-04-201-0/+6
| | | | | * tests/mv/backup-dir.sh: New test for Bug#55029, reported by Steve Ward.
* tail: detect closed stdout on SolarisPádraig Brady2022-04-131-2/+2
| | | | | | | | | * src/tail.c (check_output_alive): Use poll() on Solaris. Also handle POLLHUP, which Solaris returns in this case. * tests/tail-2/pipe-f.sh: Use `head -n2` rather than `sed 2q` as Solaris sed does not exit in this case. * NEWS: Mention the improvement. Reported by Bruno Haible.
* tests: cygwin: handle ENOENT from execvp(".")Pádraig Brady2022-04-134-8/+8
| | | | | | | | | * tests/misc/env.sh: Verify with another command that execvp() doesn not return ENOENT, before testing the exit code from the command in question. * tests/misc/nice-fail.sh: Likewise. * tests/misc/stdbuf.sh: Likewise. * tests/misc/timeout-parameters.sh: Likewise.
* tests: env-S.pl: unset cygwin hardwired env varsPádraig Brady2022-04-131-2/+6
| | | | * tests/misc/env-S.pl: Unset SYSTEMROOT and WINDIR.
* tests: md5sum: fix false failures on cygwinPádraig Brady2022-04-122-2/+2
| | | | | | | | * tests/misc/md5sum-newline.pl: Avoid binary '*' tags when comparing checksums. * tests/misc/md5sum-bsd.sh: Avoid binary '*' tags so that we correctly trigger the ambiguity test. Reported by Bruno Haible
* tests: b2sum.sh: fix false failure on cygwinPádraig Brady2022-04-111-2/+4
| | | | | * tests/misc/b2sum.sh: Avoid binary '*' tags when comparing checksums. Reported by Bruno Haible
* tests: dircolors.pl: avoid false failure with TERM=dumbPádraig Brady2022-04-111-0/+5
| | | | | | | * tests/Coreutils.pm: Ensure an unset $TERM env var, which is required on perl 5.22.2 on Solaris 11 OpenIndiana at least, where TERM was being reset to 'dumb'. Reported By Bruno Haible.
* tests: printf-mb.sh: fix false failure with french translationsPádraig Brady2022-04-111-5/+13
| | | | | | * tests/misc/printf-mb.sh: As per commit 04148c99c, adjust non C warnings before comparison, to those of LC_MESSAGES=C. Reported by Adam Sampson
* cp,mv,install: avoid opening non directory destinationPádraig Brady2022-04-091-7/+5
| | | | | | | | | | | | | | | | | commit v9.0-66-ge2daa8f79 introduced an issue, for example where cp could hang when overwriting a destination fifo, when it would try to open() the fifo on systems like Solaris 10 that didn't support the O_DIRECTORY flag. This is still racy on such systems, but only in the case where a directory is replaced by a fifo in the small window between stat() and open(). * src/system.h (target_directory_operand): On systems without O_DIRECTORY, ensure the file is a directory before attempting to open(). * tests/cp/special-f.sh: Protect cp with timeout(1), as cp was seen to hang when trying to overwrite an existing fifo. * NEWS: Mention the bug fix.
* tests: improve recent printf testPádraig Brady2022-03-201-0/+4
| | | | | | * tests/misc/printf-mb.sh: Given we shortcut the single char (invalid multi-byte) case, add a case to ensure we're correctly checking the return from mbrtowc().
* printf: support printing the numeric value of multi-byte charsPádraig Brady2022-03-192-0/+53
| | | | | | | | * src/printf.c (STRTOX): Update to support multi-byte chars. * tests/misc/printf-mb.sh: Add a new test. * tests/local.mk: Reference the new test. * NEWS: Mention the improvement. Fixes https://bugs.gnu.org/54388
* date: fix newly-introduced %%-N bugPaul Eggert2022-03-051-0/+3
| | | | | * src/date.c (adjust_resolution): Don’t mishandle %%-N. * tests/misc/date.pl (pct-pct): New test.
* fmt: fix invalid multi-byte splitting on macOSPádraig Brady2022-02-242-1/+51
| | | | | | | | | | | On macOS, isspace(0x85) returns true, which results in splitting within multi-byte characters. * src/fmt.c (get_line): s/isspace/c_isspace/. * tests/fmt/non-space.sh: Add a new test. * tests/local.mk: Reference new test. * NEWS: Mention the fix. Addresses https://bugs.gnu.org/54124
* tests: improve compat with macOSPádraig Brady2022-02-241-2/+2
| | | | | | * tests/misc/wc-nbsp.sh: Only the en_US.iso8859-1 form is accepted on macOS 10.15.7 at least. GNU/Linux also accepts ISO-8859-1 (and canonicalizes the charmap to this).
* dd: counts ending in "B" now count bytesPaul Eggert2022-02-222-31/+38
| | | | | | | | | | This implements my suggestion in Bug#54112. * src/dd.c (usage): Document the change. (parse_integer, scanargs): Implement the change. Omit some now-obsolete checks for invalid flags. * tests/dd/bytes.sh: Test the new behavior, while retaining checks for the now-obsolete usage. * tests/dd/nocache_eof.sh: Avoid now-obsolete usage.
* dd: support iseek= and oseek=Paul Eggert2022-02-221-0/+10
| | | | | | Alias iseek=N to skip=N, oseek=N to seek=N (Bug#45648). * src/dd.c (scanargs): Parse iseek= and oseek=. * tests/dd/skip-seek.pl (sk-seek5): New test case.
* dircolors: consider COLORTERM as well as TERM env varsPádraig Brady2022-02-151-0/+8
| | | | | | | | | | | | | | | COLORTERM is an environment used usually to expose truecolor support in terminal emulators. Therefore support matches on that in addition to TERM. Also set the default COLORTERM match pattern so that we apply colors if COLORTERM is any value. This implicitly supports a terminal like "foot" without a need for an explicit TERM entry. * NEWS: Mention the new feature. * src/dircolors.c (main): Match COLORTERM like we do for TERM. * src/dircolors.hin: Add default config to match any COLORTERM. * tests/misc/dircolors.pl: Add test cases.
* dircolors: add --print-ls-colors to display colored entriesPádraig Brady2022-02-131-1/+15
| | | | | | | | | | | | * NEWS: Mention the new feature. * doc/coreutils.texi (dircolors invocation): Describe the new --print-ls-colors option. * src/dircolors.c (print_ls_colors): A new global to select between shell or terminal output. (append_entry): A new function refactored from dc_parse_stream() to append the entry in the appropriate format. (dc_parse_stream): Adjust to call append_entry(). * tests/misc/dircolors.pl: Add test cases.