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