summaryrefslogtreecommitdiffstats
path: root/tests/fold
AgeCommit message (Collapse)AuthorLines
13 daysmaint: tests: refactor uses of bad_unicode()Pádraig Brady-6/+1
* init.cfg: Use 0xFF rather than 0xC3 everywhere. * tests/fold/fold-characters.sh: Reuse bad_unicode(). * tests/tac/tac-locale.sh: Likewise.
13 daysfold: fix output truncation with 0xFF bytes in inputPádraig Brady-4/+5
On signed char platforms, 0xFF was converted to -1 which matches MBBUF_EOF, causing fold to stop processing. * NEWS: Mention the bug fix. * gl/lib/mbbuf.h: Avoid sign extension on signed char platforms. * tests/fold/fold-characters.sh: Adjust test case. Reported at https://src.fedoraproject.org/rpms/coreutils/pull-request/20
2026-02-18maint: tests: avoid ENOSPC specific handlingPádraig Brady-3/+6
* tests/csplit/csplit-io-err.sh: Adjust determination of ENOSPC. * tests/csplit/split-io-err.sh: Likewise. * tests/fold/fold-zero-width.sh: Verify full ENOSPC message. * tests/tac/tac-continue.sh: Likewise. * tests/misc/io-errors.sh: Likewise. * tests/misc/write-errors.sh: Likewise.
2026-02-06tests: fold: check that all files are processedCollin Funk-0/+36
* tests/fold/multiple-files.sh: New file. * tests/local.mk (all_tests): Add the test.
2026-01-06tests: mktemp: add tests for invalid Unicode optionsCollin Funk-3/+4
* init.cfg (bad_unicode): New function, copied from tests/fold/fold-characters.sh with the NUL removed. * tests/fold/fold-characters.sh (bad_unicode): Rename to bad_unicode_with_nul. Reformat long line. * tests/mktemp/bad-unicode.sh: New test. * tests/local.mk (all_tests): Add the new test.
2026-01-01maint: run 'make update-copyright'Collin Funk-5/+5
2025-09-21tests: avoid false failure on older Linux kernelsPádraig Brady-1/+3
* tests/fold/fold-zero-width.sh: Check the shell was able to create the redirection file, as intermittently on CentOS 5,6,7 this wasn't the case, with the shell giving an xmalloc failure due to the ulimit. Reported by William Bader and Bruno Haible.
2025-09-20tests: fold: avoid false failures on Solaris 10Pádraig Brady-3/+8
* tests/fold/fold-characters.sh: Ensure we have independent verification of the width of characters before testing based on those widths. * tests/fold/fold-zero-width.sh: Likewise. * tests/fold/fold.pl: Only compare the exit status, as the error message can be translated.
2025-09-20tests: avoid false failure on CentOS 5,6,7Pádraig Brady-1/+1
* tests/fold/fold-zero-width.sh: Increase vm limit to avoid failures on CentOS 5,6,7. Match the limit used in write-errors.sh as per commit v9.5-255-g0bd149403
2025-09-17tests: fix issues with fold-characters.sh testPádraig Brady-6/+0
This was noticed with: trap '' PIPE && # Ignore SIGPIPE make check TESTS=tests/fold/fold-characters.sh SUBDIRS=. * tests/fold/fold-characters.sh: Move memory limit test to ... * tests/misc/write-errors.sh: ... which avoids "write error" messages on stderr due to the ignored SIGPIPE. It also protects the fold invocation with a timeout(1) so that fold implementations that don't exit promptly upon write error don't hang the test suite (Like we would have done before commit v9.7-311-gc95c7ee76).
2025-09-16fold: fix write error checks with invalid multi-byte inputPádraig Brady-3/+8
* src/fold.c (write_out): A new helper to check all writes. (fold-file): Use write_out() for all writes. * tests/fold/fold-zero-width.sh: Adjust to writing more data in various patterns, rather than two buffers of NULs. This is a more robust memory bound check, and the '\303' case tests this particular logic change. * NEWS: fold now exits immediately, not just promptly.
2025-09-16tests: fold/fold-zero-width.sh: avoid false failure with ENOSPCPádraig Brady-5/+6
* tests/fold/fold-zero-width.sh: Check relatively large test file is created appropriately. Also apply more idomatic wc -l usage.
2025-09-15fold: fix out of bounds write with zero width charactersCollin Funk-0/+55
* src/fold.c (fold_file): Prefer putchar ('\n') to copying characters. If we do not have room in the output buffer print it since it is not a full line of text. * tests/fold/fold-zero-width.sh: New test case. * tests/local.mk (all_tests): Add it.
2025-09-04tests: fold: check if multi-byte spaces are treated as blankCollin Funk-13/+26
This avoids a test failure on FreeBSD 14, MacOS 15, and musl. Fix suggested by Pádraig Brady in: <https://bugs.gnu.org/79301#32>. * tests/fold/fold-spaces.sh (isblank): New function. Only run the tests if the character is treated as blank. Fixes https://bugs.gnu.org/79301
2025-08-28fold: fix handling of invalid multi-byte charactersCollin Funk-0/+11
* src/fold.c (fold_file): Continue the loop when we have buffered bytes but nothing left to read from the file. (adjust_column): Don't assume that the character is printable. * tests/fold/fold-characters.sh: Add a new test case. (bad_unicode): New function.
2025-08-27tests: fold: add tests for multi-byte widthPádraig Brady-0/+22
* tests/fold/fold.pl: The i18n patch didn't actually test folding of multi-byte characters, so add tests for various multi-byte forms.
2025-08-27tests: fold: copy i18n patch testsPádraig Brady-1/+33
* tests/fold/fold.pl: Copy tests from Fedora, removing copy & pasted logic that was extraneous to either the i18n patch or upstream.
2025-08-27tests: parameterize IO_BUFSIZEPádraig Brady-1/+4
* src/getlimits.c (main): Output IO_BUFSIZE, useful for sizing data for tests. * tests/fold/fold-characters.sh: Use it rather than hardcoding.
2025-08-26fold: don't truncate multibyte characters at the end of the bufferCollin Funk-0/+19
* src/fold.c (fold_file): Replace invalid characters with the original byte read. Copy multibyte sequences that may not yet be read to the start of the buffer before reading more bytes. * tests/fold/fold-characters.sh: Add a test case.
2025-08-26tests: fold: consolidate all fold tests in tests/foldPádraig Brady-1/+52
* tests/misc/fold.pl: Move from here to ... * tests/fold/fold.pl: ... here. * tests/local.mk: Adjust accordingly.
2025-08-26tests: fold: add a memory constraint testPádraig Brady-0/+6
Enforcing this interface behavior is worthwhile irrespective of our current implementation, to ensure future or other implementations conform. * tests/fold/fold-characters.sh: Ensure the fold implementation uses bounded memory.
2025-08-22fold: add the --characters optionCollin Funk-0/+143
* src/fold.c: Include mcel.h. (count_bytes): Remove variable. (counting_mode, last_character_width): New variables. (shortopts, long_options): Add the option. (adjust_column): If --characters is in used account for number of characters instead of their width. (fold_file): Use getline and iterate over the result with mcel functions to handle multibyte characters. (main): Check for the option. * src/local.mk (src_fold_LDADD): Add $(LIBC32CONV), $(LIBUNISTRING), and $(MBRTOWC_LIB). * tests/fold/fold-characters.sh: New file. * tests/fold/fold-spaces.sh: New file. * tests/fold/fold-nbsp.sh: New file. * tests/local.mk (all_tests): Add the tests. * NEWS: Mention the new option. * doc/coreutils.texi (fold invocation): Likewise.