aboutsummaryrefslogtreecommitdiffstats
path: root/tests/fold (follow)
AgeCommit message (Collapse)AuthorFilesLines
2025-09-21tests: avoid false failure on older Linux kernelsPádraig Brady1-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 Brady3-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 Brady1-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 Brady1-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 Brady1-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 Brady1-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 Funk1-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 Funk1-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 Funk1-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 Brady1-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 Brady1-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 Brady1-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 Funk1-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 Brady2-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 Brady1-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 Funk3-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.