syscalls/fstatat01: fix test on x86_64 arch
PATCH 1/1 syscalls/fstatat01: fix test on x86_64 arch
Test returns TCONF for x86_64 arch as it tries to invoke a syscall with __NR_fstatat64 which the arch doesn't have. Test macro checks that it != 0, then proceed inside the if block. But it skips the case when it's defined as a stub (-1) for x86_64.
So here are fixes:
* checking that __NR_fstatat64 > 0;
* use glibc wrapper only if it's supported (add 'configure' check);
* remove building *_64 test ('utils/newer_64.mk' include); TST_USE_NEWER64_SYSCALL seems redundant and build process makes the same binary in the end;
* Remove test 'fstatat01_64' from .gitignore and runtest/syscalls.
--- configure.ac | 1 + m4/ltp-fstatat.m4 | 26 ++++++++++++++++++ runtest/syscalls | 1 - testcases/kernel/syscalls/.gitignore | 1 - testcases/kernel/syscalls/fstatat/Makefile | 1 - testcases/kernel/syscalls/fstatat/fstatat01.c | 35 ++++++++----------------- 6 files changed, 38 insertions(+), 27 deletions(-) create mode 100644 m4/ltp-fstatat.m4
configure.ac +1 -0
@@ -161,6 +161,7 @@ LTP_CHECK_XFS_QUOTACTL LTP_CHECK_CLONE_SUPPORTS_7_ARGS LTP_CHECK_MKDIRAT LTP_CHECK_FCHOWNAT +LTP_CHECK_FSTATAT LTP_CHECK_MKNODAT LTP_CHECK_READLINKAT LTP_CHECK_OPENAT
m4/ltp-fstatat.m4 new file +26 -0
@@ -0,0 +1,26 @@ +dnl +dnl Copyright (c) 2016 Oracle and/or its affiliates. All Rights Reserved. +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +dnl the GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program. If not, see <http://www.gnu.org/licenses/>. +dnl +dnl Author: Alexey Kodanev <[email protected]> +dnl + +dnl +dnl LTP_CHECK_FSTATAT +dnl ----------------- +dnl +AC_DEFUN([LTP_CHECK_FSTATAT],[ +AC_CHECK_FUNCS(fstatat,,) +])
runtest/syscalls +0 -1
@@ -305,7 +305,6 @@ fstat05_64 fstat05_64 #fstatat64/newfstatat test cases fstatat01 fstatat01 -fstatat01_64 fstatat01_64 fstatfs01 fstatfs01 fstatfs01_64 fstatfs01_64
testcases/kernel/syscalls/.gitignore +0 -1
@@ -261,7 +261,6 @@ /fstat/fstat05 /fstat/fstat05_64 /fstatat/fstatat01 -/fstatat/fstatat01_64 /fstatfs/fstatfs01 /fstatfs/fstatfs01_64 /fstatfs/fstatfs02
testcases/kernel/syscalls/fstatat/Makefile +0 -1
@@ -19,5 +19,4 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk -include $(abs_srcdir)/../utils/newer_64.mk include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/fstatat/fstatat01.c +11 -24
@@ -33,6 +33,7 @@#include <errno.h> #include <string.h> #include <signal.h> +#include "config.h" #include "test.h" #include "safe_macros.h" #include "linux_syscall_numbers.h"
@@ -58,35 +59,22 @@ static const char *filenames[TEST_CASES];static const int expected_errno[] = {0 ,0 ,ENOTDIR ,EBADF ,EINVAL ,0 };static const int flags[] = {0 ,0 ,0 ,0 ,9999 ,0 }; -/* 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 +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,
Signature · 1 line
1.7.1
PATCH 1/1 syscalls/fstatat01: fix test on x86_64 arch
----- Original Message -----
Quoted 5 lines
From: "Alexey Kodanev" <[email protected]>
To: [email protected]
Cc: "vasily isaenko" <[email protected]>
Sent: Wednesday, 9 March, 2016 9:23:45 AM
Subject: [LTP] [PATCH] syscalls/fstatat01: fix test onx86_64arch
Hi,
Quoted 154 lines
Test returns TCONF for
x86_64arch as it tries to invoke a syscall with__NR_fstatat64which the arch doesn't have. Test macro checks that it != 0, then proceed inside the if block. But it skips the case when it's defined as a stub (-1) forx86_64.So here are fixes:
* checking that
__NR_fstatat64> 0;* use glibc wrapper only if it's supported (add 'configure' check);
* remove building *_64 test ('
utils/newer_64.mk' include);TST_USE_NEWER64_SYSCALLseems redundant and build process makes the same binary in the end;* Remove test '
fstatat01_64' from .gitignore and runtest/syscalls.Signed-off-by Alexey Kodanev <[email protected]>--- configure.ac | 1 + m4/ltp-fstatat.m4 | 26 ++++++++++++++++++ runtest/syscalls | 1 - testcases/kernel/syscalls/.gitignore | 1 - testcases/kernel/syscalls/fstatat/Makefile | 1 - testcases/kernel/syscalls/fstatat/fstatat01.c | 35 ++++++++----------------- 6 files changed, 38 insertions(+), 27 deletions(-) create mode 100644 m4/ltp-fstatat.m4configure.ac +1
-0@@ -161,6 +161,7 @@ LTP_CHECK_XFS_QUOTACTL LTP_CHECK_CLONE_SUPPORTS_7_ARGS LTP_CHECK_MKDIRAT LTP_CHECK_FCHOWNAT +LTP_CHECK_FSTATAT LTP_CHECK_MKNODAT LTP_CHECK_READLINKAT LTP_CHECK_OPENATm4/ltp-fstatat.m4 new file +26
-0@@ -0,0 +1,26 @@ +dnl +dnl Copyright (c) 2016 Oracle and/or its affiliates. All Rights Reserved. +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +dnl the GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program. If not, see <http://www.gnu.org/licenses/>. +dnl +dnl Author: Alexey Kodanev <[email protected]> +dnl + +dnl +dnl LTP_CHECK_FSTATAT +dnl ----------------- +dnl +AC_DEFUN([LTP_CHECK_FSTATAT],[ +AC_CHECK_FUNCS(fstatat,,) +])runtest/syscalls +0
-1@@ -305,7 +305,6 @@ fstat05_64 fstat05_64 #fstatat64/newfstatat test cases fstatat01 fstatat01 -fstatat01_64 fstatat01_64 fstatfs01 fstatfs01 fstatfs01_64 fstatfs01_64testcases/kernel/syscalls/.gitignore +0
-1@@ -261,7 +261,6 @@ /fstat/fstat05 /fstat/fstat05_64 /fstatat/fstatat01 -/fstatat/fstatat01_64 /fstatfs/fstatfs01 /fstatfs/fstatfs01_64 /fstatfs/fstatfs02testcases/kernel/syscalls/fstatat/Makefile +0
-1@@ -19,5 +19,4 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk -include $(abs_srcdir)/../utils/newer_64.mk include $(top_srcdir)/include/mk/generic_leaf_target.mktestcases/kernel/syscalls/fstatat/fstatat01.c +1
-9@@ -33,6 +33,7 @@#include <errno.h> #include <string.h> #include <signal.h> +#include "config.h" #include "test.h" #include "safe_macros.h" #include "linux_syscall_numbers.h" @@ -58,35 +59,22 @@ static const char *filenames[TEST_CASES];static const int expected_errno[] = {0 ,0 ,ENOTDIR ,EBADF ,EINVAL ,0 };static const int flags[] = {0 ,0 ,0 ,0 ,9999 ,0 }; -/* 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_fstatat64and__NR_fstatat64if not defined are ALWAYS stubbed by
- *linux_syscall_numbers.hNeed to check for 0 to avoid testing with stubs */testcases/kernel/syscalls/fstatat/fstatat01.c +4
-3-#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, intflags)
{testcases/kernel/syscalls/fstatat/fstatat01.c +0
-2return 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
Quoted 2 lines
flags)
+#else
Shouldn't we check that __NR_newfstatat is defined? There seem to be architectures, that don't define both fstatat64 and newfstatat.
Regards,
Jan
Quoted 35 lines
testcases/kernel/syscalls/fstatat/fstatat01.c +2
-0+static struct stat statbuf; +int fstatat(int dirfd, const char *filename, struct stat *statbuf, intflags)
{testcases/kernel/syscalls/fstatat/fstatat01.c +1
-2return ltp_syscall(__NR_newfstatat, dirfd, filename, statbuf, flags); } +#endif #else -/* stub - will never run */ -int myfstatat(int dirfd, const char *filename, struct stat *statbuf, intflags)
testcases/kernel/syscalls/fstatat/fstatat01.c +2
-6-{ -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
PATCH 1/1 syscalls/fstatat01: fix test on x86_64 arch
Hi,
Quoted 28 lines · Jan Stancek
...
testcases/kernel/syscalls/fstatat/fstatat01.c +0
-9-/* 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_fstatat64and__NR_fstatat64if not defined are ALWAYS stubbed by
- *linux_syscall_numbers.hNeed to check for 0 to avoid testing with stubs */testcases/kernel/syscalls/fstatat/fstatat01.c +4
-3-#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, intflags)
{
returnltp_syscall(__NR_fstatat64, dirfd, filename, statbuf, flags);
}(quoted diff) +0
-2-#elif (defined __NR_newfstatat) && (__NR_newfstatat != 0) -int myfstatat(int dirfd, const char *filename, struct stat *statbuf, int
Quoted 4 lines
flags)
+#else
Shouldn't we check that__NR_newfstatatis 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, ...).
Thanks,
Alexey
Quoted 39 lines
Regards,
JanQuoted 35 lines
(quoted diff) +2
-0+static struct stat statbuf; +int fstatat(int dirfd, const char *filename, struct stat *statbuf, intflags)
{
returnltp_syscall(__NR_newfstatat, dirfd, filename, statbuf, flags);
}testcases/kernel/syscalls/fstatat/fstatat01.c +1
-2+#endif #else -/* stub - will never run */ -int myfstatat(int dirfd, const char *filename, struct stat *statbuf, intflags)
testcases/kernel/syscalls/fstatat/fstatat01.c +2
-6-{ -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
PATCH 1/1 syscalls/fstatat01: fix test on x86_64 arch
----- Original Message -----
Quoted 40 lines
From: "Alexey Kodanev" <[email protected]>
To: "Jan Stancek" <[email protected]>
Cc: [email protected], "vasily isaenko" <[email protected]>
Sent: Wednesday, 9 March, 2016 10:47:11 AM
Subject: Re: [LTP] [PATCH] syscalls/fstatat01: fix test onx86_64archHi,
Quoted 32 lines · Jan Stancek
...
testcases/kernel/syscalls/fstatat/fstatat01.c +0
-9-/* 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_fstatat64and__NR_fstatat64if not defined are ALWAYS stubbed by
- *linux_syscall_numbers.hNeed to check for 0 to avoid testing with stubs
*/testcases/kernel/syscalls/fstatat/fstatat01.c +4
-3-#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, intflags)
{
returnltp_syscall(__NR_fstatat64, dirfd, filename, statbuf, flags);
}(quoted diff) +0
-2-#elif (defined __NR_newfstatat) && (__NR_newfstatat != 0) -int myfstatat(int dirfd, const char *filename, struct stat *statbuf, intflags)
+#else
Shouldn't we check that__NR_newfstatatis defined? There seem to be
Quoted 8 lines
Quoted 2 lines
architectures,
that don't define both fstatat64 and newfstatat.It seems unnecessary... it should be defined in
linux_syscall_numbers.hwhether
it is supported or not. In the last case__NR_newfstatatis defined as __LTP_NR_INVALID_SYSCALL,eventually we'll get TCONF forltp_syscall(-1, ...).
You're right, regen.sh will add common stub as long as at least one arch defines it (which we do).
Regards,
Jan
Quoted 45 lines
Thanks,
AlexeyQuoted 39 lines
Regards,
JanQuoted 35 lines
(quoted diff) +2
-0+static struct stat statbuf; +int fstatat(int dirfd, const char *filename, struct stat *statbuf, intflags)
{
returnltp_syscall(__NR_newfstatat, dirfd, filename, statbuf, flags);
}testcases/kernel/syscalls/fstatat/fstatat01.c +1
-2+#endif #else -/* stub - will never run */ -int myfstatat(int dirfd, const char *filename, struct stat *statbuf, intflags)
testcases/kernel/syscalls/fstatat/fstatat01.c +2
-6-{ -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
PATCH 1/1 syscalls/fstatat01: fix test on x86_64 arch
Quoted 49 lines · Jan Stancek
----- Original Message -----
Quoted 39 lines
From: "Alexey Kodanev" <[email protected]>
To: "Jan Stancek" <[email protected]>
Cc: [email protected], "vasily isaenko" <[email protected]>
Sent: Wednesday, 9 March, 2016 10:47:11 AM
Subject: Re: [LTP] [PATCH] syscalls/fstatat01: fix test onx86_64archHi,
Quoted 31 lines · Jan Stancek
...
testcases/kernel/syscalls/fstatat/fstatat01.c +0
-9-/* 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_fstatat64and__NR_fstatat64if not defined are ALWAYS stubbed by
- *linux_syscall_numbers.hNeed to check for 0 to avoid testing with stubs
*/testcases/kernel/syscalls/fstatat/fstatat01.c +4
-3-#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, intflags)
{ return ltp_syscall(__NR_fstatat64, dirfd, filename, statbuf, flags); }(quoted diff) +0
-2-#elif (defined __NR_newfstatat) && (__NR_newfstatat != 0) -int myfstatat(int dirfd, const char *filename, struct stat *statbuf, intflags)
+#elseQuoted 8 lines
Quoted 3 lines
Shouldn't we check that
__NR_newfstatatis 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.hwhether
it is supported or not. In the last case__NR_newfstatatis defined as __LTP_NR_INVALID_SYSCALL,eventually we'll get TCONF forltp_syscall(-1, ...).
Quoted 2 lines
You're right,
regen.shwill 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
Quoted 45 lines
Regards,
JanQuoted 42 lines
Thanks,
AlexeyQuoted 38 lines
Regards,
JanQuoted 35 lines
(quoted diff) +2
-0+static struct stat statbuf; +int fstatat(int dirfd, const char *filename, struct stat *statbuf, intflags)
{ return ltp_syscall(__NR_newfstatat, dirfd, filename, statbuf, flags); }testcases/kernel/syscalls/fstatat/fstatat01.c +1
-2+#endif #else -/* stub - will never run */ -int myfstatat(int dirfd, const char *filename, struct stat *statbuf, intflags)
testcases/kernel/syscalls/fstatat/fstatat01.c +2
-6-{ -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