On 4/21/21 3:32 PM, Pádraig Brady wrote:
> On 20/04/2021 23:15, Bernhard Voelker wrote:
>> This FP was seen on latest openSUSE - logfile attached.
>> The patch fixes it.  Okay to push?
> 
> Jim also noticed that on Fedora 34.
> 
> Oh so it's stating stdout.
> Could you change the "1" in your commit summary to STDOUT_FILENO
> as that makes the system behavior change more apparent to me at least.

done.

> Also the test is now relaxed a bit as it's no longer really checking regular 
> files.
> Could you instead try changing the first ls in the test
> to `ls -a` to ensure something is output?

Well, in the case ls would do an extra stat on each file in the test directory
(which we actually want to test that this is not the case), then ls would do so
for the 'regf' file and the new file.  So we'd see the test failing as well.
But adding -a for the reference invocation is also good.

Updated patch attached.  OK?

Thanks & have a nice day,
Berny
>From b7091093bb6505c33279f9bc940b2e94763a6e5d Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <[email protected]>
Date: Wed, 21 Apr 2021 00:12:00 +0200
Subject: [PATCH] tests: fix FP in ls/stat-free-color.sh

On newer systems like Fedora 34 and openSUSE Tumbleweed, ls(1) calls
newfstatat(STDOUT_FILENO, ...), but only when there is something to
output.

* tests/ls/stat-free-color.sh: Add -a option to the reference invocation
of ls, thus enforcing something gets output.
---
 tests/ls/stat-free-color.sh | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tests/ls/stat-free-color.sh b/tests/ls/stat-free-color.sh
index 13f41a090..fac609f91 100755
--- a/tests/ls/stat-free-color.sh
+++ b/tests/ls/stat-free-color.sh
@@ -56,12 +56,14 @@ eval $(dircolors -b color-without-stat)
 # The system may perform additional stat-like calls before main.
 # Furthermore, underlying library functions may also implicitly
 # add an extra stat call, e.g. opendir since glibc-2.21-360-g46f894d.
-# To avoid counting those, first get a baseline count for running
-# ls with one empty directory argument.  Then, compare that with the
-# invocation under test.
+# Finally, ls(1) makes a stat call for stdout, but only in the case
+# when there is something to output.
+# To get the comparison right, first get a baseline count for running
+# 'ls -a' with one empty directory argument.  Then, compare that with
+# the invocation under test.
 mkdir d || framework_failure_
 
-strace -q -o log1 -e $stats ls --color=always d || fail=1
+strace -q -o log1 -e $stats ls -a --color=always d || fail=1
 n_stat1=$(grep -vF '+++' log1 | wc -l) || framework_failure_
 
 test $n_stat1 = 0 \
-- 
2.31.1

Reply via email to