[LTP] [PATCH 2/2] setitimer03: convert to new API

Richard Palethorpe rpalethorpe@suse.de
Thu Oct 20 10:17:00 CEST 2022


Hello,

Li Wang <liwang@redhat.com> writes:

> Combine this EINVAL test into setitimer02 and add one additional
> ITIMER_VIRTUAL verification.

EINVAL is not mentioned in the test description.

>
> Signed-off-by: Li Wang <liwang@redhat.com>
> ---
>  runtest/syscalls                              |   1 -
>  .../kernel/syscalls/setitimer/.gitignore      |   1 -
>  .../kernel/syscalls/setitimer/setitimer02.c   |  30 +++-
>  .../kernel/syscalls/setitimer/setitimer03.c   | 158 ------------------
>  4 files changed, 24 insertions(+), 166 deletions(-)
>  delete mode 100644 testcases/kernel/syscalls/setitimer/setitimer03.c
>
> diff --git a/runtest/syscalls b/runtest/syscalls
> index 61a7b7677..2d673836d 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -1325,7 +1325,6 @@ sethostname03 sethostname03
>  
>  setitimer01 setitimer01
>  setitimer02 setitimer02
> -setitimer03 setitimer03
>  
>  setns01 setns01
>  setns02 setns02
> diff --git a/testcases/kernel/syscalls/setitimer/.gitignore b/testcases/kernel/syscalls/setitimer/.gitignore
> index 048db9b31..35779a32c 100644
> --- a/testcases/kernel/syscalls/setitimer/.gitignore
> +++ b/testcases/kernel/syscalls/setitimer/.gitignore
> @@ -1,3 +1,2 @@
>  /setitimer01
>  /setitimer02
> -/setitimer03
> diff --git a/testcases/kernel/syscalls/setitimer/setitimer02.c b/testcases/kernel/syscalls/setitimer/setitimer02.c
> index 9ac9ce1fa..ccba231c9 100644
> --- a/testcases/kernel/syscalls/setitimer/setitimer02.c
> +++ b/testcases/kernel/syscalls/setitimer/setitimer02.c
> @@ -18,17 +18,33 @@
>  #include "tst_test.h"
>  #include "lapi/syscalls.h"
>  
> -static struct itimerval *value;
> +static struct itimerval *value, *ovalue;
> +
> +static struct tcase {
> +       int which;
> +       struct itimerval **val;
> +       struct itimerval **oval;
> +       int exp_errno;

There is a whitespace error here (see checkpatch/make check)

> +} tcases[] = {
> +       {ITIMER_REAL,    &value, &ovalue, EFAULT},
> +       {ITIMER_VIRTUAL, &value, &ovalue, EFAULT},
> +       {-ITIMER_PROF,   &value, &ovalue, EINVAL},
> +};

Why do we need value and ovalue in the struct?

>  
>  static int sys_setitimer(int which, void *new_value, void *old_value)
>  {
>  	return tst_syscall(__NR_setitimer, which, new_value, old_value);
>  }
>  
> -static void verify_setitimer(void)
> +static void verify_setitimer(unsigned int i)
>  {
> -	TST_EXP_FAIL(sys_setitimer(ITIMER_REAL, value, (struct itimerval *)-1),
> -	             EFAULT);
> +        struct tcase *tc = &tcases[i];
> +
> +	if (tc->exp_errno == EFAULT)
> +		*(tc->oval) = (struct itimerval *)-1;

Or, why do we use an if statement here instead of defining it in the struct?

-- 
Thank you,
Richard.


More information about the ltp mailing list