]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: fix false failure with large printf formats
authorPádraig Brady <P@draigBrady.com>
Sun, 13 Aug 2017 06:53:33 +0000 (23:53 -0700)
committerPádraig Brady <P@draigBrady.com>
Mon, 14 Aug 2017 04:31:28 +0000 (21:31 -0700)
* tests/misc/printf-surprise.sh: With musl libc the
large printf format does succeed, outputting data.
To avoid SIGPIPE being generated we ignore that signal
and then handle the subsequent EPIPE error.
Addresses https://bugs.gnu.org/28054

tests/misc/printf-surprise.sh

index 2edd34ca16a3c2f085ab5eeb9dd2676de3057bcb..46c0d8f2317b451991dec8c3bd89baf24884905b 100755 (executable)
@@ -50,6 +50,9 @@ vm=$(get_min_ulimit_v_ env $prog %20f 0) \
 
 mkfifo_or_skip_ fifo
 
+(trap '' PIPE && yes | :) 2>&1 | grep -qF 'Broken pipe' ||
+    skip_ 'trapping SIGPIPE is not supported'
+
 # Disable MALLOC_PERTURB_, to avoid triggering this bug
 # https://bugs.debian.org/481543#77
 export MALLOC_PERTURB_=0
@@ -60,11 +63,11 @@ cleanup_() { kill $pid 2>/dev/null && wait $pid; }
 head -c 10 fifo > out & pid=$!
 
 # Trigger large mem allocation failure
-( ulimit -v $vm && env $prog %20000000f 0 2>err-msg > fifo )
+( trap '' PIPE && ulimit -v $vm && env $prog %20000000f 0 2>err-msg > fifo )
 exit=$?
 
 # Map this longer, and rarer, diagnostic to the common one.
-# printf: cannot perform formatted output: Cannot allocate memory" \
+# printf: cannot perform formatted output: Cannot allocate memory"
 sed 's/cannot perform .*/write error/' err-msg > k && mv k err-msg
 err_msg=$(tr '\n' : < err-msg)
 
@@ -81,6 +84,7 @@ n_out=$(wc -c < out)
 
 case $n_out:$diagnostic:$exit in
   10:n:0) ;; # ok, succeeds w/no diagnostic: FreeBSD 6.1
+  10:y:1) ;; # ok, fails with EPIPE diagnostic: musl libc
   0:y:1)  ;; # ok, glibc-2.8 and newer, when printf(3) fails with ENOMEM
 
   # With MALLOC_PERTURB_=0, this no longer happens.