On 12/06/2013 09:12 PM, Pádraig Brady wrote:
> On 12/06/2013 08:58 PM, Bernhard Voelker wrote:
>> On 12/06/2013 06:45 PM, Pádraig Brady wrote:
> 
>>> Even at that the test is still brittle,
>>> as the guard only checks that `strace -e stat` works.
>>> Also it's conceivable that on some edge cases there
>>> may be more than one stat call used in this case.
>>
>> I must confess that I don't understand this, i.e. in which circumstances
>> this test would fail as it has been working long enough, and now just
>> is ported to another architecture.
> 
> So I'm worried that the system might have a version
> of strace that doesn't support say newfstatat for example.
> Now my removing of the -e ... above will avoid the immediate:
>   strace: invalid system call `newfstatat'
> But strace may then output something that `grep stat..` doesn't match,
> thuse messing up the counts and failing the test.
> 
> I'll sleep on it as I'm rushing off now.

I going with the attached which should handle everything,
even diagnosis of unhandled "stat" calls.

thanks,
Pádraig.

>From 51c357a9a4fb23d6b3e6b6a7134314bf427e6a10 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]>
Date: Sat, 7 Dec 2013 15:00:06 +0000
Subject: [PATCH] tests: fix false failure on platforms using newfstatat

* tests/ls/stat-free-color.sh: Add newfstatat to the list
of syscalls to trace.  Also add all "stat" syscalls to the
list of syscalls that we verify that strace supports.
Also only create a single dangling symlink to check, since
we already only check for a single "stat" call.
Fixes http://bugs.gnu.org/16075
---
 tests/ls/stat-free-color.sh |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/tests/ls/stat-free-color.sh b/tests/ls/stat-free-color.sh
index 3aacf96..5fd5bea 100755
--- a/tests/ls/stat-free-color.sh
+++ b/tests/ls/stat-free-color.sh
@@ -18,12 +18,16 @@
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ ls
-require_strace_ stat
+
+# Note this list of _file name_ stat functions must be
+# as cross platform as possible and so doesn't include
+# fstatat64 as that's not available on aarch64 for example.
+stats='stat,lstat,stat64,lstat64,newfstatat'
+
+require_strace_ $stats
 require_dirent_d_type_
 
-for i in 1 2 3; do
-  ln -s nowhere dangle-$i || framework_failure_
-done
+ln -s nowhere dangle || framework_failure_
 
 # Disable enough features via LS_COLORS so that ls --color
 # can do its job without calling stat (other than the obligatory
@@ -53,17 +57,18 @@ eval $(dircolors -b color-without-stat)
 # To avoid counting those, first get a baseline count by running
 # ls with only the --help option.  Then, compare that with the
 # invocation under test.
-strace -o log-help -e stat,lstat,stat64,lstat64 ls --help >/dev/null || fail=1
+strace -o log-help -e $stats ls --help >/dev/null || fail=1
 n_lines_help=$(wc -l < log-help)
 
-strace -o log -e stat,lstat,stat64,lstat64 ls --color=always . || fail=1
+strace -o log -e $stats ls --color=always . || fail=1
 n_lines=$(wc -l < log)
 
 n_stat=$(expr $n_lines - $n_lines_help)
 
-# Expect one or two stat calls.
+# Expect one stat call.
 case $n_stat in
-  1) ;;
+  0) skip_ 'No stat calls recognized on this platform' ;;
+  1) ;; # Corresponding to stat(".")
   *) fail=1; head -n30 log* ;;
 esac
 
-- 
1.7.7.6

Reply via email to