[LTP] [PATCH 1/1] getrlimit03: Simplify TCONF code
Li Wang
liwang@redhat.com
Fri Jul 18 14:48:59 CEST 2025
On Fri, Jul 18, 2025 at 6:31 PM Petr Vorel <pvorel@suse.cz> wrote:
> Hi Li, all,
>
> [ Cc also Steve ]
>
> > Hi Petr,
>
> > On Fri, Jul 18, 2025 at 5:05 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> > > ENOSYS checks added in fac783b5d6 and d071de02e8 are verbose, use
> > > tst_syscall() to handle ENOSYS.
>
> > > Also check for __NR_getrlimit caused TCONF message being printed more
> > > times (RLIM_NLIMITS => 16 on x86_64), which is also fixed by using
> > > tst_syscall().
>
> > > Because it should be safe to not use specific errno variables remove
> > > errno_l and errno_ul.
>
> > > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > > ---
> > > Hi all,
>
> > > @Tiezhu can you please test this patch?
> > > @Li Hope I did not overlook anything.
>
> > > Kind regards,
> > > Petr
>
> > > .../kernel/syscalls/getrlimit/getrlimit03.c | 23 ++++---------------
> > > 1 file changed, 4 insertions(+), 19 deletions(-)
>
> > > diff --git a/testcases/kernel/syscalls/getrlimit/getrlimit03.c
> > > b/testcases/kernel/syscalls/getrlimit/getrlimit03.c
> > > index 846ef3ced6..a2dd0ca79c 100644
> > > --- a/testcases/kernel/syscalls/getrlimit/getrlimit03.c
> > > +++ b/testcases/kernel/syscalls/getrlimit/getrlimit03.c
> > > @@ -77,7 +77,7 @@ struct rlimit_ulong {
>
> > > static int getrlimit_ulong(int resource, struct rlimit_ulong *rlim)
> > > {
> > > - return syscall(__NR_getrlimit_ulong, resource, rlim);
> > > + return tst_syscall(__NR_getrlimit_ulong, resource, rlim);
> > > }
>
> > > const long RLIM_INFINITY_L = LONG_MAX;
> > > @@ -90,7 +90,7 @@ struct rlimit_long {
>
> > > static int getrlimit_long(int resource, struct rlimit_long *rlim)
> > > {
> > > - return syscall(__NR_getrlimit, resource, rlim);
> > > + return tst_syscall(__NR_getrlimit, resource, rlim);
>
>
> > I guess at least we should avoid using tst_syscall() in gerlimit_long,
> > because it will miss (break with TCONF) the next getrlimit_ulong tests
> > when running an aarch32 user binary on 64bit kernel:
> >
> https://github.com/linux-test-project/ltp/commit/fac783b5d6631efa70d2ea3257142763d944ba32
>
> Thanks, I did miss the point of this commit when I looked into it earlier.
> Reading again the code and commit messages of both commits.
>
> I suppose you're right it's safe to quit getrlimit_ulong() via
> tst_syscall()
> because it's either old arch which has always getrlimit() syscall or new
> arch
> which has always ugetrlimit() syscall. In that case we can leave the code
> as is
> or add tst_syscall() to getrlimit_ulong() + explanation at gerlimit_long()
> why
> tst_syscall() is not used.
>
That's right, and I am fine with both way.
> And if I'm wrong and it's not safe to quit getrlimit_ulong() with
> tst_syscall(),
> then we should remove test.tcnt = 1 added recently.
> Kind regards,
> Petr
>
> > > }
> > > #endif
>
> > > @@ -147,12 +147,10 @@ static void run(unsigned int resource)
>
> > > struct rlimit_ulong rlim_ul;
> > > int ret_ul;
> > > - int errno_ul;
>
> > > #ifdef SIGNED_GETRLIMIT
> > > struct rlimit_long rlim_l;
> > > int ret_l;
> > > - int errno_l;
> > > #endif
>
> > > errno = 0;
> > > @@ -161,15 +159,8 @@ static void run(unsigned int resource)
>
> > > errno = 0;
> > > ret_ul = getrlimit_ulong(resource, &rlim_ul);
> > > - errno_ul = errno;
> > > - if (errno_ul == ENOSYS) {
> > > - tst_res(TCONF | TERRNO,
> > > - "%s not implemented",
> __NR_getrlimit_ulong_str);
> > > - test.tcnt = 1;
> > > - return;
> > > - }
>
> > > - if (compare_retval(resource, ret_u64, errno_u64, ret_ul,
> errno_ul,
> > > + if (compare_retval(resource, ret_u64, errno_u64, ret_ul, errno,
> > > __NR_getrlimit_ulong_str) ||
> > > compare_u64_ulong(resource, rlim_u64.rlim_cur,
> > > rlim_ul.rlim_cur,
> > > "rlim_cur") ||
> > > @@ -183,14 +174,8 @@ static void run(unsigned int resource)
> > > #ifdef SIGNED_GETRLIMIT
> > > errno = 0;
> > > ret_l = getrlimit_long(resource, &rlim_l);
> > > - errno_l = errno;
> > > - if (errno_l == ENOSYS) {
> > > - tst_res(TCONF | TERRNO,
> > > - "__NR_getrlimit(%d) not implemented",
> > > __NR_getrlimit);
> > > - return;
> > > - }
>
> > > - if (compare_retval(resource, ret_u64, errno_u64, ret_l,
> errno_l,
> > > + if (compare_retval(resource, ret_u64, errno_u64, ret_l, errno,
> > > "__NR_getrlimit") ||
> > > compare_u64_long(resource, rlim_u64.rlim_cur,
> rlim_l.rlim_cur,
> > > "rlim_cur") ||
> > > --
> > > 2.50.0
>
>
--
Regards,
Li Wang
More information about the ltp
mailing list