[LTP] [PATCH] getrlimit/getrlimit03: Skip test if __NR_getrlimit not implemented

Li Wang liwang@redhat.com
Tue Jul 8 12:55:06 CEST 2025


On Tue, Jul 8, 2025 at 5:45 PM Wei Gao via ltp <ltp@lists.linux.it> wrote:

> On Tue, Jul 08, 2025 at 03:17:06PM +0800, Tiezhu Yang wrote:
> > In the Linux kernel, LoongArch uses the generic syscall table which
> > is defined in include/uapi/asm-generic/unistd.h, and also there is
> > no __ARCH_WANT_SET_GET_RLIMIT in arch/loongarch/include/asm/unistd.h,
> > so __NR_getrlimit is not implemented on LoongArch.
> >
> > That is to say, getrlimit are superseded with prlimit64. There is no
> > need to compare the return value and errno about the syscall numbers
> > __NR_prlimit64 and __NR_getrlimit, just check this case and then skip
> > the test.
> >
> > Without this patch:
> >
> > $ /opt/ltp/testcases/bin/getrlimit03
> > ...
> > getrlimit03.c:102: TFAIL: __NR_prlimit64(0) returned 0 (SUCCESS) but
> __NR_getrlimit(0) returned -1 (ENOSYS)
> > getrlimit03.c:102: TFAIL: __NR_prlimit64(1) returned 0 (SUCCESS) but
> __NR_getrlimit(1) returned -1 (ENOSYS)
> > getrlimit03.c:102: TFAIL: __NR_prlimit64(2) returned 0 (SUCCESS) but
> __NR_getrlimit(2) returned -1 (ENOSYS)
> > getrlimit03.c:102: TFAIL: __NR_prlimit64(3) returned 0 (SUCCESS) but
> __NR_getrlimit(3) returned -1 (ENOSYS)
> > getrlimit03.c:102: TFAIL: __NR_prlimit64(4) returned 0 (SUCCESS) but
> __NR_getrlimit(4) returned -1 (ENOSYS)
> > getrlimit03.c:102: TFAIL: __NR_prlimit64(5) returned 0 (SUCCESS) but
> __NR_getrlimit(5) returned -1 (ENOSYS)
> > getrlimit03.c:102: TFAIL: __NR_prlimit64(6) returned 0 (SUCCESS) but
> __NR_getrlimit(6) returned -1 (ENOSYS)
> > getrlimit03.c:102: TFAIL: __NR_prlimit64(7) returned 0 (SUCCESS) but
> __NR_getrlimit(7) returned -1 (ENOSYS)
> > getrlimit03.c:102: TFAIL: __NR_prlimit64(8) returned 0 (SUCCESS) but
> __NR_getrlimit(8) returned -1 (ENOSYS)
> > getrlimit03.c:102: TFAIL: __NR_prlimit64(9) returned 0 (SUCCESS) but
> __NR_getrlimit(9) returned -1 (ENOSYS)
> > getrlimit03.c:102: TFAIL: __NR_prlimit64(10) returned 0 (SUCCESS) but
> __NR_getrlimit(10) returned -1 (ENOSYS)
> > getrlimit03.c:102: TFAIL: __NR_prlimit64(11) returned 0 (SUCCESS) but
> __NR_getrlimit(11) returned -1 (ENOSYS)
> > getrlimit03.c:102: TFAIL: __NR_prlimit64(12) returned 0 (SUCCESS) but
> __NR_getrlimit(12) returned -1 (ENOSYS)
> > getrlimit03.c:102: TFAIL: __NR_prlimit64(13) returned 0 (SUCCESS) but
> __NR_getrlimit(13) returned -1 (ENOSYS)
> > getrlimit03.c:102: TFAIL: __NR_prlimit64(14) returned 0 (SUCCESS) but
> __NR_getrlimit(14) returned -1 (ENOSYS)
> > getrlimit03.c:102: TFAIL: __NR_prlimit64(15) returned 0 (SUCCESS) but
> __NR_getrlimit(15) returned -1 (ENOSYS)
> >
> > Summary:
> > passed   0
> > failed   16
> > broken   0
> > skipped  0
> > warnings 0
> >
> > With this patch:
> >
> > $ /opt/ltp/testcases/bin/getrlimit03
> > ...
> > getrlimit03.c:167: TCONF: __NR_getrlimit not implemented: ENOSYS (38)
> > getrlimit03.c:167: TCONF: __NR_getrlimit not implemented: ENOSYS (38)
> > getrlimit03.c:167: TCONF: __NR_getrlimit not implemented: ENOSYS (38)
> > getrlimit03.c:167: TCONF: __NR_getrlimit not implemented: ENOSYS (38)
> > getrlimit03.c:167: TCONF: __NR_getrlimit not implemented: ENOSYS (38)
> > getrlimit03.c:167: TCONF: __NR_getrlimit not implemented: ENOSYS (38)
> > getrlimit03.c:167: TCONF: __NR_getrlimit not implemented: ENOSYS (38)
> > getrlimit03.c:167: TCONF: __NR_getrlimit not implemented: ENOSYS (38)
> > getrlimit03.c:167: TCONF: __NR_getrlimit not implemented: ENOSYS (38)
> > getrlimit03.c:167: TCONF: __NR_getrlimit not implemented: ENOSYS (38)
> > getrlimit03.c:167: TCONF: __NR_getrlimit not implemented: ENOSYS (38)
> > getrlimit03.c:167: TCONF: __NR_getrlimit not implemented: ENOSYS (38)
> > getrlimit03.c:167: TCONF: __NR_getrlimit not implemented: ENOSYS (38)
> > getrlimit03.c:167: TCONF: __NR_getrlimit not implemented: ENOSYS (38)
> > getrlimit03.c:167: TCONF: __NR_getrlimit not implemented: ENOSYS (38)
> > getrlimit03.c:167: TCONF: __NR_getrlimit not implemented: ENOSYS (38)
> >
> > Summary:
> > passed   0
> > failed   0
> > broken   0
> > skipped  16
> > warnings 0
> >
> > How to reproduce:
> >
> > git clone https://github.com/linux-test-project/ltp.git
> > cd ltp
> > make autotools
> > ./configure
> > make all
> > sudo make install
> > /opt/ltp/testcases/bin/getrlimit03
> >
> > Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> > ---
> >  testcases/kernel/syscalls/getrlimit/getrlimit03.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/testcases/kernel/syscalls/getrlimit/getrlimit03.c
> b/testcases/kernel/syscalls/getrlimit/getrlimit03.c
> > index 604082ccf..2d79057da 100644
> > --- a/testcases/kernel/syscalls/getrlimit/getrlimit03.c
> > +++ b/testcases/kernel/syscalls/getrlimit/getrlimit03.c
> > @@ -162,6 +162,11 @@ 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);
> > +             return;
> > +     }
>
> Maybe following change can fix your issue since tst_syscall will
> handle ENOSYS. You can have a try, thanks.
>
> diff --git a/testcases/kernel/syscalls/getrlimit/getrlimit03.c
> b/testcases/kernel/syscalls/getrlimit/getrlimit03.c
> index 604082ccf..aad27a402 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);
>

This might not a good idea, imagine if the testbench defines
SIGNED_GETRLIMIT
with enables an additional getrlimit_long(resource, &rlim_l) test but get
ENOSYS,
then the whole test will be TCONF, which is not what we want.



>  }
>  #endif
>
>
> >
> >       if (compare_retval(resource, ret_u64, errno_u64, ret_ul, errno_ul,
> >                          __NR_getrlimit_ulong_str) ||
> > --
> > 2.48.1
> >
> >
> > --
> > Mailing list info: https://lists.linux.it/listinfo/ltp
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>

-- 
Regards,
Li Wang


More information about the ltp mailing list