[LTP] [PATCH] syscalls/fstatat01: fix test on x86_64 arch

Alexey Kodanev alexey.kodanev@oracle.com
Wed Mar 9 11:14:08 CET 2016


On 03/09/2016 12:49 PM, Jan Stancek wrote:
>
> ----- Original Message -----
>> From: "Alexey Kodanev" <alexey.kodanev@oracle.com>
>> To: "Jan Stancek" <jstancek@redhat.com>
>> Cc: ltp@lists.linux.it, "vasily isaenko" <vasily.isaenko@oracle.com>
>> Sent: Wednesday, 9 March, 2016 10:47:11 AM
>> Subject: Re: [LTP] [PATCH] syscalls/fstatat01: fix test on x86_64 arch
>>
>> Hi,
>> On 03/09/2016 12:18 PM, Jan Stancek wrote:
>>> ...
>>> -/* TODO (garrcoop): properly port to fstatat64. */
>>> -#if (defined __NR_fstatat64) && (__NR_fstatat64 != 0)
>>> -struct stat64 statbuf;
>>> -#else
>>> -struct stat statbuf;
>>> -#endif
>>> -
>>> -/*
>>> - * XXX (garrcoop): NO NO NO NO NO NO NO NO NO ... use
>>> linux_syscall_numbers.h!
>>> - */
>>> -/* __NR_fstatat64 and __NR_fstatat64 if not defined are ALWAYS stubbed by
>>> - *  linux_syscall_numbers.h Need to check for 0 to avoid testing with
>>> stubs
>>> */
>>> -#if (defined __NR_fstatat64) && (__NR_fstatat64 != 0)
>>> -int myfstatat(int dirfd, const char *filename, struct stat64 *statbuf,
>>> -	      int flags)
>>> +#if !defined(HAVE_FSTATAT)
>>> +#if (defined __NR_fstatat64) && (__NR_fstatat64 > 0)
>>> +static struct stat64 statbuf;
>>> +int fstatat(int dirfd, const char *filename, struct stat64 *statbuf, int
>>> flags)
>>>    {
>>>    	return ltp_syscall(__NR_fstatat64, dirfd, filename, statbuf, flags);
>>>    }
>>> -#elif (defined __NR_newfstatat) && (__NR_newfstatat != 0)
>>> -int myfstatat(int dirfd, const char *filename, struct stat *statbuf, int
>>> flags)
>>> +#else
>>> Shouldn't we check that __NR_newfstatat is defined? There seem to be
>>> architectures,
>>> that don't define both fstatat64 and newfstatat.
>> It seems unnecessary... it should be defined in linux_syscall_numbers.h
>> whether
>> it is supported or not. In the last case __NR_newfstatat is defined as
>> __LTP_NR_INVALID_SYSCALL,eventually we'll get TCONF for ltp_syscall(-1,
>> ...).
> You're right, regen.sh will add common stub as long as at least one arch
> defines it (which we do).

Looking at aarch64, it only defines "fstatat 79" and it neither has 
fstatat64
nor newfstatat, so may be we should additionally check _NR_newfstatat in 
the same
way we do for fstatat64. And if both < 0 invoke ltp_syscall with 
__NR_fstatat.

Thanks,
Alexey

> Regards,
> Jan
>
>> Thanks,
>> Alexey
>>
>>> Regards,
>>> Jan
>>>
>>>> +static struct stat statbuf;
>>>> +int fstatat(int dirfd, const char *filename, struct stat *statbuf, int
>>>> flags)
>>>>    {
>>>>    	return ltp_syscall(__NR_newfstatat, dirfd, filename, statbuf, flags);
>>>>    }
>>>> +#endif
>>>>    #else
>>>> -/* stub - will never run */
>>>> -int myfstatat(int dirfd, const char *filename, struct stat *statbuf, int
>>>> flags)
>>>> -{
>>>> -	return ltp_syscall(0, dirfd, filename, statbuf, flags);
>>>> -}
>>>> +static struct stat statbuf;
>>>>    #endif
>>>>    
>>>>    int main(int ac, char **av)
>>>> @@ -104,8 +92,7 @@ int main(int ac, char **av)
>>>>    		tst_count = 0;
>>>>    
>>>>    		for (i = 0; i < TST_TOTAL; i++) {
>>>> -			TEST(myfstatat
>>>> -			     (fds[i], filenames[i], &statbuf, flags[i]));
>>>> +			TEST(fstatat(fds[i], filenames[i], &statbuf, flags[i]));
>>>>    
>>>>    			if (TEST_ERRNO == expected_errno[i]) {
>>>>    				tst_resm(TPASS | TTERRNO,
>>>> --
>>>> 1.7.1
>>>>
>>>>
>>>> --
>>>> Mailing list info: http://lists.linux.it/listinfo/ltp
>>>>
>>



More information about the ltp mailing list