]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: stat-free-color: do not count stat calls before main
authorBernhard Voelker <mail@bernhard-voelker.de>
Tue, 21 Jun 2011 14:26:50 +0000 (16:26 +0200)
committerJim Meyering <meyering@redhat.com>
Wed, 22 Jun 2011 14:06:52 +0000 (16:06 +0200)
* tests/ls/stat-free-color: The system may perform additional stat
calls upon loading (seen on OpenSuSE-11.4).  Count only the number
of stat calls compared to --help.
This also reduces back to "1" the number of expected calls,
effectively reverting part of 2011-06-01 commit, ccf2d9a4.

tests/ls/stat-free-color

index b1c474428e0cb9f0f51140943f8a9e9db3056ec0..1288560ff30649c9a179d5d32d19608b424ad715 100755 (executable)
@@ -49,13 +49,22 @@ MULTIHARDLINK 00
 EOF
 eval $(dircolors -b color-without-stat)
 
+# The system may perform additional stat-like calls before main.
+# 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
+n_lines_help=$(wc -l < log-help)
+
 strace -o log -e stat,lstat,stat64,lstat64 ls --color=always . || fail=1
 n_lines=$(wc -l < log)
 
+n_stat=$(expr $n_lines - $n_lines_help)
+
 # Expect one or two stat calls.
-case $n_lines in
-  1|2) ;;
-  *) fail=1 ;;
+case $n_stat in
+  1) ;;
+  *) fail=1; head -n30 log* ;;
 esac
 
 Exit $fail