Subject: Re: bug#16075: ls/stat-free-color.sh fails on AArch64 architecture

From: Pádraig Brady <[email-masked]>
Date: Fri, 06 Dec 2013 17:45:13 +0000

On 12/06/2013 05:20 PM, Pádraig Brady wrote:
> On 12/06/2013 04:48 PM, Bernhard Voelker wrote:
>> On 12/06/2013 04:50 PM, Marcin Juszkiewicz wrote:
>>> Test checks for use of stat,lstat,stat64,lstat64 syscalls. But on
>>> AArch64 it is using statfs64 and newfstatat calls so test fails.
>>>
>>> log and log-help attached
>>>
>>> Commands used:
>>> strace -o log ls --color=always >/dev/null
>>> strace -o log-help ls --help >/dev/null
>>
>> Thanks for the bug report.
>> Does adding both system calls as in the following patch help?
>>
>> Thanks & have a nice day,
>> Berny
>>
>>
>> diff --git a/tests/ls/stat-free-color.sh b/tests/ls/stat-free-color.sh
>> index 3aacf96..145c566 100755
>> --- a/tests/ls/stat-free-color.sh
>> +++ b/tests/ls/stat-free-color.sh
>> @@ -53,10 +53,11 @@ 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
>> +stats='stat,lstat,stat64,lstat64,statfs64,newfstatat'
>> +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)
> 
> That would probably work, though perhaps we should
> make this test a bit more general with something like the following?
> 
> Also Marcin, could you try out the latest snapshot (which will
> also need the patch applied). It has another aarch64 specific patch included,
> and it would be great to verify it on this platform.
> Two birds with one stone and all that. Simple test instructions at:
> http://lists.gnu.org/archive/html/coreutils/2013-12/msg00062.html
> 
> diff --git a/tests/ls/stat-free-color.sh b/tests/ls/stat-free-color.sh
> index 3aacf96..4dd7ae7 100755
> --- a/tests/ls/stat-free-color.sh
> +++ b/tests/ls/stat-free-color.sh
> @@ -53,11 +53,11 @@ 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
> -n_lines_help=$(wc -l < log-help)
> +strace -o log-help ls --help >/dev/null || fail=1
> +n_lines_help=$(grep 'stat.*(' log-help | wc -l)
> 
> -strace -o log -e stat,lstat,stat64,lstat64 ls --color=always . || fail=1
> -n_lines=$(wc -l < log)
> +strace -o log ls --color=always . || fail=1
> +n_lines=$(grep 'stat.*(' log | wc -l)
> 
>  n_stat=$(expr $n_lines - $n_lines_help)

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.

So I'd be inclined to drop this from the default test set,
if we can't come up with something more robust.

Pádraig.