]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: parameterize IO_BUFSIZE
authorPádraig Brady <P@draigBrady.com>
Tue, 26 Aug 2025 17:04:56 +0000 (18:04 +0100)
committerPádraig Brady <P@draigBrady.com>
Wed, 27 Aug 2025 11:03:46 +0000 (12:03 +0100)
* src/getlimits.c (main): Output IO_BUFSIZE, useful for
sizing data for tests.
* tests/fold/fold-characters.sh: Use it rather than hardcoding.

src/getlimits.c
tests/fold/fold-characters.sh

index 7c902bc1d92fb01a8ce2edad0916593f01444683..1cd10a6e987a7ee6a72ab3e466d2ec245efa7183 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "ftoastr.h"
 #include "system.h"
+#include "ioblksize.h"
 #include "long-options.h"
 
 #define PROGRAM_NAME "getlimits"
@@ -168,5 +169,8 @@ main (int argc, char **argv)
   print_float (DBL);
   print_float (LDBL);
 
+  /* Other useful constants */
+  printf ("IO_BUFSIZE=%ju\n", (uintmax_t) IO_BUFSIZE);
+
   return EXIT_SUCCESS;
 }
index be17d80be1726ef55407b4f3ba38a0c0b858a6a2..7de718450cbae139622866cbbfe9cd4eb622e5f1 100755 (executable)
@@ -18,6 +18,7 @@
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ fold printf
+getlimits_
 
 test "$LOCALE_FR_UTF8" != none || skip_ "French UTF-8 locale not available"
 
@@ -60,7 +61,9 @@ compare character-exp2 character-out2 || fail=1
 
 # Test a Unicode character on the edge of the input buffer.
 # Keep in sync with IO_BUFSIZE - 1.
-yes a | head -n 262143 | tr -d '\n' > input3 || framework_failure_
+IO_BUFSIZE_MINUS_1=$(($IO_BUFSIZE - 1))
+test $IO_BUFSIZE_MINUS_1 -gt 0 || framework_failure_
+yes a | head -n $IO_BUFSIZE_MINUS_1 | tr -d '\n' > input3 || framework_failure_
 env printf '\uB250' >> input3 || framework_failure_
 yes a | head -n 100 | tr -d '\n' >> input3 || framework_failure_
 env printf '\n' >> input3 || framework_failure_