Collin Funk <[email protected]> writes:

> You can also see the difference like this:
>
>     $ printenv PERL_UNICODE
>     $ perl -e 'print join ("\n", PerlIO::get_layers (STDOUT)) . "\n"'
>     unix
>     perlio
>     $ PERL_UNICODE=S perl -e 'print join ("\n", PerlIO::get_layers (STDOUT)) 
> . "\n"'
>     unix
>     perlio
>     utf8
>
> If not, perhaps there is another way to get this behavior?

I guess you can add -C to PERL5OPT to get this behavior as well, and
likely in many other ways.

I've attached a patch that should fix the issue. It adds a call to
"binmode STDOUT" before those tests. That should be enough, but I have
also set PERL_UNICODE to 0 in the TESTS_ENVIRONMENT, since I suspect it
may cause problems later down the line. I've left PERL5OPT untouched
since it seems useful to allow customizing it when running tests.

I've left it unpushed for now, in case someone better at Perl than I has
any better ideas.

Thanks again,
Collin

>From 01ef17fe8cd568f715f7c6bf6dd2dcbdde9489ea Mon Sep 17 00:00:00 2001
Message-ID: <01ef17fe8cd568f715f7c6bf6dd2dcbdde9489ea.1791180446.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Sun, 4 Oct 2026 22:55:08 -0700
Subject: [PATCH] tests: sum,cp: disable Unicode when executing Perl

* tests/local.mk (TESTS_ENVIRONMENT): Set PERL_UNICODE to 0.
* tests/cksum/sum-sysv.sh: Call binmode on STDOUT.
* tests/cp/copy-FMR.sh: Likewise.
* tests/cp/sparse-extents-2.sh: Likewise.
Fixes https://bugs.gnu.org/81994
---
 tests/cksum/sum-sysv.sh      | 6 ++++--
 tests/cp/copy-FMR.sh         | 2 +-
 tests/cp/sparse-extents-2.sh | 2 +-
 tests/local.mk               | 1 +
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/tests/cksum/sum-sysv.sh b/tests/cksum/sum-sysv.sh
index 854870018..76e85dc49 100755
--- a/tests/cksum/sum-sysv.sh
+++ b/tests/cksum/sum-sysv.sh
@@ -30,7 +30,8 @@ require_perl_
 # FYI, 16843009 is floor (2^32 / 255).
 
 # aka: perl -e 'print chr(255) x 16843009'
-$PERL -e '$s = chr(255) x 65537; foreach (1..257) {print $s}' \
+$PERL -e 'binmode STDOUT;
+$s = chr(255) x 65537; foreach (1..257) {print $s}' \
   | sum -s > out || fail=1
 cat > exp <<\EOF
 65535 32897
@@ -40,7 +41,8 @@ compare exp out || fail=1
 rm -f out exp
 
 # aka: perl -e 'print chr(255) x 16843010'
-$PERL -e '$s = chr(255) x 65537; foreach (1..257) {print $s}; print chr(255)' \
+$PERL -e 'binmode STDOUT;
+$s = chr(255) x 65537; foreach (1..257) {print $s}; print chr(255)' \
   | sum -s > out || fail=1
 cat > exp <<\EOF
 254 32897
diff --git a/tests/cp/copy-FMR.sh b/tests/cp/copy-FMR.sh
index 7312562e0..ca5df58bd 100755
--- a/tests/cp/copy-FMR.sh
+++ b/tests/cp/copy-FMR.sh
@@ -23,7 +23,7 @@ require_valgrind_
 require_perl_
 
 # Trigger FMR in fiemap logic from v8.11..v8.19
-$PERL -e 'for (1..600) { sysseek (*STDOUT, 4096, 1)' \
+$PERL -e 'binmode STDOUT; for (1..600) { sysseek (*STDOUT, 4096, 1)' \
   -e '&& syswrite (*STDOUT, "a" x 1024) or die "$!"}' > j || fail=1
 valgrind --quiet --error-exitcode=3 cp --reflink=never j j2 || fail=1
 cmp j j2 || fail=1
diff --git a/tests/cp/sparse-extents-2.sh b/tests/cp/sparse-extents-2.sh
index e7740ae65..3dc1cac2c 100755
--- a/tests/cp/sparse-extents-2.sh
+++ b/tests/cp/sparse-extents-2.sh
@@ -68,7 +68,7 @@ f()
 
 for i in $(seq 1 2 21); do
   for j in 1 2 31 100; do
-    $PERL -e '$n = '$i' * 1024; *F = *STDOUT;' \
+    $PERL -e 'binmode STDOUT; $n = '$i' * 1024; *F = *STDOUT;' \
           -e 'for (1..'$j') { sysseek (*F, $n, 1)' \
           -e '&& syswrite (*F, chr($_)x$n) or die "$!"}' > j1 || fail=1
 
diff --git a/tests/local.mk b/tests/local.mk
index 9b9d25a4d..c513c0756 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -79,6 +79,7 @@ TESTS_ENVIRONMENT =				\
   MAKE=$(MAKE)					\
   PACKAGE_VERSION=$(PACKAGE_VERSION)		\
   PERL='$(PERL)'				\
+  PERL_UNICODE=0				\
   SHELL='$(PREFERABLY_POSIX_SHELL)'		\
   ; test -d /usr/xpg4/bin && PATH='/usr/xpg4/bin$(PATH_SEPARATOR)'"$$PATH"; \
   PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'"$$PATH" \
-- 
2.55.0

Reply via email to